Commit 6e65e6db authored by mstarzinger's avatar mstarzinger Committed by Commit bot

[turbofan] Remove usage of Unique<T> from graph.

The usage of Unique<T> throughout the TurboFan IR does not have any
advantage. There is no single point in time when they are initialized
and most use-sites looked through to the underlying Handle<T> anyways.
Also there already was a mixture of Handle<T> versus Unique<T> in the
graph and this unifies the situation to use Handle<T> everywhere.

R=bmeurer@chromium.org,titzer@chromium.org

Review URL: https://codereview.chromium.org/1314473007

Cr-Commit-Position: refs/heads/master@{#30458}
parent f4f3b431
...@@ -1420,7 +1420,7 @@ void AstGraphBuilder::VisitTryCatchStatement(TryCatchStatement* stmt) { ...@@ -1420,7 +1420,7 @@ void AstGraphBuilder::VisitTryCatchStatement(TryCatchStatement* stmt) {
// Create a catch scope that binds the exception. // Create a catch scope that binds the exception.
Node* exception = try_control.GetExceptionNode(); Node* exception = try_control.GetExceptionNode();
Unique<String> name = MakeUnique(stmt->variable()->name()); Handle<String> name = stmt->variable()->name();
const Operator* op = javascript()->CreateCatchContext(name); const Operator* op = javascript()->CreateCatchContext(name);
Node* context = NewNode(op, exception, GetFunctionClosureForContext()); Node* context = NewNode(op, exception, GetFunctionClosureForContext());
...@@ -3617,8 +3617,7 @@ Node* AstGraphBuilder::BuildKeyedLoad(Node* object, Node* key, ...@@ -3617,8 +3617,7 @@ Node* AstGraphBuilder::BuildKeyedLoad(Node* object, Node* key,
Node* AstGraphBuilder::BuildNamedLoad(Node* object, Handle<Name> name, Node* AstGraphBuilder::BuildNamedLoad(Node* object, Handle<Name> name,
const VectorSlotPair& feedback) { const VectorSlotPair& feedback) {
const Operator* op = const Operator* op = javascript()->LoadNamed(name, feedback, language_mode());
javascript()->LoadNamed(MakeUnique(name), feedback, language_mode());
Node* node = NewNode(op, object, BuildLoadFeedbackVector()); Node* node = NewNode(op, object, BuildLoadFeedbackVector());
return Record(js_type_feedback_, node, feedback.slot()); return Record(js_type_feedback_, node, feedback.slot());
} }
...@@ -3641,7 +3640,7 @@ Node* AstGraphBuilder::BuildNamedStore(Node* object, Handle<Name> name, ...@@ -3641,7 +3640,7 @@ Node* AstGraphBuilder::BuildNamedStore(Node* object, Handle<Name> name,
const VectorSlotPair& feedback, const VectorSlotPair& feedback,
TypeFeedbackId id) { TypeFeedbackId id) {
const Operator* op = const Operator* op =
javascript()->StoreNamed(language_mode(), MakeUnique(name), feedback); javascript()->StoreNamed(language_mode(), name, feedback);
Node* node = NewNode(op, object, value, BuildLoadFeedbackVector()); Node* node = NewNode(op, object, value, BuildLoadFeedbackVector());
if (FLAG_vector_stores) { if (FLAG_vector_stores) {
return Record(js_type_feedback_, node, feedback.slot()); return Record(js_type_feedback_, node, feedback.slot());
...@@ -3701,8 +3700,8 @@ Node* AstGraphBuilder::BuildGlobalLoad(Node* script_context, Node* global, ...@@ -3701,8 +3700,8 @@ Node* AstGraphBuilder::BuildGlobalLoad(Node* script_context, Node* global,
Handle<Name> name, Handle<Name> name,
const VectorSlotPair& feedback, const VectorSlotPair& feedback,
TypeofMode typeof_mode, int slot_index) { TypeofMode typeof_mode, int slot_index) {
const Operator* op = javascript()->LoadGlobal(MakeUnique(name), feedback, const Operator* op =
typeof_mode, slot_index); javascript()->LoadGlobal(name, feedback, typeof_mode, slot_index);
Node* node = NewNode(op, script_context, global, BuildLoadFeedbackVector()); Node* node = NewNode(op, script_context, global, BuildLoadFeedbackVector());
return Record(js_type_feedback_, node, feedback.slot()); return Record(js_type_feedback_, node, feedback.slot());
} }
...@@ -3712,8 +3711,8 @@ Node* AstGraphBuilder::BuildGlobalStore(Node* script_context, Node* global, ...@@ -3712,8 +3711,8 @@ Node* AstGraphBuilder::BuildGlobalStore(Node* script_context, Node* global,
Handle<Name> name, Node* value, Handle<Name> name, Node* value,
const VectorSlotPair& feedback, const VectorSlotPair& feedback,
TypeFeedbackId id, int slot_index) { TypeFeedbackId id, int slot_index) {
const Operator* op = javascript()->StoreGlobal( const Operator* op =
language_mode(), MakeUnique(name), feedback, slot_index); javascript()->StoreGlobal(language_mode(), name, feedback, slot_index);
Node* node = Node* node =
NewNode(op, script_context, global, value, BuildLoadFeedbackVector()); NewNode(op, script_context, global, value, BuildLoadFeedbackVector());
if (FLAG_vector_stores) { if (FLAG_vector_stores) {
...@@ -3798,7 +3797,7 @@ Node* AstGraphBuilder::BuildToBoolean(Node* input) { ...@@ -3798,7 +3797,7 @@ Node* AstGraphBuilder::BuildToBoolean(Node* input) {
return jsgraph_->BooleanConstant(!m.Is(0) && !m.IsNaN()); return jsgraph_->BooleanConstant(!m.Is(0) && !m.IsNaN());
} }
case IrOpcode::kHeapConstant: { case IrOpcode::kHeapConstant: {
Handle<HeapObject> object = HeapObjectMatcher(input).Value().handle(); Handle<HeapObject> object = HeapObjectMatcher(input).Value();
return jsgraph_->BooleanConstant(object->BooleanValue()); return jsgraph_->BooleanConstant(object->BooleanValue());
} }
case IrOpcode::kJSEqual: case IrOpcode::kJSEqual:
......
...@@ -230,12 +230,6 @@ class AstGraphBuilder : public AstVisitor { ...@@ -230,12 +230,6 @@ class AstGraphBuilder : public AstVisitor {
// frame states with the undefined values. // frame states with the undefined values.
void ClearNonLiveSlotsInFrameStates(); void ClearNonLiveSlotsInFrameStates();
// Helper to wrap a Handle<T> into a Unique<T>.
template <class T>
Unique<T> MakeUnique(Handle<T> object) {
return Unique<T>::CreateUninitialized(object);
}
Node** EnsureInputBufferSize(int size); Node** EnsureInputBufferSize(int size);
// Named and keyed loads require a VectorSlotPair for successful lowering. // Named and keyed loads require a VectorSlotPair for successful lowering.
......
...@@ -33,8 +33,7 @@ Decision DecideCondition(Node* const cond) { ...@@ -33,8 +33,7 @@ Decision DecideCondition(Node* const cond) {
} }
case IrOpcode::kHeapConstant: { case IrOpcode::kHeapConstant: {
HeapObjectMatcher mcond(cond); HeapObjectMatcher mcond(cond);
return mcond.Value().handle()->BooleanValue() ? Decision::kTrue return mcond.Value()->BooleanValue() ? Decision::kTrue : Decision::kFalse;
: Decision::kFalse;
} }
default: default:
return Decision::kUnknown; return Decision::kUnknown;
......
...@@ -575,8 +575,10 @@ const Operator* CommonOperatorBuilder::NumberConstant(volatile double value) { ...@@ -575,8 +575,10 @@ const Operator* CommonOperatorBuilder::NumberConstant(volatile double value) {
const Operator* CommonOperatorBuilder::HeapConstant( const Operator* CommonOperatorBuilder::HeapConstant(
const Unique<HeapObject>& value) { const Handle<HeapObject>& value) {
return new (zone()) Operator1<Unique<HeapObject>>( // -- return new (zone())
Operator1<Handle<HeapObject>, Handle<HeapObject>::equal_to,
Handle<HeapObject>::hash>( // --
IrOpcode::kHeapConstant, Operator::kPure, // opcode IrOpcode::kHeapConstant, Operator::kPure, // opcode
"HeapConstant", // name "HeapConstant", // name
0, 0, 0, 1, 0, 0, // counts 0, 0, 0, 1, 0, 0, // counts
......
...@@ -139,7 +139,7 @@ class CommonOperatorBuilder final : public ZoneObject { ...@@ -139,7 +139,7 @@ class CommonOperatorBuilder final : public ZoneObject {
const Operator* Float64Constant(volatile double); const Operator* Float64Constant(volatile double);
const Operator* ExternalConstant(const ExternalReference&); const Operator* ExternalConstant(const ExternalReference&);
const Operator* NumberConstant(volatile double); const Operator* NumberConstant(volatile double);
const Operator* HeapConstant(const Unique<HeapObject>&); const Operator* HeapConstant(const Handle<HeapObject>&);
const Operator* Select(MachineType, BranchHint = BranchHint::kNone); const Operator* Select(MachineType, BranchHint = BranchHint::kNone);
const Operator* Phi(MachineType type, int value_input_count); const Operator* Phi(MachineType type, int value_input_count);
......
...@@ -36,9 +36,9 @@ class IA32OperandGenerator final : public OperandGenerator { ...@@ -36,9 +36,9 @@ class IA32OperandGenerator final : public OperandGenerator {
case IrOpcode::kHeapConstant: { case IrOpcode::kHeapConstant: {
// Constants in new space cannot be used as immediates in V8 because // Constants in new space cannot be used as immediates in V8 because
// the GC does not scan code objects when collecting the new generation. // the GC does not scan code objects when collecting the new generation.
Unique<HeapObject> value = OpParameter<Unique<HeapObject> >(node); Handle<HeapObject> value = OpParameter<Handle<HeapObject>>(node);
Isolate* isolate = value.handle()->GetIsolate(); Isolate* isolate = value->GetIsolate();
return !isolate->heap()->InNewSpace(*value.handle()); return !isolate->heap()->InNewSpace(*value);
} }
default: default:
return false; return false;
......
...@@ -183,7 +183,7 @@ class OperandGenerator { ...@@ -183,7 +183,7 @@ class OperandGenerator {
case IrOpcode::kExternalConstant: case IrOpcode::kExternalConstant:
return Constant(OpParameter<ExternalReference>(node)); return Constant(OpParameter<ExternalReference>(node));
case IrOpcode::kHeapConstant: case IrOpcode::kHeapConstant:
return Constant(OpParameter<Unique<HeapObject> >(node).handle()); return Constant(OpParameter<Handle<HeapObject>>(node));
default: default:
break; break;
} }
......
...@@ -176,7 +176,7 @@ Node* InterpreterAssembler::NumberConstant(double value) { ...@@ -176,7 +176,7 @@ Node* InterpreterAssembler::NumberConstant(double value) {
} }
Node* InterpreterAssembler::HeapConstant(Unique<HeapObject> object) { Node* InterpreterAssembler::HeapConstant(Handle<HeapObject> object) {
return raw_assembler_->HeapConstant(object); return raw_assembler_->HeapConstant(object);
} }
...@@ -258,8 +258,7 @@ Node* InterpreterAssembler::CallJSBuiltin(int context_index, Node* receiver, ...@@ -258,8 +258,7 @@ Node* InterpreterAssembler::CallJSBuiltin(int context_index, Node* receiver,
void InterpreterAssembler::Return() { void InterpreterAssembler::Return() {
Node* exit_trampoline_code_object = Node* exit_trampoline_code_object =
HeapConstant(Unique<HeapObject>::CreateImmovable( HeapConstant(isolate()->builtins()->InterpreterExitTrampoline());
isolate()->builtins()->InterpreterExitTrampoline()));
// If the order of the parameters you need to change the call signature below. // If the order of the parameters you need to change the call signature below.
STATIC_ASSERT(0 == Linkage::kInterpreterAccumulatorParameter); STATIC_ASSERT(0 == Linkage::kInterpreterAccumulatorParameter);
STATIC_ASSERT(1 == Linkage::kInterpreterRegisterFileParameter); STATIC_ASSERT(1 == Linkage::kInterpreterRegisterFileParameter);
......
...@@ -59,7 +59,7 @@ class InterpreterAssembler { ...@@ -59,7 +59,7 @@ class InterpreterAssembler {
Node* Int32Constant(int value); Node* Int32Constant(int value);
Node* IntPtrConstant(intptr_t value); Node* IntPtrConstant(intptr_t value);
Node* NumberConstant(double value); Node* NumberConstant(double value);
Node* HeapConstant(Unique<HeapObject> object); Node* HeapConstant(Handle<HeapObject> object);
// Tag and untag Smi values. // Tag and untag Smi values.
Node* SmiTag(Node* value); Node* SmiTag(Node* value);
......
...@@ -25,8 +25,8 @@ class JSCallReduction { ...@@ -25,8 +25,8 @@ class JSCallReduction {
bool HasBuiltinFunctionId() { bool HasBuiltinFunctionId() {
if (node_->opcode() != IrOpcode::kJSCallFunction) return false; if (node_->opcode() != IrOpcode::kJSCallFunction) return false;
HeapObjectMatcher m(NodeProperties::GetValueInput(node_, 0)); HeapObjectMatcher m(NodeProperties::GetValueInput(node_, 0));
if (!m.HasValue() || !m.Value().handle()->IsJSFunction()) return false; if (!m.HasValue() || !m.Value()->IsJSFunction()) return false;
Handle<JSFunction> function = Handle<JSFunction>::cast(m.Value().handle()); Handle<JSFunction> function = Handle<JSFunction>::cast(m.Value());
return function->shared()->HasBuiltinFunctionId(); return function->shared()->HasBuiltinFunctionId();
} }
...@@ -34,7 +34,7 @@ class JSCallReduction { ...@@ -34,7 +34,7 @@ class JSCallReduction {
BuiltinFunctionId GetBuiltinFunctionId() { BuiltinFunctionId GetBuiltinFunctionId() {
DCHECK_EQ(IrOpcode::kJSCallFunction, node_->opcode()); DCHECK_EQ(IrOpcode::kJSCallFunction, node_->opcode());
HeapObjectMatcher m(NodeProperties::GetValueInput(node_, 0)); HeapObjectMatcher m(NodeProperties::GetValueInput(node_, 0));
Handle<JSFunction> function = Handle<JSFunction>::cast(m.Value().handle()); Handle<JSFunction> function = Handle<JSFunction>::cast(m.Value());
return function->shared()->builtin_function_id(); return function->shared()->builtin_function_id();
} }
......
...@@ -35,8 +35,7 @@ MaybeHandle<Context> JSContextSpecialization::GetSpecializationContext( ...@@ -35,8 +35,7 @@ MaybeHandle<Context> JSContextSpecialization::GetSpecializationContext(
Node* const object = NodeProperties::GetValueInput(node, 0); Node* const object = NodeProperties::GetValueInput(node, 0);
switch (object->opcode()) { switch (object->opcode()) {
case IrOpcode::kHeapConstant: case IrOpcode::kHeapConstant:
return Handle<Context>::cast( return Handle<Context>::cast(OpParameter<Handle<HeapObject>>(object));
OpParameter<Unique<HeapObject>>(object).handle());
case IrOpcode::kParameter: { case IrOpcode::kParameter: {
Node* const start = NodeProperties::GetValueInput(object, 0); Node* const start = NodeProperties::GetValueInput(object, 0);
DCHECK_EQ(IrOpcode::kStart, start->opcode()); DCHECK_EQ(IrOpcode::kStart, start->opcode());
......
...@@ -535,7 +535,7 @@ void JSGenericLowering::LowerJSCreateLiteralObject(Node* node) { ...@@ -535,7 +535,7 @@ void JSGenericLowering::LowerJSCreateLiteralObject(Node* node) {
void JSGenericLowering::LowerJSCreateCatchContext(Node* node) { void JSGenericLowering::LowerJSCreateCatchContext(Node* node) {
Unique<String> name = OpParameter<Unique<String>>(node); Handle<String> name = OpParameter<Handle<String>>(node);
node->InsertInput(zone(), 0, jsgraph()->HeapConstant(name)); node->InsertInput(zone(), 0, jsgraph()->HeapConstant(name));
ReplaceWithRuntimeCall(node, Runtime::kPushCatchContext); ReplaceWithRuntimeCall(node, Runtime::kPushCatchContext);
} }
......
...@@ -12,8 +12,7 @@ namespace internal { ...@@ -12,8 +12,7 @@ namespace internal {
namespace compiler { namespace compiler {
Node* JSGraph::ImmovableHeapConstant(Handle<HeapObject> object) { Node* JSGraph::ImmovableHeapConstant(Handle<HeapObject> object) {
Unique<HeapObject> unique = Unique<HeapObject>::CreateImmovable(object); return graph()->NewNode(common()->HeapConstant(object));
return graph()->NewNode(common()->HeapConstant(unique));
} }
...@@ -74,23 +73,12 @@ Node* JSGraph::NaNConstant() { ...@@ -74,23 +73,12 @@ Node* JSGraph::NaNConstant() {
} }
Node* JSGraph::HeapConstant(Unique<HeapObject> value) {
// TODO(turbofan): canonicalize heap constants using Unique<T>
return graph()->NewNode(common()->HeapConstant(value));
}
Node* JSGraph::HeapConstant(Handle<HeapObject> value) { Node* JSGraph::HeapConstant(Handle<HeapObject> value) {
// TODO(turbofan): canonicalize heap constants using <magic approach>.
// TODO(titzer): We could also match against the addresses of immortable // TODO(titzer): We could also match against the addresses of immortable
// immovables here, even without access to the heap, thus always // immovables here, even without access to the heap, thus always
// canonicalizing references to them. // canonicalizing references to them.
// return HeapConstant(Unique<Object>::CreateUninitialized(value)); return graph()->NewNode(common()->HeapConstant(value));
// TODO(turbofan): This is a work-around to make Unique::HashCode() work for
// value numbering. We need some sane way to compute a unique hash code for
// arbitrary handles here.
Unique<HeapObject> unique(reinterpret_cast<Address>(*value.location()),
value);
return HeapConstant(unique);
} }
......
...@@ -45,10 +45,6 @@ class JSGraph : public ZoneObject { ...@@ -45,10 +45,6 @@ class JSGraph : public ZoneObject {
Node* OneConstant(); Node* OneConstant();
Node* NaNConstant(); Node* NaNConstant();
// Creates a HeapConstant node, possibly canonicalized, without inspecting the
// object.
Node* HeapConstant(Unique<HeapObject> value);
// Creates a HeapConstant node, possibly canonicalized, and may access the // Creates a HeapConstant node, possibly canonicalized, and may access the
// heap to inspect the object. // heap to inspect the object.
Node* HeapConstant(Handle<HeapObject> value); Node* HeapConstant(Handle<HeapObject> value);
......
...@@ -243,9 +243,8 @@ Reduction JSInliner::Reduce(Node* node) { ...@@ -243,9 +243,8 @@ Reduction JSInliner::Reduce(Node* node) {
HeapObjectMatcher match(call.jsfunction()); HeapObjectMatcher match(call.jsfunction());
if (!match.HasValue()) return NoChange(); if (!match.HasValue()) return NoChange();
if (!match.Value().handle()->IsJSFunction()) return NoChange(); if (!match.Value()->IsJSFunction()) return NoChange();
Handle<JSFunction> function = Handle<JSFunction> function = Handle<JSFunction>::cast(match.Value());
Handle<JSFunction>::cast(match.Value().handle());
if (mode_ == kRestrictedInlining && !function->shared()->force_inline()) { if (mode_ == kRestrictedInlining && !function->shared()->force_inline()) {
return NoChange(); return NoChange();
} }
......
...@@ -177,11 +177,11 @@ Reduction JSIntrinsicLowering::ReduceHeapObjectGetMap(Node* node) { ...@@ -177,11 +177,11 @@ Reduction JSIntrinsicLowering::ReduceHeapObjectGetMap(Node* node) {
Reduction JSIntrinsicLowering::ReduceIncrementStatsCounter(Node* node) { Reduction JSIntrinsicLowering::ReduceIncrementStatsCounter(Node* node) {
if (!FLAG_native_code_counters) return ChangeToUndefined(node); if (!FLAG_native_code_counters) return ChangeToUndefined(node);
HeapObjectMatcher m(NodeProperties::GetValueInput(node, 0)); HeapObjectMatcher m(NodeProperties::GetValueInput(node, 0));
if (!m.HasValue() || !m.Value().handle()->IsString()) { if (!m.HasValue() || !m.Value()->IsString()) {
return ChangeToUndefined(node); return ChangeToUndefined(node);
} }
base::SmartArrayPointer<char> name = base::SmartArrayPointer<char> name =
Handle<String>::cast(m.Value().handle())->ToCString(); Handle<String>::cast(m.Value())->ToCString();
StatsCounter counter(jsgraph()->isolate(), name.get()); StatsCounter counter(jsgraph()->isolate(), name.get());
if (!counter.Enabled()) return ChangeToUndefined(node); if (!counter.Enabled()) return ChangeToUndefined(node);
......
...@@ -196,7 +196,7 @@ DynamicContextAccess const& DynamicContextAccessOf(Operator const* op) { ...@@ -196,7 +196,7 @@ DynamicContextAccess const& DynamicContextAccessOf(Operator const* op) {
bool operator==(LoadNamedParameters const& lhs, bool operator==(LoadNamedParameters const& lhs,
LoadNamedParameters const& rhs) { LoadNamedParameters const& rhs) {
return lhs.name() == rhs.name() && return lhs.name().location() == rhs.name().location() &&
lhs.language_mode() == rhs.language_mode() && lhs.language_mode() == rhs.language_mode() &&
lhs.feedback() == rhs.feedback(); lhs.feedback() == rhs.feedback();
} }
...@@ -209,12 +209,13 @@ bool operator!=(LoadNamedParameters const& lhs, ...@@ -209,12 +209,13 @@ bool operator!=(LoadNamedParameters const& lhs,
size_t hash_value(LoadNamedParameters const& p) { size_t hash_value(LoadNamedParameters const& p) {
return base::hash_combine(p.name(), p.language_mode(), p.feedback()); return base::hash_combine(p.name().location(), p.language_mode(),
p.feedback());
} }
std::ostream& operator<<(std::ostream& os, LoadNamedParameters const& p) { std::ostream& operator<<(std::ostream& os, LoadNamedParameters const& p) {
return os << Brief(*p.name().handle()) << ", " << p.language_mode(); return os << Brief(*p.name()) << ", " << p.language_mode();
} }
...@@ -255,7 +256,8 @@ const LoadNamedParameters& LoadNamedParametersOf(const Operator* op) { ...@@ -255,7 +256,8 @@ const LoadNamedParameters& LoadNamedParametersOf(const Operator* op) {
bool operator==(LoadGlobalParameters const& lhs, bool operator==(LoadGlobalParameters const& lhs,
LoadGlobalParameters const& rhs) { LoadGlobalParameters const& rhs) {
return lhs.name() == rhs.name() && lhs.feedback() == rhs.feedback() && return lhs.name().location() == rhs.name().location() &&
lhs.feedback() == rhs.feedback() &&
lhs.typeof_mode() == rhs.typeof_mode() && lhs.typeof_mode() == rhs.typeof_mode() &&
lhs.slot_index() == rhs.slot_index(); lhs.slot_index() == rhs.slot_index();
} }
...@@ -268,12 +270,13 @@ bool operator!=(LoadGlobalParameters const& lhs, ...@@ -268,12 +270,13 @@ bool operator!=(LoadGlobalParameters const& lhs,
size_t hash_value(LoadGlobalParameters const& p) { size_t hash_value(LoadGlobalParameters const& p) {
return base::hash_combine(p.name(), p.typeof_mode(), p.slot_index()); return base::hash_combine(p.name().location(), p.typeof_mode(),
p.slot_index());
} }
std::ostream& operator<<(std::ostream& os, LoadGlobalParameters const& p) { std::ostream& operator<<(std::ostream& os, LoadGlobalParameters const& p) {
return os << Brief(*p.name().handle()) << ", " << p.typeof_mode() return os << Brief(*p.name()) << ", " << p.typeof_mode()
<< ", slot: " << p.slot_index(); << ", slot: " << p.slot_index();
} }
...@@ -287,7 +290,8 @@ const LoadGlobalParameters& LoadGlobalParametersOf(const Operator* op) { ...@@ -287,7 +290,8 @@ const LoadGlobalParameters& LoadGlobalParametersOf(const Operator* op) {
bool operator==(StoreGlobalParameters const& lhs, bool operator==(StoreGlobalParameters const& lhs,
StoreGlobalParameters const& rhs) { StoreGlobalParameters const& rhs) {
return lhs.language_mode() == rhs.language_mode() && return lhs.language_mode() == rhs.language_mode() &&
lhs.name() == rhs.name() && lhs.feedback() == rhs.feedback() && lhs.name().location() == rhs.name().location() &&
lhs.feedback() == rhs.feedback() &&
lhs.slot_index() == rhs.slot_index(); lhs.slot_index() == rhs.slot_index();
} }
...@@ -299,13 +303,13 @@ bool operator!=(StoreGlobalParameters const& lhs, ...@@ -299,13 +303,13 @@ bool operator!=(StoreGlobalParameters const& lhs,
size_t hash_value(StoreGlobalParameters const& p) { size_t hash_value(StoreGlobalParameters const& p) {
return base::hash_combine(p.language_mode(), p.name(), p.feedback(), return base::hash_combine(p.language_mode(), p.name().location(),
p.slot_index()); p.feedback(), p.slot_index());
} }
std::ostream& operator<<(std::ostream& os, StoreGlobalParameters const& p) { std::ostream& operator<<(std::ostream& os, StoreGlobalParameters const& p) {
return os << p.language_mode() << ", " << Brief(*p.name().handle()) return os << p.language_mode() << ", " << Brief(*p.name())
<< ", slot: " << p.slot_index(); << ", slot: " << p.slot_index();
} }
...@@ -319,7 +323,8 @@ const StoreGlobalParameters& StoreGlobalParametersOf(const Operator* op) { ...@@ -319,7 +323,8 @@ const StoreGlobalParameters& StoreGlobalParametersOf(const Operator* op) {
bool operator==(StoreNamedParameters const& lhs, bool operator==(StoreNamedParameters const& lhs,
StoreNamedParameters const& rhs) { StoreNamedParameters const& rhs) {
return lhs.language_mode() == rhs.language_mode() && return lhs.language_mode() == rhs.language_mode() &&
lhs.name() == rhs.name() && lhs.feedback() == rhs.feedback(); lhs.name().location() == rhs.name().location() &&
lhs.feedback() == rhs.feedback();
} }
...@@ -330,12 +335,13 @@ bool operator!=(StoreNamedParameters const& lhs, ...@@ -330,12 +335,13 @@ bool operator!=(StoreNamedParameters const& lhs,
size_t hash_value(StoreNamedParameters const& p) { size_t hash_value(StoreNamedParameters const& p) {
return base::hash_combine(p.language_mode(), p.name(), p.feedback()); return base::hash_combine(p.language_mode(), p.name().location(),
p.feedback());
} }
std::ostream& operator<<(std::ostream& os, StoreNamedParameters const& p) { std::ostream& operator<<(std::ostream& os, StoreNamedParameters const& p) {
return os << p.language_mode() << ", " << Brief(*p.name().handle()); return os << p.language_mode() << ", " << Brief(*p.name());
} }
...@@ -559,7 +565,7 @@ const Operator* JSOperatorBuilder::CallConstruct(int arguments) { ...@@ -559,7 +565,7 @@ const Operator* JSOperatorBuilder::CallConstruct(int arguments) {
} }
const Operator* JSOperatorBuilder::LoadNamed(const Unique<Name>& name, const Operator* JSOperatorBuilder::LoadNamed(const Handle<Name>& name,
const VectorSlotPair& feedback, const VectorSlotPair& feedback,
LanguageMode language_mode) { LanguageMode language_mode) {
LoadNamedParameters parameters(name, feedback, language_mode); LoadNamedParameters parameters(name, feedback, language_mode);
...@@ -583,7 +589,7 @@ const Operator* JSOperatorBuilder::LoadProperty(const VectorSlotPair& feedback, ...@@ -583,7 +589,7 @@ const Operator* JSOperatorBuilder::LoadProperty(const VectorSlotPair& feedback,
const Operator* JSOperatorBuilder::StoreNamed(LanguageMode language_mode, const Operator* JSOperatorBuilder::StoreNamed(LanguageMode language_mode,
const Unique<Name>& name, const Handle<Name>& name,
const VectorSlotPair& feedback) { const VectorSlotPair& feedback) {
StoreNamedParameters parameters(language_mode, feedback, name); StoreNamedParameters parameters(language_mode, feedback, name);
return new (zone()) Operator1<StoreNamedParameters>( // -- return new (zone()) Operator1<StoreNamedParameters>( // --
...@@ -614,7 +620,7 @@ const Operator* JSOperatorBuilder::DeleteProperty(LanguageMode language_mode) { ...@@ -614,7 +620,7 @@ const Operator* JSOperatorBuilder::DeleteProperty(LanguageMode language_mode) {
} }
const Operator* JSOperatorBuilder::LoadGlobal(const Unique<Name>& name, const Operator* JSOperatorBuilder::LoadGlobal(const Handle<Name>& name,
const VectorSlotPair& feedback, const VectorSlotPair& feedback,
TypeofMode typeof_mode, TypeofMode typeof_mode,
int slot_index) { int slot_index) {
...@@ -628,7 +634,7 @@ const Operator* JSOperatorBuilder::LoadGlobal(const Unique<Name>& name, ...@@ -628,7 +634,7 @@ const Operator* JSOperatorBuilder::LoadGlobal(const Unique<Name>& name,
const Operator* JSOperatorBuilder::StoreGlobal(LanguageMode language_mode, const Operator* JSOperatorBuilder::StoreGlobal(LanguageMode language_mode,
const Unique<Name>& name, const Handle<Name>& name,
const VectorSlotPair& feedback, const VectorSlotPair& feedback,
int slot_index) { int slot_index) {
StoreGlobalParameters parameters(language_mode, feedback, name, slot_index); StoreGlobalParameters parameters(language_mode, feedback, name, slot_index);
...@@ -718,8 +724,9 @@ const Operator* JSOperatorBuilder::CreateLiteralObject(int literal_flags) { ...@@ -718,8 +724,9 @@ const Operator* JSOperatorBuilder::CreateLiteralObject(int literal_flags) {
const Operator* JSOperatorBuilder::CreateCatchContext( const Operator* JSOperatorBuilder::CreateCatchContext(
const Unique<String>& name) { const Handle<String>& name) {
return new (zone()) Operator1<Unique<String>>( // -- return new (zone()) Operator1<Handle<String>, Handle<String>::equal_to,
Handle<String>::hash>( // --
IrOpcode::kJSCreateCatchContext, Operator::kNoProperties, // opcode IrOpcode::kJSCreateCatchContext, Operator::kNoProperties, // opcode
"JSCreateCatchContext", // name "JSCreateCatchContext", // name
2, 1, 1, 1, 1, 2, // counts 2, 1, 1, 1, 1, 2, // counts
......
...@@ -236,17 +236,17 @@ DynamicContextAccess const& DynamicContextAccessOf(Operator const*); ...@@ -236,17 +236,17 @@ DynamicContextAccess const& DynamicContextAccessOf(Operator const*);
// used as a parameter by JSLoadNamed operators. // used as a parameter by JSLoadNamed operators.
class LoadNamedParameters final { class LoadNamedParameters final {
public: public:
LoadNamedParameters(const Unique<Name>& name, const VectorSlotPair& feedback, LoadNamedParameters(const Handle<Name>& name, const VectorSlotPair& feedback,
LanguageMode language_mode) LanguageMode language_mode)
: name_(name), feedback_(feedback), language_mode_(language_mode) {} : name_(name), feedback_(feedback), language_mode_(language_mode) {}
const Unique<Name>& name() const { return name_; } const Handle<Name>& name() const { return name_; }
LanguageMode language_mode() const { return language_mode_; } LanguageMode language_mode() const { return language_mode_; }
const VectorSlotPair& feedback() const { return feedback_; } const VectorSlotPair& feedback() const { return feedback_; }
private: private:
const Unique<Name> name_; const Handle<Name> name_;
const VectorSlotPair feedback_; const VectorSlotPair feedback_;
const LanguageMode language_mode_; const LanguageMode language_mode_;
}; };
...@@ -265,14 +265,14 @@ const LoadNamedParameters& LoadNamedParametersOf(const Operator* op); ...@@ -265,14 +265,14 @@ const LoadNamedParameters& LoadNamedParametersOf(const Operator* op);
// used as a parameter by JSLoadGlobal operator. // used as a parameter by JSLoadGlobal operator.
class LoadGlobalParameters final { class LoadGlobalParameters final {
public: public:
LoadGlobalParameters(const Unique<Name>& name, const VectorSlotPair& feedback, LoadGlobalParameters(const Handle<Name>& name, const VectorSlotPair& feedback,
TypeofMode typeof_mode, int slot_index) TypeofMode typeof_mode, int slot_index)
: name_(name), : name_(name),
feedback_(feedback), feedback_(feedback),
typeof_mode_(typeof_mode), typeof_mode_(typeof_mode),
slot_index_(slot_index) {} slot_index_(slot_index) {}
const Unique<Name>& name() const { return name_; } const Handle<Name>& name() const { return name_; }
TypeofMode typeof_mode() const { return typeof_mode_; } TypeofMode typeof_mode() const { return typeof_mode_; }
const VectorSlotPair& feedback() const { return feedback_; } const VectorSlotPair& feedback() const { return feedback_; }
...@@ -280,7 +280,7 @@ class LoadGlobalParameters final { ...@@ -280,7 +280,7 @@ class LoadGlobalParameters final {
int slot_index() const { return slot_index_; } int slot_index() const { return slot_index_; }
private: private:
const Unique<Name> name_; const Handle<Name> name_;
const VectorSlotPair feedback_; const VectorSlotPair feedback_;
const TypeofMode typeof_mode_; const TypeofMode typeof_mode_;
const int slot_index_; const int slot_index_;
...@@ -302,7 +302,7 @@ class StoreGlobalParameters final { ...@@ -302,7 +302,7 @@ class StoreGlobalParameters final {
public: public:
StoreGlobalParameters(LanguageMode language_mode, StoreGlobalParameters(LanguageMode language_mode,
const VectorSlotPair& feedback, const VectorSlotPair& feedback,
const Unique<Name>& name, int slot_index) const Handle<Name>& name, int slot_index)
: language_mode_(language_mode), : language_mode_(language_mode),
name_(name), name_(name),
feedback_(feedback), feedback_(feedback),
...@@ -310,12 +310,12 @@ class StoreGlobalParameters final { ...@@ -310,12 +310,12 @@ class StoreGlobalParameters final {
LanguageMode language_mode() const { return language_mode_; } LanguageMode language_mode() const { return language_mode_; }
const VectorSlotPair& feedback() const { return feedback_; } const VectorSlotPair& feedback() const { return feedback_; }
const Unique<Name>& name() const { return name_; } const Handle<Name>& name() const { return name_; }
int slot_index() const { return slot_index_; } int slot_index() const { return slot_index_; }
private: private:
const LanguageMode language_mode_; const LanguageMode language_mode_;
const Unique<Name> name_; const Handle<Name> name_;
const VectorSlotPair feedback_; const VectorSlotPair feedback_;
int slot_index_; int slot_index_;
}; };
...@@ -362,16 +362,16 @@ const LoadPropertyParameters& LoadPropertyParametersOf(const Operator* op); ...@@ -362,16 +362,16 @@ const LoadPropertyParameters& LoadPropertyParametersOf(const Operator* op);
class StoreNamedParameters final { class StoreNamedParameters final {
public: public:
StoreNamedParameters(LanguageMode language_mode, StoreNamedParameters(LanguageMode language_mode,
const VectorSlotPair& feedback, const Unique<Name>& name) const VectorSlotPair& feedback, const Handle<Name>& name)
: language_mode_(language_mode), name_(name), feedback_(feedback) {} : language_mode_(language_mode), name_(name), feedback_(feedback) {}
LanguageMode language_mode() const { return language_mode_; } LanguageMode language_mode() const { return language_mode_; }
const VectorSlotPair& feedback() const { return feedback_; } const VectorSlotPair& feedback() const { return feedback_; }
const Unique<Name>& name() const { return name_; } const Handle<Name>& name() const { return name_; }
private: private:
const LanguageMode language_mode_; const LanguageMode language_mode_;
const Unique<Name> name_; const Handle<Name> name_;
const VectorSlotPair feedback_; const VectorSlotPair feedback_;
}; };
...@@ -488,26 +488,26 @@ class JSOperatorBuilder final : public ZoneObject { ...@@ -488,26 +488,26 @@ class JSOperatorBuilder final : public ZoneObject {
const Operator* LoadProperty(const VectorSlotPair& feedback, const Operator* LoadProperty(const VectorSlotPair& feedback,
LanguageMode language_mode); LanguageMode language_mode);
const Operator* LoadNamed(const Unique<Name>& name, const Operator* LoadNamed(const Handle<Name>& name,
const VectorSlotPair& feedback, const VectorSlotPair& feedback,
LanguageMode language_mode); LanguageMode language_mode);
const Operator* StoreProperty(LanguageMode language_mode, const Operator* StoreProperty(LanguageMode language_mode,
const VectorSlotPair& feedback); const VectorSlotPair& feedback);
const Operator* StoreNamed(LanguageMode language_mode, const Operator* StoreNamed(LanguageMode language_mode,
const Unique<Name>& name, const Handle<Name>& name,
const VectorSlotPair& feedback); const VectorSlotPair& feedback);
const Operator* DeleteProperty(LanguageMode language_mode); const Operator* DeleteProperty(LanguageMode language_mode);
const Operator* HasProperty(); const Operator* HasProperty();
const Operator* LoadGlobal(const Unique<Name>& name, const Operator* LoadGlobal(const Handle<Name>& name,
const VectorSlotPair& feedback, const VectorSlotPair& feedback,
TypeofMode typeof_mode = NOT_INSIDE_TYPEOF, TypeofMode typeof_mode = NOT_INSIDE_TYPEOF,
int slot_index = -1); int slot_index = -1);
const Operator* StoreGlobal(LanguageMode language_mode, const Operator* StoreGlobal(LanguageMode language_mode,
const Unique<Name>& name, const Handle<Name>& name,
const VectorSlotPair& feedback, const VectorSlotPair& feedback,
int slot_index = -1); int slot_index = -1);
...@@ -534,7 +534,7 @@ class JSOperatorBuilder final : public ZoneObject { ...@@ -534,7 +534,7 @@ class JSOperatorBuilder final : public ZoneObject {
// TODO(titzer): nail down the static parts of each of these context flavors. // TODO(titzer): nail down the static parts of each of these context flavors.
const Operator* CreateFunctionContext(); const Operator* CreateFunctionContext();
const Operator* CreateCatchContext(const Unique<String>& name); const Operator* CreateCatchContext(const Handle<String>& name);
const Operator* CreateWithContext(); const Operator* CreateWithContext();
const Operator* CreateBlockContext(); const Operator* CreateBlockContext();
const Operator* CreateModuleContext(); const Operator* CreateModuleContext();
......
...@@ -43,7 +43,7 @@ Reduction JSTypeFeedbackLowering::ReduceJSLoadNamed(Node* node) { ...@@ -43,7 +43,7 @@ Reduction JSTypeFeedbackLowering::ReduceJSLoadNamed(Node* node) {
LoadNamedParameters const& p = LoadNamedParametersOf(node->op()); LoadNamedParameters const& p = LoadNamedParametersOf(node->op());
Handle<TypeFeedbackVector> vector; Handle<TypeFeedbackVector> vector;
if (!p.feedback().vector().ToHandle(&vector)) return NoChange(); if (!p.feedback().vector().ToHandle(&vector)) return NoChange();
if (p.name().handle().is_identical_to(factory()->length_string())) { if (p.name().is_identical_to(factory()->length_string())) {
LoadICNexus nexus(vector, p.feedback().slot()); LoadICNexus nexus(vector, p.feedback().slot());
MapHandleList maps; MapHandleList maps;
if (nexus.ExtractMaps(&maps) > 0) { if (nexus.ExtractMaps(&maps) > 0) {
......
...@@ -146,7 +146,6 @@ Reduction JSTypeFeedbackSpecializer::ReduceJSLoadNamed(Node* node) { ...@@ -146,7 +146,6 @@ Reduction JSTypeFeedbackSpecializer::ReduceJSLoadNamed(Node* node) {
if (frame_state_before == nullptr) return NoChange(); if (frame_state_before == nullptr) return NoChange();
const LoadNamedParameters& p = LoadNamedParametersOf(node->op()); const LoadNamedParameters& p = LoadNamedParametersOf(node->op());
Handle<Name> name = p.name().handle();
SmallMapList maps; SmallMapList maps;
FeedbackVectorICSlot slot = js_type_feedback_->FindFeedbackVectorICSlot(node); FeedbackVectorICSlot slot = js_type_feedback_->FindFeedbackVectorICSlot(node);
...@@ -155,7 +154,7 @@ Reduction JSTypeFeedbackSpecializer::ReduceJSLoadNamed(Node* node) { ...@@ -155,7 +154,7 @@ Reduction JSTypeFeedbackSpecializer::ReduceJSLoadNamed(Node* node) {
// No type feedback ids or the load is uninitialized. // No type feedback ids or the load is uninitialized.
return NoChange(); return NoChange();
} }
oracle()->PropertyReceiverTypes(slot, name, &maps); oracle()->PropertyReceiverTypes(slot, p.name(), &maps);
Node* receiver = node->InputAt(0); Node* receiver = node->InputAt(0);
Node* effect = NodeProperties::GetEffectInput(node); Node* effect = NodeProperties::GetEffectInput(node);
...@@ -165,7 +164,7 @@ Reduction JSTypeFeedbackSpecializer::ReduceJSLoadNamed(Node* node) { ...@@ -165,7 +164,7 @@ Reduction JSTypeFeedbackSpecializer::ReduceJSLoadNamed(Node* node) {
Handle<Map> map = maps.first(); Handle<Map> map = maps.first();
FieldAccess field_access; FieldAccess field_access;
if (!GetInObjectFieldAccess(LOAD, map, name, &field_access)) { if (!GetInObjectFieldAccess(LOAD, map, p.name(), &field_access)) {
return NoChange(); return NoChange();
} }
...@@ -191,7 +190,7 @@ Reduction JSTypeFeedbackSpecializer::ReduceJSLoadNamed(Node* node) { ...@@ -191,7 +190,7 @@ Reduction JSTypeFeedbackSpecializer::ReduceJSLoadNamed(Node* node) {
Reduction JSTypeFeedbackSpecializer::ReduceJSLoadGlobal(Node* node) { Reduction JSTypeFeedbackSpecializer::ReduceJSLoadGlobal(Node* node) {
DCHECK(node->opcode() == IrOpcode::kJSLoadGlobal); DCHECK(node->opcode() == IrOpcode::kJSLoadGlobal);
Handle<String> name = Handle<String> name =
Handle<String>::cast(LoadGlobalParametersOf(node->op()).name().handle()); Handle<String>::cast(LoadGlobalParametersOf(node->op()).name());
// Try to optimize loads from the global object. // Try to optimize loads from the global object.
Handle<Object> constant_value = Handle<Object> constant_value =
jsgraph()->isolate()->factory()->GlobalConstantFor(name); jsgraph()->isolate()->factory()->GlobalConstantFor(name);
...@@ -267,7 +266,6 @@ Reduction JSTypeFeedbackSpecializer::ReduceJSStoreNamed(Node* node) { ...@@ -267,7 +266,6 @@ Reduction JSTypeFeedbackSpecializer::ReduceJSStoreNamed(Node* node) {
if (frame_state_before == nullptr) return NoChange(); if (frame_state_before == nullptr) return NoChange();
const StoreNamedParameters& p = StoreNamedParametersOf(node->op()); const StoreNamedParameters& p = StoreNamedParametersOf(node->op());
Handle<Name> name = p.name().handle();
SmallMapList maps; SmallMapList maps;
TypeFeedbackId id = js_type_feedback_->FindTypeFeedbackId(node); TypeFeedbackId id = js_type_feedback_->FindTypeFeedbackId(node);
if (id.IsNone() || oracle()->StoreIsUninitialized(id) == UNINITIALIZED) { if (id.IsNone() || oracle()->StoreIsUninitialized(id) == UNINITIALIZED) {
...@@ -275,7 +273,7 @@ Reduction JSTypeFeedbackSpecializer::ReduceJSStoreNamed(Node* node) { ...@@ -275,7 +273,7 @@ Reduction JSTypeFeedbackSpecializer::ReduceJSStoreNamed(Node* node) {
// TODO(titzer): no feedback from vector ICs from stores. // TODO(titzer): no feedback from vector ICs from stores.
return NoChange(); return NoChange();
} else { } else {
oracle()->AssignmentReceiverTypes(id, name, &maps); oracle()->AssignmentReceiverTypes(id, p.name(), &maps);
} }
Node* receiver = node->InputAt(0); Node* receiver = node->InputAt(0);
...@@ -287,7 +285,7 @@ Reduction JSTypeFeedbackSpecializer::ReduceJSStoreNamed(Node* node) { ...@@ -287,7 +285,7 @@ Reduction JSTypeFeedbackSpecializer::ReduceJSStoreNamed(Node* node) {
Handle<Map> map = maps.first(); Handle<Map> map = maps.first();
FieldAccess field_access; FieldAccess field_access;
if (!GetInObjectFieldAccess(STORE, map, name, &field_access)) { if (!GetInObjectFieldAccess(STORE, map, p.name(), &field_access)) {
return NoChange(); return NoChange();
} }
......
...@@ -786,7 +786,7 @@ Reduction JSTypedLowering::ReduceJSToString(Node* node) { ...@@ -786,7 +786,7 @@ Reduction JSTypedLowering::ReduceJSToString(Node* node) {
Reduction JSTypedLowering::ReduceJSLoadGlobal(Node* node) { Reduction JSTypedLowering::ReduceJSLoadGlobal(Node* node) {
// Optimize global constants like "undefined", "Infinity", and "NaN". // Optimize global constants like "undefined", "Infinity", and "NaN".
Handle<Name> name = LoadGlobalParametersOf(node->op()).name().handle(); Handle<Name> name = LoadGlobalParametersOf(node->op()).name();
Handle<Object> constant_value = factory()->GlobalConstantFor(name); Handle<Object> constant_value = factory()->GlobalConstantFor(name);
if (!constant_value.is_null()) { if (!constant_value.is_null()) {
Node* constant = jsgraph()->Constant(constant_value); Node* constant = jsgraph()->Constant(constant_value);
...@@ -803,7 +803,7 @@ Reduction JSTypedLowering::ReduceJSLoadNamed(Node* node) { ...@@ -803,7 +803,7 @@ Reduction JSTypedLowering::ReduceJSLoadNamed(Node* node) {
Type* receiver_type = NodeProperties::GetBounds(receiver).upper; Type* receiver_type = NodeProperties::GetBounds(receiver).upper;
Node* effect = NodeProperties::GetEffectInput(node); Node* effect = NodeProperties::GetEffectInput(node);
Node* control = NodeProperties::GetControlInput(node); Node* control = NodeProperties::GetControlInput(node);
Handle<Name> name = LoadNamedParametersOf(node->op()).name().handle(); Handle<Name> name = LoadNamedParametersOf(node->op()).name();
// Optimize "length" property of strings. // Optimize "length" property of strings.
if (name.is_identical_to(factory()->length_string()) && if (name.is_identical_to(factory()->length_string()) &&
receiver_type->Is(Type::String())) { receiver_type->Is(Type::String())) {
...@@ -823,9 +823,9 @@ Reduction JSTypedLowering::ReduceJSLoadProperty(Node* node) { ...@@ -823,9 +823,9 @@ Reduction JSTypedLowering::ReduceJSLoadProperty(Node* node) {
Node* base = NodeProperties::GetValueInput(node, 0); Node* base = NodeProperties::GetValueInput(node, 0);
Type* key_type = NodeProperties::GetBounds(key).upper; Type* key_type = NodeProperties::GetBounds(key).upper;
HeapObjectMatcher mbase(base); HeapObjectMatcher mbase(base);
if (mbase.HasValue() && mbase.Value().handle()->IsJSTypedArray()) { if (mbase.HasValue() && mbase.Value()->IsJSTypedArray()) {
Handle<JSTypedArray> const array = Handle<JSTypedArray> const array =
Handle<JSTypedArray>::cast(mbase.Value().handle()); Handle<JSTypedArray>::cast(mbase.Value());
if (!array->GetBuffer()->was_neutered()) { if (!array->GetBuffer()->was_neutered()) {
array->GetBuffer()->set_is_neuterable(false); array->GetBuffer()->set_is_neuterable(false);
BufferAccess const access(array->type()); BufferAccess const access(array->type());
...@@ -869,9 +869,9 @@ Reduction JSTypedLowering::ReduceJSStoreProperty(Node* node) { ...@@ -869,9 +869,9 @@ Reduction JSTypedLowering::ReduceJSStoreProperty(Node* node) {
Type* key_type = NodeProperties::GetBounds(key).upper; Type* key_type = NodeProperties::GetBounds(key).upper;
Type* value_type = NodeProperties::GetBounds(value).upper; Type* value_type = NodeProperties::GetBounds(value).upper;
HeapObjectMatcher mbase(base); HeapObjectMatcher mbase(base);
if (mbase.HasValue() && mbase.Value().handle()->IsJSTypedArray()) { if (mbase.HasValue() && mbase.Value()->IsJSTypedArray()) {
Handle<JSTypedArray> const array = Handle<JSTypedArray> const array =
Handle<JSTypedArray>::cast(mbase.Value().handle()); Handle<JSTypedArray>::cast(mbase.Value());
if (!array->GetBuffer()->was_neutered()) { if (!array->GetBuffer()->was_neutered()) {
array->GetBuffer()->set_is_neuterable(false); array->GetBuffer()->set_is_neuterable(false);
BufferAccess const access(array->type()); BufferAccess const access(array->type());
...@@ -1016,12 +1016,12 @@ Reduction JSTypedLowering::ReduceJSLoadDynamicGlobal(Node* node) { ...@@ -1016,12 +1016,12 @@ Reduction JSTypedLowering::ReduceJSLoadDynamicGlobal(Node* node) {
} }
// Fast case, because variable is not shadowed. Perform global object load. // Fast case, because variable is not shadowed. Perform global object load.
Unique<Name> name = Unique<Name>::CreateUninitialized(access.name());
Node* global = graph()->NewNode( Node* global = graph()->NewNode(
javascript()->LoadContext(0, Context::GLOBAL_OBJECT_INDEX, true), context, javascript()->LoadContext(0, Context::GLOBAL_OBJECT_INDEX, true), context,
context, effect); context, effect);
Node* fast = graph()->NewNode( Node* fast = graph()->NewNode(
javascript()->LoadGlobal(name, access.feedback(), access.typeof_mode()), javascript()->LoadGlobal(access.name(), access.feedback(),
access.typeof_mode()),
context, global, vector, context, state1, state2, global, check_true); context, global, vector, context, state1, state2, global, check_true);
// Slow case, because variable potentially shadowed. Perform dynamic lookup. // Slow case, because variable potentially shadowed. Perform dynamic lookup.
...@@ -1129,7 +1129,7 @@ Reduction JSTypedLowering::ReduceJSCreateClosure(Node* node) { ...@@ -1129,7 +1129,7 @@ Reduction JSTypedLowering::ReduceJSCreateClosure(Node* node) {
Reduction JSTypedLowering::ReduceJSCreateLiteralArray(Node* node) { Reduction JSTypedLowering::ReduceJSCreateLiteralArray(Node* node) {
DCHECK_EQ(IrOpcode::kJSCreateLiteralArray, node->opcode()); DCHECK_EQ(IrOpcode::kJSCreateLiteralArray, node->opcode());
HeapObjectMatcher mconst(NodeProperties::GetValueInput(node, 2)); HeapObjectMatcher mconst(NodeProperties::GetValueInput(node, 2));
int length = Handle<FixedArray>::cast(mconst.Value().handle())->length(); int length = Handle<FixedArray>::cast(mconst.Value())->length();
int flags = OpParameter<int>(node->op()); int flags = OpParameter<int>(node->op());
// Use the FastCloneShallowArrayStub only for shallow boilerplates up to the // Use the FastCloneShallowArrayStub only for shallow boilerplates up to the
...@@ -1160,7 +1160,7 @@ Reduction JSTypedLowering::ReduceJSCreateLiteralObject(Node* node) { ...@@ -1160,7 +1160,7 @@ Reduction JSTypedLowering::ReduceJSCreateLiteralObject(Node* node) {
DCHECK_EQ(IrOpcode::kJSCreateLiteralObject, node->opcode()); DCHECK_EQ(IrOpcode::kJSCreateLiteralObject, node->opcode());
HeapObjectMatcher mconst(NodeProperties::GetValueInput(node, 2)); HeapObjectMatcher mconst(NodeProperties::GetValueInput(node, 2));
// Constants are pairs, see ObjectLiteral::properties_count(). // Constants are pairs, see ObjectLiteral::properties_count().
int length = Handle<FixedArray>::cast(mconst.Value().handle())->length() / 2; int length = Handle<FixedArray>::cast(mconst.Value())->length() / 2;
int flags = OpParameter<int>(node->op()); int flags = OpParameter<int>(node->op());
// Use the FastCloneShallowObjectStub only for shallow boilerplates without // Use the FastCloneShallowObjectStub only for shallow boilerplates without
...@@ -1225,8 +1225,7 @@ Reduction JSTypedLowering::ReduceJSCreateBlockContext(Node* node) { ...@@ -1225,8 +1225,7 @@ Reduction JSTypedLowering::ReduceJSCreateBlockContext(Node* node) {
Node* const input = NodeProperties::GetValueInput(node, 0); Node* const input = NodeProperties::GetValueInput(node, 0);
HeapObjectMatcher minput(input); HeapObjectMatcher minput(input);
DCHECK(minput.HasValue()); // TODO(mstarzinger): Make ScopeInfo static. DCHECK(minput.HasValue()); // TODO(mstarzinger): Make ScopeInfo static.
int context_length = int context_length = Handle<ScopeInfo>::cast(minput.Value())->ContextLength();
Handle<ScopeInfo>::cast(minput.Value().handle())->ContextLength();
if (FLAG_turbo_allocate && context_length < kBlockContextAllocationLimit) { if (FLAG_turbo_allocate && context_length < kBlockContextAllocationLimit) {
// JSCreateBlockContext(s:scope[length < limit], f) // JSCreateBlockContext(s:scope[length < limit], f)
Node* const effect = NodeProperties::GetEffectInput(node); Node* const effect = NodeProperties::GetEffectInput(node);
......
...@@ -62,14 +62,6 @@ struct ValueMatcher : public NodeMatcher { ...@@ -62,14 +62,6 @@ struct ValueMatcher : public NodeMatcher {
return value_; return value_;
} }
bool Is(const T& value) const {
return this->HasValue() && this->Value() == value;
}
bool IsInRange(const T& low, const T& high) const {
return this->HasValue() && low <= this->Value() && this->Value() <= high;
}
private: private:
T value_; T value_;
bool has_value_; bool has_value_;
...@@ -108,6 +100,12 @@ template <typename T, IrOpcode::Value kOpcode> ...@@ -108,6 +100,12 @@ template <typename T, IrOpcode::Value kOpcode>
struct IntMatcher final : public ValueMatcher<T, kOpcode> { struct IntMatcher final : public ValueMatcher<T, kOpcode> {
explicit IntMatcher(Node* node) : ValueMatcher<T, kOpcode>(node) {} explicit IntMatcher(Node* node) : ValueMatcher<T, kOpcode>(node) {}
bool Is(const T& value) const {
return this->HasValue() && this->Value() == value;
}
bool IsInRange(const T& low, const T& high) const {
return this->HasValue() && low <= this->Value() && this->Value() <= high;
}
bool IsMultipleOf(T n) const { bool IsMultipleOf(T n) const {
return this->HasValue() && (this->Value() % n) == 0; return this->HasValue() && (this->Value() % n) == 0;
} }
...@@ -139,6 +137,12 @@ template <typename T, IrOpcode::Value kOpcode> ...@@ -139,6 +137,12 @@ template <typename T, IrOpcode::Value kOpcode>
struct FloatMatcher final : public ValueMatcher<T, kOpcode> { struct FloatMatcher final : public ValueMatcher<T, kOpcode> {
explicit FloatMatcher(Node* node) : ValueMatcher<T, kOpcode>(node) {} explicit FloatMatcher(Node* node) : ValueMatcher<T, kOpcode>(node) {}
bool Is(const T& value) const {
return this->HasValue() && this->Value() == value;
}
bool IsInRange(const T& low, const T& high) const {
return this->HasValue() && low <= this->Value() && this->Value() <= high;
}
bool IsMinusZero() const { bool IsMinusZero() const {
return this->Is(0.0) && std::signbit(this->Value()); return this->Is(0.0) && std::signbit(this->Value());
} }
...@@ -153,9 +157,9 @@ typedef FloatMatcher<double, IrOpcode::kNumberConstant> NumberMatcher; ...@@ -153,9 +157,9 @@ typedef FloatMatcher<double, IrOpcode::kNumberConstant> NumberMatcher;
// A pattern matcher for heap object constants. // A pattern matcher for heap object constants.
struct HeapObjectMatcher final struct HeapObjectMatcher final
: public ValueMatcher<Unique<HeapObject>, IrOpcode::kHeapConstant> { : public ValueMatcher<Handle<HeapObject>, IrOpcode::kHeapConstant> {
explicit HeapObjectMatcher(Node* node) explicit HeapObjectMatcher(Node* node)
: ValueMatcher<Unique<HeapObject>, IrOpcode::kHeapConstant>(node) {} : ValueMatcher<Handle<HeapObject>, IrOpcode::kHeapConstant>(node) {}
}; };
...@@ -164,6 +168,9 @@ struct ExternalReferenceMatcher final ...@@ -164,6 +168,9 @@ struct ExternalReferenceMatcher final
: public ValueMatcher<ExternalReference, IrOpcode::kExternalConstant> { : public ValueMatcher<ExternalReference, IrOpcode::kExternalConstant> {
explicit ExternalReferenceMatcher(Node* node) explicit ExternalReferenceMatcher(Node* node)
: ValueMatcher<ExternalReference, IrOpcode::kExternalConstant>(node) {} : ValueMatcher<ExternalReference, IrOpcode::kExternalConstant>(node) {}
bool Is(const ExternalReference& value) const {
return this->HasValue() && this->Value() == value;
}
}; };
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "src/base/flags.h" #include "src/base/flags.h"
#include "src/base/functional.h" #include "src/base/functional.h"
#include "src/handles.h"
#include "src/zone.h" #include "src/zone.h"
namespace v8 { namespace v8 {
...@@ -155,7 +156,8 @@ class Operator1 : public Operator { ...@@ -155,7 +156,8 @@ class Operator1 : public Operator {
bool Equals(const Operator* other) const final { bool Equals(const Operator* other) const final {
if (opcode() != other->opcode()) return false; if (opcode() != other->opcode()) return false;
const Operator1<T>* that = reinterpret_cast<const Operator1<T>*>(other); const Operator1<T, Pred, Hash>* that =
reinterpret_cast<const Operator1<T, Pred, Hash>*>(other);
return this->pred_(this->parameter(), that->parameter()); return this->pred_(this->parameter(), that->parameter());
} }
size_t HashCode() const final { size_t HashCode() const final {
...@@ -185,7 +187,8 @@ inline T const& OpParameter(const Operator* op) { ...@@ -185,7 +187,8 @@ inline T const& OpParameter(const Operator* op) {
} }
// NOTE: We have to be careful to use the right equal/hash functions below, for // NOTE: We have to be careful to use the right equal/hash functions below, for
// float/double we always use the ones operating on the bit level. // float/double we always use the ones operating on the bit level, for Handle<>
// we always use the ones operating on the location level.
template <> template <>
inline float const& OpParameter(const Operator* op) { inline float const& OpParameter(const Operator* op) {
return reinterpret_cast<const Operator1<float, base::bit_equal_to<float>, return reinterpret_cast<const Operator1<float, base::bit_equal_to<float>,
...@@ -200,6 +203,20 @@ inline double const& OpParameter(const Operator* op) { ...@@ -200,6 +203,20 @@ inline double const& OpParameter(const Operator* op) {
->parameter(); ->parameter();
} }
template <>
inline Handle<HeapObject> const& OpParameter(const Operator* op) {
return reinterpret_cast<
const Operator1<Handle<HeapObject>, Handle<HeapObject>::equal_to,
Handle<HeapObject>::hash>*>(op)->parameter();
}
template <>
inline Handle<String> const& OpParameter(const Operator* op) {
return reinterpret_cast<const Operator1<
Handle<String>, Handle<String>::equal_to, Handle<String>::hash>*>(op)
->parameter();
}
} // namespace compiler } // namespace compiler
} // namespace internal } // namespace internal
} // namespace v8 } // namespace v8
......
...@@ -72,9 +72,8 @@ class RawMachineAssembler { ...@@ -72,9 +72,8 @@ class RawMachineAssembler {
// hence will not switch the current basic block. // hence will not switch the current basic block.
Node* UndefinedConstant() { Node* UndefinedConstant() {
Unique<HeapObject> unique = Unique<HeapObject>::CreateImmovable( Handle<HeapObject> undefined = isolate()->factory()->undefined_value();
isolate()->factory()->undefined_value()); return NewNode(common()->HeapConstant(undefined));
return NewNode(common()->HeapConstant(unique));
} }
// Constants. // Constants.
...@@ -102,10 +101,6 @@ class RawMachineAssembler { ...@@ -102,10 +101,6 @@ class RawMachineAssembler {
return NewNode(common()->Float64Constant(value)); return NewNode(common()->Float64Constant(value));
} }
Node* HeapConstant(Handle<HeapObject> object) { Node* HeapConstant(Handle<HeapObject> object) {
Unique<HeapObject> val = Unique<HeapObject>::CreateUninitialized(object);
return NewNode(common()->HeapConstant(val));
}
Node* HeapConstant(Unique<HeapObject> object) {
return NewNode(common()->HeapConstant(object)); return NewNode(common()->HeapConstant(object));
} }
Node* ExternalConstant(ExternalReference address) { Node* ExternalConstant(ExternalReference address) {
......
...@@ -292,7 +292,7 @@ class RepresentationChanger { ...@@ -292,7 +292,7 @@ class RepresentationChanger {
// Eagerly fold representation changes for constants. // Eagerly fold representation changes for constants.
switch (node->opcode()) { switch (node->opcode()) {
case IrOpcode::kHeapConstant: { case IrOpcode::kHeapConstant: {
Handle<Object> value = OpParameter<Unique<Object> >(node).handle(); Handle<HeapObject> value = OpParameter<Handle<HeapObject>>(node);
DCHECK(value.is_identical_to(factory()->true_value()) || DCHECK(value.is_identical_to(factory()->true_value()) ||
value.is_identical_to(factory()->false_value())); value.is_identical_to(factory()->false_value()));
return jsgraph()->Int32Constant( return jsgraph()->Int32Constant(
......
...@@ -25,8 +25,7 @@ Reduction SimplifiedOperatorReducer::Reduce(Node* node) { ...@@ -25,8 +25,7 @@ Reduction SimplifiedOperatorReducer::Reduce(Node* node) {
case IrOpcode::kBooleanNot: { case IrOpcode::kBooleanNot: {
HeapObjectMatcher m(node->InputAt(0)); HeapObjectMatcher m(node->InputAt(0));
if (m.HasValue()) { if (m.HasValue()) {
return Replace( return Replace(jsgraph()->BooleanConstant(!m.Value()->BooleanValue()));
jsgraph()->BooleanConstant(!m.Value().handle()->BooleanValue()));
} }
if (m.IsBooleanNot()) return Replace(m.InputAt(0)); if (m.IsBooleanNot()) return Replace(m.InputAt(0));
break; break;
...@@ -40,7 +39,7 @@ Reduction SimplifiedOperatorReducer::Reduce(Node* node) { ...@@ -40,7 +39,7 @@ Reduction SimplifiedOperatorReducer::Reduce(Node* node) {
} }
case IrOpcode::kChangeBoolToBit: { case IrOpcode::kChangeBoolToBit: {
HeapObjectMatcher m(node->InputAt(0)); HeapObjectMatcher m(node->InputAt(0));
if (m.HasValue()) return ReplaceInt32(m.Value().handle()->BooleanValue()); if (m.HasValue()) return ReplaceInt32(m.Value()->BooleanValue());
if (m.IsChangeBitToBool()) return Replace(m.InputAt(0)); if (m.IsChangeBitToBool()) return Replace(m.InputAt(0));
break; break;
} }
......
...@@ -541,7 +541,7 @@ Bounds Typer::Visitor::TypeNumberConstant(Node* node) { ...@@ -541,7 +541,7 @@ Bounds Typer::Visitor::TypeNumberConstant(Node* node) {
Bounds Typer::Visitor::TypeHeapConstant(Node* node) { Bounds Typer::Visitor::TypeHeapConstant(Node* node) {
return Bounds(TypeConstant(OpParameter<Unique<HeapObject> >(node).handle())); return Bounds(TypeConstant(OpParameter<Handle<HeapObject>>(node)));
} }
......
...@@ -40,9 +40,9 @@ class X87OperandGenerator final : public OperandGenerator { ...@@ -40,9 +40,9 @@ class X87OperandGenerator final : public OperandGenerator {
case IrOpcode::kHeapConstant: { case IrOpcode::kHeapConstant: {
// Constants in new space cannot be used as immediates in V8 because // Constants in new space cannot be used as immediates in V8 because
// the GC does not scan code objects when collecting the new generation. // the GC does not scan code objects when collecting the new generation.
Unique<HeapObject> value = OpParameter<Unique<HeapObject> >(node); Handle<HeapObject> value = OpParameter<Handle<HeapObject>>(node);
Isolate* isolate = value.handle()->GetIsolate(); Isolate* isolate = value->GetIsolate();
return !isolate->heap()->InNewSpace(*value.handle()); return !isolate->heap()->InNewSpace(*value);
} }
default: default:
return false; return false;
......
...@@ -26,6 +26,12 @@ HandleScope::HandleScope(Isolate* isolate) { ...@@ -26,6 +26,12 @@ HandleScope::HandleScope(Isolate* isolate) {
} }
template <typename T>
inline std::ostream& operator<<(std::ostream& os, Handle<T> handle) {
return os << Brief(*handle);
}
HandleScope::~HandleScope() { HandleScope::~HandleScope() {
#ifdef DEBUG #ifdef DEBUG
if (FLAG_check_handle_count) { if (FLAG_check_handle_count) {
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#define V8_HANDLES_H_ #define V8_HANDLES_H_
#include "include/v8.h" #include "include/v8.h"
#include "src/base/functional.h"
#include "src/base/macros.h" #include "src/base/macros.h"
#include "src/checks.h" #include "src/checks.h"
#include "src/globals.h" #include "src/globals.h"
...@@ -118,6 +119,20 @@ class Handle final : public HandleBase { ...@@ -118,6 +119,20 @@ class Handle final : public HandleBase {
// MaybeHandle to force validation before being used as handles. // MaybeHandle to force validation before being used as handles.
static const Handle<T> null() { return Handle<T>(); } static const Handle<T> null() { return Handle<T>(); }
// Provide function object for location equality comparison.
struct equal_to : public std::binary_function<Handle<T>, Handle<T>, bool> {
V8_INLINE bool operator()(Handle<T> lhs, Handle<T> rhs) const {
return lhs.location() == rhs.location();
}
};
// Provide function object for location hashing.
struct hash : public std::unary_function<Handle<T>, size_t> {
V8_INLINE size_t operator()(Handle<T> const& handle) const {
return base::hash<void*>()(handle.location());
}
};
private: private:
// Handles of different classes are allowed to access each other's location_. // Handles of different classes are allowed to access each other's location_.
template <typename> template <typename>
...@@ -127,6 +142,9 @@ class Handle final : public HandleBase { ...@@ -127,6 +142,9 @@ class Handle final : public HandleBase {
friend class MaybeHandle; friend class MaybeHandle;
}; };
template <typename T>
inline std::ostream& operator<<(std::ostream& os, Handle<T> handle);
template <typename T> template <typename T>
V8_INLINE Handle<T> handle(T* object, Isolate* isolate) { V8_INLINE Handle<T> handle(T* object, Isolate* isolate) {
return Handle<T>(object, isolate); return Handle<T>(object, isolate);
......
...@@ -121,8 +121,8 @@ void Interpreter::DoLdaConstant(compiler::InterpreterAssembler* assembler) { ...@@ -121,8 +121,8 @@ void Interpreter::DoLdaConstant(compiler::InterpreterAssembler* assembler) {
// //
// Load Undefined into the accumulator. // Load Undefined into the accumulator.
void Interpreter::DoLdaUndefined(compiler::InterpreterAssembler* assembler) { void Interpreter::DoLdaUndefined(compiler::InterpreterAssembler* assembler) {
Node* undefined_value = __ HeapConstant(Unique<HeapObject>::CreateImmovable( Node* undefined_value =
isolate_->factory()->undefined_value())); __ HeapConstant(isolate_->factory()->undefined_value());
__ SetAccumulator(undefined_value); __ SetAccumulator(undefined_value);
__ Dispatch(); __ Dispatch();
} }
...@@ -132,8 +132,7 @@ void Interpreter::DoLdaUndefined(compiler::InterpreterAssembler* assembler) { ...@@ -132,8 +132,7 @@ void Interpreter::DoLdaUndefined(compiler::InterpreterAssembler* assembler) {
// //
// Load Null into the accumulator. // Load Null into the accumulator.
void Interpreter::DoLdaNull(compiler::InterpreterAssembler* assembler) { void Interpreter::DoLdaNull(compiler::InterpreterAssembler* assembler) {
Node* null_value = __ HeapConstant( Node* null_value = __ HeapConstant(isolate_->factory()->null_value());
Unique<HeapObject>::CreateImmovable(isolate_->factory()->null_value()));
__ SetAccumulator(null_value); __ SetAccumulator(null_value);
__ Dispatch(); __ Dispatch();
} }
...@@ -143,8 +142,7 @@ void Interpreter::DoLdaNull(compiler::InterpreterAssembler* assembler) { ...@@ -143,8 +142,7 @@ void Interpreter::DoLdaNull(compiler::InterpreterAssembler* assembler) {
// //
// Load TheHole into the accumulator. // Load TheHole into the accumulator.
void Interpreter::DoLdaTheHole(compiler::InterpreterAssembler* assembler) { void Interpreter::DoLdaTheHole(compiler::InterpreterAssembler* assembler) {
Node* the_hole_value = __ HeapConstant(Unique<HeapObject>::CreateImmovable( Node* the_hole_value = __ HeapConstant(isolate_->factory()->the_hole_value());
isolate_->factory()->the_hole_value()));
__ SetAccumulator(the_hole_value); __ SetAccumulator(the_hole_value);
__ Dispatch(); __ Dispatch();
} }
...@@ -154,8 +152,7 @@ void Interpreter::DoLdaTheHole(compiler::InterpreterAssembler* assembler) { ...@@ -154,8 +152,7 @@ void Interpreter::DoLdaTheHole(compiler::InterpreterAssembler* assembler) {
// //
// Load True into the accumulator. // Load True into the accumulator.
void Interpreter::DoLdaTrue(compiler::InterpreterAssembler* assembler) { void Interpreter::DoLdaTrue(compiler::InterpreterAssembler* assembler) {
Node* true_value = __ HeapConstant( Node* true_value = __ HeapConstant(isolate_->factory()->true_value());
Unique<HeapObject>::CreateImmovable(isolate_->factory()->true_value()));
__ SetAccumulator(true_value); __ SetAccumulator(true_value);
__ Dispatch(); __ Dispatch();
} }
...@@ -165,8 +162,7 @@ void Interpreter::DoLdaTrue(compiler::InterpreterAssembler* assembler) { ...@@ -165,8 +162,7 @@ void Interpreter::DoLdaTrue(compiler::InterpreterAssembler* assembler) {
// //
// Load False into the accumulator. // Load False into the accumulator.
void Interpreter::DoLdaFalse(compiler::InterpreterAssembler* assembler) { void Interpreter::DoLdaFalse(compiler::InterpreterAssembler* assembler) {
Node* false_value = __ HeapConstant( Node* false_value = __ HeapConstant(isolate_->factory()->false_value());
Unique<HeapObject>::CreateImmovable(isolate_->factory()->false_value()));
__ SetAccumulator(false_value); __ SetAccumulator(false_value);
__ Dispatch(); __ Dispatch();
} }
......
...@@ -104,8 +104,7 @@ class GraphBuilderTester : public HandleAndZoneScope, ...@@ -104,8 +104,7 @@ class GraphBuilderTester : public HandleAndZoneScope,
return NewNode(common()->Int32Constant(value)); return NewNode(common()->Int32Constant(value));
} }
Node* HeapConstant(Handle<HeapObject> object) { Node* HeapConstant(Handle<HeapObject> object) {
Unique<HeapObject> val = Unique<HeapObject>::CreateUninitialized(object); return NewNode(common()->HeapConstant(object));
return NewNode(common()->HeapConstant(val));
} }
Node* BooleanNot(Node* a) { return NewNode(simplified()->BooleanNot(), a); } Node* BooleanNot(Node* a) { return NewNode(simplified()->BooleanNot(), a); }
......
...@@ -47,9 +47,9 @@ class JSConstantCacheTester : public HandleAndZoneScope, ...@@ -47,9 +47,9 @@ class JSConstantCacheTester : public HandleAndZoneScope,
Type* upper(Node* node) { return NodeProperties::GetBounds(node).upper; } Type* upper(Node* node) { return NodeProperties::GetBounds(node).upper; }
Handle<Object> handle(Node* node) { Handle<HeapObject> handle(Node* node) {
CHECK_EQ(IrOpcode::kHeapConstant, node->opcode()); CHECK_EQ(IrOpcode::kHeapConstant, node->opcode());
return OpParameter<Unique<Object> >(node).handle(); return OpParameter<Handle<HeapObject>>(node);
} }
Factory* factory() { return main_isolate()->factory(); } Factory* factory() { return main_isolate()->factory(); }
......
...@@ -93,7 +93,7 @@ TEST(ReduceJSLoadContext) { ...@@ -93,7 +93,7 @@ TEST(ReduceJSLoadContext) {
Node* new_context_input = NodeProperties::GetValueInput(r.replacement(), 0); Node* new_context_input = NodeProperties::GetValueInput(r.replacement(), 0);
CHECK_EQ(IrOpcode::kHeapConstant, new_context_input->opcode()); CHECK_EQ(IrOpcode::kHeapConstant, new_context_input->opcode());
HeapObjectMatcher match(new_context_input); HeapObjectMatcher match(new_context_input);
CHECK_EQ(*native, *match.Value().handle()); CHECK_EQ(*native, *match.Value());
ContextAccess access = OpParameter<ContextAccess>(r.replacement()); ContextAccess access = OpParameter<ContextAccess>(r.replacement());
CHECK_EQ(Context::GLOBAL_EVAL_FUN_INDEX, static_cast<int>(access.index())); CHECK_EQ(Context::GLOBAL_EVAL_FUN_INDEX, static_cast<int>(access.index()));
CHECK_EQ(0, static_cast<int>(access.depth())); CHECK_EQ(0, static_cast<int>(access.depth()));
...@@ -110,7 +110,7 @@ TEST(ReduceJSLoadContext) { ...@@ -110,7 +110,7 @@ TEST(ReduceJSLoadContext) {
HeapObjectMatcher match(r.replacement()); HeapObjectMatcher match(r.replacement());
CHECK(match.HasValue()); CHECK(match.HasValue());
CHECK_EQ(*expected, *match.Value().handle()); CHECK_EQ(*expected, *match.Value());
} }
// TODO(titzer): test with other kinds of contexts, e.g. a function context. // TODO(titzer): test with other kinds of contexts, e.g. a function context.
...@@ -172,7 +172,7 @@ TEST(ReduceJSStoreContext) { ...@@ -172,7 +172,7 @@ TEST(ReduceJSStoreContext) {
Node* new_context_input = NodeProperties::GetValueInput(r.replacement(), 0); Node* new_context_input = NodeProperties::GetValueInput(r.replacement(), 0);
CHECK_EQ(IrOpcode::kHeapConstant, new_context_input->opcode()); CHECK_EQ(IrOpcode::kHeapConstant, new_context_input->opcode());
HeapObjectMatcher match(new_context_input); HeapObjectMatcher match(new_context_input);
CHECK_EQ(*native, *match.Value().handle()); CHECK_EQ(*native, *match.Value());
ContextAccess access = OpParameter<ContextAccess>(r.replacement()); ContextAccess access = OpParameter<ContextAccess>(r.replacement());
CHECK_EQ(Context::GLOBAL_EVAL_FUN_INDEX, static_cast<int>(access.index())); CHECK_EQ(Context::GLOBAL_EVAL_FUN_INDEX, static_cast<int>(access.index()));
CHECK_EQ(0, static_cast<int>(access.depth())); CHECK_EQ(0, static_cast<int>(access.depth()));
...@@ -249,7 +249,7 @@ TEST(SpecializeToContext) { ...@@ -249,7 +249,7 @@ TEST(SpecializeToContext) {
Node* replacement = value_use->InputAt(0); Node* replacement = value_use->InputAt(0);
HeapObjectMatcher match(replacement); HeapObjectMatcher match(replacement);
CHECK(match.HasValue()); CHECK(match.HasValue());
CHECK_EQ(*expected, *match.Value().handle()); CHECK_EQ(*expected, *match.Value());
} }
// TODO(titzer): clean up above test and test more complicated effects. // TODO(titzer): clean up above test and test more complicated effects.
} }
......
...@@ -63,15 +63,12 @@ class JSTypedLoweringTester : public HandleAndZoneScope { ...@@ -63,15 +63,12 @@ class JSTypedLoweringTester : public HandleAndZoneScope {
} }
Node* UndefinedConstant() { Node* UndefinedConstant() {
Unique<HeapObject> unique = Unique<HeapObject>::CreateImmovable( Handle<HeapObject> value = isolate->factory()->undefined_value();
isolate->factory()->undefined_value()); return graph.NewNode(common.HeapConstant(value));
return graph.NewNode(common.HeapConstant(unique));
} }
Node* HeapConstant(Handle<HeapObject> constant) { Node* HeapConstant(Handle<HeapObject> constant) {
Unique<HeapObject> unique = return graph.NewNode(common.HeapConstant(constant));
Unique<HeapObject>::CreateUninitialized(constant);
return graph.NewNode(common.HeapConstant(unique));
} }
Node* EmptyFrameState(Node* context) { Node* EmptyFrameState(Node* context) {
...@@ -193,9 +190,9 @@ class JSTypedLoweringTester : public HandleAndZoneScope { ...@@ -193,9 +190,9 @@ class JSTypedLoweringTester : public HandleAndZoneScope {
CheckHandle(isolate->factory()->false_value(), result); CheckHandle(isolate->factory()->false_value(), result);
} }
void CheckHandle(Handle<Object> expected, Node* result) { void CheckHandle(Handle<HeapObject> expected, Node* result) {
CHECK_EQ(IrOpcode::kHeapConstant, result->opcode()); CHECK_EQ(IrOpcode::kHeapConstant, result->opcode());
Handle<Object> value = OpParameter<Unique<Object> >(result).handle(); Handle<HeapObject> value = OpParameter<Handle<HeapObject>>(result);
CHECK_EQ(*expected, *value); CHECK_EQ(*expected, *value);
} }
}; };
......
...@@ -71,7 +71,7 @@ class RepresentationChangerTester : public HandleAndZoneScope, ...@@ -71,7 +71,7 @@ class RepresentationChangerTester : public HandleAndZoneScope,
void CheckHeapConstant(Node* n, HeapObject* expected) { void CheckHeapConstant(Node* n, HeapObject* expected) {
HeapObjectMatcher m(n); HeapObjectMatcher m(n);
CHECK(m.HasValue()); CHECK(m.HasValue());
CHECK_EQ(expected, *m.Value().handle()); CHECK_EQ(expected, *m.Value());
} }
void CheckNumberConstant(Node* n, double expected) { void CheckNumberConstant(Node* n, double expected) {
......
...@@ -268,8 +268,7 @@ Handle<Code> WrapWithCFunction(Handle<Code> inner, CallDescriptor* desc) { ...@@ -268,8 +268,7 @@ Handle<Code> WrapWithCFunction(Handle<Code> inner, CallDescriptor* desc) {
GraphAndBuilders& b = caller; GraphAndBuilders& b = caller;
Node* start = b.graph()->NewNode(b.common()->Start(param_count + 3)); Node* start = b.graph()->NewNode(b.common()->Start(param_count + 3));
b.graph()->SetStart(start); b.graph()->SetStart(start);
Unique<HeapObject> unique = Unique<HeapObject>::CreateUninitialized(inner); Node* target = b.graph()->NewNode(b.common()->HeapConstant(inner));
Node* target = b.graph()->NewNode(b.common()->HeapConstant(unique));
// Add arguments to the call. // Add arguments to the call.
Node** args = zone.NewArray<Node*>(param_count + 3); Node** args = zone.NewArray<Node*>(param_count + 3);
...@@ -445,9 +444,7 @@ class Computer { ...@@ -445,9 +444,7 @@ class Computer {
Graph graph(&zone); Graph graph(&zone);
CallDescriptor* cdesc = Linkage::GetSimplifiedCDescriptor(&zone, &csig); CallDescriptor* cdesc = Linkage::GetSimplifiedCDescriptor(&zone, &csig);
RawMachineAssembler raw(isolate, &graph, cdesc); RawMachineAssembler raw(isolate, &graph, cdesc);
Unique<HeapObject> unique = Node* target = raw.HeapConstant(inner);
Unique<HeapObject>::CreateUninitialized(inner);
Node* target = raw.HeapConstant(unique);
Node** args = zone.NewArray<Node*>(num_params); Node** args = zone.NewArray<Node*>(num_params);
for (int i = 0; i < num_params; i++) { for (int i = 0; i < num_params; i++) {
args[i] = io.MakeConstant(raw, io.input[i]); args[i] = io.MakeConstant(raw, io.input[i]);
...@@ -480,9 +477,7 @@ class Computer { ...@@ -480,9 +477,7 @@ class Computer {
CallDescriptor* cdesc = Linkage::GetSimplifiedCDescriptor(&zone, &csig); CallDescriptor* cdesc = Linkage::GetSimplifiedCDescriptor(&zone, &csig);
RawMachineAssembler raw(isolate, &graph, cdesc); RawMachineAssembler raw(isolate, &graph, cdesc);
Node* base = raw.PointerConstant(io.input); Node* base = raw.PointerConstant(io.input);
Unique<HeapObject> unique = Node* target = raw.HeapConstant(inner);
Unique<HeapObject>::CreateUninitialized(inner);
Node* target = raw.HeapConstant(unique);
Node** args = zone.NewArray<Node*>(kMaxParamCount); Node** args = zone.NewArray<Node*>(kMaxParamCount);
for (int i = 0; i < num_params; i++) { for (int i = 0; i < num_params; i++) {
args[i] = io.LoadInput(raw, base, i); args[i] = io.LoadInput(raw, base, i);
...@@ -579,8 +574,7 @@ static void CopyTwentyInt32(CallDescriptor* desc) { ...@@ -579,8 +574,7 @@ static void CopyTwentyInt32(CallDescriptor* desc) {
CallDescriptor* cdesc = Linkage::GetSimplifiedCDescriptor(&zone, &csig); CallDescriptor* cdesc = Linkage::GetSimplifiedCDescriptor(&zone, &csig);
RawMachineAssembler raw(isolate, &graph, cdesc); RawMachineAssembler raw(isolate, &graph, cdesc);
Node* base = raw.PointerConstant(input); Node* base = raw.PointerConstant(input);
Unique<HeapObject> unique = Unique<HeapObject>::CreateUninitialized(inner); Node* target = raw.HeapConstant(inner);
Node* target = raw.HeapConstant(unique);
Node** args = zone.NewArray<Node*>(kNumParams); Node** args = zone.NewArray<Node*>(kNumParams);
for (int i = 0; i < kNumParams; i++) { for (int i = 0; i < kNumParams; i++) {
Node* offset = raw.Int32Constant(i * sizeof(int32_t)); Node* offset = raw.Int32Constant(i * sizeof(int32_t));
...@@ -953,8 +947,7 @@ static void Build_Select_With_Call(CallDescriptor* desc, ...@@ -953,8 +947,7 @@ static void Build_Select_With_Call(CallDescriptor* desc,
{ {
// Build a call to the function that does the select. // Build a call to the function that does the select.
Unique<HeapObject> unique = Unique<HeapObject>::CreateUninitialized(inner); Node* target = raw.HeapConstant(inner);
Node* target = raw.HeapConstant(unique);
Node** args = raw.zone()->NewArray<Node*>(num_params); Node** args = raw.zone()->NewArray<Node*>(num_params);
for (int i = 0; i < num_params; i++) { for (int i = 0; i < num_params; i++) {
args[i] = raw.Parameter(i); args[i] = raw.Parameter(i);
...@@ -1055,9 +1048,7 @@ void MixedParamTest(int start) { ...@@ -1055,9 +1048,7 @@ void MixedParamTest(int start) {
Graph graph(&zone); Graph graph(&zone);
CallDescriptor* cdesc = Linkage::GetSimplifiedCDescriptor(&zone, &csig); CallDescriptor* cdesc = Linkage::GetSimplifiedCDescriptor(&zone, &csig);
RawMachineAssembler raw(isolate, &graph, cdesc); RawMachineAssembler raw(isolate, &graph, cdesc);
Unique<HeapObject> unique = Node* target = raw.HeapConstant(select);
Unique<HeapObject>::CreateUninitialized(select);
Node* target = raw.HeapConstant(unique);
Node** args = zone.NewArray<Node*>(num_params); Node** args = zone.NewArray<Node*>(num_params);
int64_t constant = 0x0102030405060708; int64_t constant = 0x0102030405060708;
for (int i = 0; i < num_params; i++) { for (int i = 0; i < num_params; i++) {
......
...@@ -41,10 +41,8 @@ TEST(RunOptimizedMathFloorStub) { ...@@ -41,10 +41,8 @@ TEST(RunOptimizedMathFloorStub) {
Node* start = graph.NewNode(common.Start(4)); Node* start = graph.NewNode(common.Start(4));
// Parameter 0 is the number to round // Parameter 0 is the number to round
Node* numberParam = graph.NewNode(common.Parameter(1), start); Node* numberParam = graph.NewNode(common.Parameter(1), start);
Unique<HeapObject> u = Unique<HeapObject>::CreateImmovable(code); Node* theCode = graph.NewNode(common.HeapConstant(code));
Node* theCode = graph.NewNode(common.HeapConstant(u)); Node* vector = graph.NewNode(common.HeapConstant(tv));
Unique<HeapObject> tvu = Unique<HeapObject>::CreateImmovable(tv);
Node* vector = graph.NewNode(common.HeapConstant(tvu));
Node* dummyContext = graph.NewNode(common.NumberConstant(0.0)); Node* dummyContext = graph.NewNode(common.NumberConstant(0.0));
Node* call = Node* call =
graph.NewNode(common.Call(descriptor), theCode, js.UndefinedConstant(), graph.NewNode(common.Call(descriptor), theCode, js.UndefinedConstant(),
...@@ -83,8 +81,7 @@ TEST(RunStringLengthTFStub) { ...@@ -83,8 +81,7 @@ TEST(RunStringLengthTFStub) {
Node* nameParam = graph.NewNode(common.Parameter(2), start); Node* nameParam = graph.NewNode(common.Parameter(2), start);
Node* slotParam = graph.NewNode(common.Parameter(3), start); Node* slotParam = graph.NewNode(common.Parameter(3), start);
Node* vectorParam = graph.NewNode(common.Parameter(4), start); Node* vectorParam = graph.NewNode(common.Parameter(4), start);
Unique<HeapObject> u = Unique<HeapObject>::CreateImmovable(code); Node* theCode = graph.NewNode(common.HeapConstant(code));
Node* theCode = graph.NewNode(common.HeapConstant(u));
Node* dummyContext = graph.NewNode(common.NumberConstant(0.0)); Node* dummyContext = graph.NewNode(common.NumberConstant(0.0));
Node* call = Node* call =
graph.NewNode(common.Call(descriptor), theCode, receiverParam, nameParam, graph.NewNode(common.Call(descriptor), theCode, receiverParam, nameParam,
...@@ -127,8 +124,7 @@ TEST(RunStringAddTFStub) { ...@@ -127,8 +124,7 @@ TEST(RunStringAddTFStub) {
// Parameter 0 is the receiver // Parameter 0 is the receiver
Node* leftParam = graph.NewNode(common.Parameter(1), start); Node* leftParam = graph.NewNode(common.Parameter(1), start);
Node* rightParam = graph.NewNode(common.Parameter(2), start); Node* rightParam = graph.NewNode(common.Parameter(2), start);
Unique<HeapObject> u = Unique<HeapObject>::CreateImmovable(code); Node* theCode = graph.NewNode(common.HeapConstant(code));
Node* theCode = graph.NewNode(common.HeapConstant(u));
Node* dummyContext = graph.NewNode(common.NumberConstant(0.0)); Node* dummyContext = graph.NewNode(common.NumberConstant(0.0));
Node* call = graph.NewNode(common.Call(descriptor), theCode, leftParam, Node* call = graph.NewNode(common.Call(descriptor), theCode, leftParam,
rightParam, dummyContext, start, start); rightParam, dummyContext, start, start);
......
...@@ -47,9 +47,9 @@ class ValueHelper { ...@@ -47,9 +47,9 @@ class ValueHelper {
CHECK_EQ(expected, OpParameter<int32_t>(node)); CHECK_EQ(expected, OpParameter<int32_t>(node));
} }
void CheckHeapConstant(Object* expected, Node* node) { void CheckHeapConstant(HeapObject* expected, Node* node) {
CHECK_EQ(IrOpcode::kHeapConstant, node->opcode()); CHECK_EQ(IrOpcode::kHeapConstant, node->opcode());
CHECK_EQ(expected, *OpParameter<Unique<Object> >(node).handle()); CHECK_EQ(expected, *OpParameter<Handle<HeapObject>>(node));
} }
void CheckTrue(Node* node) { void CheckTrue(Node* node) {
......
...@@ -45,10 +45,9 @@ class ChangeLoweringTest : public TypedGraphTest { ...@@ -45,10 +45,9 @@ class ChangeLoweringTest : public TypedGraphTest {
Matcher<Node*> IsAllocateHeapNumber(const Matcher<Node*>& effect_matcher, Matcher<Node*> IsAllocateHeapNumber(const Matcher<Node*>& effect_matcher,
const Matcher<Node*>& control_matcher) { const Matcher<Node*>& control_matcher) {
return IsCall(_, IsHeapConstant(Unique<HeapObject>::CreateImmovable( return IsCall(
AllocateHeapNumberStub(isolate()).GetCode())), _, IsHeapConstant(AllocateHeapNumberStub(isolate()).GetCode()),
IsNumberConstant(BitEq(0.0)), effect_matcher, IsNumberConstant(BitEq(0.0)), effect_matcher, control_matcher);
control_matcher);
} }
Matcher<Node*> IsChangeInt32ToSmi(const Matcher<Node*>& value_matcher) { Matcher<Node*> IsChangeInt32ToSmi(const Matcher<Node*>& value_matcher) {
return Is64() ? IsWord64Shl(IsChangeInt32ToInt64(value_matcher), return Is64() ? IsWord64Shl(IsChangeInt32ToInt64(value_matcher),
......
...@@ -51,33 +51,25 @@ Node* GraphTest::NumberConstant(volatile double value) { ...@@ -51,33 +51,25 @@ Node* GraphTest::NumberConstant(volatile double value) {
Node* GraphTest::HeapConstant(const Handle<HeapObject>& value) { Node* GraphTest::HeapConstant(const Handle<HeapObject>& value) {
return HeapConstant(Unique<HeapObject>::CreateUninitialized(value));
}
Node* GraphTest::HeapConstant(const Unique<HeapObject>& value) {
Node* node = graph()->NewNode(common()->HeapConstant(value)); Node* node = graph()->NewNode(common()->HeapConstant(value));
Type* type = Type::Constant(value.handle(), zone()); Type* type = Type::Constant(value, zone());
NodeProperties::SetBounds(node, Bounds(type)); NodeProperties::SetBounds(node, Bounds(type));
return node; return node;
} }
Node* GraphTest::FalseConstant() { Node* GraphTest::FalseConstant() {
return HeapConstant( return HeapConstant(factory()->false_value());
Unique<HeapObject>::CreateImmovable(factory()->false_value()));
} }
Node* GraphTest::TrueConstant() { Node* GraphTest::TrueConstant() {
return HeapConstant( return HeapConstant(factory()->true_value());
Unique<HeapObject>::CreateImmovable(factory()->true_value()));
} }
Node* GraphTest::UndefinedConstant() { Node* GraphTest::UndefinedConstant() {
return HeapConstant( return HeapConstant(factory()->undefined_value());
Unique<HeapObject>::CreateImmovable(factory()->undefined_value()));
} }
...@@ -92,20 +84,17 @@ Node* GraphTest::EmptyFrameState() { ...@@ -92,20 +84,17 @@ Node* GraphTest::EmptyFrameState() {
Matcher<Node*> GraphTest::IsFalseConstant() { Matcher<Node*> GraphTest::IsFalseConstant() {
return IsHeapConstant( return IsHeapConstant(factory()->false_value());
Unique<HeapObject>::CreateImmovable(factory()->false_value()));
} }
Matcher<Node*> GraphTest::IsTrueConstant() { Matcher<Node*> GraphTest::IsTrueConstant() {
return IsHeapConstant( return IsHeapConstant(factory()->true_value());
Unique<HeapObject>::CreateImmovable(factory()->true_value()));
} }
Matcher<Node*> GraphTest::IsUndefinedConstant() { Matcher<Node*> GraphTest::IsUndefinedConstant() {
return IsHeapConstant( return IsHeapConstant(factory()->undefined_value());
Unique<HeapObject>::CreateImmovable(factory()->undefined_value()));
} }
......
...@@ -18,8 +18,6 @@ namespace internal { ...@@ -18,8 +18,6 @@ namespace internal {
template <class T> template <class T>
class Handle; class Handle;
class HeapObject; class HeapObject;
template <class T>
class Unique;
namespace compiler { namespace compiler {
...@@ -45,7 +43,6 @@ class GraphTest : public TestWithContext, public TestWithIsolateAndZone { ...@@ -45,7 +43,6 @@ class GraphTest : public TestWithContext, public TestWithIsolateAndZone {
Node* Int64Constant(int64_t value); Node* Int64Constant(int64_t value);
Node* NumberConstant(volatile double value); Node* NumberConstant(volatile double value);
Node* HeapConstant(const Handle<HeapObject>& value); Node* HeapConstant(const Handle<HeapObject>& value);
Node* HeapConstant(const Unique<HeapObject>& value);
Node* FalseConstant(); Node* FalseConstant();
Node* TrueConstant(); Node* TrueConstant();
Node* UndefinedConstant(); Node* UndefinedConstant();
......
...@@ -154,9 +154,8 @@ TARGET_TEST_F(InterpreterAssemblerTest, Return) { ...@@ -154,9 +154,8 @@ TARGET_TEST_F(InterpreterAssemblerTest, Return) {
EXPECT_EQ(CallDescriptor::kCallCodeObject, m.call_descriptor()->kind()); EXPECT_EQ(CallDescriptor::kCallCodeObject, m.call_descriptor()->kind());
EXPECT_TRUE(m.call_descriptor()->flags() & CallDescriptor::kCanUseRoots); EXPECT_TRUE(m.call_descriptor()->flags() & CallDescriptor::kCanUseRoots);
Matcher<Unique<HeapObject>> exit_trampoline( Handle<HeapObject> exit_trampoline =
Unique<HeapObject>::CreateImmovable( isolate()->builtins()->InterpreterExitTrampoline();
isolate()->builtins()->InterpreterExitTrampoline()));
EXPECT_THAT( EXPECT_THAT(
tail_call_node, tail_call_node,
IsTailCall(m.call_descriptor(), IsHeapConstant(exit_trampoline), IsTailCall(m.call_descriptor(), IsHeapConstant(exit_trampoline),
......
...@@ -41,7 +41,7 @@ class JSBuiltinReducerTest : public TypedGraphTest { ...@@ -41,7 +41,7 @@ class JSBuiltinReducerTest : public TypedGraphTest {
JSObject::GetProperty( JSObject::GetProperty(
m, isolate()->factory()->NewStringFromAsciiChecked(name)) m, isolate()->factory()->NewStringFromAsciiChecked(name))
.ToHandleChecked()); .ToHandleChecked());
return HeapConstant(Unique<JSFunction>::CreateUninitialized(f)); return HeapConstant(f);
} }
JSOperatorBuilder* javascript() { return &javascript_; } JSOperatorBuilder* javascript() { return &javascript_; }
......
...@@ -152,7 +152,7 @@ TEST_F(JSContextRelaxationTest, ...@@ -152,7 +152,7 @@ TEST_F(JSContextRelaxationTest,
Node* const input1 = Parameter(1); Node* const input1 = Parameter(1);
Node* const context = Parameter(2); Node* const context = Parameter(2);
Node* const outer_context = Parameter(3); Node* const outer_context = Parameter(3);
const Operator* op = javascript()->CreateCatchContext(Unique<String>()); const Operator* op = javascript()->CreateCatchContext(Handle<String>());
Node* const frame_state_1 = Node* const frame_state_1 =
ShallowFrameStateChain(outer_context, CALL_MAINTAINS_NATIVE_CONTEXT); ShallowFrameStateChain(outer_context, CALL_MAINTAINS_NATIVE_CONTEXT);
Node* const effect = graph()->start(); Node* const effect = graph()->start();
......
...@@ -82,8 +82,7 @@ class JSTypeFeedbackTest : public TypedGraphTest { ...@@ -82,8 +82,7 @@ class JSTypeFeedbackTest : public TypedGraphTest {
Node* vector = UndefinedConstant(); Node* vector = UndefinedConstant();
Node* context = UndefinedConstant(); Node* context = UndefinedConstant();
Unique<Name> name = Unique<Name>::CreateUninitialized( Handle<Name> name = isolate()->factory()->InternalizeUtf8String(string);
isolate()->factory()->InternalizeUtf8String(string));
const Operator* op = javascript()->LoadGlobal(name, feedback); const Operator* op = javascript()->LoadGlobal(name, feedback);
Node* load = graph()->NewNode(op, context, global, vector, context); Node* load = graph()->NewNode(op, context, global, vector, context);
if (mode == JSTypeFeedbackSpecializer::kDeoptimizationEnabled) { if (mode == JSTypeFeedbackSpecializer::kDeoptimizationEnabled) {
...@@ -193,10 +192,9 @@ TEST_F(JSTypeFeedbackTest, JSLoadNamedGlobalConstNumberWithDeoptimization) { ...@@ -193,10 +192,9 @@ TEST_F(JSTypeFeedbackTest, JSLoadNamedGlobalConstNumberWithDeoptimization) {
TEST_F(JSTypeFeedbackTest, JSLoadNamedGlobalConstString) { TEST_F(JSTypeFeedbackTest, JSLoadNamedGlobalConstString) {
Unique<HeapObject> kValue = Unique<HeapObject>::CreateImmovable( Handle<HeapObject> kValue = isolate()->factory()->undefined_string();
isolate()->factory()->undefined_string());
const char* kName = "mango"; const char* kName = "mango";
SetGlobalProperty(kName, kValue.handle()); SetGlobalProperty(kName, kValue);
Node* ret = ReturnLoadNamedFromGlobal( Node* ret = ReturnLoadNamedFromGlobal(
kName, graph()->start(), graph()->start(), kName, graph()->start(), graph()->start(),
...@@ -211,10 +209,9 @@ TEST_F(JSTypeFeedbackTest, JSLoadNamedGlobalConstString) { ...@@ -211,10 +209,9 @@ TEST_F(JSTypeFeedbackTest, JSLoadNamedGlobalConstString) {
TEST_F(JSTypeFeedbackTest, JSLoadNamedGlobalConstStringWithDeoptimization) { TEST_F(JSTypeFeedbackTest, JSLoadNamedGlobalConstStringWithDeoptimization) {
Unique<HeapObject> kValue = Unique<HeapObject>::CreateImmovable( Handle<HeapObject> kValue = isolate()->factory()->undefined_string();
isolate()->factory()->undefined_string());
const char* kName = "mango"; const char* kName = "mango";
SetGlobalProperty(kName, kValue.handle()); SetGlobalProperty(kName, kValue);
Node* ret = ReturnLoadNamedFromGlobal( Node* ret = ReturnLoadNamedFromGlobal(
kName, graph()->start(), graph()->start(), kName, graph()->start(), graph()->start(),
...@@ -277,7 +274,7 @@ TEST_F(JSTypeFeedbackTest, JSLoadNamedGlobalPropertyCellSmiWithDeoptimization) { ...@@ -277,7 +274,7 @@ TEST_F(JSTypeFeedbackTest, JSLoadNamedGlobalPropertyCellSmiWithDeoptimization) {
HeapObjectMatcher cell(cell_capture.value()); HeapObjectMatcher cell(cell_capture.value());
EXPECT_TRUE(cell.HasValue()); EXPECT_TRUE(cell.HasValue());
EXPECT_TRUE(cell.Value().handle()->IsPropertyCell()); EXPECT_TRUE(cell.Value()->IsPropertyCell());
EXPECT_THAT(ret, EXPECT_THAT(ret,
IsReturn(load_field_match, load_field_match, graph()->start())); IsReturn(load_field_match, load_field_match, graph()->start()));
...@@ -329,7 +326,7 @@ TEST_F(JSTypeFeedbackTest, ...@@ -329,7 +326,7 @@ TEST_F(JSTypeFeedbackTest,
HeapObjectMatcher cell(cell_capture.value()); HeapObjectMatcher cell(cell_capture.value());
EXPECT_TRUE(cell.HasValue()); EXPECT_TRUE(cell.HasValue());
EXPECT_TRUE(cell.Value().handle()->IsPropertyCell()); EXPECT_TRUE(cell.Value()->IsPropertyCell());
EXPECT_THAT(ret, EXPECT_THAT(ret,
IsReturn(load_field_match, load_field_match, graph()->start())); IsReturn(load_field_match, load_field_match, graph()->start()));
......
...@@ -235,14 +235,12 @@ TEST_F(JSTypedLoweringTest, ParameterWithNull) { ...@@ -235,14 +235,12 @@ TEST_F(JSTypedLoweringTest, ParameterWithNull) {
{ {
Reduction r = Reduce(Parameter(Type::Constant(null, zone()))); Reduction r = Reduce(Parameter(Type::Constant(null, zone())));
ASSERT_TRUE(r.Changed()); ASSERT_TRUE(r.Changed());
EXPECT_THAT(r.replacement(), EXPECT_THAT(r.replacement(), IsHeapConstant(null));
IsHeapConstant(Unique<HeapObject>::CreateImmovable(null)));
} }
{ {
Reduction r = Reduce(Parameter(Type::Null())); Reduction r = Reduce(Parameter(Type::Null()));
ASSERT_TRUE(r.Changed()); ASSERT_TRUE(r.Changed());
EXPECT_THAT(r.replacement(), EXPECT_THAT(r.replacement(), IsHeapConstant(null));
IsHeapConstant(Unique<HeapObject>::CreateImmovable(null)));
} }
} }
...@@ -291,14 +289,12 @@ TEST_F(JSTypedLoweringTest, ParameterWithUndefined) { ...@@ -291,14 +289,12 @@ TEST_F(JSTypedLoweringTest, ParameterWithUndefined) {
{ {
Reduction r = Reduce(Parameter(Type::Undefined())); Reduction r = Reduce(Parameter(Type::Undefined()));
ASSERT_TRUE(r.Changed()); ASSERT_TRUE(r.Changed());
EXPECT_THAT(r.replacement(), EXPECT_THAT(r.replacement(), IsHeapConstant(undefined));
IsHeapConstant(Unique<HeapObject>::CreateImmovable(undefined)));
} }
{ {
Reduction r = Reduce(Parameter(Type::Constant(undefined, zone()))); Reduction r = Reduce(Parameter(Type::Constant(undefined, zone())));
ASSERT_TRUE(r.Changed()); ASSERT_TRUE(r.Changed());
EXPECT_THAT(r.replacement(), EXPECT_THAT(r.replacement(), IsHeapConstant(undefined));
IsHeapConstant(Unique<HeapObject>::CreateImmovable(undefined)));
} }
} }
...@@ -885,8 +881,8 @@ TEST_F(JSTypedLoweringTest, JSLoadGlobalConstants) { ...@@ -885,8 +881,8 @@ TEST_F(JSTypedLoweringTest, JSLoadGlobalConstants) {
Handle<String>(isolate()->heap()->nan_string(), isolate()) // -- Handle<String>(isolate()->heap()->nan_string(), isolate()) // --
}; };
Matcher<Node*> matches[] = { Matcher<Node*> matches[] = {
IsHeapConstant(Unique<HeapObject>::CreateImmovable( IsHeapConstant(
Handle<HeapObject>(isolate()->heap()->undefined_value(), isolate()))), Handle<HeapObject>(isolate()->heap()->undefined_value(), isolate())),
IsNumberConstant(std::numeric_limits<double>::infinity()), IsNumberConstant(std::numeric_limits<double>::infinity()),
IsNumberConstant(IsNaN()) // -- IsNumberConstant(IsNaN()) // --
}; };
...@@ -899,9 +895,8 @@ TEST_F(JSTypedLoweringTest, JSLoadGlobalConstants) { ...@@ -899,9 +895,8 @@ TEST_F(JSTypedLoweringTest, JSLoadGlobalConstants) {
Node* control = graph()->start(); Node* control = graph()->start();
for (size_t i = 0; i < arraysize(names); i++) { for (size_t i = 0; i < arraysize(names); i++) {
Unique<Name> name = Unique<Name>::CreateImmovable(names[i]);
Reduction r = Reduce(graph()->NewNode( Reduction r = Reduce(graph()->NewNode(
javascript()->LoadGlobal(name, feedback), context, global, vector, javascript()->LoadGlobal(names[i], feedback), context, global, vector,
context, EmptyFrameState(), EmptyFrameState(), effect, control)); context, EmptyFrameState(), EmptyFrameState(), effect, control));
ASSERT_TRUE(r.Changed()); ASSERT_TRUE(r.Changed());
...@@ -916,7 +911,7 @@ TEST_F(JSTypedLoweringTest, JSLoadGlobalConstants) { ...@@ -916,7 +911,7 @@ TEST_F(JSTypedLoweringTest, JSLoadGlobalConstants) {
TEST_F(JSTypedLoweringTest, JSLoadNamedStringLength) { TEST_F(JSTypedLoweringTest, JSLoadNamedStringLength) {
VectorSlotPair feedback; VectorSlotPair feedback;
Unique<Name> name = Unique<Name>::CreateImmovable(factory()->length_string()); Handle<Name> name = factory()->length_string();
Node* const receiver = Parameter(Type::String(), 0); Node* const receiver = Parameter(Type::String(), 0);
Node* const vector = Parameter(Type::Internal(), 1); Node* const vector = Parameter(Type::Internal(), 1);
Node* const context = UndefinedConstant(); Node* const context = UndefinedConstant();
...@@ -1022,11 +1017,10 @@ TEST_F(JSTypedLoweringTest, JSAddWithString) { ...@@ -1022,11 +1017,10 @@ TEST_F(JSTypedLoweringTest, JSAddWithString) {
rhs, context, frame_state0, rhs, context, frame_state0,
frame_state1, effect, control)); frame_state1, effect, control));
ASSERT_TRUE(r.Changed()); ASSERT_TRUE(r.Changed());
EXPECT_THAT( EXPECT_THAT(r.replacement(),
r.replacement(), IsCall(_, IsHeapConstant(CodeFactory::StringAdd(
IsCall(_, IsHeapConstant(Unique<HeapObject>::CreateImmovable( isolate(), STRING_ADD_CHECK_NONE,
CodeFactory::StringAdd(isolate(), STRING_ADD_CHECK_NONE, NOT_TENURED).code()),
NOT_TENURED).code())),
lhs, rhs, context, frame_state0, effect, control)); lhs, rhs, context, frame_state0, effect, control));
} }
} }
...@@ -1045,14 +1039,11 @@ TEST_F(JSTypedLoweringTest, JSCreateClosure) { ...@@ -1045,14 +1039,11 @@ TEST_F(JSTypedLoweringTest, JSCreateClosure) {
Reduce(graph()->NewNode(javascript()->CreateClosure(shared, NOT_TENURED), Reduce(graph()->NewNode(javascript()->CreateClosure(shared, NOT_TENURED),
context, context, effect, control)); context, context, effect, control));
ASSERT_TRUE(r.Changed()); ASSERT_TRUE(r.Changed());
EXPECT_THAT( EXPECT_THAT(r.replacement(),
r.replacement(), IsCall(_, IsHeapConstant(CodeFactory::FastNewClosure(
IsCall(_, isolate(), shared->language_mode(),
IsHeapConstant(Unique<HeapObject>::CreateImmovable( shared->kind()).code()),
CodeFactory::FastNewClosure(isolate(), shared->language_mode(), IsHeapConstant(shared), effect, control));
shared->kind()).code())),
IsHeapConstant(Unique<HeapObject>::CreateImmovable(shared)),
effect, control));
} }
...@@ -1074,8 +1065,8 @@ TEST_F(JSTypedLoweringTest, JSCreateLiteralArray) { ...@@ -1074,8 +1065,8 @@ TEST_F(JSTypedLoweringTest, JSCreateLiteralArray) {
ASSERT_TRUE(r.Changed()); ASSERT_TRUE(r.Changed());
EXPECT_THAT( EXPECT_THAT(
r.replacement(), r.replacement(),
IsCall(_, IsHeapConstant(Unique<HeapObject>::CreateImmovable( IsCall(_, IsHeapConstant(
CodeFactory::FastCloneShallowArray(isolate()).code())), CodeFactory::FastCloneShallowArray(isolate()).code()),
input0, input1, input2, context, frame_state, effect, control)); input0, input1, input2, context, frame_state, effect, control));
} }
...@@ -1098,8 +1089,8 @@ TEST_F(JSTypedLoweringTest, JSCreateLiteralObject) { ...@@ -1098,8 +1089,8 @@ TEST_F(JSTypedLoweringTest, JSCreateLiteralObject) {
ASSERT_TRUE(r.Changed()); ASSERT_TRUE(r.Changed());
EXPECT_THAT( EXPECT_THAT(
r.replacement(), r.replacement(),
IsCall(_, IsHeapConstant(Unique<HeapObject>::CreateImmovable( IsCall(_, IsHeapConstant(
CodeFactory::FastCloneShallowObject(isolate(), 6).code())), CodeFactory::FastCloneShallowObject(isolate(), 6).code()),
input0, input1, input2, _, context, frame_state, effect, control)); input0, input1, input2, _, context, frame_state, effect, control));
} }
......
...@@ -21,6 +21,11 @@ using testing::StringMatchResultListener; ...@@ -21,6 +21,11 @@ using testing::StringMatchResultListener;
namespace v8 { namespace v8 {
namespace internal { namespace internal {
bool operator==(Handle<HeapObject> const& lhs, Handle<HeapObject> const& rhs) {
return lhs.is_identical_to(rhs);
}
namespace compiler { namespace compiler {
namespace { namespace {
...@@ -1528,10 +1533,9 @@ Matcher<Node*> IsExternalConstant( ...@@ -1528,10 +1533,9 @@ Matcher<Node*> IsExternalConstant(
} }
Matcher<Node*> IsHeapConstant( Matcher<Node*> IsHeapConstant(Handle<HeapObject> value) {
const Matcher<Unique<HeapObject> >& value_matcher) { return MakeMatcher(new IsConstantMatcher<Handle<HeapObject>>(
return MakeMatcher(new IsConstantMatcher<Unique<HeapObject> >( IrOpcode::kHeapConstant, value));
IrOpcode::kHeapConstant, value_matcher));
} }
......
...@@ -14,9 +14,9 @@ namespace internal { ...@@ -14,9 +14,9 @@ namespace internal {
// Forward declarations. // Forward declarations.
class ExternalReference; class ExternalReference;
template <typename T>
class Handle;
class HeapObject; class HeapObject;
template <class T>
class Unique;
template <class> template <class>
class TypeImpl; class TypeImpl;
struct ZoneTypeConfig; struct ZoneTypeConfig;
...@@ -73,8 +73,7 @@ Matcher<Node*> IsTerminate(const Matcher<Node*>& effect_matcher, ...@@ -73,8 +73,7 @@ Matcher<Node*> IsTerminate(const Matcher<Node*>& effect_matcher,
const Matcher<Node*>& control_matcher); const Matcher<Node*>& control_matcher);
Matcher<Node*> IsExternalConstant( Matcher<Node*> IsExternalConstant(
const Matcher<ExternalReference>& value_matcher); const Matcher<ExternalReference>& value_matcher);
Matcher<Node*> IsHeapConstant( Matcher<Node*> IsHeapConstant(Handle<HeapObject> value);
const Matcher<Unique<HeapObject> >& value_matcher);
Matcher<Node*> IsFloat32Constant(const Matcher<float>& value_matcher); Matcher<Node*> IsFloat32Constant(const Matcher<float>& value_matcher);
Matcher<Node*> IsFloat64Constant(const Matcher<double>& value_matcher); Matcher<Node*> IsFloat64Constant(const Matcher<double>& value_matcher);
Matcher<Node*> IsInt32Constant(const Matcher<int32_t>& value_matcher); Matcher<Node*> IsInt32Constant(const Matcher<int32_t>& value_matcher);
......
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