Commit 59b9aaf7 authored by Jakob Gruber's avatar Jakob Gruber Committed by V8 LUCI CQ

[compiler] Make SharedFunctionInfo never-ever serialized

Bug: v8:7790
Change-Id: I54eea2deaaa4823b13f8f66e13a1851f951c63c0
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2991241
Commit-Queue: Jakob Gruber <jgruber@chromium.org>
Reviewed-by: 's avatarSantiago Aboy Solanes <solanes@chromium.org>
Cr-Commit-Position: refs/heads/master@{#75464}
parent c3bdc076
...@@ -1942,88 +1942,14 @@ void ScopeInfoData::SerializeScopeInfoChain(JSHeapBroker* broker) { ...@@ -1942,88 +1942,14 @@ void ScopeInfoData::SerializeScopeInfoChain(JSHeapBroker* broker) {
class SharedFunctionInfoData : public HeapObjectData { class SharedFunctionInfoData : public HeapObjectData {
public: public:
SharedFunctionInfoData(JSHeapBroker* broker, ObjectData** storage, SharedFunctionInfoData(JSHeapBroker* broker, ObjectData** storage,
Handle<SharedFunctionInfo> object); Handle<SharedFunctionInfo> object)
: HeapObjectData(broker, storage, object) {
Builtin builtin_id() const { return builtin_id_; } // TODO(v8:7790): Remove this class once all kNeverSerialized types are
int context_header_size() const { return context_header_size_; } // NeverEverSerialize.
ObjectData* GetBytecodeArray() const { return GetBytecodeArray_; } UNREACHABLE();
SharedFunctionInfo::Inlineability GetInlineability() const {
return inlineability_;
}
void SerializeFunctionTemplateInfo(JSHeapBroker* broker);
ObjectData* scope_info() const { return scope_info_; }
void SerializeScopeInfoChain(JSHeapBroker* broker);
ObjectData* function_template_info() const { return function_template_info_; }
ObjectData* GetTemplateObject(FeedbackSlot slot) const {
auto lookup_it = template_objects_.find(slot.ToInt());
if (lookup_it != template_objects_.cend()) {
return lookup_it->second;
}
return nullptr;
}
void SetTemplateObject(FeedbackSlot slot, ObjectData* object) {
CHECK(
template_objects_.insert(std::make_pair(slot.ToInt(), object)).second);
} }
#define DECL_ACCESSOR(type, name) \
type name() const { return name##_; }
BROKER_SFI_FIELDS(DECL_ACCESSOR)
#undef DECL_ACCESSOR
private:
Builtin const builtin_id_;
int const context_header_size_;
ObjectData* const GetBytecodeArray_;
#define DECL_MEMBER(type, name) type const name##_;
BROKER_SFI_FIELDS(DECL_MEMBER)
#undef DECL_MEMBER
SharedFunctionInfo::Inlineability const inlineability_;
ObjectData* function_template_info_;
ZoneMap<int, ObjectData*> template_objects_;
ObjectData* scope_info_;
}; };
SharedFunctionInfoData::SharedFunctionInfoData(
JSHeapBroker* broker, ObjectData** storage,
Handle<SharedFunctionInfo> object)
: HeapObjectData(broker, storage, object),
builtin_id_(object->HasBuiltinId() ? object->builtin_id()
: Builtin::kNoBuiltinId),
context_header_size_(object->scope_info().ContextHeaderLength()),
GetBytecodeArray_(object->HasBytecodeArray()
? broker->GetOrCreateData(
object->GetBytecodeArray(broker->isolate()))
: nullptr)
#define INIT_MEMBER(type, name) , name##_(object->name())
BROKER_SFI_FIELDS(INIT_MEMBER)
#undef INIT_MEMBER
,
inlineability_(
object->GetInlineability(broker->isolate(), broker->is_turboprop())),
function_template_info_(nullptr),
template_objects_(broker->zone()),
scope_info_(nullptr) {
DCHECK_EQ(HasBuiltinId_, builtin_id_ != Builtin::kNoBuiltinId);
DCHECK_EQ(HasBytecodeArray_, GetBytecodeArray_ != nullptr);
}
void SharedFunctionInfoData::SerializeFunctionTemplateInfo(
JSHeapBroker* broker) {
if (function_template_info_) return;
function_template_info_ = broker->GetOrCreateData(
Handle<SharedFunctionInfo>::cast(object())->function_data(kAcquireLoad));
}
void SharedFunctionInfoData::SerializeScopeInfoChain(JSHeapBroker* broker) {
if (scope_info_) return;
scope_info_ = broker->GetOrCreateData(
Handle<SharedFunctionInfo>::cast(object())->scope_info());
if (!scope_info_->should_access_heap()) {
scope_info_->AsScopeInfo()->SerializeScopeInfoChain(broker);
}
}
class SourceTextModuleData : public HeapObjectData { class SourceTextModuleData : public HeapObjectData {
public: public:
SourceTextModuleData(JSHeapBroker* broker, ObjectData** storage, SourceTextModuleData(JSHeapBroker* broker, ObjectData** storage,
...@@ -2731,6 +2657,7 @@ NEVER_EVER_SERIALIZE(Context) ...@@ -2731,6 +2657,7 @@ NEVER_EVER_SERIALIZE(Context)
NEVER_EVER_SERIALIZE(NativeContext) NEVER_EVER_SERIALIZE(NativeContext)
NEVER_EVER_SERIALIZE(ObjectBoilerplateDescription) NEVER_EVER_SERIALIZE(ObjectBoilerplateDescription)
NEVER_EVER_SERIALIZE(RegExpBoilerplateDescription) NEVER_EVER_SERIALIZE(RegExpBoilerplateDescription)
NEVER_EVER_SERIALIZE(SharedFunctionInfo)
NEVER_EVER_SERIALIZE(TemplateObjectDescription) NEVER_EVER_SERIALIZE(TemplateObjectDescription)
#undef NEVER_EVER_SERIALIZE #undef NEVER_EVER_SERIALIZE
...@@ -3263,6 +3190,9 @@ int BytecodeArrayRef::handler_table_size() const { ...@@ -3263,6 +3190,9 @@ int BytecodeArrayRef::handler_table_size() const {
return BitField::decode(ObjectRef::data()->As##holder()->field()); \ return BitField::decode(ObjectRef::data()->As##holder()->field()); \
} }
#define HEAP_ACCESSOR_C(holder, result, name) \
result holder##Ref::name() const { return object()->name(); }
BIMODAL_ACCESSOR(AllocationSite, Object, nested_site) BIMODAL_ACCESSOR(AllocationSite, Object, nested_site)
BIMODAL_ACCESSOR_C(AllocationSite, bool, CanInlineCall) BIMODAL_ACCESSOR_C(AllocationSite, bool, CanInlineCall)
BIMODAL_ACCESSOR_C(AllocationSite, bool, PointsToLiteral) BIMODAL_ACCESSOR_C(AllocationSite, bool, PointsToLiteral)
...@@ -3483,36 +3413,30 @@ BIMODAL_ACCESSOR_C(ScopeInfo, bool, HasContextExtensionSlot) ...@@ -3483,36 +3413,30 @@ BIMODAL_ACCESSOR_C(ScopeInfo, bool, HasContextExtensionSlot)
BIMODAL_ACCESSOR_C(ScopeInfo, bool, HasOuterScopeInfo) BIMODAL_ACCESSOR_C(ScopeInfo, bool, HasOuterScopeInfo)
BIMODAL_ACCESSOR(ScopeInfo, ScopeInfo, OuterScopeInfo) BIMODAL_ACCESSOR(ScopeInfo, ScopeInfo, OuterScopeInfo)
BIMODAL_ACCESSOR_C(SharedFunctionInfo, Builtin, builtin_id) HEAP_ACCESSOR_C(SharedFunctionInfo, Builtin, builtin_id)
BytecodeArrayRef SharedFunctionInfoRef::GetBytecodeArray() const { BytecodeArrayRef SharedFunctionInfoRef::GetBytecodeArray() const {
if (data_->should_access_heap() || broker()->is_concurrent_inlining()) { BytecodeArray bytecode_array;
BytecodeArray bytecode_array; if (!broker()->IsMainThread()) {
if (!broker()->IsMainThread()) { bytecode_array = object()->GetBytecodeArray(broker()->local_isolate());
bytecode_array = object()->GetBytecodeArray(broker()->local_isolate()); } else {
} else { bytecode_array = object()->GetBytecodeArray(broker()->isolate());
bytecode_array = object()->GetBytecodeArray(broker()->isolate());
}
return MakeRef(broker(), bytecode_array);
} }
return BytecodeArrayRef( return MakeRefAssumeMemoryFence(broker(), bytecode_array);
broker(), ObjectRef::data()->AsSharedFunctionInfo()->GetBytecodeArray());
} }
#define DEF_SFI_ACCESSOR(type, name) \ #define DEF_SFI_ACCESSOR(type, name) \
BIMODAL_ACCESSOR_WITH_FLAG_C(SharedFunctionInfo, type, name) HEAP_ACCESSOR_C(SharedFunctionInfo, type, name)
BROKER_SFI_FIELDS(DEF_SFI_ACCESSOR) BROKER_SFI_FIELDS(DEF_SFI_ACCESSOR)
#undef DEF_SFI_ACCESSOR #undef DEF_SFI_ACCESSOR
SharedFunctionInfo::Inlineability SharedFunctionInfoRef::GetInlineability() SharedFunctionInfo::Inlineability SharedFunctionInfoRef::GetInlineability()
const { const {
if (data_->should_access_heap()) { return broker()->IsMainThread()
if (!broker()->IsMainThread()) { ? object()->GetInlineability(broker()->isolate(),
return object()->GetInlineability(broker()->local_isolate(), broker()->is_turboprop())
broker()->is_turboprop()); : object()->GetInlineability(broker()->local_isolate(),
} else { broker()->is_turboprop());
return object()->GetInlineability(broker()->isolate(),
broker()->is_turboprop());
}
}
return ObjectRef::data()->AsSharedFunctionInfo()->GetInlineability();
} }
base::Optional<FeedbackVectorRef> FeedbackCellRef::value() const { base::Optional<FeedbackVectorRef> FeedbackCellRef::value() const {
...@@ -4308,41 +4232,19 @@ CodeRef JSFunctionRef::code() const { ...@@ -4308,41 +4232,19 @@ CodeRef JSFunctionRef::code() const {
return CodeRef(broker(), ObjectRef::data()->AsJSFunction()->code()); return CodeRef(broker(), ObjectRef::data()->AsJSFunction()->code());
} }
void SharedFunctionInfoRef::SerializeFunctionTemplateInfo() {
if (data_->should_access_heap()) return;
CHECK_EQ(broker()->mode(), JSHeapBroker::kSerializing);
data()->AsSharedFunctionInfo()->SerializeFunctionTemplateInfo(broker());
}
void SharedFunctionInfoRef::SerializeScopeInfoChain() {
if (data_->should_access_heap()) return;
CHECK_EQ(broker()->mode(), JSHeapBroker::kSerializing);
data()->AsSharedFunctionInfo()->SerializeScopeInfoChain(broker());
}
base::Optional<FunctionTemplateInfoRef> base::Optional<FunctionTemplateInfoRef>
SharedFunctionInfoRef::function_template_info() const { SharedFunctionInfoRef::function_template_info() const {
if (data_->should_access_heap()) { if (!object()->IsApiFunction()) return {};
if (!object()->IsApiFunction()) return {}; return TryMakeRef(broker(), FunctionTemplateInfo::cast(
return TryMakeRef(broker(), FunctionTemplateInfo::cast( object()->function_data(kAcquireLoad)));
object()->function_data(kAcquireLoad)));
}
ObjectData* function_template_info =
data()->AsSharedFunctionInfo()->function_template_info();
if (!function_template_info) return base::nullopt;
return FunctionTemplateInfoRef(broker(), function_template_info);
} }
int SharedFunctionInfoRef::context_header_size() const { int SharedFunctionInfoRef::context_header_size() const {
IF_ACCESS_FROM_HEAP_C(scope_info().ContextHeaderLength); return object()->scope_info().ContextHeaderLength();
return data()->AsSharedFunctionInfo()->context_header_size();
} }
ScopeInfoRef SharedFunctionInfoRef::scope_info() const { ScopeInfoRef SharedFunctionInfoRef::scope_info() const {
if (data_->should_access_heap()) { return MakeRef(broker(), object()->scope_info());
return MakeRef(broker(), object()->scope_info());
}
return ScopeInfoRef(broker(), data()->AsSharedFunctionInfo()->scope_info());
} }
void JSObjectRef::SerializeObjectCreateMap() { void JSObjectRef::SerializeObjectCreateMap() {
...@@ -4518,8 +4420,14 @@ unsigned CodeRef::GetInlinedBytecodeSize() const { ...@@ -4518,8 +4420,14 @@ unsigned CodeRef::GetInlinedBytecodeSize() const {
#undef BIMODAL_ACCESSOR #undef BIMODAL_ACCESSOR
#undef BIMODAL_ACCESSOR_B #undef BIMODAL_ACCESSOR_B
#undef BIMODAL_ACCESSOR_C #undef BIMODAL_ACCESSOR_C
#undef BIMODAL_ACCESSOR_WITH_FLAG
#undef BIMODAL_ACCESSOR_WITH_FLAG_B
#undef BIMODAL_ACCESSOR_WITH_FLAG_C
#undef HEAP_ACCESSOR_C
#undef IF_ACCESS_FROM_HEAP #undef IF_ACCESS_FROM_HEAP
#undef IF_ACCESS_FROM_HEAP_C #undef IF_ACCESS_FROM_HEAP_C
#undef IF_ACCESS_FROM_HEAP_WITH_FLAG
#undef IF_ACCESS_FROM_HEAP_WITH_FLAG_C
#undef TRACE #undef TRACE
#undef TRACE_MISSING #undef TRACE_MISSING
......
...@@ -899,6 +899,8 @@ class V8_EXPORT_PRIVATE SharedFunctionInfoRef : public HeapObjectRef { ...@@ -899,6 +899,8 @@ class V8_EXPORT_PRIVATE SharedFunctionInfoRef : public HeapObjectRef {
int context_header_size() const; int context_header_size() const;
BytecodeArrayRef GetBytecodeArray() const; BytecodeArrayRef GetBytecodeArray() const;
SharedFunctionInfo::Inlineability GetInlineability() const; SharedFunctionInfo::Inlineability GetInlineability() const;
base::Optional<FunctionTemplateInfoRef> function_template_info() const;
ScopeInfoRef scope_info() const;
#define DECL_ACCESSOR(type, name) type name() const; #define DECL_ACCESSOR(type, name) type name() const;
BROKER_SFI_FIELDS(DECL_ACCESSOR) BROKER_SFI_FIELDS(DECL_ACCESSOR)
...@@ -907,12 +909,6 @@ class V8_EXPORT_PRIVATE SharedFunctionInfoRef : public HeapObjectRef { ...@@ -907,12 +909,6 @@ class V8_EXPORT_PRIVATE SharedFunctionInfoRef : public HeapObjectRef {
bool IsInlineable() const { bool IsInlineable() const {
return GetInlineability() == SharedFunctionInfo::kIsInlineable; return GetInlineability() == SharedFunctionInfo::kIsInlineable;
} }
void SerializeFunctionTemplateInfo();
base::Optional<FunctionTemplateInfoRef> function_template_info() const;
void SerializeScopeInfoChain();
ScopeInfoRef scope_info() const;
}; };
class StringRef : public NameRef { class StringRef : public NameRef {
......
...@@ -2245,9 +2245,6 @@ void SerializerForBackgroundCompilation::ProcessApiCall( ...@@ -2245,9 +2245,6 @@ void SerializerForBackgroundCompilation::ProcessApiCall(
if (!target_template_info.has_call_code()) return; if (!target_template_info.has_call_code()) return;
target_template_info.SerializeCallCode(); target_template_info.SerializeCallCode();
SharedFunctionInfoRef target_ref = MakeRef(broker(), target);
target_ref.SerializeFunctionTemplateInfo();
if (target_template_info.accept_any_receiver() && if (target_template_info.accept_any_receiver() &&
target_template_info.is_signature_undefined()) { target_template_info.is_signature_undefined()) {
return; return;
...@@ -2893,8 +2890,7 @@ void SerializerForBackgroundCompilation::ProcessCheckContextExtensions( ...@@ -2893,8 +2890,7 @@ void SerializerForBackgroundCompilation::ProcessCheckContextExtensions(
ProcessContextAccess(context_hints, Context::EXTENSION_INDEX, i, ProcessContextAccess(context_hints, Context::EXTENSION_INDEX, i,
kSerializeSlot); kSerializeSlot);
} }
SharedFunctionInfoRef shared = MakeRef(broker(), function().shared()); MakeRef(broker(), function().shared()).scope_info().SerializeScopeInfoChain();
shared.SerializeScopeInfoChain();
} }
void SerializerForBackgroundCompilation::ProcessLdaLookupGlobalSlot( void SerializerForBackgroundCompilation::ProcessLdaLookupGlobalSlot(
......
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