Commit a1270d00 authored by Georg Neis's avatar Georg Neis Committed by Commit Bot

Reland "[compiler] Clean up ObjectDataKind"

This is a reland of 5cc7bfd0, after the
dependency has relanded.

Original change's description:
> [compiler] Clean up ObjectDataKind
>
> In particular: remove PossiblyBackgroundSerializedHeapObject in favor of
> either SerializedHeapObject or BackgroundSerializedHeapObject, depending
> on the (existing) argument to the ObjectRef constructor.
>
> Bug: v8:7790
> Change-Id: I0a67872c377107799233742cc7774bea62811d0f
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2681946
> Commit-Queue: Georg Neis <neis@chromium.org>
> Reviewed-by: Nico Hartmann <nicohartmann@chromium.org>
> Reviewed-by: Santiago Aboy Solanes <solanes@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#72591}

Tbr: solanes@chromium.org, nicohartmann@chromium.org
Bug: v8:7790
Change-Id: I7de88f54172078a42b5aa341b11309ac3581eed0
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2695589Reviewed-by: 's avatarGeorg Neis <neis@chromium.org>
Reviewed-by: 's avatarNico Hartmann <nicohartmann@chromium.org>
Reviewed-by: 's avatarSantiago Aboy Solanes <solanes@chromium.org>
Commit-Queue: Georg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#72751}
parent b526d8c2
...@@ -51,7 +51,7 @@ HEAP_BROKER_BACKGROUND_SERIALIZED_OBJECT_LIST(FORWARD_DECL) ...@@ -51,7 +51,7 @@ HEAP_BROKER_BACKGROUND_SERIALIZED_OBJECT_LIST(FORWARD_DECL)
HEAP_BROKER_NEVER_SERIALIZED_OBJECT_LIST(FORWARD_DECL) HEAP_BROKER_NEVER_SERIALIZED_OBJECT_LIST(FORWARD_DECL)
#undef FORWARD_DECL #undef FORWARD_DECL
// There are five 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
// base class (ObjectData), i.e. it's basically just the handle. Because the // base class (ObjectData), i.e. it's basically just the handle. Because the
...@@ -62,9 +62,8 @@ HEAP_BROKER_NEVER_SERIALIZED_OBJECT_LIST(FORWARD_DECL) ...@@ -62,9 +62,8 @@ HEAP_BROKER_NEVER_SERIALIZED_OBJECT_LIST(FORWARD_DECL)
// data is an instance of the corresponding (most-specific) subclass, e.g. // data is an instance of the corresponding (most-specific) subclass, e.g.
// JSFunctionData, which provides serialized information about the object. // JSFunctionData, which provides serialized information about the object.
// //
// kPossiblyBackgroundSerializedHeapObject: Like kSerializedHeapObject, but // kBackgroundSerializedHeapObject: Like kSerializedHeapObject, but
// allows serialization from the background thread where this is safe // allows serialization from the background thread.
// (indicated by corresponding ObjectRef constructor argument).
// //
// kUnserializedHeapObject: The underlying V8 object is a HeapObject and the // kUnserializedHeapObject: The underlying V8 object is a HeapObject and the
// data is an instance of the base class (ObjectData), i.e. it basically // data is an instance of the base class (ObjectData), i.e. it basically
...@@ -83,7 +82,6 @@ HEAP_BROKER_NEVER_SERIALIZED_OBJECT_LIST(FORWARD_DECL) ...@@ -83,7 +82,6 @@ HEAP_BROKER_NEVER_SERIALIZED_OBJECT_LIST(FORWARD_DECL)
enum ObjectDataKind { enum ObjectDataKind {
kSmi, kSmi,
kSerializedHeapObject, kSerializedHeapObject,
kPossiblyBackgroundSerializedHeapObject,
kBackgroundSerializedHeapObject, kBackgroundSerializedHeapObject,
kUnserializedHeapObject, kUnserializedHeapObject,
kNeverSerializedHeapObject, kNeverSerializedHeapObject,
...@@ -139,7 +137,6 @@ class ObjectData : public ZoneObject { ...@@ -139,7 +137,6 @@ class ObjectData : public ZoneObject {
CHECK_IMPLIES(broker->mode() == JSHeapBroker::kSerialized, CHECK_IMPLIES(broker->mode() == JSHeapBroker::kSerialized,
kind == kUnserializedReadOnlyHeapObject || kind == kSmi || kind == kUnserializedReadOnlyHeapObject || kind == kSmi ||
kind == kNeverSerializedHeapObject || kind == kNeverSerializedHeapObject ||
kind == kPossiblyBackgroundSerializedHeapObject ||
kind == kBackgroundSerializedHeapObject); kind == kBackgroundSerializedHeapObject);
CHECK_IMPLIES(kind == kUnserializedReadOnlyHeapObject, CHECK_IMPLIES(kind == kUnserializedReadOnlyHeapObject,
IsReadOnlyHeapObject(*object)); IsReadOnlyHeapObject(*object));
...@@ -771,9 +768,9 @@ class RegExpBoilerplateDescriptionData : public HeapObjectData { ...@@ -771,9 +768,9 @@ class RegExpBoilerplateDescriptionData : public HeapObjectData {
class HeapNumberData : public HeapObjectData { class HeapNumberData : public HeapObjectData {
public: public:
HeapNumberData(JSHeapBroker* broker, ObjectData** storage, HeapNumberData(JSHeapBroker* broker, ObjectData** storage,
Handle<HeapNumber> object) Handle<HeapNumber> object,
: HeapObjectData(broker, storage, object, ObjectDataKind kind = ObjectDataKind::kSerializedHeapObject)
kPossiblyBackgroundSerializedHeapObject), : HeapObjectData(broker, storage, object, kind),
value_(object->value()) {} value_(object->value()) {}
double value() const { return value_; } double value() const { return value_; }
...@@ -1075,9 +1072,9 @@ class AllocationSiteData : public HeapObjectData { ...@@ -1075,9 +1072,9 @@ class AllocationSiteData : public HeapObjectData {
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,
: HeapObjectData(broker, storage, object, ObjectDataKind kind = ObjectDataKind::kSerializedHeapObject)
ObjectDataKind::kPossiblyBackgroundSerializedHeapObject), : HeapObjectData(broker, storage, object, kind),
as_uint64_(object->AsUint64(nullptr)) {} as_uint64_(object->AsUint64(nullptr)) {}
uint64_t AsUint64() const { return as_uint64_; } uint64_t AsUint64() const { return as_uint64_; }
...@@ -1105,7 +1102,8 @@ struct PropertyDescriptor { ...@@ -1105,7 +1102,8 @@ struct PropertyDescriptor {
class MapData : public HeapObjectData { class MapData : public HeapObjectData {
public: public:
MapData(JSHeapBroker* broker, ObjectData** storage, Handle<Map> object); MapData(JSHeapBroker* broker, ObjectData** storage, Handle<Map> object,
ObjectDataKind kind = ObjectDataKind::kSerializedHeapObject);
InstanceType instance_type() const { return instance_type_; } InstanceType instance_type() const { return instance_type_; }
int instance_size() const { return instance_size_; } int instance_size() const { return instance_size_; }
...@@ -1276,7 +1274,6 @@ HeapObjectData::HeapObjectData(JSHeapBroker* broker, ObjectData** storage, ...@@ -1276,7 +1274,6 @@ HeapObjectData::HeapObjectData(JSHeapBroker* broker, ObjectData** storage,
CHECK_IMPLIES(kind == kSerializedHeapObject, CHECK_IMPLIES(kind == kSerializedHeapObject,
broker->mode() == JSHeapBroker::kSerializing); broker->mode() == JSHeapBroker::kSerializing);
CHECK_IMPLIES(broker->mode() == JSHeapBroker::kSerialized, CHECK_IMPLIES(broker->mode() == JSHeapBroker::kSerialized,
kind == kPossiblyBackgroundSerializedHeapObject ||
kind == kBackgroundSerializedHeapObject); kind == kBackgroundSerializedHeapObject);
} }
...@@ -1313,9 +1310,9 @@ bool SupportsFastArrayResize(Isolate* isolate, Handle<Map> map) { ...@@ -1313,9 +1310,9 @@ bool SupportsFastArrayResize(Isolate* isolate, Handle<Map> map) {
} }
} // namespace } // namespace
MapData::MapData(JSHeapBroker* broker, ObjectData** storage, Handle<Map> object) MapData::MapData(JSHeapBroker* broker, ObjectData** storage, Handle<Map> object,
: HeapObjectData(broker, storage, object, ObjectDataKind kind)
ObjectDataKind::kPossiblyBackgroundSerializedHeapObject), : HeapObjectData(broker, storage, object, kind),
instance_type_(object->instance_type()), instance_type_(object->instance_type()),
instance_size_(object->instance_size()), instance_size_(object->instance_size()),
bit_field_(object->bit_field()), bit_field_(object->bit_field()),
...@@ -2191,27 +2188,11 @@ HEAP_BROKER_NEVER_SERIALIZED_OBJECT_LIST(DEFINE_IS) ...@@ -2191,27 +2188,11 @@ HEAP_BROKER_NEVER_SERIALIZED_OBJECT_LIST(DEFINE_IS)
Name##Data* ObjectData::As##Name() { \ Name##Data* ObjectData::As##Name() { \
CHECK(Is##Name()); \ CHECK(Is##Name()); \
CHECK(kind_ == kSerializedHeapObject || \ CHECK(kind_ == kSerializedHeapObject || \
kind_ == kPossiblyBackgroundSerializedHeapObject || \
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_SERIALIZED_OBJECT_LIST(DEFINE_AS)
#undef DEFINE_AS
#define DEFINE_AS(Name) \
Name##Data* ObjectData::As##Name() { \
CHECK(Is##Name()); \
CHECK_EQ(kind_, kPossiblyBackgroundSerializedHeapObject); \
return static_cast<Name##Data*>(this); \
}
HEAP_BROKER_POSSIBLY_BACKGROUND_SERIALIZED_OBJECT_LIST(DEFINE_AS) HEAP_BROKER_POSSIBLY_BACKGROUND_SERIALIZED_OBJECT_LIST(DEFINE_AS)
#undef DEFINE_AS
#define DEFINE_AS(Name) \
Name##Data* ObjectData::As##Name() { \
CHECK(Is##Name()); \
CHECK(kind_ == kSerializedHeapObject || \
kind_ == kBackgroundSerializedHeapObject); \
return static_cast<Name##Data*>(this); \
}
HEAP_BROKER_BACKGROUND_SERIALIZED_OBJECT_LIST(DEFINE_AS) HEAP_BROKER_BACKGROUND_SERIALIZED_OBJECT_LIST(DEFINE_AS)
#undef DEFINE_AS #undef DEFINE_AS
...@@ -2473,8 +2454,7 @@ bool ObjectRef::equals(const ObjectRef& other) const { ...@@ -2473,8 +2454,7 @@ bool ObjectRef::equals(const ObjectRef& other) const {
bool ObjectRef::ShouldHaveBeenSerialized() const { bool ObjectRef::ShouldHaveBeenSerialized() const {
return broker()->mode() == JSHeapBroker::kSerialized && return broker()->mode() == JSHeapBroker::kSerialized &&
(data()->kind() == kSerializedHeapObject || data()->kind() == kSerializedHeapObject;
data()->kind() == kPossiblyBackgroundSerializedHeapObject);
} }
Isolate* ObjectRef::isolate() const { return broker()->isolate(); } Isolate* ObjectRef::isolate() const { return broker()->isolate(); }
...@@ -2915,10 +2895,15 @@ ObjectData* JSHeapBroker::TryGetOrCreateData(Handle<Object> object, ...@@ -2915,10 +2895,15 @@ ObjectData* JSHeapBroker::TryGetOrCreateData(Handle<Object> object,
return nullptr; \ return nullptr; \
} \ } \
entry = refs_->LookupOrInsert(object.address()); \ entry = refs_->LookupOrInsert(object.address()); \
ObjectDataKind kind = (background_serialization == \
ObjectRef::BackgroundSerialization::kAllowed) \
? kBackgroundSerializedHeapObject \
: kSerializedHeapObject; \
object_data = zone()->New<name##Data>(this, &(entry->value), \ object_data = zone()->New<name##Data>(this, &(entry->value), \
Handle<name>::cast(object)); Handle<name>::cast(object), \
HEAP_BROKER_POSSIBLY_BACKGROUND_SERIALIZED_OBJECT_LIST( kind);
CREATE_DATA_FOR_POSSIBLE_SERIALIZATION) HEAP_BROKER_POSSIBLY_BACKGROUND_SERIALIZED_OBJECT_LIST(
CREATE_DATA_FOR_POSSIBLE_SERIALIZATION)
#undef CREATE_DATA_FOR_POSSIBLE_SERIALIZATION #undef CREATE_DATA_FOR_POSSIBLE_SERIALIZATION
#define CREATE_DATA_FOR_BACKGROUND_SERIALIZATION(name) \ #define CREATE_DATA_FOR_BACKGROUND_SERIALIZATION(name) \
} else if (object->Is##name()) { \ } else if (object->Is##name()) { \
......
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