Commit 33853f73 authored by yangguo's avatar yangguo Committed by Commit bot

Partially revert "Optimize function across closures."

BUG=chromium:434447

Review URL: https://codereview.chromium.org/755173002

Cr-Commit-Position: refs/heads/master@{#25500}
parent 79045760
...@@ -1555,67 +1555,46 @@ HValue* CodeStubGraphBuilder<FastNewClosureStub>::BuildCodeStub() { ...@@ -1555,67 +1555,46 @@ HValue* CodeStubGraphBuilder<FastNewClosureStub>::BuildCodeStub() {
AddIncrementCounter(counters->fast_new_closure_total()); AddIncrementCounter(counters->fast_new_closure_total());
IfBuilder optimize_now(this); // Create a new closure from the given function info in new space
HInstruction* compile_hint = Add<HLoadNamedField>( HValue* size = Add<HConstant>(JSFunction::kSize);
shared_info, static_cast<HValue*>(NULL), HObjectAccess::ForCompileHint()); HInstruction* js_function =
HValue* hint_mask = Add<HConstant>( Add<HAllocate>(size, HType::JSObject(), NOT_TENURED, JS_FUNCTION_TYPE);
static_cast<int32_t>(1 << SharedFunctionInfo::kOptimizeNextClosure));
HInstruction* optimize = int map_index = Context::FunctionMapIndex(casted_stub()->strict_mode(),
AddUncasted<HBitwise>(Token::BIT_AND, compile_hint, hint_mask); casted_stub()->kind());
optimize_now.If<HCompareNumericAndBranch>(optimize, hint_mask, Token::EQ);
optimize_now.Then(); // Compute the function map in the current native context and set that
{ // as the map of the allocated object.
Add<HPushArguments>(context(), shared_info, graph()->GetConstantFalse()); HInstruction* native_context = BuildGetNativeContext();
Push(Add<HCallRuntime>(isolate()->factory()->empty_string(), HInstruction* map_slot_value =
Runtime::FunctionForId(Runtime::kNewClosure), 3)); Add<HLoadNamedField>(native_context, static_cast<HValue*>(NULL),
} HObjectAccess::ForContextSlot(map_index));
optimize_now.Else(); Add<HStoreNamedField>(js_function, HObjectAccess::ForMap(), map_slot_value);
{
// Create a new closure from the given function info in new space // Initialize the rest of the function.
HValue* size = Add<HConstant>(JSFunction::kSize); Add<HStoreNamedField>(js_function, HObjectAccess::ForPropertiesPointer(),
HInstruction* js_function = empty_fixed_array);
Add<HAllocate>(size, HType::JSObject(), NOT_TENURED, JS_FUNCTION_TYPE); Add<HStoreNamedField>(js_function, HObjectAccess::ForElementsPointer(),
empty_fixed_array);
int map_index = Context::FunctionMapIndex(casted_stub()->strict_mode(), Add<HStoreNamedField>(js_function, HObjectAccess::ForLiteralsPointer(),
casted_stub()->kind()); empty_fixed_array);
Add<HStoreNamedField>(js_function, HObjectAccess::ForPrototypeOrInitialMap(),
// Compute the function map in the current native context and set that graph()->GetConstantHole());
// as the map of the allocated object. Add<HStoreNamedField>(
HInstruction* native_context = BuildGetNativeContext(); js_function, HObjectAccess::ForSharedFunctionInfoPointer(), shared_info);
HInstruction* map_slot_value = Add<HStoreNamedField>(js_function, HObjectAccess::ForFunctionContextPointer(),
Add<HLoadNamedField>(native_context, static_cast<HValue*>(NULL), context());
HObjectAccess::ForContextSlot(map_index));
Add<HStoreNamedField>(js_function, HObjectAccess::ForMap(), map_slot_value); // Initialize the code pointer in the function to be the one
// found in the shared function info object.
// Initialize the rest of the function. // But first check if there is an optimized version for our context.
Add<HStoreNamedField>(js_function, HObjectAccess::ForPropertiesPointer(), if (FLAG_cache_optimized_code) {
empty_fixed_array); BuildInstallFromOptimizedCodeMap(js_function, shared_info, native_context);
Add<HStoreNamedField>(js_function, HObjectAccess::ForElementsPointer(), } else {
empty_fixed_array); BuildInstallCode(js_function, shared_info);
Add<HStoreNamedField>(js_function, HObjectAccess::ForLiteralsPointer(),
empty_fixed_array);
Add<HStoreNamedField>(js_function,
HObjectAccess::ForPrototypeOrInitialMap(),
graph()->GetConstantHole());
Add<HStoreNamedField>(js_function,
HObjectAccess::ForSharedFunctionInfoPointer(),
shared_info);
Add<HStoreNamedField>(
js_function, HObjectAccess::ForFunctionContextPointer(), context());
// Initialize the code pointer in the function to be the one
// found in the shared function info object.
// But first check if there is an optimized version for our context.
if (FLAG_cache_optimized_code) {
BuildInstallFromOptimizedCodeMap(js_function, shared_info,
native_context);
} else {
BuildInstallCode(js_function, shared_info);
}
Push(js_function);
} }
optimize_now.End();
return Pop(); return js_function;
} }
......
...@@ -1387,7 +1387,6 @@ MaybeHandle<Code> Compiler::GetOptimizedCode(Handle<JSFunction> function, ...@@ -1387,7 +1387,6 @@ MaybeHandle<Code> Compiler::GetOptimizedCode(Handle<JSFunction> function,
PostponeInterruptsScope postpone(isolate); PostponeInterruptsScope postpone(isolate);
Handle<SharedFunctionInfo> shared = info->shared_info(); Handle<SharedFunctionInfo> shared = info->shared_info();
shared->set_optimize_next_closure(false);
if (shared->code()->kind() != Code::FUNCTION || if (shared->code()->kind() != Code::FUNCTION ||
ScopeInfo::Empty(isolate) == shared->scope_info()) { ScopeInfo::Empty(isolate) == shared->scope_info()) {
// The function was never compiled. Compile it unoptimized first. // The function was never compiled. Compile it unoptimized first.
......
...@@ -1419,9 +1419,6 @@ Handle<JSFunction> Factory::NewFunctionFromSharedFunctionInfo( ...@@ -1419,9 +1419,6 @@ Handle<JSFunction> Factory::NewFunctionFromSharedFunctionInfo(
if (FLAG_always_opt && ShouldOptimizeNewClosure(isolate(), info)) { if (FLAG_always_opt && ShouldOptimizeNewClosure(isolate(), info)) {
result->MarkForOptimization(); result->MarkForOptimization();
} else if (info->optimize_next_closure() &&
ShouldOptimizeNewClosure(isolate(), info)) {
result->AttemptConcurrentOptimization();
} }
return result; return result;
} }
......
...@@ -6171,18 +6171,6 @@ class HObjectAccess FINAL { ...@@ -6171,18 +6171,6 @@ class HObjectAccess FINAL {
SharedFunctionInfo::kOptimizedCodeMapOffset); SharedFunctionInfo::kOptimizedCodeMapOffset);
} }
static HObjectAccess ForCompileHint() {
// Compile hints are stored in the upper half of a pseudo-smi, which for
// 64-bit means that the representation is an integer.
#if V8_HOST_ARCH_32_BIT
Representation repr = Representation::Smi();
#else
Representation repr = Representation::Integer32();
#endif
return HObjectAccess(kInobject, SharedFunctionInfo::kCompilerHintsOffset,
repr);
}
static HObjectAccess ForFunctionContextPointer() { static HObjectAccess ForFunctionContextPointer() {
return HObjectAccess(kInobject, JSFunction::kContextOffset); return HObjectAccess(kInobject, JSFunction::kContextOffset);
} }
......
...@@ -5612,8 +5612,6 @@ BOOL_ACCESSORS(SharedFunctionInfo, start_position_and_type, is_expression, ...@@ -5612,8 +5612,6 @@ BOOL_ACCESSORS(SharedFunctionInfo, start_position_and_type, is_expression,
BOOL_ACCESSORS(SharedFunctionInfo, start_position_and_type, is_toplevel, BOOL_ACCESSORS(SharedFunctionInfo, start_position_and_type, is_toplevel,
kIsTopLevelBit) kIsTopLevelBit)
BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, optimize_next_closure,
kOptimizeNextClosure)
BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, allows_lazy_compilation, BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, allows_lazy_compilation,
kAllowLazyCompilation) kAllowLazyCompilation)
BOOL_ACCESSORS(SharedFunctionInfo, BOOL_ACCESSORS(SharedFunctionInfo,
......
...@@ -6802,8 +6802,6 @@ class SharedFunctionInfo: public HeapObject { ...@@ -6802,8 +6802,6 @@ class SharedFunctionInfo: public HeapObject {
inline int ic_age(); inline int ic_age();
inline void set_ic_age(int age); inline void set_ic_age(int age);
DECL_BOOLEAN_ACCESSORS(optimize_next_closure)
// Indicates if this function can be lazy compiled. // Indicates if this function can be lazy compiled.
// This is used to determine if we can safely flush code from a function // This is used to determine if we can safely flush code from a function
// when doing GC if we expect that the function will no longer be used. // when doing GC if we expect that the function will no longer be used.
...@@ -7106,7 +7104,6 @@ class SharedFunctionInfo: public HeapObject { ...@@ -7106,7 +7104,6 @@ class SharedFunctionInfo: public HeapObject {
enum CompilerHints { enum CompilerHints {
kAllowLazyCompilation, kAllowLazyCompilation,
kAllowLazyCompilationWithoutContext, kAllowLazyCompilationWithoutContext,
kOptimizeNextClosure,
kOptimizationDisabled, kOptimizationDisabled,
kStrictModeFunction, kStrictModeFunction,
kUsesArguments, kUsesArguments,
......
...@@ -106,7 +106,6 @@ void RuntimeProfiler::Optimize(JSFunction* function, const char* reason) { ...@@ -106,7 +106,6 @@ void RuntimeProfiler::Optimize(JSFunction* function, const char* reason) {
PrintF("]\n"); PrintF("]\n");
} }
function->shared()->set_optimize_next_closure(true);
function->AttemptConcurrentOptimization(); function->AttemptConcurrentOptimization();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment