Commit 28776d01 authored by mstarzinger's avatar mstarzinger Committed by Commit bot

[compiler] Unify EnsureFeedbackMetadata call sites.

This makes sure all call sites allocating and installing the feedback
vector metadata are within the compilation pipeline and avoids spreading
them accross components.

R=leszeks@chromium.org

Review-Url: https://codereview.chromium.org/2631253002
Cr-Commit-Position: refs/heads/master@{#42399}
parent 248d1b3d
...@@ -292,9 +292,24 @@ void RecordFunctionCompilation(CodeEventListener::LogEventsAndTags tag, ...@@ -292,9 +292,24 @@ void RecordFunctionCompilation(CodeEventListener::LogEventsAndTags tag,
void EnsureFeedbackMetadata(CompilationInfo* info) { void EnsureFeedbackMetadata(CompilationInfo* info) {
DCHECK(info->has_shared_info()); DCHECK(info->has_shared_info());
TypeFeedbackMetadata::EnsureAllocated(
info->isolate(), info->shared_info(), // If no type feedback metadata exists, create it. At this point the
info->literal()->feedback_vector_spec()); // 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).
// 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());
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_metadata()->SpecDiffersFrom(
info->literal()->feedback_vector_spec()));
} }
bool UseTurboFan(Handle<SharedFunctionInfo> shared) { bool UseTurboFan(Handle<SharedFunctionInfo> shared) {
...@@ -367,10 +382,8 @@ CompilationJob* GetUnoptimizedCompilationJob(CompilationInfo* info) { ...@@ -367,10 +382,8 @@ CompilationJob* GetUnoptimizedCompilationJob(CompilationInfo* info) {
DCHECK_NOT_NULL(info->scope()); DCHECK_NOT_NULL(info->scope());
if (ShouldUseIgnition(info)) { if (ShouldUseIgnition(info)) {
// The bytecode generator will take care of feedback metadata creation.
return interpreter::Interpreter::NewCompilationJob(info); return interpreter::Interpreter::NewCompilationJob(info);
} else { } else {
EnsureFeedbackMetadata(info);
return FullCodeGenerator::NewCompilationJob(info); return FullCodeGenerator::NewCompilationJob(info);
} }
} }
...@@ -414,6 +427,7 @@ void InstallUnoptimizedCode(CompilationInfo* info) { ...@@ -414,6 +427,7 @@ void InstallUnoptimizedCode(CompilationInfo* info) {
CompilationJob::Status FinalizeUnoptimizedCompilationJob(CompilationJob* job) { CompilationJob::Status FinalizeUnoptimizedCompilationJob(CompilationJob* job) {
CompilationJob::Status status = job->FinalizeJob(); CompilationJob::Status status = job->FinalizeJob();
if (status == CompilationJob::SUCCEEDED) { if (status == CompilationJob::SUCCEEDED) {
EnsureFeedbackMetadata(job->info());
InstallUnoptimizedCode(job->info()); InstallUnoptimizedCode(job->info());
job->RecordUnoptimizedCompilationStats(); job->RecordUnoptimizedCompilationStats();
} }
......
...@@ -648,14 +648,6 @@ void BytecodeGenerator::AllocateDeferredConstants(Isolate* isolate) { ...@@ -648,14 +648,6 @@ void BytecodeGenerator::AllocateDeferredConstants(Isolate* isolate) {
array_literal->GetOrBuildConstantElements(isolate); array_literal->GetOrBuildConstantElements(isolate);
builder()->InsertConstantPoolEntryAt(literal.second, constant_elements); builder()->InsertConstantPoolEntryAt(literal.second, constant_elements);
} }
// TODO(leszeks): ideally there would be no path to here where feedback
// metadata is previously created, and we could create it unconditionally.
// We should investigate again once FCG has shuffled off its mortal coil.
DCHECK(info()->has_shared_info());
TypeFeedbackMetadata::EnsureAllocated(
info()->isolate(), info()->shared_info(),
info()->literal()->feedback_vector_spec());
} }
void BytecodeGenerator::GenerateBytecode(uintptr_t stack_limit) { void BytecodeGenerator::GenerateBytecode(uintptr_t stack_limit) {
......
...@@ -118,27 +118,6 @@ Handle<TypeFeedbackMetadata> TypeFeedbackMetadata::New(Isolate* isolate, ...@@ -118,27 +118,6 @@ Handle<TypeFeedbackMetadata> TypeFeedbackMetadata::New(Isolate* isolate,
return metadata; return metadata;
} }
// static
void TypeFeedbackMetadata::EnsureAllocated(Isolate* isolate,
Handle<SharedFunctionInfo> sfi,
const FeedbackVectorSpec* spec) {
// If no type feedback metadata exists, create it. 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).
// TODO(mvstanton): reintroduce is_empty() predicate to feedback_metadata().
if (sfi->feedback_metadata()->length() == 0 || !sfi->is_compiled()) {
Handle<TypeFeedbackMetadata> feedback_metadata =
TypeFeedbackMetadata::New(isolate, spec);
sfi->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(!sfi->feedback_metadata()->SpecDiffersFrom(spec));
}
bool TypeFeedbackMetadata::SpecDiffersFrom( bool TypeFeedbackMetadata::SpecDiffersFrom(
const FeedbackVectorSpec* other_spec) const { const FeedbackVectorSpec* other_spec) const {
if (other_spec->slots() != slot_count()) { if (other_spec->slots() != slot_count()) {
......
...@@ -217,11 +217,6 @@ class TypeFeedbackMetadata : public FixedArray { ...@@ -217,11 +217,6 @@ class TypeFeedbackMetadata : public FixedArray {
template <typename Spec> template <typename Spec>
static Handle<TypeFeedbackMetadata> New(Isolate* isolate, const Spec* spec); static Handle<TypeFeedbackMetadata> New(Isolate* isolate, const Spec* spec);
// Ensure that the given shared function info has type feedback metadata with
// the given spec.
static void EnsureAllocated(Isolate* isolate, Handle<SharedFunctionInfo> sfi,
const FeedbackVectorSpec* spec);
#ifdef OBJECT_PRINT #ifdef OBJECT_PRINT
// For gdb debugging. // For gdb debugging.
void Print(); void Print();
......
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