Commit f6001330 authored by bmeurer@chromium.org's avatar bmeurer@chromium.org

Fix HPushArguments instruction.

Use the zone that is passed to New() and fix implementation of
HPushArguments::AddInput() to match HPhi::AddInput().

R=jarin@chromium.org

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

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@21591 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 50cba82c
...@@ -298,7 +298,7 @@ HValue* CodeStubGraphBuilder<ToNumberStub>::BuildCodeStub() { ...@@ -298,7 +298,7 @@ HValue* CodeStubGraphBuilder<ToNumberStub>::BuildCodeStub() {
// Convert the parameter to number using the builtin. // Convert the parameter to number using the builtin.
HValue* function = AddLoadJSBuiltin(Builtins::TO_NUMBER); HValue* function = AddLoadJSBuiltin(Builtins::TO_NUMBER);
Add<HPushArguments>(zone(), value); Add<HPushArguments>(value);
Push(Add<HInvokeFunction>(function, 1)); Push(Add<HInvokeFunction>(function, 1));
if_number.End(); if_number.End();
......
...@@ -2434,6 +2434,12 @@ Range* HMathMinMax::InferRange(Zone* zone) { ...@@ -2434,6 +2434,12 @@ Range* HMathMinMax::InferRange(Zone* zone) {
} }
void HPushArguments::AddInput(HValue* value) {
inputs_.Add(NULL, value->block()->zone());
SetOperandAt(OperandCount() - 1, value);
}
void HPhi::PrintTo(StringStream* stream) { void HPhi::PrintTo(StringStream* stream) {
stream->Add("["); stream->Add("[");
for (int i = 0; i < OperandCount(); ++i) { for (int i = 0; i < OperandCount(); ++i) {
......
...@@ -2062,13 +2062,38 @@ class HLeaveInlined V8_FINAL : public HTemplateInstruction<0> { ...@@ -2062,13 +2062,38 @@ class HLeaveInlined V8_FINAL : public HTemplateInstruction<0> {
class HPushArguments V8_FINAL : public HInstruction { class HPushArguments V8_FINAL : public HInstruction {
public: public:
DECLARE_INSTRUCTION_FACTORY_P1(HPushArguments, Zone*); static HPushArguments* New(Zone* zone, HValue* context) {
DECLARE_INSTRUCTION_FACTORY_P2(HPushArguments, Zone*, HValue*); return new(zone) HPushArguments(zone);
DECLARE_INSTRUCTION_FACTORY_P3(HPushArguments, Zone*, HValue*, HValue*); }
DECLARE_INSTRUCTION_FACTORY_P4(HPushArguments, Zone*, static HPushArguments* New(Zone* zone, HValue* context, HValue* arg1) {
HValue*, HValue*, HValue*); HPushArguments* instr = new(zone) HPushArguments(zone);
DECLARE_INSTRUCTION_FACTORY_P5(HPushArguments, Zone*, instr->AddInput(arg1);
HValue*, HValue*, HValue*, HValue*); return instr;
}
static HPushArguments* New(Zone* zone, HValue* context, HValue* arg1,
HValue* arg2) {
HPushArguments* instr = new(zone) HPushArguments(zone);
instr->AddInput(arg1);
instr->AddInput(arg2);
return instr;
}
static HPushArguments* New(Zone* zone, HValue* context, HValue* arg1,
HValue* arg2, HValue* arg3) {
HPushArguments* instr = new(zone) HPushArguments(zone);
instr->AddInput(arg1);
instr->AddInput(arg2);
instr->AddInput(arg3);
return instr;
}
static HPushArguments* New(Zone* zone, HValue* context, HValue* arg1,
HValue* arg2, HValue* arg3, HValue* arg4) {
HPushArguments* instr = new(zone) HPushArguments(zone);
instr->AddInput(arg1);
instr->AddInput(arg2);
instr->AddInput(arg3);
instr->AddInput(arg4);
return instr;
}
virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE { virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
return Representation::Tagged(); return Representation::Tagged();
...@@ -2082,10 +2107,7 @@ class HPushArguments V8_FINAL : public HInstruction { ...@@ -2082,10 +2107,7 @@ class HPushArguments V8_FINAL : public HInstruction {
return inputs_[i]; return inputs_[i];
} }
void AddArgument(HValue* arg) { void AddInput(HValue* value);
inputs_.Add(NULL, zone_);
SetOperandAt(inputs_.length() - 1, arg);
}
DECLARE_CONCRETE_INSTRUCTION(PushArguments) DECLARE_CONCRETE_INSTRUCTION(PushArguments)
...@@ -2095,30 +2117,11 @@ class HPushArguments V8_FINAL : public HInstruction { ...@@ -2095,30 +2117,11 @@ class HPushArguments V8_FINAL : public HInstruction {
} }
private: private:
HPushArguments(Zone* zone, explicit HPushArguments(Zone* zone)
HValue* arg1 = NULL, HValue* arg2 = NULL, : HInstruction(HType::Tagged()), inputs_(4, zone) {
HValue* arg3 = NULL, HValue* arg4 = NULL)
: HInstruction(HType::Tagged()), zone_(zone), inputs_(4, zone) {
set_representation(Representation::Tagged()); set_representation(Representation::Tagged());
if (arg1) {
inputs_.Add(NULL, zone);
SetOperandAt(0, arg1);
}
if (arg2) {
inputs_.Add(NULL, zone);
SetOperandAt(1, arg2);
}
if (arg3) {
inputs_.Add(NULL, zone);
SetOperandAt(2, arg3);
}
if (arg4) {
inputs_.Add(NULL, zone);
SetOperandAt(3, arg4);
}
} }
Zone* zone_;
ZoneList<HValue*> inputs_; ZoneList<HValue*> inputs_;
}; };
......
...@@ -1734,7 +1734,7 @@ HValue* HGraphBuilder::BuildNumberToString(HValue* object, Type* type) { ...@@ -1734,7 +1734,7 @@ HValue* HGraphBuilder::BuildNumberToString(HValue* object, Type* type) {
if_found.Else(); if_found.Else();
{ {
// Cache miss, fallback to runtime. // Cache miss, fallback to runtime.
Add<HPushArguments>(zone(), object); Add<HPushArguments>(object);
Push(Add<HCallRuntime>( Push(Add<HCallRuntime>(
isolate()->factory()->empty_string(), isolate()->factory()->empty_string(),
Runtime::FunctionForId(Runtime::kHiddenNumberToStringSkipCache), Runtime::FunctionForId(Runtime::kHiddenNumberToStringSkipCache),
...@@ -2058,7 +2058,7 @@ HValue* HGraphBuilder::BuildUncheckedStringAdd( ...@@ -2058,7 +2058,7 @@ HValue* HGraphBuilder::BuildUncheckedStringAdd(
if_sameencodingandsequential.Else(); if_sameencodingandsequential.Else();
{ {
// Fallback to the runtime to add the two strings. // Fallback to the runtime to add the two strings.
Add<HPushArguments>(zone(), left, right); Add<HPushArguments>(left, right);
Push(Add<HCallRuntime>( Push(Add<HCallRuntime>(
isolate()->factory()->empty_string(), isolate()->factory()->empty_string(),
Runtime::FunctionForId(Runtime::kHiddenStringAdd), Runtime::FunctionForId(Runtime::kHiddenStringAdd),
...@@ -4197,9 +4197,9 @@ void HOptimizedGraphBuilder::PushArgumentsFromEnvironment(int count) { ...@@ -4197,9 +4197,9 @@ void HOptimizedGraphBuilder::PushArgumentsFromEnvironment(int count) {
arguments.Add(Pop(), zone()); arguments.Add(Pop(), zone());
} }
HPushArguments* push_args = New<HPushArguments>(zone()); HPushArguments* push_args = New<HPushArguments>();
while (!arguments.is_empty()) { while (!arguments.is_empty()) {
push_args->AddArgument(arguments.RemoveLast()); push_args->AddInput(arguments.RemoveLast());
} }
AddInstruction(push_args); AddInstruction(push_args);
} }
...@@ -5195,8 +5195,7 @@ void HOptimizedGraphBuilder::VisitObjectLiteral(ObjectLiteral* expr) { ...@@ -5195,8 +5195,7 @@ void HOptimizedGraphBuilder::VisitObjectLiteral(ObjectLiteral* expr) {
flags |= expr->has_function() flags |= expr->has_function()
? ObjectLiteral::kHasFunction : ObjectLiteral::kNoFlags; ? ObjectLiteral::kHasFunction : ObjectLiteral::kNoFlags;
Add<HPushArguments>(zone(), Add<HPushArguments>(Add<HConstant>(closure_literals),
Add<HConstant>(closure_literals),
Add<HConstant>(literal_index), Add<HConstant>(literal_index),
Add<HConstant>(constant_properties), Add<HConstant>(constant_properties),
Add<HConstant>(flags)); Add<HConstant>(flags));
...@@ -5354,8 +5353,7 @@ void HOptimizedGraphBuilder::VisitArrayLiteral(ArrayLiteral* expr) { ...@@ -5354,8 +5353,7 @@ void HOptimizedGraphBuilder::VisitArrayLiteral(ArrayLiteral* expr) {
: ArrayLiteral::kNoFlags; : ArrayLiteral::kNoFlags;
flags |= ArrayLiteral::kDisableMementos; flags |= ArrayLiteral::kDisableMementos;
Add<HPushArguments>(zone(), Add<HPushArguments>(Add<HConstant>(literals),
Add<HConstant>(literals),
Add<HConstant>(literal_index), Add<HConstant>(literal_index),
Add<HConstant>(constants), Add<HConstant>(constants),
Add<HConstant>(flags)); Add<HConstant>(flags));
...@@ -6373,7 +6371,7 @@ void HOptimizedGraphBuilder::VisitThrow(Throw* expr) { ...@@ -6373,7 +6371,7 @@ void HOptimizedGraphBuilder::VisitThrow(Throw* expr) {
HValue* value = environment()->Pop(); HValue* value = environment()->Pop();
if (!FLAG_hydrogen_track_positions) SetSourcePosition(expr->position()); if (!FLAG_hydrogen_track_positions) SetSourcePosition(expr->position());
Add<HPushArguments>(zone(), value); Add<HPushArguments>(value);
Add<HCallRuntime>(isolate()->factory()->empty_string(), Add<HCallRuntime>(isolate()->factory()->empty_string(),
Runtime::FunctionForId(Runtime::kHiddenThrow), 1); Runtime::FunctionForId(Runtime::kHiddenThrow), 1);
Add<HSimulate>(expr->id()); Add<HSimulate>(expr->id());
...@@ -6775,7 +6773,7 @@ void HOptimizedGraphBuilder::EnsureArgumentsArePushedForAccess() { ...@@ -6775,7 +6773,7 @@ void HOptimizedGraphBuilder::EnsureArgumentsArePushedForAccess() {
HInstruction* insert_after = entry; HInstruction* insert_after = entry;
for (int i = 0; i < arguments_values->length(); i++) { for (int i = 0; i < arguments_values->length(); i++) {
HValue* argument = arguments_values->at(i); HValue* argument = arguments_values->at(i);
HInstruction* push_argument = New<HPushArguments>(zone(), argument); HInstruction* push_argument = New<HPushArguments>(argument);
push_argument->InsertAfter(insert_after); push_argument->InsertAfter(insert_after);
insert_after = push_argument; insert_after = push_argument;
} }
...@@ -8070,7 +8068,7 @@ bool HOptimizedGraphBuilder::TryInlineApiCall(Handle<JSFunction> function, ...@@ -8070,7 +8068,7 @@ bool HOptimizedGraphBuilder::TryInlineApiCall(Handle<JSFunction> function,
ASSERT_EQ(NULL, receiver); ASSERT_EQ(NULL, receiver);
// Receiver is on expression stack. // Receiver is on expression stack.
receiver = Pop(); receiver = Pop();
Add<HPushArguments>(zone(), receiver); Add<HPushArguments>(receiver);
break; break;
case kCallApiSetter: case kCallApiSetter:
{ {
...@@ -8081,7 +8079,7 @@ bool HOptimizedGraphBuilder::TryInlineApiCall(Handle<JSFunction> function, ...@@ -8081,7 +8079,7 @@ bool HOptimizedGraphBuilder::TryInlineApiCall(Handle<JSFunction> function,
// Receiver and value are on expression stack. // Receiver and value are on expression stack.
HValue* value = Pop(); HValue* value = Pop();
receiver = Pop(); receiver = Pop();
Add<HPushArguments>(zone(), receiver, value); Add<HPushArguments>(receiver, value);
break; break;
} }
} }
...@@ -9127,8 +9125,7 @@ void HOptimizedGraphBuilder::VisitDelete(UnaryOperation* expr) { ...@@ -9127,8 +9125,7 @@ void HOptimizedGraphBuilder::VisitDelete(UnaryOperation* expr) {
HValue* key = Pop(); HValue* key = Pop();
HValue* obj = Pop(); HValue* obj = Pop();
HValue* function = AddLoadJSBuiltin(Builtins::DELETE); HValue* function = AddLoadJSBuiltin(Builtins::DELETE);
Add<HPushArguments>(zone(), Add<HPushArguments>(obj, key, Add<HConstant>(function_strict_mode()));
obj, key, Add<HConstant>(function_strict_mode()));
// TODO(olivf) InvokeFunction produces a check for the parameter count, // TODO(olivf) InvokeFunction produces a check for the parameter count,
// even though we are certain to pass the correct number of arguments here. // even though we are certain to pass the correct number of arguments here.
HInstruction* instr = New<HInvokeFunction>(function, 3); HInstruction* instr = New<HInvokeFunction>(function, 3);
...@@ -9608,7 +9605,7 @@ HValue* HGraphBuilder::BuildBinaryOperation( ...@@ -9608,7 +9605,7 @@ HValue* HGraphBuilder::BuildBinaryOperation(
} else if (!left_type->Is(Type::String())) { } else if (!left_type->Is(Type::String())) {
ASSERT(right_type->Is(Type::String())); ASSERT(right_type->Is(Type::String()));
HValue* function = AddLoadJSBuiltin(Builtins::STRING_ADD_RIGHT); HValue* function = AddLoadJSBuiltin(Builtins::STRING_ADD_RIGHT);
Add<HPushArguments>(zone(), left, right); Add<HPushArguments>(left, right);
return AddUncasted<HInvokeFunction>(function, 2); return AddUncasted<HInvokeFunction>(function, 2);
} }
...@@ -9619,7 +9616,7 @@ HValue* HGraphBuilder::BuildBinaryOperation( ...@@ -9619,7 +9616,7 @@ HValue* HGraphBuilder::BuildBinaryOperation(
} else if (!right_type->Is(Type::String())) { } else if (!right_type->Is(Type::String())) {
ASSERT(left_type->Is(Type::String())); ASSERT(left_type->Is(Type::String()));
HValue* function = AddLoadJSBuiltin(Builtins::STRING_ADD_LEFT); HValue* function = AddLoadJSBuiltin(Builtins::STRING_ADD_LEFT);
Add<HPushArguments>(zone(), left, right); Add<HPushArguments>(left, right);
return AddUncasted<HInvokeFunction>(function, 2); return AddUncasted<HInvokeFunction>(function, 2);
} }
...@@ -9681,7 +9678,7 @@ HValue* HGraphBuilder::BuildBinaryOperation( ...@@ -9681,7 +9678,7 @@ HValue* HGraphBuilder::BuildBinaryOperation(
// operation in optimized code, which is more expensive, than a stub call. // operation in optimized code, which is more expensive, than a stub call.
if (graph()->info()->IsStub() && is_non_primitive) { if (graph()->info()->IsStub() && is_non_primitive) {
HValue* function = AddLoadJSBuiltin(BinaryOpIC::TokenToJSBuiltin(op)); HValue* function = AddLoadJSBuiltin(BinaryOpIC::TokenToJSBuiltin(op));
Add<HPushArguments>(zone(), left, right); Add<HPushArguments>(left, right);
instr = AddUncasted<HInvokeFunction>(function, 2); instr = AddUncasted<HInvokeFunction>(function, 2);
} else { } else {
switch (op) { switch (op) {
...@@ -10045,7 +10042,7 @@ void HOptimizedGraphBuilder::VisitCompareOperation(CompareOperation* expr) { ...@@ -10045,7 +10042,7 @@ void HOptimizedGraphBuilder::VisitCompareOperation(CompareOperation* expr) {
UNREACHABLE(); UNREACHABLE();
} else if (op == Token::IN) { } else if (op == Token::IN) {
HValue* function = AddLoadJSBuiltin(Builtins::IN); HValue* function = AddLoadJSBuiltin(Builtins::IN);
Add<HPushArguments>(zone(), left, right); Add<HPushArguments>(left, right);
// TODO(olivf) InvokeFunction produces a check for the parameter count, // TODO(olivf) InvokeFunction produces a check for the parameter count,
// even though we are certain to pass the correct number of arguments here. // even though we are certain to pass the correct number of arguments here.
HInstruction* result = New<HInvokeFunction>(function, 2); HInstruction* result = New<HInvokeFunction>(function, 2);
......
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