Commit 56d21252 authored by Georg Neis's avatar Georg Neis Committed by Commit Bot

[turbofan] Make the JSHeapBroker a member of ObjectRef.

This makes it more convenient to work with brokerized data.

Bug: v8:7790
Change-Id: I7ffb4054b809c10c67787b2fb89a05e8ce8f4575
Reviewed-on: https://chromium-review.googlesource.com/1138248
Commit-Queue: Georg Neis <neis@chromium.org>
Reviewed-by: 's avatarJaroslav Sevcik <jarin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54480}
parent b95def34
...@@ -18,10 +18,8 @@ namespace compiler { ...@@ -18,10 +18,8 @@ namespace compiler {
// allocated object and also provides helpers for commonly allocated objects. // allocated object and also provides helpers for commonly allocated objects.
class AllocationBuilder final { class AllocationBuilder final {
public: public:
AllocationBuilder(JSGraph* jsgraph, const JSHeapBroker* js_heap_broker, AllocationBuilder(JSGraph* jsgraph, Node* effect, Node* control)
Node* effect, Node* control)
: jsgraph_(jsgraph), : jsgraph_(jsgraph),
js_heap_broker_(js_heap_broker),
allocation_(nullptr), allocation_(nullptr),
effect_(effect), effect_(effect),
control_(control) {} control_(control) {}
...@@ -79,7 +77,7 @@ class AllocationBuilder final { ...@@ -79,7 +77,7 @@ class AllocationBuilder final {
} }
// Compound store of a constant into a field. // Compound store of a constant into a field.
void Store(const FieldAccess& access, const ObjectRef& value) { void Store(const FieldAccess& access, const ObjectRef& value) {
Store(access, jsgraph()->Constant(js_heap_broker(), value)); Store(access, jsgraph()->Constant(value));
} }
void FinishAndChange(Node* node) { void FinishAndChange(Node* node) {
...@@ -96,7 +94,6 @@ class AllocationBuilder final { ...@@ -96,7 +94,6 @@ class AllocationBuilder final {
protected: protected:
JSGraph* jsgraph() { return jsgraph_; } JSGraph* jsgraph() { return jsgraph_; }
const JSHeapBroker* js_heap_broker() { return js_heap_broker_; }
Isolate* isolate() const { return jsgraph_->isolate(); } Isolate* isolate() const { return jsgraph_->isolate(); }
Graph* graph() { return jsgraph_->graph(); } Graph* graph() { return jsgraph_->graph(); }
CommonOperatorBuilder* common() { return jsgraph_->common(); } CommonOperatorBuilder* common() { return jsgraph_->common(); }
...@@ -104,7 +101,6 @@ class AllocationBuilder final { ...@@ -104,7 +101,6 @@ class AllocationBuilder final {
private: private:
JSGraph* const jsgraph_; JSGraph* const jsgraph_;
const JSHeapBroker* const js_heap_broker_;
Node* allocation_; Node* allocation_;
Node* effect_; Node* effect_;
Node* control_; Node* control_;
......
...@@ -27,8 +27,8 @@ Decision DecideCondition(const JSHeapBroker* broker, Node* const cond) { ...@@ -27,8 +27,8 @@ Decision DecideCondition(const JSHeapBroker* broker, Node* const cond) {
} }
case IrOpcode::kHeapConstant: { case IrOpcode::kHeapConstant: {
HeapObjectMatcher mcond(cond); HeapObjectMatcher mcond(cond);
ObjectRef object(mcond.Value()); return mcond.Ref(broker).BooleanValue() ? Decision::kTrue
return object.BooleanValue(broker) ? Decision::kTrue : Decision::kFalse; : Decision::kFalse;
} }
default: default:
return Decision::kUnknown; return Decision::kUnknown;
......
...@@ -37,12 +37,11 @@ Reduction ConstantFoldingReducer::Reduce(Node* node) { ...@@ -37,12 +37,11 @@ Reduction ConstantFoldingReducer::Reduce(Node* node) {
if (!upper.IsNone()) { if (!upper.IsNone()) {
Node* replacement = nullptr; Node* replacement = nullptr;
if (upper.IsHeapConstant()) { if (upper.IsHeapConstant()) {
replacement = jsgraph()->Constant(js_heap_broker(), replacement = jsgraph()->Constant(upper.AsHeapConstant()->Ref());
upper.AsHeapConstant()->Ref());
} else if (upper.Is(Type::MinusZero())) { } else if (upper.Is(Type::MinusZero())) {
Factory* factory = jsgraph()->isolate()->factory(); Factory* factory = jsgraph()->isolate()->factory();
ObjectRef minus_zero(factory->minus_zero_value()); ObjectRef minus_zero(js_heap_broker(), factory->minus_zero_value());
replacement = jsgraph()->Constant(js_heap_broker(), minus_zero); replacement = jsgraph()->Constant(minus_zero);
} else if (upper.Is(Type::NaN())) { } else if (upper.Is(Type::NaN())) {
replacement = jsgraph()->NaNConstant(); replacement = jsgraph()->NaNConstant();
} else if (upper.Is(Type::Null())) { } else if (upper.Is(Type::Null())) {
......
...@@ -1730,7 +1730,7 @@ Reduction JSCallReducer::ReduceArrayFilter(Node* node, ...@@ -1730,7 +1730,7 @@ Reduction JSCallReducer::ReduceArrayFilter(Node* node,
Node* a; // Construct the output array. Node* a; // Construct the output array.
{ {
AllocationBuilder ab(jsgraph(), js_heap_broker(), effect, control); AllocationBuilder ab(jsgraph(), effect, control);
ab.Allocate(initial_map->instance_size(), NOT_TENURED, Type::Array()); ab.Allocate(initial_map->instance_size(), NOT_TENURED, Type::Array());
ab.Store(AccessBuilder::ForMap(), initial_map); ab.Store(AccessBuilder::ForMap(), initial_map);
Node* empty_fixed_array = jsgraph()->EmptyFixedArrayConstant(); Node* empty_fixed_array = jsgraph()->EmptyFixedArrayConstant();
...@@ -1739,9 +1739,9 @@ Reduction JSCallReducer::ReduceArrayFilter(Node* node, ...@@ -1739,9 +1739,9 @@ Reduction JSCallReducer::ReduceArrayFilter(Node* node,
ab.Store(AccessBuilder::ForJSArrayLength(packed_kind), ab.Store(AccessBuilder::ForJSArrayLength(packed_kind),
jsgraph()->ZeroConstant()); jsgraph()->ZeroConstant());
for (int i = 0; i < initial_map->GetInObjectProperties(); ++i) { for (int i = 0; i < initial_map->GetInObjectProperties(); ++i) {
ab.Store( ab.Store(AccessBuilder::ForJSObjectInObjectProperty(
AccessBuilder::ForJSObjectInObjectProperty(MapRef(initial_map), i), MapRef(js_heap_broker(), initial_map), i),
jsgraph()->UndefinedConstant()); jsgraph()->UndefinedConstant());
} }
a = effect = ab.Finish(); a = effect = ab.Finish();
} }
......
...@@ -105,7 +105,7 @@ base::Optional<ContextRef> GetSpecializationContext( ...@@ -105,7 +105,7 @@ base::Optional<ContextRef> GetSpecializationContext(
Maybe<OuterContext> maybe_outer) { Maybe<OuterContext> maybe_outer) {
switch (node->opcode()) { switch (node->opcode()) {
case IrOpcode::kHeapConstant: { case IrOpcode::kHeapConstant: {
HeapObjectRef object(HeapConstantOf(node->op())); HeapObjectRef object(broker, HeapConstantOf(node->op()));
if (object.IsContext()) return object.AsContext(); if (object.IsContext()) return object.AsContext();
break; break;
} }
...@@ -114,7 +114,7 @@ base::Optional<ContextRef> GetSpecializationContext( ...@@ -114,7 +114,7 @@ base::Optional<ContextRef> GetSpecializationContext(
if (maybe_outer.To(&outer) && IsContextParameter(node) && if (maybe_outer.To(&outer) && IsContextParameter(node) &&
*distance >= outer.distance) { *distance >= outer.distance) {
*distance -= outer.distance; *distance -= outer.distance;
return ContextRef(outer.context); return ContextRef(broker, outer.context);
} }
break; break;
} }
...@@ -146,28 +146,26 @@ Reduction JSContextSpecialization::ReduceJSLoadContext(Node* node) { ...@@ -146,28 +146,26 @@ Reduction JSContextSpecialization::ReduceJSLoadContext(Node* node) {
// Now walk up the concrete context chain for the remaining depth. // Now walk up the concrete context chain for the remaining depth.
ContextRef concrete = maybe_concrete.value(); ContextRef concrete = maybe_concrete.value();
for (; depth > 0; --depth) { for (; depth > 0; --depth) {
concrete = concrete.previous(js_heap_broker()).value(); concrete = concrete.previous().value();
} }
if (!access.immutable()) { if (!access.immutable()) {
// We found the requested context object but since the context slot is // We found the requested context object but since the context slot is
// mutable we can only partially reduce the load. // mutable we can only partially reduce the load.
return SimplifyJSLoadContext( return SimplifyJSLoadContext(node, jsgraph()->Constant(concrete), depth);
node, jsgraph()->Constant(js_heap_broker(), concrete), depth);
} }
// This will hold the final value, if we can figure it out. // This will hold the final value, if we can figure it out.
base::Optional<ObjectRef> maybe_value; base::Optional<ObjectRef> maybe_value;
maybe_value = maybe_value = concrete.get(static_cast<int>(access.index()));
concrete.get(js_heap_broker(), static_cast<int>(access.index()));
if (maybe_value.has_value() && !maybe_value->IsSmi()) { if (maybe_value.has_value() && !maybe_value->IsSmi()) {
// Even though the context slot is immutable, the context might have escaped // Even though the context slot is immutable, the context might have escaped
// before the function to which it belongs has initialized the slot. // before the function to which it belongs has initialized the slot.
// We must be conservative and check if the value in the slot is currently // We must be conservative and check if the value in the slot is currently
// the hole or undefined. Only if it is neither of these, can we be sure // the hole or undefined. Only if it is neither of these, can we be sure
// that it won't change anymore. // that it won't change anymore.
OddballType oddball_type = maybe_value->oddball_type(js_heap_broker()); OddballType oddball_type = maybe_value->oddball_type();
if (oddball_type == OddballType::kUndefined || if (oddball_type == OddballType::kUndefined ||
oddball_type == OddballType::kHole) { oddball_type == OddballType::kHole) {
maybe_value.reset(); maybe_value.reset();
...@@ -175,15 +173,14 @@ Reduction JSContextSpecialization::ReduceJSLoadContext(Node* node) { ...@@ -175,15 +173,14 @@ Reduction JSContextSpecialization::ReduceJSLoadContext(Node* node) {
} }
if (!maybe_value.has_value()) { if (!maybe_value.has_value()) {
return SimplifyJSLoadContext( return SimplifyJSLoadContext(node, jsgraph()->Constant(concrete), depth);
node, jsgraph()->Constant(js_heap_broker(), concrete), depth);
} }
// Success. The context load can be replaced with the constant. // Success. The context load can be replaced with the constant.
// TODO(titzer): record the specialization for sharing code across // TODO(titzer): record the specialization for sharing code across
// multiple contexts that have the same value in the corresponding context // multiple contexts that have the same value in the corresponding context
// slot. // slot.
Node* constant = jsgraph_->Constant(js_heap_broker(), *maybe_value); Node* constant = jsgraph_->Constant(*maybe_value);
ReplaceWithValue(node, constant); ReplaceWithValue(node, constant);
return Replace(constant); return Replace(constant);
} }
...@@ -210,11 +207,10 @@ Reduction JSContextSpecialization::ReduceJSStoreContext(Node* node) { ...@@ -210,11 +207,10 @@ Reduction JSContextSpecialization::ReduceJSStoreContext(Node* node) {
// Now walk up the concrete context chain for the remaining depth. // Now walk up the concrete context chain for the remaining depth.
ContextRef concrete = maybe_concrete.value(); ContextRef concrete = maybe_concrete.value();
for (; depth > 0; --depth) { for (; depth > 0; --depth) {
concrete = concrete.previous(js_heap_broker()).value(); concrete = concrete.previous().value();
} }
return SimplifyJSStoreContext( return SimplifyJSStoreContext(node, jsgraph()->Constant(concrete), depth);
node, jsgraph()->Constant(js_heap_broker(), concrete), depth);
} }
......
This diff is collapsed.
...@@ -66,9 +66,9 @@ Node* JSGraph::Constant(Handle<Object> value) { ...@@ -66,9 +66,9 @@ Node* JSGraph::Constant(Handle<Object> value) {
} }
} }
Node* JSGraph::Constant(const JSHeapBroker* broker, const ObjectRef& ref) { Node* JSGraph::Constant(const ObjectRef& ref) {
if (ref.IsSmi()) return Constant(ref.AsSmi()); if (ref.IsSmi()) return Constant(ref.AsSmi());
OddballType oddball_type = ref.oddball_type(broker); OddballType oddball_type = ref.oddball_type();
if (ref.IsHeapNumber()) { if (ref.IsHeapNumber()) {
return Constant(ref.AsHeapNumber().value()); return Constant(ref.AsHeapNumber().value());
} else if (oddball_type == OddballType::kUndefined) { } else if (oddball_type == OddballType::kUndefined) {
......
...@@ -56,8 +56,7 @@ class V8_EXPORT_PRIVATE JSGraph : public MachineGraph { ...@@ -56,8 +56,7 @@ class V8_EXPORT_PRIVATE JSGraph : public MachineGraph {
Node* Constant(Handle<Object> value); Node* Constant(Handle<Object> value);
// Like above, but doesn't access the heap directly. // Like above, but doesn't access the heap directly.
// TODO(neis): Make the broker a member of JSGraph. Node* Constant(const ObjectRef& value);
Node* Constant(const JSHeapBroker* broker, const ObjectRef& value);
// Creates a NumberConstant node, usually canonicalized. // Creates a NumberConstant node, usually canonicalized.
Node* Constant(double value); Node* Constant(double value);
......
This diff is collapsed.
...@@ -94,7 +94,8 @@ HEAP_BROKER_OBJECT_LIST(FORWARD_DECL) ...@@ -94,7 +94,8 @@ HEAP_BROKER_OBJECT_LIST(FORWARD_DECL)
class ObjectRef { class ObjectRef {
public: public:
explicit ObjectRef(Handle<Object> object) : object_(object) {} explicit ObjectRef(const JSHeapBroker* broker, Handle<Object> object)
: broker_(broker), object_(object) {}
template <typename T> template <typename T>
Handle<T> object() const { Handle<T> object() const {
...@@ -102,7 +103,7 @@ class ObjectRef { ...@@ -102,7 +103,7 @@ class ObjectRef {
return Handle<T>::cast(object_); return Handle<T>::cast(object_);
} }
OddballType oddball_type(const JSHeapBroker* broker) const; OddballType oddball_type() const;
bool IsSmi() const; bool IsSmi() const;
int AsSmi() const; int AsSmi() const;
...@@ -117,11 +118,15 @@ class ObjectRef { ...@@ -117,11 +118,15 @@ class ObjectRef {
HEAP_BROKER_OBJECT_LIST(HEAP_AS_METHOD_DECL) HEAP_BROKER_OBJECT_LIST(HEAP_AS_METHOD_DECL)
#undef HEAP_AS_METHOD_DECL #undef HEAP_AS_METHOD_DECL
StringRef TypeOf(const JSHeapBroker* broker) const; StringRef TypeOf() const;
bool BooleanValue(const JSHeapBroker* broker); bool BooleanValue();
double OddballToNumber(const JSHeapBroker* broker) const; double OddballToNumber() const;
protected:
const JSHeapBroker* broker() const { return broker_; }
private: private:
const JSHeapBroker* broker_;
Handle<Object> object_; Handle<Object> object_;
}; };
...@@ -129,10 +134,9 @@ class HeapObjectRef : public ObjectRef { ...@@ -129,10 +134,9 @@ class HeapObjectRef : public ObjectRef {
public: public:
using ObjectRef::ObjectRef; using ObjectRef::ObjectRef;
HeapObjectType type(const JSHeapBroker* broker) const; HeapObjectType type() const;
MapRef map(const JSHeapBroker* broker) const; MapRef map() const;
base::Optional<MapRef> TryGetObjectCreateMap( base::Optional<MapRef> TryGetObjectCreateMap() const;
const JSHeapBroker* broker) const;
bool IsSeqString() const; bool IsSeqString() const;
bool IsExternalString() const; bool IsExternalString() const;
}; };
...@@ -143,11 +147,10 @@ class JSObjectRef : public HeapObjectRef { ...@@ -143,11 +147,10 @@ class JSObjectRef : public HeapObjectRef {
bool IsUnboxedDoubleField(FieldIndex index) const; bool IsUnboxedDoubleField(FieldIndex index) const;
double RawFastDoublePropertyAt(FieldIndex index) const; double RawFastDoublePropertyAt(FieldIndex index) const;
ObjectRef RawFastPropertyAt(const JSHeapBroker* broker, ObjectRef RawFastPropertyAt(FieldIndex index) const;
FieldIndex index) const;
FixedArrayBaseRef elements(const JSHeapBroker* broker) const; FixedArrayBaseRef elements() const;
void EnsureElementsTenured(const JSHeapBroker* broker); void EnsureElementsTenured();
}; };
struct SlackTrackingResult { struct SlackTrackingResult {
...@@ -166,15 +169,13 @@ class JSFunctionRef : public JSObjectRef { ...@@ -166,15 +169,13 @@ class JSFunctionRef : public JSObjectRef {
BuiltinFunctionId GetBuiltinFunctionId() const; BuiltinFunctionId GetBuiltinFunctionId() const;
bool IsConstructor() const; bool IsConstructor() const;
bool has_initial_map() const; bool has_initial_map() const;
MapRef initial_map(const JSHeapBroker* broker) const; MapRef initial_map() const;
MapRef DependOnInitialMap(const JSHeapBroker* broker, MapRef DependOnInitialMap(CompilationDependencies* dependencies) const;
CompilationDependencies* dependencies) const;
JSGlobalProxyRef global_proxy(const JSHeapBroker* broker) const; JSGlobalProxyRef global_proxy() const;
SlackTrackingResult FinishSlackTracking() const; SlackTrackingResult FinishSlackTracking() const;
SharedFunctionInfoRef shared(const JSHeapBroker* broker) const; SharedFunctionInfoRef shared() const;
void EnsureHasInitialMap() const; void EnsureHasInitialMap() const;
}; };
...@@ -182,11 +183,11 @@ class JSRegExpRef : public JSObjectRef { ...@@ -182,11 +183,11 @@ class JSRegExpRef : public JSObjectRef {
public: public:
using JSObjectRef::JSObjectRef; using JSObjectRef::JSObjectRef;
ObjectRef raw_properties_or_hash(const JSHeapBroker* broker) const; ObjectRef raw_properties_or_hash() const;
ObjectRef data(const JSHeapBroker* broker) const; ObjectRef data() const;
ObjectRef source(const JSHeapBroker* broker) const; ObjectRef source() const;
ObjectRef flags(const JSHeapBroker* broker) const; ObjectRef flags() const;
ObjectRef last_index(const JSHeapBroker* broker) const; ObjectRef last_index() const;
}; };
class HeapNumberRef : public HeapObjectRef { class HeapNumberRef : public HeapObjectRef {
...@@ -207,28 +208,28 @@ class ContextRef : public HeapObjectRef { ...@@ -207,28 +208,28 @@ class ContextRef : public HeapObjectRef {
public: public:
using HeapObjectRef::HeapObjectRef; using HeapObjectRef::HeapObjectRef;
base::Optional<ContextRef> previous(const JSHeapBroker* broker) const; base::Optional<ContextRef> previous() const;
ObjectRef get(const JSHeapBroker* broker, int index) const; ObjectRef get(int index) const;
}; };
class NativeContextRef : public ContextRef { class NativeContextRef : public ContextRef {
public: public:
using ContextRef::ContextRef; using ContextRef::ContextRef;
ScriptContextTableRef script_context_table(const JSHeapBroker* broker) const; ScriptContextTableRef script_context_table() const;
MapRef fast_aliased_arguments_map(const JSHeapBroker* broker) const; MapRef fast_aliased_arguments_map() const;
MapRef sloppy_arguments_map(const JSHeapBroker* broker) const; MapRef sloppy_arguments_map() const;
MapRef strict_arguments_map(const JSHeapBroker* broker) const; MapRef strict_arguments_map() const;
MapRef js_array_fast_elements_map_index(const JSHeapBroker* broker) const; MapRef js_array_fast_elements_map_index() const;
MapRef initial_array_iterator_map(const JSHeapBroker* broker) const; MapRef initial_array_iterator_map() const;
MapRef set_value_iterator_map(const JSHeapBroker* broker) const; MapRef set_value_iterator_map() const;
MapRef set_key_value_iterator_map(const JSHeapBroker* broker) const; MapRef set_key_value_iterator_map() const;
MapRef map_key_iterator_map(const JSHeapBroker* broker) const; MapRef map_key_iterator_map() const;
MapRef map_value_iterator_map(const JSHeapBroker* broker) const; MapRef map_value_iterator_map() const;
MapRef map_key_value_iterator_map(const JSHeapBroker* broker) const; MapRef map_key_value_iterator_map() const;
MapRef GetFunctionMapFromIndex(const JSHeapBroker* broker, int index) const; MapRef GetFunctionMapFromIndex(int index) const;
}; };
class NameRef : public HeapObjectRef { class NameRef : public HeapObjectRef {
...@@ -253,16 +254,16 @@ class FeedbackVectorRef : public HeapObjectRef { ...@@ -253,16 +254,16 @@ class FeedbackVectorRef : public HeapObjectRef {
public: public:
using HeapObjectRef::HeapObjectRef; using HeapObjectRef::HeapObjectRef;
ObjectRef get(const JSHeapBroker* broker, FeedbackSlot slot) const; ObjectRef get(FeedbackSlot slot) const;
}; };
class AllocationSiteRef : public HeapObjectRef { class AllocationSiteRef : public HeapObjectRef {
public: public:
using HeapObjectRef::HeapObjectRef; using HeapObjectRef::HeapObjectRef;
JSObjectRef boilerplate(const JSHeapBroker* broker) const; JSObjectRef boilerplate() const;
PretenureFlag GetPretenureMode() const; PretenureFlag GetPretenureMode() const;
bool IsFastLiteral(const JSHeapBroker* broker) const; bool IsFastLiteral() const;
}; };
class MapRef : public HeapObjectRef { class MapRef : public HeapObjectRef {
...@@ -274,10 +275,10 @@ class MapRef : public HeapObjectRef { ...@@ -274,10 +275,10 @@ class MapRef : public HeapObjectRef {
int GetInObjectProperties() const; int GetInObjectProperties() const;
int NumberOfOwnDescriptors() const; int NumberOfOwnDescriptors() const;
PropertyDetails GetPropertyDetails(int i) const; PropertyDetails GetPropertyDetails(int i) const;
NameRef GetPropertyKey(const JSHeapBroker* broker, int i) const; NameRef GetPropertyKey(int i) const;
FieldIndex GetFieldIndexFor(int i) const; FieldIndex GetFieldIndexFor(int i) const;
int GetInObjectPropertyOffset(int index) const; int GetInObjectPropertyOffset(int index) const;
ObjectRef constructor_or_backpointer(const JSHeapBroker* broker) const; ObjectRef constructor_or_backpointer() const;
bool is_stable() const; bool is_stable() const;
bool has_prototype_slot() const; bool has_prototype_slot() const;
...@@ -286,10 +287,9 @@ class MapRef : public HeapObjectRef { ...@@ -286,10 +287,9 @@ class MapRef : public HeapObjectRef {
bool is_dictionary_map() const; bool is_dictionary_map() const;
bool IsJSArrayMap() const; bool IsJSArrayMap() const;
bool IsFixedCowArrayMap(const JSHeapBroker* broker) const; bool IsFixedCowArrayMap() const;
void DependOnStableMap(const JSHeapBroker* broker, void DependOnStableMap(CompilationDependencies* dependencies) const;
CompilationDependencies* dependencies) const;
}; };
class FixedArrayBaseRef : public HeapObjectRef { class FixedArrayBaseRef : public HeapObjectRef {
...@@ -303,8 +303,8 @@ class FixedArrayRef : public FixedArrayBaseRef { ...@@ -303,8 +303,8 @@ class FixedArrayRef : public FixedArrayBaseRef {
public: public:
using FixedArrayBaseRef::FixedArrayBaseRef; using FixedArrayBaseRef::FixedArrayBaseRef;
ObjectRef get(const JSHeapBroker* broker, int i) const; ObjectRef get(int i) const;
bool is_the_hole(const JSHeapBroker* broker, int i) const; bool is_the_hole(int i) const;
}; };
class FixedDoubleArrayRef : public FixedArrayBaseRef { class FixedDoubleArrayRef : public FixedArrayBaseRef {
...@@ -320,7 +320,7 @@ class JSArrayRef : public JSObjectRef { ...@@ -320,7 +320,7 @@ class JSArrayRef : public JSObjectRef {
using JSObjectRef::JSObjectRef; using JSObjectRef::JSObjectRef;
ElementsKind GetElementsKind() const; ElementsKind GetElementsKind() const;
ObjectRef length(const JSHeapBroker* broker) const; ObjectRef length() const;
}; };
class ScopeInfoRef : public HeapObjectRef { class ScopeInfoRef : public HeapObjectRef {
...@@ -354,29 +354,29 @@ class StringRef : public NameRef { ...@@ -354,29 +354,29 @@ class StringRef : public NameRef {
int length() const; int length() const;
uint16_t GetFirstChar(); uint16_t GetFirstChar();
double ToNumber(const JSHeapBroker* broker); double ToNumber();
}; };
class ModuleRef : public HeapObjectRef { class ModuleRef : public HeapObjectRef {
public: public:
explicit ModuleRef(Handle<Object> object) : HeapObjectRef(object) {} using HeapObjectRef::HeapObjectRef;
CellRef GetCell(const JSHeapBroker* broker, int cell_index); CellRef GetCell(int cell_index);
}; };
class CellRef : public HeapObjectRef { class CellRef : public HeapObjectRef {
public: public:
explicit CellRef(Handle<Object> object) : HeapObjectRef(object) {} using HeapObjectRef::HeapObjectRef;
}; };
class JSGlobalProxyRef : public JSObjectRef { class JSGlobalProxyRef : public JSObjectRef {
public: public:
explicit JSGlobalProxyRef(Handle<Object> object) : JSObjectRef(object) {} using JSObjectRef::JSObjectRef;
}; };
class CodeRef : public HeapObjectRef { class CodeRef : public HeapObjectRef {
public: public:
explicit CodeRef(Handle<Object> object) : HeapObjectRef(object) {} using HeapObjectRef::HeapObjectRef;
}; };
class InternalizedStringRef : public StringRef { class InternalizedStringRef : public StringRef {
......
...@@ -68,7 +68,7 @@ JSNativeContextSpecialization::JSNativeContextSpecialization( ...@@ -68,7 +68,7 @@ JSNativeContextSpecialization::JSNativeContextSpecialization(
global_object_(native_context->global_object(), jsgraph->isolate()), global_object_(native_context->global_object(), jsgraph->isolate()),
global_proxy_(JSGlobalProxy::cast(native_context->global_proxy()), global_proxy_(JSGlobalProxy::cast(native_context->global_proxy()),
jsgraph->isolate()), jsgraph->isolate()),
native_context_(native_context), native_context_(js_heap_broker, native_context),
dependencies_(dependencies), dependencies_(dependencies),
zone_(zone), zone_(zone),
type_cache_(TypeCache::Get()) {} type_cache_(TypeCache::Get()) {}
...@@ -520,7 +520,7 @@ Reduction JSNativeContextSpecialization::ReduceJSLoadContext(Node* node) { ...@@ -520,7 +520,7 @@ Reduction JSNativeContextSpecialization::ReduceJSLoadContext(Node* node) {
// context (if any), so we can constant-fold those fields, which is // context (if any), so we can constant-fold those fields, which is
// safe, since the NATIVE_CONTEXT_INDEX slot is always immutable. // safe, since the NATIVE_CONTEXT_INDEX slot is always immutable.
if (access.index() == Context::NATIVE_CONTEXT_INDEX) { if (access.index() == Context::NATIVE_CONTEXT_INDEX) {
Node* value = jsgraph()->Constant(js_heap_broker(), native_context()); Node* value = jsgraph()->Constant(native_context());
ReplaceWithValue(node, value); ReplaceWithValue(node, value);
return Replace(value); return Replace(value);
} }
...@@ -732,19 +732,19 @@ Reduction JSNativeContextSpecialization::ReduceGlobalAccess( ...@@ -732,19 +732,19 @@ Reduction JSNativeContextSpecialization::ReduceGlobalAccess(
Reduction JSNativeContextSpecialization::ReduceJSLoadGlobal(Node* node) { Reduction JSNativeContextSpecialization::ReduceJSLoadGlobal(Node* node) {
DCHECK_EQ(IrOpcode::kJSLoadGlobal, node->opcode()); DCHECK_EQ(IrOpcode::kJSLoadGlobal, node->opcode());
NameRef name(LoadGlobalParametersOf(node->op()).name()); NameRef name(js_heap_broker(), LoadGlobalParametersOf(node->op()).name());
Node* effect = NodeProperties::GetEffectInput(node); Node* effect = NodeProperties::GetEffectInput(node);
// Try to lookup the name on the script context table first (lexical scoping). // Try to lookup the name on the script context table first (lexical scoping).
base::Optional<ScriptContextTableRef::LookupResult> result = base::Optional<ScriptContextTableRef::LookupResult> result =
native_context().script_context_table(js_heap_broker()).lookup(name); native_context().script_context_table().lookup(name);
if (result) { if (result) {
ObjectRef contents = result->context.get(js_heap_broker(), result->index); ObjectRef contents = result->context.get(result->index);
OddballType oddball_type = contents.oddball_type(js_heap_broker()); OddballType oddball_type = contents.oddball_type();
if (oddball_type == OddballType::kHole) { if (oddball_type == OddballType::kHole) {
return NoChange(); return NoChange();
} }
Node* context = jsgraph()->Constant(js_heap_broker(), result->context); Node* context = jsgraph()->Constant(result->context);
Node* value = effect = graph()->NewNode( Node* value = effect = graph()->NewNode(
javascript()->LoadContext(0, result->index, result->immutable), context, javascript()->LoadContext(0, result->index, result->immutable), context,
effect); effect);
...@@ -759,21 +759,21 @@ Reduction JSNativeContextSpecialization::ReduceJSLoadGlobal(Node* node) { ...@@ -759,21 +759,21 @@ Reduction JSNativeContextSpecialization::ReduceJSLoadGlobal(Node* node) {
Reduction JSNativeContextSpecialization::ReduceJSStoreGlobal(Node* node) { Reduction JSNativeContextSpecialization::ReduceJSStoreGlobal(Node* node) {
DCHECK_EQ(IrOpcode::kJSStoreGlobal, node->opcode()); DCHECK_EQ(IrOpcode::kJSStoreGlobal, node->opcode());
NameRef name(StoreGlobalParametersOf(node->op()).name()); NameRef name(js_heap_broker(), StoreGlobalParametersOf(node->op()).name());
Node* value = NodeProperties::GetValueInput(node, 0); Node* value = NodeProperties::GetValueInput(node, 0);
Node* effect = NodeProperties::GetEffectInput(node); Node* effect = NodeProperties::GetEffectInput(node);
Node* control = NodeProperties::GetControlInput(node); Node* control = NodeProperties::GetControlInput(node);
// Try to lookup the name on the script context table first (lexical scoping). // Try to lookup the name on the script context table first (lexical scoping).
base::Optional<ScriptContextTableRef::LookupResult> result = base::Optional<ScriptContextTableRef::LookupResult> result =
native_context().script_context_table(js_heap_broker()).lookup(name); native_context().script_context_table().lookup(name);
if (result) { if (result) {
ObjectRef contents = result->context.get(js_heap_broker(), result->index); ObjectRef contents = result->context.get(result->index);
OddballType oddball_type = contents.oddball_type(js_heap_broker()); OddballType oddball_type = contents.oddball_type();
if (oddball_type == OddballType::kHole || result->immutable) { if (oddball_type == OddballType::kHole || result->immutable) {
return NoChange(); return NoChange();
} }
Node* context = jsgraph()->Constant(js_heap_broker(), result->context); Node* context = jsgraph()->Constant(result->context);
effect = graph()->NewNode(javascript()->StoreContext(0, result->index), effect = graph()->NewNode(javascript()->StoreContext(0, result->index),
value, context, effect, control); value, context, effect, control);
ReplaceWithValue(node, value, effect, control); ReplaceWithValue(node, value, effect, control);
...@@ -1774,7 +1774,7 @@ Node* JSNativeContextSpecialization::InlineApiCall( ...@@ -1774,7 +1774,7 @@ Node* JSNativeContextSpecialization::InlineApiCall(
Node* code = jsgraph()->HeapConstant(call_api_callback.code()); Node* code = jsgraph()->HeapConstant(call_api_callback.code());
// Add CallApiCallbackStub's register argument as well. // Add CallApiCallbackStub's register argument as well.
Node* context = jsgraph()->Constant(js_heap_broker(), native_context()); Node* context = jsgraph()->Constant(native_context());
Node* inputs[10] = {code, context, data, holder, function_reference, Node* inputs[10] = {code, context, data, holder, function_reference,
receiver}; receiver};
int index = 6 + argc; int index = 6 + argc;
...@@ -1913,7 +1913,7 @@ JSNativeContextSpecialization::BuildPropertyStore( ...@@ -1913,7 +1913,7 @@ JSNativeContextSpecialization::BuildPropertyStore(
!FLAG_unbox_double_fields) { !FLAG_unbox_double_fields) {
if (access_info.HasTransitionMap()) { if (access_info.HasTransitionMap()) {
// Allocate a MutableHeapNumber for the new property. // Allocate a MutableHeapNumber for the new property.
AllocationBuilder a(jsgraph(), js_heap_broker(), effect, control); AllocationBuilder a(jsgraph(), effect, control);
a.Allocate(HeapNumber::kSize, NOT_TENURED, Type::OtherInternal()); a.Allocate(HeapNumber::kSize, NOT_TENURED, Type::OtherInternal());
a.Store(AccessBuilder::ForMap(), a.Store(AccessBuilder::ForMap(),
factory()->mutable_heap_number_map()); factory()->mutable_heap_number_map());
...@@ -2768,7 +2768,7 @@ Node* JSNativeContextSpecialization::BuildExtendPropertiesBackingStore( ...@@ -2768,7 +2768,7 @@ Node* JSNativeContextSpecialization::BuildExtendPropertiesBackingStore(
new_length_and_hash, effect, control); new_length_and_hash, effect, control);
// Allocate and initialize the new properties. // Allocate and initialize the new properties.
AllocationBuilder a(jsgraph(), js_heap_broker(), effect, control); AllocationBuilder a(jsgraph(), effect, control);
a.Allocate(PropertyArray::SizeFor(new_length), NOT_TENURED, a.Allocate(PropertyArray::SizeFor(new_length), NOT_TENURED,
Type::OtherInternal()); Type::OtherInternal());
a.Store(AccessBuilder::ForMap(), jsgraph()->PropertyArrayMapConstant()); a.Store(AccessBuilder::ForMap(), jsgraph()->PropertyArrayMapConstant());
......
...@@ -93,12 +93,13 @@ class JSBinopReduction final { ...@@ -93,12 +93,13 @@ class JSBinopReduction final {
if (BothInputsAre(Type::String()) || if (BothInputsAre(Type::String()) ||
BinaryOperationHintOf(node_->op()) == BinaryOperationHint::kString) { BinaryOperationHintOf(node_->op()) == BinaryOperationHint::kString) {
HeapObjectBinopMatcher m(node_); HeapObjectBinopMatcher m(node_);
if (m.right().HasValue() && m.right().Ref().IsString()) { const JSHeapBroker* broker = lowering_->js_heap_broker();
StringRef right_string(m.right().Value()); 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; if (right_string.length() >= ConsString::kMinLength) return true;
} }
if (m.left().HasValue() && m.left().Ref().IsString()) { if (m.left().HasValue() && m.left().Ref(broker).IsString()) {
StringRef left_string(m.left().Value()); StringRef left_string = m.left().Ref(broker).AsString();
if (left_string.length() >= ConsString::kMinLength) { if (left_string.length() >= ConsString::kMinLength) {
// The invariant for ConsString requires the left hand side to be // The invariant for ConsString requires the left hand side to be
// a sequential or external string if the right hand side is the // a sequential or external string if the right hand side is the
...@@ -718,11 +719,11 @@ Node* JSTypedLowering::BuildGetStringLength(Node* value) { ...@@ -718,11 +719,11 @@ Node* JSTypedLowering::BuildGetStringLength(Node* value) {
// TODO(bmeurer): Get rid of this hack and instead have a way to // TODO(bmeurer): Get rid of this hack and instead have a way to
// express the string length in the types. // express the string length in the types.
HeapObjectMatcher m(value); HeapObjectMatcher m(value);
if (!m.HasValue() || !m.Ref().IsString()) { if (!m.HasValue() || !m.Ref(js_heap_broker()).IsString()) {
return graph()->NewNode(simplified()->StringLength(), value); return graph()->NewNode(simplified()->StringLength(), value);
} }
return jsgraph()->Constant(m.Ref().AsString().length()); return jsgraph()->Constant(m.Ref(js_heap_broker()).AsString().length());
} }
Reduction JSTypedLowering::ReduceSpeculativeNumberComparison(Node* node) { Reduction JSTypedLowering::ReduceSpeculativeNumberComparison(Node* node) {
...@@ -959,17 +960,15 @@ Reduction JSTypedLowering::ReduceJSToNumberOrNumericInput(Node* input) { ...@@ -959,17 +960,15 @@ Reduction JSTypedLowering::ReduceJSToNumberOrNumericInput(Node* input) {
if (input_type.Is(Type::String())) { if (input_type.Is(Type::String())) {
HeapObjectMatcher m(input); HeapObjectMatcher m(input);
if (m.HasValue() && m.Ref().IsString()) { if (m.HasValue() && m.Ref(js_heap_broker()).IsString()) {
StringRef input_value = m.Ref().AsString(); StringRef input_value = m.Ref(js_heap_broker()).AsString();
return Replace( return Replace(jsgraph()->Constant(input_value.ToNumber()));
jsgraph()->Constant(input_value.ToNumber(js_heap_broker())));
} }
} }
if (input_type.IsHeapConstant()) { if (input_type.IsHeapConstant()) {
ObjectRef input_value = input_type.AsHeapConstant()->Ref(); ObjectRef input_value = input_type.AsHeapConstant()->Ref();
if (input_value.oddball_type(js_heap_broker()) != OddballType::kNone) { if (input_value.oddball_type() != OddballType::kNone) {
return Replace( return Replace(jsgraph()->Constant(input_value.OddballToNumber()));
jsgraph()->Constant(input_value.OddballToNumber(js_heap_broker())));
} }
} }
if (input_type.Is(Type::Number())) { if (input_type.Is(Type::Number())) {
...@@ -1135,8 +1134,8 @@ Reduction JSTypedLowering::ReduceJSLoadNamed(Node* node) { ...@@ -1135,8 +1134,8 @@ Reduction JSTypedLowering::ReduceJSLoadNamed(Node* node) {
DCHECK_EQ(IrOpcode::kJSLoadNamed, node->opcode()); DCHECK_EQ(IrOpcode::kJSLoadNamed, node->opcode());
Node* receiver = NodeProperties::GetValueInput(node, 0); Node* receiver = NodeProperties::GetValueInput(node, 0);
Type receiver_type = NodeProperties::GetType(receiver); Type receiver_type = NodeProperties::GetType(receiver);
NameRef name(NamedAccessOf(node->op()).name()); NameRef name(js_heap_broker(), NamedAccessOf(node->op()).name());
NameRef length_str(factory()->length_string()); NameRef length_str(js_heap_broker(), factory()->length_string());
// Optimize "length" property of strings. // Optimize "length" property of strings.
if (name.equals(length_str) && receiver_type.Is(Type::String())) { if (name.equals(length_str) && receiver_type.Is(Type::String())) {
Node* value = graph()->NewNode(simplified()->StringLength(), receiver); Node* value = graph()->NewNode(simplified()->StringLength(), receiver);
...@@ -1371,9 +1370,8 @@ Node* JSTypedLowering::BuildGetModuleCell(Node* node) { ...@@ -1371,9 +1370,8 @@ Node* JSTypedLowering::BuildGetModuleCell(Node* node) {
if (module_type.IsHeapConstant()) { if (module_type.IsHeapConstant()) {
ModuleRef module_constant = module_type.AsHeapConstant()->Ref().AsModule(); ModuleRef module_constant = module_type.AsHeapConstant()->Ref().AsModule();
CellRef cell_constant( CellRef cell_constant(module_constant.GetCell(cell_index));
module_constant.GetCell(js_heap_broker(), cell_index)); return jsgraph()->Constant(cell_constant);
return jsgraph()->Constant(js_heap_broker(), cell_constant);
} }
FieldAccess field_access; FieldAccess field_access;
...@@ -1560,7 +1558,7 @@ Reduction JSTypedLowering::ReduceJSConstruct(Node* node) { ...@@ -1560,7 +1558,7 @@ Reduction JSTypedLowering::ReduceJSConstruct(Node* node) {
if (target_type.IsHeapConstant() && if (target_type.IsHeapConstant() &&
target_type.AsHeapConstant()->Ref().IsJSFunction()) { target_type.AsHeapConstant()->Ref().IsJSFunction()) {
JSFunctionRef function = target_type.AsHeapConstant()->Ref().AsJSFunction(); JSFunctionRef function = target_type.AsHeapConstant()->Ref().AsJSFunction();
SharedFunctionInfoRef shared = function.shared(js_heap_broker()); SharedFunctionInfoRef shared = function.shared();
// Only optimize [[Construct]] here if {function} is a Constructor. // Only optimize [[Construct]] here if {function} is a Constructor.
if (!function.IsConstructor()) return NoChange(); if (!function.IsConstructor()) return NoChange();
...@@ -1570,13 +1568,13 @@ Reduction JSTypedLowering::ReduceJSConstruct(Node* node) { ...@@ -1570,13 +1568,13 @@ 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 = shared.construct_as_builtin(); bool use_builtin_construct_stub = shared.construct_as_builtin();
CodeRef code(use_builtin_construct_stub CodeRef code(js_heap_broker(),
use_builtin_construct_stub
? BUILTIN_CODE(isolate(), JSBuiltinsConstructStub) ? BUILTIN_CODE(isolate(), JSBuiltinsConstructStub)
: BUILTIN_CODE(isolate(), JSConstructStubGeneric)); : BUILTIN_CODE(isolate(), JSConstructStubGeneric));
node->RemoveInput(arity + 1); node->RemoveInput(arity + 1);
node->InsertInput(graph()->zone(), 0, node->InsertInput(graph()->zone(), 0, jsgraph()->Constant(code));
jsgraph()->Constant(js_heap_broker(), code));
node->InsertInput(graph()->zone(), 2, new_target); node->InsertInput(graph()->zone(), 2, new_target);
node->InsertInput(graph()->zone(), 3, jsgraph()->Constant(arity)); node->InsertInput(graph()->zone(), 3, jsgraph()->Constant(arity));
node->InsertInput(graph()->zone(), 4, jsgraph()->UndefinedConstant()); node->InsertInput(graph()->zone(), 4, jsgraph()->UndefinedConstant());
...@@ -1643,7 +1641,7 @@ Reduction JSTypedLowering::ReduceJSCall(Node* node) { ...@@ -1643,7 +1641,7 @@ Reduction JSTypedLowering::ReduceJSCall(Node* node) {
if (target_type.IsHeapConstant() && if (target_type.IsHeapConstant() &&
target_type.AsHeapConstant()->Ref().IsJSFunction()) { target_type.AsHeapConstant()->Ref().IsJSFunction()) {
JSFunctionRef function = target_type.AsHeapConstant()->Ref().AsJSFunction(); JSFunctionRef function = target_type.AsHeapConstant()->Ref().AsJSFunction();
SharedFunctionInfoRef shared = function.shared(js_heap_broker()); SharedFunctionInfoRef shared = function.shared();
if (shared.HasBreakInfo()) { if (shared.HasBreakInfo()) {
// Do not inline the call if we need to check whether to break at entry. // Do not inline the call if we need to check whether to break at entry.
...@@ -1663,8 +1661,7 @@ Reduction JSTypedLowering::ReduceJSCall(Node* node) { ...@@ -1663,8 +1661,7 @@ Reduction JSTypedLowering::ReduceJSCall(Node* node) {
// Check if we need to convert the {receiver}. // Check if we need to convert the {receiver}.
if (is_sloppy(shared.language_mode()) && !shared.native() && if (is_sloppy(shared.language_mode()) && !shared.native() &&
!receiver_type.Is(Type::Receiver())) { !receiver_type.Is(Type::Receiver())) {
Node* global_proxy = jsgraph()->Constant( Node* global_proxy = jsgraph()->Constant(function.global_proxy());
js_heap_broker(), function.global_proxy(js_heap_broker()));
receiver = effect = receiver = effect =
graph()->NewNode(simplified()->ConvertReceiver(convert_mode), graph()->NewNode(simplified()->ConvertReceiver(convert_mode),
receiver, global_proxy, effect, control); receiver, global_proxy, effect, control);
......
...@@ -18,6 +18,8 @@ namespace v8 { ...@@ -18,6 +18,8 @@ namespace v8 {
namespace internal { namespace internal {
namespace compiler { namespace compiler {
class JSHeapBroker;
// A pattern matcher for nodes. // A pattern matcher for nodes.
struct NodeMatcher { struct NodeMatcher {
explicit NodeMatcher(Node* node) : node_(node) {} explicit NodeMatcher(Node* node) : node_(node) {}
...@@ -193,7 +195,9 @@ struct HeapObjectMatcher final ...@@ -193,7 +195,9 @@ struct HeapObjectMatcher final
return this->HasValue() && this->Value().address() == value.address(); return this->HasValue() && this->Value().address() == value.address();
} }
ObjectRef Ref() const { return ObjectRef(this->Value()); } ObjectRef Ref(const JSHeapBroker* broker) const {
return ObjectRef(broker, this->Value());
}
}; };
......
...@@ -62,8 +62,7 @@ Reduction SimplifiedOperatorReducer::Reduce(Node* node) { ...@@ -62,8 +62,7 @@ Reduction SimplifiedOperatorReducer::Reduce(Node* node) {
case IrOpcode::kChangeTaggedToBit: { case IrOpcode::kChangeTaggedToBit: {
HeapObjectMatcher m(node->InputAt(0)); HeapObjectMatcher m(node->InputAt(0));
if (m.HasValue()) { if (m.HasValue()) {
HeapObjectRef object(m.Value()); return ReplaceInt32(m.Ref(js_heap_broker()).BooleanValue());
return ReplaceInt32(object.BooleanValue(js_heap_broker()));
} }
if (m.IsChangeBitToTagged()) return Replace(m.InputAt(0)); if (m.IsChangeBitToTagged()) return Replace(m.InputAt(0));
break; break;
......
...@@ -93,7 +93,7 @@ base::Optional<MapRef> GetStableMapFromObjectType( ...@@ -93,7 +93,7 @@ base::Optional<MapRef> GetStableMapFromObjectType(
const JSHeapBroker* js_heap_broker, Type object_type) { const JSHeapBroker* js_heap_broker, Type object_type) {
if (object_type.IsHeapConstant()) { if (object_type.IsHeapConstant()) {
HeapObjectRef object = object_type.AsHeapConstant()->Ref(); HeapObjectRef object = object_type.AsHeapConstant()->Ref();
MapRef object_map = object.map(js_heap_broker); MapRef object_map = object.map();
if (object_map.is_stable()) return object_map; if (object_map.is_stable()) return object_map;
} }
return {}; return {};
...@@ -153,7 +153,7 @@ Reduction TypedOptimization::ReduceCheckMaps(Node* node) { ...@@ -153,7 +153,7 @@ Reduction TypedOptimization::ReduceCheckMaps(Node* node) {
if (map_type.IsHeapConstant() && if (map_type.IsHeapConstant() &&
map_type.AsHeapConstant()->Ref().equals(*object_map)) { map_type.AsHeapConstant()->Ref().equals(*object_map)) {
if (object_map->CanTransition()) { if (object_map->CanTransition()) {
object_map->DependOnStableMap(js_heap_broker(), dependencies()); object_map->DependOnStableMap(dependencies());
} }
return Replace(effect); return Replace(effect);
} }
...@@ -219,9 +219,9 @@ Reduction TypedOptimization::ReduceLoadField(Node* node) { ...@@ -219,9 +219,9 @@ Reduction TypedOptimization::ReduceLoadField(Node* node) {
GetStableMapFromObjectType(js_heap_broker(), object_type); GetStableMapFromObjectType(js_heap_broker(), object_type);
if (object_map.has_value()) { if (object_map.has_value()) {
if (object_map->CanTransition()) { if (object_map->CanTransition()) {
object_map->DependOnStableMap(js_heap_broker(), dependencies()); object_map->DependOnStableMap(dependencies());
} }
Node* const value = jsgraph()->Constant(js_heap_broker(), *object_map); Node* const value = jsgraph()->Constant(*object_map);
ReplaceWithValue(node, value); ReplaceWithValue(node, value);
return Replace(value); return Replace(value);
} }
...@@ -558,32 +558,30 @@ Reduction TypedOptimization::ReduceTypeOf(Node* node) { ...@@ -558,32 +558,30 @@ Reduction TypedOptimization::ReduceTypeOf(Node* node) {
Factory* const f = factory(); Factory* const f = factory();
if (type.Is(Type::Boolean())) { if (type.Is(Type::Boolean())) {
return Replace( return Replace(
jsgraph()->Constant(js_heap_broker(), ObjectRef(f->boolean_string()))); jsgraph()->Constant(ObjectRef(js_heap_broker(), f->boolean_string())));
} else if (type.Is(Type::Number())) { } else if (type.Is(Type::Number())) {
return Replace( return Replace(
jsgraph()->Constant(js_heap_broker(), ObjectRef(f->number_string()))); jsgraph()->Constant(ObjectRef(js_heap_broker(), f->number_string())));
} else if (type.Is(Type::String())) { } else if (type.Is(Type::String())) {
return Replace( return Replace(
jsgraph()->Constant(js_heap_broker(), ObjectRef(f->string_string()))); jsgraph()->Constant(ObjectRef(js_heap_broker(), f->string_string())));
} else if (type.Is(Type::BigInt())) { } else if (type.Is(Type::BigInt())) {
return Replace( return Replace(
jsgraph()->Constant(js_heap_broker(), ObjectRef(f->bigint_string()))); jsgraph()->Constant(ObjectRef(js_heap_broker(), f->bigint_string())));
} else if (type.Is(Type::Symbol())) { } else if (type.Is(Type::Symbol())) {
return Replace( return Replace(
jsgraph()->Constant(js_heap_broker(), ObjectRef(f->symbol_string()))); jsgraph()->Constant(ObjectRef(js_heap_broker(), f->symbol_string())));
} else if (type.Is(Type::OtherUndetectableOrUndefined())) { } else if (type.Is(Type::OtherUndetectableOrUndefined())) {
return Replace(jsgraph()->Constant(js_heap_broker(), return Replace(jsgraph()->Constant(
ObjectRef(f->undefined_string()))); ObjectRef(js_heap_broker(), f->undefined_string())));
} else if (type.Is(Type::NonCallableOrNull())) { } else if (type.Is(Type::NonCallableOrNull())) {
return Replace( return Replace(
jsgraph()->Constant(js_heap_broker(), ObjectRef(f->object_string()))); jsgraph()->Constant(ObjectRef(js_heap_broker(), f->object_string())));
} else if (type.Is(Type::Function())) { } else if (type.Is(Type::Function())) {
return Replace( return Replace(
jsgraph()->Constant(js_heap_broker(), ObjectRef(f->function_string()))); jsgraph()->Constant(ObjectRef(js_heap_broker(), f->function_string())));
} else if (type.IsHeapConstant()) { } else if (type.IsHeapConstant()) {
return Replace(jsgraph()->Constant( return Replace(jsgraph()->Constant(type.AsHeapConstant()->Ref().TypeOf()));
js_heap_broker(),
type.AsHeapConstant()->Ref().TypeOf(js_heap_broker())));
} }
return NoChange(); return NoChange();
} }
......
...@@ -827,7 +827,7 @@ Type Type::NewConstant(const JSHeapBroker* js_heap_broker, ...@@ -827,7 +827,7 @@ Type Type::NewConstant(const JSHeapBroker* js_heap_broker,
return NewConstant(static_cast<double>(maybe_smi.value()), zone); return NewConstant(static_cast<double>(maybe_smi.value()), zone);
} }
HeapObjectRef heap_ref(value); HeapObjectRef heap_ref(js_heap_broker, value);
if (heap_ref.IsHeapNumber()) { if (heap_ref.IsHeapNumber()) {
return NewConstant(heap_ref.AsHeapNumber().value(), zone); return NewConstant(heap_ref.AsHeapNumber().value(), zone);
} }
...@@ -1064,7 +1064,7 @@ Type Type::OtherNumberConstant(double value, Zone* zone) { ...@@ -1064,7 +1064,7 @@ Type Type::OtherNumberConstant(double value, Zone* zone) {
Type Type::HeapConstant(const JSHeapBroker* js_heap_broker, Type Type::HeapConstant(const JSHeapBroker* js_heap_broker,
Handle<i::Object> value, Zone* zone) { Handle<i::Object> value, Zone* zone) {
return FromTypeBase( return FromTypeBase(
HeapConstantType::New(js_heap_broker, HeapObjectRef(value), zone)); HeapConstantType::New(HeapObjectRef(js_heap_broker, value), zone));
} }
// static // static
......
...@@ -541,11 +541,10 @@ class V8_EXPORT_PRIVATE HeapConstantType : public NON_EXPORTED_BASE(TypeBase) { ...@@ -541,11 +541,10 @@ class V8_EXPORT_PRIVATE HeapConstantType : public NON_EXPORTED_BASE(TypeBase) {
friend class Type; friend class Type;
friend class BitsetType; friend class BitsetType;
static HeapConstantType* New(const JSHeapBroker* broker, static HeapConstantType* New(const HeapObjectRef& heap_ref, Zone* zone) {
const HeapObjectRef& heap_ref, Zone* zone) {
DCHECK(!heap_ref.IsHeapNumber()); DCHECK(!heap_ref.IsHeapNumber());
DCHECK_IMPLIES(heap_ref.IsString(), heap_ref.IsInternalizedString()); DCHECK_IMPLIES(heap_ref.IsString(), heap_ref.IsInternalizedString());
BitsetType::bitset bitset = BitsetType::Lub(heap_ref.type(broker)); BitsetType::bitset bitset = BitsetType::Lub(heap_ref.type());
return new (zone->New(sizeof(HeapConstantType))) return new (zone->New(sizeof(HeapConstantType)))
HeapConstantType(bitset, heap_ref); HeapConstantType(bitset, heap_ref);
} }
......
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