Commit 32cdd4d4 authored by ishell@chromium.org's avatar ishell@chromium.org

More Hydrogen templatization.

Factories added to a set of Hydrogen classes.
Several old-style HXxx::New() replaced with New<HXxx>() and NewUncasted<HXxx>.
Several AddInstruction() calls following New::XXX() replaced with Add<XXX>().
AddLoadNamedField() method added to GraphBuilder.

R=bmeurer@chromium.org

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@17318 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent dd74f5aa
...@@ -174,8 +174,7 @@ bool CodeStubGraphBuilderBase::BuildGraph() { ...@@ -174,8 +174,7 @@ bool CodeStubGraphBuilderBase::BuildGraph() {
arguments_length_ = graph()->GetConstant0(); arguments_length_ = graph()->GetConstant0();
} }
context_ = New<HContext>(); context_ = Add<HContext>();
AddInstruction(context_);
start_environment->BindContext(context_); start_environment->BindContext(context_);
Add<HSimulate>(BailoutId::StubEntry()); Add<HSimulate>(BailoutId::StubEntry());
...@@ -567,7 +566,7 @@ HValue* CodeStubGraphBuilder<LoadFieldStub>::BuildCodeStub() { ...@@ -567,7 +566,7 @@ HValue* CodeStubGraphBuilder<LoadFieldStub>::BuildCodeStub() {
HObjectAccess access = casted_stub()->is_inobject() ? HObjectAccess access = casted_stub()->is_inobject() ?
HObjectAccess::ForJSObjectOffset(casted_stub()->offset(), rep) : HObjectAccess::ForJSObjectOffset(casted_stub()->offset(), rep) :
HObjectAccess::ForBackingStoreOffset(casted_stub()->offset(), rep); HObjectAccess::ForBackingStoreOffset(casted_stub()->offset(), rep);
return AddInstruction(BuildLoadNamedField(GetParameter(0), access)); return AddLoadNamedField(GetParameter(0), access);
} }
...@@ -582,7 +581,7 @@ HValue* CodeStubGraphBuilder<KeyedLoadFieldStub>::BuildCodeStub() { ...@@ -582,7 +581,7 @@ HValue* CodeStubGraphBuilder<KeyedLoadFieldStub>::BuildCodeStub() {
HObjectAccess access = casted_stub()->is_inobject() ? HObjectAccess access = casted_stub()->is_inobject() ?
HObjectAccess::ForJSObjectOffset(casted_stub()->offset(), rep) : HObjectAccess::ForJSObjectOffset(casted_stub()->offset(), rep) :
HObjectAccess::ForBackingStoreOffset(casted_stub()->offset(), rep); HObjectAccess::ForBackingStoreOffset(casted_stub()->offset(), rep);
return AddInstruction(BuildLoadNamedField(GetParameter(0), access)); return AddLoadNamedField(GetParameter(0), access);
} }
...@@ -688,14 +687,13 @@ HValue* CodeStubGraphBuilderBase::BuildArraySingleArgumentConstructor( ...@@ -688,14 +687,13 @@ HValue* CodeStubGraphBuilderBase::BuildArraySingleArgumentConstructor(
HValue* constant_zero = graph()->GetConstant0(); HValue* constant_zero = graph()->GetConstant0();
HInstruction* elements = Add<HArgumentsElements>(false); HInstruction* elements = Add<HArgumentsElements>(false);
HInstruction* argument = AddInstruction( HInstruction* argument = Add<HAccessArgumentsAt>(
new(zone()) HAccessArgumentsAt(elements, constant_one, constant_zero)); elements, constant_one, constant_zero);
HConstant* max_alloc_length = HConstant* max_alloc_length =
Add<HConstant>(JSObject::kInitialMaxFastElementArray); Add<HConstant>(JSObject::kInitialMaxFastElementArray);
const int initial_capacity = JSArray::kPreallocatedArrayElements; const int initial_capacity = JSArray::kPreallocatedArrayElements;
HConstant* initial_capacity_node = New<HConstant>(initial_capacity); HConstant* initial_capacity_node = Add<HConstant>(initial_capacity);
AddInstruction(initial_capacity_node);
HInstruction* checked_arg = Add<HBoundsCheck>(argument, max_alloc_length); HInstruction* checked_arg = Add<HBoundsCheck>(argument, max_alloc_length);
IfBuilder if_builder(this); IfBuilder if_builder(this);
...@@ -738,8 +736,8 @@ HValue* CodeStubGraphBuilderBase::BuildArrayNArgumentsConstructor( ...@@ -738,8 +736,8 @@ HValue* CodeStubGraphBuilderBase::BuildArrayNArgumentsConstructor(
HValue* start = graph()->GetConstant0(); HValue* start = graph()->GetConstant0();
HValue* key = builder.BeginBody(start, length, Token::LT); HValue* key = builder.BeginBody(start, length, Token::LT);
HInstruction* argument_elements = Add<HArgumentsElements>(false); HInstruction* argument_elements = Add<HArgumentsElements>(false);
HInstruction* argument = AddInstruction(new(zone()) HAccessArgumentsAt( HInstruction* argument = Add<HAccessArgumentsAt>(
argument_elements, length, key)); argument_elements, length, key);
Add<HStoreKeyed>(elements, key, argument, kind); Add<HStoreKeyed>(elements, key, argument, kind);
builder.EndBody(); builder.EndBody();
...@@ -1168,8 +1166,8 @@ void CodeStubGraphBuilderBase::BuildInstallFromOptimizedCodeMap( ...@@ -1168,8 +1166,8 @@ void CodeStubGraphBuilderBase::BuildInstallFromOptimizedCodeMap(
} }
restore_check.Else(); restore_check.Else();
{ {
HValue* keyed_minus = AddInstruction(HSub::New(zone(), context(), key, HValue* keyed_minus = AddUncasted<HSub>(
shared_function_entry_length)); key, shared_function_entry_length);
HInstruction* keyed_lookup = Add<HLoadKeyed>(optimized_map, HInstruction* keyed_lookup = Add<HLoadKeyed>(optimized_map,
keyed_minus, static_cast<HValue*>(NULL), FAST_ELEMENTS); keyed_minus, static_cast<HValue*>(NULL), FAST_ELEMENTS);
IfBuilder done_check(this); IfBuilder done_check(this);
...@@ -1178,8 +1176,8 @@ void CodeStubGraphBuilderBase::BuildInstallFromOptimizedCodeMap( ...@@ -1178,8 +1176,8 @@ void CodeStubGraphBuilderBase::BuildInstallFromOptimizedCodeMap(
done_check.Then(); done_check.Then();
{ {
// Hit: fetch the optimized code. // Hit: fetch the optimized code.
HValue* keyed_plus = AddInstruction(HAdd::New(zone(), context(), HValue* keyed_plus = AddUncasted<HAdd>(
keyed_minus, graph()->GetConstant1())); keyed_minus, graph()->GetConstant1());
HValue* code_object = Add<HLoadKeyed>(optimized_map, HValue* code_object = Add<HLoadKeyed>(optimized_map,
keyed_plus, static_cast<HValue*>(NULL), FAST_ELEMENTS); keyed_plus, static_cast<HValue*>(NULL), FAST_ELEMENTS);
BuildInstallOptimizedCode(js_function, native_context, code_object); BuildInstallOptimizedCode(js_function, native_context, code_object);
......
...@@ -1494,11 +1494,15 @@ class HReturn V8_FINAL : public HTemplateControlInstruction<0, 3> { ...@@ -1494,11 +1494,15 @@ class HReturn V8_FINAL : public HTemplateControlInstruction<0, 3> {
class HAbnormalExit V8_FINAL : public HTemplateControlInstruction<0, 0> { class HAbnormalExit V8_FINAL : public HTemplateControlInstruction<0, 0> {
public: public:
DECLARE_INSTRUCTION_FACTORY_P0(HAbnormalExit);
virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE { virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
return Representation::None(); return Representation::None();
} }
DECLARE_CONCRETE_INSTRUCTION(AbnormalExit) DECLARE_CONCRETE_INSTRUCTION(AbnormalExit)
private:
HAbnormalExit() {}
}; };
...@@ -1981,10 +1985,7 @@ class HPushArgument V8_FINAL : public HUnaryOperation { ...@@ -1981,10 +1985,7 @@ class HPushArgument V8_FINAL : public HUnaryOperation {
class HThisFunction V8_FINAL : public HTemplateInstruction<0> { class HThisFunction V8_FINAL : public HTemplateInstruction<0> {
public: public:
HThisFunction() { DECLARE_INSTRUCTION_FACTORY_P0(HThisFunction);
set_representation(Representation::Tagged());
SetFlag(kUseGVN);
}
virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE { virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
return Representation::None(); return Representation::None();
...@@ -1996,6 +1997,11 @@ class HThisFunction V8_FINAL : public HTemplateInstruction<0> { ...@@ -1996,6 +1997,11 @@ class HThisFunction V8_FINAL : public HTemplateInstruction<0> {
virtual bool DataEquals(HValue* other) V8_OVERRIDE { return true; } virtual bool DataEquals(HValue* other) V8_OVERRIDE { return true; }
private: private:
HThisFunction() {
set_representation(Representation::Tagged());
SetFlag(kUseGVN);
}
virtual bool IsDeletable() const V8_OVERRIDE { return true; } virtual bool IsDeletable() const V8_OVERRIDE { return true; }
}; };
...@@ -2057,14 +2063,7 @@ class HDeclareGlobals V8_FINAL : public HUnaryOperation { ...@@ -2057,14 +2063,7 @@ class HDeclareGlobals V8_FINAL : public HUnaryOperation {
class HGlobalObject V8_FINAL : public HUnaryOperation { class HGlobalObject V8_FINAL : public HUnaryOperation {
public: public:
explicit HGlobalObject(HValue* context) : HUnaryOperation(context) { DECLARE_INSTRUCTION_WITH_CONTEXT_FACTORY_P0(HGlobalObject);
set_representation(Representation::Tagged());
SetFlag(kUseGVN);
}
static HGlobalObject* New(Zone* zone, HValue* context) {
return new(zone) HGlobalObject(context);
}
DECLARE_CONCRETE_INSTRUCTION(GlobalObject) DECLARE_CONCRETE_INSTRUCTION(GlobalObject)
...@@ -2076,6 +2075,11 @@ class HGlobalObject V8_FINAL : public HUnaryOperation { ...@@ -2076,6 +2075,11 @@ class HGlobalObject V8_FINAL : public HUnaryOperation {
virtual bool DataEquals(HValue* other) V8_OVERRIDE { return true; } virtual bool DataEquals(HValue* other) V8_OVERRIDE { return true; }
private: private:
explicit HGlobalObject(HValue* context) : HUnaryOperation(context) {
set_representation(Representation::Tagged());
SetFlag(kUseGVN);
}
virtual bool IsDeletable() const V8_OVERRIDE { return true; } virtual bool IsDeletable() const V8_OVERRIDE { return true; }
}; };
...@@ -2317,10 +2321,7 @@ class HCallGlobal V8_FINAL : public HUnaryCall { ...@@ -2317,10 +2321,7 @@ class HCallGlobal V8_FINAL : public HUnaryCall {
class HCallKnownGlobal V8_FINAL : public HCall<0> { class HCallKnownGlobal V8_FINAL : public HCall<0> {
public: public:
HCallKnownGlobal(Handle<JSFunction> target, int argument_count) DECLARE_INSTRUCTION_FACTORY_P2(HCallKnownGlobal, Handle<JSFunction>, int);
: HCall<0>(argument_count),
target_(target),
formal_parameter_count_(target->shared()->formal_parameter_count()) { }
virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE; virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
...@@ -2334,6 +2335,11 @@ class HCallKnownGlobal V8_FINAL : public HCall<0> { ...@@ -2334,6 +2335,11 @@ class HCallKnownGlobal V8_FINAL : public HCall<0> {
DECLARE_CONCRETE_INSTRUCTION(CallKnownGlobal) DECLARE_CONCRETE_INSTRUCTION(CallKnownGlobal)
private: private:
HCallKnownGlobal(Handle<JSFunction> target, int argument_count)
: HCall<0>(argument_count),
target_(target),
formal_parameter_count_(target->shared()->formal_parameter_count()) { }
Handle<JSFunction> target_; Handle<JSFunction> target_;
int formal_parameter_count_; int formal_parameter_count_;
}; };
...@@ -3722,17 +3728,8 @@ class HWrapReceiver V8_FINAL : public HTemplateInstruction<2> { ...@@ -3722,17 +3728,8 @@ class HWrapReceiver V8_FINAL : public HTemplateInstruction<2> {
class HApplyArguments V8_FINAL : public HTemplateInstruction<4> { class HApplyArguments V8_FINAL : public HTemplateInstruction<4> {
public: public:
HApplyArguments(HValue* function, DECLARE_INSTRUCTION_FACTORY_P4(HApplyArguments, HValue*, HValue*, HValue*,
HValue* receiver, HValue*);
HValue* length,
HValue* elements) {
set_representation(Representation::Tagged());
SetOperandAt(0, function);
SetOperandAt(1, receiver);
SetOperandAt(2, length);
SetOperandAt(3, elements);
SetAllSideEffects();
}
virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE { virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
// The length is untagged, all other inputs are tagged. // The length is untagged, all other inputs are tagged.
...@@ -3747,6 +3744,19 @@ class HApplyArguments V8_FINAL : public HTemplateInstruction<4> { ...@@ -3747,6 +3744,19 @@ class HApplyArguments V8_FINAL : public HTemplateInstruction<4> {
HValue* elements() { return OperandAt(3); } HValue* elements() { return OperandAt(3); }
DECLARE_CONCRETE_INSTRUCTION(ApplyArguments) DECLARE_CONCRETE_INSTRUCTION(ApplyArguments)
private:
HApplyArguments(HValue* function,
HValue* receiver,
HValue* length,
HValue* elements) {
set_representation(Representation::Tagged());
SetOperandAt(0, function);
SetOperandAt(1, receiver);
SetOperandAt(2, length);
SetOperandAt(3, elements);
SetAllSideEffects();
}
}; };
...@@ -3804,13 +3814,7 @@ class HArgumentsLength V8_FINAL : public HUnaryOperation { ...@@ -3804,13 +3814,7 @@ class HArgumentsLength V8_FINAL : public HUnaryOperation {
class HAccessArgumentsAt V8_FINAL : public HTemplateInstruction<3> { class HAccessArgumentsAt V8_FINAL : public HTemplateInstruction<3> {
public: public:
HAccessArgumentsAt(HValue* arguments, HValue* length, HValue* index) { DECLARE_INSTRUCTION_FACTORY_P3(HAccessArgumentsAt, HValue*, HValue*, HValue*);
set_representation(Representation::Tagged());
SetFlag(kUseGVN);
SetOperandAt(0, arguments);
SetOperandAt(1, length);
SetOperandAt(2, index);
}
virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE; virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
...@@ -3827,6 +3831,15 @@ class HAccessArgumentsAt V8_FINAL : public HTemplateInstruction<3> { ...@@ -3827,6 +3831,15 @@ class HAccessArgumentsAt V8_FINAL : public HTemplateInstruction<3> {
DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt) DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt)
private:
HAccessArgumentsAt(HValue* arguments, HValue* length, HValue* index) {
set_representation(Representation::Tagged());
SetFlag(kUseGVN);
SetOperandAt(0, arguments);
SetOperandAt(1, length);
SetOperandAt(2, index);
}
virtual bool DataEquals(HValue* other) V8_OVERRIDE { return true; } virtual bool DataEquals(HValue* other) V8_OVERRIDE { return true; }
}; };
...@@ -4051,16 +4064,8 @@ class HArithmeticBinaryOperation : public HBinaryOperation { ...@@ -4051,16 +4064,8 @@ class HArithmeticBinaryOperation : public HBinaryOperation {
class HCompareGeneric V8_FINAL : public HBinaryOperation { class HCompareGeneric V8_FINAL : public HBinaryOperation {
public: public:
HCompareGeneric(HValue* context, DECLARE_INSTRUCTION_WITH_CONTEXT_FACTORY_P3(HCompareGeneric, HValue*,
HValue* left, HValue*, Token::Value);
HValue* right,
Token::Value token)
: HBinaryOperation(context, left, right, HType::Boolean()),
token_(token) {
ASSERT(Token::IsCompareOp(token));
set_representation(Representation::Tagged());
SetAllSideEffects();
}
virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE { virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
return index == 0 return index == 0
...@@ -4074,6 +4079,17 @@ class HCompareGeneric V8_FINAL : public HBinaryOperation { ...@@ -4074,6 +4079,17 @@ class HCompareGeneric V8_FINAL : public HBinaryOperation {
DECLARE_CONCRETE_INSTRUCTION(CompareGeneric) DECLARE_CONCRETE_INSTRUCTION(CompareGeneric)
private: private:
HCompareGeneric(HValue* context,
HValue* left,
HValue* right,
Token::Value token)
: HBinaryOperation(context, left, right, HType::Boolean()),
token_(token) {
ASSERT(Token::IsCompareOp(token));
set_representation(Representation::Tagged());
SetAllSideEffects();
}
Token::Value token_; Token::Value token_;
}; };
...@@ -4325,11 +4341,15 @@ class HStringCompareAndBranch : public HTemplateControlInstruction<2, 3> { ...@@ -4325,11 +4341,15 @@ class HStringCompareAndBranch : public HTemplateControlInstruction<2, 3> {
class HIsConstructCallAndBranch : public HTemplateControlInstruction<2, 0> { class HIsConstructCallAndBranch : public HTemplateControlInstruction<2, 0> {
public: public:
DECLARE_INSTRUCTION_FACTORY_P0(HIsConstructCallAndBranch);
virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE { virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
return Representation::None(); return Representation::None();
} }
DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch) DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch)
private:
HIsConstructCallAndBranch() {}
}; };
...@@ -4366,23 +4386,22 @@ class HHasInstanceTypeAndBranch V8_FINAL : public HUnaryControlInstruction { ...@@ -4366,23 +4386,22 @@ class HHasInstanceTypeAndBranch V8_FINAL : public HUnaryControlInstruction {
class HHasCachedArrayIndexAndBranch V8_FINAL : public HUnaryControlInstruction { class HHasCachedArrayIndexAndBranch V8_FINAL : public HUnaryControlInstruction {
public: public:
explicit HHasCachedArrayIndexAndBranch(HValue* value) DECLARE_INSTRUCTION_FACTORY_P1(HHasCachedArrayIndexAndBranch, HValue*);
: HUnaryControlInstruction(value, NULL, NULL) { }
virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE { virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
return Representation::Tagged(); return Representation::Tagged();
} }
DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch) DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch)
private:
explicit HHasCachedArrayIndexAndBranch(HValue* value)
: HUnaryControlInstruction(value, NULL, NULL) { }
}; };
class HGetCachedArrayIndex V8_FINAL : public HUnaryOperation { class HGetCachedArrayIndex V8_FINAL : public HUnaryOperation {
public: public:
explicit HGetCachedArrayIndex(HValue* value) : HUnaryOperation(value) { DECLARE_INSTRUCTION_FACTORY_P1(HGetCachedArrayIndex, HValue*);
set_representation(Representation::Tagged());
SetFlag(kUseGVN);
}
virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE { virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
return Representation::Tagged(); return Representation::Tagged();
...@@ -4394,15 +4413,19 @@ class HGetCachedArrayIndex V8_FINAL : public HUnaryOperation { ...@@ -4394,15 +4413,19 @@ class HGetCachedArrayIndex V8_FINAL : public HUnaryOperation {
virtual bool DataEquals(HValue* other) V8_OVERRIDE { return true; } virtual bool DataEquals(HValue* other) V8_OVERRIDE { return true; }
private: private:
explicit HGetCachedArrayIndex(HValue* value) : HUnaryOperation(value) {
set_representation(Representation::Tagged());
SetFlag(kUseGVN);
}
virtual bool IsDeletable() const V8_OVERRIDE { return true; } virtual bool IsDeletable() const V8_OVERRIDE { return true; }
}; };
class HClassOfTestAndBranch V8_FINAL : public HUnaryControlInstruction { class HClassOfTestAndBranch V8_FINAL : public HUnaryControlInstruction {
public: public:
HClassOfTestAndBranch(HValue* value, Handle<String> class_name) DECLARE_INSTRUCTION_FACTORY_P2(HClassOfTestAndBranch, HValue*,
: HUnaryControlInstruction(value, NULL, NULL), Handle<String>);
class_name_(class_name) { }
DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch) DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch)
...@@ -4415,15 +4438,17 @@ class HClassOfTestAndBranch V8_FINAL : public HUnaryControlInstruction { ...@@ -4415,15 +4438,17 @@ class HClassOfTestAndBranch V8_FINAL : public HUnaryControlInstruction {
Handle<String> class_name() const { return class_name_; } Handle<String> class_name() const { return class_name_; }
private: private:
HClassOfTestAndBranch(HValue* value, Handle<String> class_name)
: HUnaryControlInstruction(value, NULL, NULL),
class_name_(class_name) { }
Handle<String> class_name_; Handle<String> class_name_;
}; };
class HTypeofIsAndBranch V8_FINAL : public HUnaryControlInstruction { class HTypeofIsAndBranch V8_FINAL : public HUnaryControlInstruction {
public: public:
HTypeofIsAndBranch(HValue* value, Handle<String> type_literal) DECLARE_INSTRUCTION_FACTORY_P2(HTypeofIsAndBranch, HValue*, Handle<String>);
: HUnaryControlInstruction(value, NULL, NULL),
type_literal_(type_literal) { }
Handle<String> type_literal() { return type_literal_; } Handle<String> type_literal() { return type_literal_; }
virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE; virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
...@@ -4435,17 +4460,17 @@ class HTypeofIsAndBranch V8_FINAL : public HUnaryControlInstruction { ...@@ -4435,17 +4460,17 @@ class HTypeofIsAndBranch V8_FINAL : public HUnaryControlInstruction {
} }
private: private:
HTypeofIsAndBranch(HValue* value, Handle<String> type_literal)
: HUnaryControlInstruction(value, NULL, NULL),
type_literal_(type_literal) { }
Handle<String> type_literal_; Handle<String> type_literal_;
}; };
class HInstanceOf V8_FINAL : public HBinaryOperation { class HInstanceOf V8_FINAL : public HBinaryOperation {
public: public:
HInstanceOf(HValue* context, HValue* left, HValue* right) DECLARE_INSTRUCTION_WITH_CONTEXT_FACTORY_P2(HInstanceOf, HValue*, HValue*);
: HBinaryOperation(context, left, right, HType::Boolean()) {
set_representation(Representation::Tagged());
SetAllSideEffects();
}
virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE { virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
return Representation::Tagged(); return Representation::Tagged();
...@@ -4454,6 +4479,13 @@ class HInstanceOf V8_FINAL : public HBinaryOperation { ...@@ -4454,6 +4479,13 @@ class HInstanceOf V8_FINAL : public HBinaryOperation {
virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE; virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
DECLARE_CONCRETE_INSTRUCTION(InstanceOf) DECLARE_CONCRETE_INSTRUCTION(InstanceOf)
private:
HInstanceOf(HValue* context, HValue* left, HValue* right)
: HBinaryOperation(context, left, right, HType::Boolean()) {
set_representation(Representation::Tagged());
SetAllSideEffects();
}
}; };
...@@ -4529,10 +4561,7 @@ class HPower V8_FINAL : public HTemplateInstruction<2> { ...@@ -4529,10 +4561,7 @@ class HPower V8_FINAL : public HTemplateInstruction<2> {
class HRandom V8_FINAL : public HTemplateInstruction<1> { class HRandom V8_FINAL : public HTemplateInstruction<1> {
public: public:
explicit HRandom(HValue* global_object) { DECLARE_INSTRUCTION_FACTORY_P1(HRandom, HValue*);
SetOperandAt(0, global_object);
set_representation(Representation::Double());
}
HValue* global_object() { return OperandAt(0); } HValue* global_object() { return OperandAt(0); }
...@@ -4543,6 +4572,11 @@ class HRandom V8_FINAL : public HTemplateInstruction<1> { ...@@ -4543,6 +4572,11 @@ class HRandom V8_FINAL : public HTemplateInstruction<1> {
DECLARE_CONCRETE_INSTRUCTION(Random) DECLARE_CONCRETE_INSTRUCTION(Random)
private: private:
explicit HRandom(HValue* global_object) {
SetOperandAt(0, global_object);
set_representation(Representation::Double());
}
virtual bool IsDeletable() const V8_OVERRIDE { return true; } virtual bool IsDeletable() const V8_OVERRIDE { return true; }
}; };
...@@ -5179,12 +5213,8 @@ class HUnknownOSRValue V8_FINAL : public HTemplateInstruction<0> { ...@@ -5179,12 +5213,8 @@ class HUnknownOSRValue V8_FINAL : public HTemplateInstruction<0> {
class HLoadGlobalCell V8_FINAL : public HTemplateInstruction<0> { class HLoadGlobalCell V8_FINAL : public HTemplateInstruction<0> {
public: public:
HLoadGlobalCell(Handle<Cell> cell, PropertyDetails details) DECLARE_INSTRUCTION_FACTORY_P2(HLoadGlobalCell, Handle<Cell>,
: cell_(Unique<Cell>::CreateUninitialized(cell)), details_(details) { PropertyDetails);
set_representation(Representation::Tagged());
SetFlag(kUseGVN);
SetGVNFlag(kDependsOnGlobalVars);
}
Unique<Cell> cell() const { return cell_; } Unique<Cell> cell() const { return cell_; }
bool RequiresHoleCheck() const; bool RequiresHoleCheck() const;
...@@ -5211,6 +5241,13 @@ class HLoadGlobalCell V8_FINAL : public HTemplateInstruction<0> { ...@@ -5211,6 +5241,13 @@ class HLoadGlobalCell V8_FINAL : public HTemplateInstruction<0> {
} }
private: private:
HLoadGlobalCell(Handle<Cell> cell, PropertyDetails details)
: cell_(Unique<Cell>::CreateUninitialized(cell)), details_(details) {
set_representation(Representation::Tagged());
SetFlag(kUseGVN);
SetGVNFlag(kDependsOnGlobalVars);
}
virtual bool IsDeletable() const V8_OVERRIDE { return !RequiresHoleCheck(); } virtual bool IsDeletable() const V8_OVERRIDE { return !RequiresHoleCheck(); }
Unique<Cell> cell_; Unique<Cell> cell_;
...@@ -5220,17 +5257,8 @@ class HLoadGlobalCell V8_FINAL : public HTemplateInstruction<0> { ...@@ -5220,17 +5257,8 @@ class HLoadGlobalCell V8_FINAL : public HTemplateInstruction<0> {
class HLoadGlobalGeneric V8_FINAL : public HTemplateInstruction<2> { class HLoadGlobalGeneric V8_FINAL : public HTemplateInstruction<2> {
public: public:
HLoadGlobalGeneric(HValue* context, DECLARE_INSTRUCTION_WITH_CONTEXT_FACTORY_P3(HLoadGlobalGeneric, HValue*,
HValue* global_object, Handle<Object>, bool);
Handle<Object> name,
bool for_typeof)
: name_(name),
for_typeof_(for_typeof) {
SetOperandAt(0, context);
SetOperandAt(1, global_object);
set_representation(Representation::Tagged());
SetAllSideEffects();
}
HValue* context() { return OperandAt(0); } HValue* context() { return OperandAt(0); }
HValue* global_object() { return OperandAt(1); } HValue* global_object() { return OperandAt(1); }
...@@ -5246,6 +5274,18 @@ class HLoadGlobalGeneric V8_FINAL : public HTemplateInstruction<2> { ...@@ -5246,6 +5274,18 @@ class HLoadGlobalGeneric V8_FINAL : public HTemplateInstruction<2> {
DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric) DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric)
private: private:
HLoadGlobalGeneric(HValue* context,
HValue* global_object,
Handle<Object> name,
bool for_typeof)
: name_(name),
for_typeof_(for_typeof) {
SetOperandAt(0, context);
SetOperandAt(1, global_object);
set_representation(Representation::Tagged());
SetAllSideEffects();
}
Handle<Object> name_; Handle<Object> name_;
bool for_typeof_; bool for_typeof_;
}; };
...@@ -5996,13 +6036,8 @@ class HLoadNamedField V8_FINAL : public HTemplateInstruction<1> { ...@@ -5996,13 +6036,8 @@ class HLoadNamedField V8_FINAL : public HTemplateInstruction<1> {
class HLoadNamedGeneric V8_FINAL : public HTemplateInstruction<2> { class HLoadNamedGeneric V8_FINAL : public HTemplateInstruction<2> {
public: public:
HLoadNamedGeneric(HValue* context, HValue* object, Handle<Object> name) DECLARE_INSTRUCTION_WITH_CONTEXT_FACTORY_P2(HLoadNamedGeneric, HValue*,
: name_(name) { Handle<Object>);
SetOperandAt(0, context);
SetOperandAt(1, object);
set_representation(Representation::Tagged());
SetAllSideEffects();
}
HValue* context() { return OperandAt(0); } HValue* context() { return OperandAt(0); }
HValue* object() { return OperandAt(1); } HValue* object() { return OperandAt(1); }
...@@ -6017,18 +6052,21 @@ class HLoadNamedGeneric V8_FINAL : public HTemplateInstruction<2> { ...@@ -6017,18 +6052,21 @@ class HLoadNamedGeneric V8_FINAL : public HTemplateInstruction<2> {
DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric) DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric)
private: private:
HLoadNamedGeneric(HValue* context, HValue* object, Handle<Object> name)
: name_(name) {
SetOperandAt(0, context);
SetOperandAt(1, object);
set_representation(Representation::Tagged());
SetAllSideEffects();
}
Handle<Object> name_; Handle<Object> name_;
}; };
class HLoadFunctionPrototype V8_FINAL : public HUnaryOperation { class HLoadFunctionPrototype V8_FINAL : public HUnaryOperation {
public: public:
explicit HLoadFunctionPrototype(HValue* function) DECLARE_INSTRUCTION_FACTORY_P1(HLoadFunctionPrototype, HValue*);
: HUnaryOperation(function) {
set_representation(Representation::Tagged());
SetFlag(kUseGVN);
SetGVNFlag(kDependsOnCalls);
}
HValue* function() { return OperandAt(0); } HValue* function() { return OperandAt(0); }
...@@ -6040,6 +6078,14 @@ class HLoadFunctionPrototype V8_FINAL : public HUnaryOperation { ...@@ -6040,6 +6078,14 @@ class HLoadFunctionPrototype V8_FINAL : public HUnaryOperation {
protected: protected:
virtual bool DataEquals(HValue* other) V8_OVERRIDE { return true; } virtual bool DataEquals(HValue* other) V8_OVERRIDE { return true; }
private:
explicit HLoadFunctionPrototype(HValue* function)
: HUnaryOperation(function) {
set_representation(Representation::Tagged());
SetFlag(kUseGVN);
SetGVNFlag(kDependsOnCalls);
}
}; };
class ArrayInstructionInterface { class ArrayInstructionInterface {
...@@ -6227,14 +6273,8 @@ class HLoadKeyed V8_FINAL ...@@ -6227,14 +6273,8 @@ class HLoadKeyed V8_FINAL
class HLoadKeyedGeneric V8_FINAL : public HTemplateInstruction<3> { class HLoadKeyedGeneric V8_FINAL : public HTemplateInstruction<3> {
public: public:
HLoadKeyedGeneric(HValue* context, HValue* obj, HValue* key) { DECLARE_INSTRUCTION_WITH_CONTEXT_FACTORY_P2(HLoadKeyedGeneric, HValue*,
set_representation(Representation::Tagged()); HValue*);
SetOperandAt(0, obj);
SetOperandAt(1, key);
SetOperandAt(2, context);
SetAllSideEffects();
}
HValue* object() { return OperandAt(0); } HValue* object() { return OperandAt(0); }
HValue* key() { return OperandAt(1); } HValue* key() { return OperandAt(1); }
HValue* context() { return OperandAt(2); } HValue* context() { return OperandAt(2); }
...@@ -6249,6 +6289,15 @@ class HLoadKeyedGeneric V8_FINAL : public HTemplateInstruction<3> { ...@@ -6249,6 +6289,15 @@ class HLoadKeyedGeneric V8_FINAL : public HTemplateInstruction<3> {
virtual HValue* Canonicalize() V8_OVERRIDE; virtual HValue* Canonicalize() V8_OVERRIDE;
DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric) DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric)
private:
HLoadKeyedGeneric(HValue* context, HValue* obj, HValue* key) {
set_representation(Representation::Tagged());
SetOperandAt(0, obj);
SetOperandAt(1, key);
SetOperandAt(2, context);
SetAllSideEffects();
}
}; };
...@@ -6367,19 +6416,9 @@ class HStoreNamedField V8_FINAL : public HTemplateInstruction<3> { ...@@ -6367,19 +6416,9 @@ class HStoreNamedField V8_FINAL : public HTemplateInstruction<3> {
class HStoreNamedGeneric V8_FINAL : public HTemplateInstruction<3> { class HStoreNamedGeneric V8_FINAL : public HTemplateInstruction<3> {
public: public:
HStoreNamedGeneric(HValue* context, DECLARE_INSTRUCTION_WITH_CONTEXT_FACTORY_P4(HStoreNamedGeneric, HValue*,
HValue* object, Handle<String>, HValue*,
Handle<String> name, StrictModeFlag);
HValue* value,
StrictModeFlag strict_mode_flag)
: name_(name),
strict_mode_flag_(strict_mode_flag) {
SetOperandAt(0, object);
SetOperandAt(1, value);
SetOperandAt(2, context);
SetAllSideEffects();
}
HValue* object() { return OperandAt(0); } HValue* object() { return OperandAt(0); }
HValue* value() { return OperandAt(1); } HValue* value() { return OperandAt(1); }
HValue* context() { return OperandAt(2); } HValue* context() { return OperandAt(2); }
...@@ -6395,6 +6434,19 @@ class HStoreNamedGeneric V8_FINAL : public HTemplateInstruction<3> { ...@@ -6395,6 +6434,19 @@ class HStoreNamedGeneric V8_FINAL : public HTemplateInstruction<3> {
DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric) DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric)
private: private:
HStoreNamedGeneric(HValue* context,
HValue* object,
Handle<String> name,
HValue* value,
StrictModeFlag strict_mode_flag)
: name_(name),
strict_mode_flag_(strict_mode_flag) {
SetOperandAt(0, object);
SetOperandAt(1, value);
SetOperandAt(2, context);
SetAllSideEffects();
}
Handle<String> name_; Handle<String> name_;
StrictModeFlag strict_mode_flag_; StrictModeFlag strict_mode_flag_;
}; };
...@@ -6543,18 +6595,8 @@ class HStoreKeyed V8_FINAL ...@@ -6543,18 +6595,8 @@ class HStoreKeyed V8_FINAL
class HStoreKeyedGeneric V8_FINAL : public HTemplateInstruction<4> { class HStoreKeyedGeneric V8_FINAL : public HTemplateInstruction<4> {
public: public:
HStoreKeyedGeneric(HValue* context, DECLARE_INSTRUCTION_WITH_CONTEXT_FACTORY_P4(HStoreKeyedGeneric, HValue*,
HValue* object, HValue*, HValue*, StrictModeFlag);
HValue* key,
HValue* value,
StrictModeFlag strict_mode_flag)
: strict_mode_flag_(strict_mode_flag) {
SetOperandAt(0, object);
SetOperandAt(1, key);
SetOperandAt(2, value);
SetOperandAt(3, context);
SetAllSideEffects();
}
HValue* object() { return OperandAt(0); } HValue* object() { return OperandAt(0); }
HValue* key() { return OperandAt(1); } HValue* key() { return OperandAt(1); }
...@@ -6572,6 +6614,19 @@ class HStoreKeyedGeneric V8_FINAL : public HTemplateInstruction<4> { ...@@ -6572,6 +6614,19 @@ class HStoreKeyedGeneric V8_FINAL : public HTemplateInstruction<4> {
DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric) DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric)
private: private:
HStoreKeyedGeneric(HValue* context,
HValue* object,
HValue* key,
HValue* value,
StrictModeFlag strict_mode_flag)
: strict_mode_flag_(strict_mode_flag) {
SetOperandAt(0, object);
SetOperandAt(1, key);
SetOperandAt(2, value);
SetOperandAt(3, context);
SetAllSideEffects();
}
StrictModeFlag strict_mode_flag_; StrictModeFlag strict_mode_flag_;
}; };
...@@ -6950,9 +7005,7 @@ class HToFastProperties V8_FINAL : public HUnaryOperation { ...@@ -6950,9 +7005,7 @@ class HToFastProperties V8_FINAL : public HUnaryOperation {
class HValueOf V8_FINAL : public HUnaryOperation { class HValueOf V8_FINAL : public HUnaryOperation {
public: public:
explicit HValueOf(HValue* value) : HUnaryOperation(value) { DECLARE_INSTRUCTION_FACTORY_P1(HValueOf, HValue*);
set_representation(Representation::Tagged());
}
virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE { virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
return Representation::Tagged(); return Representation::Tagged();
...@@ -6961,16 +7014,17 @@ class HValueOf V8_FINAL : public HUnaryOperation { ...@@ -6961,16 +7014,17 @@ class HValueOf V8_FINAL : public HUnaryOperation {
DECLARE_CONCRETE_INSTRUCTION(ValueOf) DECLARE_CONCRETE_INSTRUCTION(ValueOf)
private: private:
explicit HValueOf(HValue* value) : HUnaryOperation(value) {
set_representation(Representation::Tagged());
}
virtual bool IsDeletable() const V8_OVERRIDE { return true; } virtual bool IsDeletable() const V8_OVERRIDE { return true; }
}; };
class HDateField V8_FINAL : public HUnaryOperation { class HDateField V8_FINAL : public HUnaryOperation {
public: public:
HDateField(HValue* date, Smi* index) DECLARE_INSTRUCTION_FACTORY_P2(HDateField, HValue*, Smi*);
: HUnaryOperation(date), index_(index) {
set_representation(Representation::Tagged());
}
Smi* index() const { return index_; } Smi* index() const { return index_; }
...@@ -6981,21 +7035,19 @@ class HDateField V8_FINAL : public HUnaryOperation { ...@@ -6981,21 +7035,19 @@ class HDateField V8_FINAL : public HUnaryOperation {
DECLARE_CONCRETE_INSTRUCTION(DateField) DECLARE_CONCRETE_INSTRUCTION(DateField)
private: private:
HDateField(HValue* date, Smi* index)
: HUnaryOperation(date), index_(index) {
set_representation(Representation::Tagged());
}
Smi* index_; Smi* index_;
}; };
class HSeqStringSetChar V8_FINAL : public HTemplateInstruction<3> { class HSeqStringSetChar V8_FINAL : public HTemplateInstruction<3> {
public: public:
HSeqStringSetChar(String::Encoding encoding, DECLARE_INSTRUCTION_FACTORY_P4(HSeqStringSetChar, String::Encoding,
HValue* string, HValue*, HValue*, HValue*);
HValue* index,
HValue* value) : encoding_(encoding) {
SetOperandAt(0, string);
SetOperandAt(1, index);
SetOperandAt(2, value);
set_representation(Representation::Tagged());
}
String::Encoding encoding() { return encoding_; } String::Encoding encoding() { return encoding_; }
HValue* string() { return OperandAt(0); } HValue* string() { return OperandAt(0); }
...@@ -7010,6 +7062,16 @@ class HSeqStringSetChar V8_FINAL : public HTemplateInstruction<3> { ...@@ -7010,6 +7062,16 @@ class HSeqStringSetChar V8_FINAL : public HTemplateInstruction<3> {
DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar) DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar)
private: private:
HSeqStringSetChar(String::Encoding encoding,
HValue* string,
HValue* index,
HValue* value) : encoding_(encoding) {
SetOperandAt(0, string);
SetOperandAt(1, index);
SetOperandAt(2, value);
set_representation(Representation::Tagged());
}
String::Encoding encoding_; String::Encoding encoding_;
}; };
......
...@@ -1203,7 +1203,6 @@ HValue* HGraphBuilder::BuildCheckForCapacityGrow(HValue* object, ...@@ -1203,7 +1203,6 @@ HValue* HGraphBuilder::BuildCheckForCapacityGrow(HValue* object,
HValue* length, HValue* length,
HValue* key, HValue* key,
bool is_js_array) { bool is_js_array) {
Zone* zone = this->zone();
IfBuilder length_checker(this); IfBuilder length_checker(this);
Token::Value token = IsHoleyElementsKind(kind) ? Token::GTE : Token::EQ; Token::Value token = IsHoleyElementsKind(kind) ? Token::GTE : Token::EQ;
...@@ -1219,8 +1218,6 @@ HValue* HGraphBuilder::BuildCheckForCapacityGrow(HValue* object, ...@@ -1219,8 +1218,6 @@ HValue* HGraphBuilder::BuildCheckForCapacityGrow(HValue* object,
Token::GTE); Token::GTE);
capacity_checker.Then(); capacity_checker.Then();
HValue* context = environment()->context();
HValue* max_gap = Add<HConstant>(static_cast<int32_t>(JSObject::kMaxGap)); HValue* max_gap = Add<HConstant>(static_cast<int32_t>(JSObject::kMaxGap));
HValue* max_capacity = Add<HAdd>(current_capacity, max_gap); HValue* max_capacity = Add<HAdd>(current_capacity, max_gap);
IfBuilder key_checker(this); IfBuilder key_checker(this);
...@@ -1241,8 +1238,7 @@ HValue* HGraphBuilder::BuildCheckForCapacityGrow(HValue* object, ...@@ -1241,8 +1238,7 @@ HValue* HGraphBuilder::BuildCheckForCapacityGrow(HValue* object,
capacity_checker.End(); capacity_checker.End();
if (is_js_array) { if (is_js_array) {
HValue* new_length = AddInstruction( HValue* new_length = AddUncasted<HAdd>(key, graph_->GetConstant1());
HAdd::New(zone, context, key, graph_->GetConstant1()));
new_length->ClearFlag(HValue::kCanOverflow); new_length->ClearFlag(HValue::kCanOverflow);
Add<HStoreNamedField>(object, HObjectAccess::ForArrayLength(kind), Add<HStoreNamedField>(object, HObjectAccess::ForArrayLength(kind),
...@@ -2033,8 +2029,7 @@ HValue* HGraphBuilder::JSArrayBuilder::EmitMapCode() { ...@@ -2033,8 +2029,7 @@ HValue* HGraphBuilder::JSArrayBuilder::EmitMapCode() {
// No need for a context lookup if the kind_ matches the initial // No need for a context lookup if the kind_ matches the initial
// map, because we can just load the map in that case. // map, because we can just load the map in that case.
HObjectAccess access = HObjectAccess::ForPrototypeOrInitialMap(); HObjectAccess access = HObjectAccess::ForPrototypeOrInitialMap();
return builder()->AddInstruction( return builder()->AddLoadNamedField(constructor_function_, access);
builder()->BuildLoadNamedField(constructor_function_, access));
} }
HInstruction* native_context = builder()->BuildGetNativeContext(); HInstruction* native_context = builder()->BuildGetNativeContext();
...@@ -2054,8 +2049,7 @@ HValue* HGraphBuilder::JSArrayBuilder::EmitMapCode() { ...@@ -2054,8 +2049,7 @@ HValue* HGraphBuilder::JSArrayBuilder::EmitMapCode() {
HValue* HGraphBuilder::JSArrayBuilder::EmitInternalMapCode() { HValue* HGraphBuilder::JSArrayBuilder::EmitInternalMapCode() {
// Find the map near the constructor function // Find the map near the constructor function
HObjectAccess access = HObjectAccess::ForPrototypeOrInitialMap(); HObjectAccess access = HObjectAccess::ForPrototypeOrInitialMap();
return builder()->AddInstruction( return builder()->AddLoadNamedField(constructor_function_, access);
builder()->BuildLoadNamedField(constructor_function_, access));
} }
...@@ -4111,16 +4105,13 @@ void HOptimizedGraphBuilder::VisitVariableProxy(VariableProxy* expr) { ...@@ -4111,16 +4105,13 @@ void HOptimizedGraphBuilder::VisitVariableProxy(VariableProxy* expr) {
return ast_context()->ReturnInstruction(constant, expr->id()); return ast_context()->ReturnInstruction(constant, expr->id());
} else { } else {
HLoadGlobalCell* instr = HLoadGlobalCell* instr =
new(zone()) HLoadGlobalCell(cell, lookup.GetPropertyDetails()); New<HLoadGlobalCell>(cell, lookup.GetPropertyDetails());
return ast_context()->ReturnInstruction(instr, expr->id()); return ast_context()->ReturnInstruction(instr, expr->id());
} }
} else { } else {
HValue* context = environment()->context(); HGlobalObject* global_object = Add<HGlobalObject>();
HGlobalObject* global_object = new(zone()) HGlobalObject(context);
AddInstruction(global_object);
HLoadGlobalGeneric* instr = HLoadGlobalGeneric* instr =
new(zone()) HLoadGlobalGeneric(context, New<HLoadGlobalGeneric>(global_object,
global_object,
variable->name(), variable->name(),
ast_context()->is_for_typeof()); ast_context()->is_for_typeof());
return ast_context()->ReturnInstruction(instr, expr->id()); return ast_context()->ReturnInstruction(instr, expr->id());
...@@ -4657,9 +4648,7 @@ HInstruction* HOptimizedGraphBuilder::BuildStoreNamedGeneric( ...@@ -4657,9 +4648,7 @@ HInstruction* HOptimizedGraphBuilder::BuildStoreNamedGeneric(
HValue* object, HValue* object,
Handle<String> name, Handle<String> name,
HValue* value) { HValue* value) {
HValue* context = environment()->context(); return New<HStoreNamedGeneric>(
return new(zone()) HStoreNamedGeneric(
context,
object, object,
name, name,
value, value,
...@@ -4924,9 +4913,7 @@ void HOptimizedGraphBuilder::HandlePolymorphicLoadNamedField( ...@@ -4924,9 +4913,7 @@ void HOptimizedGraphBuilder::HandlePolymorphicLoadNamedField(
if (!ast_context()->IsEffect()) Push(graph()->GetConstant0()); if (!ast_context()->IsEffect()) Push(graph()->GetConstant0());
FinishExitWithHardDeoptimization("Unknown map in polymorphic load", join); FinishExitWithHardDeoptimization("Unknown map in polymorphic load", join);
} else { } else {
HValue* context = environment()->context(); HInstruction* load = Add<HLoadNamedGeneric>(object, name);
HInstruction* load = new(zone()) HLoadNamedGeneric(context, object, name);
AddInstruction(load);
if (!ast_context()->IsEffect()) Push(load); if (!ast_context()->IsEffect()) Push(load);
if (join != NULL) { if (join != NULL) {
...@@ -5492,7 +5479,7 @@ void HOptimizedGraphBuilder::VisitThrow(Throw* expr) { ...@@ -5492,7 +5479,7 @@ void HOptimizedGraphBuilder::VisitThrow(Throw* expr) {
// control flow at this point. This is not the case if the throw is inside // control flow at this point. This is not the case if the throw is inside
// an inlined function which may be replaced. // an inlined function which may be replaced.
if (call_context() == NULL) { if (call_context() == NULL) {
FinishExitCurrentBlock(new(zone()) HAbnormalExit); FinishExitCurrentBlock(New<HAbnormalExit>());
} }
} }
...@@ -5512,6 +5499,12 @@ HLoadNamedField* HGraphBuilder::BuildLoadNamedField(HValue* object, ...@@ -5512,6 +5499,12 @@ HLoadNamedField* HGraphBuilder::BuildLoadNamedField(HValue* object,
} }
HInstruction* HGraphBuilder::AddLoadNamedField(HValue* object,
HObjectAccess access) {
return AddInstruction(BuildLoadNamedField(object, access));
}
HInstruction* HGraphBuilder::BuildLoadStringLength(HValue* object, HInstruction* HGraphBuilder::BuildLoadStringLength(HValue* object,
HValue* checked_string) { HValue* checked_string) {
if (FLAG_fold_constants && object->IsConstant()) { if (FLAG_fold_constants && object->IsConstant()) {
...@@ -5532,16 +5525,14 @@ HInstruction* HOptimizedGraphBuilder::BuildLoadNamedGeneric( ...@@ -5532,16 +5525,14 @@ HInstruction* HOptimizedGraphBuilder::BuildLoadNamedGeneric(
Add<HDeoptimize>("Insufficient type feedback for generic named load", Add<HDeoptimize>("Insufficient type feedback for generic named load",
Deoptimizer::SOFT); Deoptimizer::SOFT);
} }
HValue* context = environment()->context(); return New<HLoadNamedGeneric>(object, name);
return new(zone()) HLoadNamedGeneric(context, object, name);
} }
HInstruction* HOptimizedGraphBuilder::BuildLoadKeyedGeneric(HValue* object, HInstruction* HOptimizedGraphBuilder::BuildLoadKeyedGeneric(HValue* object,
HValue* key) { HValue* key) {
HValue* context = environment()->context(); return New<HLoadKeyedGeneric>(object, key);
return new(zone()) HLoadKeyedGeneric(context, object, key);
} }
...@@ -5828,9 +5819,7 @@ HInstruction* HOptimizedGraphBuilder::BuildStoreKeyedGeneric( ...@@ -5828,9 +5819,7 @@ HInstruction* HOptimizedGraphBuilder::BuildStoreKeyedGeneric(
HValue* object, HValue* object,
HValue* key, HValue* key,
HValue* value) { HValue* value) {
HValue* context = environment()->context(); return New<HStoreKeyedGeneric>(
return new(zone()) HStoreKeyedGeneric(
context,
object, object,
key, key,
value, value,
...@@ -5897,7 +5886,7 @@ bool HOptimizedGraphBuilder::TryArgumentsAccess(Property* expr) { ...@@ -5897,7 +5886,7 @@ bool HOptimizedGraphBuilder::TryArgumentsAccess(Property* expr) {
HInstruction* elements = Add<HArgumentsElements>(false); HInstruction* elements = Add<HArgumentsElements>(false);
HInstruction* length = Add<HArgumentsLength>(elements); HInstruction* length = Add<HArgumentsLength>(elements);
HInstruction* checked_key = Add<HBoundsCheck>(key, length); HInstruction* checked_key = Add<HBoundsCheck>(key, length);
result = new(zone()) HAccessArgumentsAt(elements, length, checked_key); result = New<HAccessArgumentsAt>(elements, length, checked_key);
} else { } else {
EnsureArgumentsArePushedForAccess(); EnsureArgumentsArePushedForAccess();
...@@ -5907,7 +5896,7 @@ bool HOptimizedGraphBuilder::TryArgumentsAccess(Property* expr) { ...@@ -5907,7 +5896,7 @@ bool HOptimizedGraphBuilder::TryArgumentsAccess(Property* expr) {
arguments_environment()->parameter_count() - 1; arguments_environment()->parameter_count() - 1;
HInstruction* length = Add<HConstant>(argument_count); HInstruction* length = Add<HConstant>(argument_count);
HInstruction* checked_key = Add<HBoundsCheck>(key, length); HInstruction* checked_key = Add<HBoundsCheck>(key, length);
result = new(zone()) HAccessArgumentsAt(elements, length, checked_key); result = New<HAccessArgumentsAt>(elements, length, checked_key);
} }
} }
ast_context()->ReturnInstruction(result, expr->id()); ast_context()->ReturnInstruction(result, expr->id());
...@@ -5939,16 +5928,14 @@ void HOptimizedGraphBuilder::BuildLoad(Property* expr, ...@@ -5939,16 +5928,14 @@ void HOptimizedGraphBuilder::BuildLoad(Property* expr,
if (expr->IsStringAccess()) { if (expr->IsStringAccess()) {
HValue* index = Pop(); HValue* index = Pop();
HValue* string = Pop(); HValue* string = Pop();
HValue* context = environment()->context(); HInstruction* char_code = BuildStringCharCodeAt(string, index);
HInstruction* char_code =
BuildStringCharCodeAt(string, index);
AddInstruction(char_code); AddInstruction(char_code);
instr = HStringCharFromCode::New(zone(), context, char_code); instr = NewUncasted<HStringCharFromCode>(char_code);
} else if (expr->IsFunctionPrototype()) { } else if (expr->IsFunctionPrototype()) {
HValue* function = Pop(); HValue* function = Pop();
BuildCheckHeapObject(function); BuildCheckHeapObject(function);
instr = new(zone()) HLoadFunctionPrototype(function); instr = New<HLoadFunctionPrototype>(function);
} else if (expr->key()->IsPropertyName()) { } else if (expr->key()->IsPropertyName()) {
Handle<String> name = expr->key()->AsLiteral()->AsPropertyName(); Handle<String> name = expr->key()->AsLiteral()->AsPropertyName();
...@@ -6734,10 +6721,8 @@ bool HOptimizedGraphBuilder::TryInlineBuiltinFunctionCall(Call* expr, ...@@ -6734,10 +6721,8 @@ bool HOptimizedGraphBuilder::TryInlineBuiltinFunctionCall(Call* expr,
case kMathTan: case kMathTan:
if (expr->arguments()->length() == 1) { if (expr->arguments()->length() == 1) {
HValue* argument = Pop(); HValue* argument = Pop();
HValue* context = environment()->context();
Drop(1); // Receiver. Drop(1); // Receiver.
HInstruction* op = HInstruction* op = NewUncasted<HUnaryMathOperation>(argument, id);
HUnaryMathOperation::New(zone(), context, argument, id);
if (drop_extra) Drop(1); // Optionally drop the function. if (drop_extra) Drop(1); // Optionally drop the function.
ast_context()->ReturnInstruction(op, expr->id()); ast_context()->ReturnInstruction(op, expr->id());
return true; return true;
...@@ -6748,8 +6733,7 @@ bool HOptimizedGraphBuilder::TryInlineBuiltinFunctionCall(Call* expr, ...@@ -6748,8 +6733,7 @@ bool HOptimizedGraphBuilder::TryInlineBuiltinFunctionCall(Call* expr,
HValue* right = Pop(); HValue* right = Pop();
HValue* left = Pop(); HValue* left = Pop();
Drop(1); // Receiver. Drop(1); // Receiver.
HValue* context = environment()->context(); HInstruction* op = HMul::NewImul(zone(), context(), left, right);
HInstruction* op = HMul::NewImul(zone(), context, left, right);
if (drop_extra) Drop(1); // Optionally drop the function. if (drop_extra) Drop(1); // Optionally drop the function.
ast_context()->ReturnInstruction(op, expr->id()); ast_context()->ReturnInstruction(op, expr->id());
return true; return true;
...@@ -6779,7 +6763,6 @@ bool HOptimizedGraphBuilder::TryInlineBuiltinMethodCall( ...@@ -6779,7 +6763,6 @@ bool HOptimizedGraphBuilder::TryInlineBuiltinMethodCall(
if (argument_count == 2 && check_type == STRING_CHECK) { if (argument_count == 2 && check_type == STRING_CHECK) {
HValue* index = Pop(); HValue* index = Pop();
HValue* string = Pop(); HValue* string = Pop();
HValue* context = environment()->context();
ASSERT(!expr->holder().is_null()); ASSERT(!expr->holder().is_null());
BuildCheckPrototypeMaps(Call::GetPrototypeForPrimitiveCheck( BuildCheckPrototypeMaps(Call::GetPrototypeForPrimitiveCheck(
STRING_CHECK, expr->holder()->GetIsolate()), STRING_CHECK, expr->holder()->GetIsolate()),
...@@ -6791,8 +6774,7 @@ bool HOptimizedGraphBuilder::TryInlineBuiltinMethodCall( ...@@ -6791,8 +6774,7 @@ bool HOptimizedGraphBuilder::TryInlineBuiltinMethodCall(
return true; return true;
} }
AddInstruction(char_code); AddInstruction(char_code);
HInstruction* result = HInstruction* result = NewUncasted<HStringCharFromCode>(char_code);
HStringCharFromCode::New(zone(), context, char_code);
ast_context()->ReturnInstruction(result, expr->id()); ast_context()->ReturnInstruction(result, expr->id());
return true; return true;
} }
...@@ -6801,10 +6783,8 @@ bool HOptimizedGraphBuilder::TryInlineBuiltinMethodCall( ...@@ -6801,10 +6783,8 @@ bool HOptimizedGraphBuilder::TryInlineBuiltinMethodCall(
if (argument_count == 2 && check_type == RECEIVER_MAP_CHECK) { if (argument_count == 2 && check_type == RECEIVER_MAP_CHECK) {
AddCheckConstantFunction(expr->holder(), receiver, receiver_map); AddCheckConstantFunction(expr->holder(), receiver, receiver_map);
HValue* argument = Pop(); HValue* argument = Pop();
HValue* context = environment()->context();
Drop(1); // Receiver. Drop(1); // Receiver.
HInstruction* result = HInstruction* result = NewUncasted<HStringCharFromCode>(argument);
HStringCharFromCode::New(zone(), context, argument);
ast_context()->ReturnInstruction(result, expr->id()); ast_context()->ReturnInstruction(result, expr->id());
return true; return true;
} }
...@@ -6823,10 +6803,8 @@ bool HOptimizedGraphBuilder::TryInlineBuiltinMethodCall( ...@@ -6823,10 +6803,8 @@ bool HOptimizedGraphBuilder::TryInlineBuiltinMethodCall(
if (argument_count == 2 && check_type == RECEIVER_MAP_CHECK) { if (argument_count == 2 && check_type == RECEIVER_MAP_CHECK) {
AddCheckConstantFunction(expr->holder(), receiver, receiver_map); AddCheckConstantFunction(expr->holder(), receiver, receiver_map);
HValue* argument = Pop(); HValue* argument = Pop();
HValue* context = environment()->context();
Drop(1); // Receiver. Drop(1); // Receiver.
HInstruction* op = HInstruction* op = NewUncasted<HUnaryMathOperation>(argument, id);
HUnaryMathOperation::New(zone(), context, argument, id);
ast_context()->ReturnInstruction(op, expr->id()); ast_context()->ReturnInstruction(op, expr->id());
return true; return true;
} }
...@@ -6837,30 +6815,27 @@ bool HOptimizedGraphBuilder::TryInlineBuiltinMethodCall( ...@@ -6837,30 +6815,27 @@ bool HOptimizedGraphBuilder::TryInlineBuiltinMethodCall(
HValue* right = Pop(); HValue* right = Pop();
HValue* left = Pop(); HValue* left = Pop();
Pop(); // Pop receiver. Pop(); // Pop receiver.
HValue* context = environment()->context();
HInstruction* result = NULL; HInstruction* result = NULL;
// Use sqrt() if exponent is 0.5 or -0.5. // Use sqrt() if exponent is 0.5 or -0.5.
if (right->IsConstant() && HConstant::cast(right)->HasDoubleValue()) { if (right->IsConstant() && HConstant::cast(right)->HasDoubleValue()) {
double exponent = HConstant::cast(right)->DoubleValue(); double exponent = HConstant::cast(right)->DoubleValue();
if (exponent == 0.5) { if (exponent == 0.5) {
result = result = NewUncasted<HUnaryMathOperation>(left, kMathPowHalf);
HUnaryMathOperation::New(zone(), context, left, kMathPowHalf);
} else if (exponent == -0.5) { } else if (exponent == -0.5) {
HValue* one = graph()->GetConstant1(); HValue* one = graph()->GetConstant1();
HInstruction* sqrt = HInstruction* sqrt = AddUncasted<HUnaryMathOperation>(
HUnaryMathOperation::New(zone(), context, left, kMathPowHalf); left, kMathPowHalf);
AddInstruction(sqrt);
// MathPowHalf doesn't have side effects so there's no need for // MathPowHalf doesn't have side effects so there's no need for
// an environment simulation here. // an environment simulation here.
ASSERT(!sqrt->HasObservableSideEffects()); ASSERT(!sqrt->HasObservableSideEffects());
result = HDiv::New(zone(), context, one, sqrt); result = NewUncasted<HDiv>(one, sqrt);
} else if (exponent == 2.0) { } else if (exponent == 2.0) {
result = HMul::New(zone(), context, left, left); result = NewUncasted<HMul>(left, left);
} }
} }
if (result == NULL) { if (result == NULL) {
result = HPower::New(zone(), context, left, right); result = NewUncasted<HPower>(left, right);
} }
ast_context()->ReturnInstruction(result, expr->id()); ast_context()->ReturnInstruction(result, expr->id());
return true; return true;
...@@ -6871,7 +6846,7 @@ bool HOptimizedGraphBuilder::TryInlineBuiltinMethodCall( ...@@ -6871,7 +6846,7 @@ bool HOptimizedGraphBuilder::TryInlineBuiltinMethodCall(
AddCheckConstantFunction(expr->holder(), receiver, receiver_map); AddCheckConstantFunction(expr->holder(), receiver, receiver_map);
Drop(1); // Receiver. Drop(1); // Receiver.
HGlobalObject* global_object = Add<HGlobalObject>(); HGlobalObject* global_object = Add<HGlobalObject>();
HRandom* result = new(zone()) HRandom(global_object); HRandom* result = New<HRandom>(global_object);
ast_context()->ReturnInstruction(result, expr->id()); ast_context()->ReturnInstruction(result, expr->id());
return true; return true;
} }
...@@ -6883,11 +6858,9 @@ bool HOptimizedGraphBuilder::TryInlineBuiltinMethodCall( ...@@ -6883,11 +6858,9 @@ bool HOptimizedGraphBuilder::TryInlineBuiltinMethodCall(
HValue* right = Pop(); HValue* right = Pop();
HValue* left = Pop(); HValue* left = Pop();
Drop(1); // Receiver. Drop(1); // Receiver.
HValue* context = environment()->context();
HMathMinMax::Operation op = (id == kMathMin) ? HMathMinMax::kMathMin HMathMinMax::Operation op = (id == kMathMin) ? HMathMinMax::kMathMin
: HMathMinMax::kMathMax; : HMathMinMax::kMathMax;
HInstruction* result = HInstruction* result = NewUncasted<HMathMinMax>(left, right, op);
HMathMinMax::New(zone(), context, left, right, op);
ast_context()->ReturnInstruction(result, expr->id()); ast_context()->ReturnInstruction(result, expr->id());
return true; return true;
} }
...@@ -6898,8 +6871,7 @@ bool HOptimizedGraphBuilder::TryInlineBuiltinMethodCall( ...@@ -6898,8 +6871,7 @@ bool HOptimizedGraphBuilder::TryInlineBuiltinMethodCall(
HValue* right = Pop(); HValue* right = Pop();
HValue* left = Pop(); HValue* left = Pop();
Drop(1); // Receiver. Drop(1); // Receiver.
HValue* context = environment()->context(); HInstruction* result = HMul::NewImul(zone(), context(), left, right);
HInstruction* result = HMul::NewImul(zone(), context, left, right);
ast_context()->ReturnInstruction(result, expr->id()); ast_context()->ReturnInstruction(result, expr->id());
return true; return true;
} }
...@@ -6950,8 +6922,7 @@ bool HOptimizedGraphBuilder::TryCallApply(Call* expr) { ...@@ -6950,8 +6922,7 @@ bool HOptimizedGraphBuilder::TryCallApply(Call* expr) {
HInstruction* elements = Add<HArgumentsElements>(false); HInstruction* elements = Add<HArgumentsElements>(false);
HInstruction* length = Add<HArgumentsLength>(elements); HInstruction* length = Add<HArgumentsLength>(elements);
HValue* wrapped_receiver = BuildWrapReceiver(receiver, function); HValue* wrapped_receiver = BuildWrapReceiver(receiver, function);
HInstruction* result = HInstruction* result = New<HApplyArguments>(function,
new(zone()) HApplyArguments(function,
wrapped_receiver, wrapped_receiver,
length, length,
elements); elements);
...@@ -6985,10 +6956,7 @@ bool HOptimizedGraphBuilder::TryCallApply(Call* expr) { ...@@ -6985,10 +6956,7 @@ bool HOptimizedGraphBuilder::TryCallApply(Call* expr) {
PushAndAdd(New<HPushArgument>(arguments_values->at(i))); PushAndAdd(New<HPushArgument>(arguments_values->at(i)));
} }
HValue* context = environment()->context(); HInvokeFunction* call = New<HInvokeFunction>(function,
HInvokeFunction* call = new(zone()) HInvokeFunction(
context,
function,
known_function, known_function,
arguments_count); arguments_count);
Drop(arguments_count); Drop(arguments_count);
...@@ -7098,8 +7066,7 @@ void HOptimizedGraphBuilder::VisitCall(Call* expr) { ...@@ -7098,8 +7066,7 @@ void HOptimizedGraphBuilder::VisitCall(Call* expr) {
if (known_global_function) { if (known_global_function) {
// Push the global object instead of the global receiver because // Push the global object instead of the global receiver because
// code generated by the full code generator expects it. // code generated by the full code generator expects it.
HValue* context = environment()->context(); HGlobalObject* global_object = New<HGlobalObject>();
HGlobalObject* global_object = new(zone()) HGlobalObject(context);
PushAndAdd(global_object); PushAndAdd(global_object);
CHECK_ALIVE(VisitExpressions(expr->arguments())); CHECK_ALIVE(VisitExpressions(expr->arguments()));
...@@ -7134,8 +7101,8 @@ void HOptimizedGraphBuilder::VisitCall(Call* expr) { ...@@ -7134,8 +7101,8 @@ void HOptimizedGraphBuilder::VisitCall(Call* expr) {
// because it is likely to generate better code. // because it is likely to generate better code.
call = PreProcessCall(New<HCallNamed>(var->name(), argument_count)); call = PreProcessCall(New<HCallNamed>(var->name(), argument_count));
} else { } else {
call = PreProcessCall(new(zone()) HCallKnownGlobal(expr->target(), call = PreProcessCall(New<HCallKnownGlobal>(
argument_count)); expr->target(), argument_count));
} }
} else { } else {
HGlobalObject* receiver = Add<HGlobalObject>(); HGlobalObject* receiver = Add<HGlobalObject>();
...@@ -8133,7 +8100,7 @@ void HOptimizedGraphBuilder::HandleLiteralCompareTypeof(CompareOperation* expr, ...@@ -8133,7 +8100,7 @@ void HOptimizedGraphBuilder::HandleLiteralCompareTypeof(CompareOperation* expr,
CHECK_ALIVE(VisitForTypeOf(sub_expr)); CHECK_ALIVE(VisitForTypeOf(sub_expr));
if (!FLAG_emit_opt_code_positions) SetSourcePosition(expr->position()); if (!FLAG_emit_opt_code_positions) SetSourcePosition(expr->position());
HValue* value = Pop(); HValue* value = Pop();
HTypeofIsAndBranch* instr = new(zone()) HTypeofIsAndBranch(value, check); HTypeofIsAndBranch* instr = New<HTypeofIsAndBranch>(value, check);
return ast_context()->ReturnControl(instr, expr->id()); return ast_context()->ReturnControl(instr, expr->id());
} }
...@@ -8179,8 +8146,7 @@ void HOptimizedGraphBuilder::VisitCompareOperation(CompareOperation* expr) { ...@@ -8179,8 +8146,7 @@ void HOptimizedGraphBuilder::VisitCompareOperation(CompareOperation* expr) {
HValue* value = Pop(); HValue* value = Pop();
Literal* literal = expr->right()->AsLiteral(); Literal* literal = expr->right()->AsLiteral();
Handle<String> rhs = Handle<String>::cast(literal->value()); Handle<String> rhs = Handle<String>::cast(literal->value());
HClassOfTestAndBranch* instr = HClassOfTestAndBranch* instr = New<HClassOfTestAndBranch>(value, rhs);
new(zone()) HClassOfTestAndBranch(value, rhs);
return ast_context()->ReturnControl(instr, expr->id()); return ast_context()->ReturnControl(instr, expr->id());
} }
...@@ -8194,7 +8160,6 @@ void HOptimizedGraphBuilder::VisitCompareOperation(CompareOperation* expr) { ...@@ -8194,7 +8160,6 @@ void HOptimizedGraphBuilder::VisitCompareOperation(CompareOperation* expr) {
CHECK_ALIVE(VisitForValue(expr->left())); CHECK_ALIVE(VisitForValue(expr->left()));
CHECK_ALIVE(VisitForValue(expr->right())); CHECK_ALIVE(VisitForValue(expr->right()));
HValue* context = environment()->context();
HValue* right = Pop(); HValue* right = Pop();
HValue* left = Pop(); HValue* left = Pop();
Token::Value op = expr->op(); Token::Value op = expr->op();
...@@ -8232,7 +8197,7 @@ void HOptimizedGraphBuilder::VisitCompareOperation(CompareOperation* expr) { ...@@ -8232,7 +8197,7 @@ void HOptimizedGraphBuilder::VisitCompareOperation(CompareOperation* expr) {
// If the target is not null we have found a known global function that is // If the target is not null we have found a known global function that is
// assumed to stay the same for this instanceof. // assumed to stay the same for this instanceof.
if (target.is_null()) { if (target.is_null()) {
HInstanceOf* result = new(zone()) HInstanceOf(context, left, right); HInstanceOf* result = New<HInstanceOf>(left, right);
return ast_context()->ReturnInstruction(result, expr->id()); return ast_context()->ReturnInstruction(result, expr->id());
} else { } else {
Add<HCheckValue>(right, target); Add<HCheckValue>(right, target);
...@@ -8306,8 +8271,7 @@ void HOptimizedGraphBuilder::VisitCompareOperation(CompareOperation* expr) { ...@@ -8306,8 +8271,7 @@ void HOptimizedGraphBuilder::VisitCompareOperation(CompareOperation* expr) {
return ast_context()->ReturnControl(result, expr->id()); return ast_context()->ReturnControl(result, expr->id());
} else { } else {
if (combined_rep.IsTagged() || combined_rep.IsNone()) { if (combined_rep.IsTagged() || combined_rep.IsNone()) {
HCompareGeneric* result = HCompareGeneric* result = New<HCompareGeneric>(left, right, op);
new(zone()) HCompareGeneric(context, left, right, op);
result->set_observed_input_representation(1, left_rep); result->set_observed_input_representation(1, left_rep);
result->set_observed_input_representation(2, right_rep); result->set_observed_input_representation(2, right_rep);
return ast_context()->ReturnInstruction(result, expr->id()); return ast_context()->ReturnInstruction(result, expr->id());
...@@ -8357,7 +8321,7 @@ HInstruction* HOptimizedGraphBuilder::BuildThisFunction() { ...@@ -8357,7 +8321,7 @@ HInstruction* HOptimizedGraphBuilder::BuildThisFunction() {
return New<HConstant>( return New<HConstant>(
function_state()->compilation_info()->closure()); function_state()->compilation_info()->closure());
} else { } else {
return new(zone()) HThisFunction; return New<HThisFunction>();
} }
} }
...@@ -8777,7 +8741,7 @@ void HOptimizedGraphBuilder::GenerateHasCachedArrayIndex(CallRuntime* call) { ...@@ -8777,7 +8741,7 @@ void HOptimizedGraphBuilder::GenerateHasCachedArrayIndex(CallRuntime* call) {
CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); CHECK_ALIVE(VisitForValue(call->arguments()->at(0)));
HValue* value = Pop(); HValue* value = Pop();
HHasCachedArrayIndexAndBranch* result = HHasCachedArrayIndexAndBranch* result =
new(zone()) HHasCachedArrayIndexAndBranch(value); New<HHasCachedArrayIndexAndBranch>(value);
return ast_context()->ReturnControl(result, call->id()); return ast_context()->ReturnControl(result, call->id());
} }
...@@ -8841,7 +8805,7 @@ void HOptimizedGraphBuilder::GenerateIsConstructCall(CallRuntime* call) { ...@@ -8841,7 +8805,7 @@ void HOptimizedGraphBuilder::GenerateIsConstructCall(CallRuntime* call) {
: graph()->GetConstantFalse(); : graph()->GetConstantFalse();
return ast_context()->ReturnValue(value); return ast_context()->ReturnValue(value);
} else { } else {
return ast_context()->ReturnControl(new(zone()) HIsConstructCallAndBranch, return ast_context()->ReturnControl(New<HIsConstructCallAndBranch>(),
call->id()); call->id());
} }
} }
...@@ -8871,8 +8835,8 @@ void HOptimizedGraphBuilder::GenerateArguments(CallRuntime* call) { ...@@ -8871,8 +8835,8 @@ void HOptimizedGraphBuilder::GenerateArguments(CallRuntime* call) {
HInstruction* elements = Add<HArgumentsElements>(false); HInstruction* elements = Add<HArgumentsElements>(false);
HInstruction* length = Add<HArgumentsLength>(elements); HInstruction* length = Add<HArgumentsLength>(elements);
HInstruction* checked_index = Add<HBoundsCheck>(index, length); HInstruction* checked_index = Add<HBoundsCheck>(index, length);
HAccessArgumentsAt* result = HAccessArgumentsAt* result = New<HAccessArgumentsAt>(
new(zone()) HAccessArgumentsAt(elements, length, checked_index); elements, length, checked_index);
return ast_context()->ReturnInstruction(result, call->id()); return ast_context()->ReturnInstruction(result, call->id());
} }
...@@ -8889,7 +8853,7 @@ void HOptimizedGraphBuilder::GenerateValueOf(CallRuntime* call) { ...@@ -8889,7 +8853,7 @@ void HOptimizedGraphBuilder::GenerateValueOf(CallRuntime* call) {
ASSERT(call->arguments()->length() == 1); ASSERT(call->arguments()->length() == 1);
CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); CHECK_ALIVE(VisitForValue(call->arguments()->at(0)));
HValue* value = Pop(); HValue* value = Pop();
HValueOf* result = new(zone()) HValueOf(value); HValueOf* result = New<HValueOf>(value);
return ast_context()->ReturnInstruction(result, call->id()); return ast_context()->ReturnInstruction(result, call->id());
} }
...@@ -8900,7 +8864,7 @@ void HOptimizedGraphBuilder::GenerateDateField(CallRuntime* call) { ...@@ -8900,7 +8864,7 @@ void HOptimizedGraphBuilder::GenerateDateField(CallRuntime* call) {
Smi* index = Smi::cast(*(call->arguments()->at(1)->AsLiteral()->value())); Smi* index = Smi::cast(*(call->arguments()->at(1)->AsLiteral()->value()));
CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); CHECK_ALIVE(VisitForValue(call->arguments()->at(0)));
HValue* date = Pop(); HValue* date = Pop();
HDateField* result = new(zone()) HDateField(date, index); HDateField* result = New<HDateField>(date, index);
return ast_context()->ReturnInstruction(result, call->id()); return ast_context()->ReturnInstruction(result, call->id());
} }
...@@ -8914,7 +8878,7 @@ void HOptimizedGraphBuilder::GenerateOneByteSeqStringSetChar( ...@@ -8914,7 +8878,7 @@ void HOptimizedGraphBuilder::GenerateOneByteSeqStringSetChar(
HValue* value = Pop(); HValue* value = Pop();
HValue* index = Pop(); HValue* index = Pop();
HValue* string = Pop(); HValue* string = Pop();
HSeqStringSetChar* result = new(zone()) HSeqStringSetChar( HSeqStringSetChar* result = New<HSeqStringSetChar>(
String::ONE_BYTE_ENCODING, string, index, value); String::ONE_BYTE_ENCODING, string, index, value);
return ast_context()->ReturnInstruction(result, call->id()); return ast_context()->ReturnInstruction(result, call->id());
} }
...@@ -8929,7 +8893,7 @@ void HOptimizedGraphBuilder::GenerateTwoByteSeqStringSetChar( ...@@ -8929,7 +8893,7 @@ void HOptimizedGraphBuilder::GenerateTwoByteSeqStringSetChar(
HValue* value = Pop(); HValue* value = Pop();
HValue* index = Pop(); HValue* index = Pop();
HValue* string = Pop(); HValue* string = Pop();
HSeqStringSetChar* result = new(zone()) HSeqStringSetChar( HSeqStringSetChar* result = New<HSeqStringSetChar>(
String::TWO_BYTE_ENCODING, string, index, value); String::TWO_BYTE_ENCODING, string, index, value);
return ast_context()->ReturnInstruction(result, call->id()); return ast_context()->ReturnInstruction(result, call->id());
} }
...@@ -8987,7 +8951,7 @@ void HOptimizedGraphBuilder::GenerateStringCharFromCode(CallRuntime* call) { ...@@ -8987,7 +8951,7 @@ void HOptimizedGraphBuilder::GenerateStringCharFromCode(CallRuntime* call) {
ASSERT(call->arguments()->length() == 1); ASSERT(call->arguments()->length() == 1);
CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); CHECK_ALIVE(VisitForValue(call->arguments()->at(0)));
HValue* char_code = Pop(); HValue* char_code = Pop();
HInstruction* result = New<HStringCharFromCode>(char_code); HInstruction* result = NewUncasted<HStringCharFromCode>(char_code);
return ast_context()->ReturnInstruction(result, call->id()); return ast_context()->ReturnInstruction(result, call->id());
} }
...@@ -9001,7 +8965,7 @@ void HOptimizedGraphBuilder::GenerateStringCharAt(CallRuntime* call) { ...@@ -9001,7 +8965,7 @@ void HOptimizedGraphBuilder::GenerateStringCharAt(CallRuntime* call) {
HValue* string = Pop(); HValue* string = Pop();
HInstruction* char_code = BuildStringCharCodeAt(string, index); HInstruction* char_code = BuildStringCharCodeAt(string, index);
AddInstruction(char_code); AddInstruction(char_code);
HInstruction* result = New<HStringCharFromCode>(char_code); HInstruction* result = NewUncasted<HStringCharFromCode>(char_code);
return ast_context()->ReturnInstruction(result, call->id()); return ast_context()->ReturnInstruction(result, call->id());
} }
...@@ -9028,7 +8992,7 @@ void HOptimizedGraphBuilder::GenerateLog(CallRuntime* call) { ...@@ -9028,7 +8992,7 @@ void HOptimizedGraphBuilder::GenerateLog(CallRuntime* call) {
// Fast support for Math.random(). // Fast support for Math.random().
void HOptimizedGraphBuilder::GenerateRandomHeapNumber(CallRuntime* call) { void HOptimizedGraphBuilder::GenerateRandomHeapNumber(CallRuntime* call) {
HGlobalObject* global_object = Add<HGlobalObject>(); HGlobalObject* global_object = Add<HGlobalObject>();
HRandom* result = new(zone()) HRandom(global_object); HRandom* result = New<HRandom>(global_object);
return ast_context()->ReturnInstruction(result, call->id()); return ast_context()->ReturnInstruction(result, call->id());
} }
...@@ -9150,7 +9114,7 @@ void HOptimizedGraphBuilder::GenerateMathPow(CallRuntime* call) { ...@@ -9150,7 +9114,7 @@ void HOptimizedGraphBuilder::GenerateMathPow(CallRuntime* call) {
CHECK_ALIVE(VisitForValue(call->arguments()->at(1))); CHECK_ALIVE(VisitForValue(call->arguments()->at(1)));
HValue* right = Pop(); HValue* right = Pop();
HValue* left = Pop(); HValue* left = Pop();
HInstruction* result = HPower::New(zone(), context(), left, right); HInstruction* result = NewUncasted<HPower>(left, right);
return ast_context()->ReturnInstruction(result, call->id()); return ast_context()->ReturnInstruction(result, call->id());
} }
...@@ -9214,7 +9178,7 @@ void HOptimizedGraphBuilder::GenerateGetCachedArrayIndex(CallRuntime* call) { ...@@ -9214,7 +9178,7 @@ void HOptimizedGraphBuilder::GenerateGetCachedArrayIndex(CallRuntime* call) {
ASSERT(call->arguments()->length() == 1); ASSERT(call->arguments()->length() == 1);
CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); CHECK_ALIVE(VisitForValue(call->arguments()->at(0)));
HValue* value = Pop(); HValue* value = Pop();
HGetCachedArrayIndex* result = new(zone()) HGetCachedArrayIndex(value); HGetCachedArrayIndex* result = New<HGetCachedArrayIndex>(value);
return ast_context()->ReturnInstruction(result, call->id()); return ast_context()->ReturnInstruction(result, call->id());
} }
...@@ -9237,7 +9201,7 @@ void HOptimizedGraphBuilder::GenerateGeneratorThrow(CallRuntime* call) { ...@@ -9237,7 +9201,7 @@ void HOptimizedGraphBuilder::GenerateGeneratorThrow(CallRuntime* call) {
void HOptimizedGraphBuilder::GenerateDebugBreakInOptimizedCode( void HOptimizedGraphBuilder::GenerateDebugBreakInOptimizedCode(
CallRuntime* call) { CallRuntime* call) {
AddInstruction(new(zone()) HDebugBreak()); Add<HDebugBreak>();
return ast_context()->ReturnValue(graph()->GetConstant0()); return ast_context()->ReturnValue(graph()->GetConstant0());
} }
......
...@@ -1283,6 +1283,7 @@ class HGraphBuilder { ...@@ -1283,6 +1283,7 @@ class HGraphBuilder {
LoadKeyedHoleMode load_mode = NEVER_RETURN_HOLE); LoadKeyedHoleMode load_mode = NEVER_RETURN_HOLE);
HLoadNamedField* BuildLoadNamedField(HValue* object, HObjectAccess access); HLoadNamedField* BuildLoadNamedField(HValue* object, HObjectAccess access);
HInstruction* AddLoadNamedField(HValue* object, HObjectAccess access);
HInstruction* BuildLoadStringLength(HValue* object, HValue* checked_value); HInstruction* BuildLoadStringLength(HValue* object, HValue* checked_value);
HStoreNamedField* AddStoreMapConstant(HValue* object, Handle<Map>); HStoreNamedField* AddStoreMapConstant(HValue* object, Handle<Map>);
HLoadNamedField* AddLoadElements(HValue* object); HLoadNamedField* AddLoadElements(HValue* object);
...@@ -1948,21 +1949,22 @@ class HOptimizedGraphBuilder : public HGraphBuilder, public AstVisitor { ...@@ -1948,21 +1949,22 @@ class HOptimizedGraphBuilder : public HGraphBuilder, public AstVisitor {
env->Bind(index, value); env->Bind(index, value);
if (IsEligibleForEnvironmentLivenessAnalysis(var, index, value, env)) { if (IsEligibleForEnvironmentLivenessAnalysis(var, index, value, env)) {
HEnvironmentMarker* bind = HEnvironmentMarker* bind =
New<HEnvironmentMarker>(HEnvironmentMarker::BIND, index); Add<HEnvironmentMarker>(HEnvironmentMarker::BIND, index);
AddInstruction(bind); USE(bind);
#ifdef DEBUG #ifdef DEBUG
bind->set_closure(env->closure()); bind->set_closure(env->closure());
#endif #endif
} }
} }
HValue* LookupAndMakeLive(Variable* var) { HValue* LookupAndMakeLive(Variable* var) {
HEnvironment* env = environment(); HEnvironment* env = environment();
int index = env->IndexFor(var); int index = env->IndexFor(var);
HValue* value = env->Lookup(index); HValue* value = env->Lookup(index);
if (IsEligibleForEnvironmentLivenessAnalysis(var, index, value, env)) { if (IsEligibleForEnvironmentLivenessAnalysis(var, index, value, env)) {
HEnvironmentMarker* lookup = HEnvironmentMarker* lookup =
New<HEnvironmentMarker>(HEnvironmentMarker::LOOKUP, index); Add<HEnvironmentMarker>(HEnvironmentMarker::LOOKUP, index);
AddInstruction(lookup); USE(lookup);
#ifdef DEBUG #ifdef DEBUG
lookup->set_closure(env->closure()); lookup->set_closure(env->closure());
#endif #endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment