Remove deprecated PrintableUnique.

R=bmeurer@chromium.org

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

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@23697 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
mstarzinger@chromium.org 2014-09-04 13:45:05 +00:00
parent 2b6f5d6a9a
commit 4539e9b936
18 changed files with 93 additions and 180 deletions

View File

@ -900,7 +900,7 @@ void AstGraphBuilder::VisitObjectLiteral(ObjectLiteral* expr) {
if (property->emit_store()) { if (property->emit_store()) {
VisitForValue(property->value()); VisitForValue(property->value());
Node* value = environment()->Pop(); Node* value = environment()->Pop();
PrintableUnique<Name> name = MakeUnique(key->AsPropertyName()); Unique<Name> name = MakeUnique(key->AsPropertyName());
Node* store = NewNode(javascript()->StoreNamed(strict_mode(), name), Node* store = NewNode(javascript()->StoreNamed(strict_mode(), name),
literal, value); literal, value);
PrepareFrameState(store, key->id()); PrepareFrameState(store, key->id());
@ -1025,7 +1025,7 @@ void AstGraphBuilder::VisitForInAssignment(Expression* expr, Node* value) {
VisitForValue(property->obj()); VisitForValue(property->obj());
Node* object = environment()->Pop(); Node* object = environment()->Pop();
value = environment()->Pop(); value = environment()->Pop();
PrintableUnique<Name> name = Unique<Name> name =
MakeUnique(property->key()->AsLiteral()->AsPropertyName()); MakeUnique(property->key()->AsLiteral()->AsPropertyName());
Node* store = Node* store =
NewNode(javascript()->StoreNamed(strict_mode(), name), object, value); NewNode(javascript()->StoreNamed(strict_mode(), name), object, value);
@ -1084,7 +1084,7 @@ void AstGraphBuilder::VisitAssignment(Assignment* expr) {
} }
case NAMED_PROPERTY: { case NAMED_PROPERTY: {
Node* object = environment()->Top(); Node* object = environment()->Top();
PrintableUnique<Name> name = Unique<Name> name =
MakeUnique(property->key()->AsLiteral()->AsPropertyName()); MakeUnique(property->key()->AsLiteral()->AsPropertyName());
old_value = NewNode(javascript()->LoadNamed(name), object); old_value = NewNode(javascript()->LoadNamed(name), object);
PrepareFrameState(old_value, property->LoadId(), kPushOutput); PrepareFrameState(old_value, property->LoadId(), kPushOutput);
@ -1120,7 +1120,7 @@ void AstGraphBuilder::VisitAssignment(Assignment* expr) {
} }
case NAMED_PROPERTY: { case NAMED_PROPERTY: {
Node* object = environment()->Pop(); Node* object = environment()->Pop();
PrintableUnique<Name> name = Unique<Name> name =
MakeUnique(property->key()->AsLiteral()->AsPropertyName()); MakeUnique(property->key()->AsLiteral()->AsPropertyName());
Node* store = Node* store =
NewNode(javascript()->StoreNamed(strict_mode(), name), object, value); NewNode(javascript()->StoreNamed(strict_mode(), name), object, value);
@ -1165,8 +1165,7 @@ void AstGraphBuilder::VisitProperty(Property* expr) {
if (expr->key()->IsPropertyName()) { if (expr->key()->IsPropertyName()) {
VisitForValue(expr->obj()); VisitForValue(expr->obj());
Node* object = environment()->Pop(); Node* object = environment()->Pop();
PrintableUnique<Name> name = Unique<Name> name = MakeUnique(expr->key()->AsLiteral()->AsPropertyName());
MakeUnique(expr->key()->AsLiteral()->AsPropertyName());
value = NewNode(javascript()->LoadNamed(name), object); value = NewNode(javascript()->LoadNamed(name), object);
} else { } else {
VisitForValue(expr->obj()); VisitForValue(expr->obj());
@ -1212,7 +1211,7 @@ void AstGraphBuilder::VisitCall(Call* expr) {
VisitForValue(property->obj()); VisitForValue(property->obj());
Node* object = environment()->Top(); Node* object = environment()->Top();
if (property->key()->IsPropertyName()) { if (property->key()->IsPropertyName()) {
PrintableUnique<Name> name = Unique<Name> name =
MakeUnique(property->key()->AsLiteral()->AsPropertyName()); MakeUnique(property->key()->AsLiteral()->AsPropertyName());
callee_value = NewNode(javascript()->LoadNamed(name), object); callee_value = NewNode(javascript()->LoadNamed(name), object);
} else { } else {
@ -1302,7 +1301,7 @@ void AstGraphBuilder::VisitCallJSRuntime(CallRuntime* expr) {
// before arguments are being evaluated. // before arguments are being evaluated.
CallFunctionFlags flags = NO_CALL_FUNCTION_FLAGS; CallFunctionFlags flags = NO_CALL_FUNCTION_FLAGS;
Node* receiver_value = BuildLoadBuiltinsObject(); Node* receiver_value = BuildLoadBuiltinsObject();
PrintableUnique<String> unique = MakeUnique(name); Unique<String> unique = MakeUnique(name);
Node* callee_value = NewNode(javascript()->LoadNamed(unique), receiver_value); Node* callee_value = NewNode(javascript()->LoadNamed(unique), receiver_value);
// TODO(jarin): Find/create a bailout id to deoptimize to (crankshaft // TODO(jarin): Find/create a bailout id to deoptimize to (crankshaft
// refuses to optimize functions with jsruntime calls). // refuses to optimize functions with jsruntime calls).
@ -1385,7 +1384,7 @@ void AstGraphBuilder::VisitCountOperation(CountOperation* expr) {
case NAMED_PROPERTY: { case NAMED_PROPERTY: {
VisitForValue(property->obj()); VisitForValue(property->obj());
Node* object = environment()->Top(); Node* object = environment()->Top();
PrintableUnique<Name> name = Unique<Name> name =
MakeUnique(property->key()->AsLiteral()->AsPropertyName()); MakeUnique(property->key()->AsLiteral()->AsPropertyName());
old_value = NewNode(javascript()->LoadNamed(name), object); old_value = NewNode(javascript()->LoadNamed(name), object);
PrepareFrameState(old_value, property->LoadId(), kPushOutput); PrepareFrameState(old_value, property->LoadId(), kPushOutput);
@ -1427,7 +1426,7 @@ void AstGraphBuilder::VisitCountOperation(CountOperation* expr) {
} }
case NAMED_PROPERTY: { case NAMED_PROPERTY: {
Node* object = environment()->Pop(); Node* object = environment()->Pop();
PrintableUnique<Name> name = Unique<Name> name =
MakeUnique(property->key()->AsLiteral()->AsPropertyName()); MakeUnique(property->key()->AsLiteral()->AsPropertyName());
Node* store = Node* store =
NewNode(javascript()->StoreNamed(strict_mode(), name), object, value); NewNode(javascript()->StoreNamed(strict_mode(), name), object, value);
@ -1746,7 +1745,7 @@ Node* AstGraphBuilder::BuildVariableLoad(Variable* variable,
case Variable::UNALLOCATED: { case Variable::UNALLOCATED: {
// Global var, const, or let variable. // Global var, const, or let variable.
Node* global = BuildLoadGlobalObject(); Node* global = BuildLoadGlobalObject();
PrintableUnique<Name> name = MakeUnique(variable->name()); Unique<Name> name = MakeUnique(variable->name());
Operator* op = javascript()->LoadNamed(name, contextual_mode); Operator* op = javascript()->LoadNamed(name, contextual_mode);
Node* node = NewNode(op, global); Node* node = NewNode(op, global);
PrepareFrameState(node, bailout_id, kPushOutput); PrepareFrameState(node, bailout_id, kPushOutput);
@ -1847,7 +1846,7 @@ Node* AstGraphBuilder::BuildVariableAssignment(Variable* variable, Node* value,
case Variable::UNALLOCATED: { case Variable::UNALLOCATED: {
// Global var, const, or let variable. // Global var, const, or let variable.
Node* global = BuildLoadGlobalObject(); Node* global = BuildLoadGlobalObject();
PrintableUnique<Name> name = MakeUnique(variable->name()); Unique<Name> name = MakeUnique(variable->name());
Operator* op = javascript()->StoreNamed(strict_mode(), name); Operator* op = javascript()->StoreNamed(strict_mode(), name);
Node* store = NewNode(op, global, value); Node* store = NewNode(op, global, value);
PrepareFrameState(store, bailout_id); PrepareFrameState(store, bailout_id);

View File

@ -87,8 +87,8 @@ class ChangeLoweringTest : public GraphTest {
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( return IsCall(
_, IsHeapConstant(PrintableUnique<HeapObject>::CreateImmovable( _, IsHeapConstant(Unique<HeapObject>::CreateImmovable(
zone(), CEntryStub(isolate(), 1).GetCode())), CEntryStub(isolate(), 1).GetCode())),
IsExternalConstant(ExternalReference( IsExternalConstant(ExternalReference(
Runtime::FunctionForId(Runtime::kAllocateHeapNumber), isolate())), Runtime::FunctionForId(Runtime::kAllocateHeapNumber), isolate())),
IsInt32Constant(0), IsNumberConstant(0.0), effect_matcher, IsInt32Constant(0), IsNumberConstant(0.0), effect_matcher,

View File

@ -138,8 +138,8 @@ class CommonOperatorBuilder {
Operator1<double>(IrOpcode::kNumberConstant, Operator::kPure, 0, 1, Operator1<double>(IrOpcode::kNumberConstant, Operator::kPure, 0, 1,
"NumberConstant", value); "NumberConstant", value);
} }
Operator* HeapConstant(PrintableUnique<Object> value) { Operator* HeapConstant(Unique<Object> value) {
return new (zone_) Operator1<PrintableUnique<Object> >( return new (zone_) Operator1<Unique<Object> >(
IrOpcode::kHeapConstant, Operator::kPure, 0, 1, "HeapConstant", value); IrOpcode::kHeapConstant, Operator::kPure, 0, 1, "HeapConstant", value);
} }
Operator* Phi(int arguments) { Operator* Phi(int arguments) {
@ -289,23 +289,23 @@ struct CommonOperatorTraits<ExternalReference> {
}; };
template <typename T> template <typename T>
struct CommonOperatorTraits<PrintableUnique<T> > { struct CommonOperatorTraits<Unique<T> > {
static inline bool HasValue(const Operator* op) { static inline bool HasValue(const Operator* op) {
return op->opcode() == IrOpcode::kHeapConstant; return op->opcode() == IrOpcode::kHeapConstant;
} }
static inline PrintableUnique<T> ValueOf(const Operator* op) { static inline Unique<T> ValueOf(const Operator* op) {
CHECK_EQ(IrOpcode::kHeapConstant, op->opcode()); CHECK_EQ(IrOpcode::kHeapConstant, op->opcode());
return OpParameter<PrintableUnique<T> >(op); return OpParameter<Unique<T> >(op);
} }
}; };
template <typename T> template <typename T>
struct CommonOperatorTraits<Handle<T> > { struct CommonOperatorTraits<Handle<T> > {
static inline bool HasValue(const Operator* op) { static inline bool HasValue(const Operator* op) {
return CommonOperatorTraits<PrintableUnique<T> >::HasValue(op); return CommonOperatorTraits<Unique<T> >::HasValue(op);
} }
static inline Handle<T> ValueOf(const Operator* op) { static inline Handle<T> ValueOf(const Operator* op) {
return CommonOperatorTraits<PrintableUnique<T> >::ValueOf(op).handle(); return CommonOperatorTraits<Unique<T> >::ValueOf(op).handle();
} }
}; };

View File

@ -128,8 +128,8 @@ class StructuredGraphBuilder : public GraphBuilder {
// Helper to wrap a Handle<T> into a Unique<T>. // Helper to wrap a Handle<T> into a Unique<T>.
template <class T> template <class T>
PrintableUnique<T> MakeUnique(Handle<T> object) { Unique<T> MakeUnique(Handle<T> object) {
return PrintableUnique<T>::CreateUninitialized(zone(), object); return Unique<T>::CreateUninitialized(object);
} }
// Support for control flow builders. The concrete type of the environment // Support for control flow builders. The concrete type of the environment

View File

@ -19,9 +19,8 @@ namespace internal {
// TODO(bmeurer): Find a new home for these functions. // TODO(bmeurer): Find a new home for these functions.
template <typename T> template <typename T>
inline std::ostream& operator<<(std::ostream& os, inline std::ostream& operator<<(std::ostream& os, const Unique<T>& value) {
const PrintableUnique<T>& value) { return os << *value.handle();
return os << value.string();
} }
inline std::ostream& operator<<(std::ostream& os, inline std::ostream& operator<<(std::ostream& os,
const ExternalReference& value) { const ExternalReference& value) {
@ -65,32 +64,32 @@ Node* GraphTest::NumberConstant(double value) {
} }
Node* GraphTest::HeapConstant(const PrintableUnique<HeapObject>& value) { Node* GraphTest::HeapConstant(const Unique<HeapObject>& value) {
return graph()->NewNode(common()->HeapConstant(value)); return graph()->NewNode(common()->HeapConstant(value));
} }
Node* GraphTest::FalseConstant() { Node* GraphTest::FalseConstant() {
return HeapConstant(PrintableUnique<HeapObject>::CreateImmovable( return HeapConstant(
zone(), factory()->false_value())); Unique<HeapObject>::CreateImmovable(factory()->false_value()));
} }
Node* GraphTest::TrueConstant() { Node* GraphTest::TrueConstant() {
return HeapConstant(PrintableUnique<HeapObject>::CreateImmovable( return HeapConstant(
zone(), factory()->true_value())); Unique<HeapObject>::CreateImmovable(factory()->true_value()));
} }
Matcher<Node*> GraphTest::IsFalseConstant() { Matcher<Node*> GraphTest::IsFalseConstant() {
return IsHeapConstant(PrintableUnique<HeapObject>::CreateImmovable( return IsHeapConstant(
zone(), factory()->false_value())); Unique<HeapObject>::CreateImmovable(factory()->false_value()));
} }
Matcher<Node*> GraphTest::IsTrueConstant() { Matcher<Node*> GraphTest::IsTrueConstant() {
return IsHeapConstant(PrintableUnique<HeapObject>::CreateImmovable( return IsHeapConstant(
zone(), factory()->true_value())); Unique<HeapObject>::CreateImmovable(factory()->true_value()));
} }
namespace { namespace {
@ -640,8 +639,8 @@ Matcher<Node*> IsExternalConstant(
Matcher<Node*> IsHeapConstant( Matcher<Node*> IsHeapConstant(
const Matcher<PrintableUnique<HeapObject> >& value_matcher) { const Matcher<Unique<HeapObject> >& value_matcher) {
return MakeMatcher(new IsConstantMatcher<PrintableUnique<HeapObject> >( return MakeMatcher(new IsConstantMatcher<Unique<HeapObject> >(
IrOpcode::kHeapConstant, value_matcher)); IrOpcode::kHeapConstant, value_matcher));
} }

View File

@ -17,7 +17,7 @@ namespace internal {
// Forward declarations. // Forward declarations.
class HeapObject; class HeapObject;
template <class T> template <class T>
class PrintableUnique; class Unique;
namespace compiler { namespace compiler {
@ -35,7 +35,7 @@ class GraphTest : public TestWithContext, public TestWithZone {
Node* Int32Constant(int32_t value); Node* Int32Constant(int32_t value);
Node* Int64Constant(int64_t value); Node* Int64Constant(int64_t value);
Node* NumberConstant(double value); Node* NumberConstant(double value);
Node* HeapConstant(const PrintableUnique<HeapObject>& value); Node* HeapConstant(const Unique<HeapObject>& value);
Node* FalseConstant(); Node* FalseConstant();
Node* TrueConstant(); Node* TrueConstant();
@ -64,7 +64,7 @@ Matcher<Node*> IsFinish(const Matcher<Node*>& value_matcher,
Matcher<Node*> IsExternalConstant( Matcher<Node*> IsExternalConstant(
const Matcher<ExternalReference>& value_matcher); const Matcher<ExternalReference>& value_matcher);
Matcher<Node*> IsHeapConstant( Matcher<Node*> IsHeapConstant(
const Matcher<PrintableUnique<HeapObject> >& value_matcher); const Matcher<Unique<HeapObject> >& 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);
Matcher<Node*> IsInt64Constant(const Matcher<int64_t>& value_matcher); Matcher<Node*> IsInt64Constant(const Matcher<int64_t>& value_matcher);

View File

@ -11,8 +11,7 @@ namespace internal {
namespace compiler { namespace compiler {
Node* JSGraph::ImmovableHeapConstant(Handle<Object> object) { Node* JSGraph::ImmovableHeapConstant(Handle<Object> object) {
PrintableUnique<Object> unique = Unique<Object> unique = Unique<Object>::CreateImmovable(object);
PrintableUnique<Object>::CreateImmovable(zone(), object);
return NewNode(common()->HeapConstant(unique)); return NewNode(common()->HeapConstant(unique));
} }
@ -94,7 +93,7 @@ Node* JSGraph::NaNConstant() {
} }
Node* JSGraph::HeapConstant(PrintableUnique<Object> value) { Node* JSGraph::HeapConstant(Unique<Object> value) {
// TODO(turbofan): canonicalize heap constants using Unique<T> // TODO(turbofan): canonicalize heap constants using Unique<T>
return NewNode(common()->HeapConstant(value)); return NewNode(common()->HeapConstant(value));
} }
@ -104,13 +103,11 @@ Node* JSGraph::HeapConstant(Handle<Object> value) {
// 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( // return HeapConstant(Unique<Object>::CreateUninitialized(value));
// PrintableUnique<Object>::CreateUninitialized(zone(), value));
// TODO(turbofan): This is a work-around to make Unique::HashCode() work for // 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 // value numbering. We need some sane way to compute a unique hash code for
// arbitrary handles here. // arbitrary handles here.
PrintableUnique<Object> unique( Unique<Object> unique(reinterpret_cast<Address>(*value.location()), value);
zone(), reinterpret_cast<Address>(*value.location()), value);
return HeapConstant(unique); return HeapConstant(unique);
} }

View File

@ -42,7 +42,7 @@ class JSGraph : public ZoneObject {
// Creates a HeapConstant node, possibly canonicalized, without inspecting the // Creates a HeapConstant node, possibly canonicalized, without inspecting the
// object. // object.
Node* HeapConstant(PrintableUnique<Object> value); Node* HeapConstant(Unique<Object> 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.

View File

@ -40,7 +40,7 @@ class ContextAccess {
// Defines the property being loaded from an object by a named load. This is // Defines the property being loaded from an object by a named load. This is
// used as a parameter by JSLoadNamed operators. // used as a parameter by JSLoadNamed operators.
struct LoadNamedParameters { struct LoadNamedParameters {
PrintableUnique<Name> name; Unique<Name> name;
ContextualMode contextual_mode; ContextualMode contextual_mode;
}; };
@ -55,7 +55,7 @@ struct CallParameters {
// used as a parameter by JSStoreNamed operators. // used as a parameter by JSStoreNamed operators.
struct StoreNamedParameters { struct StoreNamedParameters {
StrictMode strict_mode; StrictMode strict_mode;
PrintableUnique<Name> name; Unique<Name> name;
}; };
// Interface for building JavaScript-level operators, e.g. directly from the // Interface for building JavaScript-level operators, e.g. directly from the
@ -124,7 +124,7 @@ class JSOperatorBuilder {
} }
Operator* LoadProperty() { BINOP(JSLoadProperty); } Operator* LoadProperty() { BINOP(JSLoadProperty); }
Operator* LoadNamed(PrintableUnique<Name> name, Operator* LoadNamed(Unique<Name> name,
ContextualMode contextual_mode = NOT_CONTEXTUAL) { ContextualMode contextual_mode = NOT_CONTEXTUAL) {
LoadNamedParameters parameters = {name, contextual_mode}; LoadNamedParameters parameters = {name, contextual_mode};
OP1(JSLoadNamed, LoadNamedParameters, parameters, Operator::kNoProperties, OP1(JSLoadNamed, LoadNamedParameters, parameters, Operator::kNoProperties,
@ -136,7 +136,7 @@ class JSOperatorBuilder {
0); 0);
} }
Operator* StoreNamed(StrictMode strict_mode, PrintableUnique<Name> name) { Operator* StoreNamed(StrictMode strict_mode, Unique<Name> name) {
StoreNamedParameters parameters = {strict_mode, name}; StoreNamedParameters parameters = {strict_mode, name};
OP1(JSStoreNamed, StoreNamedParameters, parameters, Operator::kNoProperties, OP1(JSStoreNamed, StoreNamedParameters, parameters, Operator::kNoProperties,
2, 0); 2, 0);
@ -165,9 +165,9 @@ class JSOperatorBuilder {
// 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.
Operator* CreateFunctionContext() { NOPROPS(JSCreateFunctionContext, 1, 1); } Operator* CreateFunctionContext() { NOPROPS(JSCreateFunctionContext, 1, 1); }
Operator* CreateCatchContext(PrintableUnique<String> name) { Operator* CreateCatchContext(Unique<String> name) {
OP1(JSCreateCatchContext, PrintableUnique<String>, name, OP1(JSCreateCatchContext, Unique<String>, name, Operator::kNoProperties, 1,
Operator::kNoProperties, 1, 1); 1);
} }
Operator* CreateWithContext() { NOPROPS(JSCreateWithContext, 2, 1); } Operator* CreateWithContext() { NOPROPS(JSCreateWithContext, 2, 1); }
Operator* CreateBlockContext() { NOPROPS(JSCreateBlockContext, 2, 1); } Operator* CreateBlockContext() { NOPROPS(JSCreateBlockContext, 2, 1); }

View File

@ -55,8 +55,7 @@ class MachineNodeFactory {
return NEW_NODE_0(COMMON()->Float64Constant(value)); return NEW_NODE_0(COMMON()->Float64Constant(value));
} }
Node* HeapConstant(Handle<Object> object) { Node* HeapConstant(Handle<Object> object) {
PrintableUnique<Object> val = Unique<Object> val = Unique<Object>::CreateUninitialized(object);
PrintableUnique<Object>::CreateUninitialized(ZONE(), object);
return NEW_NODE_0(COMMON()->HeapConstant(val)); return NEW_NODE_0(COMMON()->HeapConstant(val));
} }

View File

@ -94,13 +94,12 @@ typedef FloatMatcher<double> Float64Matcher;
// A pattern matcher for heap object constants. // A pattern matcher for heap object constants.
struct HeapObjectMatcher FINAL struct HeapObjectMatcher FINAL : public ValueMatcher<Handle<HeapObject> > {
: public ValueMatcher<PrintableUnique<HeapObject> > {
explicit HeapObjectMatcher(Node* node) explicit HeapObjectMatcher(Node* node)
: ValueMatcher<PrintableUnique<HeapObject> >(node) {} : ValueMatcher<Handle<HeapObject> >(node) {}
bool IsKnownGlobal(HeapObject* global) const { bool IsKnownGlobal(Handle<HeapObject> global) const {
return HasValue() && Value().IsKnownGlobal(global); return HasValue() && Value().is_identical_to(global);
} }
}; };

View File

@ -178,32 +178,26 @@ struct StaticParameterTraits<double> {
} }
}; };
// Specialization for static parameters of type {PrintableUnique<Object>}. // Specialization for static parameters of type {Unique<Object>}.
template <> template <>
struct StaticParameterTraits<PrintableUnique<Object> > { struct StaticParameterTraits<Unique<Object> > {
static OStream& PrintTo(OStream& os, PrintableUnique<Object> val) { // NOLINT static OStream& PrintTo(OStream& os, Unique<Object> val) { // NOLINT
return os << val.string(); return os << Brief(*val.handle());
} }
static int HashCode(PrintableUnique<Object> a) { static int HashCode(Unique<Object> a) {
return static_cast<int>(a.Hashcode()); return static_cast<int>(a.Hashcode());
} }
static bool Equals(PrintableUnique<Object> a, PrintableUnique<Object> b) { static bool Equals(Unique<Object> a, Unique<Object> b) { return a == b; }
return a == b;
}
}; };
// Specialization for static parameters of type {PrintableUnique<Name>}. // Specialization for static parameters of type {Unique<Name>}.
template <> template <>
struct StaticParameterTraits<PrintableUnique<Name> > { struct StaticParameterTraits<Unique<Name> > {
static OStream& PrintTo(OStream& os, PrintableUnique<Name> val) { // NOLINT static OStream& PrintTo(OStream& os, Unique<Name> val) { // NOLINT
return os << val.string(); return os << Brief(*val.handle());
}
static int HashCode(PrintableUnique<Name> a) {
return static_cast<int>(a.Hashcode());
}
static bool Equals(PrintableUnique<Name> a, PrintableUnique<Name> b) {
return a == b;
} }
static int HashCode(Unique<Name> a) { return static_cast<int>(a.Hashcode()); }
static bool Equals(Unique<Name> a, Unique<Name> b) { return a == b; }
}; };
#if DEBUG #if DEBUG
@ -212,15 +206,15 @@ struct StaticParameterTraits<PrintableUnique<Name> > {
template <> template <>
struct StaticParameterTraits<Handle<Object> > { struct StaticParameterTraits<Handle<Object> > {
static OStream& PrintTo(OStream& os, Handle<Object> val) { // NOLINT static OStream& PrintTo(OStream& os, Handle<Object> val) { // NOLINT
UNREACHABLE(); // Should use PrintableUnique<Object> instead UNREACHABLE(); // Should use Unique<Object> instead
return os; return os;
} }
static int HashCode(Handle<Object> a) { static int HashCode(Handle<Object> a) {
UNREACHABLE(); // Should use PrintableUnique<Object> instead UNREACHABLE(); // Should use Unique<Object> instead
return 0; return 0;
} }
static bool Equals(Handle<Object> a, Handle<Object> b) { static bool Equals(Handle<Object> a, Handle<Object> b) {
UNREACHABLE(); // Should use PrintableUnique<Object> instead UNREACHABLE(); // Should use Unique<Object> instead
return false; return false;
} }
}; };
@ -267,7 +261,7 @@ class Operator1 : public Operator {
}; };
// Type definitions for operators with specific types of parameters. // Type definitions for operators with specific types of parameters.
typedef Operator1<PrintableUnique<Name> > NameOperator; typedef Operator1<Unique<Name> > NameOperator;
// Helper to extract parameters from Operator1<*> operator. // Helper to extract parameters from Operator1<*> operator.

View File

@ -58,8 +58,8 @@ class RawMachineAssembler : public GraphBuilder,
MachineSignature* machine_sig() const { return machine_sig_; } MachineSignature* machine_sig() const { return machine_sig_; }
Node* UndefinedConstant() { Node* UndefinedConstant() {
PrintableUnique<Object> unique = PrintableUnique<Object>::CreateImmovable( Unique<Object> unique = Unique<Object>::CreateImmovable(
zone(), isolate()->factory()->undefined_value()); isolate()->factory()->undefined_value());
return NewNode(common()->HeapConstant(unique)); return NewNode(common()->HeapConstant(unique));
} }

View File

@ -19,10 +19,10 @@ Reduction SimplifiedOperatorReducer::Reduce(Node* node) {
switch (node->opcode()) { switch (node->opcode()) {
case IrOpcode::kBooleanNot: { case IrOpcode::kBooleanNot: {
HeapObjectMatcher m(node->InputAt(0)); HeapObjectMatcher m(node->InputAt(0));
if (m.IsKnownGlobal(heap()->false_value())) { if (m.IsKnownGlobal(factory()->false_value())) {
return Replace(jsgraph()->TrueConstant()); return Replace(jsgraph()->TrueConstant());
} }
if (m.IsKnownGlobal(heap()->true_value())) { if (m.IsKnownGlobal(factory()->true_value())) {
return Replace(jsgraph()->FalseConstant()); return Replace(jsgraph()->FalseConstant());
} }
if (m.IsBooleanNot()) return Replace(m.node()->InputAt(0)); if (m.IsBooleanNot()) return Replace(m.node()->InputAt(0));
@ -37,8 +37,8 @@ Reduction SimplifiedOperatorReducer::Reduce(Node* node) {
} }
case IrOpcode::kChangeBoolToBit: { case IrOpcode::kChangeBoolToBit: {
HeapObjectMatcher m(node->InputAt(0)); HeapObjectMatcher m(node->InputAt(0));
if (m.IsKnownGlobal(heap()->false_value())) return ReplaceInt32(0); if (m.IsKnownGlobal(factory()->false_value())) return ReplaceInt32(0);
if (m.IsKnownGlobal(heap()->true_value())) return ReplaceInt32(1); if (m.IsKnownGlobal(factory()->true_value())) return ReplaceInt32(1);
if (m.IsChangeBitToBool()) return Replace(m.node()->InputAt(0)); if (m.IsChangeBitToBool()) return Replace(m.node()->InputAt(0));
break; break;
} }
@ -128,8 +128,8 @@ Reduction SimplifiedOperatorReducer::ReplaceNumber(int32_t value) {
Graph* SimplifiedOperatorReducer::graph() const { return jsgraph()->graph(); } Graph* SimplifiedOperatorReducer::graph() const { return jsgraph()->graph(); }
Heap* SimplifiedOperatorReducer::heap() const { Factory* SimplifiedOperatorReducer::factory() const {
return jsgraph()->isolate()->heap(); return jsgraph()->isolate()->factory();
} }
} // namespace compiler } // namespace compiler

View File

@ -38,7 +38,7 @@ class SimplifiedOperatorReducer FINAL : public Reducer {
Reduction ReplaceNumber(int32_t value); Reduction ReplaceNumber(int32_t value);
Graph* graph() const; Graph* graph() const;
Heap* heap() const; Factory* factory() const;
JSGraph* jsgraph() const { return jsgraph_; } JSGraph* jsgraph() const { return jsgraph_; }
MachineOperatorBuilder* machine() const { return machine_; } MachineOperatorBuilder* machine() const { return machine_; }

View File

@ -118,8 +118,6 @@ class Unique {
friend class UniqueSet<T>; // Uses internal details for speed. friend class UniqueSet<T>; // Uses internal details for speed.
template <class U> template <class U>
friend class Unique; // For comparing raw_address values. friend class Unique; // For comparing raw_address values.
template <class U>
friend class PrintableUnique; // For automatic up casting.
protected: protected:
Unique<T>() : raw_address_(NULL) { } Unique<T>() : raw_address_(NULL) { }
@ -131,73 +129,6 @@ class Unique {
}; };
// TODO(danno): At some point if all of the uses of Unique end up using
// PrintableUnique, then we should merge PrintableUnique into Unique and
// predicate generating the printable string on a "am I tracing" check.
template <class T>
class PrintableUnique : public Unique<T> {
public:
// TODO(titzer): make private and introduce a uniqueness scope.
PrintableUnique() : string_("null") {}
// TODO(titzer): make private and introduce a uniqueness scope.
explicit PrintableUnique(Zone* zone, Handle<T> handle) : Unique<T>(handle) {
InitializeString(zone);
}
// TODO(titzer): this is a hack to migrate to Unique<T> incrementally.
PrintableUnique(Zone* zone, Address raw_address, Handle<T> handle)
: Unique<T>(raw_address, handle) {
InitializeString(zone);
}
// Constructor for handling automatic up casting.
// Eg. PrintableUnique<JSFunction> can be passed when PrintableUnique<Object>
// is expected.
template <class S>
PrintableUnique(PrintableUnique<S> uniq) // NOLINT
: Unique<T>(Handle<T>()) {
#ifdef DEBUG
T* a = NULL;
S* b = NULL;
a = b; // Fake assignment to enforce type checks.
USE(a);
#endif
this->raw_address_ = uniq.raw_address_;
this->handle_ = uniq.handle_;
string_ = uniq.string();
}
// TODO(titzer): this is a hack to migrate to Unique<T> incrementally.
static PrintableUnique<T> CreateUninitialized(Zone* zone, Handle<T> handle) {
return PrintableUnique<T>(zone, reinterpret_cast<Address>(NULL), handle);
}
static PrintableUnique<T> CreateImmovable(Zone* zone, Handle<T> handle) {
return PrintableUnique<T>(zone, reinterpret_cast<Address>(*handle), handle);
}
const char* string() const { return string_; }
private:
const char* string_;
void InitializeString(Zone* zone) {
// The stringified version of the parameter must be calculated when the
// Operator is constructed to avoid accessing the heap.
HeapStringAllocator temp_allocator;
StringStream stream(&temp_allocator);
this->handle_->ShortPrint(&stream);
SmartArrayPointer<const char> desc_string = stream.ToCString();
const char* desc_chars = desc_string.get();
int length = static_cast<int>(strlen(desc_chars));
char* desc_copy = zone->NewArray<char>(length + 1);
memcpy(desc_copy, desc_chars, length + 1);
string_ = desc_copy;
}
};
template <typename T> template <typename T>
class UniqueSet FINAL : public ZoneObject { class UniqueSet FINAL : public ZoneObject {
public: public:

View File

@ -135,13 +135,13 @@ class TrivialDeoptCodegenTester : public DeoptCodegenTester {
Handle<JSFunction> deopt_function = Handle<JSFunction> deopt_function =
NewFunction("function deopt() { %DeoptimizeFunction(foo); }; deopt"); NewFunction("function deopt() { %DeoptimizeFunction(foo); }; deopt");
PrintableUnique<Object> deopt_fun_constant = Unique<Object> deopt_fun_constant =
PrintableUnique<Object>::CreateUninitialized(zone(), deopt_function); Unique<Object>::CreateUninitialized(deopt_function);
Node* deopt_fun_node = m.NewNode(common.HeapConstant(deopt_fun_constant)); Node* deopt_fun_node = m.NewNode(common.HeapConstant(deopt_fun_constant));
Handle<Context> context(deopt_function->context(), CcTest::i_isolate()); Handle<Context> context(deopt_function->context(), CcTest::i_isolate());
PrintableUnique<Object> context_constant = Unique<Object> context_constant =
PrintableUnique<Object>::CreateUninitialized(zone(), context); Unique<Object>::CreateUninitialized(context);
Node* context_node = m.NewNode(common.HeapConstant(context_constant)); Node* context_node = m.NewNode(common.HeapConstant(context_constant));
bailout_id = GetCallBailoutId(); bailout_id = GetCallBailoutId();
@ -244,13 +244,13 @@ class TrivialRuntimeDeoptCodegenTester : public DeoptCodegenTester {
CSignature1<Object*, Object*> sig; CSignature1<Object*, Object*> sig;
RawMachineAssembler m(graph, &sig); RawMachineAssembler m(graph, &sig);
PrintableUnique<Object> this_fun_constant = Unique<Object> this_fun_constant =
PrintableUnique<Object>::CreateUninitialized(zone(), function); Unique<Object>::CreateUninitialized(function);
Node* this_fun_node = m.NewNode(common.HeapConstant(this_fun_constant)); Node* this_fun_node = m.NewNode(common.HeapConstant(this_fun_constant));
Handle<Context> context(function->context(), CcTest::i_isolate()); Handle<Context> context(function->context(), CcTest::i_isolate());
PrintableUnique<Object> context_constant = Unique<Object> context_constant =
PrintableUnique<Object>::CreateUninitialized(zone(), context); Unique<Object>::CreateUninitialized(context);
Node* context_node = m.NewNode(common.HeapConstant(context_constant)); Node* context_node = m.NewNode(common.HeapConstant(context_constant));
bailout_id = GetCallBailoutId(); bailout_id = GetCallBailoutId();

View File

@ -680,8 +680,7 @@ TEST(BuildScheduleIfSplitWithEffects) {
Handle<Object> object = Handle<Object> object =
Handle<Object>(isolate->heap()->undefined_value(), isolate); Handle<Object>(isolate->heap()->undefined_value(), isolate);
PrintableUnique<Object> unique_constant = Unique<Object> unique_constant = Unique<Object>::CreateUninitialized(object);
PrintableUnique<Object>::CreateUninitialized(scope.main_zone(), object);
// Manually transcripted code for: // Manually transcripted code for:
// function turbo_fan_test(a, b, c, y) { // function turbo_fan_test(a, b, c, y) {
@ -826,8 +825,7 @@ TEST(BuildScheduleSimpleLoop) {
Handle<Object> object = Handle<Object> object =
Handle<Object>(isolate->heap()->undefined_value(), isolate); Handle<Object>(isolate->heap()->undefined_value(), isolate);
PrintableUnique<Object> unique_constant = Unique<Object> unique_constant = Unique<Object>::CreateUninitialized(object);
PrintableUnique<Object>::CreateUninitialized(scope.main_zone(), object);
// Manually transcripted code for: // Manually transcripted code for:
// function turbo_fan_test(a, b) { // function turbo_fan_test(a, b) {
@ -939,8 +937,7 @@ TEST(BuildScheduleComplexLoops) {
Handle<Object> object = Handle<Object> object =
Handle<Object>(isolate->heap()->undefined_value(), isolate); Handle<Object>(isolate->heap()->undefined_value(), isolate);
PrintableUnique<Object> unique_constant = Unique<Object> unique_constant = Unique<Object>::CreateUninitialized(object);
PrintableUnique<Object>::CreateUninitialized(scope.main_zone(), object);
// Manually transcripted code for: // Manually transcripted code for:
// function turbo_fan_test(a, b, c) { // function turbo_fan_test(a, b, c) {
@ -1187,8 +1184,7 @@ TEST(BuildScheduleBreakAndContinue) {
Handle<Object> object = Handle<Object> object =
Handle<Object>(isolate->heap()->undefined_value(), isolate); Handle<Object>(isolate->heap()->undefined_value(), isolate);
PrintableUnique<Object> unique_constant = Unique<Object> unique_constant = Unique<Object>::CreateUninitialized(object);
PrintableUnique<Object>::CreateUninitialized(scope.main_zone(), object);
// Manually transcripted code for: // Manually transcripted code for:
// function turbo_fan_test(a, b, c) { // function turbo_fan_test(a, b, c) {
@ -1518,8 +1514,7 @@ TEST(BuildScheduleSimpleLoopWithCodeMotion) {
Handle<Object> object = Handle<Object> object =
Handle<Object>(isolate->heap()->undefined_value(), isolate); Handle<Object>(isolate->heap()->undefined_value(), isolate);
PrintableUnique<Object> unique_constant = Unique<Object> unique_constant = Unique<Object>::CreateUninitialized(object);
PrintableUnique<Object>::CreateUninitialized(scope.main_zone(), object);
// Manually transcripted code for: // Manually transcripted code for:
// function turbo_fan_test(a, b, c) { // function turbo_fan_test(a, b, c) {