[ignition] Create the type feedback vector after bytecode generation
BUG=v8:5832 Review-Url: https://codereview.chromium.org/2627783008 Cr-Commit-Position: refs/heads/master@{#42377}
This commit is contained in:
parent
ac45f88acb
commit
d4ac63de7c
@ -292,24 +292,9 @@ void RecordFunctionCompilation(CodeEventListener::LogEventsAndTags tag,
|
||||
|
||||
void EnsureFeedbackMetadata(CompilationInfo* info) {
|
||||
DCHECK(info->has_shared_info());
|
||||
|
||||
// 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).
|
||||
|
||||
// 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()));
|
||||
TypeFeedbackMetadata::EnsureAllocated(
|
||||
info->isolate(), info->shared_info(),
|
||||
info->literal()->feedback_vector_spec());
|
||||
}
|
||||
|
||||
bool UseTurboFan(Handle<SharedFunctionInfo> shared) {
|
||||
@ -381,10 +366,11 @@ CompilationJob* GetUnoptimizedCompilationJob(CompilationInfo* info) {
|
||||
DCHECK_NOT_NULL(info->literal());
|
||||
DCHECK_NOT_NULL(info->scope());
|
||||
|
||||
EnsureFeedbackMetadata(info);
|
||||
if (ShouldUseIgnition(info)) {
|
||||
// The bytecode generator will take care of feedback metadata creation.
|
||||
return interpreter::Interpreter::NewCompilationJob(info);
|
||||
} else {
|
||||
EnsureFeedbackMetadata(info);
|
||||
return FullCodeGenerator::NewCompilationJob(info);
|
||||
}
|
||||
}
|
||||
|
@ -651,6 +651,14 @@ void BytecodeGenerator::AllocateDeferredConstants(Isolate* isolate) {
|
||||
array_literal->GetOrBuildConstantElements(isolate);
|
||||
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) {
|
||||
|
@ -118,6 +118,26 @@ Handle<TypeFeedbackMetadata> TypeFeedbackMetadata::New(Isolate* isolate,
|
||||
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(
|
||||
const FeedbackVectorSpec* other_spec) const {
|
||||
|
@ -217,6 +217,11 @@ class TypeFeedbackMetadata : public FixedArray {
|
||||
template <typename 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
|
||||
// For gdb debugging.
|
||||
void Print();
|
||||
|
Loading…
Reference in New Issue
Block a user