Revert of [ignition] Inline the binary op TurboFan code stubs in the bytecode handlers. (patchset #4 id:60001 of https://codereview.chromium.org/1902823002/ )

Reason for revert:
Caused a performance regression in TurboFan and did not improve in a significant way Ignition's performances.

Original issue's description:
> [ignition] Inline the binary op TurboFan code stubs in the bytecode handlers.
>
> Adds a Generate method to the stubs that can be used to embed the graph directly in the bytecode handlers.
>
> Committed: https://crrev.com/e8caf78ff2a9f7d50ac9b47f6b4c80f92b69914a
> Cr-Commit-Position: refs/heads/master@{#35696}

TBR=bmeurer@chromium.org,rmcilroy@chromium.org,machenbach@chromium.org
# Not skipping CQ checks because original CL landed more than 1 days ago.

Review-Url: https://codereview.chromium.org/1927873002
Cr-Commit-Position: refs/heads/master@{#35851}
This commit is contained in:
epertoso 2016-04-28 03:02:34 -07:00 committed by Commit bot
parent 622c92b88f
commit 941f553574
4 changed files with 127 additions and 188 deletions

View File

@ -498,27 +498,26 @@ void StringLengthStub::GenerateAssembly(CodeStubAssembler* assembler) const {
assembler->Return(result); assembler->Return(result);
} }
compiler::Node* AddStub::Generate(CodeStubAssembler* assembler, void AddStub::GenerateAssembly(CodeStubAssembler* assembler) const {
compiler::Node* left, compiler::Node* right,
compiler::Node* context) {
typedef CodeStubAssembler::Label Label; typedef CodeStubAssembler::Label Label;
typedef compiler::Node Node; typedef compiler::Node Node;
typedef CodeStubAssembler::Variable Variable; typedef CodeStubAssembler::Variable Variable;
Node* context = assembler->Parameter(2);
// Shared entry for floating point addition. // Shared entry for floating point addition.
Label do_fadd(assembler), end(assembler); Label do_fadd(assembler);
Variable var_fadd_lhs(assembler, MachineRepresentation::kFloat64), Variable var_fadd_lhs(assembler, MachineRepresentation::kFloat64),
var_fadd_rhs(assembler, MachineRepresentation::kFloat64); var_fadd_rhs(assembler, MachineRepresentation::kFloat64);
// We might need to loop several times due to ToPrimitive, ToString and/or // We might need to loop several times due to ToPrimitive, ToString and/or
// ToNumber conversions. // ToNumber conversions.
Variable var_lhs(assembler, MachineRepresentation::kTagged), Variable var_lhs(assembler, MachineRepresentation::kTagged),
var_rhs(assembler, MachineRepresentation::kTagged), var_rhs(assembler, MachineRepresentation::kTagged);
var_result(assembler, MachineRepresentation::kTagged);
Variable* loop_vars[2] = {&var_lhs, &var_rhs}; Variable* loop_vars[2] = {&var_lhs, &var_rhs};
Label loop(assembler, 2, loop_vars); Label loop(assembler, 2, loop_vars);
var_lhs.Bind(left); var_lhs.Bind(assembler->Parameter(0));
var_rhs.Bind(right); var_rhs.Bind(assembler->Parameter(1));
assembler->Goto(&loop); assembler->Goto(&loop);
assembler->Bind(&loop); assembler->Bind(&loop);
{ {
@ -555,8 +554,7 @@ compiler::Node* AddStub::Generate(CodeStubAssembler* assembler,
} }
assembler->Bind(&if_notoverflow); assembler->Bind(&if_notoverflow);
var_result.Bind(assembler->Projection(0, pair)); assembler->Return(assembler->Projection(0, pair));
assembler->Goto(&end);
} }
assembler->Bind(&if_rhsisnotsmi); assembler->Bind(&if_rhsisnotsmi);
@ -597,8 +595,7 @@ compiler::Node* AddStub::Generate(CodeStubAssembler* assembler,
// resulting string with the String {rhs}. // resulting string with the String {rhs}.
Callable callable = CodeFactory::StringAdd( Callable callable = CodeFactory::StringAdd(
assembler->isolate(), STRING_ADD_CONVERT_LEFT, NOT_TENURED); assembler->isolate(), STRING_ADD_CONVERT_LEFT, NOT_TENURED);
var_result.Bind(assembler->CallStub(callable, context, lhs, rhs)); assembler->TailCallStub(callable, context, lhs, rhs);
assembler->Goto(&end);
} }
assembler->Bind(&if_rhsisnotstring); assembler->Bind(&if_rhsisnotstring);
@ -652,8 +649,7 @@ compiler::Node* AddStub::Generate(CodeStubAssembler* assembler,
// no hint followed by ToString) and concatenate the strings. // no hint followed by ToString) and concatenate the strings.
Callable callable = CodeFactory::StringAdd( Callable callable = CodeFactory::StringAdd(
assembler->isolate(), STRING_ADD_CONVERT_RIGHT, NOT_TENURED); assembler->isolate(), STRING_ADD_CONVERT_RIGHT, NOT_TENURED);
var_result.Bind(assembler->CallStub(callable, context, lhs, rhs)); assembler->TailCallStub(callable, context, lhs, rhs);
assembler->Goto(&end);
} }
assembler->Bind(&if_lhsisnotstring); assembler->Bind(&if_lhsisnotstring);
@ -731,8 +727,7 @@ compiler::Node* AddStub::Generate(CodeStubAssembler* assembler,
// no hint followed by ToString) and concatenate the strings. // no hint followed by ToString) and concatenate the strings.
Callable callable = CodeFactory::StringAdd( Callable callable = CodeFactory::StringAdd(
assembler->isolate(), STRING_ADD_CONVERT_LEFT, NOT_TENURED); assembler->isolate(), STRING_ADD_CONVERT_LEFT, NOT_TENURED);
var_result.Bind(assembler->CallStub(callable, context, lhs, rhs)); assembler->TailCallStub(callable, context, lhs, rhs);
assembler->Goto(&end);
} }
assembler->Bind(&if_rhsisnotstring); assembler->Bind(&if_rhsisnotstring);
@ -854,35 +849,31 @@ compiler::Node* AddStub::Generate(CodeStubAssembler* assembler,
Node* lhs_value = var_fadd_lhs.value(); Node* lhs_value = var_fadd_lhs.value();
Node* rhs_value = var_fadd_rhs.value(); Node* rhs_value = var_fadd_rhs.value();
Node* value = assembler->Float64Add(lhs_value, rhs_value); Node* value = assembler->Float64Add(lhs_value, rhs_value);
var_result.Bind(assembler->ChangeFloat64ToTagged(value)); Node* result = assembler->ChangeFloat64ToTagged(value);
assembler->Goto(&end); assembler->Return(result);
} }
assembler->Bind(&end);
return var_result.value();
} }
compiler::Node* SubtractStub::Generate(CodeStubAssembler* assembler, void SubtractStub::GenerateAssembly(CodeStubAssembler* assembler) const {
compiler::Node* left,
compiler::Node* right,
compiler::Node* context) {
typedef CodeStubAssembler::Label Label; typedef CodeStubAssembler::Label Label;
typedef compiler::Node Node; typedef compiler::Node Node;
typedef CodeStubAssembler::Variable Variable; typedef CodeStubAssembler::Variable Variable;
Node* context = assembler->Parameter(2);
// Shared entry for floating point subtraction. // Shared entry for floating point subtraction.
Label do_fsub(assembler), end(assembler); Label do_fsub(assembler);
Variable var_fsub_lhs(assembler, MachineRepresentation::kFloat64), Variable var_fsub_lhs(assembler, MachineRepresentation::kFloat64),
var_fsub_rhs(assembler, MachineRepresentation::kFloat64); var_fsub_rhs(assembler, MachineRepresentation::kFloat64);
// We might need to loop several times due to ToPrimitive and/or ToNumber // We might need to loop several times due to ToPrimitive and/or ToNumber
// conversions. // conversions.
Variable var_lhs(assembler, MachineRepresentation::kTagged), Variable var_lhs(assembler, MachineRepresentation::kTagged),
var_rhs(assembler, MachineRepresentation::kTagged), var_rhs(assembler, MachineRepresentation::kTagged);
var_result(assembler, MachineRepresentation::kTagged);
Variable* loop_vars[2] = {&var_lhs, &var_rhs}; Variable* loop_vars[2] = {&var_lhs, &var_rhs};
Label loop(assembler, 2, loop_vars); Label loop(assembler, 2, loop_vars);
var_lhs.Bind(left); var_lhs.Bind(assembler->Parameter(0));
var_rhs.Bind(right); var_rhs.Bind(assembler->Parameter(1));
assembler->Goto(&loop); assembler->Goto(&loop);
assembler->Bind(&loop); assembler->Bind(&loop);
{ {
@ -920,8 +911,7 @@ compiler::Node* SubtractStub::Generate(CodeStubAssembler* assembler,
} }
assembler->Bind(&if_notoverflow); assembler->Bind(&if_notoverflow);
var_result.Bind(assembler->Projection(0, pair)); assembler->Return(assembler->Projection(0, pair));
assembler->Goto(&end);
} }
assembler->Bind(&if_rhsisnotsmi); assembler->Bind(&if_rhsisnotsmi);
@ -947,8 +937,7 @@ compiler::Node* SubtractStub::Generate(CodeStubAssembler* assembler,
assembler->Bind(&if_rhsisnotnumber); assembler->Bind(&if_rhsisnotnumber);
{ {
// Convert the {rhs} to a Number first. // Convert the {rhs} to a Number first.
Callable callable = Callable callable = CodeFactory::NonNumberToNumber(isolate());
CodeFactory::NonNumberToNumber(assembler->isolate());
var_rhs.Bind(assembler->CallStub(callable, context, rhs)); var_rhs.Bind(assembler->CallStub(callable, context, rhs));
assembler->Goto(&loop); assembler->Goto(&loop);
} }
@ -1004,8 +993,7 @@ compiler::Node* SubtractStub::Generate(CodeStubAssembler* assembler,
assembler->Bind(&if_rhsisnotnumber); assembler->Bind(&if_rhsisnotnumber);
{ {
// Convert the {rhs} to a Number first. // Convert the {rhs} to a Number first.
Callable callable = Callable callable = CodeFactory::NonNumberToNumber(isolate());
CodeFactory::NonNumberToNumber(assembler->isolate());
var_rhs.Bind(assembler->CallStub(callable, context, rhs)); var_rhs.Bind(assembler->CallStub(callable, context, rhs));
assembler->Goto(&loop); assembler->Goto(&loop);
} }
@ -1015,8 +1003,7 @@ compiler::Node* SubtractStub::Generate(CodeStubAssembler* assembler,
assembler->Bind(&if_lhsisnotnumber); assembler->Bind(&if_lhsisnotnumber);
{ {
// Convert the {lhs} to a Number first. // Convert the {lhs} to a Number first.
Callable callable = Callable callable = CodeFactory::NonNumberToNumber(isolate());
CodeFactory::NonNumberToNumber(assembler->isolate());
var_lhs.Bind(assembler->CallStub(callable, context, lhs)); var_lhs.Bind(assembler->CallStub(callable, context, lhs));
assembler->Goto(&loop); assembler->Goto(&loop);
} }
@ -1028,22 +1015,18 @@ compiler::Node* SubtractStub::Generate(CodeStubAssembler* assembler,
Node* lhs_value = var_fsub_lhs.value(); Node* lhs_value = var_fsub_lhs.value();
Node* rhs_value = var_fsub_rhs.value(); Node* rhs_value = var_fsub_rhs.value();
Node* value = assembler->Float64Sub(lhs_value, rhs_value); Node* value = assembler->Float64Sub(lhs_value, rhs_value);
var_result.Bind(assembler->ChangeFloat64ToTagged(value)); Node* result = assembler->ChangeFloat64ToTagged(value);
assembler->Goto(&end); assembler->Return(result);
} }
assembler->Bind(&end);
return var_result.value();
} }
// static void MultiplyStub::GenerateAssembly(CodeStubAssembler* assembler) const {
compiler::Node* MultiplyStub::Generate(CodeStubAssembler* assembler,
compiler::Node* left,
compiler::Node* right,
compiler::Node* context) {
using compiler::Node; using compiler::Node;
typedef CodeStubAssembler::Label Label; typedef CodeStubAssembler::Label Label;
typedef CodeStubAssembler::Variable Variable; typedef CodeStubAssembler::Variable Variable;
Node* context = assembler->Parameter(2);
// Shared entry point for floating point multiplication. // Shared entry point for floating point multiplication.
Label do_fmul(assembler); Label do_fmul(assembler);
Variable var_lhs_float64(assembler, MachineRepresentation::kFloat64), Variable var_lhs_float64(assembler, MachineRepresentation::kFloat64),
@ -1056,8 +1039,8 @@ compiler::Node* MultiplyStub::Generate(CodeStubAssembler* assembler,
var_rhs(assembler, MachineRepresentation::kTagged); var_rhs(assembler, MachineRepresentation::kTagged);
Variable* loop_variables[] = {&var_lhs, &var_rhs}; Variable* loop_variables[] = {&var_lhs, &var_rhs};
Label loop(assembler, 2, loop_variables); Label loop(assembler, 2, loop_variables);
var_lhs.Bind(left); var_lhs.Bind(assembler->Parameter(0));
var_rhs.Bind(right); var_rhs.Bind(assembler->Parameter(1));
assembler->Goto(&loop); assembler->Goto(&loop);
assembler->Bind(&loop); assembler->Bind(&loop);
{ {
@ -1167,8 +1150,7 @@ compiler::Node* MultiplyStub::Generate(CodeStubAssembler* assembler,
assembler->Bind(&lhs_is_not_number); assembler->Bind(&lhs_is_not_number);
{ {
// Convert {lhs} to a Number and loop. // Convert {lhs} to a Number and loop.
Callable callable = Callable callable = CodeFactory::NonNumberToNumber(isolate());
CodeFactory::NonNumberToNumber(assembler->isolate());
var_lhs.Bind(assembler->CallStub(callable, context, lhs)); var_lhs.Bind(assembler->CallStub(callable, context, lhs));
assembler->Goto(&loop); assembler->Goto(&loop);
} }
@ -1180,21 +1162,19 @@ compiler::Node* MultiplyStub::Generate(CodeStubAssembler* assembler,
Node* value = Node* value =
assembler->Float64Mul(var_lhs_float64.value(), var_rhs_float64.value()); assembler->Float64Mul(var_lhs_float64.value(), var_rhs_float64.value());
Node* result = assembler->ChangeFloat64ToTagged(value); Node* result = assembler->ChangeFloat64ToTagged(value);
return result; assembler->Return(result);
} }
} }
// static void DivideStub::GenerateAssembly(CodeStubAssembler* assembler) const {
compiler::Node* DivideStub::Generate(CodeStubAssembler* assembler,
compiler::Node* left,
compiler::Node* right,
compiler::Node* context) {
using compiler::Node; using compiler::Node;
typedef CodeStubAssembler::Label Label; typedef CodeStubAssembler::Label Label;
typedef CodeStubAssembler::Variable Variable; typedef CodeStubAssembler::Variable Variable;
Node* context = assembler->Parameter(2);
// Shared entry point for floating point division. // Shared entry point for floating point division.
Label do_fdiv(assembler), end(assembler); Label do_fdiv(assembler);
Variable var_dividend_float64(assembler, MachineRepresentation::kFloat64), Variable var_dividend_float64(assembler, MachineRepresentation::kFloat64),
var_divisor_float64(assembler, MachineRepresentation::kFloat64); var_divisor_float64(assembler, MachineRepresentation::kFloat64);
@ -1202,12 +1182,11 @@ compiler::Node* DivideStub::Generate(CodeStubAssembler* assembler,
// We might need to loop one or two times due to ToNumber conversions. // We might need to loop one or two times due to ToNumber conversions.
Variable var_dividend(assembler, MachineRepresentation::kTagged), Variable var_dividend(assembler, MachineRepresentation::kTagged),
var_divisor(assembler, MachineRepresentation::kTagged), var_divisor(assembler, MachineRepresentation::kTagged);
var_result(assembler, MachineRepresentation::kTagged);
Variable* loop_variables[] = {&var_dividend, &var_divisor}; Variable* loop_variables[] = {&var_dividend, &var_divisor};
Label loop(assembler, 2, loop_variables); Label loop(assembler, 2, loop_variables);
var_dividend.Bind(left); var_dividend.Bind(assembler->Parameter(0));
var_divisor.Bind(right); var_divisor.Bind(assembler->Parameter(1));
assembler->Goto(&loop); assembler->Goto(&loop);
assembler->Bind(&loop); assembler->Bind(&loop);
{ {
@ -1281,8 +1260,7 @@ compiler::Node* DivideStub::Generate(CodeStubAssembler* assembler,
// Do floating point division if the remainder is not 0. // Do floating point division if the remainder is not 0.
assembler->GotoIf( assembler->GotoIf(
assembler->Word32NotEqual(untagged_dividend, truncated), &bailout); assembler->Word32NotEqual(untagged_dividend, truncated), &bailout);
var_result.Bind(assembler->SmiTag(untagged_result)); assembler->Return(assembler->SmiTag(untagged_result));
assembler->Goto(&end);
// Bailout: convert {dividend} and {divisor} to double and do double // Bailout: convert {dividend} and {divisor} to double and do double
// division. // division.
@ -1316,8 +1294,7 @@ compiler::Node* DivideStub::Generate(CodeStubAssembler* assembler,
assembler->Bind(&divisor_is_not_number); assembler->Bind(&divisor_is_not_number);
{ {
// Convert {divisor} to a number and loop. // Convert {divisor} to a number and loop.
Callable callable = Callable callable = CodeFactory::NonNumberToNumber(isolate());
CodeFactory::NonNumberToNumber(assembler->isolate());
var_divisor.Bind(assembler->CallStub(callable, context, divisor)); var_divisor.Bind(assembler->CallStub(callable, context, divisor));
assembler->Goto(&loop); assembler->Goto(&loop);
} }
@ -1372,8 +1349,7 @@ compiler::Node* DivideStub::Generate(CodeStubAssembler* assembler,
assembler->Bind(&divisor_is_not_number); assembler->Bind(&divisor_is_not_number);
{ {
// Convert {divisor} to a number and loop. // Convert {divisor} to a number and loop.
Callable callable = Callable callable = CodeFactory::NonNumberToNumber(isolate());
CodeFactory::NonNumberToNumber(assembler->isolate());
var_divisor.Bind(assembler->CallStub(callable, context, divisor)); var_divisor.Bind(assembler->CallStub(callable, context, divisor));
assembler->Goto(&loop); assembler->Goto(&loop);
} }
@ -1383,8 +1359,7 @@ compiler::Node* DivideStub::Generate(CodeStubAssembler* assembler,
assembler->Bind(&dividend_is_not_number); assembler->Bind(&dividend_is_not_number);
{ {
// Convert {dividend} to a Number and loop. // Convert {dividend} to a Number and loop.
Callable callable = Callable callable = CodeFactory::NonNumberToNumber(isolate());
CodeFactory::NonNumberToNumber(assembler->isolate());
var_dividend.Bind(assembler->CallStub(callable, context, dividend)); var_dividend.Bind(assembler->CallStub(callable, context, dividend));
assembler->Goto(&loop); assembler->Goto(&loop);
} }
@ -1395,22 +1370,31 @@ compiler::Node* DivideStub::Generate(CodeStubAssembler* assembler,
{ {
Node* value = assembler->Float64Div(var_dividend_float64.value(), Node* value = assembler->Float64Div(var_dividend_float64.value(),
var_divisor_float64.value()); var_divisor_float64.value());
var_result.Bind(assembler->ChangeFloat64ToTagged(value)); Node* result = assembler->ChangeFloat64ToTagged(value);
assembler->Goto(&end); assembler->Return(result);
} }
assembler->Bind(&end);
return var_result.value();
} }
// static void BitwiseAndStub::GenerateAssembly(CodeStubAssembler* assembler) const {
compiler::Node* ModulusStub::Generate(CodeStubAssembler* assembler, using compiler::Node;
compiler::Node* left,
compiler::Node* right, Node* lhs = assembler->Parameter(0);
compiler::Node* context) { Node* rhs = assembler->Parameter(1);
Node* context = assembler->Parameter(2);
Node* lhs_value = assembler->TruncateTaggedToWord32(context, lhs);
Node* rhs_value = assembler->TruncateTaggedToWord32(context, rhs);
Node* value = assembler->Word32And(lhs_value, rhs_value);
Node* result = assembler->ChangeInt32ToTagged(value);
assembler->Return(result);
}
void ModulusStub::GenerateAssembly(CodeStubAssembler* assembler) const {
using compiler::Node; using compiler::Node;
typedef CodeStubAssembler::Label Label; typedef CodeStubAssembler::Label Label;
typedef CodeStubAssembler::Variable Variable; typedef CodeStubAssembler::Variable Variable;
Node* context = assembler->Parameter(2);
// Shared entry point for floating point modulus. // Shared entry point for floating point modulus.
Label do_fmod(assembler); Label do_fmod(assembler);
Variable var_dividend_float64(assembler, MachineRepresentation::kFloat64), Variable var_dividend_float64(assembler, MachineRepresentation::kFloat64),
@ -1423,8 +1407,8 @@ compiler::Node* ModulusStub::Generate(CodeStubAssembler* assembler,
var_divisor(assembler, MachineRepresentation::kTagged); var_divisor(assembler, MachineRepresentation::kTagged);
Variable* loop_variables[] = {&var_dividend, &var_divisor}; Variable* loop_variables[] = {&var_dividend, &var_divisor};
Label loop(assembler, 2, loop_variables); Label loop(assembler, 2, loop_variables);
var_dividend.Bind(left); var_dividend.Bind(assembler->Parameter(0));
var_divisor.Bind(right); var_divisor.Bind(assembler->Parameter(1));
assembler->Goto(&loop); assembler->Goto(&loop);
assembler->Bind(&loop); assembler->Bind(&loop);
{ {
@ -1471,8 +1455,7 @@ compiler::Node* ModulusStub::Generate(CodeStubAssembler* assembler,
assembler->Bind(&divisor_is_not_number); assembler->Bind(&divisor_is_not_number);
{ {
// Convert {divisor} to a number and loop. // Convert {divisor} to a number and loop.
Callable callable = Callable callable = CodeFactory::NonNumberToNumber(isolate());
CodeFactory::NonNumberToNumber(assembler->isolate());
var_divisor.Bind(assembler->CallStub(callable, context, divisor)); var_divisor.Bind(assembler->CallStub(callable, context, divisor));
assembler->Goto(&loop); assembler->Goto(&loop);
} }
@ -1527,8 +1510,7 @@ compiler::Node* ModulusStub::Generate(CodeStubAssembler* assembler,
assembler->Bind(&divisor_is_not_number); assembler->Bind(&divisor_is_not_number);
{ {
// Convert {divisor} to a number and loop. // Convert {divisor} to a number and loop.
Callable callable = Callable callable = CodeFactory::NonNumberToNumber(isolate());
CodeFactory::NonNumberToNumber(assembler->isolate());
var_divisor.Bind(assembler->CallStub(callable, context, divisor)); var_divisor.Bind(assembler->CallStub(callable, context, divisor));
assembler->Goto(&loop); assembler->Goto(&loop);
} }
@ -1538,8 +1520,7 @@ compiler::Node* ModulusStub::Generate(CodeStubAssembler* assembler,
assembler->Bind(&dividend_is_not_number); assembler->Bind(&dividend_is_not_number);
{ {
// Convert {dividend} to a Number and loop. // Convert {dividend} to a Number and loop.
Callable callable = Callable callable = CodeFactory::NonNumberToNumber(isolate());
CodeFactory::NonNumberToNumber(assembler->isolate());
var_dividend.Bind(assembler->CallStub(callable, context, dividend)); var_dividend.Bind(assembler->CallStub(callable, context, dividend));
assembler->Goto(&loop); assembler->Goto(&loop);
} }
@ -1551,92 +1532,80 @@ compiler::Node* ModulusStub::Generate(CodeStubAssembler* assembler,
Node* value = assembler->Float64Mod(var_dividend_float64.value(), Node* value = assembler->Float64Mod(var_dividend_float64.value(),
var_divisor_float64.value()); var_divisor_float64.value());
Node* result = assembler->ChangeFloat64ToTagged(value); Node* result = assembler->ChangeFloat64ToTagged(value);
return result; assembler->Return(result);
} }
} }
// static void ShiftLeftStub::GenerateAssembly(CodeStubAssembler* assembler) const {
compiler::Node* ShiftLeftStub::Generate(CodeStubAssembler* assembler,
compiler::Node* left,
compiler::Node* right,
compiler::Node* context) {
using compiler::Node; using compiler::Node;
Node* lhs_value = assembler->TruncateTaggedToWord32(context, left); Node* lhs = assembler->Parameter(0);
Node* rhs_value = assembler->TruncateTaggedToWord32(context, right); Node* rhs = assembler->Parameter(1);
Node* context = assembler->Parameter(2);
Node* lhs_value = assembler->TruncateTaggedToWord32(context, lhs);
Node* rhs_value = assembler->TruncateTaggedToWord32(context, rhs);
Node* shift_count = Node* shift_count =
assembler->Word32And(rhs_value, assembler->Int32Constant(0x1f)); assembler->Word32And(rhs_value, assembler->Int32Constant(0x1f));
Node* value = assembler->Word32Shl(lhs_value, shift_count); Node* value = assembler->Word32Shl(lhs_value, shift_count);
Node* result = assembler->ChangeInt32ToTagged(value); Node* result = assembler->ChangeInt32ToTagged(value);
return result; assembler->Return(result);
} }
compiler::Node* ShiftRightStub::Generate(CodeStubAssembler* assembler, void ShiftRightStub::GenerateAssembly(CodeStubAssembler* assembler) const {
compiler::Node* left,
compiler::Node* right,
compiler::Node* context) {
using compiler::Node; using compiler::Node;
Node* lhs_value = assembler->TruncateTaggedToWord32(context, left); Node* lhs = assembler->Parameter(0);
Node* rhs_value = assembler->TruncateTaggedToWord32(context, right); Node* rhs = assembler->Parameter(1);
Node* context = assembler->Parameter(2);
Node* lhs_value = assembler->TruncateTaggedToWord32(context, lhs);
Node* rhs_value = assembler->TruncateTaggedToWord32(context, rhs);
Node* shift_count = Node* shift_count =
assembler->Word32And(rhs_value, assembler->Int32Constant(0x1f)); assembler->Word32And(rhs_value, assembler->Int32Constant(0x1f));
Node* value = assembler->Word32Sar(lhs_value, shift_count); Node* value = assembler->Word32Sar(lhs_value, shift_count);
Node* result = assembler->ChangeInt32ToTagged(value); Node* result = assembler->ChangeInt32ToTagged(value);
return result; assembler->Return(result);
} }
compiler::Node* ShiftRightLogicalStub::Generate(CodeStubAssembler* assembler, void ShiftRightLogicalStub::GenerateAssembly(
compiler::Node* left, CodeStubAssembler* assembler) const {
compiler::Node* right,
compiler::Node* context) {
using compiler::Node; using compiler::Node;
Node* lhs_value = assembler->TruncateTaggedToWord32(context, left); Node* lhs = assembler->Parameter(0);
Node* rhs_value = assembler->TruncateTaggedToWord32(context, right); Node* rhs = assembler->Parameter(1);
Node* context = assembler->Parameter(2);
Node* lhs_value = assembler->TruncateTaggedToWord32(context, lhs);
Node* rhs_value = assembler->TruncateTaggedToWord32(context, rhs);
Node* shift_count = Node* shift_count =
assembler->Word32And(rhs_value, assembler->Int32Constant(0x1f)); assembler->Word32And(rhs_value, assembler->Int32Constant(0x1f));
Node* value = assembler->Word32Shr(lhs_value, shift_count); Node* value = assembler->Word32Shr(lhs_value, shift_count);
Node* result = assembler->ChangeUint32ToTagged(value); Node* result = assembler->ChangeUint32ToTagged(value);
return result; assembler->Return(result);
} }
compiler::Node* BitwiseAndStub::Generate(CodeStubAssembler* assembler, void BitwiseOrStub::GenerateAssembly(CodeStubAssembler* assembler) const {
compiler::Node* left,
compiler::Node* right,
compiler::Node* context) {
using compiler::Node; using compiler::Node;
Node* lhs_value = assembler->TruncateTaggedToWord32(context, left); Node* lhs = assembler->Parameter(0);
Node* rhs_value = assembler->TruncateTaggedToWord32(context, right); Node* rhs = assembler->Parameter(1);
Node* value = assembler->Word32And(lhs_value, rhs_value); Node* context = assembler->Parameter(2);
Node* result = assembler->ChangeInt32ToTagged(value); Node* lhs_value = assembler->TruncateTaggedToWord32(context, lhs);
return result; Node* rhs_value = assembler->TruncateTaggedToWord32(context, rhs);
}
compiler::Node* BitwiseOrStub::Generate(CodeStubAssembler* assembler,
compiler::Node* left,
compiler::Node* right,
compiler::Node* context) {
using compiler::Node;
Node* lhs_value = assembler->TruncateTaggedToWord32(context, left);
Node* rhs_value = assembler->TruncateTaggedToWord32(context, right);
Node* value = assembler->Word32Or(lhs_value, rhs_value); Node* value = assembler->Word32Or(lhs_value, rhs_value);
Node* result = assembler->ChangeInt32ToTagged(value); Node* result = assembler->ChangeInt32ToTagged(value);
return result; assembler->Return(result);
} }
compiler::Node* BitwiseXorStub::Generate(CodeStubAssembler* assembler, void BitwiseXorStub::GenerateAssembly(CodeStubAssembler* assembler) const {
compiler::Node* left,
compiler::Node* right,
compiler::Node* context) {
using compiler::Node; using compiler::Node;
Node* lhs_value = assembler->TruncateTaggedToWord32(context, left);
Node* rhs_value = assembler->TruncateTaggedToWord32(context, right); Node* lhs = assembler->Parameter(0);
Node* rhs = assembler->Parameter(1);
Node* context = assembler->Parameter(2);
Node* lhs_value = assembler->TruncateTaggedToWord32(context, lhs);
Node* rhs_value = assembler->TruncateTaggedToWord32(context, rhs);
Node* value = assembler->Word32Xor(lhs_value, rhs_value); Node* value = assembler->Word32Xor(lhs_value, rhs_value);
Node* result = assembler->ChangeInt32ToTagged(value); Node* result = assembler->ChangeInt32ToTagged(value);
return result; assembler->Return(result);
} }
void IncStub::GenerateAssembly(CodeStubAssembler* assembler) const { void IncStub::GenerateAssembly(CodeStubAssembler* assembler) const {

View File

@ -403,18 +403,6 @@ class CodeStub BASE_EMBEDDED {
void GenerateAssembly(CodeStubAssembler* assembler) const override; \ void GenerateAssembly(CodeStubAssembler* assembler) const override; \
DEFINE_CODE_STUB(NAME, SUPER) DEFINE_CODE_STUB(NAME, SUPER)
#define DEFINE_TURBOFAN_BINARY_OP_CODE_STUB(NAME, SUPER) \
public: \
static compiler::Node* Generate(CodeStubAssembler* assembler, \
compiler::Node* left, compiler::Node* right, \
compiler::Node* context); \
void GenerateAssembly(CodeStubAssembler* assembler) const override { \
assembler->Return(Generate(assembler, assembler->Parameter(0), \
assembler->Parameter(1), \
assembler->Parameter(2))); \
} \
DEFINE_CODE_STUB(NAME, SUPER)
#define DEFINE_HANDLER_CODE_STUB(NAME, SUPER) \ #define DEFINE_HANDLER_CODE_STUB(NAME, SUPER) \
public: \ public: \
Handle<Code> GenerateCode() override; \ Handle<Code> GenerateCode() override; \
@ -694,7 +682,7 @@ class AddStub final : public TurboFanCodeStub {
explicit AddStub(Isolate* isolate) : TurboFanCodeStub(isolate) {} explicit AddStub(Isolate* isolate) : TurboFanCodeStub(isolate) {}
DEFINE_CALL_INTERFACE_DESCRIPTOR(BinaryOp); DEFINE_CALL_INTERFACE_DESCRIPTOR(BinaryOp);
DEFINE_TURBOFAN_BINARY_OP_CODE_STUB(Add, TurboFanCodeStub); DEFINE_TURBOFAN_CODE_STUB(Add, TurboFanCodeStub);
}; };
class SubtractStub final : public TurboFanCodeStub { class SubtractStub final : public TurboFanCodeStub {
@ -702,7 +690,7 @@ class SubtractStub final : public TurboFanCodeStub {
explicit SubtractStub(Isolate* isolate) : TurboFanCodeStub(isolate) {} explicit SubtractStub(Isolate* isolate) : TurboFanCodeStub(isolate) {}
DEFINE_CALL_INTERFACE_DESCRIPTOR(BinaryOp); DEFINE_CALL_INTERFACE_DESCRIPTOR(BinaryOp);
DEFINE_TURBOFAN_BINARY_OP_CODE_STUB(Subtract, TurboFanCodeStub); DEFINE_TURBOFAN_CODE_STUB(Subtract, TurboFanCodeStub);
}; };
class MultiplyStub final : public TurboFanCodeStub { class MultiplyStub final : public TurboFanCodeStub {
@ -710,7 +698,7 @@ class MultiplyStub final : public TurboFanCodeStub {
explicit MultiplyStub(Isolate* isolate) : TurboFanCodeStub(isolate) {} explicit MultiplyStub(Isolate* isolate) : TurboFanCodeStub(isolate) {}
DEFINE_CALL_INTERFACE_DESCRIPTOR(BinaryOp); DEFINE_CALL_INTERFACE_DESCRIPTOR(BinaryOp);
DEFINE_TURBOFAN_BINARY_OP_CODE_STUB(Multiply, TurboFanCodeStub); DEFINE_TURBOFAN_CODE_STUB(Multiply, TurboFanCodeStub);
}; };
class DivideStub final : public TurboFanCodeStub { class DivideStub final : public TurboFanCodeStub {
@ -718,7 +706,7 @@ class DivideStub final : public TurboFanCodeStub {
explicit DivideStub(Isolate* isolate) : TurboFanCodeStub(isolate) {} explicit DivideStub(Isolate* isolate) : TurboFanCodeStub(isolate) {}
DEFINE_CALL_INTERFACE_DESCRIPTOR(BinaryOp); DEFINE_CALL_INTERFACE_DESCRIPTOR(BinaryOp);
DEFINE_TURBOFAN_BINARY_OP_CODE_STUB(Divide, TurboFanCodeStub); DEFINE_TURBOFAN_CODE_STUB(Divide, TurboFanCodeStub);
}; };
class ModulusStub final : public TurboFanCodeStub { class ModulusStub final : public TurboFanCodeStub {
@ -726,7 +714,7 @@ class ModulusStub final : public TurboFanCodeStub {
explicit ModulusStub(Isolate* isolate) : TurboFanCodeStub(isolate) {} explicit ModulusStub(Isolate* isolate) : TurboFanCodeStub(isolate) {}
DEFINE_CALL_INTERFACE_DESCRIPTOR(BinaryOp); DEFINE_CALL_INTERFACE_DESCRIPTOR(BinaryOp);
DEFINE_TURBOFAN_BINARY_OP_CODE_STUB(Modulus, TurboFanCodeStub); DEFINE_TURBOFAN_CODE_STUB(Modulus, TurboFanCodeStub);
}; };
class ShiftRightStub final : public TurboFanCodeStub { class ShiftRightStub final : public TurboFanCodeStub {
@ -734,7 +722,7 @@ class ShiftRightStub final : public TurboFanCodeStub {
explicit ShiftRightStub(Isolate* isolate) : TurboFanCodeStub(isolate) {} explicit ShiftRightStub(Isolate* isolate) : TurboFanCodeStub(isolate) {}
DEFINE_CALL_INTERFACE_DESCRIPTOR(BinaryOp); DEFINE_CALL_INTERFACE_DESCRIPTOR(BinaryOp);
DEFINE_TURBOFAN_BINARY_OP_CODE_STUB(ShiftRight, TurboFanCodeStub); DEFINE_TURBOFAN_CODE_STUB(ShiftRight, TurboFanCodeStub);
}; };
class ShiftRightLogicalStub final : public TurboFanCodeStub { class ShiftRightLogicalStub final : public TurboFanCodeStub {
@ -743,7 +731,7 @@ class ShiftRightLogicalStub final : public TurboFanCodeStub {
: TurboFanCodeStub(isolate) {} : TurboFanCodeStub(isolate) {}
DEFINE_CALL_INTERFACE_DESCRIPTOR(BinaryOp); DEFINE_CALL_INTERFACE_DESCRIPTOR(BinaryOp);
DEFINE_TURBOFAN_BINARY_OP_CODE_STUB(ShiftRightLogical, TurboFanCodeStub); DEFINE_TURBOFAN_CODE_STUB(ShiftRightLogical, TurboFanCodeStub);
}; };
class ShiftLeftStub final : public TurboFanCodeStub { class ShiftLeftStub final : public TurboFanCodeStub {
@ -751,7 +739,7 @@ class ShiftLeftStub final : public TurboFanCodeStub {
explicit ShiftLeftStub(Isolate* isolate) : TurboFanCodeStub(isolate) {} explicit ShiftLeftStub(Isolate* isolate) : TurboFanCodeStub(isolate) {}
DEFINE_CALL_INTERFACE_DESCRIPTOR(BinaryOp); DEFINE_CALL_INTERFACE_DESCRIPTOR(BinaryOp);
DEFINE_TURBOFAN_BINARY_OP_CODE_STUB(ShiftLeft, TurboFanCodeStub); DEFINE_TURBOFAN_CODE_STUB(ShiftLeft, TurboFanCodeStub);
}; };
class BitwiseAndStub final : public TurboFanCodeStub { class BitwiseAndStub final : public TurboFanCodeStub {
@ -759,7 +747,7 @@ class BitwiseAndStub final : public TurboFanCodeStub {
explicit BitwiseAndStub(Isolate* isolate) : TurboFanCodeStub(isolate) {} explicit BitwiseAndStub(Isolate* isolate) : TurboFanCodeStub(isolate) {}
DEFINE_CALL_INTERFACE_DESCRIPTOR(BinaryOp); DEFINE_CALL_INTERFACE_DESCRIPTOR(BinaryOp);
DEFINE_TURBOFAN_BINARY_OP_CODE_STUB(BitwiseAnd, TurboFanCodeStub); DEFINE_TURBOFAN_CODE_STUB(BitwiseAnd, TurboFanCodeStub);
}; };
class BitwiseOrStub final : public TurboFanCodeStub { class BitwiseOrStub final : public TurboFanCodeStub {
@ -767,7 +755,7 @@ class BitwiseOrStub final : public TurboFanCodeStub {
explicit BitwiseOrStub(Isolate* isolate) : TurboFanCodeStub(isolate) {} explicit BitwiseOrStub(Isolate* isolate) : TurboFanCodeStub(isolate) {}
DEFINE_CALL_INTERFACE_DESCRIPTOR(BinaryOp); DEFINE_CALL_INTERFACE_DESCRIPTOR(BinaryOp);
DEFINE_TURBOFAN_BINARY_OP_CODE_STUB(BitwiseOr, TurboFanCodeStub); DEFINE_TURBOFAN_CODE_STUB(BitwiseOr, TurboFanCodeStub);
}; };
class BitwiseXorStub final : public TurboFanCodeStub { class BitwiseXorStub final : public TurboFanCodeStub {
@ -775,7 +763,7 @@ class BitwiseXorStub final : public TurboFanCodeStub {
explicit BitwiseXorStub(Isolate* isolate) : TurboFanCodeStub(isolate) {} explicit BitwiseXorStub(Isolate* isolate) : TurboFanCodeStub(isolate) {}
DEFINE_CALL_INTERFACE_DESCRIPTOR(BinaryOp); DEFINE_CALL_INTERFACE_DESCRIPTOR(BinaryOp);
DEFINE_TURBOFAN_BINARY_OP_CODE_STUB(BitwiseXor, TurboFanCodeStub); DEFINE_TURBOFAN_CODE_STUB(BitwiseXor, TurboFanCodeStub);
}; };
class IncStub final : public TurboFanCodeStub { class IncStub final : public TurboFanCodeStub {

View File

@ -719,22 +719,12 @@ void Interpreter::DoBinaryOp(Runtime::FunctionId function_id,
__ Dispatch(); __ Dispatch();
} }
template <class Generator>
void Interpreter::DoBinaryOp(InterpreterAssembler* assembler) {
Node* reg_index = __ BytecodeOperandReg(0);
Node* lhs = __ LoadRegister(reg_index);
Node* rhs = __ GetAccumulator();
Node* context = __ GetContext();
Node* result = Generator::Generate(assembler, lhs, rhs, context);
__ SetAccumulator(result);
__ Dispatch();
}
// Add <src> // Add <src>
// //
// Add register <src> to accumulator. // Add register <src> to accumulator.
void Interpreter::DoAdd(InterpreterAssembler* assembler) { void Interpreter::DoAdd(InterpreterAssembler* assembler) {
DoBinaryOp<AddStub>(assembler); DoBinaryOp(CodeFactory::Add(isolate_), assembler);
} }
@ -742,7 +732,7 @@ void Interpreter::DoAdd(InterpreterAssembler* assembler) {
// //
// Subtract register <src> from accumulator. // Subtract register <src> from accumulator.
void Interpreter::DoSub(InterpreterAssembler* assembler) { void Interpreter::DoSub(InterpreterAssembler* assembler) {
DoBinaryOp<SubtractStub>(assembler); DoBinaryOp(CodeFactory::Subtract(isolate_), assembler);
} }
@ -750,7 +740,7 @@ void Interpreter::DoSub(InterpreterAssembler* assembler) {
// //
// Multiply accumulator by register <src>. // Multiply accumulator by register <src>.
void Interpreter::DoMul(InterpreterAssembler* assembler) { void Interpreter::DoMul(InterpreterAssembler* assembler) {
DoBinaryOp<MultiplyStub>(assembler); DoBinaryOp(CodeFactory::Multiply(isolate_), assembler);
} }
@ -758,7 +748,7 @@ void Interpreter::DoMul(InterpreterAssembler* assembler) {
// //
// Divide register <src> by accumulator. // Divide register <src> by accumulator.
void Interpreter::DoDiv(InterpreterAssembler* assembler) { void Interpreter::DoDiv(InterpreterAssembler* assembler) {
DoBinaryOp<DivideStub>(assembler); DoBinaryOp(CodeFactory::Divide(isolate_), assembler);
} }
@ -766,7 +756,7 @@ void Interpreter::DoDiv(InterpreterAssembler* assembler) {
// //
// Modulo register <src> by accumulator. // Modulo register <src> by accumulator.
void Interpreter::DoMod(InterpreterAssembler* assembler) { void Interpreter::DoMod(InterpreterAssembler* assembler) {
DoBinaryOp<ModulusStub>(assembler); DoBinaryOp(CodeFactory::Modulus(isolate_), assembler);
} }
@ -774,7 +764,7 @@ void Interpreter::DoMod(InterpreterAssembler* assembler) {
// //
// BitwiseOr register <src> to accumulator. // BitwiseOr register <src> to accumulator.
void Interpreter::DoBitwiseOr(InterpreterAssembler* assembler) { void Interpreter::DoBitwiseOr(InterpreterAssembler* assembler) {
DoBinaryOp<BitwiseOrStub>(assembler); DoBinaryOp(CodeFactory::BitwiseOr(isolate_), assembler);
} }
@ -782,7 +772,7 @@ void Interpreter::DoBitwiseOr(InterpreterAssembler* assembler) {
// //
// BitwiseXor register <src> to accumulator. // BitwiseXor register <src> to accumulator.
void Interpreter::DoBitwiseXor(InterpreterAssembler* assembler) { void Interpreter::DoBitwiseXor(InterpreterAssembler* assembler) {
DoBinaryOp<BitwiseXorStub>(assembler); DoBinaryOp(CodeFactory::BitwiseXor(isolate_), assembler);
} }
@ -790,7 +780,7 @@ void Interpreter::DoBitwiseXor(InterpreterAssembler* assembler) {
// //
// BitwiseAnd register <src> to accumulator. // BitwiseAnd register <src> to accumulator.
void Interpreter::DoBitwiseAnd(InterpreterAssembler* assembler) { void Interpreter::DoBitwiseAnd(InterpreterAssembler* assembler) {
DoBinaryOp<BitwiseAndStub>(assembler); DoBinaryOp(CodeFactory::BitwiseAnd(isolate_), assembler);
} }
@ -801,7 +791,7 @@ void Interpreter::DoBitwiseAnd(InterpreterAssembler* assembler) {
// before the operation. 5 lsb bits from the accumulator are used as count // before the operation. 5 lsb bits from the accumulator are used as count
// i.e. <src> << (accumulator & 0x1F). // i.e. <src> << (accumulator & 0x1F).
void Interpreter::DoShiftLeft(InterpreterAssembler* assembler) { void Interpreter::DoShiftLeft(InterpreterAssembler* assembler) {
DoBinaryOp<ShiftLeftStub>(assembler); DoBinaryOp(CodeFactory::ShiftLeft(isolate_), assembler);
} }
@ -812,7 +802,7 @@ void Interpreter::DoShiftLeft(InterpreterAssembler* assembler) {
// accumulator to uint32 before the operation. 5 lsb bits from the accumulator // accumulator to uint32 before the operation. 5 lsb bits from the accumulator
// are used as count i.e. <src> >> (accumulator & 0x1F). // are used as count i.e. <src> >> (accumulator & 0x1F).
void Interpreter::DoShiftRight(InterpreterAssembler* assembler) { void Interpreter::DoShiftRight(InterpreterAssembler* assembler) {
DoBinaryOp<ShiftRightStub>(assembler); DoBinaryOp(CodeFactory::ShiftRight(isolate_), assembler);
} }
@ -823,7 +813,7 @@ void Interpreter::DoShiftRight(InterpreterAssembler* assembler) {
// uint32 before the operation 5 lsb bits from the accumulator are used as // uint32 before the operation 5 lsb bits from the accumulator are used as
// count i.e. <src> << (accumulator & 0x1F). // count i.e. <src> << (accumulator & 0x1F).
void Interpreter::DoShiftRightLogical(InterpreterAssembler* assembler) { void Interpreter::DoShiftRightLogical(InterpreterAssembler* assembler) {
DoBinaryOp<ShiftRightLogicalStub>(assembler); DoBinaryOp(CodeFactory::ShiftRightLogical(isolate_), assembler);
} }
void Interpreter::DoCountOp(Callable callable, void Interpreter::DoCountOp(Callable callable,

View File

@ -21,10 +21,6 @@ class Isolate;
class Callable; class Callable;
class CompilationInfo; class CompilationInfo;
namespace compiler {
class Node;
} // namespace compiler
namespace interpreter { namespace interpreter {
class InterpreterAssembler; class InterpreterAssembler;
@ -77,10 +73,6 @@ class Interpreter {
void DoBinaryOp(Runtime::FunctionId function_id, void DoBinaryOp(Runtime::FunctionId function_id,
InterpreterAssembler* assembler); InterpreterAssembler* assembler);
// Generates code to perform the binary operations via |Generator|.
template <class Generator>
void DoBinaryOp(InterpreterAssembler* assembler);
// Generates code to perform the count operations via |callable|. // Generates code to perform the count operations via |callable|.
void DoCountOp(Callable callable, InterpreterAssembler* assembler); void DoCountOp(Callable callable, InterpreterAssembler* assembler);