| Index: src/compiler.cc
|
| diff --git a/src/compiler.cc b/src/compiler.cc
|
| index adc038623d0f29561cfe314bea24ef8eb2c8bf2c..083bd798fd24f13415b03440368c37ee52b9f579 100644
|
| --- a/src/compiler.cc
|
| +++ b/src/compiler.cc
|
| @@ -119,14 +119,11 @@
|
| if (FLAG_turbo_splitting) MarkAsSplittingEnabled();
|
| if (FLAG_turbo_types) MarkAsTypingEnabled();
|
|
|
| - if (has_shared_info()) {
|
| - if (shared_info()->is_compiled()) {
|
| - // We should initialize the CompilationInfo feedback vector from the
|
| - // passed in shared info, rather than creating a new one.
|
| - feedback_vector_ = Handle<TypeFeedbackVector>(
|
| - shared_info()->feedback_vector(), parse_info->isolate());
|
| - }
|
| - if (shared_info()->never_compiled()) MarkAsFirstCompile();
|
| + if (has_shared_info() && shared_info()->is_compiled()) {
|
| + // We should initialize the CompilationInfo feedback vector from the
|
| + // passed in shared info, rather than creating a new one.
|
| + feedback_vector_ = Handle<TypeFeedbackVector>(
|
| + shared_info()->feedback_vector(), parse_info->isolate());
|
| }
|
| }
|
|
|
| @@ -1019,9 +1016,6 @@
|
| PostponeInterruptsScope postpone(info.isolate());
|
| VMState<COMPILER> state(info.isolate());
|
|
|
| - // Get rid of old list of shared function infos.
|
| - script->set_shared_function_infos(Smi::FromInt(0));
|
| -
|
| info.parse_info()->set_global();
|
| if (!Parser::ParseStatic(info.parse_info())) return;
|
|
|
| @@ -1082,8 +1076,6 @@
|
| }
|
| }
|
|
|
| - info->MarkAsFirstCompile();
|
| -
|
| FunctionLiteral* lit = info->function();
|
| LiveEditFunctionTracker live_edit_tracker(isolate, lit);
|
|
|
| @@ -1110,7 +1102,7 @@
|
|
|
| DCHECK_EQ(RelocInfo::kNoPosition, lit->function_token_position());
|
| SharedFunctionInfo::InitFromFunctionLiteral(result, lit);
|
| - SharedFunctionInfo::SetScript(result, script);
|
| + result->set_script(*script);
|
| result->set_is_toplevel(true);
|
|
|
| Handle<String> script_name = script->name()->IsString()
|
| @@ -1340,26 +1332,10 @@
|
| }
|
|
|
|
|
| -Handle<SharedFunctionInfo> Compiler::GetSharedFunctionInfo(
|
| +Handle<SharedFunctionInfo> Compiler::BuildFunctionInfo(
|
| FunctionLiteral* literal, Handle<Script> script,
|
| CompilationInfo* outer_info) {
|
| // Precondition: code has been parsed and scopes have been analyzed.
|
| - MaybeHandle<SharedFunctionInfo> maybe_existing;
|
| - if (outer_info->is_first_compile()) {
|
| - // On the first compile, there are no existing shared function info for
|
| - // inner functions yet, so do not try to find them.
|
| - DCHECK(script->FindSharedFunctionInfo(literal).is_null());
|
| - } else {
|
| - maybe_existing = script->FindSharedFunctionInfo(literal);
|
| - }
|
| - // We found an existing shared function info. If it's already compiled,
|
| - // don't worry about compiling it, and simply return it. If it's not yet
|
| - // compiled, continue to decide whether to eagerly compile.
|
| - Handle<SharedFunctionInfo> existing;
|
| - if (maybe_existing.ToHandle(&existing) && existing->is_compiled()) {
|
| - return existing;
|
| - }
|
| -
|
| Zone zone;
|
| ParseInfo parse_info(&zone, script);
|
| CompilationInfo info(&parse_info);
|
| @@ -1367,7 +1343,6 @@
|
| parse_info.set_scope(literal->scope());
|
| parse_info.set_language_mode(literal->scope()->language_mode());
|
| if (outer_info->will_serialize()) info.PrepareForSerializing();
|
| - if (outer_info->is_first_compile()) info.MarkAsFirstCompile();
|
|
|
| Isolate* isolate = info.isolate();
|
| Factory* factory = isolate->factory();
|
| @@ -1421,34 +1396,25 @@
|
| return Handle<SharedFunctionInfo>::null();
|
| }
|
|
|
| - if (maybe_existing.is_null()) {
|
| - // Create a shared function info object.
|
| - Handle<SharedFunctionInfo> result = factory->NewSharedFunctionInfo(
|
| - literal->name(), literal->materialized_literal_count(), literal->kind(),
|
| - info.code(), scope_info, info.feedback_vector());
|
| -
|
| - SharedFunctionInfo::InitFromFunctionLiteral(result, literal);
|
| - SharedFunctionInfo::SetScript(result, script);
|
| - result->set_is_toplevel(false);
|
| -
|
| - RecordFunctionCompilation(Logger::FUNCTION_TAG, &info, result);
|
| - result->set_allows_lazy_compilation(literal->AllowsLazyCompilation());
|
| - result->set_allows_lazy_compilation_without_context(allow_lazy_without_ctx);
|
| -
|
| - // Set the expected number of properties for instances and return
|
| - // the resulting function.
|
| - SetExpectedNofPropertiesFromEstimate(result,
|
| - literal->expected_property_count());
|
| - live_edit_tracker.RecordFunctionInfo(result, literal, info.zone());
|
| - return result;
|
| - } else {
|
| - // We may have additional data from compilation now.
|
| - DCHECK(!existing->is_compiled());
|
| - existing->ReplaceCode(*info.code());
|
| - existing->set_scope_info(*scope_info);
|
| - existing->set_feedback_vector(*info.feedback_vector());
|
| - return existing;
|
| - }
|
| + // Create a shared function info object.
|
| + Handle<SharedFunctionInfo> result = factory->NewSharedFunctionInfo(
|
| + literal->name(), literal->materialized_literal_count(), literal->kind(),
|
| + info.code(), scope_info, info.feedback_vector());
|
| +
|
| + SharedFunctionInfo::InitFromFunctionLiteral(result, literal);
|
| + result->set_script(*script);
|
| + result->set_is_toplevel(false);
|
| +
|
| + RecordFunctionCompilation(Logger::FUNCTION_TAG, &info, result);
|
| + result->set_allows_lazy_compilation(literal->AllowsLazyCompilation());
|
| + result->set_allows_lazy_compilation_without_context(allow_lazy_without_ctx);
|
| +
|
| + // Set the expected number of properties for instances and return
|
| + // the resulting function.
|
| + SetExpectedNofPropertiesFromEstimate(result,
|
| + literal->expected_property_count());
|
| + live_edit_tracker.RecordFunctionInfo(result, literal, info.zone());
|
| + return result;
|
| }
|
|
|
|
|
| @@ -1462,22 +1428,25 @@
|
| return cached_code;
|
| }
|
|
|
| - Isolate* isolate = function->GetIsolate();
|
| + SmartPointer<CompilationInfo> info(new CompilationInfoWithZone(function));
|
| + Isolate* isolate = info->isolate();
|
| DCHECK(AllowCompilation::IsAllowed(isolate));
|
| -
|
| - Handle<SharedFunctionInfo> shared(function->shared(), isolate);
|
| - if (!shared->is_compiled() ||
|
| - shared->scope_info() == ScopeInfo::Empty(isolate)) {
|
| + VMState<COMPILER> state(isolate);
|
| + DCHECK(!isolate->has_pending_exception());
|
| + PostponeInterruptsScope postpone(isolate);
|
| +
|
| + Handle<SharedFunctionInfo> shared = info->shared_info();
|
| + if (shared->code()->kind() != Code::FUNCTION ||
|
| + ScopeInfo::Empty(isolate) == shared->scope_info()) {
|
| // The function was never compiled. Compile it unoptimized first.
|
| // TODO(titzer): reuse the AST and scope info from this compile.
|
| - CompilationInfoWithZone unoptimized(function);
|
| - unoptimized.EnableDeoptimizationSupport();
|
| - if (!GetUnoptimizedCodeCommon(&unoptimized).ToHandle(¤t_code)) {
|
| + CompilationInfoWithZone nested(function);
|
| + nested.EnableDeoptimizationSupport();
|
| + if (!GetUnoptimizedCodeCommon(&nested).ToHandle(¤t_code)) {
|
| return MaybeHandle<Code>();
|
| }
|
| shared->ReplaceCode(*current_code);
|
| }
|
| -
|
| current_code->set_profiler_ticks(0);
|
|
|
| // TODO(mstarzinger): We cannot properly deserialize a scope chain containing
|
| @@ -1491,11 +1460,6 @@
|
| if (shared->is_toplevel() && isolate->bootstrapper()->IsActive()) {
|
| return MaybeHandle<Code>();
|
| }
|
| -
|
| - SmartPointer<CompilationInfo> info(new CompilationInfoWithZone(function));
|
| - VMState<COMPILER> state(isolate);
|
| - DCHECK(!isolate->has_pending_exception());
|
| - PostponeInterruptsScope postpone(isolate);
|
|
|
| info->SetOptimizing(osr_ast_id, current_code);
|
|
|
|
|