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

[compiler] Remove the old Ref ctor generator macro

This is the final part of a CL series that establishes
MakeRef/TryMakeRef as the bottleneck for Ref construction. We do this by
converting direct constructor uses to (Try)MakeRef calls, and then
marking the ctor as protected.

Bug: v8:7790
Change-Id: I41bfa226d48cbdfee53b434ec52004eb6507e67a
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2874166
Commit-Queue: Jakob Gruber <jgruber@chromium.org>
Auto-Submit: Jakob Gruber <jgruber@chromium.org>
Reviewed-by: 's avatarSantiago Aboy Solanes <solanes@chromium.org>
Cr-Commit-Position: refs/heads/master@{#74372}
parent 2e8dd879
......@@ -2498,7 +2498,7 @@ ContextRef ContextRef::previous(size_t* depth,
current = Context::cast(current.unchecked_previous());
(*depth)--;
}
return ContextRef(broker(), broker()->CanonicalPersistentHandle(current));
return MakeRef(broker(), broker()->CanonicalPersistentHandle(current));
}
if (*depth == 0) return *this;
......@@ -2891,7 +2891,7 @@ INSTANCE_TYPE_CHECKERS(DEF_TESTER)
base::Optional<MapRef> MapRef::AsElementsKind(ElementsKind kind) const {
if (data_->should_access_heap()) {
return MapRef(broker(),
return MakeRef(broker(),
Map::AsElementsKind(broker()->isolate(), object(), kind));
}
if (kind == elements_kind()) return *this;
......@@ -2981,25 +2981,25 @@ OddballType MapRef::oddball_type() const {
return OddballType::kNone;
}
Factory* f = broker()->isolate()->factory();
if (equals(MapRef(broker(), f->undefined_map()))) {
if (equals(MakeRef(broker(), f->undefined_map()))) {
return OddballType::kUndefined;
}
if (equals(MapRef(broker(), f->null_map()))) {
if (equals(MakeRef(broker(), f->null_map()))) {
return OddballType::kNull;
}
if (equals(MapRef(broker(), f->boolean_map()))) {
if (equals(MakeRef(broker(), f->boolean_map()))) {
return OddballType::kBoolean;
}
if (equals(MapRef(broker(), f->the_hole_map()))) {
if (equals(MakeRef(broker(), f->the_hole_map()))) {
return OddballType::kHole;
}
if (equals(MapRef(broker(), f->uninitialized_map()))) {
if (equals(MakeRef(broker(), f->uninitialized_map()))) {
return OddballType::kUninitialized;
}
DCHECK(equals(MapRef(broker(), f->termination_exception_map())) ||
equals(MapRef(broker(), f->arguments_marker_map())) ||
equals(MapRef(broker(), f->optimized_out_map())) ||
equals(MapRef(broker(), f->stale_register_map())));
DCHECK(equals(MakeRef(broker(), f->termination_exception_map())) ||
equals(MakeRef(broker(), f->arguments_marker_map())) ||
equals(MakeRef(broker(), f->optimized_out_map())) ||
equals(MakeRef(broker(), f->stale_register_map())));
return OddballType::kOther;
}
......@@ -3103,7 +3103,7 @@ NameRef MapRef::GetPropertyKey(InternalIndex descriptor_index) const {
bool MapRef::IsFixedCowArrayMap() const {
Handle<Map> fixed_cow_array_map =
ReadOnlyRoots(broker()->isolate()).fixed_cow_array_map_handle();
return equals(MapRef(broker(), fixed_cow_array_map));
return equals(MakeRef(broker(), fixed_cow_array_map));
}
bool MapRef::IsPrimitiveMap() const {
......
......@@ -275,20 +275,7 @@ class HeapObjectType {
// Constructors are carefully defined such that we do a type check on
// the outermost Ref class in the inheritance chain only.
//
// Note this macro changes public/protected/private state.
// TODO(jgruber): Remove DEFINE_REF_CONSTRUCTOR once all types use the new
// pattern based on TryMakeRef.
#define DEFINE_REF_CONSTRUCTOR(Name, Base) \
Name##Ref(JSHeapBroker* broker, Handle<Object> object, \
BackgroundSerialization background_serialization = \
BackgroundSerialization::kDisallowed, \
bool check_type = true) \
: Base(broker, object, background_serialization, false) { \
if (check_type) { \
CHECK(Is##Name()); \
} \
} \
Name##Ref(JSHeapBroker* broker, ObjectData* data, bool check_type = true) \
: Base(broker, data, false) { \
if (check_type) { \
......@@ -296,37 +283,9 @@ class HeapObjectType {
} \
}
#define DEFINE_REF_CONSTRUCTOR2(Name, Base) \
public: \
Name##Ref(JSHeapBroker* broker, ObjectData* data, bool check_type = true) \
: Base(broker, data, false) { \
if (check_type) { \
CHECK(Is##Name()); \
} \
} \
\
protected: \
Name##Ref(JSHeapBroker* broker, Handle<Object> object, \
BackgroundSerialization background_serialization = \
BackgroundSerialization::kDisallowed, \
bool check_type = true) \
: Base(broker, object, background_serialization, false) { \
if (check_type) { \
CHECK(Is##Name()); \
} \
} \
template <class T, typename> \
friend base::Optional<typename ref_traits<T>::ref_type> TryMakeRef( \
JSHeapBroker*, T); \
template <class T, typename> \
friend base::Optional<typename ref_traits<T>::ref_type> TryMakeRef( \
JSHeapBroker*, Handle<T>); \
\
public:
class HeapObjectRef : public ObjectRef {
public:
DEFINE_REF_CONSTRUCTOR2(HeapObject, ObjectRef)
DEFINE_REF_CONSTRUCTOR(HeapObject, ObjectRef)
Handle<HeapObject> object() const;
......@@ -338,7 +297,7 @@ class HeapObjectRef : public ObjectRef {
class PropertyCellRef : public HeapObjectRef {
public:
DEFINE_REF_CONSTRUCTOR2(PropertyCell, HeapObjectRef)
DEFINE_REF_CONSTRUCTOR(PropertyCell, HeapObjectRef)
Handle<PropertyCell> object() const;
......@@ -357,14 +316,14 @@ class PropertyCellRef : public HeapObjectRef {
class JSReceiverRef : public HeapObjectRef {
public:
DEFINE_REF_CONSTRUCTOR2(JSReceiver, HeapObjectRef)
DEFINE_REF_CONSTRUCTOR(JSReceiver, HeapObjectRef)
Handle<JSReceiver> object() const;
};
class JSObjectRef : public JSReceiverRef {
public:
DEFINE_REF_CONSTRUCTOR2(JSObject, JSReceiverRef)
DEFINE_REF_CONSTRUCTOR(JSObject, JSReceiverRef)
Handle<JSObject> object() const;
......@@ -400,7 +359,7 @@ class JSObjectRef : public JSReceiverRef {
class JSDataViewRef : public JSObjectRef {
public:
DEFINE_REF_CONSTRUCTOR2(JSDataView, JSObjectRef)
DEFINE_REF_CONSTRUCTOR(JSDataView, JSObjectRef)
Handle<JSDataView> object() const;
......@@ -409,7 +368,7 @@ class JSDataViewRef : public JSObjectRef {
class JSBoundFunctionRef : public JSObjectRef {
public:
DEFINE_REF_CONSTRUCTOR2(JSBoundFunction, JSObjectRef)
DEFINE_REF_CONSTRUCTOR(JSBoundFunction, JSObjectRef)
Handle<JSBoundFunction> object() const;
......@@ -424,7 +383,7 @@ class JSBoundFunctionRef : public JSObjectRef {
class V8_EXPORT_PRIVATE JSFunctionRef : public JSObjectRef {
public:
DEFINE_REF_CONSTRUCTOR2(JSFunction, JSObjectRef)
DEFINE_REF_CONSTRUCTOR(JSFunction, JSObjectRef)
Handle<JSFunction> object() const;
......@@ -459,7 +418,7 @@ class V8_EXPORT_PRIVATE JSFunctionRef : public JSObjectRef {
class RegExpBoilerplateDescriptionRef : public HeapObjectRef {
public:
DEFINE_REF_CONSTRUCTOR2(RegExpBoilerplateDescription, HeapObjectRef)
DEFINE_REF_CONSTRUCTOR(RegExpBoilerplateDescription, HeapObjectRef)
Handle<RegExpBoilerplateDescription> object() const;
......@@ -472,7 +431,7 @@ class RegExpBoilerplateDescriptionRef : public HeapObjectRef {
class HeapNumberRef : public HeapObjectRef {
public:
DEFINE_REF_CONSTRUCTOR2(HeapNumber, HeapObjectRef)
DEFINE_REF_CONSTRUCTOR(HeapNumber, HeapObjectRef)
Handle<HeapNumber> object() const;
......@@ -481,7 +440,7 @@ class HeapNumberRef : public HeapObjectRef {
class ContextRef : public HeapObjectRef {
public:
DEFINE_REF_CONSTRUCTOR2(Context, HeapObjectRef)
DEFINE_REF_CONSTRUCTOR(Context, HeapObjectRef)
Handle<Context> object() const;
......@@ -565,7 +524,7 @@ class ContextRef : public HeapObjectRef {
class NativeContextRef : public ContextRef {
public:
DEFINE_REF_CONSTRUCTOR2(NativeContext, ContextRef)
DEFINE_REF_CONSTRUCTOR(NativeContext, ContextRef)
bool is_unserialized_heap_object() const;
......@@ -586,7 +545,7 @@ class NativeContextRef : public ContextRef {
class NameRef : public HeapObjectRef {
public:
DEFINE_REF_CONSTRUCTOR2(Name, HeapObjectRef)
DEFINE_REF_CONSTRUCTOR(Name, HeapObjectRef)
Handle<Name> object() const;
......@@ -595,7 +554,7 @@ class NameRef : public HeapObjectRef {
class DescriptorArrayRef : public HeapObjectRef {
public:
DEFINE_REF_CONSTRUCTOR2(DescriptorArray, HeapObjectRef)
DEFINE_REF_CONSTRUCTOR(DescriptorArray, HeapObjectRef)
Handle<DescriptorArray> object() const;
......@@ -608,7 +567,7 @@ class DescriptorArrayRef : public HeapObjectRef {
class FeedbackCellRef : public HeapObjectRef {
public:
DEFINE_REF_CONSTRUCTOR2(FeedbackCell, HeapObjectRef)
DEFINE_REF_CONSTRUCTOR(FeedbackCell, HeapObjectRef)
Handle<FeedbackCell> object() const;
base::Optional<SharedFunctionInfoRef> shared_function_info() const;
......@@ -622,7 +581,7 @@ class FeedbackCellRef : public HeapObjectRef {
class FeedbackVectorRef : public HeapObjectRef {
public:
DEFINE_REF_CONSTRUCTOR2(FeedbackVector, HeapObjectRef)
DEFINE_REF_CONSTRUCTOR(FeedbackVector, HeapObjectRef)
Handle<FeedbackVector> object() const;
......@@ -636,7 +595,7 @@ class FeedbackVectorRef : public HeapObjectRef {
class CallHandlerInfoRef : public HeapObjectRef {
public:
DEFINE_REF_CONSTRUCTOR2(CallHandlerInfo, HeapObjectRef)
DEFINE_REF_CONSTRUCTOR(CallHandlerInfo, HeapObjectRef)
Handle<CallHandlerInfo> object() const;
......@@ -646,14 +605,14 @@ class CallHandlerInfoRef : public HeapObjectRef {
class AccessorInfoRef : public HeapObjectRef {
public:
DEFINE_REF_CONSTRUCTOR2(AccessorInfo, HeapObjectRef)
DEFINE_REF_CONSTRUCTOR(AccessorInfo, HeapObjectRef)
Handle<AccessorInfo> object() const;
};
class AllocationSiteRef : public HeapObjectRef {
public:
DEFINE_REF_CONSTRUCTOR2(AllocationSite, HeapObjectRef)
DEFINE_REF_CONSTRUCTOR(AllocationSite, HeapObjectRef)
Handle<AllocationSite> object() const;
......@@ -679,7 +638,7 @@ class AllocationSiteRef : public HeapObjectRef {
class BigIntRef : public HeapObjectRef {
public:
DEFINE_REF_CONSTRUCTOR2(BigInt, HeapObjectRef)
DEFINE_REF_CONSTRUCTOR(BigInt, HeapObjectRef)
Handle<BigInt> object() const;
......@@ -688,7 +647,7 @@ class BigIntRef : public HeapObjectRef {
class V8_EXPORT_PRIVATE MapRef : public HeapObjectRef {
public:
DEFINE_REF_CONSTRUCTOR2(Map, HeapObjectRef)
DEFINE_REF_CONSTRUCTOR(Map, HeapObjectRef)
Handle<Map> object() const;
......@@ -775,7 +734,7 @@ struct HolderLookupResult {
class FunctionTemplateInfoRef : public HeapObjectRef {
public:
DEFINE_REF_CONSTRUCTOR2(FunctionTemplateInfo, HeapObjectRef)
DEFINE_REF_CONSTRUCTOR(FunctionTemplateInfo, HeapObjectRef)
Handle<FunctionTemplateInfo> object() const;
......@@ -796,7 +755,7 @@ class FunctionTemplateInfoRef : public HeapObjectRef {
class FixedArrayBaseRef : public HeapObjectRef {
public:
DEFINE_REF_CONSTRUCTOR2(FixedArrayBase, HeapObjectRef)
DEFINE_REF_CONSTRUCTOR(FixedArrayBase, HeapObjectRef)
Handle<FixedArrayBase> object() const;
......@@ -813,7 +772,7 @@ class ArrayBoilerplateDescriptionRef : public HeapObjectRef {
class FixedArrayRef : public FixedArrayBaseRef {
public:
DEFINE_REF_CONSTRUCTOR2(FixedArray, FixedArrayBaseRef)
DEFINE_REF_CONSTRUCTOR(FixedArray, FixedArrayBaseRef)
Handle<FixedArray> object() const;
......@@ -828,7 +787,7 @@ class FixedArrayRef : public FixedArrayBaseRef {
class FixedDoubleArrayRef : public FixedArrayBaseRef {
public:
DEFINE_REF_CONSTRUCTOR2(FixedDoubleArray, FixedArrayBaseRef)
DEFINE_REF_CONSTRUCTOR(FixedDoubleArray, FixedArrayBaseRef)
Handle<FixedDoubleArray> object() const;
......@@ -840,7 +799,7 @@ class FixedDoubleArrayRef : public FixedArrayBaseRef {
class BytecodeArrayRef : public FixedArrayBaseRef {
public:
DEFINE_REF_CONSTRUCTOR2(BytecodeArray, FixedArrayBaseRef)
DEFINE_REF_CONSTRUCTOR(BytecodeArray, FixedArrayBaseRef)
Handle<BytecodeArray> object() const;
......@@ -861,14 +820,14 @@ class BytecodeArrayRef : public FixedArrayBaseRef {
class ScriptContextTableRef : public FixedArrayRef {
public:
DEFINE_REF_CONSTRUCTOR2(ScriptContextTable, FixedArrayRef)
DEFINE_REF_CONSTRUCTOR(ScriptContextTable, FixedArrayRef)
Handle<ScriptContextTable> object() const;
};
class ObjectBoilerplateDescriptionRef : public FixedArrayRef {
public:
DEFINE_REF_CONSTRUCTOR2(ObjectBoilerplateDescription, FixedArrayRef)
DEFINE_REF_CONSTRUCTOR(ObjectBoilerplateDescription, FixedArrayRef)
Handle<ObjectBoilerplateDescription> object() const;
......@@ -877,7 +836,7 @@ class ObjectBoilerplateDescriptionRef : public FixedArrayRef {
class JSArrayRef : public JSObjectRef {
public:
DEFINE_REF_CONSTRUCTOR2(JSArray, JSObjectRef)
DEFINE_REF_CONSTRUCTOR(JSArray, JSObjectRef)
Handle<JSArray> object() const;
......@@ -903,7 +862,7 @@ class JSArrayRef : public JSObjectRef {
class ScopeInfoRef : public HeapObjectRef {
public:
DEFINE_REF_CONSTRUCTOR2(ScopeInfo, HeapObjectRef)
DEFINE_REF_CONSTRUCTOR(ScopeInfo, HeapObjectRef)
Handle<ScopeInfo> object() const;
......@@ -935,7 +894,7 @@ class ScopeInfoRef : public HeapObjectRef {
class V8_EXPORT_PRIVATE SharedFunctionInfoRef : public HeapObjectRef {
public:
DEFINE_REF_CONSTRUCTOR2(SharedFunctionInfo, HeapObjectRef)
DEFINE_REF_CONSTRUCTOR(SharedFunctionInfo, HeapObjectRef)
Handle<SharedFunctionInfo> object() const;
......@@ -961,7 +920,7 @@ class V8_EXPORT_PRIVATE SharedFunctionInfoRef : public HeapObjectRef {
class StringRef : public NameRef {
public:
DEFINE_REF_CONSTRUCTOR2(String, NameRef)
DEFINE_REF_CONSTRUCTOR(String, NameRef)
Handle<String> object() const;
......@@ -983,14 +942,14 @@ class StringRef : public NameRef {
class SymbolRef : public NameRef {
public:
DEFINE_REF_CONSTRUCTOR2(Symbol, NameRef)
DEFINE_REF_CONSTRUCTOR(Symbol, NameRef)
Handle<Symbol> object() const;
};
class JSTypedArrayRef : public JSObjectRef {
public:
DEFINE_REF_CONSTRUCTOR2(JSTypedArray, JSObjectRef)
DEFINE_REF_CONSTRUCTOR(JSTypedArray, JSObjectRef)
Handle<JSTypedArray> object() const;
......@@ -1007,7 +966,7 @@ class JSTypedArrayRef : public JSObjectRef {
class SourceTextModuleRef : public HeapObjectRef {
public:
DEFINE_REF_CONSTRUCTOR2(SourceTextModule, HeapObjectRef)
DEFINE_REF_CONSTRUCTOR(SourceTextModule, HeapObjectRef)
Handle<SourceTextModule> object() const;
......@@ -1019,21 +978,21 @@ class SourceTextModuleRef : public HeapObjectRef {
class TemplateObjectDescriptionRef : public HeapObjectRef {
public:
DEFINE_REF_CONSTRUCTOR2(TemplateObjectDescription, HeapObjectRef)
DEFINE_REF_CONSTRUCTOR(TemplateObjectDescription, HeapObjectRef)
Handle<TemplateObjectDescription> object() const;
};
class CellRef : public HeapObjectRef {
public:
DEFINE_REF_CONSTRUCTOR2(Cell, HeapObjectRef)
DEFINE_REF_CONSTRUCTOR(Cell, HeapObjectRef)
Handle<Cell> object() const;
};
class JSGlobalObjectRef : public JSObjectRef {
public:
DEFINE_REF_CONSTRUCTOR2(JSGlobalObject, JSObjectRef)
DEFINE_REF_CONSTRUCTOR(JSGlobalObject, JSObjectRef)
Handle<JSGlobalObject> object() const;
......@@ -1053,14 +1012,14 @@ class JSGlobalObjectRef : public JSObjectRef {
class JSGlobalProxyRef : public JSObjectRef {
public:
DEFINE_REF_CONSTRUCTOR2(JSGlobalProxy, JSObjectRef)
DEFINE_REF_CONSTRUCTOR(JSGlobalProxy, JSObjectRef)
Handle<JSGlobalProxy> object() const;
};
class CodeRef : public HeapObjectRef {
public:
DEFINE_REF_CONSTRUCTOR2(Code, HeapObjectRef)
DEFINE_REF_CONSTRUCTOR(Code, HeapObjectRef)
Handle<Code> object() const;
......@@ -1069,12 +1028,11 @@ class CodeRef : public HeapObjectRef {
class InternalizedStringRef : public StringRef {
public:
DEFINE_REF_CONSTRUCTOR2(InternalizedString, StringRef)
DEFINE_REF_CONSTRUCTOR(InternalizedString, StringRef)
Handle<InternalizedString> object() const;
};
#undef DEFINE_REF_CONSTRUCTOR2
#undef DEFINE_REF_CONSTRUCTOR
} // namespace compiler
......
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