Chromium Code Reviews| Index: src/compiler.cc |
| diff --git a/src/compiler.cc b/src/compiler.cc |
| index 9dea9e414cab3b6dd7761507d36bafd1eef3d3bc..af51d276ce9b40012c27c7a5becce38690ec6004 100644 |
| --- a/src/compiler.cc |
| +++ b/src/compiler.cc |
| @@ -143,12 +143,6 @@ CompilationInfo::CompilationInfo(ParseInfo* parse_info) |
| 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(); |
| } |
| } |
| @@ -222,20 +216,6 @@ bool CompilationInfo::ShouldSelfOptimize() { |
| } |
| -void CompilationInfo::EnsureFeedbackVector() { |
| - if (feedback_vector_.is_null()) { |
| - Handle<TypeFeedbackMetadata> feedback_metadata = |
| - TypeFeedbackMetadata::New(isolate(), literal()->feedback_vector_spec()); |
| - feedback_vector_ = TypeFeedbackVector::New(isolate(), feedback_metadata); |
| - } |
| - |
| - // It's very important that recompiles do not alter the structure of the |
| - // type feedback vector. |
| - CHECK(!feedback_vector_->metadata()->SpecDiffersFrom( |
| - literal()->feedback_vector_spec())); |
| -} |
| - |
| - |
| bool CompilationInfo::has_simple_parameters() { |
| return scope()->has_simple_parameters(); |
| } |
| @@ -784,10 +764,30 @@ void RecordFunctionCompilation(Logger::LogEventsAndTags tag, |
| } |
| } |
| +void EnsureFeedbackVector(CompilationInfo* info) { |
| + if (!info->has_shared_info()) return; |
| + |
| + // If no type feedback vector exists, we create one now. At this point the |
| + // AstNumbering pass has already run. Note that we should reuse any existing |
| + // feedback vector rather than creating a new one. |
| + if (info->shared_info()->feedback_vector()->is_empty()) { |
| + Handle<TypeFeedbackMetadata> feedback_metadata = TypeFeedbackMetadata::New( |
| + info->isolate(), info->literal()->feedback_vector_spec()); |
| + Handle<TypeFeedbackVector> feedback_vector = |
| + TypeFeedbackVector::New(info->isolate(), feedback_metadata); |
| + info->shared_info()->set_feedback_vector(*feedback_vector); |
| + } |
| + |
| + // It's very important that recompiles do not alter the structure of the type |
| + // feedback vector. Verify that the structure fits the function literal. |
| + CHECK(!info->shared_info()->feedback_vector()->metadata()->SpecDiffersFrom( |
| + info->literal()->feedback_vector_spec())); |
| +} |
| + |
| bool CompileUnoptimizedCode(CompilationInfo* info) { |
| DCHECK(AllowCompilation::IsAllowed(info->isolate())); |
| if (!Compiler::Analyze(info->parse_info()) || |
| - !(info->EnsureFeedbackVector(), FullCodeGenerator::MakeCode(info))) { |
| + !(EnsureFeedbackVector(info), FullCodeGenerator::MakeCode(info))) { |
| Isolate* isolate = info->isolate(); |
| if (!isolate->has_pending_exception()) isolate->StackOverflow(); |
| return false; |
| @@ -839,7 +839,7 @@ int CodeAndMetadataSize(CompilationInfo* info) { |
| bool GenerateBaselineCode(CompilationInfo* info) { |
| bool success; |
| - info->EnsureFeedbackVector(); |
| + EnsureFeedbackVector(info); |
| if (FLAG_ignition && UseIgnition(info)) { |
| success = interpreter::Interpreter::MakeBytecode(info); |
| } else { |
| @@ -872,7 +872,6 @@ void InstallBaselineCompilationResult(CompilationInfo* info, |
| DCHECK(!info->code().is_null()); |
| shared->ReplaceCode(*info->code()); |
| shared->set_scope_info(*scope_info); |
| - shared->set_feedback_vector(*info->feedback_vector()); |
| if (info->has_bytecode_array()) { |
| DCHECK(!shared->HasBytecodeArray()); // Only compiled once. |
| shared->set_bytecode_array(*info->bytecode_array()); |
| @@ -1460,11 +1459,10 @@ bool Compiler::EnsureDeoptimizationSupport(CompilationInfo* info) { |
| shared->code()->has_reloc_info_for_serialization()) { |
| unoptimized.PrepareForSerializing(); |
| } |
| - unoptimized.EnsureFeedbackVector(); |
| + EnsureFeedbackVector(&unoptimized); |
| if (!FullCodeGenerator::MakeCode(&unoptimized)) return false; |
| shared->EnableDeoptimizationSupport(*unoptimized.code()); |
| - shared->set_feedback_vector(*unoptimized.feedback_vector()); |
| info->MarkAsCompiled(); |
| @@ -1498,11 +1496,6 @@ void Compiler::CompileForLiveEdit(Handle<Script> script) { |
| LiveEditFunctionTracker tracker(info.isolate(), parse_info.literal()); |
| if (!CompileUnoptimizedCode(&info)) return; |
| - if (info.has_shared_info()) { |
|
Michael Starzinger
2016/04/05 12:55:43
This is genuinely dead code. Drive-by fix unrelate
|
| - Handle<ScopeInfo> scope_info = |
| - ScopeInfo::Create(info.isolate(), info.zone(), info.scope()); |
| - info.shared_info()->set_scope_info(*scope_info); |
| - } |
| tracker.RecordRootFunctionInfo(info.code()); |
| } |