Commit 10ca48ff authored by Jakob Gruber's avatar Jakob Gruber Committed by Commit Bot

[compiler] Merge the Ref lists

Prior to this CL, Refs were defined through four lists:

HEAP_BROKER_SERIALIZED_OBJECT_LIST
HEAP_BROKER_POSSIBLY_BACKGROUND_SERIALIZED_OBJECT_LIST
HEAP_BROKER_BACKGROUND_SERIALIZED_OBJECT_LIST
HEAP_BROKER_NEVER_SERIALIZED_OBJECT_LIST

Due to the way FooData objects are constructed (a long if-else chain
generated from these lists), the order of entries within the lists and
also between lists was important. In particular, subtypes had to
appear before all their supertypes. Within one list this was doable,
but with the split into 4 different lists this invariant cannot hold
in practice.

This CL refactors the four lists back into a single list to make
observing the invariant possible with upcoming changes. The new
unified list contains the RefSerializationKind as a second argument.

Related changes are not very interesting, except for
TryGetOrCreateData which now uses a set of templated functor objects
for setup (this was necessary to handle different FooData constructor
signatures).

Bug: v8:7790
Change-Id: Ia4c030c767830be4253cf41e3aaf67454f1cbef6
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2843351
Commit-Queue: Santiago Aboy Solanes <solanes@chromium.org>
Auto-Submit: Jakob Gruber <jgruber@chromium.org>
Reviewed-by: 's avatarSantiago Aboy Solanes <solanes@chromium.org>
Cr-Commit-Position: refs/heads/master@{#74171}
parent d8e1f4d5
...@@ -27,11 +27,8 @@ namespace compiler { ...@@ -27,11 +27,8 @@ 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; #define FORWARD_DECL(Name, ...) class Name##Data;
HEAP_BROKER_SERIALIZED_OBJECT_LIST(FORWARD_DECL) HEAP_BROKER_OBJECT_LIST(FORWARD_DECL)
HEAP_BROKER_POSSIBLY_BACKGROUND_SERIALIZED_OBJECT_LIST(FORWARD_DECL)
HEAP_BROKER_BACKGROUND_SERIALIZED_OBJECT_LIST(FORWARD_DECL)
HEAP_BROKER_NEVER_SERIALIZED_OBJECT_LIST(FORWARD_DECL)
#undef FORWARD_DECL #undef FORWARD_DECL
// There are several kinds of ObjectData values. // There are several kinds of ObjectData values.
...@@ -85,13 +82,15 @@ constexpr bool IsSerializedHeapObject() { ...@@ -85,13 +82,15 @@ constexpr bool IsSerializedHeapObject() {
return false; return false;
} }
#define DEFINE_MARKER(Name) \ #define DEFINE_MARKER(Name, Kind) \
template <> \ template <> \
constexpr bool IsSerializedHeapObject<Name>() { \ constexpr bool IsSerializedHeapObject<Name>() { \
return true; \ return Kind == RefSerializationKind::kSerialized; \
} \ } \
STATIC_ASSERT(IsSerializedHeapObject<Name>()); /* The static assert is needed to avoid 'unused function' warnings. */ \
HEAP_BROKER_SERIALIZED_OBJECT_LIST(DEFINE_MARKER) STATIC_ASSERT(IsSerializedHeapObject<Name>() == \
(Kind == RefSerializationKind::kSerialized));
HEAP_BROKER_OBJECT_LIST(DEFINE_MARKER)
#undef DEFINE_MARKER #undef DEFINE_MARKER
} // namespace } // namespace
...@@ -133,18 +132,12 @@ class ObjectData : public ZoneObject { ...@@ -133,18 +132,12 @@ class ObjectData : public ZoneObject {
IsReadOnlyHeapObject(*object)); IsReadOnlyHeapObject(*object));
} }
#define DECLARE_IS(Name) bool Is##Name() const; #define DECLARE_IS(Name, ...) bool Is##Name() const;
HEAP_BROKER_SERIALIZED_OBJECT_LIST(DECLARE_IS) HEAP_BROKER_OBJECT_LIST(DECLARE_IS)
HEAP_BROKER_POSSIBLY_BACKGROUND_SERIALIZED_OBJECT_LIST(DECLARE_IS)
HEAP_BROKER_BACKGROUND_SERIALIZED_OBJECT_LIST(DECLARE_IS)
HEAP_BROKER_NEVER_SERIALIZED_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_SERIALIZED_OBJECT_LIST(DECLARE_AS) HEAP_BROKER_OBJECT_LIST(DECLARE_AS)
HEAP_BROKER_POSSIBLY_BACKGROUND_SERIALIZED_OBJECT_LIST(DECLARE_AS)
HEAP_BROKER_BACKGROUND_SERIALIZED_OBJECT_LIST(DECLARE_AS)
HEAP_BROKER_NEVER_SERIALIZED_OBJECT_LIST(DECLARE_AS)
#undef DECLARE_AS #undef DECLARE_AS
Handle<Object> object() const { return object_; } Handle<Object> object() const { return object_; }
...@@ -2221,7 +2214,7 @@ class CodeData : public HeapObjectData { ...@@ -2221,7 +2214,7 @@ class CodeData : public HeapObjectData {
unsigned const inlined_bytecode_size_; unsigned const inlined_bytecode_size_;
}; };
#define DEFINE_IS(Name) \ #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(); \
...@@ -2231,36 +2224,25 @@ class CodeData : public HeapObjectData { ...@@ -2231,36 +2224,25 @@ class CodeData : public HeapObjectData {
static_cast<const HeapObjectData*>(this)->GetMapInstanceType(); \ static_cast<const HeapObjectData*>(this)->GetMapInstanceType(); \
return InstanceTypeChecker::Is##Name(instance_type); \ return InstanceTypeChecker::Is##Name(instance_type); \
} }
HEAP_BROKER_SERIALIZED_OBJECT_LIST(DEFINE_IS) HEAP_BROKER_OBJECT_LIST(DEFINE_IS)
HEAP_BROKER_POSSIBLY_BACKGROUND_SERIALIZED_OBJECT_LIST(DEFINE_IS)
HEAP_BROKER_BACKGROUND_SERIALIZED_OBJECT_LIST(DEFINE_IS)
HEAP_BROKER_NEVER_SERIALIZED_OBJECT_LIST(DEFINE_IS)
#undef DEFINE_IS #undef DEFINE_IS
#define DEFINE_AS(Name) \ // TODO(solanes, v8:10866): Remove support for kNeverSerialized objects here
// once broker()->is_concurrent_inlining() is removed.
// AsFoo() methods for NeverSerialized objects should only be used with direct
// heap access off.
#define DEFINE_AS(Name, Kind) \
Name##Data* ObjectData::As##Name() { \ Name##Data* ObjectData::As##Name() { \
DCHECK_IMPLIES(Kind == RefSerializationKind::kNeverSerialized, \
!broker()->is_concurrent_inlining()); \
DCHECK_IMPLIES(Kind == RefSerializationKind::kNeverSerialized, \
kind_ == kSerializedHeapObject); \
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_SERIALIZED_OBJECT_LIST(DEFINE_AS) HEAP_BROKER_OBJECT_LIST(DEFINE_AS)
HEAP_BROKER_POSSIBLY_BACKGROUND_SERIALIZED_OBJECT_LIST(DEFINE_AS)
HEAP_BROKER_BACKGROUND_SERIALIZED_OBJECT_LIST(DEFINE_AS)
#undef DEFINE_AS
// TODO(solanes, v8:10866): Remove once broker()->is_concurrent_inlining() is
// removed.
// This macro defines the Asxxx methods for NeverSerialized objects, which
// should only be used with direct heap access off.
#define DEFINE_AS(Name) \
Name##Data* ObjectData::As##Name() { \
DCHECK(!broker()->is_concurrent_inlining()); \
CHECK(Is##Name()); \
CHECK_EQ(kind_, kSerializedHeapObject); \
return static_cast<Name##Data*>(this); \
}
HEAP_BROKER_NEVER_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 {
...@@ -2722,6 +2704,114 @@ void JSHeapBroker::InitializeAndStartSerializing( ...@@ -2722,6 +2704,114 @@ void JSHeapBroker::InitializeAndStartSerializing(
TRACE(this, "Finished serializing standard objects"); TRACE(this, "Finished serializing standard objects");
} }
namespace {
template <RefSerializationKind Kind, class DataT, class ObjectT>
struct CreateDataFunctor {
bool operator()(JSHeapBroker* broker, RefsMap* refs,
ObjectRef::BackgroundSerialization background_serialization,
Handle<Object> object, RefsMap::Entry** entry_out,
ObjectData** object_data_out) {
USE(broker, refs, background_serialization, object, entry_out,
object_data_out);
UNREACHABLE();
}
};
template <class DataT, class ObjectT>
struct CreateDataFunctor<RefSerializationKind::kSerialized, DataT, ObjectT> {
bool operator()(JSHeapBroker* broker, RefsMap* refs,
ObjectRef::BackgroundSerialization background_serialization,
Handle<Object> object, RefsMap::Entry** entry_out,
ObjectData** object_data_out) {
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;
}
};
template <class DataT, class ObjectT>
struct CreateDataFunctor<RefSerializationKind::kBackgroundSerialized, DataT,
ObjectT> {
bool operator()(JSHeapBroker* broker, RefsMap* refs,
ObjectRef::BackgroundSerialization background_serialization,
Handle<Object> object, RefsMap::Entry** entry_out,
ObjectData** object_data_out) {
if (broker->is_concurrent_inlining()) {
RefsMap::Entry* entry = refs->LookupOrInsert(object.address());
*object_data_out = broker->zone()->New<DataT>(
broker, &entry->value, Handle<ObjectT>::cast(object),
kBackgroundSerializedHeapObject);
*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;
}
};
template <class DataT, class ObjectT>
struct CreateDataFunctor<RefSerializationKind::kPossiblyBackgroundSerialized,
DataT, ObjectT> {
bool operator()(JSHeapBroker* broker, RefsMap* refs,
ObjectRef::BackgroundSerialization background_serialization,
Handle<Object> object, RefsMap::Entry** entry_out,
ObjectData** object_data_out) {
if (broker->mode() == JSHeapBroker::kSerialized &&
background_serialization !=
ObjectRef::BackgroundSerialization::kAllowed) {
return false;
}
RefsMap::Entry* entry = refs->LookupOrInsert(object.address());
ObjectDataKind kind = (background_serialization ==
ObjectRef::BackgroundSerialization::kAllowed)
? kBackgroundSerializedHeapObject
: kSerializedHeapObject;
*object_data_out = broker->zone()->New<DataT>(
broker, &entry->value, Handle<ObjectT>::cast(object), kind);
*entry_out = entry;
return true;
}
};
template <class DataT, class ObjectT>
struct CreateDataFunctor<RefSerializationKind::kNeverSerialized, DataT,
ObjectT> {
bool operator()(JSHeapBroker* broker, RefsMap* refs,
ObjectRef::BackgroundSerialization, Handle<Object> object,
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()) {
RefsMap::Entry* entry = refs->LookupOrInsert(object.address());
*object_data_out = broker->zone()->New<ObjectData>(
broker, &entry->value, object, kNeverSerializedHeapObject);
*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;
}
};
} // namespace
ObjectData* JSHeapBroker::TryGetOrCreateData( ObjectData* JSHeapBroker::TryGetOrCreateData(
Handle<Object> object, bool crash_on_error, Handle<Object> object, bool crash_on_error,
ObjectRef::BackgroundSerialization background_serialization) { ObjectRef::BackgroundSerialization background_serialization) {
...@@ -2750,81 +2840,18 @@ ObjectData* JSHeapBroker::TryGetOrCreateData( ...@@ -2750,81 +2840,18 @@ ObjectData* JSHeapBroker::TryGetOrCreateData(
entry = refs_->LookupOrInsert(object.address()); entry = refs_->LookupOrInsert(object.address());
object_data = zone()->New<ObjectData>(this, &(entry->value), object, object_data = zone()->New<ObjectData>(this, &(entry->value), object,
kUnserializedReadOnlyHeapObject); kUnserializedReadOnlyHeapObject);
// TODO(solanes, v8:10866): Remove the `(mode() == kSerializing)` case in this #define CREATE_DATA(Name, Kind) \
// macro when all classes skip serialization. Same for the other macros if we
// end up keeping them.
#define CREATE_DATA_FOR_DIRECT_READ(name) \
} \
/* NOLINTNEXTLINE(readability/braces) */ \
else if (object->Is##name()) { \
if (is_concurrent_inlining()) { \
entry = refs_->LookupOrInsert(object.address()); \
object_data = zone()->New<ObjectData>(this, &(entry->value), object, \
kNeverSerializedHeapObject); \
} else if (mode() == kSerializing) { \
entry = refs_->LookupOrInsert(object.address()); \
object_data = zone()->New<name##Data>(this, &(entry->value), \
Handle<name>::cast(object)); \
} else { \
CHECK(!crash_on_error); \
return nullptr; \
}
HEAP_BROKER_NEVER_SERIALIZED_OBJECT_LIST(CREATE_DATA_FOR_DIRECT_READ)
#undef CREATE_DATA_FOR_DIRECT_READ
#define CREATE_DATA_FOR_POSSIBLE_SERIALIZATION(name) \
} \
/* NOLINTNEXTLINE(readability/braces) */ \
else if (object->Is##name()) { \
if (mode() == kSerialized && \
background_serialization != \
ObjectRef::BackgroundSerialization::kAllowed) { \
CHECK(!crash_on_error); \
return nullptr; \
} \
entry = refs_->LookupOrInsert(object.address()); \
ObjectDataKind kind = (background_serialization == \
ObjectRef::BackgroundSerialization::kAllowed) \
? kBackgroundSerializedHeapObject \
: kSerializedHeapObject; \
object_data = zone()->New<name##Data>(this, &(entry->value), \
Handle<name>::cast(object), kind);
HEAP_BROKER_POSSIBLY_BACKGROUND_SERIALIZED_OBJECT_LIST(
CREATE_DATA_FOR_POSSIBLE_SERIALIZATION)
#undef CREATE_DATA_FOR_POSSIBLE_SERIALIZATION
#define CREATE_DATA_FOR_BACKGROUND_SERIALIZATION(name) \
} \
/* NOLINTNEXTLINE(readability/braces) */ \
else if (object->Is##name()) { \
if (is_concurrent_inlining()) { \
entry = refs_->LookupOrInsert(object.address()); \
object_data = zone()->New<name##Data>(this, &(entry->value), \
Handle<name>::cast(object), \
kBackgroundSerializedHeapObject); \
} else if (mode() == kSerializing) { \
entry = refs_->LookupOrInsert(object.address()); \
object_data = zone()->New<name##Data>(this, &(entry->value), \
Handle<name>::cast(object)); \
} else { \
CHECK(!crash_on_error); \
return nullptr; \
}
HEAP_BROKER_BACKGROUND_SERIALIZED_OBJECT_LIST(
CREATE_DATA_FOR_BACKGROUND_SERIALIZATION)
#undef CREATE_DATA_FOR_SERIALIZATION
#define CREATE_DATA_FOR_SERIALIZATION(name) \
} \ } \
/* NOLINTNEXTLINE(readability/braces) */ \ /* NOLINTNEXTLINE(readability/braces) */ \
else if (object->Is##name()) { \ else if (object->Is##Name()) { \
if (mode() == kSerializing) { \ CreateDataFunctor<Kind, Name##Data, Name> f; \
entry = refs_->LookupOrInsert(object.address()); \ if (!f(this, refs_, background_serialization, object, &entry, \
object_data = zone()->New<name##Data>(this, &(entry->value), \ &object_data)) { \
Handle<name>::cast(object)); \
} else { \
CHECK(!crash_on_error); \ CHECK(!crash_on_error); \
return nullptr; \ return nullptr; \
} }
HEAP_BROKER_SERIALIZED_OBJECT_LIST(CREATE_DATA_FOR_SERIALIZATION) HEAP_BROKER_OBJECT_LIST(CREATE_DATA)
#undef CREATE_DATA_FOR_SERIALIZATION #undef CREATE_DATA
} else { } else {
UNREACHABLE(); UNREACHABLE();
} }
...@@ -2834,16 +2861,13 @@ ObjectData* JSHeapBroker::TryGetOrCreateData( ...@@ -2834,16 +2861,13 @@ ObjectData* JSHeapBroker::TryGetOrCreateData(
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()); \
return Name##Ref(broker(), data()); \ return Name##Ref(broker(), data()); \
} }
HEAP_BROKER_SERIALIZED_OBJECT_LIST(DEFINE_IS_AND_AS) HEAP_BROKER_OBJECT_LIST(DEFINE_IS_AND_AS)
HEAP_BROKER_POSSIBLY_BACKGROUND_SERIALIZED_OBJECT_LIST(DEFINE_IS_AND_AS)
HEAP_BROKER_BACKGROUND_SERIALIZED_OBJECT_LIST(DEFINE_IS_AND_AS)
HEAP_BROKER_NEVER_SERIALIZED_OBJECT_LIST(DEFINE_IS_AND_AS)
#undef DEFINE_IS_AND_AS #undef DEFINE_IS_AND_AS
bool ObjectRef::IsSmi() const { return data()->is_smi(); } bool ObjectRef::IsSmi() const { return data()->is_smi(); }
...@@ -4236,7 +4260,7 @@ Handle<Object> ObjectRef::object() const { ...@@ -4236,7 +4260,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) { \
...@@ -4245,16 +4269,13 @@ Handle<Object> ObjectRef::object() const { ...@@ -4245,16 +4269,13 @@ 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())); \
} }
#endif // DEBUG #endif // DEBUG
HEAP_BROKER_SERIALIZED_OBJECT_LIST(DEF_OBJECT_GETTER) HEAP_BROKER_OBJECT_LIST(DEF_OBJECT_GETTER)
HEAP_BROKER_POSSIBLY_BACKGROUND_SERIALIZED_OBJECT_LIST(DEF_OBJECT_GETTER)
HEAP_BROKER_BACKGROUND_SERIALIZED_OBJECT_LIST(DEF_OBJECT_GETTER)
HEAP_BROKER_NEVER_SERIALIZED_OBJECT_LIST(DEF_OBJECT_GETTER)
#undef DEF_OBJECT_GETTER #undef DEF_OBJECT_GETTER
JSHeapBroker* ObjectRef::broker() const { return broker_; } JSHeapBroker* ObjectRef::broker() const { return broker_; }
......
...@@ -62,87 +62,74 @@ enum class OddballType : uint8_t { ...@@ -62,87 +62,74 @@ enum class OddballType : uint8_t {
kOther // Oddball, but none of the above. kOther // Oddball, but none of the above.
}; };
// This list is sorted such that subtypes appear before their supertypes. enum class RefSerializationKind {
// This list must not contain a type if it doesn't contain all of its subtypes // Will skip serialization when --concurrent-inlining is on. Otherwise, they
// too. For example, it CANNOT contain FixedArrayBase if it doesn't contain // might get serialized. (The cake is a lie.)
// FixedDoubleArray, BytecodeArray and FixedArray. kNeverSerialized,
// DO NOT VIOLATE THESE TWO PROPERTIES! // Can be serialized on demand from the background thread.
// Classes on this list will skip serialization when --concurrent-inlining is kBackgroundSerialized,
// on. Otherwise, they might get serialized. // Behave like serialized classes, but allow lazy serialization from
#define HEAP_BROKER_NEVER_SERIALIZED_OBJECT_LIST(V) \ // background threads where this is safe (e.g. for objects that are immutable
/* Subtypes of FixedArray */ \ // and fully initialized once visible). Pass
V(ObjectBoilerplateDescription) \ // ObjectRef::BackgroundSerialization::kAllowed to the ObjectRef constructor
V(ScopeInfo) \ // for objects where serialization from the background thread is safe.
/* Subtypes of String */ \ kPossiblyBackgroundSerialized,
V(InternalizedString) \ kSerialized,
/* Subtypes of FixedArrayBase */ \ };
V(BytecodeArray) \
/* Subtypes of Name */ \
V(String) \
V(Symbol) \
/* Subtypes of HeapObject */ \
V(AccessorInfo) \
V(ArrayBoilerplateDescription) \
V(CallHandlerInfo) \
V(Cell) \
V(Code) \
V(DescriptorArray) \
V(FeedbackCell) \
V(FeedbackVector) \
V(FunctionTemplateInfo) \
V(Name) \
V(RegExpBoilerplateDescription) \
V(SharedFunctionInfo) \
V(TemplateObjectDescription)
// This list is sorted such that subtypes appear before their supertypes.
// DO NOT VIOLATE THIS PROPERTY!
// Classes in this list behave like serialized classes, but they allow lazy
// serialization from background threads where this is safe (e.g. for objects
// that are immutable and fully initialized once visible). Pass
// ObjectRef::BackgroundSerialization::kAllowed to the ObjectRef constructor
// for objects where serialization from the background thread is safe.
#define HEAP_BROKER_POSSIBLY_BACKGROUND_SERIALIZED_OBJECT_LIST(V) \
/* Subtypes of HeapObject */ \
V(BigInt) \
V(HeapNumber)
// This list is sorted such that subtypes appear before their supertypes.
// DO NOT VIOLATE THIS PROPERTY!
// Types in this list can be serialized on demand from the background thread.
#define HEAP_BROKER_BACKGROUND_SERIALIZED_OBJECT_LIST(V) \
/* Subtypes of HeapObject */ \
V(Map) \
V(PropertyCell)
// 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_SERIALIZED_OBJECT_LIST(V) \ #define HEAP_BROKER_OBJECT_LIST(V) \
/* Subtypes of JSObject */ \ /* Subtypes of JSObject */ \
V(JSArray) \ V(JSArray, RefSerializationKind::kSerialized) \
V(JSBoundFunction) \ V(JSBoundFunction, RefSerializationKind::kSerialized) \
V(JSDataView) \ V(JSDataView, RefSerializationKind::kSerialized) \
V(JSFunction) \ V(JSFunction, RefSerializationKind::kSerialized) \
V(JSGlobalObject) \ V(JSGlobalObject, RefSerializationKind::kSerialized) \
V(JSGlobalProxy) \ V(JSGlobalProxy, RefSerializationKind::kSerialized) \
V(JSTypedArray) \ V(JSTypedArray, RefSerializationKind::kSerialized) \
/* Subtypes of Context */ \ /* Subtypes of Context */ \
V(NativeContext) \ V(NativeContext, RefSerializationKind::kSerialized) \
/* Subtypes of FixedArray */ \ /* Subtypes of FixedArray */ \
V(Context) \ V(Context, RefSerializationKind::kSerialized) \
V(ScriptContextTable) \ V(ObjectBoilerplateDescription, RefSerializationKind::kNeverSerialized) \
V(ScopeInfo, RefSerializationKind::kNeverSerialized) \
V(ScriptContextTable, RefSerializationKind::kSerialized) \
/* Subtypes of String */ \
V(InternalizedString, RefSerializationKind::kNeverSerialized) \
/* Subtypes of FixedArrayBase */ \ /* Subtypes of FixedArrayBase */ \
V(FixedArray) \ V(BytecodeArray, RefSerializationKind::kNeverSerialized) \
V(FixedDoubleArray) \ V(FixedArray, RefSerializationKind::kSerialized) \
V(FixedDoubleArray, RefSerializationKind::kSerialized) \
/* Subtypes of Name */ \
V(String, RefSerializationKind::kNeverSerialized) \
V(Symbol, RefSerializationKind::kNeverSerialized) \
/* Subtypes of JSReceiver */ \ /* Subtypes of JSReceiver */ \
V(JSObject) \ V(JSObject, RefSerializationKind::kSerialized) \
/* Subtypes of HeapObject */ \ /* Subtypes of HeapObject */ \
V(AllocationSite) \ V(AccessorInfo, RefSerializationKind::kNeverSerialized) \
V(FixedArrayBase) \ V(AllocationSite, RefSerializationKind::kSerialized) \
V(JSReceiver) \ V(ArrayBoilerplateDescription, RefSerializationKind::kNeverSerialized) \
V(SourceTextModule) \ V(BigInt, RefSerializationKind::kPossiblyBackgroundSerialized) \
V(CallHandlerInfo, RefSerializationKind::kNeverSerialized) \
V(Cell, RefSerializationKind::kNeverSerialized) \
V(Code, RefSerializationKind::kNeverSerialized) \
V(DescriptorArray, RefSerializationKind::kNeverSerialized) \
V(FeedbackCell, RefSerializationKind::kNeverSerialized) \
V(FeedbackVector, RefSerializationKind::kNeverSerialized) \
V(FixedArrayBase, RefSerializationKind::kSerialized) \
V(FunctionTemplateInfo, RefSerializationKind::kNeverSerialized) \
V(HeapNumber, RefSerializationKind::kPossiblyBackgroundSerialized) \
V(JSReceiver, RefSerializationKind::kSerialized) \
V(Map, RefSerializationKind::kBackgroundSerialized) \
V(Name, RefSerializationKind::kNeverSerialized) \
V(PropertyCell, RefSerializationKind::kBackgroundSerialized) \
V(RegExpBoilerplateDescription, RefSerializationKind::kNeverSerialized) \
V(SharedFunctionInfo, RefSerializationKind::kNeverSerialized) \
V(SourceTextModule, RefSerializationKind::kSerialized) \
V(TemplateObjectDescription, RefSerializationKind::kNeverSerialized) \
/* Subtypes of Object */ \ /* Subtypes of Object */ \
V(HeapObject) V(HeapObject, RefSerializationKind::kSerialized)
class CompilationDependencies; class CompilationDependencies;
struct FeedbackSource; struct FeedbackSource;
...@@ -150,11 +137,8 @@ class JSHeapBroker; ...@@ -150,11 +137,8 @@ class JSHeapBroker;
class ObjectData; class ObjectData;
class PerIsolateCompilerCache; class PerIsolateCompilerCache;
class PropertyAccessInfo; class PropertyAccessInfo;
#define FORWARD_DECL(Name) class Name##Ref; #define FORWARD_DECL(Name, ...) class Name##Ref;
HEAP_BROKER_SERIALIZED_OBJECT_LIST(FORWARD_DECL) HEAP_BROKER_OBJECT_LIST(FORWARD_DECL)
HEAP_BROKER_POSSIBLY_BACKGROUND_SERIALIZED_OBJECT_LIST(FORWARD_DECL)
HEAP_BROKER_BACKGROUND_SERIALIZED_OBJECT_LIST(FORWARD_DECL)
HEAP_BROKER_NEVER_SERIALIZED_OBJECT_LIST(FORWARD_DECL)
#undef FORWARD_DECL #undef FORWARD_DECL
class V8_EXPORT_PRIVATE ObjectRef { class V8_EXPORT_PRIVATE ObjectRef {
...@@ -180,18 +164,12 @@ class V8_EXPORT_PRIVATE ObjectRef { ...@@ -180,18 +164,12 @@ 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_SERIALIZED_OBJECT_LIST(HEAP_IS_METHOD_DECL) HEAP_BROKER_OBJECT_LIST(HEAP_IS_METHOD_DECL)
HEAP_BROKER_POSSIBLY_BACKGROUND_SERIALIZED_OBJECT_LIST(HEAP_IS_METHOD_DECL)
HEAP_BROKER_BACKGROUND_SERIALIZED_OBJECT_LIST(HEAP_IS_METHOD_DECL)
HEAP_BROKER_NEVER_SERIALIZED_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_SERIALIZED_OBJECT_LIST(HEAP_AS_METHOD_DECL) HEAP_BROKER_OBJECT_LIST(HEAP_AS_METHOD_DECL)
HEAP_BROKER_POSSIBLY_BACKGROUND_SERIALIZED_OBJECT_LIST(HEAP_AS_METHOD_DECL)
HEAP_BROKER_BACKGROUND_SERIALIZED_OBJECT_LIST(HEAP_AS_METHOD_DECL)
HEAP_BROKER_NEVER_SERIALIZED_OBJECT_LIST(HEAP_AS_METHOD_DECL)
#undef HEAP_AS_METHOD_DECL #undef HEAP_AS_METHOD_DECL
bool IsNull() const; bool IsNull() const;
......
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