[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 <neis@chromium.org>
Reviewed-by: Maya Lekova <mslekova@chromium.org>
Reviewed-by: Jaroslav Sevcik <jarin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54618}
This commit is contained in:
Georg Neis 2018-07-23 18:36:52 +02:00 committed by Commit Bot
parent 7ead0c146e
commit 8994347c35
46 changed files with 205 additions and 168 deletions

View File

@ -237,7 +237,7 @@ Handle<Cell> PropertyAccessInfo::export_cell() const {
return Handle<Cell>::cast(constant_);
}
AccessInfoFactory::AccessInfoFactory(const JSHeapBroker* js_heap_broker,
AccessInfoFactory::AccessInfoFactory(JSHeapBroker* js_heap_broker,
CompilationDependencies* dependencies,
Handle<Context> native_context, Zone* zone)
: js_heap_broker_(js_heap_broker),

View File

@ -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<Context> 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<Context> 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<Context> const native_context_;
Isolate* const isolate_;

View File

@ -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)

View File

@ -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_;

View File

@ -346,7 +346,7 @@ bool CompilationDependencies::Commit(Handle<Code> code) {
}
namespace {
void DependOnStablePrototypeChain(const JSHeapBroker* broker,
void DependOnStablePrototypeChain(JSHeapBroker* broker,
CompilationDependencies* deps,
Handle<Map> map,
MaybeHandle<JSReceiver> last_prototype) {
@ -364,7 +364,7 @@ void DependOnStablePrototypeChain(const JSHeapBroker* broker,
} // namespace
void CompilationDependencies::DependOnStablePrototypeChains(
const JSHeapBroker* broker, Handle<Context> native_context,
JSHeapBroker* broker, Handle<Context> native_context,
std::vector<Handle<Map>> const& receiver_maps, Handle<JSObject> holder) {
Isolate* isolate = holder->GetIsolate();
// Determine actual holder and perform prototype chain checks.

View File

@ -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<Context> native_context,
JSHeapBroker* broker, Handle<Context> native_context,
std::vector<Handle<Map>> const& receiver_maps, Handle<JSObject> holder);
// Like DependOnElementsKind but also applies to all nested allocation sites.

View File

@ -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) {}

View File

@ -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);
};

View File

@ -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<Context> 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<Context> const native_context_;
CompilationDependencies* const dependencies_;

View File

@ -101,7 +101,7 @@ bool IsContextParameter(Node* node) {
// specialization context. If successful, update {distance} to whatever
// distance remains from the specialization context.
base::Optional<ContextRef> GetSpecializationContext(
const JSHeapBroker* broker, Node* node, size_t* distance,
JSHeapBroker* broker, Node* node, size_t* distance,
Maybe<OuterContext> maybe_outer) {
switch (node->opcode()) {
case IrOpcode::kHeapConstant: {

View File

@ -63,12 +63,12 @@ class JSContextSpecialization final : public AdvancedReducer {
JSGraph* jsgraph() const { return jsgraph_; }
Maybe<OuterContext> outer() const { return outer_; }
MaybeHandle<JSFunction> 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<OuterContext> outer_;
MaybeHandle<JSFunction> closure_;
const JSHeapBroker* const js_heap_broker_;
JSHeapBroker* const js_heap_broker_;
DISALLOW_COPY_AND_ASSIGN(JSContextSpecialization);
};

View File

@ -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<Context> 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<Context> const native_context_;
Zone* const zone_;
};

View File

@ -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> object_)
: broker(broker_), object(object_) {}
JSHeapBroker* broker;
Handle<Object> 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<MutableHeapNumber>()->value();
}
bool ObjectRef::IsSmi() const {
AllowHandleDereference allow_handle_dereference;
return object_->IsSmi();
}
int ObjectRef::AsSmi() const { return object<Smi>()->value(); }
bool ObjectRef::equals(const ObjectRef& other) const {
return object<Object>().equals(other.object<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<int> JSHeapBroker::TryGetSmi(Handle<Object> object) {
AllowHandleDereference allow_handle_dereference;
if (!object->IsSmi()) return base::Optional<int>();
return Smi::cast(*object)->value();
}
#define DEFINE_IS_AND_AS(Name) \
bool ObjectRef::Is##Name() const { \
AllowHandleDereference allow_handle_dereference; \
return object<Object>()->Is##Name(); \
} \
Name##Ref ObjectRef::As##Name() const { \
DCHECK(Is##Name()); \
return Name##Ref(broker(), object<HeapObject>()); \
#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<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<HeapObject>()->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<FixedArrayBase>(
object_elements =
broker()->isolate()->factory()->CopyAndTenureFixedCOWArray(
Handle<FixedArray>::cast(object_elements)));
Handle<FixedArray>::cast(object_elements));
object<JSObject>()->set_elements(*object_elements);
}
}
@ -885,6 +899,25 @@ PropertyDetails PropertyCellRef::property_details() const {
return object<PropertyCell>()->property_details();
}
ObjectRef::ObjectRef(JSHeapBroker* broker, Handle<Object> 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<Object> 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

View File

@ -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> object)
: broker_(broker), object_(object) {}
ObjectRef(JSHeapBroker* broker, Handle<Object> object);
explicit ObjectRef(ObjectData* data) : data_(data) { CHECK_NOT_NULL(data); }
bool equals(const ObjectRef& other) const;
Handle<Object> object() const;
// TODO(neis): Remove eventually.
template <typename T>
Handle<T> object() const {
AllowHandleDereference handle_dereference;
return Handle<T>::cast(object_);
return Handle<T>::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> 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> map) const {
AllowHandleDereference handle_dereference;
return HeapObjectTypeFromMap(*map);
}
static base::Optional<int> TryGetSmi(Handle<Object> 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<Address, ObjectData*> refs_;
};
} // namespace compiler

