Chromium Code Reviews| Index: src/compiler.cc |
| diff --git a/src/compiler.cc b/src/compiler.cc |
| index 8eb6ff577308015c0ec7ee0e7984d04d4e43ac81..a1139c83dc7f6ec4e735d81c628a5bd29b72e7c2 100644 |
| --- a/src/compiler.cc |
| +++ b/src/compiler.cc |
| @@ -405,25 +405,25 @@ void RecordFunctionCompilation(Logger::LogEventsAndTags tag, |
| } |
| } |
| -void EnsureFeedbackVector(CompilationInfo* info) { |
| +void EnsureFeedbackMetadata(CompilationInfo* info) { |
| DCHECK(info->has_shared_info()); |
| - // If no type feedback vector exists, we create one now. At this point the |
| + // If no type feedback metadata exists, we create it now. At this point the |
| // AstNumbering pass has already run. Note the snapshot can contain outdated |
| // vectors for a different configuration, hence we also recreate a new vector |
| // when the function is not compiled (i.e. no code was serialized). |
| - if (info->shared_info()->feedback_vector()->is_empty() || |
| + |
| + // TODO(mvstanton): reintroduce is_empty() predicate to feedback_metadata(). |
| + if (info->shared_info()->feedback_metadata()->length() == 0 || |
| !info->shared_info()->is_compiled()) { |
| 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); |
| + info->shared_info()->set_feedback_metadata(*feedback_metadata); |
| } |
| // 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( |
| + CHECK(!info->shared_info()->feedback_metadata()->SpecDiffersFrom( |
| info->literal()->feedback_vector_spec())); |
| } |
| @@ -463,7 +463,7 @@ int CodeAndMetadataSize(CompilationInfo* info) { |
| bool GenerateUnoptimizedCode(CompilationInfo* info) { |
| bool success; |
| - EnsureFeedbackVector(info); |
| + EnsureFeedbackMetadata(info); |
| if (FLAG_ignition && UseIgnition(info)) { |
| success = interpreter::Interpreter::MakeBytecode(info); |
| } else { |
| @@ -516,7 +516,12 @@ MUST_USE_RESULT MaybeHandle<Code> GetUnoptimizedCode(CompilationInfo* info) { |
| // Parse and update CompilationInfo with the results. |
| if (!Parser::ParseStatic(info->parse_info())) return MaybeHandle<Code>(); |
| Handle<SharedFunctionInfo> shared = info->shared_info(); |
| - DCHECK_EQ(shared->language_mode(), info->literal()->language_mode()); |
| + |
| + // TODO(mvstanton): can I eliminate this? MStarzinger got rid of this |
| + // boilerplate stuff before. |
| + FunctionLiteral* lit = info->literal(); |
| + DCHECK_EQ(shared->language_mode(), lit->language_mode()); |
| + shared->set_num_literals(lit->materialized_literal_count()); |
|
Michael Starzinger
2016/05/10 13:47:20
Depending on who computes the literals count for a
mvstanton
2016/05/24 16:31:49
Happily, I could eliminate this piece completely (
|
| // Compile either unoptimized code or bytecode for the interpreter. |
| if (!CompileUnoptimizedCode(info)) return MaybeHandle<Code>(); |
| @@ -634,6 +639,9 @@ bool GetOptimizedCodeNow(CompilationJob* job) { |
| if (!Compiler::ParseAndAnalyze(info->parse_info())) return false; |
| } |
| + EnsureFeedbackMetadata(info); |
| + JSFunction::EnsureLiterals(info->closure()); |
| + |
| TimerEventScope<TimerEventRecompileSynchronous> timer(isolate); |
| TRACE_EVENT0("v8", "V8.RecompileSynchronous"); |
| @@ -678,6 +686,8 @@ bool GetOptimizedCodeLater(CompilationJob* job) { |
| if (!Compiler::ParseAndAnalyze(info->parse_info())) return false; |
| } |
| + JSFunction::EnsureLiterals(info->closure()); |
| + |
| // Reopen handles in the new CompilationHandleScope. |
| info->ReopenHandlesInNewHandleScope(); |
| info->parse_info()->ReopenHandlesInNewHandleScope(); |
| @@ -1123,6 +1133,7 @@ bool Compiler::Compile(Handle<JSFunction> function, ClearExceptionFlag flag) { |
| // Install code on closure. |
| function->ReplaceCode(*code); |
| + JSFunction::EnsureLiterals(function); |
| // Check postconditions on success. |
| DCHECK(!isolate->has_pending_exception()); |
| @@ -1179,6 +1190,7 @@ bool Compiler::CompileOptimized(Handle<JSFunction> function, |
| // Install code on closure. |
| function->ReplaceCode(*code); |
| + JSFunction::EnsureLiterals(function); |
| // Check postconditions on success. |
| DCHECK(!isolate->has_pending_exception()); |
| @@ -1285,7 +1297,7 @@ bool Compiler::EnsureDeoptimizationSupport(CompilationInfo* info) { |
| shared->code()->has_reloc_info_for_serialization()) { |
| unoptimized.PrepareForSerializing(); |
| } |
| - EnsureFeedbackVector(&unoptimized); |
| + EnsureFeedbackMetadata(&unoptimized); |
| if (!FullCodeGenerator::MakeCode(&unoptimized)) return false; |
| // TODO(4280): For now we play it safe and remove the bytecode array when we |
| @@ -1660,7 +1672,7 @@ Handle<SharedFunctionInfo> Compiler::GetSharedFunctionInfoForNative( |
| name, literals, FunctionKind::kNormalFunction, code, |
| Handle<ScopeInfo>(fun->shared()->scope_info())); |
| shared->set_construct_stub(*construct_stub); |
| - shared->set_feedback_vector(fun->shared()->feedback_vector()); |
| + shared->set_feedback_metadata(fun->shared()->feedback_metadata()); |
| // Copy the function data to the shared function info. |
| shared->set_function_data(fun->shared()->function_data()); |
| @@ -1747,21 +1759,11 @@ void Compiler::PostInstantiation(Handle<JSFunction> function, |
| } |
| if (cached.literals != nullptr) { |
| + DCHECK(shared->is_compiled()); |
| function->set_literals(cached.literals); |
| - } else { |
| - Isolate* isolate = function->GetIsolate(); |
| - int number_of_literals = shared->num_literals(); |
| - Handle<LiteralsArray> literals = |
| - LiteralsArray::New(isolate, handle(shared->feedback_vector()), |
| - number_of_literals, pretenure); |
| - function->set_literals(*literals); |
| - |
| - // Cache context-specific literals. |
| - MaybeHandle<Code> code; |
| - if (cached.code != nullptr) code = handle(cached.code); |
| - Handle<Context> native_context(function->context()->native_context()); |
| - SharedFunctionInfo::AddToOptimizedCodeMap(shared, native_context, code, |
| - literals, BailoutId::None()); |
| + } else if (shared->is_compiled()) { |
| + // TODO(mvstanton): pass pretenure flag to EnsureLiterals. |
| + JSFunction::EnsureLiterals(function); |
| } |
| } |