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

[compiler] Use MakeRef for remaining types

This is 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: I26faa6bc1934662c81ae127dee64bddffa428de9
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2874165Reviewed-by: 's avatarSantiago Aboy Solanes <solanes@chromium.org>
Commit-Queue: Jakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#74371}
parent 202032c8
...@@ -2298,7 +2298,9 @@ void BytecodeGraphBuilder::VisitPopContext() { ...@@ -2298,7 +2298,9 @@ void BytecodeGraphBuilder::VisitPopContext() {
} }
void BytecodeGraphBuilder::VisitCreateClosure() { void BytecodeGraphBuilder::VisitCreateClosure() {
SharedFunctionInfoRef shared_info(broker(), GetConstantForIndexOperand(0)); SharedFunctionInfoRef shared_info =
MakeRef(broker(),
Handle<SharedFunctionInfo>::cast(GetConstantForIndexOperand(0)));
AllocationType allocation = AllocationType allocation =
interpreter::CreateClosureFlags::PretenuredBit::decode( interpreter::CreateClosureFlags::PretenuredBit::decode(
bytecode_iterator().GetFlagOperand(2)) bytecode_iterator().GetFlagOperand(2))
......
...@@ -697,7 +697,7 @@ void CompilationDependencies::DependOnStablePrototypeChains( ...@@ -697,7 +697,7 @@ void CompilationDependencies::DependOnStablePrototypeChains(
MapContainer const& receiver_maps, WhereToStart start, MapContainer const& receiver_maps, WhereToStart start,
base::Optional<JSObjectRef> last_prototype) { base::Optional<JSObjectRef> last_prototype) {
for (auto map : receiver_maps) { for (auto map : receiver_maps) {
MapRef receiver_map(broker_, map); MapRef receiver_map = MakeRef(broker_, map);
if (start == kStartAtReceiver) DependOnStableMap(receiver_map); if (start == kStartAtReceiver) DependOnStableMap(receiver_map);
if (receiver_map.IsPrimitiveMap()) { if (receiver_map.IsPrimitiveMap()) {
// Perform the implicit ToObject for primitives here. // Perform the implicit ToObject for primitives here.
......
...@@ -2869,7 +2869,7 @@ base::Optional<MapRef> JSObjectRef::GetObjectCreateMap() const { ...@@ -2869,7 +2869,7 @@ base::Optional<MapRef> JSObjectRef::GetObjectCreateMap() const {
Handle<Map> instance_map; Handle<Map> instance_map;
if (Map::TryGetObjectCreateMap(broker()->isolate(), object()) if (Map::TryGetObjectCreateMap(broker()->isolate(), object())
.ToHandle(&instance_map)) { .ToHandle(&instance_map)) {
return MapRef(broker(), instance_map); return MakeRef(broker(), instance_map);
} else { } else {
return base::Optional<MapRef>(); return base::Optional<MapRef>();
} }
...@@ -2877,7 +2877,7 @@ base::Optional<MapRef> JSObjectRef::GetObjectCreateMap() const { ...@@ -2877,7 +2877,7 @@ base::Optional<MapRef> JSObjectRef::GetObjectCreateMap() const {
ObjectData* map_data = data()->AsJSObject()->object_create_map(broker()); ObjectData* map_data = data()->AsJSObject()->object_create_map(broker());
if (map_data == nullptr) return base::Optional<MapRef>(); if (map_data == nullptr) return base::Optional<MapRef>();
if (map_data->should_access_heap()) { if (map_data->should_access_heap()) {
return MapRef(broker(), map_data->object()); return MakeRef(broker(), Handle<Map>::cast(map_data->object()));
} }
return MapRef(broker(), map_data->AsMap()); return MapRef(broker(), map_data->AsMap());
} }
...@@ -4367,7 +4367,7 @@ bool JSFunctionRef::serialized_code_and_feedback() const { ...@@ -4367,7 +4367,7 @@ bool JSFunctionRef::serialized_code_and_feedback() const {
CodeRef JSFunctionRef::code() const { CodeRef JSFunctionRef::code() const {
if (data_->should_access_heap() || broker()->is_concurrent_inlining()) { if (data_->should_access_heap() || broker()->is_concurrent_inlining()) {
return CodeRef(broker(), broker()->CanonicalPersistentHandle( return MakeRef(broker(), broker()->CanonicalPersistentHandle(
object()->code(kAcquireLoad))); object()->code(kAcquireLoad)));
} }
......
...@@ -275,6 +275,8 @@ class HeapObjectType { ...@@ -275,6 +275,8 @@ class HeapObjectType {
// Constructors are carefully defined such that we do a type check on // Constructors are carefully defined such that we do a type check on
// the outermost Ref class in the inheritance chain only. // 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 // TODO(jgruber): Remove DEFINE_REF_CONSTRUCTOR once all types use the new
// pattern based on TryMakeRef. // pattern based on TryMakeRef.
#define DEFINE_REF_CONSTRUCTOR(Name, Base) \ #define DEFINE_REF_CONSTRUCTOR(Name, Base) \
...@@ -686,7 +688,7 @@ class BigIntRef : public HeapObjectRef { ...@@ -686,7 +688,7 @@ class BigIntRef : public HeapObjectRef {
class V8_EXPORT_PRIVATE MapRef : public HeapObjectRef { class V8_EXPORT_PRIVATE MapRef : public HeapObjectRef {
public: public:
DEFINE_REF_CONSTRUCTOR(Map, HeapObjectRef) DEFINE_REF_CONSTRUCTOR2(Map, HeapObjectRef)
Handle<Map> object() const; Handle<Map> object() const;
...@@ -933,7 +935,7 @@ class ScopeInfoRef : public HeapObjectRef { ...@@ -933,7 +935,7 @@ class ScopeInfoRef : public HeapObjectRef {
class V8_EXPORT_PRIVATE SharedFunctionInfoRef : public HeapObjectRef { class V8_EXPORT_PRIVATE SharedFunctionInfoRef : public HeapObjectRef {
public: public:
DEFINE_REF_CONSTRUCTOR(SharedFunctionInfo, HeapObjectRef) DEFINE_REF_CONSTRUCTOR2(SharedFunctionInfo, HeapObjectRef)
Handle<SharedFunctionInfo> object() const; Handle<SharedFunctionInfo> object() const;
...@@ -1058,7 +1060,7 @@ class JSGlobalProxyRef : public JSObjectRef { ...@@ -1058,7 +1060,7 @@ class JSGlobalProxyRef : public JSObjectRef {
class CodeRef : public HeapObjectRef { class CodeRef : public HeapObjectRef {
public: public:
DEFINE_REF_CONSTRUCTOR(Code, HeapObjectRef) DEFINE_REF_CONSTRUCTOR2(Code, HeapObjectRef)
Handle<Code> object() const; Handle<Code> object() const;
......
This diff is collapsed.
...@@ -151,8 +151,8 @@ Reduction JSCreateLowering::ReduceJSCreateArguments(Node* node) { ...@@ -151,8 +151,8 @@ Reduction JSCreateLowering::ReduceJSCreateArguments(Node* node) {
FrameState frame_state{NodeProperties::GetFrameStateInput(node)}; FrameState frame_state{NodeProperties::GetFrameStateInput(node)};
Node* const control = graph()->start(); Node* const control = graph()->start();
FrameStateInfo state_info = frame_state.frame_state_info(); FrameStateInfo state_info = frame_state.frame_state_info();
SharedFunctionInfoRef shared(broker(), SharedFunctionInfoRef shared =
state_info.shared_info().ToHandleChecked()); MakeRef(broker(), state_info.shared_info().ToHandleChecked());
// Use the ArgumentsAccessStub for materializing both mapped and unmapped // Use the ArgumentsAccessStub for materializing both mapped and unmapped
// arguments object, but only for non-inlined (i.e. outermost) frames. // arguments object, but only for non-inlined (i.e. outermost) frames.
...@@ -404,7 +404,7 @@ Reduction JSCreateLowering::ReduceJSCreateGeneratorObject(Node* node) { ...@@ -404,7 +404,7 @@ Reduction JSCreateLowering::ReduceJSCreateGeneratorObject(Node* node) {
int parameter_count_no_receiver = shared.internal_formal_parameter_count(); int parameter_count_no_receiver = shared.internal_formal_parameter_count();
int length = parameter_count_no_receiver + int length = parameter_count_no_receiver +
shared.GetBytecodeArray().register_count(); shared.GetBytecodeArray().register_count();
MapRef fixed_array_map(broker(), factory()->fixed_array_map()); MapRef fixed_array_map = MakeRef(broker(), factory()->fixed_array_map());
AllocationBuilder ab(jsgraph(), effect, control); AllocationBuilder ab(jsgraph(), effect, control);
if (!ab.CanAllocateArray(length, fixed_array_map)) { if (!ab.CanAllocateArray(length, fixed_array_map)) {
return NoChange(); return NoChange();
...@@ -775,7 +775,7 @@ Reduction JSCreateLowering::ReduceJSCreateAsyncFunctionObject(Node* node) { ...@@ -775,7 +775,7 @@ Reduction JSCreateLowering::ReduceJSCreateAsyncFunctionObject(Node* node) {
Node* control = NodeProperties::GetControlInput(node); Node* control = NodeProperties::GetControlInput(node);
// Create the register file. // Create the register file.
MapRef fixed_array_map(broker(), factory()->fixed_array_map()); MapRef fixed_array_map = MakeRef(broker(), factory()->fixed_array_map());
AllocationBuilder ab(jsgraph(), effect, control); AllocationBuilder ab(jsgraph(), effect, control);
CHECK(ab.CanAllocateArray(register_count, fixed_array_map)); CHECK(ab.CanAllocateArray(register_count, fixed_array_map));
ab.AllocateArray(register_count, fixed_array_map); ab.AllocateArray(register_count, fixed_array_map);
...@@ -879,7 +879,7 @@ Reduction JSCreateLowering::ReduceJSCreateBoundFunction(Node* node) { ...@@ -879,7 +879,7 @@ Reduction JSCreateLowering::ReduceJSCreateBoundFunction(Node* node) {
CreateBoundFunctionParameters const& p = CreateBoundFunctionParameters const& p =
CreateBoundFunctionParametersOf(node->op()); CreateBoundFunctionParametersOf(node->op());
int const arity = static_cast<int>(p.arity()); int const arity = static_cast<int>(p.arity());
MapRef const map(broker(), p.map()); MapRef const map = MakeRef(broker(), p.map());
Node* bound_target_function = NodeProperties::GetValueInput(node, 0); Node* bound_target_function = NodeProperties::GetValueInput(node, 0);
Node* bound_this = NodeProperties::GetValueInput(node, 1); Node* bound_this = NodeProperties::GetValueInput(node, 1);
Node* effect = NodeProperties::GetEffectInput(node); Node* effect = NodeProperties::GetEffectInput(node);
...@@ -888,7 +888,7 @@ Reduction JSCreateLowering::ReduceJSCreateBoundFunction(Node* node) { ...@@ -888,7 +888,7 @@ Reduction JSCreateLowering::ReduceJSCreateBoundFunction(Node* node) {
// Create the [[BoundArguments]] for the result. // Create the [[BoundArguments]] for the result.
Node* bound_arguments = jsgraph()->EmptyFixedArrayConstant(); Node* bound_arguments = jsgraph()->EmptyFixedArrayConstant();
if (arity > 0) { if (arity > 0) {
MapRef fixed_array_map(broker(), factory()->fixed_array_map()); MapRef fixed_array_map = MakeRef(broker(), factory()->fixed_array_map());
AllocationBuilder ab(jsgraph(), effect, control); AllocationBuilder ab(jsgraph(), effect, control);
CHECK(ab.CanAllocateArray(arity, fixed_array_map)); CHECK(ab.CanAllocateArray(arity, fixed_array_map));
ab.AllocateArray(arity, fixed_array_map); ab.AllocateArray(arity, fixed_array_map);
...@@ -920,7 +920,7 @@ Reduction JSCreateLowering::ReduceJSCreateBoundFunction(Node* node) { ...@@ -920,7 +920,7 @@ Reduction JSCreateLowering::ReduceJSCreateBoundFunction(Node* node) {
Reduction JSCreateLowering::ReduceJSCreateClosure(Node* node) { Reduction JSCreateLowering::ReduceJSCreateClosure(Node* node) {
JSCreateClosureNode n(node); JSCreateClosureNode n(node);
CreateClosureParameters const& p = n.Parameters(); CreateClosureParameters const& p = n.Parameters();
SharedFunctionInfoRef shared(broker(), p.shared_info()); SharedFunctionInfoRef shared = MakeRef(broker(), p.shared_info());
FeedbackCellRef feedback_cell = n.GetFeedbackCellRefChecked(broker()); FeedbackCellRef feedback_cell = n.GetFeedbackCellRefChecked(broker());
HeapObjectRef code = MakeRef(broker(), p.code()); HeapObjectRef code = MakeRef(broker(), p.code());
Effect effect = n.effect(); Effect effect = n.effect();
...@@ -931,7 +931,7 @@ Reduction JSCreateLowering::ReduceJSCreateClosure(Node* node) { ...@@ -931,7 +931,7 @@ Reduction JSCreateLowering::ReduceJSCreateClosure(Node* node) {
// seen more than one instantiation, this simplifies the generated code and // seen more than one instantiation, this simplifies the generated code and
// also serves as a heuristic of which allocation sites benefit from it. // also serves as a heuristic of which allocation sites benefit from it.
if (!feedback_cell.map().equals( if (!feedback_cell.map().equals(
MapRef(broker(), factory()->many_closures_cell_map()))) { MakeRef(broker(), factory()->many_closures_cell_map()))) {
return NoChange(); return NoChange();
} }
...@@ -1037,7 +1037,7 @@ Reduction JSCreateLowering::ReduceJSCreateKeyValueArray(Node* node) { ...@@ -1037,7 +1037,7 @@ Reduction JSCreateLowering::ReduceJSCreateKeyValueArray(Node* node) {
Node* length = jsgraph()->Constant(2); Node* length = jsgraph()->Constant(2);
AllocationBuilder aa(jsgraph(), effect, graph()->start()); AllocationBuilder aa(jsgraph(), effect, graph()->start());
aa.AllocateArray(2, MapRef(broker(), factory()->fixed_array_map())); aa.AllocateArray(2, MakeRef(broker(), factory()->fixed_array_map()));
aa.Store(AccessBuilder::ForFixedArrayElement(PACKED_ELEMENTS), aa.Store(AccessBuilder::ForFixedArrayElement(PACKED_ELEMENTS),
jsgraph()->ZeroConstant(), key); jsgraph()->ZeroConstant(), key);
aa.Store(AccessBuilder::ForFixedArrayElement(PACKED_ELEMENTS), aa.Store(AccessBuilder::ForFixedArrayElement(PACKED_ELEMENTS),
...@@ -1357,7 +1357,7 @@ Reduction JSCreateLowering::ReduceJSCreateObject(Node* node) { ...@@ -1357,7 +1357,7 @@ Reduction JSCreateLowering::ReduceJSCreateObject(Node* node) {
if (instance_map.is_dictionary_map()) { if (instance_map.is_dictionary_map()) {
DCHECK_EQ(prototype_const.map().oddball_type(), OddballType::kNull); DCHECK_EQ(prototype_const.map().oddball_type(), OddballType::kNull);
// Allocate an empty NameDictionary as backing store for the properties. // Allocate an empty NameDictionary as backing store for the properties.
MapRef map(broker(), factory()->name_dictionary_map()); MapRef map = MakeRef(broker(), factory()->name_dictionary_map());
int capacity = int capacity =
NameDictionary::ComputeCapacity(NameDictionary::kInitialCapacity); NameDictionary::ComputeCapacity(NameDictionary::kInitialCapacity);
DCHECK(base::bits::IsPowerOfTwo(capacity)); DCHECK(base::bits::IsPowerOfTwo(capacity));
...@@ -1433,7 +1433,7 @@ Node* JSCreateLowering::TryAllocateArguments(Node* effect, Node* control, ...@@ -1433,7 +1433,7 @@ Node* JSCreateLowering::TryAllocateArguments(Node* effect, Node* control,
auto parameters_it = parameters_access.begin_without_receiver(); auto parameters_it = parameters_access.begin_without_receiver();
// Actually allocate the backing store. // Actually allocate the backing store.
MapRef fixed_array_map(broker(), factory()->fixed_array_map()); MapRef fixed_array_map = MakeRef(broker(), factory()->fixed_array_map());
AllocationBuilder ab(jsgraph(), effect, control); AllocationBuilder ab(jsgraph(), effect, control);
if (!ab.CanAllocateArray(argument_count, fixed_array_map)) { if (!ab.CanAllocateArray(argument_count, fixed_array_map)) {
return nullptr; return nullptr;
...@@ -1464,7 +1464,7 @@ Node* JSCreateLowering::TryAllocateRestArguments(Node* effect, Node* control, ...@@ -1464,7 +1464,7 @@ Node* JSCreateLowering::TryAllocateRestArguments(Node* effect, Node* control,
parameters_access.begin_without_receiver_and_skip(start_index); parameters_access.begin_without_receiver_and_skip(start_index);
// Actually allocate the backing store. // Actually allocate the backing store.
MapRef fixed_array_map(broker(), factory()->fixed_array_map()); MapRef fixed_array_map = MakeRef(broker(), factory()->fixed_array_map());
AllocationBuilder ab(jsgraph(), effect, control); AllocationBuilder ab(jsgraph(), effect, control);
if (!ab.CanAllocateArray(num_elements, fixed_array_map)) { if (!ab.CanAllocateArray(num_elements, fixed_array_map)) {
return nullptr; return nullptr;
...@@ -1499,14 +1499,14 @@ Node* JSCreateLowering::TryAllocateAliasedArguments( ...@@ -1499,14 +1499,14 @@ Node* JSCreateLowering::TryAllocateAliasedArguments(
int mapped_count = std::min(argument_count, parameter_count); int mapped_count = std::min(argument_count, parameter_count);
*has_aliased_arguments = true; *has_aliased_arguments = true;
MapRef sloppy_arguments_elements_map( MapRef sloppy_arguments_elements_map =
broker(), factory()->sloppy_arguments_elements_map()); MakeRef(broker(), factory()->sloppy_arguments_elements_map());
if (!AllocationBuilder::CanAllocateSloppyArgumentElements( if (!AllocationBuilder::CanAllocateSloppyArgumentElements(
mapped_count, sloppy_arguments_elements_map)) { mapped_count, sloppy_arguments_elements_map)) {
return nullptr; return nullptr;
} }
MapRef fixed_array_map(broker(), factory()->fixed_array_map()); MapRef fixed_array_map = MakeRef(broker(), factory()->fixed_array_map());
if (!AllocationBuilder::CanAllocateArray(argument_count, fixed_array_map)) { if (!AllocationBuilder::CanAllocateArray(argument_count, fixed_array_map)) {
return nullptr; return nullptr;
} }
...@@ -1564,8 +1564,8 @@ Node* JSCreateLowering::TryAllocateAliasedArguments( ...@@ -1564,8 +1564,8 @@ Node* JSCreateLowering::TryAllocateAliasedArguments(
} }
int mapped_count = parameter_count; int mapped_count = parameter_count;
MapRef sloppy_arguments_elements_map( MapRef sloppy_arguments_elements_map =
broker(), factory()->sloppy_arguments_elements_map()); MakeRef(broker(), factory()->sloppy_arguments_elements_map());
if (!AllocationBuilder::CanAllocateSloppyArgumentElements( if (!AllocationBuilder::CanAllocateSloppyArgumentElements(
mapped_count, sloppy_arguments_elements_map)) { mapped_count, sloppy_arguments_elements_map)) {
return nullptr; return nullptr;
...@@ -1620,7 +1620,7 @@ Node* JSCreateLowering::AllocateElements(Node* effect, Node* control, ...@@ -1620,7 +1620,7 @@ Node* JSCreateLowering::AllocateElements(Node* effect, Node* control,
// Actually allocate the backing store. // Actually allocate the backing store.
AllocationBuilder a(jsgraph(), effect, control); AllocationBuilder a(jsgraph(), effect, control);
a.AllocateArray(capacity, MapRef(broker(), elements_map), allocation); a.AllocateArray(capacity, MakeRef(broker(), elements_map), allocation);
for (int i = 0; i < capacity; ++i) { for (int i = 0; i < capacity; ++i) {
Node* index = jsgraph()->Constant(i); Node* index = jsgraph()->Constant(i);
a.Store(access, index, value); a.Store(access, index, value);
...@@ -1645,7 +1645,7 @@ Node* JSCreateLowering::AllocateElements(Node* effect, Node* control, ...@@ -1645,7 +1645,7 @@ Node* JSCreateLowering::AllocateElements(Node* effect, Node* control,
// Actually allocate the backing store. // Actually allocate the backing store.
AllocationBuilder a(jsgraph(), effect, control); AllocationBuilder a(jsgraph(), effect, control);
a.AllocateArray(capacity, MapRef(broker(), elements_map), allocation); a.AllocateArray(capacity, MakeRef(broker(), elements_map), allocation);
for (int i = 0; i < capacity; ++i) { for (int i = 0; i < capacity; ++i) {
Node* index = jsgraph()->Constant(i); Node* index = jsgraph()->Constant(i);
a.Store(access, index, values[i]); a.Store(access, index, values[i]);
...@@ -1699,7 +1699,7 @@ base::Optional<Node*> JSCreateLowering::TryAllocateFastLiteral( ...@@ -1699,7 +1699,7 @@ base::Optional<Node*> JSCreateLowering::TryAllocateFastLiteral(
AllocationBuilder builder(jsgraph(), effect, control); AllocationBuilder builder(jsgraph(), effect, control);
builder.Allocate(HeapNumber::kSize, allocation); builder.Allocate(HeapNumber::kSize, allocation);
builder.Store(AccessBuilder::ForMap(), builder.Store(AccessBuilder::ForMap(),
MapRef(broker(), factory()->heap_number_map())); MakeRef(broker(), factory()->heap_number_map()));
builder.Store(AccessBuilder::ForHeapNumberValue(), builder.Store(AccessBuilder::ForHeapNumberValue(),
jsgraph()->Constant(number)); jsgraph()->Constant(number));
value = effect = builder.Finish(); value = effect = builder.Finish();
......
...@@ -716,7 +716,7 @@ void JSGenericLowering::LowerJSCreateLiteralArray(Node* node) { ...@@ -716,7 +716,7 @@ void JSGenericLowering::LowerJSCreateLiteralArray(Node* node) {
void JSGenericLowering::LowerJSGetTemplateObject(Node* node) { void JSGenericLowering::LowerJSGetTemplateObject(Node* node) {
JSGetTemplateObjectNode n(node); JSGetTemplateObjectNode n(node);
GetTemplateObjectParameters const& p = n.Parameters(); GetTemplateObjectParameters const& p = n.Parameters();
SharedFunctionInfoRef shared(broker(), p.shared()); SharedFunctionInfoRef shared = MakeRef(broker(), p.shared());
TemplateObjectDescriptionRef description = MakeRef(broker(), p.description()); TemplateObjectDescriptionRef description = MakeRef(broker(), p.description());
DCHECK_EQ(node->op()->ControlInputCount(), 1); DCHECK_EQ(node->op()->ControlInputCount(), 1);
......
...@@ -466,7 +466,7 @@ ElementAccessFeedback::ElementAccessFeedback(Zone* zone, ...@@ -466,7 +466,7 @@ ElementAccessFeedback::ElementAccessFeedback(Zone* zone,
bool ElementAccessFeedback::HasOnlyStringMaps(JSHeapBroker* broker) const { bool ElementAccessFeedback::HasOnlyStringMaps(JSHeapBroker* broker) const {
for (auto const& group : transition_groups()) { for (auto const& group : transition_groups()) {
for (Handle<Map> map : group) { for (Handle<Map> map : group) {
if (!MapRef(broker, map).IsStringMap()) return false; if (!MakeRef(broker, map).IsStringMap()) return false;
} }
} }
return true; return true;
...@@ -996,7 +996,7 @@ ElementAccessFeedback const& JSHeapBroker::ProcessFeedbackMapsForElementAccess( ...@@ -996,7 +996,7 @@ ElementAccessFeedback const& JSHeapBroker::ProcessFeedbackMapsForElementAccess(
MapHandles possible_transition_targets; MapHandles possible_transition_targets;
possible_transition_targets.reserve(maps.size()); possible_transition_targets.reserve(maps.size());
for (Handle<Map> map : maps) { for (Handle<Map> map : maps) {
MapRef map_ref(this, map); MapRef map_ref = MakeRef(this, map);
map_ref.SerializeRootMap(); map_ref.SerializeRootMap();
if (CanInlineElementAccess(map_ref) && if (CanInlineElementAccess(map_ref) &&
......
...@@ -55,8 +55,7 @@ Reduction JSHeapCopyReducer::Reduce(Node* node) { ...@@ -55,8 +55,7 @@ Reduction JSHeapCopyReducer::Reduce(Node* node) {
case IrOpcode::kJSCreateArguments: { case IrOpcode::kJSCreateArguments: {
Node* const frame_state = NodeProperties::GetFrameStateInput(node); Node* const frame_state = NodeProperties::GetFrameStateInput(node);
FrameStateInfo state_info = FrameStateInfoOf(frame_state->op()); FrameStateInfo state_info = FrameStateInfoOf(frame_state->op());
SharedFunctionInfoRef shared(broker(), MakeRef(broker(), state_info.shared_info().ToHandleChecked());
state_info.shared_info().ToHandleChecked());
break; break;
} }
case IrOpcode::kJSCreateBlockContext: { case IrOpcode::kJSCreateBlockContext: {
......
...@@ -124,7 +124,7 @@ JSInliningHeuristic::Candidate JSInliningHeuristic::CollectFunctions( ...@@ -124,7 +124,7 @@ JSInliningHeuristic::Candidate JSInliningHeuristic::CollectFunctions(
JSCreateClosureNode n(callee); JSCreateClosureNode n(callee);
CreateClosureParameters const& p = n.Parameters(); CreateClosureParameters const& p = n.Parameters();
FeedbackCellRef feedback_cell = n.GetFeedbackCellRefChecked(broker()); FeedbackCellRef feedback_cell = n.GetFeedbackCellRefChecked(broker());
SharedFunctionInfoRef shared_info(broker(), p.shared_info()); SharedFunctionInfoRef shared_info = MakeRef(broker(), p.shared_info());
out.shared_info = shared_info; out.shared_info = shared_info;
if (feedback_cell.value().has_value() && if (feedback_cell.value().has_value() &&
CanConsiderForInlining(broker(), shared_info, *feedback_cell.value())) { CanConsiderForInlining(broker(), shared_info, *feedback_cell.value())) {
......
...@@ -475,7 +475,8 @@ Reduction JSInliner::ReduceJSCall(Node* node) { ...@@ -475,7 +475,8 @@ Reduction JSInliner::ReduceJSCall(Node* node) {
if (!shared_info.has_value()) return NoChange(); if (!shared_info.has_value()) return NoChange();
DCHECK(shared_info->IsInlineable()); DCHECK(shared_info->IsInlineable());
SharedFunctionInfoRef outer_shared_info(broker(), info_->shared_info()); SharedFunctionInfoRef outer_shared_info =
MakeRef(broker(), info_->shared_info());
// Constructor must be constructable. // Constructor must be constructable.
if (node->opcode() == IrOpcode::kJSConstruct && if (node->opcode() == IrOpcode::kJSConstruct &&
......
...@@ -36,7 +36,7 @@ namespace { ...@@ -36,7 +36,7 @@ namespace {
bool HasNumberMaps(JSHeapBroker* broker, ZoneVector<Handle<Map>> const& maps) { bool HasNumberMaps(JSHeapBroker* broker, ZoneVector<Handle<Map>> const& maps) {
for (auto map : maps) { for (auto map : maps) {
MapRef map_ref(broker, map); MapRef map_ref = MakeRef(broker, map);
if (map_ref.IsHeapNumberMap()) return true; if (map_ref.IsHeapNumberMap()) return true;
} }
return false; return false;
...@@ -45,7 +45,7 @@ bool HasNumberMaps(JSHeapBroker* broker, ZoneVector<Handle<Map>> const& maps) { ...@@ -45,7 +45,7 @@ bool HasNumberMaps(JSHeapBroker* broker, ZoneVector<Handle<Map>> const& maps) {
bool HasOnlyJSArrayMaps(JSHeapBroker* broker, bool HasOnlyJSArrayMaps(JSHeapBroker* broker,
ZoneVector<Handle<Map>> const& maps) { ZoneVector<Handle<Map>> const& maps) {
for (auto map : maps) { for (auto map : maps) {
MapRef map_ref(broker, map); MapRef map_ref = MakeRef(broker, map);
if (!map_ref.IsJSArrayMap()) return false; if (!map_ref.IsJSArrayMap()) return false;
} }
return true; return true;
...@@ -228,13 +228,13 @@ Reduction JSNativeContextSpecialization::ReduceJSAsyncFunctionEnter( ...@@ -228,13 +228,13 @@ Reduction JSNativeContextSpecialization::ReduceJSAsyncFunctionEnter(
// Create the JSAsyncFunctionObject based on the SharedFunctionInfo // Create the JSAsyncFunctionObject based on the SharedFunctionInfo
// extracted from the top-most frame in {frame_state}. // extracted from the top-most frame in {frame_state}.
SharedFunctionInfoRef shared( SharedFunctionInfoRef shared = MakeRef(
broker(), broker(),
FrameStateInfoOf(frame_state->op()).shared_info().ToHandleChecked()); FrameStateInfoOf(frame_state->op()).shared_info().ToHandleChecked());
DCHECK(shared.is_compiled()); DCHECK(shared.is_compiled());
int register_count = shared.internal_formal_parameter_count() + int register_count = shared.internal_formal_parameter_count() +
shared.GetBytecodeArray().register_count(); shared.GetBytecodeArray().register_count();
MapRef fixed_array_map(broker(), factory()->fixed_array_map()); MapRef fixed_array_map = MakeRef(broker(), factory()->fixed_array_map());
AllocationBuilder ab(jsgraph(), effect, control); AllocationBuilder ab(jsgraph(), effect, control);
if (!ab.CanAllocateArray(register_count, fixed_array_map)) { if (!ab.CanAllocateArray(register_count, fixed_array_map)) {
return NoChange(); return NoChange();
...@@ -540,7 +540,7 @@ JSNativeContextSpecialization::InferHasInPrototypeChain( ...@@ -540,7 +540,7 @@ JSNativeContextSpecialization::InferHasInPrototypeChain(
bool all = true; bool all = true;
bool none = true; bool none = true;
for (size_t i = 0; i < receiver_maps.size(); ++i) { for (size_t i = 0; i < receiver_maps.size(); ++i) {
MapRef map(broker(), receiver_maps[i]); MapRef map = MakeRef(broker(), receiver_maps[i]);
if (result == NodeProperties::kUnreliableMaps && !map.is_stable()) { if (result == NodeProperties::kUnreliableMaps && !map.is_stable()) {
return kMayBeInPrototypeChain; return kMayBeInPrototypeChain;
} }
...@@ -741,7 +741,7 @@ Reduction JSNativeContextSpecialization::ReduceJSResolvePromise(Node* node) { ...@@ -741,7 +741,7 @@ Reduction JSNativeContextSpecialization::ReduceJSResolvePromise(Node* node) {
} else { } else {
// Obtain pre-computed access infos from the broker. // Obtain pre-computed access infos from the broker.
for (auto map : resolution_maps) { for (auto map : resolution_maps) {
MapRef map_ref(broker(), map); MapRef map_ref = MakeRef(broker(), map);
access_infos.push_back(broker()->GetPropertyAccessInfo( access_infos.push_back(broker()->GetPropertyAccessInfo(
map_ref, MakeRef(broker(), isolate()->factory()->then_string()), map_ref, MakeRef(broker(), isolate()->factory()->then_string()),
AccessMode::kLoad, dependencies())); AccessMode::kLoad, dependencies()));
...@@ -1193,7 +1193,8 @@ Reduction JSNativeContextSpecialization::ReduceNamedAccess( ...@@ -1193,7 +1193,8 @@ Reduction JSNativeContextSpecialization::ReduceNamedAccess(
// contexts' global proxy, and turn that into a direct access to the // contexts' global proxy, and turn that into a direct access to the
// corresponding global object instead. // corresponding global object instead.
if (lookup_start_object_maps.size() == 1) { if (lookup_start_object_maps.size() == 1) {
MapRef lookup_start_object_map(broker(), lookup_start_object_maps[0]); MapRef lookup_start_object_map =
MakeRef(broker(), lookup_start_object_maps[0]);
if (lookup_start_object_map.equals( if (lookup_start_object_map.equals(
broker()->target_native_context().global_proxy_object().map()) && broker()->target_native_context().global_proxy_object().map()) &&
!broker()->target_native_context().global_object().IsDetached()) { !broker()->target_native_context().global_object().IsDetached()) {
...@@ -1206,7 +1207,7 @@ Reduction JSNativeContextSpecialization::ReduceNamedAccess( ...@@ -1206,7 +1207,7 @@ Reduction JSNativeContextSpecialization::ReduceNamedAccess(
{ {
ZoneVector<PropertyAccessInfo> access_infos_for_feedback(zone()); ZoneVector<PropertyAccessInfo> access_infos_for_feedback(zone());
for (Handle<Map> map_handle : lookup_start_object_maps) { for (Handle<Map> map_handle : lookup_start_object_maps) {
MapRef map(broker(), map_handle); MapRef map = MakeRef(broker(), map_handle);
if (map.is_deprecated()) continue; if (map.is_deprecated()) continue;
PropertyAccessInfo access_info = broker()->GetPropertyAccessInfo( PropertyAccessInfo access_info = broker()->GetPropertyAccessInfo(
map, feedback.name(), access_mode, dependencies(), map, feedback.name(), access_mode, dependencies(),
...@@ -1674,7 +1675,7 @@ void JSNativeContextSpecialization::RemoveImpossibleMaps( ...@@ -1674,7 +1675,7 @@ void JSNativeContextSpecialization::RemoveImpossibleMaps(
maps->erase( maps->erase(
std::remove_if(maps->begin(), maps->end(), std::remove_if(maps->begin(), maps->end(),
[root_map, this](Handle<Map> map) { [root_map, this](Handle<Map> map) {
MapRef map_ref(broker(), map); MapRef map_ref = MakeRef(broker(), map);
return map_ref.is_abandoned_prototype_map() || return map_ref.is_abandoned_prototype_map() ||
(map_ref.FindRootMap().has_value() && (map_ref.FindRootMap().has_value() &&
!map_ref.FindRootMap()->equals(*root_map)); !map_ref.FindRootMap()->equals(*root_map));
...@@ -1763,7 +1764,7 @@ Reduction JSNativeContextSpecialization::ReduceElementAccess( ...@@ -1763,7 +1764,7 @@ Reduction JSNativeContextSpecialization::ReduceElementAccess(
ZoneVector<MapRef> prototype_maps(zone()); ZoneVector<MapRef> prototype_maps(zone());
for (ElementAccessInfo const& access_info : access_infos) { for (ElementAccessInfo const& access_info : access_infos) {
for (Handle<Map> map : access_info.lookup_start_object_maps()) { for (Handle<Map> map : access_info.lookup_start_object_maps()) {
MapRef receiver_map(broker(), map); MapRef receiver_map = MakeRef(broker(), map);
// If the {receiver_map} has a prototype and its elements backing // If the {receiver_map} has a prototype and its elements backing
// store is either holey, or we have a potentially growing store, // store is either holey, or we have a potentially growing store,
// then we need to check that all prototypes have stable maps with // then we need to check that all prototypes have stable maps with
...@@ -1810,11 +1811,11 @@ Reduction JSNativeContextSpecialization::ReduceElementAccess( ...@@ -1810,11 +1811,11 @@ Reduction JSNativeContextSpecialization::ReduceElementAccess(
ElementAccessInfo access_info = access_infos.front(); ElementAccessInfo access_info = access_infos.front();
// Perform possible elements kind transitions. // Perform possible elements kind transitions.
MapRef transition_target(broker(), MapRef transition_target =
access_info.lookup_start_object_maps().front()); MakeRef(broker(), access_info.lookup_start_object_maps().front());
for (auto source : access_info.transition_sources()) { for (auto source : access_info.transition_sources()) {
DCHECK_EQ(access_info.lookup_start_object_maps().size(), 1); DCHECK_EQ(access_info.lookup_start_object_maps().size(), 1);
MapRef transition_source(broker(), source); MapRef transition_source = MakeRef(broker(), source);
effect = graph()->NewNode( effect = graph()->NewNode(
simplified()->TransitionElementsKind(ElementsTransition( simplified()->TransitionElementsKind(ElementsTransition(
IsSimpleMapChangeTransition(transition_source.elements_kind(), IsSimpleMapChangeTransition(transition_source.elements_kind(),
...@@ -1862,10 +1863,10 @@ Reduction JSNativeContextSpecialization::ReduceElementAccess( ...@@ -1862,10 +1863,10 @@ Reduction JSNativeContextSpecialization::ReduceElementAccess(
Node* this_control = fallthrough_control; Node* this_control = fallthrough_control;
// Perform possible elements kind transitions. // Perform possible elements kind transitions.
MapRef transition_target(broker(), MapRef transition_target =
access_info.lookup_start_object_maps().front()); MakeRef(broker(), access_info.lookup_start_object_maps().front());
for (auto source : access_info.transition_sources()) { for (auto source : access_info.transition_sources()) {
MapRef transition_source(broker(), source); MapRef transition_source = MakeRef(broker(), source);
DCHECK_EQ(access_info.lookup_start_object_maps().size(), 1); DCHECK_EQ(access_info.lookup_start_object_maps().size(), 1);
this_effect = graph()->NewNode( this_effect = graph()->NewNode(
simplified()->TransitionElementsKind(ElementsTransition( simplified()->TransitionElementsKind(ElementsTransition(
...@@ -2513,7 +2514,7 @@ JSNativeContextSpecialization::BuildPropertyStore( ...@@ -2513,7 +2514,7 @@ JSNativeContextSpecialization::BuildPropertyStore(
a.Allocate(HeapNumber::kSize, AllocationType::kYoung, a.Allocate(HeapNumber::kSize, AllocationType::kYoung,
Type::OtherInternal()); Type::OtherInternal());
a.Store(AccessBuilder::ForMap(), a.Store(AccessBuilder::ForMap(),
MapRef(broker(), factory()->heap_number_map())); MakeRef(broker(), factory()->heap_number_map()));
FieldAccess value_field_access = AccessBuilder::ForHeapNumberValue(); FieldAccess value_field_access = AccessBuilder::ForHeapNumberValue();
value_field_access.const_field_info = field_access.const_field_info; value_field_access.const_field_info = field_access.const_field_info;
a.Store(value_field_access, value); a.Store(value_field_access, value);
...@@ -2620,7 +2621,7 @@ JSNativeContextSpecialization::BuildPropertyStore( ...@@ -2620,7 +2621,7 @@ JSNativeContextSpecialization::BuildPropertyStore(
if (access_info.transition_map().ToHandle(&transition_map)) { if (access_info.transition_map().ToHandle(&transition_map)) {
// Check if we need to grow the properties backing store // Check if we need to grow the properties backing store
// with this transitioning store. // with this transitioning store.
MapRef transition_map_ref(broker(), transition_map); MapRef transition_map_ref = MakeRef(broker(), transition_map);
MapRef original_map = transition_map_ref.GetBackPointer().AsMap(); MapRef original_map = transition_map_ref.GetBackPointer().AsMap();
if (original_map.UnusedPropertyFields() == 0) { if (original_map.UnusedPropertyFields() == 0) {
DCHECK(!field_index.is_inobject()); DCHECK(!field_index.is_inobject());
...@@ -3470,7 +3471,7 @@ bool JSNativeContextSpecialization::CanTreatHoleAsUndefined( ...@@ -3470,7 +3471,7 @@ bool JSNativeContextSpecialization::CanTreatHoleAsUndefined(
// or Object.prototype objects as their prototype (in any of the current // or Object.prototype objects as their prototype (in any of the current
// native contexts, as the global Array protector works isolate-wide). // native contexts, as the global Array protector works isolate-wide).
for (Handle<Map> map : receiver_maps) { for (Handle<Map> map : receiver_maps) {
MapRef receiver_map(broker(), map); MapRef receiver_map = MakeRef(broker(), map);
ObjectRef receiver_prototype = receiver_map.prototype(); ObjectRef receiver_prototype = receiver_map.prototype();
if (!receiver_prototype.IsJSObject() || if (!receiver_prototype.IsJSObject() ||
!broker()->IsArrayOrObjectPrototype(receiver_prototype.AsJSObject())) { !broker()->IsArrayOrObjectPrototype(receiver_prototype.AsJSObject())) {
...@@ -3496,7 +3497,7 @@ bool JSNativeContextSpecialization::InferMaps( ...@@ -3496,7 +3497,7 @@ bool JSNativeContextSpecialization::InferMaps(
// For untrusted maps, we can still use the information // For untrusted maps, we can still use the information
// if the maps are stable. // if the maps are stable.
for (size_t i = 0; i < map_set.size(); ++i) { for (size_t i = 0; i < map_set.size(); ++i) {
MapRef map(broker(), map_set[i]); MapRef map = MakeRef(broker(), map_set[i]);
if (!map.is_stable()) return false; if (!map.is_stable()) return false;
} }
for (size_t i = 0; i < map_set.size(); ++i) { for (size_t i = 0; i < map_set.size(); ++i) {
......
...@@ -1629,8 +1629,8 @@ Reduction JSTypedLowering::ReduceJSConstruct(Node* node) { ...@@ -1629,8 +1629,8 @@ Reduction JSTypedLowering::ReduceJSConstruct(Node* node) {
// Patch {node} to an indirect call via the {function}s construct stub. // Patch {node} to an indirect call via the {function}s construct stub.
bool use_builtin_construct_stub = function.shared().construct_as_builtin(); bool use_builtin_construct_stub = function.shared().construct_as_builtin();
CodeRef code(broker(), CodeRef code = MakeRef(
use_builtin_construct_stub broker(), use_builtin_construct_stub
? BUILTIN_CODE(isolate(), JSBuiltinsConstructStub) ? BUILTIN_CODE(isolate(), JSBuiltinsConstructStub)
: BUILTIN_CODE(isolate(), JSConstructStubGeneric)); : BUILTIN_CODE(isolate(), JSConstructStubGeneric));
STATIC_ASSERT(JSConstructNode::TargetIndex() == 0); STATIC_ASSERT(JSConstructNode::TargetIndex() == 0);
...@@ -1713,7 +1713,7 @@ Reduction JSTypedLowering::ReduceJSCall(Node* node) { ...@@ -1713,7 +1713,7 @@ Reduction JSTypedLowering::ReduceJSCall(Node* node) {
} else if (target->opcode() == IrOpcode::kJSCreateClosure) { } else if (target->opcode() == IrOpcode::kJSCreateClosure) {
CreateClosureParameters const& ccp = CreateClosureParameters const& ccp =
JSCreateClosureNode{target}.Parameters(); JSCreateClosureNode{target}.Parameters();
shared = SharedFunctionInfoRef(broker(), ccp.shared_info()); shared = MakeRef(broker(), ccp.shared_info());
} else if (target->opcode() == IrOpcode::kCheckClosure) { } else if (target->opcode() == IrOpcode::kCheckClosure) {
FeedbackCellRef cell = MakeRef(broker(), FeedbackCellOf(target->op())); FeedbackCellRef cell = MakeRef(broker(), FeedbackCellOf(target->op()));
base::Optional<FeedbackVectorRef> feedback_vector = cell.value(); base::Optional<FeedbackVectorRef> feedback_vector = cell.value();
......
...@@ -68,7 +68,7 @@ bool MapInference::AllOfInstanceTypesUnsafe( ...@@ -68,7 +68,7 @@ bool MapInference::AllOfInstanceTypesUnsafe(
CHECK(HaveMaps()); CHECK(HaveMaps());
auto instance_type = [this, f](Handle<Map> map) { auto instance_type = [this, f](Handle<Map> map) {
MapRef map_ref(broker_, map); MapRef map_ref = MakeRef(broker_, map);
return f(map_ref.instance_type()); return f(map_ref.instance_type());
}; };
return std::all_of(maps_.begin(), maps_.end(), instance_type); return std::all_of(maps_.begin(), maps_.end(), instance_type);
...@@ -79,7 +79,7 @@ bool MapInference::AnyOfInstanceTypesUnsafe( ...@@ -79,7 +79,7 @@ bool MapInference::AnyOfInstanceTypesUnsafe(
CHECK(HaveMaps()); CHECK(HaveMaps());
auto instance_type = [this, f](Handle<Map> map) { auto instance_type = [this, f](Handle<Map> map) {
MapRef map_ref(broker_, map); MapRef map_ref = MakeRef(broker_, map);
return f(map_ref.instance_type()); return f(map_ref.instance_type());
}; };
...@@ -134,13 +134,13 @@ bool MapInference::RelyOnMapsHelper(CompilationDependencies* dependencies, ...@@ -134,13 +134,13 @@ bool MapInference::RelyOnMapsHelper(CompilationDependencies* dependencies,
if (Safe()) return true; if (Safe()) return true;
auto is_stable = [this](Handle<Map> map) { auto is_stable = [this](Handle<Map> map) {
MapRef map_ref(broker_, map); MapRef map_ref = MakeRef(broker_, map);
return map_ref.is_stable(); return map_ref.is_stable();
}; };
if (dependencies != nullptr && if (dependencies != nullptr &&
std::all_of(maps_.cbegin(), maps_.cend(), is_stable)) { std::all_of(maps_.cbegin(), maps_.cend(), is_stable)) {
for (Handle<Map> map : maps_) { for (Handle<Map> map : maps_) {
dependencies->DependOnStableMap(MapRef(broker_, map)); dependencies->DependOnStableMap(MakeRef(broker_, map));
} }
SetGuarded(); SetGuarded();
return true; return true;
......
...@@ -2650,7 +2650,8 @@ bool PipelineImpl::CreateGraph() { ...@@ -2650,7 +2650,8 @@ bool PipelineImpl::CreateGraph() {
// Determine the Typer operation flags. // Determine the Typer operation flags.
{ {
SharedFunctionInfoRef shared_info(data->broker(), info()->shared_info()); SharedFunctionInfoRef shared_info =
MakeRef(data->broker(), info()->shared_info());
if (is_sloppy(shared_info.language_mode()) && if (is_sloppy(shared_info.language_mode()) &&
shared_info.IsUserJavaScript()) { shared_info.IsUserJavaScript()) {
// Sloppy mode functions always have an Object for this. // Sloppy mode functions always have an Object for this.
......
...@@ -35,7 +35,7 @@ SimplifiedOperatorBuilder* PropertyAccessBuilder::simplified() const { ...@@ -35,7 +35,7 @@ SimplifiedOperatorBuilder* PropertyAccessBuilder::simplified() const {
bool HasOnlyStringMaps(JSHeapBroker* broker, bool HasOnlyStringMaps(JSHeapBroker* broker,
ZoneVector<Handle<Map>> const& maps) { ZoneVector<Handle<Map>> const& maps) {
for (auto map : maps) { for (auto map : maps) {
MapRef map_ref(broker, map); MapRef map_ref = MakeRef(broker, map);
if (!map_ref.IsStringMap()) return false; if (!map_ref.IsStringMap()) return false;
} }
return true; return true;
...@@ -46,7 +46,7 @@ namespace { ...@@ -46,7 +46,7 @@ namespace {
bool HasOnlyNumberMaps(JSHeapBroker* broker, bool HasOnlyNumberMaps(JSHeapBroker* broker,
ZoneVector<Handle<Map>> const& maps) { ZoneVector<Handle<Map>> const& maps) {
for (auto map : maps) { for (auto map : maps) {
MapRef map_ref(broker, map); MapRef map_ref = MakeRef(broker, map);
if (map_ref.instance_type() != HEAP_NUMBER_TYPE) return false; if (map_ref.instance_type() != HEAP_NUMBER_TYPE) return false;
} }
return true; return true;
...@@ -89,7 +89,7 @@ void PropertyAccessBuilder::BuildCheckMaps( ...@@ -89,7 +89,7 @@ void PropertyAccessBuilder::BuildCheckMaps(
MapRef object_map = m.Ref(broker()).map(); MapRef object_map = m.Ref(broker()).map();
if (object_map.is_stable()) { if (object_map.is_stable()) {
for (Handle<Map> map : maps) { for (Handle<Map> map : maps) {
if (MapRef(broker(), map).equals(object_map)) { if (MakeRef(broker(), map).equals(object_map)) {
dependencies()->DependOnStableMap(object_map); dependencies()->DependOnStableMap(object_map);
return; return;
} }
...@@ -99,7 +99,7 @@ void PropertyAccessBuilder::BuildCheckMaps( ...@@ -99,7 +99,7 @@ void PropertyAccessBuilder::BuildCheckMaps(
ZoneHandleSet<Map> map_set; ZoneHandleSet<Map> map_set;
CheckMapsFlags flags = CheckMapsFlag::kNone; CheckMapsFlags flags = CheckMapsFlag::kNone;
for (Handle<Map> map : maps) { for (Handle<Map> map : maps) {
MapRef object_map(broker(), map); MapRef object_map = MakeRef(broker(), map);
map_set.insert(object_map.object(), graph()->zone()); map_set.insert(object_map.object(), graph()->zone());
if (object_map.is_migration_target()) { if (object_map.is_migration_target()) {
flags |= CheckMapsFlag::kTryMigrateInstance; flags |= CheckMapsFlag::kTryMigrateInstance;
...@@ -198,7 +198,7 @@ Node* PropertyAccessBuilder::TryFoldLoadConstantDataField( ...@@ -198,7 +198,7 @@ Node* PropertyAccessBuilder::TryFoldLoadConstantDataField(
if (std::find_if( if (std::find_if(
access_info.lookup_start_object_maps().begin(), access_info.lookup_start_object_maps().begin(),
access_info.lookup_start_object_maps().end(), [&](Handle<Map> map) { access_info.lookup_start_object_maps().end(), [&](Handle<Map> map) {
return MapRef(broker(), map).equals(lookup_start_object_map); return MakeRef(broker(), map).equals(lookup_start_object_map);
}) == access_info.lookup_start_object_maps().end()) { }) == access_info.lookup_start_object_maps().end()) {
// The map of the lookup_start_object is not in the feedback, let us bail // The map of the lookup_start_object is not in the feedback, let us bail
// out. // out.
...@@ -330,7 +330,7 @@ Node* PropertyAccessBuilder::BuildLoadDataField( ...@@ -330,7 +330,7 @@ Node* PropertyAccessBuilder::BuildLoadDataField(
// used by the LoadElimination to eliminate map checks on the result. // used by the LoadElimination to eliminate map checks on the result.
Handle<Map> field_map; Handle<Map> field_map;
if (access_info.field_map().ToHandle(&field_map)) { if (access_info.field_map().ToHandle(&field_map)) {
MapRef field_map_ref(broker(), field_map); MapRef field_map_ref = MakeRef(broker(), field_map);
if (field_map_ref.is_stable()) { if (field_map_ref.is_stable()) {
dependencies()->DependOnStableMap(field_map_ref); dependencies()->DependOnStableMap(field_map_ref);
field_access.map = field_map; field_access.map = field_map;
......
...@@ -1148,7 +1148,7 @@ Hints SerializerForBackgroundCompilation::Run() { ...@@ -1148,7 +1148,7 @@ Hints SerializerForBackgroundCompilation::Run() {
TRACE_BROKER_MEMORY(broker(), "[serializer start] Broker zone usage: " TRACE_BROKER_MEMORY(broker(), "[serializer start] Broker zone usage: "
<< broker()->zone()->allocation_size()); << broker()->zone()->allocation_size());
SharedFunctionInfoRef shared(broker(), function().shared()); SharedFunctionInfoRef shared = MakeRef(broker(), function().shared());
FeedbackVectorRef feedback_vector_ref = MakeRef(broker(), feedback_vector()); FeedbackVectorRef feedback_vector_ref = MakeRef(broker(), feedback_vector());
if (!broker()->ShouldBeSerializedForCompilation(shared, feedback_vector_ref, if (!broker()->ShouldBeSerializedForCompilation(shared, feedback_vector_ref,
arguments_)) { arguments_)) {
...@@ -2277,7 +2277,7 @@ void SerializerForBackgroundCompilation::ProcessApiCall( ...@@ -2277,7 +2277,7 @@ void SerializerForBackgroundCompilation::ProcessApiCall(
if (!target_template_info.has_call_code()) return; if (!target_template_info.has_call_code()) return;
target_template_info.SerializeCallCode(); target_template_info.SerializeCallCode();
SharedFunctionInfoRef target_ref(broker(), target); SharedFunctionInfoRef target_ref = MakeRef(broker(), target);
target_ref.SerializeFunctionTemplateInfo(); target_ref.SerializeFunctionTemplateInfo();
if (target_template_info.accept_any_receiver() && if (target_template_info.accept_any_receiver() &&
...@@ -2313,7 +2313,7 @@ void SerializerForBackgroundCompilation::ProcessApiCall( ...@@ -2313,7 +2313,7 @@ void SerializerForBackgroundCompilation::ProcessApiCall(
void SerializerForBackgroundCompilation::ProcessReceiverMapForApiCall( void SerializerForBackgroundCompilation::ProcessReceiverMapForApiCall(
FunctionTemplateInfoRef target, Handle<Map> receiver) { FunctionTemplateInfoRef target, Handle<Map> receiver) {
if (!receiver->is_access_check_needed()) { if (!receiver->is_access_check_needed()) {
MapRef receiver_map(broker(), receiver); MapRef receiver_map = MakeRef(broker(), receiver);
TRACE_BROKER(broker(), "Serializing holder for target: " << target); TRACE_BROKER(broker(), "Serializing holder for target: " << target);
target.LookupHolderOfExpectedType(receiver_map, target.LookupHolderOfExpectedType(receiver_map,
SerializationPolicy::kSerializeIfNeeded); SerializationPolicy::kSerializeIfNeeded);
...@@ -2361,10 +2361,10 @@ void SerializerForBackgroundCompilation::ProcessBuiltinCall( ...@@ -2361,10 +2361,10 @@ void SerializerForBackgroundCompilation::ProcessBuiltinCall(
if (arguments.size() >= 1) { if (arguments.size() >= 1) {
ProcessMapHintsForPromises(arguments[0]); ProcessMapHintsForPromises(arguments[0]);
} }
SharedFunctionInfoRef( MakeRef(
broker(), broker(),
broker()->isolate()->factory()->promise_catch_finally_shared_fun()); broker()->isolate()->factory()->promise_catch_finally_shared_fun());
SharedFunctionInfoRef( MakeRef(
broker(), broker(),
broker()->isolate()->factory()->promise_then_finally_shared_fun()); broker()->isolate()->factory()->promise_then_finally_shared_fun());
} }
...@@ -2501,13 +2501,11 @@ void SerializerForBackgroundCompilation::ProcessBuiltinCall( ...@@ -2501,13 +2501,11 @@ void SerializerForBackgroundCompilation::ProcessBuiltinCall(
kMissingArgumentsAreUnknown, result_hints); kMissingArgumentsAreUnknown, result_hints);
} }
} }
SharedFunctionInfoRef( MakeRef(broker(), broker()
broker(), broker()
->isolate() ->isolate()
->factory() ->factory()
->promise_capability_default_reject_shared_fun()); ->promise_capability_default_reject_shared_fun());
SharedFunctionInfoRef( MakeRef(broker(), broker()
broker(), broker()
->isolate() ->isolate()
->factory() ->factory()
->promise_capability_default_resolve_shared_fun()); ->promise_capability_default_resolve_shared_fun());
...@@ -2612,7 +2610,7 @@ void SerializerForBackgroundCompilation::ProcessHintsForOrdinaryHasInstance( ...@@ -2612,7 +2610,7 @@ void SerializerForBackgroundCompilation::ProcessHintsForOrdinaryHasInstance(
void SerializerForBackgroundCompilation::ProcessHintsForHasInPrototypeChain( void SerializerForBackgroundCompilation::ProcessHintsForHasInPrototypeChain(
Hints const& instance_hints) { Hints const& instance_hints) {
auto processMap = [&](Handle<Map> map_handle) { auto processMap = [&](Handle<Map> map_handle) {
MapRef map(broker(), map_handle); MapRef map = MakeRef(broker(), map_handle);
while (map.IsJSObjectMap()) { while (map.IsJSObjectMap()) {
map.SerializePrototype(); map.SerializePrototype();
map = map.prototype().map(); map = map.prototype().map();
...@@ -2656,11 +2654,11 @@ void SerializerForBackgroundCompilation::ProcessMapHintsForPromises( ...@@ -2656,11 +2654,11 @@ void SerializerForBackgroundCompilation::ProcessMapHintsForPromises(
if (!constant->IsJSPromise()) continue; if (!constant->IsJSPromise()) continue;
Handle<Map> map(Handle<HeapObject>::cast(constant)->map(), Handle<Map> map(Handle<HeapObject>::cast(constant)->map(),
broker()->isolate()); broker()->isolate());
MapRef(broker(), map).SerializePrototype(); MakeRef(broker(), map).SerializePrototype();
} }
for (auto map : receiver_hints.maps()) { for (auto map : receiver_hints.maps()) {
if (!map->IsJSPromiseMap()) continue; if (!map->IsJSPromiseMap()) continue;
MapRef(broker(), map).SerializePrototype(); MakeRef(broker(), map).SerializePrototype();
} }
} }
...@@ -2689,7 +2687,7 @@ void SerializerForBackgroundCompilation::ProcessHintsForRegExpTest( ...@@ -2689,7 +2687,7 @@ void SerializerForBackgroundCompilation::ProcessHintsForRegExpTest(
Handle<JSObject> regexp(Handle<JSObject>::cast(hint)); Handle<JSObject> regexp(Handle<JSObject>::cast(hint));
Handle<Map> regexp_map(regexp->map(), broker()->isolate()); Handle<Map> regexp_map(regexp->map(), broker()->isolate());
PropertyAccessInfo ai_exec = PropertyAccessInfo ai_exec =
ProcessMapForRegExpTest(MapRef(broker(), regexp_map)); ProcessMapForRegExpTest(MakeRef(broker(), regexp_map));
Handle<JSObject> holder; Handle<JSObject> holder;
if (ai_exec.IsFastDataConstant() && !ai_exec.holder().ToHandle(&holder)) { if (ai_exec.IsFastDataConstant() && !ai_exec.holder().ToHandle(&holder)) {
// The property is on the object itself. // The property is on the object itself.
...@@ -2702,7 +2700,7 @@ void SerializerForBackgroundCompilation::ProcessHintsForRegExpTest( ...@@ -2702,7 +2700,7 @@ void SerializerForBackgroundCompilation::ProcessHintsForRegExpTest(
for (auto map : regexp_hints.maps()) { for (auto map : regexp_hints.maps()) {
if (!map->IsJSRegExpMap()) continue; if (!map->IsJSRegExpMap()) continue;
ProcessMapForRegExpTest(MapRef(broker(), map)); ProcessMapForRegExpTest(MakeRef(broker(), map));
} }
} }
...@@ -2732,7 +2730,7 @@ void SerializerForBackgroundCompilation::ProcessHintsForFunctionBind( ...@@ -2732,7 +2730,7 @@ void SerializerForBackgroundCompilation::ProcessHintsForFunctionBind(
for (auto map : receiver_hints.maps()) { for (auto map : receiver_hints.maps()) {
if (!map->IsJSFunctionMap()) continue; if (!map->IsJSFunctionMap()) continue;
MapRef map_ref(broker(), map); MapRef map_ref = MakeRef(broker(), map);
ProcessMapForFunctionBind(map_ref); ProcessMapForFunctionBind(map_ref);
} }
} }
...@@ -2890,7 +2888,7 @@ void SerializerForBackgroundCompilation::ProcessCheckContextExtensions( ...@@ -2890,7 +2888,7 @@ void SerializerForBackgroundCompilation::ProcessCheckContextExtensions(
ProcessContextAccess(context_hints, Context::EXTENSION_INDEX, i, ProcessContextAccess(context_hints, Context::EXTENSION_INDEX, i,
kSerializeSlot); kSerializeSlot);
} }
SharedFunctionInfoRef shared(broker(), function().shared()); SharedFunctionInfoRef shared = MakeRef(broker(), function().shared());
shared.SerializeScopeInfoChain(); shared.SerializeScopeInfoChain();
} }
...@@ -3105,7 +3103,7 @@ SerializerForBackgroundCompilation::ProcessMapForNamedPropertyAccess( ...@@ -3105,7 +3103,7 @@ SerializerForBackgroundCompilation::ProcessMapForNamedPropertyAccess(
if (access_info.IsDataField() || access_info.IsFastDataConstant()) { if (access_info.IsDataField() || access_info.IsFastDataConstant()) {
Handle<Map> transition_map; Handle<Map> transition_map;
if (access_info.transition_map().ToHandle(&transition_map)) { if (access_info.transition_map().ToHandle(&transition_map)) {
MapRef map_ref(broker(), transition_map); MapRef map_ref = MakeRef(broker(), transition_map);
TRACE_BROKER(broker(), "Propagating transition map " TRACE_BROKER(broker(), "Propagating transition map "
<< map_ref << " to receiver hints."); << map_ref << " to receiver hints.");
receiver->AddMap(transition_map, zone(), broker_, false); receiver->AddMap(transition_map, zone(), broker_, false);
...@@ -3235,7 +3233,7 @@ void SerializerForBackgroundCompilation::ProcessNamedAccess( ...@@ -3235,7 +3233,7 @@ void SerializerForBackgroundCompilation::ProcessNamedAccess(
Hints* receiver, NamedAccessFeedback const& feedback, Hints* receiver, NamedAccessFeedback const& feedback,
AccessMode access_mode, Hints* result_hints) { AccessMode access_mode, Hints* result_hints) {
for (Handle<Map> map : feedback.maps()) { for (Handle<Map> map : feedback.maps()) {
MapRef map_ref(broker(), map); MapRef map_ref = MakeRef(broker(), map);
TRACE_BROKER(broker(), "Propagating feedback map " TRACE_BROKER(broker(), "Propagating feedback map "
<< map_ref << " to receiver hints."); << map_ref << " to receiver hints.");
receiver->AddMap(map, zone(), broker_, false); receiver->AddMap(map, zone(), broker_, false);
...@@ -3243,7 +3241,7 @@ void SerializerForBackgroundCompilation::ProcessNamedAccess( ...@@ -3243,7 +3241,7 @@ void SerializerForBackgroundCompilation::ProcessNamedAccess(
for (Handle<Map> map : for (Handle<Map> map :
GetRelevantReceiverMaps(broker()->isolate(), receiver->maps())) { GetRelevantReceiverMaps(broker()->isolate(), receiver->maps())) {
MapRef map_ref(broker(), map); MapRef map_ref = MakeRef(broker(), map);
ProcessMapForNamedPropertyAccess(receiver, map_ref, map_ref, ProcessMapForNamedPropertyAccess(receiver, map_ref, map_ref,
feedback.name(), access_mode, feedback.name(), access_mode,
base::nullopt, result_hints); base::nullopt, result_hints);
...@@ -3279,9 +3277,9 @@ void SerializerForBackgroundCompilation::ProcessNamedSuperAccess( ...@@ -3279,9 +3277,9 @@ void SerializerForBackgroundCompilation::ProcessNamedSuperAccess(
MapHandles receiver_maps = MapHandles receiver_maps =
GetRelevantReceiverMaps(broker()->isolate(), receiver->maps()); GetRelevantReceiverMaps(broker()->isolate(), receiver->maps());
for (Handle<Map> receiver_map : receiver_maps) { for (Handle<Map> receiver_map : receiver_maps) {
MapRef receiver_map_ref(broker(), receiver_map); MapRef receiver_map_ref = MakeRef(broker(), receiver_map);
for (Handle<Map> feedback_map : feedback.maps()) { for (Handle<Map> feedback_map : feedback.maps()) {
MapRef feedback_map_ref(broker(), feedback_map); MapRef feedback_map_ref = MakeRef(broker(), feedback_map);
ProcessMapForNamedPropertyAccess( ProcessMapForNamedPropertyAccess(
receiver, receiver_map_ref, feedback_map_ref, feedback.name(), receiver, receiver_map_ref, feedback_map_ref, feedback.name(),
access_mode, base::nullopt, result_hints); access_mode, base::nullopt, result_hints);
...@@ -3289,7 +3287,7 @@ void SerializerForBackgroundCompilation::ProcessNamedSuperAccess( ...@@ -3289,7 +3287,7 @@ void SerializerForBackgroundCompilation::ProcessNamedSuperAccess(
} }
if (receiver_maps.empty()) { if (receiver_maps.empty()) {
for (Handle<Map> feedback_map : feedback.maps()) { for (Handle<Map> feedback_map : feedback.maps()) {
MapRef feedback_map_ref(broker(), feedback_map); MapRef feedback_map_ref = MakeRef(broker(), feedback_map);
ProcessMapForNamedPropertyAccess( ProcessMapForNamedPropertyAccess(
receiver, base::nullopt, feedback_map_ref, feedback.name(), receiver, base::nullopt, feedback_map_ref, feedback.name(),
access_mode, base::nullopt, result_hints); access_mode, base::nullopt, result_hints);
...@@ -3302,7 +3300,7 @@ void SerializerForBackgroundCompilation::ProcessElementAccess( ...@@ -3302,7 +3300,7 @@ void SerializerForBackgroundCompilation::ProcessElementAccess(
ElementAccessFeedback const& feedback, AccessMode access_mode) { ElementAccessFeedback const& feedback, AccessMode access_mode) {
for (auto const& group : feedback.transition_groups()) { for (auto const& group : feedback.transition_groups()) {
for (Handle<Map> map_handle : group) { for (Handle<Map> map_handle : group) {
MapRef map(broker(), map_handle); MapRef map = MakeRef(broker(), map_handle);
switch (access_mode) { switch (access_mode) {
case AccessMode::kHas: case AccessMode::kHas:
case AccessMode::kLoad: case AccessMode::kLoad:
...@@ -3362,7 +3360,7 @@ void SerializerForBackgroundCompilation::ProcessElementAccess( ...@@ -3362,7 +3360,7 @@ void SerializerForBackgroundCompilation::ProcessElementAccess(
// For JSNativeContextSpecialization::InferRootMap // For JSNativeContextSpecialization::InferRootMap
for (Handle<Map> map : receiver.maps()) { for (Handle<Map> map : receiver.maps()) {
MapRef map_ref(broker(), map); MapRef map_ref = MakeRef(broker(), map);
map_ref.SerializeRootMap(); map_ref.SerializeRootMap();
} }
} }
......
...@@ -86,7 +86,7 @@ void CheckForSerializedInlinee(const char* source, int argc = 0, ...@@ -86,7 +86,7 @@ void CheckForSerializedInlinee(const char* source, int argc = 0,
tester.broker() tester.broker()
->FindCanonicalPersistentHandleForTesting<SharedFunctionInfo>( ->FindCanonicalPersistentHandleForTesting<SharedFunctionInfo>(
g_func->shared())); g_func->shared()));
SharedFunctionInfoRef g_sfi(tester.broker(), sfi); SharedFunctionInfoRef g_sfi = MakeRef(tester.broker(), sfi);
Handle<FeedbackVector> fv( Handle<FeedbackVector> fv(
tester.broker()->FindCanonicalPersistentHandleForTesting<FeedbackVector>( tester.broker()->FindCanonicalPersistentHandleForTesting<FeedbackVector>(
g_func->feedback_vector())); g_func->feedback_vector()));
......
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