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

Make BuildBinaryOperation use ReturnValue instead of ReturnInstruction.

R=svenpanne@chromium.org

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@17914 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 6826b747
...@@ -896,17 +896,17 @@ HValue* CodeStubGraphBuilder<BinaryOpStub>::BuildCodeInitializedStub() { ...@@ -896,17 +896,17 @@ HValue* CodeStubGraphBuilder<BinaryOpStub>::BuildCodeInitializedStub() {
if_leftisstring.If<HIsStringAndBranch>(left); if_leftisstring.If<HIsStringAndBranch>(left);
if_leftisstring.Then(); if_leftisstring.Then();
{ {
Push(AddInstruction(BuildBinaryOperation( Push(BuildBinaryOperation(
stub->operation(), left, right, stub->operation(), left, right,
handle(Type::String(), isolate()), right_type, handle(Type::String(), isolate()), right_type,
result_type, stub->fixed_right_arg(), true))); result_type, stub->fixed_right_arg(), true));
} }
if_leftisstring.Else(); if_leftisstring.Else();
{ {
Push(AddInstruction(BuildBinaryOperation( Push(BuildBinaryOperation(
stub->operation(), left, right, stub->operation(), left, right,
left_type, right_type, result_type, left_type, right_type, result_type,
stub->fixed_right_arg(), true))); stub->fixed_right_arg(), true));
} }
if_leftisstring.End(); if_leftisstring.End();
result = Pop(); result = Pop();
...@@ -915,26 +915,26 @@ HValue* CodeStubGraphBuilder<BinaryOpStub>::BuildCodeInitializedStub() { ...@@ -915,26 +915,26 @@ HValue* CodeStubGraphBuilder<BinaryOpStub>::BuildCodeInitializedStub() {
if_rightisstring.If<HIsStringAndBranch>(right); if_rightisstring.If<HIsStringAndBranch>(right);
if_rightisstring.Then(); if_rightisstring.Then();
{ {
Push(AddInstruction(BuildBinaryOperation( Push(BuildBinaryOperation(
stub->operation(), left, right, stub->operation(), left, right,
left_type, handle(Type::String(), isolate()), left_type, handle(Type::String(), isolate()),
result_type, stub->fixed_right_arg(), true))); result_type, stub->fixed_right_arg(), true));
} }
if_rightisstring.Else(); if_rightisstring.Else();
{ {
Push(AddInstruction(BuildBinaryOperation( Push(BuildBinaryOperation(
stub->operation(), left, right, stub->operation(), left, right,
left_type, right_type, result_type, left_type, right_type, result_type,
stub->fixed_right_arg(), true))); stub->fixed_right_arg(), true));
} }
if_rightisstring.End(); if_rightisstring.End();
result = Pop(); result = Pop();
} }
} else { } else {
result = AddInstruction(BuildBinaryOperation( result = BuildBinaryOperation(
stub->operation(), left, right, stub->operation(), left, right,
left_type, right_type, result_type, left_type, right_type, result_type,
stub->fixed_right_arg(), true)); stub->fixed_right_arg(), true);
} }
// If we encounter a generic argument, the number conversion is // If we encounter a generic argument, the number conversion is
......
...@@ -5948,12 +5948,7 @@ void HOptimizedGraphBuilder::HandleCompoundAssignment(Assignment* expr) { ...@@ -5948,12 +5948,7 @@ void HOptimizedGraphBuilder::HandleCompoundAssignment(Assignment* expr) {
HValue* right = Pop(); HValue* right = Pop();
HValue* left = Pop(); HValue* left = Pop();
HInstruction* instr = BuildBinaryOperation(operation, left, right); Push(BuildBinaryOperation(operation, left, right));
AddInstruction(instr);
Push(instr);
if (instr->HasObservableSideEffects()) {
Add<HSimulate>(operation->id(), REMOVABLE_SIMULATE);
}
BuildStore(expr, prop, expr->id(), BuildStore(expr, prop, expr->id(),
expr->AssignmentId(), expr->IsUninitialized()); expr->AssignmentId(), expr->IsUninitialized());
} else { } else {
...@@ -8589,7 +8584,7 @@ HValue* HGraphBuilder::TruncateToNumber(HValue* value, Handle<Type>* expected) { ...@@ -8589,7 +8584,7 @@ HValue* HGraphBuilder::TruncateToNumber(HValue* value, Handle<Type>* expected) {
} }
HInstruction* HOptimizedGraphBuilder::BuildBinaryOperation( HValue* HOptimizedGraphBuilder::BuildBinaryOperation(
BinaryOperation* expr, BinaryOperation* expr,
HValue* left, HValue* left,
HValue* right) { HValue* right) {
...@@ -8598,12 +8593,22 @@ HInstruction* HOptimizedGraphBuilder::BuildBinaryOperation( ...@@ -8598,12 +8593,22 @@ HInstruction* HOptimizedGraphBuilder::BuildBinaryOperation(
Handle<Type> result_type = expr->bounds().lower; Handle<Type> result_type = expr->bounds().lower;
Maybe<int> fixed_right_arg = expr->fixed_right_arg(); Maybe<int> fixed_right_arg = expr->fixed_right_arg();
return HGraphBuilder::BuildBinaryOperation(expr->op(), left, right, HValue* result = HGraphBuilder::BuildBinaryOperation(
left_type, right_type, result_type, fixed_right_arg); expr->op(), left, right, left_type, right_type,
result_type, fixed_right_arg);
// Add a simulate after instructions with observable side effects, and
// after phis, which are the result of BuildBinaryOperation when we
// inlined some complex subgraph.
if (result->HasObservableSideEffects() || result->IsPhi()) {
Push(result);
Add<HSimulate>(expr->id(), REMOVABLE_SIMULATE);
Drop(1);
}
return result;
} }
HInstruction* HGraphBuilder::BuildBinaryOperation( HValue* HGraphBuilder::BuildBinaryOperation(
Token::Value op, Token::Value op,
HValue* left, HValue* left,
HValue* right, HValue* right,
...@@ -8664,7 +8669,7 @@ HInstruction* HGraphBuilder::BuildBinaryOperation( ...@@ -8664,7 +8669,7 @@ HInstruction* HGraphBuilder::BuildBinaryOperation(
HValue* function = AddLoadJSBuiltin(Builtins::STRING_ADD_RIGHT); HValue* function = AddLoadJSBuiltin(Builtins::STRING_ADD_RIGHT);
Add<HPushArgument>(left); Add<HPushArgument>(left);
Add<HPushArgument>(right); Add<HPushArgument>(right);
return NewUncasted<HInvokeFunction>(function, 2); return AddUncasted<HInvokeFunction>(function, 2);
} }
// Convert right argument as necessary. // Convert right argument as necessary.
...@@ -8676,10 +8681,10 @@ HInstruction* HGraphBuilder::BuildBinaryOperation( ...@@ -8676,10 +8681,10 @@ HInstruction* HGraphBuilder::BuildBinaryOperation(
HValue* function = AddLoadJSBuiltin(Builtins::STRING_ADD_LEFT); HValue* function = AddLoadJSBuiltin(Builtins::STRING_ADD_LEFT);
Add<HPushArgument>(left); Add<HPushArgument>(left);
Add<HPushArgument>(right); Add<HPushArgument>(right);
return NewUncasted<HInvokeFunction>(function, 2); return AddUncasted<HInvokeFunction>(function, 2);
} }
return NewUncasted<HStringAdd>(left, right, STRING_ADD_CHECK_NONE); return AddUncasted<HStringAdd>(left, right, STRING_ADD_CHECK_NONE);
} }
if (binop_stub) { if (binop_stub) {
...@@ -8700,51 +8705,51 @@ HInstruction* HGraphBuilder::BuildBinaryOperation( ...@@ -8700,51 +8705,51 @@ HInstruction* HGraphBuilder::BuildBinaryOperation(
HValue* function = AddLoadJSBuiltin(BinaryOpIC::TokenToJSBuiltin(op)); HValue* function = AddLoadJSBuiltin(BinaryOpIC::TokenToJSBuiltin(op));
Add<HPushArgument>(left); Add<HPushArgument>(left);
Add<HPushArgument>(right); Add<HPushArgument>(right);
instr = NewUncasted<HInvokeFunction>(function, 2); instr = AddUncasted<HInvokeFunction>(function, 2);
} else { } else {
switch (op) { switch (op) {
case Token::ADD: case Token::ADD:
instr = NewUncasted<HAdd>(left, right); instr = AddUncasted<HAdd>(left, right);
break; break;
case Token::SUB: case Token::SUB:
instr = NewUncasted<HSub>(left, right); instr = AddUncasted<HSub>(left, right);
break; break;
case Token::MUL: case Token::MUL:
instr = NewUncasted<HMul>(left, right); instr = AddUncasted<HMul>(left, right);
break; break;
case Token::MOD: case Token::MOD:
instr = NewUncasted<HMod>(left, right, fixed_right_arg); instr = AddUncasted<HMod>(left, right, fixed_right_arg);
break; break;
case Token::DIV: case Token::DIV:
instr = NewUncasted<HDiv>(left, right); instr = AddUncasted<HDiv>(left, right);
break; break;
case Token::BIT_XOR: case Token::BIT_XOR:
case Token::BIT_AND: case Token::BIT_AND:
instr = NewUncasted<HBitwise>(op, left, right); instr = AddUncasted<HBitwise>(op, left, right);
break; break;
case Token::BIT_OR: { case Token::BIT_OR: {
HValue* operand, *shift_amount; HValue* operand, *shift_amount;
if (left_type->Is(Type::Signed32()) && if (left_type->Is(Type::Signed32()) &&
right_type->Is(Type::Signed32()) && right_type->Is(Type::Signed32()) &&
MatchRotateRight(left, right, &operand, &shift_amount)) { MatchRotateRight(left, right, &operand, &shift_amount)) {
instr = NewUncasted<HRor>(operand, shift_amount); instr = AddUncasted<HRor>(operand, shift_amount);
} else { } else {
instr = NewUncasted<HBitwise>(op, left, right); instr = AddUncasted<HBitwise>(op, left, right);
} }
break; break;
} }
case Token::SAR: case Token::SAR:
instr = NewUncasted<HSar>(left, right); instr = AddUncasted<HSar>(left, right);
break; break;
case Token::SHR: case Token::SHR:
instr = NewUncasted<HShr>(left, right); instr = AddUncasted<HShr>(left, right);
if (FLAG_opt_safe_uint32_operations && instr->IsShr() && if (FLAG_opt_safe_uint32_operations && instr->IsShr() &&
CanBeZero(right)) { CanBeZero(right)) {
graph()->RecordUint32Instruction(instr); graph()->RecordUint32Instruction(instr);
} }
break; break;
case Token::SHL: case Token::SHL:
instr = NewUncasted<HShl>(left, right); instr = AddUncasted<HShl>(left, right);
break; break;
default: default:
UNREACHABLE(); UNREACHABLE();
...@@ -8920,12 +8925,12 @@ void HOptimizedGraphBuilder::VisitArithmeticExpression(BinaryOperation* expr) { ...@@ -8920,12 +8925,12 @@ void HOptimizedGraphBuilder::VisitArithmeticExpression(BinaryOperation* expr) {
SetSourcePosition(expr->position()); SetSourcePosition(expr->position());
HValue* right = Pop(); HValue* right = Pop();
HValue* left = Pop(); HValue* left = Pop();
HInstruction* instr = BuildBinaryOperation(expr, left, right); HValue* result = BuildBinaryOperation(expr, left, right);
if (FLAG_emit_opt_code_positions && instr->IsBinaryOperation()) { if (FLAG_emit_opt_code_positions && result->IsBinaryOperation()) {
HBinaryOperation::cast(instr)->SetOperandPositions( HBinaryOperation::cast(result)->SetOperandPositions(
zone(), expr->left()->position(), expr->right()->position()); zone(), expr->left()->position(), expr->right()->position());
} }
return ast_context()->ReturnInstruction(instr, expr->id()); return ast_context()->ReturnValue(result);
} }
......
...@@ -1339,14 +1339,14 @@ class HGraphBuilder { ...@@ -1339,14 +1339,14 @@ class HGraphBuilder {
HValue** operand, HValue** operand,
HValue** shift_amount); HValue** shift_amount);
HInstruction* BuildBinaryOperation(Token::Value op, HValue* BuildBinaryOperation(Token::Value op,
HValue* left, HValue* left,
HValue* right, HValue* right,
Handle<Type> left_type, Handle<Type> left_type,
Handle<Type> right_type, Handle<Type> right_type,
Handle<Type> result_type, Handle<Type> result_type,
Maybe<int> fixed_right_arg, Maybe<int> fixed_right_arg,
bool binop_stub = false); bool binop_stub = false);
HLoadNamedField* AddLoadFixedArrayLength(HValue *object); HLoadNamedField* AddLoadFixedArrayLength(HValue *object);
...@@ -2275,9 +2275,9 @@ class HOptimizedGraphBuilder : public HGraphBuilder, public AstVisitor { ...@@ -2275,9 +2275,9 @@ class HOptimizedGraphBuilder : public HGraphBuilder, public AstVisitor {
HInstruction* BuildStringCharCodeAt(HValue* string, HInstruction* BuildStringCharCodeAt(HValue* string,
HValue* index); HValue* index);
HInstruction* BuildBinaryOperation(BinaryOperation* expr, HValue* BuildBinaryOperation(BinaryOperation* expr,
HValue* left, HValue* left,
HValue* right); HValue* right);
HInstruction* BuildIncrement(bool returns_original_input, HInstruction* BuildIncrement(bool returns_original_input,
CountOperation* expr); CountOperation* expr);
HInstruction* BuildLoadKeyedGeneric(HValue* object, HInstruction* BuildLoadKeyedGeneric(HValue* object,
......
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