View File

@ -58,9 +58,9 @@ struct JSNativeContextSpecialization::ScriptContextTableLookupResult {
};
JSNativeContextSpecialization::JSNativeContextSpecialization(
Editor* editor, JSGraph* jsgraph, const JSHeapBroker* js_heap_broker,
Flags flags, Handle<Context> native_context,
CompilationDependencies* dependencies, Zone* zone)
Editor* editor, JSGraph* jsgraph, JSHeapBroker* js_heap_broker, Flags flags,
Handle<Context> native_context, CompilationDependencies* dependencies,
Zone* zone)
: AdvancedReducer(editor),
jsgraph_(jsgraph),
js_heap_broker_(js_heap_broker),

View File

@ -47,7 +47,7 @@ class JSNativeContextSpecialization final : public AdvancedReducer {
typedef base::Flags<Flag> Flags;
JSNativeContextSpecialization(Editor* editor, JSGraph* jsgraph,
const JSHeapBroker* js_heap_broker, Flags flags,
JSHeapBroker* js_heap_broker, Flags flags,
Handle<Context> 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<JSGlobalObject> global_object_;
Handle<JSGlobalProxy> global_proxy_;

View File

@ -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);
}

View File

@ -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_;

View File

@ -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());
}
};

View File

@ -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_ =

View File

@ -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);

View File

@ -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_);
}

View File

@ -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_;
};

View File

@ -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)

View File

@ -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<Node> to_number_code_;

View File

@ -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) {}

View File

@ -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);
};

View File

@ -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()) {}

View File

@ -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"; }

View File

@ -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<MapRef> GetStableMapFromObjectType(
const JSHeapBroker* js_heap_broker, Type object_type) {
base::Optional<MapRef> GetStableMapFromObjectType(JSHeapBroker* js_heap_broker,
Type object_type) {
if (object_type.IsHeapConstant()) {
HeapObjectRef object = object_type.AsHeapConstant()->Ref();
MapRef object_map = object.map();

View File

@ -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_;

View File

@ -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),

View File

@ -25,7 +25,7 @@ class V8_EXPORT_PRIVATE Typer {
};
typedef base::Flags<Flag> 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_;

View File

@ -820,22 +820,19 @@ Type Type::NewConstant(double value, Zone* zone) {
return OtherNumberConstant(value, zone);
}
Type Type::NewConstant(const JSHeapBroker* js_heap_broker,
Handle<i::Object> value, Zone* zone) {
auto maybe_smi = JSHeapBroker::TryGetSmi(value);
if (maybe_smi.has_value()) {
return NewConstant(static_cast<double>(maybe_smi.value()), zone);
Type Type::NewConstant(JSHeapBroker* js_heap_broker, Handle<i::Object> value,
Zone* zone) {
ObjectRef ref(js_heap_broker, value);
if (ref.IsSmi()) {
return NewConstant(static_cast<double>(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<i::Object> value, Zone* zone) {
Type Type::HeapConstant(JSHeapBroker* js_heap_broker, Handle<i::Object> value,
Zone* zone) {
return FromTypeBase(
HeapConstantType::New(HeapObjectRef(js_heap_broker, value), zone));
}

View File

@ -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<i::Object> 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<i::Object> value, Zone* zone);
static Type NewConstant(JSHeapBroker* js_heap_broker, Handle<i::Object> 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<i::Map> map) {
static Type For(JSHeapBroker* js_heap_broker, Handle<i::Map> map) {
HeapObjectType type = js_heap_broker->HeapObjectTypeFromMap(map);
return NewBitset(BitsetType::ExpandInternals(BitsetType::Lub(type)));
}

View File

@ -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<JSFunction>()) {}

View File

@ -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()),

View File

@ -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<FieldType> 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);

View File

@ -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_;

View File

@ -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,

View File

@ -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_;

View File

@ -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)));

View File

@ -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_;

View File

@ -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:

View File

@ -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(),

View File

@ -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()),