From 8994347c35ed6ca91f6530f6ae17843f93bf9074 Mon Sep 17 00:00:00 2001 From: Georg Neis Date: Mon, 23 Jul 2018 18:36:52 +0200 Subject: [PATCH] [turbofan] Prepare broker for serialization. We'll soon start collecting data from the JS heap prior to the typed lowering pass, and then refrain from reading the heap in that pass. This CL prepares the broker machinery by introducing a hash table that maps an object (handle) to the corresponding cached data. For the time being, that cached data is essentially just the handle itself. Bug: v8:7790 Change-Id: I830e9c72faafb7ae1d10e8a111636b3a3762bbc6 Reviewed-on: https://chromium-review.googlesource.com/1143405 Commit-Queue: Georg Neis Reviewed-by: Maya Lekova Reviewed-by: Jaroslav Sevcik Cr-Commit-Position: refs/heads/master@{#54618} --- src/compiler/access-info.cc | 2 +- src/compiler/access-info.h | 6 +- src/compiler/common-operator-reducer.cc | 4 +- src/compiler/common-operator-reducer.h | 6 +- src/compiler/compilation-dependencies.cc | 4 +- src/compiler/compilation-dependencies.h | 2 +- src/compiler/constant-folding-reducer.cc | 4 +- src/compiler/constant-folding-reducer.h | 6 +- src/compiler/js-call-reducer.h | 4 +- src/compiler/js-context-specialization.cc | 2 +- src/compiler/js-context-specialization.h | 4 +- src/compiler/js-create-lowering.h | 6 +- src/compiler/js-heap-broker.cc | 83 ++++++++++++------ src/compiler/js-heap-broker.h | 85 ++++++++++--------- .../js-native-context-specialization.cc | 6 +- .../js-native-context-specialization.h | 6 +- src/compiler/js-typed-lowering.cc | 10 +-- src/compiler/js-typed-lowering.h | 6 +- src/compiler/node-matchers.h | 2 +- src/compiler/operation-typer.cc | 4 +- src/compiler/operation-typer.h | 3 +- src/compiler/pipeline.cc | 2 +- src/compiler/property-access-builder.h | 6 +- src/compiler/simplified-lowering.cc | 5 +- src/compiler/simplified-lowering.h | 6 +- src/compiler/simplified-operator-reducer.cc | 2 +- src/compiler/simplified-operator-reducer.h | 6 +- src/compiler/type-narrowing-reducer.cc | 2 +- src/compiler/type-narrowing-reducer.h | 2 +- src/compiler/typed-optimization.cc | 6 +- src/compiler/typed-optimization.h | 6 +- src/compiler/typer.cc | 2 +- src/compiler/typer.h | 6 +- src/compiler/types.cc | 25 +++--- src/compiler/types.h | 8 +- .../test-js-context-specialization.cc | 2 +- .../cctest/compiler/test-js-typed-lowering.cc | 2 +- test/cctest/test-field-type-tracking.cc | 10 +-- test/cctest/types-fuzz.h | 4 +- .../common-operator-reducer-unittest.cc | 2 +- .../constant-folding-reducer-unittest.cc | 4 +- test/unittests/compiler/graph-unittest.cc | 2 +- test/unittests/compiler/graph-unittest.h | 2 +- .../compiler/js-call-reducer-unittest.cc | 2 +- .../simplified-operator-reducer-unittest.cc | 2 +- test/unittests/compiler/typer-unittest.cc | 2 +- 46 files changed, 205 insertions(+), 168 deletions(-) diff --git a/src/compiler/access-info.cc b/src/compiler/access-info.cc index 2e0cbe0c81..a8307cb3f9 100644 --- a/src/compiler/access-info.cc +++ b/src/compiler/access-info.cc @@ -237,7 +237,7 @@ Handle PropertyAccessInfo::export_cell() const { return Handle::cast(constant_); } -AccessInfoFactory::AccessInfoFactory(const JSHeapBroker* js_heap_broker, +AccessInfoFactory::AccessInfoFactory(JSHeapBroker* js_heap_broker, CompilationDependencies* dependencies, Handle native_context, Zone* zone) : js_heap_broker_(js_heap_broker), diff --git a/src/compiler/access-info.h b/src/compiler/access-info.h index fa737ce0c4..e9890bbb7a 100644 --- a/src/compiler/access-info.h +++ b/src/compiler/access-info.h @@ -140,7 +140,7 @@ class PropertyAccessInfo final { // Factory class for {ElementAccessInfo}s and {PropertyAccessInfo}s. class AccessInfoFactory final { public: - AccessInfoFactory(const JSHeapBroker* js_heap_broker, + AccessInfoFactory(JSHeapBroker* js_heap_broker, CompilationDependencies* dependencies, Handle native_context, Zone* zone); @@ -169,13 +169,13 @@ class AccessInfoFactory final { PropertyAccessInfo* access_info); CompilationDependencies* dependencies() const { return dependencies_; } - const JSHeapBroker* js_heap_broker() const { return js_heap_broker_; } + JSHeapBroker* js_heap_broker() const { return js_heap_broker_; } Factory* factory() const; Isolate* isolate() const { return isolate_; } Handle native_context() const { return native_context_; } Zone* zone() const { return zone_; } - const JSHeapBroker* const js_heap_broker_; + JSHeapBroker* const js_heap_broker_; CompilationDependencies* const dependencies_; Handle const native_context_; Isolate* const isolate_; diff --git a/src/compiler/common-operator-reducer.cc b/src/compiler/common-operator-reducer.cc index 6e50d700b7..16a9096079 100644 --- a/src/compiler/common-operator-reducer.cc +++ b/src/compiler/common-operator-reducer.cc @@ -19,7 +19,7 @@ namespace compiler { namespace { -Decision DecideCondition(const JSHeapBroker* broker, Node* const cond) { +Decision DecideCondition(JSHeapBroker* broker, Node* const cond) { switch (cond->opcode()) { case IrOpcode::kInt32Constant: { Int32Matcher mcond(cond); @@ -38,7 +38,7 @@ Decision DecideCondition(const JSHeapBroker* broker, Node* const cond) { } // namespace CommonOperatorReducer::CommonOperatorReducer(Editor* editor, Graph* graph, - const JSHeapBroker* js_heap_broker, + JSHeapBroker* js_heap_broker, CommonOperatorBuilder* common, MachineOperatorBuilder* machine, Zone* temp_zone) diff --git a/src/compiler/common-operator-reducer.h b/src/compiler/common-operator-reducer.h index 77a1d71084..f1b29eaf76 100644 --- a/src/compiler/common-operator-reducer.h +++ b/src/compiler/common-operator-reducer.h @@ -25,7 +25,7 @@ class V8_EXPORT_PRIVATE CommonOperatorReducer final : public NON_EXPORTED_BASE(AdvancedReducer) { public: CommonOperatorReducer(Editor* editor, Graph* graph, - const JSHeapBroker* js_heap_broker, + JSHeapBroker* js_heap_broker, CommonOperatorBuilder* common, MachineOperatorBuilder* machine, Zone* temp_zone); ~CommonOperatorReducer() final {} @@ -48,13 +48,13 @@ class V8_EXPORT_PRIVATE CommonOperatorReducer final Reduction Change(Node* node, Operator const* op, Node* a, Node* b); Graph* graph() const { return graph_; } - const JSHeapBroker* js_heap_broker() const { return js_heap_broker_; } + JSHeapBroker* js_heap_broker() const { return js_heap_broker_; } CommonOperatorBuilder* common() const { return common_; } MachineOperatorBuilder* machine() const { return machine_; } Node* dead() const { return dead_; } Graph* const graph_; - const JSHeapBroker* const js_heap_broker_; + JSHeapBroker* const js_heap_broker_; CommonOperatorBuilder* const common_; MachineOperatorBuilder* const machine_; Node* const dead_; diff --git a/src/compiler/compilation-dependencies.cc b/src/compiler/compilation-dependencies.cc index a672d0a1f0..0572e7a5dd 100644 --- a/src/compiler/compilation-dependencies.cc +++ b/src/compiler/compilation-dependencies.cc @@ -346,7 +346,7 @@ bool CompilationDependencies::Commit(Handle code) { } namespace { -void DependOnStablePrototypeChain(const JSHeapBroker* broker, +void DependOnStablePrototypeChain(JSHeapBroker* broker, CompilationDependencies* deps, Handle map, MaybeHandle last_prototype) { @@ -364,7 +364,7 @@ void DependOnStablePrototypeChain(const JSHeapBroker* broker, } // namespace void CompilationDependencies::DependOnStablePrototypeChains( - const JSHeapBroker* broker, Handle native_context, + JSHeapBroker* broker, Handle native_context, std::vector> const& receiver_maps, Handle holder) { Isolate* isolate = holder->GetIsolate(); // Determine actual holder and perform prototype chain checks. diff --git a/src/compiler/compilation-dependencies.h b/src/compiler/compilation-dependencies.h index 9770775c2e..e47e7c54ea 100644 --- a/src/compiler/compilation-dependencies.h +++ b/src/compiler/compilation-dependencies.h @@ -53,7 +53,7 @@ class V8_EXPORT_PRIVATE CompilationDependencies : public ZoneObject { // {receiver_type} up to (and including) the {holder}. // TODO(neis): Fully brokerize! void DependOnStablePrototypeChains( - const JSHeapBroker* broker, Handle native_context, + JSHeapBroker* broker, Handle native_context, std::vector> const& receiver_maps, Handle holder); // Like DependOnElementsKind but also applies to all nested allocation sites. diff --git a/src/compiler/constant-folding-reducer.cc b/src/compiler/constant-folding-reducer.cc index 1811c06f98..a447b2a07c 100644 --- a/src/compiler/constant-folding-reducer.cc +++ b/src/compiler/constant-folding-reducer.cc @@ -11,8 +11,8 @@ namespace v8 { namespace internal { namespace compiler { -ConstantFoldingReducer::ConstantFoldingReducer( - Editor* editor, JSGraph* jsgraph, const JSHeapBroker* js_heap_broker) +ConstantFoldingReducer::ConstantFoldingReducer(Editor* editor, JSGraph* jsgraph, + JSHeapBroker* js_heap_broker) : AdvancedReducer(editor), jsgraph_(jsgraph), js_heap_broker_(js_heap_broker) {} diff --git a/src/compiler/constant-folding-reducer.h b/src/compiler/constant-folding-reducer.h index b111e5b878..3fbe5c4c2e 100644 --- a/src/compiler/constant-folding-reducer.h +++ b/src/compiler/constant-folding-reducer.h @@ -18,7 +18,7 @@ class V8_EXPORT_PRIVATE ConstantFoldingReducer final : public NON_EXPORTED_BASE(AdvancedReducer) { public: ConstantFoldingReducer(Editor* editor, JSGraph* jsgraph, - const JSHeapBroker* js_heap_broker); + JSHeapBroker* js_heap_broker); ~ConstantFoldingReducer() final; const char* reducer_name() const override { return "ConstantFoldingReducer"; } @@ -27,10 +27,10 @@ class V8_EXPORT_PRIVATE ConstantFoldingReducer final private: JSGraph* jsgraph() const { return jsgraph_; } - const JSHeapBroker* js_heap_broker() const { return js_heap_broker_; } + JSHeapBroker* js_heap_broker() const { return js_heap_broker_; } JSGraph* const jsgraph_; - const JSHeapBroker* const js_heap_broker_; + JSHeapBroker* const js_heap_broker_; DISALLOW_COPY_AND_ASSIGN(ConstantFoldingReducer); }; diff --git a/src/compiler/js-call-reducer.h b/src/compiler/js-call-reducer.h index ab2f6aa96f..0412e38aba 100644 --- a/src/compiler/js-call-reducer.h +++ b/src/compiler/js-call-reducer.h @@ -233,7 +233,7 @@ class V8_EXPORT_PRIVATE JSCallReducer final : public AdvancedReducer { Graph* graph() const; JSGraph* jsgraph() const { return jsgraph_; } - const JSHeapBroker* js_heap_broker() const { return js_heap_broker_; } + JSHeapBroker* js_heap_broker() const { return js_heap_broker_; } Isolate* isolate() const; Factory* factory() const; Handle native_context() const { return native_context_; } @@ -245,7 +245,7 @@ class V8_EXPORT_PRIVATE JSCallReducer final : public AdvancedReducer { CompilationDependencies* dependencies() const { return dependencies_; } JSGraph* const jsgraph_; - const JSHeapBroker* const js_heap_broker_; + JSHeapBroker* const js_heap_broker_; Flags const flags_; Handle const native_context_; CompilationDependencies* const dependencies_; diff --git a/src/compiler/js-context-specialization.cc b/src/compiler/js-context-specialization.cc index 85a80a2b2f..d43b98fd66 100644 --- a/src/compiler/js-context-specialization.cc +++ b/src/compiler/js-context-specialization.cc @@ -101,7 +101,7 @@ bool IsContextParameter(Node* node) { // specialization context. If successful, update {distance} to whatever // distance remains from the specialization context. base::Optional GetSpecializationContext( - const JSHeapBroker* broker, Node* node, size_t* distance, + JSHeapBroker* broker, Node* node, size_t* distance, Maybe maybe_outer) { switch (node->opcode()) { case IrOpcode::kHeapConstant: { diff --git a/src/compiler/js-context-specialization.h b/src/compiler/js-context-specialization.h index 1b7f994c7a..7324c5aaf0 100644 --- a/src/compiler/js-context-specialization.h +++ b/src/compiler/js-context-specialization.h @@ -63,12 +63,12 @@ class JSContextSpecialization final : public AdvancedReducer { JSGraph* jsgraph() const { return jsgraph_; } Maybe outer() const { return outer_; } MaybeHandle closure() const { return closure_; } - const JSHeapBroker* js_heap_broker() const { return js_heap_broker_; } + JSHeapBroker* js_heap_broker() const { return js_heap_broker_; } JSGraph* const jsgraph_; Maybe outer_; MaybeHandle closure_; - const JSHeapBroker* const js_heap_broker_; + JSHeapBroker* const js_heap_broker_; DISALLOW_COPY_AND_ASSIGN(JSContextSpecialization); }; diff --git a/src/compiler/js-create-lowering.h b/src/compiler/js-create-lowering.h index cb58140c0e..441d671233 100644 --- a/src/compiler/js-create-lowering.h +++ b/src/compiler/js-create-lowering.h @@ -33,7 +33,7 @@ class V8_EXPORT_PRIVATE JSCreateLowering final : public NON_EXPORTED_BASE(AdvancedReducer) { public: JSCreateLowering(Editor* editor, CompilationDependencies* dependencies, - JSGraph* jsgraph, const JSHeapBroker* js_heap_broker, + JSGraph* jsgraph, JSHeapBroker* js_heap_broker, Handle native_context, Zone* zone) : AdvancedReducer(editor), dependencies_(dependencies), @@ -116,12 +116,12 @@ class V8_EXPORT_PRIVATE JSCreateLowering final CommonOperatorBuilder* common() const; SimplifiedOperatorBuilder* simplified() const; CompilationDependencies* dependencies() const { return dependencies_; } - const JSHeapBroker* js_heap_broker() const { return js_heap_broker_; } + JSHeapBroker* js_heap_broker() const { return js_heap_broker_; } Zone* zone() const { return zone_; } CompilationDependencies* const dependencies_; JSGraph* const jsgraph_; - const JSHeapBroker* const js_heap_broker_; + JSHeapBroker* const js_heap_broker_; Handle const native_context_; Zone* const zone_; }; diff --git a/src/compiler/js-heap-broker.cc b/src/compiler/js-heap-broker.cc index 2670112fa9..d736033b8c 100644 --- a/src/compiler/js-heap-broker.cc +++ b/src/compiler/js-heap-broker.cc @@ -13,6 +13,25 @@ namespace v8 { namespace internal { namespace compiler { +// TODO(neis): When do we need NON_EXPORTED_BASE? +class ObjectData : public ZoneObject { + public: + ObjectData(JSHeapBroker* broker_, Handle object_) + : broker(broker_), object(object_) {} + + JSHeapBroker* broker; + Handle object; + +#define DEFINE_IS(Name) \ + bool Is##Name() const { \ + AllowHandleDereference allow_handle_dereference; \ + return object->Is##Name(); \ + } + HEAP_BROKER_NORMAL_OBJECT_LIST(DEFINE_IS) + DEFINE_IS(Smi) +#undef DEFINE_IS +}; + MapRef HeapObjectRef::map() const { AllowHandleAllocation handle_allocation; AllowHandleDereference allow_handle_dereference; @@ -30,15 +49,11 @@ double MutableHeapNumberRef::value() const { return object()->value(); } -bool ObjectRef::IsSmi() const { - AllowHandleDereference allow_handle_dereference; - return object_->IsSmi(); -} - int ObjectRef::AsSmi() const { return object()->value(); } bool ObjectRef::equals(const ObjectRef& other) const { - return object().equals(other.object()); + DCHECK_EQ(data_ == other.data_, data_->object.equals(other.data_->object)); + return data_ == other.data_; } StringRef ObjectRef::TypeOf() const { @@ -63,7 +78,8 @@ ObjectRef ContextRef::get(int index) const { return ObjectRef(broker(), value); } -JSHeapBroker::JSHeapBroker(Isolate* isolate) : isolate_(isolate) {} +JSHeapBroker::JSHeapBroker(Isolate* isolate, Zone* zone) + : isolate_(isolate), zone_(zone), refs_(zone_) {} HeapObjectType JSHeapBroker::HeapObjectTypeFromMap(Map* map) const { AllowHandleDereference allow_handle_dereference; @@ -95,27 +111,25 @@ HeapObjectType JSHeapBroker::HeapObjectTypeFromMap(Map* map) const { return HeapObjectType(map->instance_type(), flags, oddball_type); } -// static -base::Optional JSHeapBroker::TryGetSmi(Handle object) { - AllowHandleDereference allow_handle_dereference; - if (!object->IsSmi()) return base::Optional(); - return Smi::cast(*object)->value(); -} - -#define DEFINE_IS_AND_AS(Name) \ - bool ObjectRef::Is##Name() const { \ - AllowHandleDereference allow_handle_dereference; \ - return object()->Is##Name(); \ - } \ - Name##Ref ObjectRef::As##Name() const { \ - DCHECK(Is##Name()); \ - return Name##Ref(broker(), object()); \ +#define DEFINE_IS_AND_AS(Name) \ + bool ObjectRef::Is##Name() const { return data()->Is##Name(); } \ + Name##Ref ObjectRef::As##Name() const { \ + DCHECK(Is##Name()); \ + return Name##Ref(data()); \ } -HEAP_BROKER_OBJECT_LIST(DEFINE_IS_AND_AS) +HEAP_BROKER_NORMAL_OBJECT_LIST(DEFINE_IS_AND_AS) #undef DEFINE_IS_AND_AS +bool ObjectRef::IsSmi() const { return data()->IsSmi(); } + +FieldTypeRef ObjectRef::AsFieldType() const { + return FieldTypeRef(broker(), object()); +} + HeapObjectType HeapObjectRef::type() const { AllowHandleDereference allow_handle_dereference; + // TODO(neis): When this gets called via OptimizingCompileDispatcher -> + // LoadElimination -> TypeNarrowingReducer, we don't have a HandleScope. Why? return broker()->HeapObjectTypeFromMap(object()->map()); } @@ -423,9 +437,9 @@ void JSObjectRef::EnsureElementsTenured() { // If we would like to pretenure a fixed cow array, we must ensure that // the array is already in old space, otherwise we'll create too many // old-to-new-space pointers (overflowing the store buffer). - object_elements = Handle( + object_elements = broker()->isolate()->factory()->CopyAndTenureFixedCOWArray( - Handle::cast(object_elements))); + Handle::cast(object_elements)); object()->set_elements(*object_elements); } } @@ -885,6 +899,25 @@ PropertyDetails PropertyCellRef::property_details() const { return object()->property_details(); } +ObjectRef::ObjectRef(JSHeapBroker* broker, Handle object) + : data_(nullptr) { + DisallowHeapAccess no_heap_access; + // TODO(neis): After serialization pass, only read from the hash table. + auto x = broker->refs_.insert({object.address(), nullptr}); + bool const inserted = x.second; + if (inserted) { + x.first->second = new (broker->zone_) ObjectData(broker, object); + } + data_ = x.first->second; + CHECK_NOT_NULL(data_); +} + +Handle ObjectRef::object() const { return data_->object; } + +JSHeapBroker* ObjectRef::broker() const { return data_->broker; } + +ObjectData* ObjectRef::data() const { return data_; } + } // namespace compiler } // namespace internal } // namespace v8 diff --git a/src/compiler/js-heap-broker.h b/src/compiler/js-heap-broker.h index 6121079f89..466436d032 100644 --- a/src/compiler/js-heap-broker.h +++ b/src/compiler/js-heap-broker.h @@ -9,6 +9,7 @@ #include "src/base/optional.h" #include "src/globals.h" #include "src/objects.h" +#include "src/zone/zone-containers.h" namespace v8 { namespace internal { @@ -59,49 +60,58 @@ class HeapObjectType { Flags const flags_; }; -#define HEAP_BROKER_OBJECT_LIST(V) \ - V(AllocationSite) \ - V(Cell) \ - V(Code) \ - V(Context) \ - V(FeedbackVector) \ - V(FixedArray) \ - V(FixedArrayBase) \ - V(FixedDoubleArray) \ - V(HeapNumber) \ - V(HeapObject) \ - V(InternalizedString) \ - V(JSArray) \ - V(JSFunction) \ - V(JSGlobalProxy) \ - V(JSObject) \ - V(JSRegExp) \ - V(Map) \ - V(Module) \ - V(MutableHeapNumber) \ - V(Name) \ - V(NativeContext) \ - V(PropertyCell) \ - V(ScopeInfo) \ - V(ScriptContextTable) \ - V(SharedFunctionInfo) \ +#define HEAP_BROKER_NORMAL_OBJECT_LIST(V) \ + V(AllocationSite) \ + V(Cell) \ + V(Code) \ + V(Context) \ + V(FeedbackVector) \ + V(FixedArray) \ + V(FixedArrayBase) \ + V(FixedDoubleArray) \ + V(HeapNumber) \ + V(HeapObject) \ + V(InternalizedString) \ + V(JSArray) \ + V(JSFunction) \ + V(JSGlobalProxy) \ + V(JSObject) \ + V(JSRegExp) \ + V(Map) \ + V(Module) \ + V(MutableHeapNumber) \ + V(Name) \ + V(NativeContext) \ + V(PropertyCell) \ + V(ScopeInfo) \ + V(ScriptContextTable) \ + V(SharedFunctionInfo) \ V(String) +#define HEAP_BROKER_OBJECT_LIST(V) \ + HEAP_BROKER_NORMAL_OBJECT_LIST(V) \ + V(FieldType) + class CompilationDependencies; class JSHeapBroker; +class ObjectData; #define FORWARD_DECL(Name) class Name##Ref; HEAP_BROKER_OBJECT_LIST(FORWARD_DECL) #undef FORWARD_DECL class ObjectRef { public: - explicit ObjectRef(const JSHeapBroker* broker, Handle object) - : broker_(broker), object_(object) {} + ObjectRef(JSHeapBroker* broker, Handle object); + explicit ObjectRef(ObjectData* data) : data_(data) { CHECK_NOT_NULL(data); } + bool equals(const ObjectRef& other) const; + + Handle object() const; + // TODO(neis): Remove eventually. template Handle object() const { AllowHandleDereference handle_dereference; - return Handle::cast(object_); + return Handle::cast(object()); } OddballType oddball_type() const; @@ -109,10 +119,8 @@ class ObjectRef { bool IsSmi() const; int AsSmi() const; - bool equals(const ObjectRef& other) const; - #define HEAP_IS_METHOD_DECL(Name) bool Is##Name() const; - HEAP_BROKER_OBJECT_LIST(HEAP_IS_METHOD_DECL) + HEAP_BROKER_NORMAL_OBJECT_LIST(HEAP_IS_METHOD_DECL) #undef HEAP_IS_METHOD_DECL #define HEAP_AS_METHOD_DECL(Name) Name##Ref As##Name() const; @@ -124,11 +132,11 @@ class ObjectRef { double OddballToNumber() const; protected: - const JSHeapBroker* broker() const { return broker_; } + JSHeapBroker* broker() const; + ObjectData* data() const; private: - const JSHeapBroker* broker_; - Handle object_; + ObjectData* data_; }; class FieldTypeRef : public ObjectRef { @@ -415,22 +423,23 @@ class InternalizedStringRef : public StringRef { class V8_EXPORT_PRIVATE JSHeapBroker : public NON_EXPORTED_BASE(ZoneObject) { public: - JSHeapBroker(Isolate* isolate); + JSHeapBroker(Isolate* isolate, Zone* zone); HeapObjectType HeapObjectTypeFromMap(Handle map) const { AllowHandleDereference handle_dereference; return HeapObjectTypeFromMap(*map); } - static base::Optional TryGetSmi(Handle object); - Isolate* isolate() const { return isolate_; } private: + friend class ObjectRef; friend class HeapObjectRef; HeapObjectType HeapObjectTypeFromMap(Map* map) const; Isolate* const isolate_; + Zone* const zone_; + ZoneUnorderedMap refs_; }; } // namespace compiler diff --git a/src/compiler/js-native-context-specialization.cc b/src/compiler/js-native-context-specialization.cc index 1ec13960c1..e156c5d9c2 100644 --- a/src/compiler/js-native-context-specialization.cc +++ b/src/compiler/js-native-context-specialization.cc @@ -58,9 +58,9 @@ struct JSNativeContextSpecialization::ScriptContextTableLookupResult { }; JSNativeContextSpecialization::JSNativeContextSpecialization( - Editor* editor, JSGraph* jsgraph, const JSHeapBroker* js_heap_broker, - Flags flags, Handle native_context, - CompilationDependencies* dependencies, Zone* zone) + Editor* editor, JSGraph* jsgraph, JSHeapBroker* js_heap_broker, Flags flags, + Handle native_context, CompilationDependencies* dependencies, + Zone* zone) : AdvancedReducer(editor), jsgraph_(jsgraph), js_heap_broker_(js_heap_broker), diff --git a/src/compiler/js-native-context-specialization.h b/src/compiler/js-native-context-specialization.h index 53fe9e2c11..5c32636d33 100644 --- a/src/compiler/js-native-context-specialization.h +++ b/src/compiler/js-native-context-specialization.h @@ -47,7 +47,7 @@ class JSNativeContextSpecialization final : public AdvancedReducer { typedef base::Flags Flags; JSNativeContextSpecialization(Editor* editor, JSGraph* jsgraph, - const JSHeapBroker* js_heap_broker, Flags flags, + JSHeapBroker* js_heap_broker, Flags flags, Handle native_context, CompilationDependencies* dependencies, Zone* zone); @@ -217,7 +217,7 @@ class JSNativeContextSpecialization final : public AdvancedReducer { Graph* graph() const; JSGraph* jsgraph() const { return jsgraph_; } - const JSHeapBroker* js_heap_broker() const { return js_heap_broker_; } + JSHeapBroker* js_heap_broker() const { return js_heap_broker_; } Isolate* isolate() const; Factory* factory() const; CommonOperatorBuilder* common() const; @@ -231,7 +231,7 @@ class JSNativeContextSpecialization final : public AdvancedReducer { Zone* zone() const { return zone_; } JSGraph* const jsgraph_; - const JSHeapBroker* const js_heap_broker_; + JSHeapBroker* const js_heap_broker_; Flags const flags_; Handle global_object_; Handle global_proxy_; diff --git a/src/compiler/js-typed-lowering.cc b/src/compiler/js-typed-lowering.cc index 89675b5c98..0ec9c055bb 100644 --- a/src/compiler/js-typed-lowering.cc +++ b/src/compiler/js-typed-lowering.cc @@ -94,7 +94,7 @@ class JSBinopReduction final { if (BothInputsAre(Type::String()) || BinaryOperationHintOf(node_->op()) == BinaryOperationHint::kString) { HeapObjectBinopMatcher m(node_); - const JSHeapBroker* broker = lowering_->js_heap_broker(); + JSHeapBroker* broker = lowering_->js_heap_broker(); if (m.right().HasValue() && m.right().Ref(broker).IsString()) { StringRef right_string = m.right().Ref(broker).AsString(); if (right_string.length() >= ConsString::kMinLength) return true; @@ -409,7 +409,7 @@ class JSBinopReduction final { // - relax effects from generic but not-side-effecting operations JSTypedLowering::JSTypedLowering(Editor* editor, JSGraph* jsgraph, - const JSHeapBroker* js_heap_broker, Zone* zone) + JSHeapBroker* js_heap_broker, Zone* zone) : AdvancedReducer(editor), jsgraph_(jsgraph), js_heap_broker_(js_heap_broker), @@ -534,8 +534,8 @@ Reduction JSTypedLowering::ReduceJSAdd(Node* node) { if (r.BothInputsAre(Type::String())) { HeapObjectBinopMatcher m(node); if (m.IsFoldable()) { - StringRef left(js_heap_broker(), m.left().Value()); - StringRef right(js_heap_broker(), m.right().Value()); + StringRef left = m.left().Ref(js_heap_broker()).AsString(); + StringRef right = m.right().Ref(js_heap_broker()).AsString(); if (left.length() + right.length() > String::kMaxLength) { // No point in trying to optimize this, as it will just throw. return NoChange(); @@ -1384,7 +1384,7 @@ Node* JSTypedLowering::BuildGetModuleCell(Node* node) { if (module_type.IsHeapConstant()) { ModuleRef module_constant = module_type.AsHeapConstant()->Ref().AsModule(); - CellRef cell_constant(module_constant.GetCell(cell_index)); + CellRef cell_constant = module_constant.GetCell(cell_index); return jsgraph()->Constant(cell_constant); } diff --git a/src/compiler/js-typed-lowering.h b/src/compiler/js-typed-lowering.h index c8fcac5ff6..c3bef9aeed 100644 --- a/src/compiler/js-typed-lowering.h +++ b/src/compiler/js-typed-lowering.h @@ -32,7 +32,7 @@ class V8_EXPORT_PRIVATE JSTypedLowering final : public NON_EXPORTED_BASE(AdvancedReducer) { public: JSTypedLowering(Editor* editor, JSGraph* jsgraph, - const JSHeapBroker* js_heap_broker, Zone* zone); + JSHeapBroker* js_heap_broker, Zone* zone); ~JSTypedLowering() final {} const char* reducer_name() const override { return "JSTypedLowering"; } @@ -98,14 +98,14 @@ class V8_EXPORT_PRIVATE JSTypedLowering final Factory* factory() const; Graph* graph() const; JSGraph* jsgraph() const { return jsgraph_; } - const JSHeapBroker* js_heap_broker() const { return js_heap_broker_; } + JSHeapBroker* js_heap_broker() const { return js_heap_broker_; } Isolate* isolate() const; JSOperatorBuilder* javascript() const; CommonOperatorBuilder* common() const; SimplifiedOperatorBuilder* simplified() const; JSGraph* jsgraph_; - const JSHeapBroker* js_heap_broker_; + JSHeapBroker* js_heap_broker_; Type empty_string_type_; Type pointer_comparable_type_; TypeCache const& type_cache_; diff --git a/src/compiler/node-matchers.h b/src/compiler/node-matchers.h index 4b02cad9b9..cbefb0ac35 100644 --- a/src/compiler/node-matchers.h +++ b/src/compiler/node-matchers.h @@ -195,7 +195,7 @@ struct HeapObjectMatcher final return this->HasValue() && this->Value().address() == value.address(); } - ObjectRef Ref(const JSHeapBroker* broker) const { + ObjectRef Ref(JSHeapBroker* broker) const { return ObjectRef(broker, this->Value()); } }; diff --git a/src/compiler/operation-typer.cc b/src/compiler/operation-typer.cc index f8342cb542..67a7b138a5 100644 --- a/src/compiler/operation-typer.cc +++ b/src/compiler/operation-typer.cc @@ -16,8 +16,8 @@ namespace v8 { namespace internal { namespace compiler { -OperationTyper::OperationTyper(Isolate* isolate, - const JSHeapBroker* js_heap_broker, Zone* zone) +OperationTyper::OperationTyper(Isolate* isolate, JSHeapBroker* js_heap_broker, + Zone* zone) : zone_(zone), cache_(TypeCache::Get()) { Factory* factory = isolate->factory(); infinity_ = diff --git a/src/compiler/operation-typer.h b/src/compiler/operation-typer.h index 7d62decd82..fb5997485c 100644 --- a/src/compiler/operation-typer.h +++ b/src/compiler/operation-typer.h @@ -27,8 +27,7 @@ class TypeCache; class V8_EXPORT_PRIVATE OperationTyper { public: - OperationTyper(Isolate* isolate, const JSHeapBroker* js_heap_broker, - Zone* zone); + OperationTyper(Isolate* isolate, JSHeapBroker* js_heap_broker, Zone* zone); // Typing Phi. Type Merge(Type left, Type right); diff --git a/src/compiler/pipeline.cc b/src/compiler/pipeline.cc index a1a084e537..a920b804eb 100644 --- a/src/compiler/pipeline.cc +++ b/src/compiler/pipeline.cc @@ -136,7 +136,7 @@ class PipelineData { javascript_ = new (graph_zone_) JSOperatorBuilder(graph_zone_); jsgraph_ = new (graph_zone_) JSGraph(isolate_, graph_, common_, javascript_, simplified_, machine_); - js_heap_broker_ = new (codegen_zone_) JSHeapBroker(isolate_); + js_heap_broker_ = new (codegen_zone_) JSHeapBroker(isolate_, codegen_zone_); dependencies_ = new (codegen_zone_) CompilationDependencies(isolate_, codegen_zone_); } diff --git a/src/compiler/property-access-builder.h b/src/compiler/property-access-builder.h index 7b569a9a12..6a073be65d 100644 --- a/src/compiler/property-access-builder.h +++ b/src/compiler/property-access-builder.h @@ -26,7 +26,7 @@ class SimplifiedOperatorBuilder; class PropertyAccessBuilder { public: - PropertyAccessBuilder(JSGraph* jsgraph, const JSHeapBroker* js_heap_broker, + PropertyAccessBuilder(JSGraph* jsgraph, JSHeapBroker* js_heap_broker, CompilationDependencies* dependencies) : jsgraph_(jsgraph), js_heap_broker_(js_heap_broker), @@ -54,7 +54,7 @@ class PropertyAccessBuilder { private: JSGraph* jsgraph() const { return jsgraph_; } - const JSHeapBroker* js_heap_broker() const { return js_heap_broker_; } + JSHeapBroker* js_heap_broker() const { return js_heap_broker_; } CompilationDependencies* dependencies() const { return dependencies_; } Graph* graph() const; Isolate* isolate() const; @@ -69,7 +69,7 @@ class PropertyAccessBuilder { Node* ResolveHolder(PropertyAccessInfo const& access_info, Node* receiver); JSGraph* jsgraph_; - const JSHeapBroker* js_heap_broker_; + JSHeapBroker* js_heap_broker_; CompilationDependencies* dependencies_; }; diff --git a/src/compiler/simplified-lowering.cc b/src/compiler/simplified-lowering.cc index da7ada89c8..085a1f7eb9 100644 --- a/src/compiler/simplified-lowering.cc +++ b/src/compiler/simplified-lowering.cc @@ -286,7 +286,7 @@ class RepresentationSelector { bool weakened_ = false; }; - RepresentationSelector(JSGraph* jsgraph, const JSHeapBroker* js_heap_broker, + RepresentationSelector(JSGraph* jsgraph, JSHeapBroker* js_heap_broker, Zone* zone, RepresentationChanger* changer, SourcePositionTable* source_positions, NodeOriginTable* node_origins) @@ -3275,8 +3275,7 @@ class RepresentationSelector { }; SimplifiedLowering::SimplifiedLowering(JSGraph* jsgraph, - const JSHeapBroker* js_heap_broker, - Zone* zone, + JSHeapBroker* js_heap_broker, Zone* zone, SourcePositionTable* source_positions, NodeOriginTable* node_origins, PoisoningMitigationLevel poisoning_level) diff --git a/src/compiler/simplified-lowering.h b/src/compiler/simplified-lowering.h index 5b748e7e95..7b21b07813 100644 --- a/src/compiler/simplified-lowering.h +++ b/src/compiler/simplified-lowering.h @@ -23,8 +23,8 @@ class TypeCache; class V8_EXPORT_PRIVATE SimplifiedLowering final { public: - SimplifiedLowering(JSGraph* jsgraph, const JSHeapBroker* js_heap_broker, - Zone* zone, SourcePositionTable* source_position, + SimplifiedLowering(JSGraph* jsgraph, JSHeapBroker* js_heap_broker, Zone* zone, + SourcePositionTable* source_position, NodeOriginTable* node_origins, PoisoningMitigationLevel poisoning_level); ~SimplifiedLowering() {} @@ -48,7 +48,7 @@ class V8_EXPORT_PRIVATE SimplifiedLowering final { private: JSGraph* const jsgraph_; - const JSHeapBroker* js_heap_broker_; + JSHeapBroker* js_heap_broker_; Zone* const zone_; TypeCache const& type_cache_; SetOncePointer to_number_code_; diff --git a/src/compiler/simplified-operator-reducer.cc b/src/compiler/simplified-operator-reducer.cc index 34be9cb0e4..ce7d18f34a 100644 --- a/src/compiler/simplified-operator-reducer.cc +++ b/src/compiler/simplified-operator-reducer.cc @@ -33,7 +33,7 @@ Decision DecideObjectIsSmi(Node* const input) { } // namespace SimplifiedOperatorReducer::SimplifiedOperatorReducer( - Editor* editor, JSGraph* jsgraph, const JSHeapBroker* js_heap_broker) + Editor* editor, JSGraph* jsgraph, JSHeapBroker* js_heap_broker) : AdvancedReducer(editor), jsgraph_(jsgraph), js_heap_broker_(js_heap_broker) {} diff --git a/src/compiler/simplified-operator-reducer.h b/src/compiler/simplified-operator-reducer.h index af827a2788..93104e31b0 100644 --- a/src/compiler/simplified-operator-reducer.h +++ b/src/compiler/simplified-operator-reducer.h @@ -27,7 +27,7 @@ class V8_EXPORT_PRIVATE SimplifiedOperatorReducer final : public NON_EXPORTED_BASE(AdvancedReducer) { public: SimplifiedOperatorReducer(Editor* editor, JSGraph* jsgraph, - const JSHeapBroker* js_heap_broker); + JSHeapBroker* js_heap_broker); ~SimplifiedOperatorReducer() final; const char* reducer_name() const override { @@ -56,10 +56,10 @@ class V8_EXPORT_PRIVATE SimplifiedOperatorReducer final SimplifiedOperatorBuilder* simplified() const; JSGraph* jsgraph() const { return jsgraph_; } - const JSHeapBroker* js_heap_broker() const { return js_heap_broker_; } + JSHeapBroker* js_heap_broker() const { return js_heap_broker_; } JSGraph* const jsgraph_; - const JSHeapBroker* const js_heap_broker_; + JSHeapBroker* const js_heap_broker_; DISALLOW_COPY_AND_ASSIGN(SimplifiedOperatorReducer); }; diff --git a/src/compiler/type-narrowing-reducer.cc b/src/compiler/type-narrowing-reducer.cc index 1b8b5b4657..01afdcb911 100644 --- a/src/compiler/type-narrowing-reducer.cc +++ b/src/compiler/type-narrowing-reducer.cc @@ -12,7 +12,7 @@ namespace internal { namespace compiler { TypeNarrowingReducer::TypeNarrowingReducer(Editor* editor, JSGraph* jsgraph, - const JSHeapBroker* js_heap_broker) + JSHeapBroker* js_heap_broker) : AdvancedReducer(editor), jsgraph_(jsgraph), op_typer_(jsgraph->isolate(), js_heap_broker, zone()) {} diff --git a/src/compiler/type-narrowing-reducer.h b/src/compiler/type-narrowing-reducer.h index 77cb07e772..62237ccce3 100644 --- a/src/compiler/type-narrowing-reducer.h +++ b/src/compiler/type-narrowing-reducer.h @@ -20,7 +20,7 @@ class V8_EXPORT_PRIVATE TypeNarrowingReducer final : public NON_EXPORTED_BASE(AdvancedReducer) { public: TypeNarrowingReducer(Editor* editor, JSGraph* jsgraph, - const JSHeapBroker* js_heap_broker); + JSHeapBroker* js_heap_broker); ~TypeNarrowingReducer() final; const char* reducer_name() const override { return "TypeNarrowingReducer"; } diff --git a/src/compiler/typed-optimization.cc b/src/compiler/typed-optimization.cc index 0c001117de..b77fc97859 100644 --- a/src/compiler/typed-optimization.cc +++ b/src/compiler/typed-optimization.cc @@ -21,7 +21,7 @@ namespace compiler { TypedOptimization::TypedOptimization(Editor* editor, CompilationDependencies* dependencies, JSGraph* jsgraph, - const JSHeapBroker* js_heap_broker) + JSHeapBroker* js_heap_broker) : AdvancedReducer(editor), dependencies_(dependencies), jsgraph_(jsgraph), @@ -89,8 +89,8 @@ Reduction TypedOptimization::Reduce(Node* node) { namespace { -base::Optional GetStableMapFromObjectType( - const JSHeapBroker* js_heap_broker, Type object_type) { +base::Optional GetStableMapFromObjectType(JSHeapBroker* js_heap_broker, + Type object_type) { if (object_type.IsHeapConstant()) { HeapObjectRef object = object_type.AsHeapConstant()->Ref(); MapRef object_map = object.map(); diff --git a/src/compiler/typed-optimization.h b/src/compiler/typed-optimization.h index 3c4b6ed9cd..baee65dd4e 100644 --- a/src/compiler/typed-optimization.h +++ b/src/compiler/typed-optimization.h @@ -28,7 +28,7 @@ class V8_EXPORT_PRIVATE TypedOptimization final : public NON_EXPORTED_BASE(AdvancedReducer) { public: TypedOptimization(Editor* editor, CompilationDependencies* dependencies, - JSGraph* jsgraph, const JSHeapBroker* js_heap_broker); + JSGraph* jsgraph, JSHeapBroker* js_heap_broker); ~TypedOptimization(); const char* reducer_name() const override { return "TypedOptimization"; } @@ -71,11 +71,11 @@ class V8_EXPORT_PRIVATE TypedOptimization final CompilationDependencies* dependencies() const { return dependencies_; } JSGraph* jsgraph() const { return jsgraph_; } - const JSHeapBroker* js_heap_broker() const { return js_heap_broker_; } + JSHeapBroker* js_heap_broker() const { return js_heap_broker_; } CompilationDependencies* const dependencies_; JSGraph* const jsgraph_; - const JSHeapBroker* js_heap_broker_; + JSHeapBroker* js_heap_broker_; Type const true_type_; Type const false_type_; TypeCache const& type_cache_; diff --git a/src/compiler/typer.cc b/src/compiler/typer.cc index 7e130cb747..ba2a0eb768 100644 --- a/src/compiler/typer.cc +++ b/src/compiler/typer.cc @@ -33,7 +33,7 @@ class Typer::Decorator final : public GraphDecorator { Typer* const typer_; }; -Typer::Typer(Isolate* isolate, const JSHeapBroker* js_heap_broker, Flags flags, +Typer::Typer(Isolate* isolate, JSHeapBroker* js_heap_broker, Flags flags, Graph* graph) : flags_(flags), graph_(graph), diff --git a/src/compiler/typer.h b/src/compiler/typer.h index 1720bc776f..741ca481c2 100644 --- a/src/compiler/typer.h +++ b/src/compiler/typer.h @@ -25,7 +25,7 @@ class V8_EXPORT_PRIVATE Typer { }; typedef base::Flags Flags; - Typer(Isolate* isolate, const JSHeapBroker* js_heap_broker, Flags flags, + Typer(Isolate* isolate, JSHeapBroker* js_heap_broker, Flags flags, Graph* graph); ~Typer(); @@ -42,13 +42,13 @@ class V8_EXPORT_PRIVATE Typer { Graph* graph() const { return graph_; } Zone* zone() const { return graph()->zone(); } OperationTyper* operation_typer() { return &operation_typer_; } - const JSHeapBroker* js_heap_broker() const { return js_heap_broker_; } + JSHeapBroker* js_heap_broker() const { return js_heap_broker_; } Flags const flags_; Graph* const graph_; Decorator* decorator_; TypeCache const& cache_; - const JSHeapBroker* js_heap_broker_; + JSHeapBroker* js_heap_broker_; OperationTyper operation_typer_; Type singleton_false_; diff --git a/src/compiler/types.cc b/src/compiler/types.cc index 64b0385f54..ae08854bda 100644 --- a/src/compiler/types.cc +++ b/src/compiler/types.cc @@ -820,22 +820,19 @@ Type Type::NewConstant(double value, Zone* zone) { return OtherNumberConstant(value, zone); } -Type Type::NewConstant(const JSHeapBroker* js_heap_broker, - Handle value, Zone* zone) { - auto maybe_smi = JSHeapBroker::TryGetSmi(value); - if (maybe_smi.has_value()) { - return NewConstant(static_cast(maybe_smi.value()), zone); +Type Type::NewConstant(JSHeapBroker* js_heap_broker, Handle value, + Zone* zone) { + ObjectRef ref(js_heap_broker, value); + if (ref.IsSmi()) { + return NewConstant(static_cast(ref.AsSmi()), zone); } - - HeapObjectRef heap_ref(js_heap_broker, value); - if (heap_ref.IsHeapNumber()) { - return NewConstant(heap_ref.AsHeapNumber().value(), zone); + if (ref.IsHeapNumber()) { + return NewConstant(ref.AsHeapNumber().value(), zone); } - - if (heap_ref.IsString() && !heap_ref.IsInternalizedString()) { + if (ref.IsString() && !ref.IsInternalizedString()) { return Type::String(); } - return HeapConstant(js_heap_broker, value, zone); + return HeapConstant(ref.AsHeapObject(), zone); } Type Type::Union(Type type1, Type type2, Zone* zone) { @@ -1061,8 +1058,8 @@ Type Type::OtherNumberConstant(double value, Zone* zone) { } // static -Type Type::HeapConstant(const JSHeapBroker* js_heap_broker, - Handle value, Zone* zone) { +Type Type::HeapConstant(JSHeapBroker* js_heap_broker, Handle value, + Zone* zone) { return FromTypeBase( HeapConstantType::New(HeapObjectRef(js_heap_broker, value), zone)); } diff --git a/src/compiler/types.h b/src/compiler/types.h index 49f81390b1..d27f6e3e75 100644 --- a/src/compiler/types.h +++ b/src/compiler/types.h @@ -361,7 +361,7 @@ class V8_EXPORT_PRIVATE Type { static Type UnsignedSmall() { return NewBitset(BitsetType::UnsignedSmall()); } static Type OtherNumberConstant(double value, Zone* zone); - static Type HeapConstant(const JSHeapBroker* js_heap_broker, + static Type HeapConstant(JSHeapBroker* js_heap_broker, Handle value, Zone* zone); static Type HeapConstant(const HeapObjectRef& value, Zone* zone); static Type Range(double min, double max, Zone* zone); @@ -370,14 +370,14 @@ class V8_EXPORT_PRIVATE Type { static Type Union(int length, Zone* zone); // NewConstant is a factory that returns Constant, Range or Number. - static Type NewConstant(const JSHeapBroker* js_heap_broker, - Handle value, Zone* zone); + static Type NewConstant(JSHeapBroker* js_heap_broker, Handle value, + Zone* zone); static Type NewConstant(double value, Zone* zone); static Type Union(Type type1, Type type2, Zone* zone); static Type Intersect(Type type1, Type type2, Zone* zone); - static Type For(const JSHeapBroker* js_heap_broker, Handle map) { + static Type For(JSHeapBroker* js_heap_broker, Handle map) { HeapObjectType type = js_heap_broker->HeapObjectTypeFromMap(map); return NewBitset(BitsetType::ExpandInternals(BitsetType::Lub(type))); } diff --git a/test/cctest/compiler/test-js-context-specialization.cc b/test/cctest/compiler/test-js-context-specialization.cc index 6560bae096..4904ee5122 100644 --- a/test/cctest/compiler/test-js-context-specialization.cc +++ b/test/cctest/compiler/test-js-context-specialization.cc @@ -30,7 +30,7 @@ class ContextSpecializationTester : public HandleAndZoneScope { jsgraph_(main_isolate(), graph(), common(), &javascript_, &simplified_, &machine_), reducer_(main_zone(), graph()), - js_heap_broker_(main_isolate()), + js_heap_broker_(main_isolate(), main_zone()), spec_(&reducer_, jsgraph(), &js_heap_broker_, context, MaybeHandle()) {} diff --git a/test/cctest/compiler/test-js-typed-lowering.cc b/test/cctest/compiler/test-js-typed-lowering.cc index 6aa84b0317..73d6cdcd8c 100644 --- a/test/cctest/compiler/test-js-typed-lowering.cc +++ b/test/cctest/compiler/test-js-typed-lowering.cc @@ -23,7 +23,7 @@ class JSTypedLoweringTester : public HandleAndZoneScope { public: explicit JSTypedLoweringTester(int num_parameters = 0) : isolate(main_isolate()), - js_heap_broker(isolate), + js_heap_broker(isolate, main_zone()), binop(nullptr), unop(nullptr), javascript(main_zone()), diff --git a/test/cctest/test-field-type-tracking.cc b/test/cctest/test-field-type-tracking.cc index f8507264cc..4e37103558 100644 --- a/test/cctest/test-field-type-tracking.cc +++ b/test/cctest/test-field-type-tracking.cc @@ -609,7 +609,6 @@ static void TestGeneralizeField(int detach_property_at_index, bool expected_deprecation, bool expected_field_type_dependency) { Isolate* isolate = CcTest::i_isolate(); - JSHeapBroker broker(isolate); Handle any_type = FieldType::Any(isolate); CHECK(detach_property_at_index >= -1 && @@ -656,6 +655,7 @@ static void TestGeneralizeField(int detach_property_at_index, // Create new maps by generalizing representation of propX field. CanonicalHandleScope canonical(isolate); + JSHeapBroker broker(isolate, &zone); CompilationDependencies dependencies(isolate, &zone); dependencies.DependOnFieldType(MapRef(&broker, map), property_index); @@ -989,7 +989,6 @@ TEST(GeneralizeFieldWithAccessorProperties) { static void TestReconfigureDataFieldAttribute_GeneralizeField( const CRFTData& from, const CRFTData& to, const CRFTData& expected) { Isolate* isolate = CcTest::i_isolate(); - JSHeapBroker broker(isolate); Expectations expectations(isolate); @@ -1028,6 +1027,7 @@ static void TestReconfigureDataFieldAttribute_GeneralizeField( Zone zone(isolate->allocator(), ZONE_NAME); CanonicalHandleScope canonical(isolate); + JSHeapBroker broker(isolate, &zone); CompilationDependencies dependencies(isolate, &zone); dependencies.DependOnFieldType(MapRef(&broker, map), kSplitProp); @@ -1073,7 +1073,6 @@ static void TestReconfigureDataFieldAttribute_GeneralizeFieldTrivial( const CRFTData& from, const CRFTData& to, const CRFTData& expected, bool expected_field_type_dependency = true) { Isolate* isolate = CcTest::i_isolate(); - JSHeapBroker broker(isolate); Expectations expectations(isolate); @@ -1112,6 +1111,7 @@ static void TestReconfigureDataFieldAttribute_GeneralizeFieldTrivial( Zone zone(isolate->allocator(), ZONE_NAME); CanonicalHandleScope canonical(isolate); + JSHeapBroker broker(isolate, &zone); CompilationDependencies dependencies(isolate, &zone); dependencies.DependOnFieldType(MapRef(&broker, map), kSplitProp); @@ -1753,7 +1753,6 @@ TEST(ReconfigureDataFieldAttribute_AccConstantToDataFieldAfterTargetMap) { static void TestReconfigureElementsKind_GeneralizeField( const CRFTData& from, const CRFTData& to, const CRFTData& expected) { Isolate* isolate = CcTest::i_isolate(); - JSHeapBroker broker(isolate); Expectations expectations(isolate, PACKED_SMI_ELEMENTS); @@ -1793,6 +1792,7 @@ static void TestReconfigureElementsKind_GeneralizeField( Zone zone(isolate->allocator(), ZONE_NAME); CanonicalHandleScope canonical(isolate); + JSHeapBroker broker(isolate, &zone); CompilationDependencies dependencies(isolate, &zone); dependencies.DependOnFieldType(MapRef(&broker, map), kDiffProp); @@ -1848,7 +1848,6 @@ static void TestReconfigureElementsKind_GeneralizeField( static void TestReconfigureElementsKind_GeneralizeFieldTrivial( const CRFTData& from, const CRFTData& to, const CRFTData& expected) { Isolate* isolate = CcTest::i_isolate(); - JSHeapBroker broker(isolate); Expectations expectations(isolate, PACKED_SMI_ELEMENTS); @@ -1888,6 +1887,7 @@ static void TestReconfigureElementsKind_GeneralizeFieldTrivial( Zone zone(isolate->allocator(), ZONE_NAME); CanonicalHandleScope canonical(isolate); + JSHeapBroker broker(isolate, &zone); CompilationDependencies dependencies(isolate, &zone); dependencies.DependOnFieldType(MapRef(&broker, map), kDiffProp); diff --git a/test/cctest/types-fuzz.h b/test/cctest/types-fuzz.h index db264db42c..b6b5bf2dc5 100644 --- a/test/cctest/types-fuzz.h +++ b/test/cctest/types-fuzz.h @@ -40,7 +40,7 @@ namespace compiler { class Types { public: Types(Zone* zone, Isolate* isolate, v8::base::RandomNumberGenerator* rng) - : zone_(zone), js_heap_broker_(isolate), rng_(rng) { + : zone_(zone), js_heap_broker_(isolate, zone), rng_(rng) { #define DECLARE_TYPE(name, value) \ name = Type::name(); \ types.push_back(name); @@ -209,7 +209,7 @@ class Types { } Zone* zone() { return zone_; } - const JSHeapBroker* js_heap_broker() const { return &js_heap_broker_; } + JSHeapBroker* js_heap_broker() { return &js_heap_broker_; } private: Zone* zone_; diff --git a/test/unittests/compiler/common-operator-reducer-unittest.cc b/test/unittests/compiler/common-operator-reducer-unittest.cc index 086fa2ec7d..cb5b5fd806 100644 --- a/test/unittests/compiler/common-operator-reducer-unittest.cc +++ b/test/unittests/compiler/common-operator-reducer-unittest.cc @@ -29,7 +29,7 @@ class CommonOperatorReducerTest : public GraphTest { Reduction Reduce( AdvancedReducer::Editor* editor, Node* node, MachineOperatorBuilder::Flags flags = MachineOperatorBuilder::kNoFlags) { - JSHeapBroker broker(isolate()); + JSHeapBroker broker(isolate(), zone()); MachineOperatorBuilder machine(zone(), MachineType::PointerRepresentation(), flags); CommonOperatorReducer reducer(editor, graph(), &broker, common(), &machine, diff --git a/test/unittests/compiler/constant-folding-reducer-unittest.cc b/test/unittests/compiler/constant-folding-reducer-unittest.cc index 6780bf8500..464ee3a971 100644 --- a/test/unittests/compiler/constant-folding-reducer-unittest.cc +++ b/test/unittests/compiler/constant-folding-reducer-unittest.cc @@ -63,7 +63,7 @@ class ConstantFoldingReducerTest : public TypedGraphTest { public: ConstantFoldingReducerTest() : TypedGraphTest(3), - js_heap_broker_(isolate()), + js_heap_broker_(isolate(), zone()), simplified_(zone()), deps_(isolate(), zone()) {} ~ConstantFoldingReducerTest() override {} @@ -81,7 +81,7 @@ class ConstantFoldingReducerTest : public TypedGraphTest { } SimplifiedOperatorBuilder* simplified() { return &simplified_; } - const JSHeapBroker* js_heap_broker() const { return &js_heap_broker_; } + JSHeapBroker* js_heap_broker() { return &js_heap_broker_; } private: JSHeapBroker js_heap_broker_; diff --git a/test/unittests/compiler/graph-unittest.cc b/test/unittests/compiler/graph-unittest.cc index a731a8f1cb..faf7793b19 100644 --- a/test/unittests/compiler/graph-unittest.cc +++ b/test/unittests/compiler/graph-unittest.cc @@ -18,7 +18,7 @@ GraphTest::GraphTest(int num_parameters) TestWithIsolateAndZone(), common_(zone()), graph_(zone()), - js_heap_broker_(isolate()), + js_heap_broker_(isolate(), zone()), source_positions_(&graph_), node_origins_(&graph_) { graph()->SetStart(graph()->NewNode(common()->Start(num_parameters))); diff --git a/test/unittests/compiler/graph-unittest.h b/test/unittests/compiler/graph-unittest.h index 1a9c83bb8a..de0f427b7a 100644 --- a/test/unittests/compiler/graph-unittest.h +++ b/test/unittests/compiler/graph-unittest.h @@ -62,7 +62,7 @@ class GraphTest : public virtual TestWithNativeContext, Graph* graph() { return &graph_; } SourcePositionTable* source_positions() { return &source_positions_; } NodeOriginTable* node_origins() { return &node_origins_; } - const JSHeapBroker* js_heap_broker() { return &js_heap_broker_; } + JSHeapBroker* js_heap_broker() { return &js_heap_broker_; } private: CommonOperatorBuilder common_; diff --git a/test/unittests/compiler/js-call-reducer-unittest.cc b/test/unittests/compiler/js-call-reducer-unittest.cc index 1f5e666eb2..53e3b48762 100644 --- a/test/unittests/compiler/js-call-reducer-unittest.cc +++ b/test/unittests/compiler/js-call-reducer-unittest.cc @@ -24,7 +24,7 @@ class JSCallReducerTest : public TypedGraphTest { : TypedGraphTest(3), javascript_(zone()), deps_(isolate(), zone()), - js_heap_broker(isolate()) {} + js_heap_broker(isolate(), zone()) {} ~JSCallReducerTest() override {} protected: diff --git a/test/unittests/compiler/simplified-operator-reducer-unittest.cc b/test/unittests/compiler/simplified-operator-reducer-unittest.cc index f0e463265e..7913d6398c 100644 --- a/test/unittests/compiler/simplified-operator-reducer-unittest.cc +++ b/test/unittests/compiler/simplified-operator-reducer-unittest.cc @@ -29,7 +29,7 @@ class SimplifiedOperatorReducerTest : public GraphTest { protected: Reduction Reduce(Node* node) { - JSHeapBroker js_heap_broker(isolate()); + JSHeapBroker js_heap_broker(isolate(), zone()); MachineOperatorBuilder machine(zone()); JSOperatorBuilder javascript(zone()); JSGraph jsgraph(isolate(), graph(), common(), &javascript, simplified(), diff --git a/test/unittests/compiler/typer-unittest.cc b/test/unittests/compiler/typer-unittest.cc index d1283a8ad1..53459c314a 100644 --- a/test/unittests/compiler/typer-unittest.cc +++ b/test/unittests/compiler/typer-unittest.cc @@ -22,7 +22,7 @@ class TyperTest : public TypedGraphTest { public: TyperTest() : TypedGraphTest(3), - js_heap_broker_(isolate()), + js_heap_broker_(isolate(), zone()), operation_typer_(isolate(), &js_heap_broker_, zone()), types_(zone(), isolate(), random_number_generator()), javascript_(zone()),