[compiler] Add kNeverSerializedObject and its macros
This is a partial reland of 7b9a0c20f3
Reason for reland: Reverted since the ScopeInfoData part was causing
issues. Relanding the macro structure, which shouldn't cause issues
and it is needed for other CLs.
Original changes description:
> [compiler] Replace ScopeInfoData with direct reads
>
> As part of this, introduce a new ObjectData kind for objects that we
> want to read directly from the background thread rather than serialize.
> ScopeInfoRef is the first user of that.
>
> For details, see:
> https://docs.google.com/document/d/1U6x6Q2bpylfxS55nxSe17yyBW0bQG-ycoBhVA82VmS0/edit?usp=sharing
>
> Bug: v8:7790
> Change-Id: Ia3cda4f67d3922367afa4a5da2aeaae7160cf1f2
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2346405
> Auto-Submit: Georg Neis <neis@chromium.org>
> 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@{#69473}
Bug: v8:7790
Change-Id: I8d13dc206bb319638e3f7209446c24d06a07c110
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2377690
Commit-Queue: Santiago Aboy Solanes <solanes@chromium.org>
Reviewed-by: Ross McIlroy <rmcilroy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#69573}
This commit is contained in:
parent
e8662c6ca5
commit
8b1e3ddc18
@ -49,57 +49,59 @@ enum class OddballType : uint8_t {
|
||||
|
||||
// This list is sorted such that subtypes appear before their supertypes.
|
||||
// DO NOT VIOLATE THIS PROPERTY!
|
||||
#define HEAP_BROKER_OBJECT_LIST(V) \
|
||||
/* Subtypes of JSObject */ \
|
||||
V(JSArray) \
|
||||
V(JSBoundFunction) \
|
||||
V(JSDataView) \
|
||||
V(JSFunction) \
|
||||
V(JSGlobalObject) \
|
||||
V(JSGlobalProxy) \
|
||||
V(JSRegExp) \
|
||||
V(JSTypedArray) \
|
||||
/* Subtypes of Context */ \
|
||||
V(NativeContext) \
|
||||
/* Subtypes of FixedArray */ \
|
||||
V(Context) \
|
||||
V(ObjectBoilerplateDescription) \
|
||||
V(ScopeInfo) \
|
||||
V(ScriptContextTable) \
|
||||
/* Subtypes of FixedArrayBase */ \
|
||||
V(BytecodeArray) \
|
||||
V(FixedArray) \
|
||||
V(FixedDoubleArray) \
|
||||
/* Subtypes of Name */ \
|
||||
V(InternalizedString) \
|
||||
V(String) \
|
||||
V(Symbol) \
|
||||
/* Subtypes of JSReceiver */ \
|
||||
V(JSObject) \
|
||||
/* Subtypes of HeapObject */ \
|
||||
V(AccessorInfo) \
|
||||
V(AllocationSite) \
|
||||
V(ArrayBoilerplateDescription) \
|
||||
V(BigInt) \
|
||||
V(CallHandlerInfo) \
|
||||
V(Cell) \
|
||||
V(Code) \
|
||||
V(DescriptorArray) \
|
||||
V(FeedbackCell) \
|
||||
V(FeedbackVector) \
|
||||
V(FixedArrayBase) \
|
||||
V(FunctionTemplateInfo) \
|
||||
V(HeapNumber) \
|
||||
V(JSReceiver) \
|
||||
V(Map) \
|
||||
V(Name) \
|
||||
V(PropertyCell) \
|
||||
V(SharedFunctionInfo) \
|
||||
V(SourceTextModule) \
|
||||
V(TemplateObjectDescription) \
|
||||
/* Subtypes of Object */ \
|
||||
#define HEAP_BROKER_SERIALIZED_OBJECT_LIST(V) \
|
||||
/* Subtypes of JSObject */ \
|
||||
V(JSArray) \
|
||||
V(JSBoundFunction) \
|
||||
V(JSDataView) \
|
||||
V(JSFunction) \
|
||||
V(JSGlobalObject) \
|
||||
V(JSGlobalProxy) \
|
||||
V(JSRegExp) \
|
||||
V(JSTypedArray) \
|
||||
/* Subtypes of Context */ \
|
||||
V(NativeContext) \
|
||||
/* Subtypes of FixedArray */ \
|
||||
V(Context) \
|
||||
V(ObjectBoilerplateDescription) \
|
||||
V(ScopeInfo) \
|
||||
V(ScriptContextTable) \
|
||||
/* Subtypes of FixedArrayBase */ \
|
||||
V(BytecodeArray) \
|
||||
V(FixedArray) \
|
||||
V(FixedDoubleArray) \
|
||||
/* Subtypes of Name */ \
|
||||
V(InternalizedString) \
|
||||
V(String) \
|
||||
V(Symbol) \
|
||||
/* Subtypes of JSReceiver */ \
|
||||
V(JSObject) \
|
||||
/* Subtypes of HeapObject */ \
|
||||
V(AccessorInfo) \
|
||||
V(AllocationSite) \
|
||||
V(ArrayBoilerplateDescription) \
|
||||
V(BigInt) \
|
||||
V(CallHandlerInfo) \
|
||||
V(Cell) \
|
||||
V(Code) \
|
||||
V(DescriptorArray) \
|
||||
V(FeedbackCell) \
|
||||
V(FeedbackVector) \
|
||||
V(FixedArrayBase) \
|
||||
V(FunctionTemplateInfo) \
|
||||
V(HeapNumber) \
|
||||
V(JSReceiver) \
|
||||
V(Map) \
|
||||
V(Name) \
|
||||
V(PropertyCell) \
|
||||
V(SharedFunctionInfo) \
|
||||
V(SourceTextModule) \
|
||||
V(TemplateObjectDescription) \
|
||||
/* Subtypes of Object */ \
|
||||
V(HeapObject)
|
||||
|
||||
#define HEAP_BROKER_NEVER_SERIALIZED_OBJECT_LIST(V)
|
||||
|
||||
class CompilationDependencies;
|
||||
struct FeedbackSource;
|
||||
class JSHeapBroker;
|
||||
@ -107,7 +109,8 @@ class ObjectData;
|
||||
class PerIsolateCompilerCache;
|
||||
class PropertyAccessInfo;
|
||||
#define FORWARD_DECL(Name) class Name##Ref;
|
||||
HEAP_BROKER_OBJECT_LIST(FORWARD_DECL)
|
||||
HEAP_BROKER_SERIALIZED_OBJECT_LIST(FORWARD_DECL)
|
||||
HEAP_BROKER_NEVER_SERIALIZED_OBJECT_LIST(FORWARD_DECL)
|
||||
#undef FORWARD_DECL
|
||||
|
||||
class V8_EXPORT_PRIVATE ObjectRef {
|
||||
@ -127,11 +130,13 @@ class V8_EXPORT_PRIVATE ObjectRef {
|
||||
int AsSmi() const;
|
||||
|
||||
#define HEAP_IS_METHOD_DECL(Name) bool Is##Name() const;
|
||||
HEAP_BROKER_OBJECT_LIST(HEAP_IS_METHOD_DECL)
|
||||
HEAP_BROKER_SERIALIZED_OBJECT_LIST(HEAP_IS_METHOD_DECL)
|
||||
HEAP_BROKER_NEVER_SERIALIZED_OBJECT_LIST(HEAP_IS_METHOD_DECL)
|
||||
#undef HEAP_IS_METHOD_DECL
|
||||
|
||||
#define HEAP_AS_METHOD_DECL(Name) Name##Ref As##Name() const;
|
||||
HEAP_BROKER_OBJECT_LIST(HEAP_AS_METHOD_DECL)
|
||||
HEAP_BROKER_SERIALIZED_OBJECT_LIST(HEAP_AS_METHOD_DECL)
|
||||
HEAP_BROKER_NEVER_SERIALIZED_OBJECT_LIST(HEAP_AS_METHOD_DECL)
|
||||
#undef HEAP_AS_METHOD_DECL
|
||||
|
||||
bool IsNullOrUndefined() const;
|
||||
|
@ -45,7 +45,7 @@ namespace compiler {
|
||||
#define TRACE_MISSING(broker, x) TRACE_BROKER_MISSING(broker, x)
|
||||
|
||||
#define FORWARD_DECL(Name) class Name##Data;
|
||||
HEAP_BROKER_OBJECT_LIST(FORWARD_DECL)
|
||||
HEAP_BROKER_SERIALIZED_OBJECT_LIST(FORWARD_DECL)
|
||||
#undef FORWARD_DECL
|
||||
|
||||
// There are three kinds of ObjectData values.
|
||||
@ -71,6 +71,7 @@ enum ObjectDataKind {
|
||||
kSmi,
|
||||
kSerializedHeapObject,
|
||||
kUnserializedHeapObject,
|
||||
kNeverSerializedHeapObject,
|
||||
kUnserializedReadOnlyHeapObject
|
||||
};
|
||||
|
||||
@ -79,7 +80,8 @@ class AllowHandleAllocationIf {
|
||||
explicit AllowHandleAllocationIf(ObjectDataKind kind,
|
||||
JSHeapBroker::BrokerMode mode) {
|
||||
DCHECK_IMPLIES(mode == JSHeapBroker::BrokerMode::kSerialized,
|
||||
kind == kUnserializedReadOnlyHeapObject);
|
||||
kind == kUnserializedReadOnlyHeapObject ||
|
||||
kind == kNeverSerializedHeapObject);
|
||||
if (kind == kUnserializedHeapObject) maybe_allow_handle_.emplace();
|
||||
}
|
||||
|
||||
@ -90,16 +92,15 @@ class AllowHandleAllocationIf {
|
||||
class AllowHandleDereferenceIf {
|
||||
public:
|
||||
explicit AllowHandleDereferenceIf(ObjectDataKind kind,
|
||||
JSHeapBroker::BrokerMode mode) {
|
||||
JSHeapBroker::BrokerMode mode)
|
||||
: AllowHandleDereferenceIf(kind) {
|
||||
DCHECK_IMPLIES(mode == JSHeapBroker::BrokerMode::kSerialized,
|
||||
kind == kUnserializedReadOnlyHeapObject);
|
||||
if (kind == kUnserializedHeapObject ||
|
||||
kind == kUnserializedReadOnlyHeapObject)
|
||||
maybe_allow_handle_.emplace();
|
||||
kind == kUnserializedReadOnlyHeapObject ||
|
||||
kind == kNeverSerializedHeapObject);
|
||||
}
|
||||
|
||||
explicit AllowHandleDereferenceIf(ObjectDataKind kind) {
|
||||
if (kind == kUnserializedHeapObject ||
|
||||
if (kind == kUnserializedHeapObject || kind == kNeverSerializedHeapObject ||
|
||||
kind == kUnserializedReadOnlyHeapObject)
|
||||
maybe_allow_handle_.emplace();
|
||||
}
|
||||
@ -154,20 +155,26 @@ class ObjectData : public ZoneObject {
|
||||
broker->mode() == JSHeapBroker::kSerializing,
|
||||
broker->isolate()->handle_scope_data()->canonical_scope != nullptr);
|
||||
CHECK_IMPLIES(broker->mode() == JSHeapBroker::kSerialized,
|
||||
IsReadOnlyHeapObject(*object));
|
||||
(kind == kUnserializedReadOnlyHeapObject &&
|
||||
IsReadOnlyHeapObject(*object)) ||
|
||||
kind == kNeverSerializedHeapObject);
|
||||
}
|
||||
|
||||
#define DECLARE_IS_AND_AS(Name) \
|
||||
bool Is##Name() const; \
|
||||
Name##Data* As##Name();
|
||||
HEAP_BROKER_OBJECT_LIST(DECLARE_IS_AND_AS)
|
||||
#undef DECLARE_IS_AND_AS
|
||||
#define DECLARE_IS(Name) bool Is##Name() const;
|
||||
HEAP_BROKER_SERIALIZED_OBJECT_LIST(DECLARE_IS)
|
||||
HEAP_BROKER_NEVER_SERIALIZED_OBJECT_LIST(DECLARE_IS)
|
||||
#undef DECLARE_IS
|
||||
|
||||
#define DECLARE_AS(Name) Name##Data* As##Name();
|
||||
HEAP_BROKER_SERIALIZED_OBJECT_LIST(DECLARE_AS)
|
||||
#undef DECLARE_AS
|
||||
|
||||
Handle<Object> object() const { return object_; }
|
||||
ObjectDataKind kind() const { return kind_; }
|
||||
bool is_smi() const { return kind_ == kSmi; }
|
||||
bool should_access_heap() const {
|
||||
return kind_ == kUnserializedHeapObject ||
|
||||
kind_ == kNeverSerializedHeapObject ||
|
||||
kind_ == kUnserializedReadOnlyHeapObject;
|
||||
}
|
||||
|
||||
@ -2007,7 +2014,7 @@ class CodeData : public HeapObjectData {
|
||||
unsigned const inlined_bytecode_size_;
|
||||
};
|
||||
|
||||
#define DEFINE_IS_AND_AS(Name) \
|
||||
#define DEFINE_IS(Name) \
|
||||
bool ObjectData::Is##Name() const { \
|
||||
if (should_access_heap()) { \
|
||||
AllowHandleDereferenceIf allow_handle_dereference(kind()); \
|
||||
@ -2017,13 +2024,18 @@ class CodeData : public HeapObjectData {
|
||||
InstanceType instance_type = \
|
||||
static_cast<const HeapObjectData*>(this)->GetMapInstanceType(); \
|
||||
return InstanceTypeChecker::Is##Name(instance_type); \
|
||||
} \
|
||||
Name##Data* ObjectData::As##Name() { \
|
||||
CHECK(Is##Name()); \
|
||||
return static_cast<Name##Data*>(this); \
|
||||
}
|
||||
HEAP_BROKER_OBJECT_LIST(DEFINE_IS_AND_AS)
|
||||
#undef DEFINE_IS_AND_AS
|
||||
HEAP_BROKER_SERIALIZED_OBJECT_LIST(DEFINE_IS)
|
||||
HEAP_BROKER_NEVER_SERIALIZED_OBJECT_LIST(DEFINE_IS)
|
||||
#undef DEFINE_IS
|
||||
|
||||
#define DEFINE_AS(Name) \
|
||||
Name##Data* ObjectData::As##Name() { \
|
||||
CHECK(Is##Name()); \
|
||||
return static_cast<Name##Data*>(this); \
|
||||
}
|
||||
HEAP_BROKER_SERIALIZED_OBJECT_LIST(DEFINE_AS)
|
||||
#undef DEFINE_AS
|
||||
|
||||
const JSObjectField& JSObjectData::GetInobjectField(int property_index) const {
|
||||
CHECK_LT(static_cast<size_t>(property_index), inobject_fields_.size());
|
||||
@ -2697,15 +2709,20 @@ ObjectData* JSHeapBroker::GetOrCreateData(Handle<Object> object) {
|
||||
} else if (IsReadOnlyHeapObject(*object)) {
|
||||
object_data = zone()->New<ObjectData>(this, data_storage, object,
|
||||
kUnserializedReadOnlyHeapObject);
|
||||
#define CREATE_DATA_IF_MATCH(name) \
|
||||
#define CREATE_DATA_FOR_DIRECT_READ(name) \
|
||||
} else if (object->Is##name()) { \
|
||||
object_data = zone()->New<ObjectData>( \
|
||||
this, data_storage, object, kNeverSerializedHeapObject);
|
||||
HEAP_BROKER_NEVER_SERIALIZED_OBJECT_LIST(CREATE_DATA_FOR_DIRECT_READ)
|
||||
#undef CREATE_DATA_FOR_DIRECT_READ
|
||||
#define CREATE_DATA_FOR_SERIALIZATION(name) \
|
||||
} else if (object->Is##name()) { \
|
||||
CHECK(SerializingAllowed()); \
|
||||
AllowHandleAllocation handle_allocation; \
|
||||
object_data = zone()->New<name##Data>(this, data_storage, \
|
||||
Handle<name>::cast(object));
|
||||
|
||||
HEAP_BROKER_OBJECT_LIST(CREATE_DATA_IF_MATCH)
|
||||
#undef CREATE_DATA_IF_MATCH
|
||||
HEAP_BROKER_SERIALIZED_OBJECT_LIST(CREATE_DATA_FOR_SERIALIZATION)
|
||||
#undef CREATE_DATA_FOR_SERIALIZATION
|
||||
} else {
|
||||
UNREACHABLE();
|
||||
}
|
||||
@ -2718,7 +2735,7 @@ ObjectData* JSHeapBroker::GetOrCreateData(Handle<Object> object) {
|
||||
// clang-format on
|
||||
|
||||
ObjectData* JSHeapBroker::GetOrCreateData(Object object) {
|
||||
return GetOrCreateData(handle(object, isolate()));
|
||||
return GetOrCreateData(CanonicalPersistentHandle(object));
|
||||
}
|
||||
|
||||
#define DEFINE_IS_AND_AS(Name) \
|
||||
@ -2727,7 +2744,8 @@ ObjectData* JSHeapBroker::GetOrCreateData(Object object) {
|
||||
DCHECK(Is##Name()); \
|
||||
return Name##Ref(broker(), data()); \
|
||||
}
|
||||
HEAP_BROKER_OBJECT_LIST(DEFINE_IS_AND_AS)
|
||||
HEAP_BROKER_SERIALIZED_OBJECT_LIST(DEFINE_IS_AND_AS)
|
||||
HEAP_BROKER_NEVER_SERIALIZED_OBJECT_LIST(DEFINE_IS_AND_AS)
|
||||
#undef DEFINE_IS_AND_AS
|
||||
|
||||
bool ObjectRef::IsSmi() const { return data()->is_smi(); }
|
||||
@ -3267,8 +3285,6 @@ Handle<Object> JSHeapBroker::GetRootHandle(Object object) {
|
||||
|
||||
#define IF_ACCESS_FROM_HEAP_C(name) \
|
||||
if (data_->should_access_heap()) { \
|
||||
CHECK(broker()->mode() == JSHeapBroker::kDisabled || \
|
||||
ReadOnlyHeap::Contains(HeapObject::cast(*object()))); \
|
||||
AllowHandleAllocationIf handle_allocation(data_->kind(), \
|
||||
broker()->mode()); \
|
||||
AllowHandleDereferenceIf allow_handle_dereference(data_->kind(), \
|
||||
@ -3276,19 +3292,22 @@ Handle<Object> JSHeapBroker::GetRootHandle(Object object) {
|
||||
return object()->name(); \
|
||||
}
|
||||
|
||||
#define IF_ACCESS_FROM_HEAP(result, name) \
|
||||
if (data_->kind() == ObjectDataKind::kUnserializedHeapObject) { \
|
||||
AllowHandleAllocationIf handle_allocation(data_->kind(), \
|
||||
broker()->mode()); \
|
||||
AllowHandleDereferenceIf handle_dereference(data_->kind(), \
|
||||
broker()->mode()); \
|
||||
return result##Ref(broker(), \
|
||||
handle(object()->name(), broker()->isolate())); \
|
||||
} else if (data_->kind() == \
|
||||
ObjectDataKind::kUnserializedReadOnlyHeapObject) { \
|
||||
AllowHandleDereferenceIf handle_dereference(data_->kind(), \
|
||||
broker()->mode()); \
|
||||
return result##Ref(broker(), broker()->GetRootHandle(object()->name())); \
|
||||
#define IF_ACCESS_FROM_HEAP(result, name) \
|
||||
if (data_->kind() == ObjectDataKind::kUnserializedHeapObject) { \
|
||||
AllowHandleAllocationIf handle_allocation(data_->kind(), \
|
||||
broker()->mode()); \
|
||||
AllowHandleDereferenceIf handle_dereference(data_->kind(), \
|
||||
broker()->mode()); \
|
||||
return result##Ref(broker(), \
|
||||
handle(object()->name(), broker()->isolate())); \
|
||||
} else if (data_->kind() == \
|
||||
ObjectDataKind::kUnserializedReadOnlyHeapObject) { \
|
||||
AllowHandleDereferenceIf handle_dereference(data_->kind(), \
|
||||
broker()->mode()); \
|
||||
return result##Ref(broker(), broker()->GetRootHandle(object()->name())); \
|
||||
} else if (data_->kind() == ObjectDataKind::kNeverSerializedHeapObject) { \
|
||||
return result##Ref(broker(), \
|
||||
broker()->CanonicalPersistentHandle(object()->name())); \
|
||||
}
|
||||
|
||||
// Macros for definining a const getter that, depending on the broker mode,
|
||||
@ -3696,8 +3715,8 @@ ScopeInfoRef NativeContextRef::scope_info() const {
|
||||
broker()->mode());
|
||||
AllowHandleDereferenceIf allow_handle_dereference(data()->kind(),
|
||||
broker()->mode());
|
||||
return ScopeInfoRef(broker(),
|
||||
handle(object()->scope_info(), broker()->isolate()));
|
||||
return ScopeInfoRef(
|
||||
broker(), broker()->CanonicalPersistentHandle(object()->scope_info()));
|
||||
}
|
||||
return ScopeInfoRef(broker(), data()->AsNativeContext()->scope_info());
|
||||
}
|
||||
@ -4132,7 +4151,8 @@ Handle<Object> ObjectRef::object() const {
|
||||
}
|
||||
#endif // DEBUG
|
||||
|
||||
HEAP_BROKER_OBJECT_LIST(DEF_OBJECT_GETTER)
|
||||
HEAP_BROKER_SERIALIZED_OBJECT_LIST(DEF_OBJECT_GETTER)
|
||||
HEAP_BROKER_NEVER_SERIALIZED_OBJECT_LIST(DEF_OBJECT_GETTER)
|
||||
#undef DEF_OBJECT_GETTER
|
||||
|
||||
JSHeapBroker* ObjectRef::broker() const { return broker_; }
|
||||
@ -4301,8 +4321,8 @@ ScopeInfoRef SharedFunctionInfoRef::scope_info() const {
|
||||
broker()->mode());
|
||||
AllowHandleDereferenceIf allow_handle_dereference(data()->kind(),
|
||||
broker()->mode());
|
||||
return ScopeInfoRef(broker(),
|
||||
handle(object()->scope_info(), broker()->isolate()));
|
||||
return ScopeInfoRef(
|
||||
broker(), broker()->CanonicalPersistentHandle(object()->scope_info()));
|
||||
}
|
||||
return ScopeInfoRef(broker(), data()->AsSharedFunctionInfo()->scope_info());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user