| Index: src/compiler.cc
|
| diff --git a/src/compiler.cc b/src/compiler.cc
|
| index acfeaa48ccb303b3722600ed435a8233abcff79e..cd8b75b42a5dc912d7a48e3c6f34b3e36bee2fe6 100644
|
| --- a/src/compiler.cc
|
| +++ b/src/compiler.cc
|
| @@ -619,37 +619,6 @@ void SetExpectedNofPropertiesFromEstimate(Handle<SharedFunctionInfo> shared,
|
| }
|
|
|
|
|
| -static void UpdateSharedFunctionInfo(CompilationInfo* info) {
|
| - // Update the shared function info with the compiled code and the
|
| - // scope info. Please note, that the order of the shared function
|
| - // info initialization is important since set_scope_info might
|
| - // trigger a GC, causing the DCHECK below to be invalid if the code
|
| - // was flushed. By setting the code object last we avoid this.
|
| - Handle<SharedFunctionInfo> shared = info->shared_info();
|
| - Handle<ScopeInfo> scope_info =
|
| - ScopeInfo::Create(info->scope(), info->zone());
|
| - shared->set_scope_info(*scope_info);
|
| -
|
| - Handle<Code> code = info->code();
|
| - CHECK(code->kind() == Code::FUNCTION);
|
| - shared->ReplaceCode(*code);
|
| - if (shared->optimization_disabled()) code->set_optimizable(false);
|
| -
|
| - shared->set_feedback_vector(*info->feedback_vector());
|
| -
|
| - // Set the expected number of properties for instances.
|
| - FunctionLiteral* lit = info->function();
|
| - int expected = lit->expected_property_count();
|
| - SetExpectedNofPropertiesFromEstimate(shared, expected);
|
| -
|
| - // Check the function has compiled code.
|
| - DCHECK(shared->is_compiled());
|
| - shared->set_bailout_reason(lit->dont_optimize_reason());
|
| - shared->set_ast_node_count(lit->ast_node_count());
|
| - shared->set_strict_mode(lit->strict_mode());
|
| -}
|
| -
|
| -
|
| // Sets the function info on a function.
|
| // The start_position points to the first '(' character after the function name
|
| // in the full script source. When counting characters in the script source the
|
| @@ -702,14 +671,33 @@ MUST_USE_RESULT static MaybeHandle<Code> GetUnoptimizedCodeCommon(
|
| CompilationInfo* info) {
|
| VMState<COMPILER> state(info->isolate());
|
| PostponeInterruptsScope postpone(info->isolate());
|
| +
|
| + // Parse and update CompilationInfo with the results.
|
| if (!Parser::Parse(info)) return MaybeHandle<Code>();
|
| - info->SetStrictMode(info->function()->strict_mode());
|
| + Handle<SharedFunctionInfo> shared = info->shared_info();
|
| + FunctionLiteral* lit = info->function();
|
| + shared->set_strict_mode(lit->strict_mode());
|
| + SetExpectedNofPropertiesFromEstimate(shared, lit->expected_property_count());
|
| + shared->set_bailout_reason(lit->dont_optimize_reason());
|
| + shared->set_ast_node_count(lit->ast_node_count());
|
|
|
| + // Compile unoptimized code.
|
| if (!CompileUnoptimizedCode(info)) return MaybeHandle<Code>();
|
| +
|
| + CHECK_EQ(Code::FUNCTION, info->code()->kind());
|
| Compiler::RecordFunctionCompilation(
|
| Logger::LAZY_COMPILE_TAG, info, info->shared_info());
|
| - UpdateSharedFunctionInfo(info);
|
| - DCHECK_EQ(Code::FUNCTION, info->code()->kind());
|
| +
|
| + // Update the shared function info with the scope info. Allocating the
|
| + // ScopeInfo object may cause a GC.
|
| + Handle<ScopeInfo> scope_info = ScopeInfo::Create(info->scope(), info->zone());
|
| + shared->set_scope_info(*scope_info);
|
| +
|
| + // Update the code and feedback vector for the shared function info.
|
| + shared->ReplaceCode(*info->code());
|
| + if (shared->optimization_disabled()) info->code()->set_optimizable(false);
|
| + shared->set_feedback_vector(*info->feedback_vector());
|
| +
|
| return info->code();
|
| }
|
|
|
| @@ -817,7 +805,6 @@ void Compiler::CompileForLiveEdit(Handle<Script> script) {
|
|
|
| info.MarkAsGlobal();
|
| if (!Parser::Parse(&info)) return;
|
| - info.SetStrictMode(info.function()->strict_mode());
|
|
|
| LiveEditFunctionTracker tracker(info.isolate(), info.function());
|
| if (!CompileUnoptimizedCode(&info)) return;
|
| @@ -1192,8 +1179,6 @@ static void InsertCodeIntoOptimizedCodeMap(CompilationInfo* info) {
|
|
|
| static bool CompileOptimizedPrologue(CompilationInfo* info) {
|
| if (!Parser::Parse(info)) return false;
|
| - info->SetStrictMode(info->function()->strict_mode());
|
| -
|
| if (!Rewriter::Rewrite(info)) return false;
|
| if (!Scope::Analyze(info)) return false;
|
| DCHECK(info->scope() != NULL);
|
|
|