Commit 634a0fd6 authored by Santiago Aboy Solanes's avatar Santiago Aboy Solanes Committed by V8 LUCI CQ

[compiler] Make NeverEverSerialized the default for NeverSerialized

Also:
* Remove forward declare and As##Name for never serialized Data classes
* Remove the Data classes
* Refactor macro list to encode being background or never serialized

Bug: v8:7790
Change-Id: Ide29d89072b247311f29948f04c4147c5c1103cc
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3056458
Commit-Queue: Santiago Aboy Solanes <solanes@chromium.org>
Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#76032}
parent 3a401f3b
...@@ -32,10 +32,6 @@ namespace compiler { ...@@ -32,10 +32,6 @@ namespace compiler {
#define TRACE(broker, x) TRACE_BROKER(broker, x) #define TRACE(broker, x) TRACE_BROKER(broker, x)
#define TRACE_MISSING(broker, x) TRACE_BROKER_MISSING(broker, x) #define TRACE_MISSING(broker, x) TRACE_BROKER_MISSING(broker, x)
#define FORWARD_DECL(Name, ...) class Name##Data;
HEAP_BROKER_OBJECT_LIST(FORWARD_DECL)
#undef FORWARD_DECL
// There are several kinds of ObjectData values. // There are several kinds of ObjectData values.
// //
// kSmi: The underlying V8 object is a Smi and the data is an instance of the // kSmi: The underlying V8 object is a Smi and the data is an instance of the
...@@ -129,12 +125,12 @@ class ObjectData : public ZoneObject { ...@@ -129,12 +125,12 @@ class ObjectData : public ZoneObject {
HeapObject::cast(*object))); HeapObject::cast(*object)));
} }
#define DECLARE_IS(Name, ...) bool Is##Name() const; #define DECLARE_IS(Name) bool Is##Name() const;
HEAP_BROKER_OBJECT_LIST(DECLARE_IS) HEAP_BROKER_OBJECT_LIST(DECLARE_IS)
#undef DECLARE_IS #undef DECLARE_IS
#define DECLARE_AS(Name, ...) Name##Data* As##Name(); #define DECLARE_AS(Name) Name##Data* As##Name();
HEAP_BROKER_OBJECT_LIST(DECLARE_AS) HEAP_BROKER_BACKGROUND_SERIALIZED_OBJECT_LIST(DECLARE_AS)
#undef DECLARE_AS #undef DECLARE_AS
Handle<Object> object() const { return object_; } Handle<Object> object() const { return object_; }
...@@ -203,30 +199,6 @@ class PropertyCellData : public HeapObjectData { ...@@ -203,30 +199,6 @@ class PropertyCellData : public HeapObjectData {
bool serialized() const { return value_ != nullptr; } bool serialized() const { return value_ != nullptr; }
}; };
class FunctionTemplateInfoData : public HeapObjectData {
public:
FunctionTemplateInfoData(JSHeapBroker* broker, ObjectData** storage,
Handle<FunctionTemplateInfo> object)
: HeapObjectData(broker, storage, object) {
// FunctionTemplateInfoData is NeverEverSerialize.
// TODO(solanes, v8:7790): Remove this class once all kNeverSerialized types
// are NeverEverSerialize.
UNREACHABLE();
}
};
class CallHandlerInfoData : public HeapObjectData {
public:
CallHandlerInfoData(JSHeapBroker* broker, ObjectData** storage,
Handle<CallHandlerInfo> object)
: HeapObjectData(broker, storage, object) {
// CallHandlerInfoData is NeverEverSerialize.
// TODO(solanes, v8:7790): Remove this class once all kNeverSerialized types
// are NeverEverSerialize.
UNREACHABLE();
}
};
namespace { namespace {
ZoneVector<Address> GetCFunctions(FixedArray function_overloads, Zone* zone) { ZoneVector<Address> GetCFunctions(FixedArray function_overloads, Zone* zone) {
...@@ -638,18 +610,6 @@ void JSTypedArrayData::Serialize(JSHeapBroker* broker, ...@@ -638,18 +610,6 @@ void JSTypedArrayData::Serialize(JSHeapBroker* broker,
} }
} }
class ArrayBoilerplateDescriptionData : public HeapObjectData {
public:
ArrayBoilerplateDescriptionData(JSHeapBroker* broker, ObjectData** storage,
Handle<ArrayBoilerplateDescription> object)
: HeapObjectData(broker, storage, object) {
// ArrayBoilerplateDescriptionData is NeverEverSerialize.
// TODO(solanes, v8:7790): Remove this class once all kNeverSerialized types
// are NeverEverSerialize.
UNREACHABLE();
}
};
class JSDataViewData : public JSObjectData { class JSDataViewData : public JSObjectData {
public: public:
JSDataViewData(JSHeapBroker* broker, ObjectData** storage, JSDataViewData(JSHeapBroker* broker, ObjectData** storage,
...@@ -792,121 +752,6 @@ class JSFunctionData : public JSObjectData { ...@@ -792,121 +752,6 @@ class JSFunctionData : public JSObjectData {
ObjectData* function_data_ = nullptr; ObjectData* function_data_ = nullptr;
}; };
class RegExpBoilerplateDescriptionData : public HeapObjectData {
public:
RegExpBoilerplateDescriptionData(JSHeapBroker* broker, ObjectData** storage,
Handle<RegExpBoilerplateDescription> object)
: HeapObjectData(broker, storage, object) {
// RegExpBoilerplateDescription is NeverEverSerialize.
// TODO(jgruber): Remove this class once all kNeverSerialized types are
// NeverEverSerialize.
UNREACHABLE();
}
};
class HeapNumberData : public HeapObjectData {
public:
HeapNumberData(JSHeapBroker* broker, ObjectData** storage,
Handle<HeapNumber> object,
ObjectDataKind kind = ObjectDataKind::kSerializedHeapObject)
: HeapObjectData(broker, storage, object, kind) {
// TODO(jgruber): Remove this class once all kNeverSerialized types are
// NeverEverSerialize.
UNREACHABLE();
}
};
class ContextData : public HeapObjectData {
public:
ContextData(JSHeapBroker* broker, ObjectData** storage,
Handle<Context> object)
: HeapObjectData(broker, storage, object) {
// TODO(v8:7790): Remove this class once all kNeverSerialized types are
// NeverEverSerialize.
UNREACHABLE();
}
};
class NativeContextData : public ContextData {
public:
NativeContextData(JSHeapBroker* broker, ObjectData** storage,
Handle<NativeContext> object)
: ContextData(broker, storage, object) {
// TODO(v8:7790): Remove this class once all kNeverSerialized types are
// NeverEverSerialize.
UNREACHABLE();
}
};
class NameData : public HeapObjectData {
public:
NameData(JSHeapBroker* broker, ObjectData** storage, Handle<Name> object)
: HeapObjectData(broker, storage, object) {
// StringData is NeverEverSerialize.
// TODO(solanes, v8:7790): Remove this class once all kNeverSerialized types
// are NeverEverSerialize.
UNREACHABLE();
}
};
class StringData : public NameData {
public:
StringData(JSHeapBroker* broker, ObjectData** storage, Handle<String> object)
: NameData(broker, storage, object) {
// StringData is NeverEverSerialize.
// TODO(solanes, v8:7790): Remove this class once all kNeverSerialized types
// are NeverEverSerialize.
UNREACHABLE();
}
};
class SymbolData : public NameData {
public:
SymbolData(JSHeapBroker* broker, ObjectData** storage, Handle<Symbol> object)
: NameData(broker, storage, object) {
// StringData is NeverEverSerialize.
// TODO(solanes, v8:7790): Remove this class once all kNeverSerialized types
// are NeverEverSerialize.
UNREACHABLE();
}
};
class InternalizedStringData : public StringData {
public:
InternalizedStringData(JSHeapBroker* broker, ObjectData** storage,
Handle<InternalizedString> object)
: StringData(broker, storage, object) {
// InternalizedStringData is NeverEverSerialize.
// TODO(solanes, v8:7790): Remove this class once all kNeverSerialized types
// are NeverEverSerialize.
UNREACHABLE();
}
};
class AccessorInfoData : public HeapObjectData {
public:
AccessorInfoData(JSHeapBroker* broker, ObjectData** storage,
Handle<AccessorInfo> object)
: HeapObjectData(broker, storage, object) {
// AccessorInfoData is NeverEverSerialize.
// TODO(solanes, v8:7790): Remove this class once all kNeverSerialized types
// are NeverEverSerialize.
UNREACHABLE();
}
};
class AllocationSiteData : public HeapObjectData {
public:
AllocationSiteData(JSHeapBroker* broker, ObjectData** storage,
Handle<AllocationSite> object)
: HeapObjectData(broker, storage, object) {
// AllocationSiteData is NeverEverSerialize.
// TODO(solanes, v8:7790): Remove this class once all kNeverSerialized types
// are NeverEverSerialize.
UNREACHABLE();
}
};
class BigIntData : public HeapObjectData { class BigIntData : public HeapObjectData {
public: public:
BigIntData(JSHeapBroker* broker, ObjectData** storage, Handle<BigInt> object, BigIntData(JSHeapBroker* broker, ObjectData** storage, Handle<BigInt> object,
...@@ -1390,41 +1235,6 @@ MapData::MapData(JSHeapBroker* broker, ObjectData** storage, Handle<Map> object, ...@@ -1390,41 +1235,6 @@ MapData::MapData(JSHeapBroker* broker, ObjectData** storage, Handle<Map> object,
} }
} }
class DescriptorArrayData : public HeapObjectData {
public:
DescriptorArrayData(JSHeapBroker* broker, ObjectData** storage,
Handle<DescriptorArray> object)
: HeapObjectData(broker, storage, object) {
// DescriptorArrayData is NeverEverSerialize.
// TODO(solanes, v8:7790): Remove this class once all kNeverSerialized types
// are NeverEverSerialize.
UNREACHABLE();
}
};
class FeedbackCellData : public HeapObjectData {
public:
FeedbackCellData(JSHeapBroker* broker, ObjectData** storage,
Handle<FeedbackCell> object)
: HeapObjectData(broker, storage, object) {
// FeedbackCellData is NeverEverSerialize.
// TODO(solanes, v8:7790): Remove this class once all kNeverSerialized types
// are NeverEverSerialize.
UNREACHABLE();
}
};
class FeedbackVectorData : public HeapObjectData {
public:
FeedbackVectorData(JSHeapBroker* broker, ObjectData** storage,
Handle<FeedbackVector> object)
: HeapObjectData(broker, storage, object) {
// TODO(solanes, v8:7790): Remove this class once all kNeverSerialized types
// are NeverEverSerialize.
UNREACHABLE();
}
};
class FixedArrayBaseData : public HeapObjectData { class FixedArrayBaseData : public HeapObjectData {
public: public:
FixedArrayBaseData(JSHeapBroker* broker, ObjectData** storage, FixedArrayBaseData(JSHeapBroker* broker, ObjectData** storage,
...@@ -1445,20 +1255,6 @@ class FixedArrayData : public FixedArrayBaseData { ...@@ -1445,20 +1255,6 @@ class FixedArrayData : public FixedArrayBaseData {
: FixedArrayBaseData(broker, storage, object, kind) {} : FixedArrayBaseData(broker, storage, object, kind) {}
}; };
class ObjectBoilerplateDescriptionData : public FixedArrayData {
public:
ObjectBoilerplateDescriptionData(
JSHeapBroker* broker, ObjectData** storage,
Handle<ObjectBoilerplateDescription> object,
ObjectDataKind kind = ObjectDataKind::kSerializedHeapObject)
: FixedArrayData(broker, storage, object, kind) {
// ObjectBoilerplateDescriptionData is NeverEverSerialize.
// TODO(solanes, v8:7790): Remove this class once all kNeverSerialized types
// are NeverEverSerialize.
UNREACHABLE();
}
};
// Only used in JSNativeContextSpecialization. // Only used in JSNativeContextSpecialization.
class ScriptContextTableData : public FixedArrayData { class ScriptContextTableData : public FixedArrayData {
public: public:
...@@ -1516,32 +1312,6 @@ JSObjectData::JSObjectData(JSHeapBroker* broker, ObjectData** storage, ...@@ -1516,32 +1312,6 @@ JSObjectData::JSObjectData(JSHeapBroker* broker, ObjectData** storage,
own_constant_elements_(broker->zone()), own_constant_elements_(broker->zone()),
own_properties_(broker->zone()) {} own_properties_(broker->zone()) {}
class FixedDoubleArrayData : public FixedArrayBaseData {
public:
FixedDoubleArrayData(
JSHeapBroker* broker, ObjectData** storage,
Handle<FixedDoubleArray> object,
ObjectDataKind kind = ObjectDataKind::kNeverSerializedHeapObject)
: FixedArrayBaseData(broker, storage, object, kind) {
// TODO(solanes, v8:7790): Remove this class once all kNeverSerialized types
// are NeverEverSerialize.
UNREACHABLE();
}
};
class BytecodeArrayData : public FixedArrayBaseData {
public:
BytecodeArrayData(JSHeapBroker* broker, ObjectData** storage,
Handle<BytecodeArray> object)
: FixedArrayBaseData(broker, storage, object,
ObjectDataKind::kNeverSerializedHeapObject) {
// BytecodeArrayData is NeverEverSerialize.
// TODO(solanes, v8:7790): Remove this class once all kNeverSerialized types
// are NeverEverSerialize.
UNREACHABLE();
}
};
class JSArrayData : public JSObjectData { class JSArrayData : public JSObjectData {
public: public:
JSArrayData(JSHeapBroker* broker, ObjectData** storage, JSArrayData(JSHeapBroker* broker, ObjectData** storage,
...@@ -1601,51 +1371,6 @@ ObjectData* JSArrayData::GetOwnElement(JSHeapBroker* broker, uint32_t index, ...@@ -1601,51 +1371,6 @@ ObjectData* JSArrayData::GetOwnElement(JSHeapBroker* broker, uint32_t index,
return result; return result;
} }
class ScopeInfoData : public HeapObjectData {
public:
ScopeInfoData(JSHeapBroker* broker, ObjectData** storage,
Handle<ScopeInfo> object)
: HeapObjectData(broker, storage, object) {
// TODO(v8:7790): Remove this class once all kNeverSerialized types are
// NeverEverSerialize.
UNREACHABLE();
}
};
class SharedFunctionInfoData : public HeapObjectData {
public:
SharedFunctionInfoData(JSHeapBroker* broker, ObjectData** storage,
Handle<SharedFunctionInfo> object)
: HeapObjectData(broker, storage, object) {
// TODO(v8:7790): Remove this class once all kNeverSerialized types are
// NeverEverSerialize.
UNREACHABLE();
}
};
class SourceTextModuleData : public HeapObjectData {
public:
SourceTextModuleData(JSHeapBroker* broker, ObjectData** storage,
Handle<SourceTextModule> object)
: HeapObjectData(broker, storage, object) {
// SourceTextModuleData is NeverEverSerialize.
// TODO(solanes, v8:7790): Remove this class once all kNeverSerialized types
// are NeverEverSerialize.
UNREACHABLE();
}
};
class CellData : public HeapObjectData {
public:
CellData(JSHeapBroker* broker, ObjectData** storage, Handle<Cell> object)
: HeapObjectData(broker, storage, object) {
// CellData is NeverEverSerialize.
// TODO(solanes, v8:7790): Remove this class once all kNeverSerialized types
// are NeverEverSerialize.
UNREACHABLE();
}
};
class JSGlobalObjectData : public JSObjectData { class JSGlobalObjectData : public JSObjectData {
public: public:
JSGlobalObjectData(JSHeapBroker* broker, ObjectData** storage, JSGlobalObjectData(JSHeapBroker* broker, ObjectData** storage,
...@@ -1729,40 +1454,7 @@ ObjectData* JSGlobalObjectData::GetPropertyCell(JSHeapBroker* broker, ...@@ -1729,40 +1454,7 @@ ObjectData* JSGlobalObjectData::GetPropertyCell(JSHeapBroker* broker,
return result; return result;
} }
class TemplateObjectDescriptionData : public HeapObjectData { #define DEFINE_IS(Name) \
public:
TemplateObjectDescriptionData(JSHeapBroker* broker, ObjectData** storage,
Handle<TemplateObjectDescription> object)
: HeapObjectData(broker, storage, object) {
// TemplateObjectDescriptionData is NeverEverSerialize.
// TODO(solanes, v8:7790): Remove this class once all kNeverSerialized types
// are NeverEverSerialize.
UNREACHABLE();
}
};
class CodeData : public HeapObjectData {
public:
CodeData(JSHeapBroker* broker, ObjectData** storage, Handle<Code> object)
: HeapObjectData(broker, storage, object) {
// TODO(solanes, v8:7790): Remove this class once all kNeverSerialized types
// are NeverEverSerialize.
UNREACHABLE();
}
};
class CodeDataContainerData : public HeapObjectData {
public:
CodeDataContainerData(JSHeapBroker* broker, ObjectData** storage,
Handle<CodeDataContainer> object)
: HeapObjectData(broker, storage, object) {
// TODO(solanes, v8:7790): Remove this class once all kNeverSerialized types
// are NeverEverSerialize.
UNREACHABLE();
}
};
#define DEFINE_IS(Name, ...) \
bool ObjectData::Is##Name() const { \ bool ObjectData::Is##Name() const { \
if (should_access_heap()) { \ if (should_access_heap()) { \
return object()->Is##Name(); \ return object()->Is##Name(); \
...@@ -1775,14 +1467,14 @@ class CodeDataContainerData : public HeapObjectData { ...@@ -1775,14 +1467,14 @@ class CodeDataContainerData : public HeapObjectData {
HEAP_BROKER_OBJECT_LIST(DEFINE_IS) HEAP_BROKER_OBJECT_LIST(DEFINE_IS)
#undef DEFINE_IS #undef DEFINE_IS
#define DEFINE_AS(Name, Kind) \ #define DEFINE_AS(Name) \
Name##Data* ObjectData::As##Name() { \ Name##Data* ObjectData::As##Name() { \
CHECK(Is##Name()); \ CHECK(Is##Name()); \
CHECK(kind_ == kSerializedHeapObject || \ CHECK(kind_ == kSerializedHeapObject || \
kind_ == kBackgroundSerializedHeapObject); \ kind_ == kBackgroundSerializedHeapObject); \
return static_cast<Name##Data*>(this); \ return static_cast<Name##Data*>(this); \
} }
HEAP_BROKER_OBJECT_LIST(DEFINE_AS) HEAP_BROKER_BACKGROUND_SERIALIZED_OBJECT_LIST(DEFINE_AS)
#undef DEFINE_AS #undef DEFINE_AS
ObjectData* JSObjectData::GetInobjectField(int property_index) const { ObjectData* JSObjectData::GetInobjectField(int property_index) const {
...@@ -2143,7 +1835,7 @@ namespace { ...@@ -2143,7 +1835,7 @@ namespace {
template <RefSerializationKind Kind, class DataT, class ObjectT> template <RefSerializationKind Kind, class DataT, class ObjectT>
struct CreateDataFunctor { struct CreateDataFunctor {
bool operator()(JSHeapBroker* broker, RefsMap* refs, Handle<Object> object, void operator()(JSHeapBroker* broker, RefsMap* refs, Handle<Object> object,
RefsMap::Entry** entry_out, ObjectData** object_data_out) { RefsMap::Entry** entry_out, ObjectData** object_data_out) {
USE(broker, refs, object, entry_out, object_data_out); USE(broker, refs, object, entry_out, object_data_out);
UNREACHABLE(); UNREACHABLE();
...@@ -2153,83 +1845,25 @@ struct CreateDataFunctor { ...@@ -2153,83 +1845,25 @@ struct CreateDataFunctor {
template <class DataT, class ObjectT> template <class DataT, class ObjectT>
struct CreateDataFunctor<RefSerializationKind::kBackgroundSerialized, DataT, struct CreateDataFunctor<RefSerializationKind::kBackgroundSerialized, DataT,
ObjectT> { ObjectT> {
bool operator()(JSHeapBroker* broker, RefsMap* refs, Handle<Object> object, void operator()(JSHeapBroker* broker, RefsMap* refs, Handle<Object> object,
RefsMap::Entry** entry_out, ObjectData** object_data_out) { RefsMap::Entry** entry_out, ObjectData** object_data_out) {
RefsMap::Entry* entry = refs->LookupOrInsert(object.address()); RefsMap::Entry* entry = refs->LookupOrInsert(object.address());
*object_data_out = broker->zone()->New<DataT>( *object_data_out = broker->zone()->New<DataT>(
broker, &entry->value, Handle<ObjectT>::cast(object), broker, &entry->value, Handle<ObjectT>::cast(object),
kBackgroundSerializedHeapObject); kBackgroundSerializedHeapObject);
*entry_out = entry; *entry_out = entry;
return true;
} }
}; };
template <class T> template <class ObjectT>
bool NeverEverSerialize() { struct CreateDataFunctor<RefSerializationKind::kNeverSerialized, ObjectData,
return false;
}
// This list is to help with the transition of kNeverSerialize types (which are
// currently still serialized if concurrent inlining is disabled) to actually
// be never serialized. It should be removed once all types have been migrated
// here.
#define NEVER_EVER_SERIALIZE(Type) \
template <> \
bool NeverEverSerialize<Type>() { \
return true; \
}
NEVER_EVER_SERIALIZE(AccessorInfo)
NEVER_EVER_SERIALIZE(AllocationSite)
NEVER_EVER_SERIALIZE(ArrayBoilerplateDescription)
NEVER_EVER_SERIALIZE(BytecodeArray)
NEVER_EVER_SERIALIZE(Cell)
NEVER_EVER_SERIALIZE(CallHandlerInfo)
NEVER_EVER_SERIALIZE(Code)
NEVER_EVER_SERIALIZE(CodeDataContainer)
NEVER_EVER_SERIALIZE(Context)
NEVER_EVER_SERIALIZE(DescriptorArray)
NEVER_EVER_SERIALIZE(FeedbackCell)
NEVER_EVER_SERIALIZE(FeedbackVector)
NEVER_EVER_SERIALIZE(FixedDoubleArray)
NEVER_EVER_SERIALIZE(FunctionTemplateInfo)
NEVER_EVER_SERIALIZE(HeapNumber)
NEVER_EVER_SERIALIZE(InternalizedString)
NEVER_EVER_SERIALIZE(Name)
NEVER_EVER_SERIALIZE(NativeContext)
NEVER_EVER_SERIALIZE(ObjectBoilerplateDescription)
NEVER_EVER_SERIALIZE(RegExpBoilerplateDescription)
NEVER_EVER_SERIALIZE(SharedFunctionInfo)
NEVER_EVER_SERIALIZE(ScopeInfo)
NEVER_EVER_SERIALIZE(SourceTextModule)
NEVER_EVER_SERIALIZE(String)
NEVER_EVER_SERIALIZE(Symbol)
NEVER_EVER_SERIALIZE(TemplateObjectDescription)
#undef NEVER_EVER_SERIALIZE
template <class DataT, class ObjectT>
struct CreateDataFunctor<RefSerializationKind::kNeverSerialized, DataT,
ObjectT> { ObjectT> {
bool operator()(JSHeapBroker* broker, RefsMap* refs, Handle<Object> object, void operator()(JSHeapBroker* broker, RefsMap* refs, Handle<Object> object,
RefsMap::Entry** entry_out, ObjectData** object_data_out) { RefsMap::Entry** entry_out, ObjectData** object_data_out) {
// TODO(solanes, v8:10866): Remove the `(mode() == kSerializing)` case
// below when all classes skip serialization. Same for similar spots if we
// end up keeping them.
if (broker->is_concurrent_inlining() || NeverEverSerialize<ObjectT>()) {
RefsMap::Entry* entry = refs->LookupOrInsert(object.address()); RefsMap::Entry* entry = refs->LookupOrInsert(object.address());
*object_data_out = broker->zone()->New<ObjectData>( *object_data_out = broker->zone()->New<ObjectData>(
broker, &entry->value, object, kNeverSerializedHeapObject); broker, &entry->value, object, kNeverSerializedHeapObject);
*entry_out = entry; *entry_out = entry;
return true;
} else if (broker->mode() == JSHeapBroker::kSerializing) {
RefsMap::Entry* entry = refs->LookupOrInsert(object.address());
*object_data_out = broker->zone()->New<DataT>(
broker, &entry->value, Handle<ObjectT>::cast(object));
*entry_out = entry;
return true;
}
return false;
} }
}; };
...@@ -2296,13 +1930,12 @@ ObjectData* JSHeapBroker::TryGetOrCreateData(Handle<Object> object, ...@@ -2296,13 +1930,12 @@ ObjectData* JSHeapBroker::TryGetOrCreateData(Handle<Object> object,
kUnserializedReadOnlyHeapObject); kUnserializedReadOnlyHeapObject);
} }
#define CREATE_DATA(Name, Kind) \ #define CREATE_DATA(Name) \
if (object->Is##Name()) { \ if (object->Is##Name()) { \
CreateDataFunctor<Kind, Name##Data, Name> f; \ CreateDataFunctor<ref_traits<Name>::ref_serialization_kind, \
if (!f(this, refs_, object, &entry, &object_data)) { \ ref_traits<Name>::data_type, Name> \
CHECK_WITH_MSG(!crash_on_error, #Name "Ref construction failed"); \ f; \
return nullptr; \ f(this, refs_, object, &entry, &object_data); \
} \
/* NOLINTNEXTLINE(readability/braces) */ \ /* NOLINTNEXTLINE(readability/braces) */ \
} else } else
HEAP_BROKER_OBJECT_LIST(CREATE_DATA) HEAP_BROKER_OBJECT_LIST(CREATE_DATA)
...@@ -2316,7 +1949,7 @@ ObjectData* JSHeapBroker::TryGetOrCreateData(Handle<Object> object, ...@@ -2316,7 +1949,7 @@ ObjectData* JSHeapBroker::TryGetOrCreateData(Handle<Object> object,
return object_data; return object_data;
} }
#define DEFINE_IS_AND_AS(Name, ...) \ #define DEFINE_IS_AND_AS(Name) \
bool ObjectRef::Is##Name() const { return data()->Is##Name(); } \ bool ObjectRef::Is##Name() const { return data()->Is##Name(); } \
Name##Ref ObjectRef::As##Name() const { \ Name##Ref ObjectRef::As##Name() const { \
DCHECK(Is##Name()); \ DCHECK(Is##Name()); \
...@@ -3556,7 +3189,7 @@ Handle<Object> ObjectRef::object() const { ...@@ -3556,7 +3189,7 @@ Handle<Object> ObjectRef::object() const {
} }
#ifdef DEBUG #ifdef DEBUG
#define DEF_OBJECT_GETTER(T, ...) \ #define DEF_OBJECT_GETTER(T) \
Handle<T> T##Ref::object() const { \ Handle<T> T##Ref::object() const { \
if (broker()->mode() == JSHeapBroker::kSerialized && \ if (broker()->mode() == JSHeapBroker::kSerialized && \
data_->used_status == ObjectData::Usage::kUnused) { \ data_->used_status == ObjectData::Usage::kUnused) { \
...@@ -3565,7 +3198,7 @@ Handle<Object> ObjectRef::object() const { ...@@ -3565,7 +3198,7 @@ Handle<Object> ObjectRef::object() const {
return Handle<T>(reinterpret_cast<Address*>(data_->object().address())); \ return Handle<T>(reinterpret_cast<Address*>(data_->object().address())); \
} }
#else #else
#define DEF_OBJECT_GETTER(T, ...) \ #define DEF_OBJECT_GETTER(T) \
Handle<T> T##Ref::object() const { \ Handle<T> T##Ref::object() const { \
return Handle<T>(reinterpret_cast<Address*>(data_->object().address())); \ return Handle<T>(reinterpret_cast<Address*>(data_->object().address())); \
} }
......
...@@ -75,8 +75,7 @@ enum class OddballType : uint8_t { ...@@ -75,8 +75,7 @@ enum class OddballType : uint8_t {
}; };
enum class RefSerializationKind { enum class RefSerializationKind {
// Will skip serialization when --concurrent-inlining is on. Otherwise, they // Skips serialization.
// might get serialized. (The cake is a lie.)
kNeverSerialized, kNeverSerialized,
// Can be serialized on demand from the background thread. // Can be serialized on demand from the background thread.
kBackgroundSerialized, kBackgroundSerialized,
...@@ -84,60 +83,65 @@ enum class RefSerializationKind { ...@@ -84,60 +83,65 @@ enum class RefSerializationKind {
// This list is sorted such that subtypes appear before their supertypes. // This list is sorted such that subtypes appear before their supertypes.
// DO NOT VIOLATE THIS PROPERTY! // DO NOT VIOLATE THIS PROPERTY!
#define HEAP_BROKER_OBJECT_LIST(V) \ #define HEAP_BROKER_OBJECT_LIST_BASE(BACKGROUND_SERIALIZED, NEVER_SERIALIZED) \
/* Subtypes of JSObject */ \ /* Subtypes of JSObject */ \
V(JSArray, RefSerializationKind::kBackgroundSerialized) \ BACKGROUND_SERIALIZED(JSArray) \
V(JSBoundFunction, RefSerializationKind::kBackgroundSerialized) \ BACKGROUND_SERIALIZED(JSBoundFunction) \
V(JSDataView, RefSerializationKind::kBackgroundSerialized) \ BACKGROUND_SERIALIZED(JSDataView) \
V(JSFunction, RefSerializationKind::kBackgroundSerialized) \ BACKGROUND_SERIALIZED(JSFunction) \
V(JSGlobalObject, RefSerializationKind::kBackgroundSerialized) \ BACKGROUND_SERIALIZED(JSGlobalObject) \
V(JSGlobalProxy, RefSerializationKind::kBackgroundSerialized) \ BACKGROUND_SERIALIZED(JSGlobalProxy) \
V(JSTypedArray, RefSerializationKind::kBackgroundSerialized) \ BACKGROUND_SERIALIZED(JSTypedArray) \
/* Subtypes of Context */ \ /* Subtypes of Context */ \
V(NativeContext, RefSerializationKind::kNeverSerialized) \ NEVER_SERIALIZED(NativeContext) \
/* Subtypes of FixedArray */ \ /* Subtypes of FixedArray */ \
V(ObjectBoilerplateDescription, RefSerializationKind::kNeverSerialized) \ NEVER_SERIALIZED(ObjectBoilerplateDescription) \
V(ScriptContextTable, RefSerializationKind::kBackgroundSerialized) \ BACKGROUND_SERIALIZED(ScriptContextTable) \
/* Subtypes of String */ \ /* Subtypes of String */ \
V(InternalizedString, RefSerializationKind::kNeverSerialized) \ NEVER_SERIALIZED(InternalizedString) \
/* Subtypes of FixedArrayBase */ \ /* Subtypes of FixedArrayBase */ \
V(BytecodeArray, RefSerializationKind::kNeverSerialized) \ NEVER_SERIALIZED(BytecodeArray) \
V(FixedArray, RefSerializationKind::kBackgroundSerialized) \ BACKGROUND_SERIALIZED(FixedArray) \
V(FixedDoubleArray, RefSerializationKind::kNeverSerialized) \ NEVER_SERIALIZED(FixedDoubleArray) \
/* Subtypes of Name */ \ /* Subtypes of Name */ \
V(String, RefSerializationKind::kNeverSerialized) \ NEVER_SERIALIZED(String) \
V(Symbol, RefSerializationKind::kNeverSerialized) \ NEVER_SERIALIZED(Symbol) \
/* Subtypes of JSReceiver */ \ /* Subtypes of JSReceiver */ \
V(JSObject, RefSerializationKind::kBackgroundSerialized) \ BACKGROUND_SERIALIZED(JSObject) \
/* Subtypes of HeapObject */ \ /* Subtypes of HeapObject */ \
V(AccessorInfo, RefSerializationKind::kNeverSerialized) \ NEVER_SERIALIZED(AccessorInfo) \
V(AllocationSite, RefSerializationKind::kNeverSerialized) \ NEVER_SERIALIZED(AllocationSite) \
V(ArrayBoilerplateDescription, RefSerializationKind::kNeverSerialized) \ NEVER_SERIALIZED(ArrayBoilerplateDescription) \
V(BigInt, RefSerializationKind::kBackgroundSerialized) \ BACKGROUND_SERIALIZED(BigInt) \
V(CallHandlerInfo, RefSerializationKind::kNeverSerialized) \ NEVER_SERIALIZED(CallHandlerInfo) \
V(Cell, RefSerializationKind::kNeverSerialized) \ NEVER_SERIALIZED(Cell) \
V(Code, RefSerializationKind::kNeverSerialized) \ NEVER_SERIALIZED(Code) \
V(CodeDataContainer, RefSerializationKind::kNeverSerialized) \ NEVER_SERIALIZED(CodeDataContainer) \
V(Context, RefSerializationKind::kNeverSerialized) \ NEVER_SERIALIZED(Context) \
V(DescriptorArray, RefSerializationKind::kNeverSerialized) \ NEVER_SERIALIZED(DescriptorArray) \
V(FeedbackCell, RefSerializationKind::kNeverSerialized) \ NEVER_SERIALIZED(FeedbackCell) \
V(FeedbackVector, RefSerializationKind::kNeverSerialized) \ NEVER_SERIALIZED(FeedbackVector) \
V(FixedArrayBase, RefSerializationKind::kBackgroundSerialized) \ BACKGROUND_SERIALIZED(FixedArrayBase) \
V(FunctionTemplateInfo, RefSerializationKind::kNeverSerialized) \ NEVER_SERIALIZED(FunctionTemplateInfo) \
V(HeapNumber, RefSerializationKind::kNeverSerialized) \ NEVER_SERIALIZED(HeapNumber) \
V(JSReceiver, RefSerializationKind::kBackgroundSerialized) \ BACKGROUND_SERIALIZED(JSReceiver) \
V(Map, RefSerializationKind::kBackgroundSerialized) \ BACKGROUND_SERIALIZED(Map) \
V(Name, RefSerializationKind::kNeverSerialized) \ NEVER_SERIALIZED(Name) \
V(PropertyCell, RefSerializationKind::kBackgroundSerialized) \ BACKGROUND_SERIALIZED(PropertyCell) \
V(RegExpBoilerplateDescription, RefSerializationKind::kNeverSerialized) \ NEVER_SERIALIZED(RegExpBoilerplateDescription) \
V(ScopeInfo, RefSerializationKind::kNeverSerialized) \ NEVER_SERIALIZED(ScopeInfo) \
V(SharedFunctionInfo, RefSerializationKind::kNeverSerialized) \ NEVER_SERIALIZED(SharedFunctionInfo) \
V(SourceTextModule, RefSerializationKind::kNeverSerialized) \ NEVER_SERIALIZED(SourceTextModule) \
V(TemplateObjectDescription, RefSerializationKind::kNeverSerialized) \ NEVER_SERIALIZED(TemplateObjectDescription) \
/* Subtypes of Object */ \ /* Subtypes of Object */ \
V(HeapObject, RefSerializationKind::kBackgroundSerialized) BACKGROUND_SERIALIZED(HeapObject)
#define FORWARD_DECL(Name, ...) class Name##Ref; #define HEAP_BROKER_OBJECT_LIST(V) HEAP_BROKER_OBJECT_LIST_BASE(V, V)
#define IGNORE_CASE(...)
#define HEAP_BROKER_BACKGROUND_SERIALIZED_OBJECT_LIST(V) \
HEAP_BROKER_OBJECT_LIST_BASE(V, IGNORE_CASE)
#define FORWARD_DECL(Name) class Name##Ref;
HEAP_BROKER_OBJECT_LIST(FORWARD_DECL) HEAP_BROKER_OBJECT_LIST(FORWARD_DECL)
#undef FORWARD_DECL #undef FORWARD_DECL
...@@ -146,14 +150,32 @@ class ObjectRef; ...@@ -146,14 +150,32 @@ class ObjectRef;
template <class T> template <class T>
struct ref_traits; struct ref_traits;
#define REF_TRAITS(Name, Kind) \ #define FORWARD_DECL(Name) class Name##Data;
HEAP_BROKER_BACKGROUND_SERIALIZED_OBJECT_LIST(FORWARD_DECL)
#undef FORWARD_DECL
#define BACKGROUND_SERIALIZED_REF_TRAITS(Name) \
template <> \ template <> \
struct ref_traits<Name> { \ struct ref_traits<Name> { \
using ref_type = Name##Ref; \ using ref_type = Name##Ref; \
static constexpr RefSerializationKind ref_serialization_kind = Kind; \ using data_type = Name##Data; \
static constexpr RefSerializationKind ref_serialization_kind = \
RefSerializationKind::kBackgroundSerialized; \
}; };
HEAP_BROKER_OBJECT_LIST(REF_TRAITS)
#undef REF_TYPE #define NEVER_SERIALIZED_REF_TRAITS(Name) \
template <> \
struct ref_traits<Name> { \
using ref_type = Name##Ref; \
using data_type = ObjectData; \
static constexpr RefSerializationKind ref_serialization_kind = \
RefSerializationKind::kNeverSerialized; \
};
HEAP_BROKER_OBJECT_LIST_BASE(BACKGROUND_SERIALIZED_REF_TRAITS,
NEVER_SERIALIZED_REF_TRAITS)
#undef NEVER_SERIALIZED_REF_TRAITS
#undef BACKGROUND_SERIALIZED_REF_TRAITS
template <> template <>
struct ref_traits<Object> { struct ref_traits<Object> {
...@@ -179,11 +201,11 @@ class V8_EXPORT_PRIVATE ObjectRef { ...@@ -179,11 +201,11 @@ class V8_EXPORT_PRIVATE ObjectRef {
bool IsSmi() const; bool IsSmi() const;
int AsSmi() const; int AsSmi() const;
#define HEAP_IS_METHOD_DECL(Name, ...) bool Is##Name() const; #define HEAP_IS_METHOD_DECL(Name) bool Is##Name() const;
HEAP_BROKER_OBJECT_LIST(HEAP_IS_METHOD_DECL) HEAP_BROKER_OBJECT_LIST(HEAP_IS_METHOD_DECL)
#undef HEAP_IS_METHOD_DECL #undef HEAP_IS_METHOD_DECL
#define HEAP_AS_METHOD_DECL(Name, ...) Name##Ref As##Name() const; #define HEAP_AS_METHOD_DECL(Name) Name##Ref As##Name() const;
HEAP_BROKER_OBJECT_LIST(HEAP_AS_METHOD_DECL) HEAP_BROKER_OBJECT_LIST(HEAP_AS_METHOD_DECL)
#undef HEAP_AS_METHOD_DECL #undef HEAP_AS_METHOD_DECL
......
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