// 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());
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());
}
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());
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());
}
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) {
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:
// 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.
}
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;
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
}
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);
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;
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;
}
}
-Node* InterpreterAssembler::HeapConstant(Unique<HeapObject> object) {
+Node* InterpreterAssembler::HeapConstant(Handle<HeapObject> object) {
return raw_assembler_->HeapConstant(object);
}
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);
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);
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();
}
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();
}
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());
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);
}
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));
}
}
-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));
}
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);
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();
}
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);
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();
}
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();
}
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();
}
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();
}
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();
}
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();
}
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();
}
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());
}
}
-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);
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>( // --
}
-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) {
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);
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
// 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_;
};
// 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_; }
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_;
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),
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_;
};
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_;
};
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);
// 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();
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) {
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);
// 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);
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();
}
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);
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) {
// 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);
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();
}
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);
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())) {
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());
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());
}
// 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.
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
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
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);
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_;
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;
}
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());
}
// 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) {}
};
: 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;
+ }
};
#include "src/base/flags.h"
#include "src/base/functional.h"
+#include "src/handles.h"
#include "src/zone.h"
namespace v8 {
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 {
}
// 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>,
->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
// 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.
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) {
// 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(
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;
}
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;
}
Bounds Typer::Visitor::TypeHeapConstant(Node* node) {
- return Bounds(TypeConstant(OpParameter<Unique<HeapObject> >(node).handle()));
+ return Bounds(TypeConstant(OpParameter<Handle<HeapObject>>(node)));
}
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;
}
+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) {
#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"
// 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>
};
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);
}
//
// 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();
}
//
// 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();
}
//
// 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();
}
//
// 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();
}
//
// 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();
}
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); }
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(); }
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()));
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.
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()));
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.
}
}
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) {
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);
}
};
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) {
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);
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]);
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);
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));
{
// 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);
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++) {
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(),
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,
// 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);
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) {
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),
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());
}
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());
}
template <class T>
class Handle;
class HeapObject;
-template <class T>
-class Unique;
namespace compiler {
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();
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),
JSObject::GetProperty(
m, isolate()->factory()->NewStringFromAsciiChecked(name))
.ToHandleChecked());
- return HeapConstant(Unique<JSFunction>::CreateUninitialized(f));
+ return HeapConstant(f);
}
JSOperatorBuilder* javascript() { return &javascript_; }
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();
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) {
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(),
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(),
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()));
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()));
{
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));
}
}
{
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));
}
}
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()) // --
};
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());
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();
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));
}
}
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));
}
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));
}
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));
}
namespace v8 {
namespace internal {
+
+bool operator==(Handle<HeapObject> const& lhs, Handle<HeapObject> const& rhs) {
+ return lhs.is_identical_to(rhs);
+}
+
namespace compiler {
namespace {
}
-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));
}
// Forward declarations.
class ExternalReference;
+template <typename T>
+class Handle;
class HeapObject;
-template <class T>
-class Unique;
template <class>
class TypeImpl;
struct ZoneTypeConfig;
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);