[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}
This commit is contained in:
mstarzinger 2015-08-31 01:24:52 -07:00 committed by Commit bot
parent f4f3b431b9
commit 6e65e6db6c
49 changed files with 251 additions and 276 deletions

View File

@ -1420,7 +1420,7 @@ void AstGraphBuilder::VisitTryCatchStatement(TryCatchStatement* stmt) {
// Create a catch scope that binds the exception.
Node* exception = try_control.GetExceptionNode();
Unique<String> name = MakeUnique(stmt->variable()->name());
Handle<String> name = stmt->variable()->name();
const Operator* op = javascript()->CreateCatchContext(name);
Node* context = NewNode(op, exception, GetFunctionClosureForContext());
@ -3617,8 +3617,7 @@ Node* AstGraphBuilder::BuildKeyedLoad(Node* object, Node* key,
Node* AstGraphBuilder::BuildNamedLoad(Node* object, Handle<Name> name,
const VectorSlotPair& feedback) {
const Operator* op =
javascript()->LoadNamed(MakeUnique(name), feedback, language_mode());
const Operator* op = javascript()->LoadNamed(name, feedback, language_mode());
Node* node = NewNode(op, object, BuildLoadFeedbackVector());
return Record(js_type_feedback_, node, feedback.slot());
}
@ -3641,7 +3640,7 @@ Node* AstGraphBuilder::BuildNamedStore(Node* object, Handle<Name> name,
const VectorSlotPair& feedback,
TypeFeedbackId id) {
const Operator* op =
javascript()->StoreNamed(language_mode(), MakeUnique(name), feedback);
javascript()->StoreNamed(language_mode(), name, feedback);
Node* node = NewNode(op, object, value, BuildLoadFeedbackVector());
if (FLAG_vector_stores) {
return Record(js_type_feedback_, node, feedback.slot());
@ -3701,8 +3700,8 @@ Node* AstGraphBuilder::BuildGlobalLoad(Node* script_context, Node* global,
Handle<Name> name,
const VectorSlotPair& feedback,
TypeofMode typeof_mode, int slot_index) {
const Operator* op = javascript()->LoadGlobal(MakeUnique(name), feedback,
typeof_mode, slot_index);
const Operator* op =
javascript()->LoadGlobal(name, feedback, typeof_mode, slot_index);
Node* node = NewNode(op, script_context, global, BuildLoadFeedbackVector());
return Record(js_type_feedback_, node, feedback.slot());
}
@ -3712,8 +3711,8 @@ Node* AstGraphBuilder::BuildGlobalStore(Node* script_context, Node* global,
Handle<Name> name, Node* value,
const VectorSlotPair& feedback,
TypeFeedbackId id, int slot_index) {
const Operator* op = javascript()->StoreGlobal(
language_mode(), MakeUnique(name), feedback, slot_index);
const Operator* op =
javascript()->StoreGlobal(language_mode(), name, feedback, slot_index);
Node* node =
NewNode(op, script_context, global, value, BuildLoadFeedbackVector());
if (FLAG_vector_stores) {
@ -3798,7 +3797,7 @@ Node* AstGraphBuilder::BuildToBoolean(Node* input) {
return jsgraph_->BooleanConstant(!m.Is(0) && !m.IsNaN());
}
case IrOpcode::kHeapConstant: {
Handle<HeapObject> object = HeapObjectMatcher(input).Value().handle();
Handle<HeapObject> object = HeapObjectMatcher(input).Value();
return jsgraph_->BooleanConstant(object->BooleanValue());
}
case IrOpcode::kJSEqual:

View File

@ -230,12 +230,6 @@ class AstGraphBuilder : public AstVisitor {
// frame states with the undefined values.
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);
// Named and keyed loads require a VectorSlotPair for successful lowering.

View File

@ -33,8 +33,7 @@ Decision DecideCondition(Node* const cond) {
}
case IrOpcode::kHeapConstant: {
HeapObjectMatcher mcond(cond);
return mcond.Value().handle()->BooleanValue() ? Decision::kTrue
: Decision::kFalse;
return mcond.Value()->BooleanValue() ? Decision::kTrue : Decision::kFalse;
}
default:
return Decision::kUnknown;

View File

@ -575,12 +575,14 @@ const Operator* CommonOperatorBuilder::NumberConstant(volatile double value) {
const Operator* CommonOperatorBuilder::HeapConstant(
const Unique<HeapObject>& value) {
return new (zone()) Operator1<Unique<HeapObject>>( // --
IrOpcode::kHeapConstant, Operator::kPure, // opcode
"HeapConstant", // name
0, 0, 0, 1, 0, 0, // counts
value); // parameter
const Handle<HeapObject>& value) {
return new (zone())
Operator1<Handle<HeapObject>, Handle<HeapObject>::equal_to,
Handle<HeapObject>::hash>( // --
IrOpcode::kHeapConstant, Operator::kPure, // opcode
"HeapConstant", // name
0, 0, 0, 1, 0, 0, // counts
value); // parameter
}

View File

@ -139,7 +139,7 @@ class CommonOperatorBuilder final : public ZoneObject {
const Operator* Float64Constant(volatile double);
const Operator* ExternalConstant(const ExternalReference&);
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* Phi(MachineType type, int value_input_count);

View File

@ -36,9 +36,9 @@ class IA32OperandGenerator final : public OperandGenerator {
case IrOpcode::kHeapConstant: {
// Constants in new space cannot be used as immediates in V8 because
// the GC does not scan code objects when collecting the new generation.
Unique<HeapObject> value = OpParameter<Unique<HeapObject> >(node);
Isolate* isolate = value.handle()->GetIsolate();
return !isolate->heap()->InNewSpace(*value.handle());
Handle<HeapObject> value = OpParameter<Handle<HeapObject>>(node);
Isolate* isolate = value->GetIsolate();
return !isolate->heap()->InNewSpace(*value);
}
default:
return false;

View File

@ -183,7 +183,7 @@ class OperandGenerator {
case IrOpcode::kExternalConstant:
return Constant(OpParameter<ExternalReference>(node));
case IrOpcode::kHeapConstant:
return Constant(OpParameter<Unique<HeapObject> >(node).handle());
return Constant(OpParameter<Handle<HeapObject>>(node));
default:
break;
}

View File

@ -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);
}
@ -258,8 +258,7 @@ Node* InterpreterAssembler::CallJSBuiltin(int context_index, Node* receiver,
void InterpreterAssembler::Return() {
Node* exit_trampoline_code_object =
HeapConstant(Unique<HeapObject>::CreateImmovable(
isolate()->builtins()->InterpreterExitTrampoline()));
HeapConstant(isolate()->builtins()->InterpreterExitTrampoline());
// If the order of the parameters you need to change the call signature below.
STATIC_ASSERT(0 == Linkage::kInterpreterAccumulatorParameter);
STATIC_ASSERT(1 == Linkage::kInterpreterRegisterFileParameter);

View File

@ -59,7 +59,7 @@ class InterpreterAssembler {
Node* Int32Constant(int value);
Node* IntPtrConstant(intptr_t value);
Node* NumberConstant(double value);
Node* HeapConstant(Unique<HeapObject> object);
Node* HeapConstant(Handle<HeapObject> object);
// Tag and untag Smi values.
Node* SmiTag(Node* value);

View File

@ -25,8 +25,8 @@ class JSCallReduction {
bool HasBuiltinFunctionId() {
if (node_->opcode() != IrOpcode::kJSCallFunction) return false;
HeapObjectMatcher m(NodeProperties::GetValueInput(node_, 0));
if (!m.HasValue() || !m.Value().handle()->IsJSFunction()) return false;
Handle<JSFunction> function = Handle<JSFunction>::cast(m.Value().handle());
if (!m.HasValue() || !m.Value()->IsJSFunction()) return false;
Handle<JSFunction> function = Handle<JSFunction>::cast(m.Value());
return function->shared()->HasBuiltinFunctionId();
}
@ -34,7 +34,7 @@ class JSCallReduction {
BuiltinFunctionId GetBuiltinFunctionId() {
DCHECK_EQ(IrOpcode::kJSCallFunction, node_->opcode());
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();
}

View File

@ -35,8 +35,7 @@ MaybeHandle<Context> JSContextSpecialization::GetSpecializationContext(
Node* const object = NodeProperties::GetValueInput(node, 0);
switch (object->opcode()) {
case IrOpcode::kHeapConstant:
return Handle<Context>::cast(
OpParameter<Unique<HeapObject>>(object).handle());
return Handle<Context>::cast(OpParameter<Handle<HeapObject>>(object));
case IrOpcode::kParameter: {
Node* const start = NodeProperties::GetValueInput(object, 0);
DCHECK_EQ(IrOpcode::kStart, start->opcode());

View File

@ -535,7 +535,7 @@ void JSGenericLowering::LowerJSCreateLiteralObject(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));
ReplaceWithRuntimeCall(node, Runtime::kPushCatchContext);
}

View File

@ -12,8 +12,7 @@ namespace internal {
namespace compiler {
Node* JSGraph::ImmovableHeapConstant(Handle<HeapObject> object) {
Unique<HeapObject> unique = Unique<HeapObject>::CreateImmovable(object);
return graph()->NewNode(common()->HeapConstant(unique));
return graph()->NewNode(common()->HeapConstant(object));
}
@ -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) {
// TODO(turbofan): canonicalize heap constants using <magic approach>.
// TODO(titzer): We could also match against the addresses of immortable
// immovables here, even without access to the heap, thus always
// canonicalizing references to them.
// return HeapConstant(Unique<Object>::CreateUninitialized(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);
return graph()->NewNode(common()->HeapConstant(value));
}

View File

@ -45,10 +45,6 @@ class JSGraph : public ZoneObject {
Node* OneConstant();
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
// heap to inspect the object.
Node* HeapConstant(Handle<HeapObject> value);

View File

@ -243,9 +243,8 @@ Reduction JSInliner::Reduce(Node* node) {
HeapObjectMatcher match(call.jsfunction());
if (!match.HasValue()) return NoChange();
if (!match.Value().handle()->IsJSFunction()) return NoChange();
Handle<JSFunction> function =
Handle<JSFunction>::cast(match.Value().handle());
if (!match.Value()->IsJSFunction()) return NoChange();
Handle<JSFunction> function = Handle<JSFunction>::cast(match.Value());
if (mode_ == kRestrictedInlining && !function->shared()->force_inline()) {
return NoChange();
}

View File

@ -177,11 +177,11 @@ Reduction JSIntrinsicLowering::ReduceHeapObjectGetMap(Node* node) {
Reduction JSIntrinsicLowering::ReduceIncrementStatsCounter(Node* node) {
if (!FLAG_native_code_counters) return ChangeToUndefined(node);
HeapObjectMatcher m(NodeProperties::GetValueInput(node, 0));
if (!m.HasValue() || !m.Value().handle()->IsString()) {
if (!m.HasValue() || !m.Value()->IsString()) {
return ChangeToUndefined(node);
}
base::SmartArrayPointer<char> name =
Handle<String>::cast(m.Value().handle())->ToCString();
Handle<String>::cast(m.Value())->ToCString();
StatsCounter counter(jsgraph()->isolate(), name.get());
if (!counter.Enabled()) return ChangeToUndefined(node);

View File

@ -196,7 +196,7 @@ DynamicContextAccess const& DynamicContextAccessOf(Operator const* op) {
bool operator==(LoadNamedParameters const& lhs,
LoadNamedParameters const& rhs) {
return lhs.name() == rhs.name() &&
return lhs.name().location() == rhs.name().location() &&
lhs.language_mode() == rhs.language_mode() &&
lhs.feedback() == rhs.feedback();
}
@ -209,12 +209,13 @@ bool operator!=(LoadNamedParameters const& lhs,
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) {
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) {
bool operator==(LoadGlobalParameters const& lhs,
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.slot_index() == rhs.slot_index();
}
@ -268,12 +270,13 @@ bool operator!=(LoadGlobalParameters const& lhs,
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) {
return os << Brief(*p.name().handle()) << ", " << p.typeof_mode()
return os << Brief(*p.name()) << ", " << p.typeof_mode()
<< ", slot: " << p.slot_index();
}
@ -287,7 +290,8 @@ const LoadGlobalParameters& LoadGlobalParametersOf(const Operator* op) {
bool operator==(StoreGlobalParameters const& lhs,
StoreGlobalParameters const& rhs) {
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();
}
@ -299,13 +303,13 @@ bool operator!=(StoreGlobalParameters const& lhs,
size_t hash_value(StoreGlobalParameters const& p) {
return base::hash_combine(p.language_mode(), p.name(), p.feedback(),
p.slot_index());
return base::hash_combine(p.language_mode(), p.name().location(),
p.feedback(), p.slot_index());
}
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();
}
@ -319,7 +323,8 @@ const StoreGlobalParameters& StoreGlobalParametersOf(const Operator* op) {
bool operator==(StoreNamedParameters const& lhs,
StoreNamedParameters const& rhs) {
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,
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) {
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) {
}
const Operator* JSOperatorBuilder::LoadNamed(const Unique<Name>& name,
const Operator* JSOperatorBuilder::LoadNamed(const Handle<Name>& name,
const VectorSlotPair& feedback,
LanguageMode language_mode) {
LoadNamedParameters parameters(name, feedback, language_mode);
@ -583,7 +589,7 @@ const Operator* JSOperatorBuilder::LoadProperty(const VectorSlotPair& feedback,
const Operator* JSOperatorBuilder::StoreNamed(LanguageMode language_mode,
const Unique<Name>& name,
const Handle<Name>& name,
const VectorSlotPair& feedback) {
StoreNamedParameters parameters(language_mode, feedback, name);
return new (zone()) Operator1<StoreNamedParameters>( // --
@ -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,
TypeofMode typeof_mode,
int slot_index) {
@ -628,7 +634,7 @@ const Operator* JSOperatorBuilder::LoadGlobal(const Unique<Name>& name,
const Operator* JSOperatorBuilder::StoreGlobal(LanguageMode language_mode,
const Unique<Name>& name,
const Handle<Name>& name,
const VectorSlotPair& feedback,
int slot_index) {
StoreGlobalParameters parameters(language_mode, feedback, name, slot_index);
@ -718,8 +724,9 @@ const Operator* JSOperatorBuilder::CreateLiteralObject(int literal_flags) {
const Operator* JSOperatorBuilder::CreateCatchContext(
const Unique<String>& name) {
return new (zone()) Operator1<Unique<String>>( // --
const Handle<String>& name) {
return new (zone()) Operator1<Handle<String>, Handle<String>::equal_to,
Handle<String>::hash>( // --
IrOpcode::kJSCreateCatchContext, Operator::kNoProperties, // opcode
"JSCreateCatchContext", // name
2, 1, 1, 1, 1, 2, // counts

View File

@ -236,17 +236,17 @@ DynamicContextAccess const& DynamicContextAccessOf(Operator const*);
// used as a parameter by JSLoadNamed operators.
class LoadNamedParameters final {
public:
LoadNamedParameters(const Unique<Name>& name, const VectorSlotPair& feedback,
LoadNamedParameters(const Handle<Name>& name, const VectorSlotPair& feedback,
LanguageMode 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_; }
const VectorSlotPair& feedback() const { return feedback_; }
private:
const Unique<Name> name_;
const Handle<Name> name_;
const VectorSlotPair feedback_;
const LanguageMode language_mode_;
};
@ -265,14 +265,14 @@ const LoadNamedParameters& LoadNamedParametersOf(const Operator* op);
// used as a parameter by JSLoadGlobal operator.
class LoadGlobalParameters final {
public:
LoadGlobalParameters(const Unique<Name>& name, const VectorSlotPair& feedback,
LoadGlobalParameters(const Handle<Name>& name, const VectorSlotPair& feedback,
TypeofMode typeof_mode, int slot_index)
: name_(name),
feedback_(feedback),
typeof_mode_(typeof_mode),
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_; }
const VectorSlotPair& feedback() const { return feedback_; }
@ -280,7 +280,7 @@ class LoadGlobalParameters final {
int slot_index() const { return slot_index_; }
private:
const Unique<Name> name_;
const Handle<Name> name_;
const VectorSlotPair feedback_;
const TypeofMode typeof_mode_;
const int slot_index_;
@ -302,7 +302,7 @@ class StoreGlobalParameters final {
public:
StoreGlobalParameters(LanguageMode language_mode,
const VectorSlotPair& feedback,
const Unique<Name>& name, int slot_index)
const Handle<Name>& name, int slot_index)
: language_mode_(language_mode),
name_(name),
feedback_(feedback),
@ -310,12 +310,12 @@ class StoreGlobalParameters final {
LanguageMode language_mode() const { return language_mode_; }
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_; }
private:
const LanguageMode language_mode_;
const Unique<Name> name_;
const Handle<Name> name_;
const VectorSlotPair feedback_;
int slot_index_;
};
@ -362,16 +362,16 @@ const LoadPropertyParameters& LoadPropertyParametersOf(const Operator* op);
class StoreNamedParameters final {
public:
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) {}
LanguageMode language_mode() const { return language_mode_; }
const VectorSlotPair& feedback() const { return feedback_; }
const Unique<Name>& name() const { return name_; }
const Handle<Name>& name() const { return name_; }
private:
const LanguageMode language_mode_;
const Unique<Name> name_;
const Handle<Name> name_;
const VectorSlotPair feedback_;
};
@ -488,26 +488,26 @@ class JSOperatorBuilder final : public ZoneObject {
const Operator* LoadProperty(const VectorSlotPair& feedback,
LanguageMode language_mode);
const Operator* LoadNamed(const Unique<Name>& name,
const Operator* LoadNamed(const Handle<Name>& name,
const VectorSlotPair& feedback,
LanguageMode language_mode);
const Operator* StoreProperty(LanguageMode language_mode,
const VectorSlotPair& feedback);
const Operator* StoreNamed(LanguageMode language_mode,
const Unique<Name>& name,
const Handle<Name>& name,
const VectorSlotPair& feedback);
const Operator* DeleteProperty(LanguageMode language_mode);
const Operator* HasProperty();
const Operator* LoadGlobal(const Unique<Name>& name,
const Operator* LoadGlobal(const Handle<Name>& name,
const VectorSlotPair& feedback,
TypeofMode typeof_mode = NOT_INSIDE_TYPEOF,
int slot_index = -1);
const Operator* StoreGlobal(LanguageMode language_mode,
const Unique<Name>& name,
const Handle<Name>& name,
const VectorSlotPair& feedback,
int slot_index = -1);
@ -534,7 +534,7 @@ class JSOperatorBuilder final : public ZoneObject {
// TODO(titzer): nail down the static parts of each of these context flavors.
const Operator* CreateFunctionContext();
const Operator* CreateCatchContext(const Unique<String>& name);
const Operator* CreateCatchContext(const Handle<String>& name);
const Operator* CreateWithContext();
const Operator* CreateBlockContext();
const Operator* CreateModuleContext();

View File

@ -43,7 +43,7 @@ Reduction JSTypeFeedbackLowering::ReduceJSLoadNamed(Node* node) {
LoadNamedParameters const& p = LoadNamedParametersOf(node->op());
Handle<TypeFeedbackVector> vector;
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());
MapHandleList maps;
if (nexus.ExtractMaps(&maps) > 0) {

View File

@ -146,7 +146,6 @@ Reduction JSTypeFeedbackSpecializer::ReduceJSLoadNamed(Node* node) {
if (frame_state_before == nullptr) return NoChange();
const LoadNamedParameters& p = LoadNamedParametersOf(node->op());
Handle<Name> name = p.name().handle();
SmallMapList maps;
FeedbackVectorICSlot slot = js_type_feedback_->FindFeedbackVectorICSlot(node);
@ -155,7 +154,7 @@ Reduction JSTypeFeedbackSpecializer::ReduceJSLoadNamed(Node* node) {
// No type feedback ids or the load is uninitialized.
return NoChange();
}
oracle()->PropertyReceiverTypes(slot, name, &maps);
oracle()->PropertyReceiverTypes(slot, p.name(), &maps);
Node* receiver = node->InputAt(0);
Node* effect = NodeProperties::GetEffectInput(node);
@ -165,7 +164,7 @@ Reduction JSTypeFeedbackSpecializer::ReduceJSLoadNamed(Node* node) {
Handle<Map> map = maps.first();
FieldAccess field_access;
if (!GetInObjectFieldAccess(LOAD, map, name, &field_access)) {
if (!GetInObjectFieldAccess(LOAD, map, p.name(), &field_access)) {
return NoChange();
}
@ -191,7 +190,7 @@ Reduction JSTypeFeedbackSpecializer::ReduceJSLoadNamed(Node* node) {
Reduction JSTypeFeedbackSpecializer::ReduceJSLoadGlobal(Node* node) {
DCHECK(node->opcode() == IrOpcode::kJSLoadGlobal);
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.
Handle<Object> constant_value =
jsgraph()->isolate()->factory()->GlobalConstantFor(name);
@ -267,7 +266,6 @@ Reduction JSTypeFeedbackSpecializer::ReduceJSStoreNamed(Node* node) {
if (frame_state_before == nullptr) return NoChange();
const StoreNamedParameters& p = StoreNamedParametersOf(node->op());
Handle<Name> name = p.name().handle();
SmallMapList maps;
TypeFeedbackId id = js_type_feedback_->FindTypeFeedbackId(node);
if (id.IsNone() || oracle()->StoreIsUninitialized(id) == UNINITIALIZED) {
@ -275,7 +273,7 @@ Reduction JSTypeFeedbackSpecializer::ReduceJSStoreNamed(Node* node) {
// TODO(titzer): no feedback from vector ICs from stores.
return NoChange();
} else {
oracle()->AssignmentReceiverTypes(id, name, &maps);
oracle()->AssignmentReceiverTypes(id, p.name(), &maps);
}
Node* receiver = node->InputAt(0);
@ -287,7 +285,7 @@ Reduction JSTypeFeedbackSpecializer::ReduceJSStoreNamed(Node* node) {
Handle<Map> map = maps.first();
FieldAccess field_access;
if (!GetInObjectFieldAccess(STORE, map, name, &field_access)) {
if (!GetInObjectFieldAccess(STORE, map, p.name(), &field_access)) {
return NoChange();
}

View File

@ -786,7 +786,7 @@ Reduction JSTypedLowering::ReduceJSToString(Node* node) {
Reduction JSTypedLowering::ReduceJSLoadGlobal(Node* node) {
// 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);
if (!constant_value.is_null()) {
Node* constant = jsgraph()->Constant(constant_value);
@ -803,7 +803,7 @@ Reduction JSTypedLowering::ReduceJSLoadNamed(Node* node) {
Type* receiver_type = NodeProperties::GetBounds(receiver).upper;
Node* effect = NodeProperties::GetEffectInput(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.
if (name.is_identical_to(factory()->length_string()) &&
receiver_type->Is(Type::String())) {
@ -823,9 +823,9 @@ Reduction JSTypedLowering::ReduceJSLoadProperty(Node* node) {
Node* base = NodeProperties::GetValueInput(node, 0);
Type* key_type = NodeProperties::GetBounds(key).upper;
HeapObjectMatcher mbase(base);
if (mbase.HasValue() && mbase.Value().handle()->IsJSTypedArray()) {
if (mbase.HasValue() && mbase.Value()->IsJSTypedArray()) {
Handle<JSTypedArray> const array =
Handle<JSTypedArray>::cast(mbase.Value().handle());
Handle<JSTypedArray>::cast(mbase.Value());
if (!array->GetBuffer()->was_neutered()) {
array->GetBuffer()->set_is_neuterable(false);
BufferAccess const access(array->type());
@ -869,9 +869,9 @@ Reduction JSTypedLowering::ReduceJSStoreProperty(Node* node) {
Type* key_type = NodeProperties::GetBounds(key).upper;
Type* value_type = NodeProperties::GetBounds(value).upper;
HeapObjectMatcher mbase(base);
if (mbase.HasValue() && mbase.Value().handle()->IsJSTypedArray()) {
if (mbase.HasValue() && mbase.Value()->IsJSTypedArray()) {
Handle<JSTypedArray> const array =
Handle<JSTypedArray>::cast(mbase.Value().handle());
Handle<JSTypedArray>::cast(mbase.Value());
if (!array->GetBuffer()->was_neutered()) {
array->GetBuffer()->set_is_neuterable(false);
BufferAccess const access(array->type());
@ -1016,12 +1016,12 @@ Reduction JSTypedLowering::ReduceJSLoadDynamicGlobal(Node* node) {
}
// Fast case, because variable is not shadowed. Perform global object load.
Unique<Name> name = Unique<Name>::CreateUninitialized(access.name());
Node* global = graph()->NewNode(
javascript()->LoadContext(0, Context::GLOBAL_OBJECT_INDEX, true), context,
context, effect);
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);
// Slow case, because variable potentially shadowed. Perform dynamic lookup.
@ -1129,7 +1129,7 @@ Reduction JSTypedLowering::ReduceJSCreateClosure(Node* node) {
Reduction JSTypedLowering::ReduceJSCreateLiteralArray(Node* node) {
DCHECK_EQ(IrOpcode::kJSCreateLiteralArray, node->opcode());
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());
// Use the FastCloneShallowArrayStub only for shallow boilerplates up to the
@ -1160,7 +1160,7 @@ Reduction JSTypedLowering::ReduceJSCreateLiteralObject(Node* node) {
DCHECK_EQ(IrOpcode::kJSCreateLiteralObject, node->opcode());
HeapObjectMatcher mconst(NodeProperties::GetValueInput(node, 2));
// 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());
// Use the FastCloneShallowObjectStub only for shallow boilerplates without
@ -1225,8 +1225,7 @@ Reduction JSTypedLowering::ReduceJSCreateBlockContext(Node* node) {
Node* const input = NodeProperties::GetValueInput(node, 0);
HeapObjectMatcher minput(input);
DCHECK(minput.HasValue()); // TODO(mstarzinger): Make ScopeInfo static.
int context_length =
Handle<ScopeInfo>::cast(minput.Value().handle())->ContextLength();
int context_length = Handle<ScopeInfo>::cast(minput.Value())->ContextLength();
if (FLAG_turbo_allocate && context_length < kBlockContextAllocationLimit) {
// JSCreateBlockContext(s:scope[length < limit], f)
Node* const effect = NodeProperties::GetEffectInput(node);

View File

@ -62,14 +62,6 @@ struct ValueMatcher : public NodeMatcher {
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:
T value_;
bool has_value_;
@ -108,6 +100,12 @@ template <typename T, IrOpcode::Value kOpcode>
struct IntMatcher final : public ValueMatcher<T, kOpcode> {
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 {
return this->HasValue() && (this->Value() % n) == 0;
}
@ -139,6 +137,12 @@ template <typename T, IrOpcode::Value kOpcode>
struct FloatMatcher final : public ValueMatcher<T, kOpcode> {
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 {
return this->Is(0.0) && std::signbit(this->Value());
}
@ -153,9 +157,9 @@ typedef FloatMatcher<double, IrOpcode::kNumberConstant> NumberMatcher;
// A pattern matcher for heap object constants.
struct HeapObjectMatcher final
: public ValueMatcher<Unique<HeapObject>, IrOpcode::kHeapConstant> {
: public ValueMatcher<Handle<HeapObject>, IrOpcode::kHeapConstant> {
explicit HeapObjectMatcher(Node* node)
: ValueMatcher<Unique<HeapObject>, IrOpcode::kHeapConstant>(node) {}
: ValueMatcher<Handle<HeapObject>, IrOpcode::kHeapConstant>(node) {}
};
@ -164,6 +168,9 @@ struct ExternalReferenceMatcher final
: public ValueMatcher<ExternalReference, IrOpcode::kExternalConstant> {
explicit ExternalReferenceMatcher(Node* node)
: ValueMatcher<ExternalReference, IrOpcode::kExternalConstant>(node) {}
bool Is(const ExternalReference& value) const {
return this->HasValue() && this->Value() == value;
}
};

View File

@ -9,6 +9,7 @@
#include "src/base/flags.h"
#include "src/base/functional.h"
#include "src/handles.h"
#include "src/zone.h"
namespace v8 {
@ -155,7 +156,8 @@ class Operator1 : public Operator {
bool Equals(const Operator* other) const final {
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());
}
size_t HashCode() const final {
@ -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
// 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 <>
inline float const& OpParameter(const Operator* op) {
return reinterpret_cast<const Operator1<float, base::bit_equal_to<float>,
@ -200,6 +203,20 @@ inline double const& OpParameter(const Operator* op) {
->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 internal
} // namespace v8

View File

@ -72,9 +72,8 @@ class RawMachineAssembler {
// hence will not switch the current basic block.
Node* UndefinedConstant() {
Unique<HeapObject> unique = Unique<HeapObject>::CreateImmovable(
isolate()->factory()->undefined_value());
return NewNode(common()->HeapConstant(unique));
Handle<HeapObject> undefined = isolate()->factory()->undefined_value();
return NewNode(common()->HeapConstant(undefined));
}
// Constants.
@ -102,10 +101,6 @@ class RawMachineAssembler {
return NewNode(common()->Float64Constant(value));
}
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));
}
Node* ExternalConstant(ExternalReference address) {

View File

@ -292,7 +292,7 @@ class RepresentationChanger {
// Eagerly fold representation changes for constants.
switch (node->opcode()) {
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()) ||
value.is_identical_to(factory()->false_value()));
return jsgraph()->Int32Constant(

View File

@ -25,8 +25,7 @@ Reduction SimplifiedOperatorReducer::Reduce(Node* node) {
case IrOpcode::kBooleanNot: {
HeapObjectMatcher m(node->InputAt(0));
if (m.HasValue()) {
return Replace(
jsgraph()->BooleanConstant(!m.Value().handle()->BooleanValue()));
return Replace(jsgraph()->BooleanConstant(!m.Value()->BooleanValue()));
}
if (m.IsBooleanNot()) return Replace(m.InputAt(0));
break;
@ -40,7 +39,7 @@ Reduction SimplifiedOperatorReducer::Reduce(Node* node) {
}
case IrOpcode::kChangeBoolToBit: {
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));
break;
}

View File

@ -541,7 +541,7 @@ Bounds Typer::Visitor::TypeNumberConstant(Node* node) {
Bounds Typer::Visitor::TypeHeapConstant(Node* node) {
return Bounds(TypeConstant(OpParameter<Unique<HeapObject> >(node).handle()));
return Bounds(TypeConstant(OpParameter<Handle<HeapObject>>(node)));
}

View File

@ -40,9 +40,9 @@ class X87OperandGenerator final : public OperandGenerator {
case IrOpcode::kHeapConstant: {
// Constants in new space cannot be used as immediates in V8 because
// the GC does not scan code objects when collecting the new generation.
Unique<HeapObject> value = OpParameter<Unique<HeapObject> >(node);
Isolate* isolate = value.handle()->GetIsolate();
return !isolate->heap()->InNewSpace(*value.handle());
Handle<HeapObject> value = OpParameter<Handle<HeapObject>>(node);
Isolate* isolate = value->GetIsolate();
return !isolate->heap()->InNewSpace(*value);
}
default:
return false;

View File

@ -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() {
#ifdef DEBUG
if (FLAG_check_handle_count) {

View File

@ -6,6 +6,7 @@
#define V8_HANDLES_H_
#include "include/v8.h"
#include "src/base/functional.h"
#include "src/base/macros.h"
#include "src/checks.h"
#include "src/globals.h"
@ -118,6 +119,20 @@ class Handle final : public HandleBase {
// MaybeHandle to force validation before being used as handles.
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:
// Handles of different classes are allowed to access each other's location_.
template <typename>
@ -127,6 +142,9 @@ class Handle final : public HandleBase {
friend class MaybeHandle;
};
template <typename T>
inline std::ostream& operator<<(std::ostream& os, Handle<T> handle);
template <typename T>
V8_INLINE Handle<T> handle(T* object, Isolate* isolate) {
return Handle<T>(object, isolate);

View File

@ -121,8 +121,8 @@ void Interpreter::DoLdaConstant(compiler::InterpreterAssembler* assembler) {
//
// Load Undefined into the accumulator.
void Interpreter::DoLdaUndefined(compiler::InterpreterAssembler* assembler) {
Node* undefined_value = __ HeapConstant(Unique<HeapObject>::CreateImmovable(
isolate_->factory()->undefined_value()));
Node* undefined_value =
__ HeapConstant(isolate_->factory()->undefined_value());
__ SetAccumulator(undefined_value);
__ Dispatch();
}
@ -132,8 +132,7 @@ void Interpreter::DoLdaUndefined(compiler::InterpreterAssembler* assembler) {
//
// Load Null into the accumulator.
void Interpreter::DoLdaNull(compiler::InterpreterAssembler* assembler) {
Node* null_value = __ HeapConstant(
Unique<HeapObject>::CreateImmovable(isolate_->factory()->null_value()));
Node* null_value = __ HeapConstant(isolate_->factory()->null_value());
__ SetAccumulator(null_value);
__ Dispatch();
}
@ -143,8 +142,7 @@ void Interpreter::DoLdaNull(compiler::InterpreterAssembler* assembler) {
//
// Load TheHole into the accumulator.
void Interpreter::DoLdaTheHole(compiler::InterpreterAssembler* assembler) {
Node* the_hole_value = __ HeapConstant(Unique<HeapObject>::CreateImmovable(
isolate_->factory()->the_hole_value()));
Node* the_hole_value = __ HeapConstant(isolate_->factory()->the_hole_value());
__ SetAccumulator(the_hole_value);
__ Dispatch();
}
@ -154,8 +152,7 @@ void Interpreter::DoLdaTheHole(compiler::InterpreterAssembler* assembler) {
//
// Load True into the accumulator.
void Interpreter::DoLdaTrue(compiler::InterpreterAssembler* assembler) {
Node* true_value = __ HeapConstant(
Unique<HeapObject>::CreateImmovable(isolate_->factory()->true_value()));
Node* true_value = __ HeapConstant(isolate_->factory()->true_value());
__ SetAccumulator(true_value);
__ Dispatch();
}
@ -165,8 +162,7 @@ void Interpreter::DoLdaTrue(compiler::InterpreterAssembler* assembler) {
//
// Load False into the accumulator.
void Interpreter::DoLdaFalse(compiler::InterpreterAssembler* assembler) {
Node* false_value = __ HeapConstant(
Unique<HeapObject>::CreateImmovable(isolate_->factory()->false_value()));
Node* false_value = __ HeapConstant(isolate_->factory()->false_value());
__ SetAccumulator(false_value);
__ Dispatch();
}

View File

@ -104,8 +104,7 @@ class GraphBuilderTester : public HandleAndZoneScope,
return NewNode(common()->Int32Constant(value));
}
Node* HeapConstant(Handle<HeapObject> object) {
Unique<HeapObject> val = Unique<HeapObject>::CreateUninitialized(object);
return NewNode(common()->HeapConstant(val));
return NewNode(common()->HeapConstant(object));
}
Node* BooleanNot(Node* a) { return NewNode(simplified()->BooleanNot(), a); }

View File

@ -47,9 +47,9 @@ class JSConstantCacheTester : public HandleAndZoneScope,
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());
return OpParameter<Unique<Object> >(node).handle();
return OpParameter<Handle<HeapObject>>(node);
}
Factory* factory() { return main_isolate()->factory(); }

View File

@ -93,7 +93,7 @@ TEST(ReduceJSLoadContext) {
Node* new_context_input = NodeProperties::GetValueInput(r.replacement(), 0);
CHECK_EQ(IrOpcode::kHeapConstant, new_context_input->opcode());
HeapObjectMatcher match(new_context_input);
CHECK_EQ(*native, *match.Value().handle());
CHECK_EQ(*native, *match.Value());
ContextAccess access = OpParameter<ContextAccess>(r.replacement());
CHECK_EQ(Context::GLOBAL_EVAL_FUN_INDEX, static_cast<int>(access.index()));
CHECK_EQ(0, static_cast<int>(access.depth()));
@ -110,7 +110,7 @@ TEST(ReduceJSLoadContext) {
HeapObjectMatcher match(r.replacement());
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.
@ -172,7 +172,7 @@ TEST(ReduceJSStoreContext) {
Node* new_context_input = NodeProperties::GetValueInput(r.replacement(), 0);
CHECK_EQ(IrOpcode::kHeapConstant, new_context_input->opcode());
HeapObjectMatcher match(new_context_input);
CHECK_EQ(*native, *match.Value().handle());
CHECK_EQ(*native, *match.Value());
ContextAccess access = OpParameter<ContextAccess>(r.replacement());
CHECK_EQ(Context::GLOBAL_EVAL_FUN_INDEX, static_cast<int>(access.index()));
CHECK_EQ(0, static_cast<int>(access.depth()));
@ -249,7 +249,7 @@ TEST(SpecializeToContext) {
Node* replacement = value_use->InputAt(0);
HeapObjectMatcher match(replacement);
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.
}

View File

@ -63,15 +63,12 @@ class JSTypedLoweringTester : public HandleAndZoneScope {
}
Node* UndefinedConstant() {
Unique<HeapObject> unique = Unique<HeapObject>::CreateImmovable(
isolate->factory()->undefined_value());
return graph.NewNode(common.HeapConstant(unique));
Handle<HeapObject> value = isolate->factory()->undefined_value();
return graph.NewNode(common.HeapConstant(value));
}
Node* HeapConstant(Handle<HeapObject> constant) {
Unique<HeapObject> unique =
Unique<HeapObject>::CreateUninitialized(constant);
return graph.NewNode(common.HeapConstant(unique));
return graph.NewNode(common.HeapConstant(constant));
}
Node* EmptyFrameState(Node* context) {
@ -193,9 +190,9 @@ class JSTypedLoweringTester : public HandleAndZoneScope {
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());
Handle<Object> value = OpParameter<Unique<Object> >(result).handle();
Handle<HeapObject> value = OpParameter<Handle<HeapObject>>(result);
CHECK_EQ(*expected, *value);
}
};

View File

@ -71,7 +71,7 @@ class RepresentationChangerTester : public HandleAndZoneScope,
void CheckHeapConstant(Node* n, HeapObject* expected) {
HeapObjectMatcher m(n);
CHECK(m.HasValue());
CHECK_EQ(expected, *m.Value().handle());
CHECK_EQ(expected, *m.Value());
}
void CheckNumberConstant(Node* n, double expected) {

View File

@ -268,8 +268,7 @@ Handle<Code> WrapWithCFunction(Handle<Code> inner, CallDescriptor* desc) {
GraphAndBuilders& b = caller;
Node* start = b.graph()->NewNode(b.common()->Start(param_count + 3));
b.graph()->SetStart(start);
Unique<HeapObject> unique = Unique<HeapObject>::CreateUninitialized(inner);
Node* target = b.graph()->NewNode(b.common()->HeapConstant(unique));
Node* target = b.graph()->NewNode(b.common()->HeapConstant(inner));
// Add arguments to the call.
Node** args = zone.NewArray<Node*>(param_count + 3);
@ -445,9 +444,7 @@ class Computer {
Graph graph(&zone);
CallDescriptor* cdesc = Linkage::GetSimplifiedCDescriptor(&zone, &csig);
RawMachineAssembler raw(isolate, &graph, cdesc);
Unique<HeapObject> unique =
Unique<HeapObject>::CreateUninitialized(inner);
Node* target = raw.HeapConstant(unique);
Node* target = raw.HeapConstant(inner);
Node** args = zone.NewArray<Node*>(num_params);
for (int i = 0; i < num_params; i++) {
args[i] = io.MakeConstant(raw, io.input[i]);
@ -480,9 +477,7 @@ class Computer {
CallDescriptor* cdesc = Linkage::GetSimplifiedCDescriptor(&zone, &csig);
RawMachineAssembler raw(isolate, &graph, cdesc);
Node* base = raw.PointerConstant(io.input);
Unique<HeapObject> unique =
Unique<HeapObject>::CreateUninitialized(inner);
Node* target = raw.HeapConstant(unique);
Node* target = raw.HeapConstant(inner);
Node** args = zone.NewArray<Node*>(kMaxParamCount);
for (int i = 0; i < num_params; i++) {
args[i] = io.LoadInput(raw, base, i);
@ -579,8 +574,7 @@ static void CopyTwentyInt32(CallDescriptor* desc) {
CallDescriptor* cdesc = Linkage::GetSimplifiedCDescriptor(&zone, &csig);
RawMachineAssembler raw(isolate, &graph, cdesc);
Node* base = raw.PointerConstant(input);
Unique<HeapObject> unique = Unique<HeapObject>::CreateUninitialized(inner);
Node* target = raw.HeapConstant(unique);
Node* target = raw.HeapConstant(inner);
Node** args = zone.NewArray<Node*>(kNumParams);
for (int i = 0; i < kNumParams; i++) {
Node* offset = raw.Int32Constant(i * sizeof(int32_t));
@ -953,8 +947,7 @@ static void Build_Select_With_Call(CallDescriptor* desc,
{
// Build a call to the function that does the select.
Unique<HeapObject> unique = Unique<HeapObject>::CreateUninitialized(inner);
Node* target = raw.HeapConstant(unique);
Node* target = raw.HeapConstant(inner);
Node** args = raw.zone()->NewArray<Node*>(num_params);
for (int i = 0; i < num_params; i++) {
args[i] = raw.Parameter(i);
@ -1055,9 +1048,7 @@ void MixedParamTest(int start) {
Graph graph(&zone);
CallDescriptor* cdesc = Linkage::GetSimplifiedCDescriptor(&zone, &csig);
RawMachineAssembler raw(isolate, &graph, cdesc);
Unique<HeapObject> unique =
Unique<HeapObject>::CreateUninitialized(select);
Node* target = raw.HeapConstant(unique);
Node* target = raw.HeapConstant(select);
Node** args = zone.NewArray<Node*>(num_params);
int64_t constant = 0x0102030405060708;
for (int i = 0; i < num_params; i++) {

View File

@ -41,10 +41,8 @@ TEST(RunOptimizedMathFloorStub) {
Node* start = graph.NewNode(common.Start(4));
// Parameter 0 is the number to round
Node* numberParam = graph.NewNode(common.Parameter(1), start);
Unique<HeapObject> u = Unique<HeapObject>::CreateImmovable(code);
Node* theCode = graph.NewNode(common.HeapConstant(u));
Unique<HeapObject> tvu = Unique<HeapObject>::CreateImmovable(tv);
Node* vector = graph.NewNode(common.HeapConstant(tvu));
Node* theCode = graph.NewNode(common.HeapConstant(code));
Node* vector = graph.NewNode(common.HeapConstant(tv));
Node* dummyContext = graph.NewNode(common.NumberConstant(0.0));
Node* call =
graph.NewNode(common.Call(descriptor), theCode, js.UndefinedConstant(),
@ -83,8 +81,7 @@ TEST(RunStringLengthTFStub) {
Node* nameParam = graph.NewNode(common.Parameter(2), start);
Node* slotParam = graph.NewNode(common.Parameter(3), start);
Node* vectorParam = graph.NewNode(common.Parameter(4), start);
Unique<HeapObject> u = Unique<HeapObject>::CreateImmovable(code);
Node* theCode = graph.NewNode(common.HeapConstant(u));
Node* theCode = graph.NewNode(common.HeapConstant(code));
Node* dummyContext = graph.NewNode(common.NumberConstant(0.0));
Node* call =
graph.NewNode(common.Call(descriptor), theCode, receiverParam, nameParam,
@ -127,8 +124,7 @@ TEST(RunStringAddTFStub) {
// Parameter 0 is the receiver
Node* leftParam = graph.NewNode(common.Parameter(1), start);
Node* rightParam = graph.NewNode(common.Parameter(2), start);
Unique<HeapObject> u = Unique<HeapObject>::CreateImmovable(code);
Node* theCode = graph.NewNode(common.HeapConstant(u));
Node* theCode = graph.NewNode(common.HeapConstant(code));
Node* dummyContext = graph.NewNode(common.NumberConstant(0.0));
Node* call = graph.NewNode(common.Call(descriptor), theCode, leftParam,
rightParam, dummyContext, start, start);

View File

@ -47,9 +47,9 @@ class ValueHelper {
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(expected, *OpParameter<Unique<Object> >(node).handle());
CHECK_EQ(expected, *OpParameter<Handle<HeapObject>>(node));
}
void CheckTrue(Node* node) {

View File

@ -45,10 +45,9 @@ class ChangeLoweringTest : public TypedGraphTest {
Matcher<Node*> IsAllocateHeapNumber(const Matcher<Node*>& effect_matcher,
const Matcher<Node*>& control_matcher) {
return IsCall(_, IsHeapConstant(Unique<HeapObject>::CreateImmovable(
AllocateHeapNumberStub(isolate()).GetCode())),
IsNumberConstant(BitEq(0.0)), effect_matcher,
control_matcher);
return IsCall(
_, IsHeapConstant(AllocateHeapNumberStub(isolate()).GetCode()),
IsNumberConstant(BitEq(0.0)), effect_matcher, control_matcher);
}
Matcher<Node*> IsChangeInt32ToSmi(const Matcher<Node*>& value_matcher) {
return Is64() ? IsWord64Shl(IsChangeInt32ToInt64(value_matcher),

View File

@ -51,33 +51,25 @@ Node* GraphTest::NumberConstant(volatile double 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));
Type* type = Type::Constant(value.handle(), zone());
Type* type = Type::Constant(value, zone());
NodeProperties::SetBounds(node, Bounds(type));
return node;
}
Node* GraphTest::FalseConstant() {
return HeapConstant(
Unique<HeapObject>::CreateImmovable(factory()->false_value()));
return HeapConstant(factory()->false_value());
}
Node* GraphTest::TrueConstant() {
return HeapConstant(
Unique<HeapObject>::CreateImmovable(factory()->true_value()));
return HeapConstant(factory()->true_value());
}
Node* GraphTest::UndefinedConstant() {
return HeapConstant(
Unique<HeapObject>::CreateImmovable(factory()->undefined_value()));
return HeapConstant(factory()->undefined_value());
}
@ -92,20 +84,17 @@ Node* GraphTest::EmptyFrameState() {
Matcher<Node*> GraphTest::IsFalseConstant() {
return IsHeapConstant(
Unique<HeapObject>::CreateImmovable(factory()->false_value()));
return IsHeapConstant(factory()->false_value());
}
Matcher<Node*> GraphTest::IsTrueConstant() {
return IsHeapConstant(
Unique<HeapObject>::CreateImmovable(factory()->true_value()));
return IsHeapConstant(factory()->true_value());
}
Matcher<Node*> GraphTest::IsUndefinedConstant() {
return IsHeapConstant(
Unique<HeapObject>::CreateImmovable(factory()->undefined_value()));
return IsHeapConstant(factory()->undefined_value());
}

View File

@ -18,8 +18,6 @@ namespace internal {
template <class T>
class Handle;
class HeapObject;
template <class T>
class Unique;
namespace compiler {
@ -45,7 +43,6 @@ class GraphTest : public TestWithContext, public TestWithIsolateAndZone {
Node* Int64Constant(int64_t value);
Node* NumberConstant(volatile double value);
Node* HeapConstant(const Handle<HeapObject>& value);
Node* HeapConstant(const Unique<HeapObject>& value);
Node* FalseConstant();
Node* TrueConstant();
Node* UndefinedConstant();

View File

@ -154,9 +154,8 @@ TARGET_TEST_F(InterpreterAssemblerTest, Return) {
EXPECT_EQ(CallDescriptor::kCallCodeObject, m.call_descriptor()->kind());
EXPECT_TRUE(m.call_descriptor()->flags() & CallDescriptor::kCanUseRoots);
Matcher<Unique<HeapObject>> exit_trampoline(
Unique<HeapObject>::CreateImmovable(
isolate()->builtins()->InterpreterExitTrampoline()));
Handle<HeapObject> exit_trampoline =
isolate()->builtins()->InterpreterExitTrampoline();
EXPECT_THAT(
tail_call_node,
IsTailCall(m.call_descriptor(), IsHeapConstant(exit_trampoline),

View File

@ -41,7 +41,7 @@ class JSBuiltinReducerTest : public TypedGraphTest {
JSObject::GetProperty(
m, isolate()->factory()->NewStringFromAsciiChecked(name))
.ToHandleChecked());
return HeapConstant(Unique<JSFunction>::CreateUninitialized(f));
return HeapConstant(f);
}
JSOperatorBuilder* javascript() { return &javascript_; }

View File

@ -152,7 +152,7 @@ TEST_F(JSContextRelaxationTest,
Node* const input1 = Parameter(1);
Node* const context = Parameter(2);
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 =
ShallowFrameStateChain(outer_context, CALL_MAINTAINS_NATIVE_CONTEXT);
Node* const effect = graph()->start();

View File

@ -82,8 +82,7 @@ class JSTypeFeedbackTest : public TypedGraphTest {
Node* vector = UndefinedConstant();
Node* context = UndefinedConstant();
Unique<Name> name = Unique<Name>::CreateUninitialized(
isolate()->factory()->InternalizeUtf8String(string));
Handle<Name> name = isolate()->factory()->InternalizeUtf8String(string);
const Operator* op = javascript()->LoadGlobal(name, feedback);
Node* load = graph()->NewNode(op, context, global, vector, context);
if (mode == JSTypeFeedbackSpecializer::kDeoptimizationEnabled) {
@ -193,10 +192,9 @@ TEST_F(JSTypeFeedbackTest, JSLoadNamedGlobalConstNumberWithDeoptimization) {
TEST_F(JSTypeFeedbackTest, JSLoadNamedGlobalConstString) {
Unique<HeapObject> kValue = Unique<HeapObject>::CreateImmovable(
isolate()->factory()->undefined_string());
Handle<HeapObject> kValue = isolate()->factory()->undefined_string();
const char* kName = "mango";
SetGlobalProperty(kName, kValue.handle());
SetGlobalProperty(kName, kValue);
Node* ret = ReturnLoadNamedFromGlobal(
kName, graph()->start(), graph()->start(),
@ -211,10 +209,9 @@ TEST_F(JSTypeFeedbackTest, JSLoadNamedGlobalConstString) {
TEST_F(JSTypeFeedbackTest, JSLoadNamedGlobalConstStringWithDeoptimization) {
Unique<HeapObject> kValue = Unique<HeapObject>::CreateImmovable(
isolate()->factory()->undefined_string());
Handle<HeapObject> kValue = isolate()->factory()->undefined_string();
const char* kName = "mango";
SetGlobalProperty(kName, kValue.handle());
SetGlobalProperty(kName, kValue);
Node* ret = ReturnLoadNamedFromGlobal(
kName, graph()->start(), graph()->start(),
@ -277,7 +274,7 @@ TEST_F(JSTypeFeedbackTest, JSLoadNamedGlobalPropertyCellSmiWithDeoptimization) {
HeapObjectMatcher cell(cell_capture.value());
EXPECT_TRUE(cell.HasValue());
EXPECT_TRUE(cell.Value().handle()->IsPropertyCell());
EXPECT_TRUE(cell.Value()->IsPropertyCell());
EXPECT_THAT(ret,
IsReturn(load_field_match, load_field_match, graph()->start()));
@ -329,7 +326,7 @@ TEST_F(JSTypeFeedbackTest,
HeapObjectMatcher cell(cell_capture.value());
EXPECT_TRUE(cell.HasValue());
EXPECT_TRUE(cell.Value().handle()->IsPropertyCell());
EXPECT_TRUE(cell.Value()->IsPropertyCell());
EXPECT_THAT(ret,
IsReturn(load_field_match, load_field_match, graph()->start()));

View File

@ -235,14 +235,12 @@ TEST_F(JSTypedLoweringTest, ParameterWithNull) {
{
Reduction r = Reduce(Parameter(Type::Constant(null, zone())));
ASSERT_TRUE(r.Changed());
EXPECT_THAT(r.replacement(),
IsHeapConstant(Unique<HeapObject>::CreateImmovable(null)));
EXPECT_THAT(r.replacement(), IsHeapConstant(null));
}
{
Reduction r = Reduce(Parameter(Type::Null()));
ASSERT_TRUE(r.Changed());
EXPECT_THAT(r.replacement(),
IsHeapConstant(Unique<HeapObject>::CreateImmovable(null)));
EXPECT_THAT(r.replacement(), IsHeapConstant(null));
}
}
@ -291,14 +289,12 @@ TEST_F(JSTypedLoweringTest, ParameterWithUndefined) {
{
Reduction r = Reduce(Parameter(Type::Undefined()));
ASSERT_TRUE(r.Changed());
EXPECT_THAT(r.replacement(),
IsHeapConstant(Unique<HeapObject>::CreateImmovable(undefined)));
EXPECT_THAT(r.replacement(), IsHeapConstant(undefined));
}
{
Reduction r = Reduce(Parameter(Type::Constant(undefined, zone())));
ASSERT_TRUE(r.Changed());
EXPECT_THAT(r.replacement(),
IsHeapConstant(Unique<HeapObject>::CreateImmovable(undefined)));
EXPECT_THAT(r.replacement(), IsHeapConstant(undefined));
}
}
@ -885,8 +881,8 @@ TEST_F(JSTypedLoweringTest, JSLoadGlobalConstants) {
Handle<String>(isolate()->heap()->nan_string(), isolate()) // --
};
Matcher<Node*> matches[] = {
IsHeapConstant(Unique<HeapObject>::CreateImmovable(
Handle<HeapObject>(isolate()->heap()->undefined_value(), isolate()))),
IsHeapConstant(
Handle<HeapObject>(isolate()->heap()->undefined_value(), isolate())),
IsNumberConstant(std::numeric_limits<double>::infinity()),
IsNumberConstant(IsNaN()) // --
};
@ -899,9 +895,8 @@ TEST_F(JSTypedLoweringTest, JSLoadGlobalConstants) {
Node* control = graph()->start();
for (size_t i = 0; i < arraysize(names); i++) {
Unique<Name> name = Unique<Name>::CreateImmovable(names[i]);
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));
ASSERT_TRUE(r.Changed());
@ -916,7 +911,7 @@ TEST_F(JSTypedLoweringTest, JSLoadGlobalConstants) {
TEST_F(JSTypedLoweringTest, JSLoadNamedStringLength) {
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 vector = Parameter(Type::Internal(), 1);
Node* const context = UndefinedConstant();
@ -1022,12 +1017,11 @@ TEST_F(JSTypedLoweringTest, JSAddWithString) {
rhs, context, frame_state0,
frame_state1, effect, control));
ASSERT_TRUE(r.Changed());
EXPECT_THAT(
r.replacement(),
IsCall(_, IsHeapConstant(Unique<HeapObject>::CreateImmovable(
CodeFactory::StringAdd(isolate(), STRING_ADD_CHECK_NONE,
NOT_TENURED).code())),
lhs, rhs, context, frame_state0, effect, control));
EXPECT_THAT(r.replacement(),
IsCall(_, IsHeapConstant(CodeFactory::StringAdd(
isolate(), STRING_ADD_CHECK_NONE,
NOT_TENURED).code()),
lhs, rhs, context, frame_state0, effect, control));
}
}
@ -1045,14 +1039,11 @@ TEST_F(JSTypedLoweringTest, JSCreateClosure) {
Reduce(graph()->NewNode(javascript()->CreateClosure(shared, NOT_TENURED),
context, context, effect, control));
ASSERT_TRUE(r.Changed());
EXPECT_THAT(
r.replacement(),
IsCall(_,
IsHeapConstant(Unique<HeapObject>::CreateImmovable(
CodeFactory::FastNewClosure(isolate(), shared->language_mode(),
shared->kind()).code())),
IsHeapConstant(Unique<HeapObject>::CreateImmovable(shared)),
effect, control));
EXPECT_THAT(r.replacement(),
IsCall(_, IsHeapConstant(CodeFactory::FastNewClosure(
isolate(), shared->language_mode(),
shared->kind()).code()),
IsHeapConstant(shared), effect, control));
}
@ -1074,8 +1065,8 @@ TEST_F(JSTypedLoweringTest, JSCreateLiteralArray) {
ASSERT_TRUE(r.Changed());
EXPECT_THAT(
r.replacement(),
IsCall(_, IsHeapConstant(Unique<HeapObject>::CreateImmovable(
CodeFactory::FastCloneShallowArray(isolate()).code())),
IsCall(_, IsHeapConstant(
CodeFactory::FastCloneShallowArray(isolate()).code()),
input0, input1, input2, context, frame_state, effect, control));
}
@ -1098,8 +1089,8 @@ TEST_F(JSTypedLoweringTest, JSCreateLiteralObject) {
ASSERT_TRUE(r.Changed());
EXPECT_THAT(
r.replacement(),
IsCall(_, IsHeapConstant(Unique<HeapObject>::CreateImmovable(
CodeFactory::FastCloneShallowObject(isolate(), 6).code())),
IsCall(_, IsHeapConstant(
CodeFactory::FastCloneShallowObject(isolate(), 6).code()),
input0, input1, input2, _, context, frame_state, effect, control));
}

View File

@ -21,6 +21,11 @@ using testing::StringMatchResultListener;
namespace v8 {
namespace internal {
bool operator==(Handle<HeapObject> const& lhs, Handle<HeapObject> const& rhs) {
return lhs.is_identical_to(rhs);
}
namespace compiler {
namespace {
@ -1528,10 +1533,9 @@ Matcher<Node*> IsExternalConstant(
}
Matcher<Node*> IsHeapConstant(
const Matcher<Unique<HeapObject> >& value_matcher) {
return MakeMatcher(new IsConstantMatcher<Unique<HeapObject> >(
IrOpcode::kHeapConstant, value_matcher));
Matcher<Node*> IsHeapConstant(Handle<HeapObject> value) {
return MakeMatcher(new IsConstantMatcher<Handle<HeapObject>>(
IrOpcode::kHeapConstant, value));
}

View File

@ -14,9 +14,9 @@ namespace internal {
// Forward declarations.
class ExternalReference;
template <typename T>
class Handle;
class HeapObject;
template <class T>
class Unique;
template <class>
class TypeImpl;
struct ZoneTypeConfig;
@ -73,8 +73,7 @@ Matcher<Node*> IsTerminate(const Matcher<Node*>& effect_matcher,
const Matcher<Node*>& control_matcher);
Matcher<Node*> IsExternalConstant(
const Matcher<ExternalReference>& value_matcher);
Matcher<Node*> IsHeapConstant(
const Matcher<Unique<HeapObject> >& value_matcher);
Matcher<Node*> IsHeapConstant(Handle<HeapObject> value);
Matcher<Node*> IsFloat32Constant(const Matcher<float>& value_matcher);
Matcher<Node*> IsFloat64Constant(const Matcher<double>& value_matcher);
Matcher<Node*> IsInt32Constant(const Matcher<int32_t>& value_matcher);