[ignition] Inline the binary op TurboFan code stubs in the bytecode handlers.

Trying to reland http://crrev.com/1902823002.

This time some blocks have been shuffled around in the AddStub so that the frame still doesn't get built for the fast path.

Review-Url: https://codereview.chromium.org/1974293002
Cr-Commit-Position: refs/heads/master@{#36251}
This commit is contained in:
epertoso 2016-05-13 09:51:36 -07:00 committed by Commit bot
parent baf1204df1
commit 567160122d
4 changed files with 217 additions and 137 deletions

View File

@ -487,13 +487,14 @@ void StringLengthStub::GenerateAssembly(CodeStubAssembler* assembler) const {
assembler->Return(result);
}
void AddStub::GenerateAssembly(CodeStubAssembler* assembler) const {
// static
compiler::Node* AddStub::Generate(CodeStubAssembler* assembler,
compiler::Node* left, compiler::Node* right,
compiler::Node* context) {
typedef CodeStubAssembler::Label Label;
typedef compiler::Node Node;
typedef CodeStubAssembler::Variable Variable;
Node* context = assembler->Parameter(2);
// Shared entry for floating point addition.
Label do_fadd(assembler);
Variable var_fadd_lhs(assembler, MachineRepresentation::kFloat64),
@ -502,11 +503,14 @@ void AddStub::GenerateAssembly(CodeStubAssembler* assembler) const {
// We might need to loop several times due to ToPrimitive, ToString and/or
// ToNumber conversions.
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};
Label loop(assembler, 2, loop_vars);
var_lhs.Bind(assembler->Parameter(0));
var_rhs.Bind(assembler->Parameter(1));
Label loop(assembler, 2, loop_vars), end(assembler),
string_add_convert_left(assembler, Label::kDeferred),
string_add_convert_right(assembler, Label::kDeferred);
var_lhs.Bind(left);
var_rhs.Bind(right);
assembler->Goto(&loop);
assembler->Bind(&loop);
{
@ -543,7 +547,8 @@ void AddStub::GenerateAssembly(CodeStubAssembler* assembler) const {
}
assembler->Bind(&if_notoverflow);
assembler->Return(assembler->Projection(0, pair));
var_result.Bind(assembler->Projection(0, pair));
assembler->Goto(&end);
}
assembler->Bind(&if_rhsisnotsmi);
@ -580,11 +585,9 @@ void AddStub::GenerateAssembly(CodeStubAssembler* assembler) const {
assembler->Bind(&if_rhsisstring);
{
// Convert {lhs}, which is a Smi, to a String and concatenate the
// resulting string with the String {rhs}.
Callable callable = CodeFactory::StringAdd(
assembler->isolate(), STRING_ADD_CONVERT_LEFT, NOT_TENURED);
assembler->TailCallStub(callable, context, lhs, rhs);
var_lhs.Bind(lhs);
var_rhs.Bind(rhs);
assembler->Goto(&string_add_convert_left);
}
assembler->Bind(&if_rhsisnotstring);
@ -634,11 +637,9 @@ void AddStub::GenerateAssembly(CodeStubAssembler* assembler) const {
assembler->Bind(&if_lhsisstring);
{
// Convert {rhs} to a String (using the sequence of ToPrimitive with
// no hint followed by ToString) and concatenate the strings.
Callable callable = CodeFactory::StringAdd(
assembler->isolate(), STRING_ADD_CONVERT_RIGHT, NOT_TENURED);
assembler->TailCallStub(callable, context, lhs, rhs);
var_lhs.Bind(lhs);
var_rhs.Bind(rhs);
assembler->Goto(&string_add_convert_right);
}
assembler->Bind(&if_lhsisnotstring);
@ -712,11 +713,9 @@ void AddStub::GenerateAssembly(CodeStubAssembler* assembler) const {
assembler->Bind(&if_rhsisstring);
{
// Convert {lhs} to a String (using the sequence of ToPrimitive with
// no hint followed by ToString) and concatenate the strings.
Callable callable = CodeFactory::StringAdd(
assembler->isolate(), STRING_ADD_CONVERT_LEFT, NOT_TENURED);
assembler->TailCallStub(callable, context, lhs, rhs);
var_lhs.Bind(lhs);
var_rhs.Bind(rhs);
assembler->Goto(&string_add_convert_left);
}
assembler->Bind(&if_rhsisnotstring);
@ -832,6 +831,27 @@ void AddStub::GenerateAssembly(CodeStubAssembler* assembler) const {
}
}
}
assembler->Bind(&string_add_convert_left);
{
// Convert {lhs}, which is a Smi, to a String and concatenate the
// resulting string with the String {rhs}.
Callable callable = CodeFactory::StringAdd(
assembler->isolate(), STRING_ADD_CONVERT_LEFT, NOT_TENURED);
var_result.Bind(assembler->CallStub(callable, context, var_lhs.value(),
var_rhs.value()));
assembler->Goto(&end);
}
assembler->Bind(&string_add_convert_right);
{
// Convert {lhs}, which is a Smi, to a String and concatenate the
// resulting string with the String {rhs}.
Callable callable = CodeFactory::StringAdd(
assembler->isolate(), STRING_ADD_CONVERT_RIGHT, NOT_TENURED);
var_result.Bind(assembler->CallStub(callable, context, var_lhs.value(),
var_rhs.value()));
assembler->Goto(&end);
}
assembler->Bind(&do_fadd);
{
@ -839,30 +859,36 @@ void AddStub::GenerateAssembly(CodeStubAssembler* assembler) const {
Node* rhs_value = var_fadd_rhs.value();
Node* value = assembler->Float64Add(lhs_value, rhs_value);
Node* result = assembler->ChangeFloat64ToTagged(value);
assembler->Return(result);
var_result.Bind(result);
assembler->Goto(&end);
}
assembler->Bind(&end);
return var_result.value();
}
void SubtractStub::GenerateAssembly(CodeStubAssembler* assembler) const {
// static
compiler::Node* SubtractStub::Generate(CodeStubAssembler* assembler,
compiler::Node* left,
compiler::Node* right,
compiler::Node* context) {
typedef CodeStubAssembler::Label Label;
typedef compiler::Node Node;
typedef CodeStubAssembler::Variable Variable;
Node* context = assembler->Parameter(2);
// Shared entry for floating point subtraction.
Label do_fsub(assembler);
Label do_fsub(assembler), end(assembler);
Variable var_fsub_lhs(assembler, MachineRepresentation::kFloat64),
var_fsub_rhs(assembler, MachineRepresentation::kFloat64);
// We might need to loop several times due to ToPrimitive and/or ToNumber
// conversions.
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};
Label loop(assembler, 2, loop_vars);
var_lhs.Bind(assembler->Parameter(0));
var_rhs.Bind(assembler->Parameter(1));
var_lhs.Bind(left);
var_rhs.Bind(right);
assembler->Goto(&loop);
assembler->Bind(&loop);
{
@ -900,7 +926,8 @@ void SubtractStub::GenerateAssembly(CodeStubAssembler* assembler) const {
}
assembler->Bind(&if_notoverflow);
assembler->Return(assembler->Projection(0, pair));
var_result.Bind(assembler->Projection(0, pair));
assembler->Goto(&end);
}
assembler->Bind(&if_rhsisnotsmi);
@ -926,7 +953,8 @@ void SubtractStub::GenerateAssembly(CodeStubAssembler* assembler) const {
assembler->Bind(&if_rhsisnotnumber);
{
// Convert the {rhs} to a Number first.
Callable callable = CodeFactory::NonNumberToNumber(isolate());
Callable callable =
CodeFactory::NonNumberToNumber(assembler->isolate());
var_rhs.Bind(assembler->CallStub(callable, context, rhs));
assembler->Goto(&loop);
}
@ -982,7 +1010,8 @@ void SubtractStub::GenerateAssembly(CodeStubAssembler* assembler) const {
assembler->Bind(&if_rhsisnotnumber);
{
// Convert the {rhs} to a Number first.
Callable callable = CodeFactory::NonNumberToNumber(isolate());
Callable callable =
CodeFactory::NonNumberToNumber(assembler->isolate());
var_rhs.Bind(assembler->CallStub(callable, context, rhs));
assembler->Goto(&loop);
}
@ -992,7 +1021,8 @@ void SubtractStub::GenerateAssembly(CodeStubAssembler* assembler) const {
assembler->Bind(&if_lhsisnotnumber);
{
// Convert the {lhs} to a Number first.
Callable callable = CodeFactory::NonNumberToNumber(isolate());
Callable callable =
CodeFactory::NonNumberToNumber(assembler->isolate());
var_lhs.Bind(assembler->CallStub(callable, context, lhs));
assembler->Goto(&loop);
}
@ -1004,18 +1034,22 @@ void SubtractStub::GenerateAssembly(CodeStubAssembler* assembler) const {
Node* lhs_value = var_fsub_lhs.value();
Node* rhs_value = var_fsub_rhs.value();
Node* value = assembler->Float64Sub(lhs_value, rhs_value);
Node* result = assembler->ChangeFloat64ToTagged(value);
assembler->Return(result);
var_result.Bind(assembler->ChangeFloat64ToTagged(value));
assembler->Goto(&end);
}
assembler->Bind(&end);
return var_result.value();
}
void MultiplyStub::GenerateAssembly(CodeStubAssembler* assembler) const {
// static
compiler::Node* MultiplyStub::Generate(CodeStubAssembler* assembler,
compiler::Node* left,
compiler::Node* right,
compiler::Node* context) {
using compiler::Node;
typedef CodeStubAssembler::Label Label;
typedef CodeStubAssembler::Variable Variable;
Node* context = assembler->Parameter(2);
// Shared entry point for floating point multiplication.
Label do_fmul(assembler);
Variable var_lhs_float64(assembler, MachineRepresentation::kFloat64),
@ -1028,8 +1062,8 @@ void MultiplyStub::GenerateAssembly(CodeStubAssembler* assembler) const {
var_rhs(assembler, MachineRepresentation::kTagged);
Variable* loop_variables[] = {&var_lhs, &var_rhs};
Label loop(assembler, 2, loop_variables);
var_lhs.Bind(assembler->Parameter(0));
var_rhs.Bind(assembler->Parameter(1));
var_lhs.Bind(left);
var_rhs.Bind(right);
assembler->Goto(&loop);
assembler->Bind(&loop);
{
@ -1139,7 +1173,8 @@ void MultiplyStub::GenerateAssembly(CodeStubAssembler* assembler) const {
assembler->Bind(&lhs_is_not_number);
{
// Convert {lhs} to a Number and loop.
Callable callable = CodeFactory::NonNumberToNumber(isolate());
Callable callable =
CodeFactory::NonNumberToNumber(assembler->isolate());
var_lhs.Bind(assembler->CallStub(callable, context, lhs));
assembler->Goto(&loop);
}
@ -1151,19 +1186,21 @@ void MultiplyStub::GenerateAssembly(CodeStubAssembler* assembler) const {
Node* value =
assembler->Float64Mul(var_lhs_float64.value(), var_rhs_float64.value());
Node* result = assembler->ChangeFloat64ToTagged(value);
assembler->Return(result);
return result;
}
}
void DivideStub::GenerateAssembly(CodeStubAssembler* assembler) const {
// static
compiler::Node* DivideStub::Generate(CodeStubAssembler* assembler,
compiler::Node* left,
compiler::Node* right,
compiler::Node* context) {
using compiler::Node;
typedef CodeStubAssembler::Label Label;
typedef CodeStubAssembler::Variable Variable;
Node* context = assembler->Parameter(2);
// Shared entry point for floating point division.
Label do_fdiv(assembler);
Label do_fdiv(assembler), end(assembler);
Variable var_dividend_float64(assembler, MachineRepresentation::kFloat64),
var_divisor_float64(assembler, MachineRepresentation::kFloat64);
@ -1171,11 +1208,12 @@ void DivideStub::GenerateAssembly(CodeStubAssembler* assembler) const {
// We might need to loop one or two times due to ToNumber conversions.
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};
Label loop(assembler, 2, loop_variables);
var_dividend.Bind(assembler->Parameter(0));
var_divisor.Bind(assembler->Parameter(1));
var_dividend.Bind(left);
var_divisor.Bind(right);
assembler->Goto(&loop);
assembler->Bind(&loop);
{
@ -1249,7 +1287,8 @@ void DivideStub::GenerateAssembly(CodeStubAssembler* assembler) const {
// Do floating point division if the remainder is not 0.
assembler->GotoIf(
assembler->Word32NotEqual(untagged_dividend, truncated), &bailout);
assembler->Return(assembler->SmiTag(untagged_result));
var_result.Bind(assembler->SmiTag(untagged_result));
assembler->Goto(&end);
// Bailout: convert {dividend} and {divisor} to double and do double
// division.
@ -1283,7 +1322,8 @@ void DivideStub::GenerateAssembly(CodeStubAssembler* assembler) const {
assembler->Bind(&divisor_is_not_number);
{
// Convert {divisor} to a number and loop.
Callable callable = CodeFactory::NonNumberToNumber(isolate());
Callable callable =
CodeFactory::NonNumberToNumber(assembler->isolate());
var_divisor.Bind(assembler->CallStub(callable, context, divisor));
assembler->Goto(&loop);
}
@ -1338,7 +1378,8 @@ void DivideStub::GenerateAssembly(CodeStubAssembler* assembler) const {
assembler->Bind(&divisor_is_not_number);
{
// Convert {divisor} to a number and loop.
Callable callable = CodeFactory::NonNumberToNumber(isolate());
Callable callable =
CodeFactory::NonNumberToNumber(assembler->isolate());
var_divisor.Bind(assembler->CallStub(callable, context, divisor));
assembler->Goto(&loop);
}
@ -1348,7 +1389,8 @@ void DivideStub::GenerateAssembly(CodeStubAssembler* assembler) const {
assembler->Bind(&dividend_is_not_number);
{
// Convert {dividend} to a Number and loop.
Callable callable = CodeFactory::NonNumberToNumber(isolate());
Callable callable =
CodeFactory::NonNumberToNumber(assembler->isolate());
var_dividend.Bind(assembler->CallStub(callable, context, dividend));
assembler->Goto(&loop);
}
@ -1359,31 +1401,22 @@ void DivideStub::GenerateAssembly(CodeStubAssembler* assembler) const {
{
Node* value = assembler->Float64Div(var_dividend_float64.value(),
var_divisor_float64.value());
Node* result = assembler->ChangeFloat64ToTagged(value);
assembler->Return(result);
var_result.Bind(assembler->ChangeFloat64ToTagged(value));
assembler->Goto(&end);
}
assembler->Bind(&end);
return var_result.value();
}
void BitwiseAndStub::GenerateAssembly(CodeStubAssembler* assembler) const {
using compiler::Node;
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->Word32And(lhs_value, rhs_value);
Node* result = assembler->ChangeInt32ToTagged(value);
assembler->Return(result);
}
void ModulusStub::GenerateAssembly(CodeStubAssembler* assembler) const {
// static
compiler::Node* ModulusStub::Generate(CodeStubAssembler* assembler,
compiler::Node* left,
compiler::Node* right,
compiler::Node* context) {
using compiler::Node;
typedef CodeStubAssembler::Label Label;
typedef CodeStubAssembler::Variable Variable;
Node* context = assembler->Parameter(2);
// Shared entry point for floating point modulus.
Label do_fmod(assembler);
Variable var_dividend_float64(assembler, MachineRepresentation::kFloat64),
@ -1396,8 +1429,8 @@ void ModulusStub::GenerateAssembly(CodeStubAssembler* assembler) const {
var_divisor(assembler, MachineRepresentation::kTagged);
Variable* loop_variables[] = {&var_dividend, &var_divisor};
Label loop(assembler, 2, loop_variables);
var_dividend.Bind(assembler->Parameter(0));
var_divisor.Bind(assembler->Parameter(1));
var_dividend.Bind(left);
var_divisor.Bind(right);
assembler->Goto(&loop);
assembler->Bind(&loop);
{
@ -1444,7 +1477,8 @@ void ModulusStub::GenerateAssembly(CodeStubAssembler* assembler) const {
assembler->Bind(&divisor_is_not_number);
{
// Convert {divisor} to a number and loop.
Callable callable = CodeFactory::NonNumberToNumber(isolate());
Callable callable =
CodeFactory::NonNumberToNumber(assembler->isolate());
var_divisor.Bind(assembler->CallStub(callable, context, divisor));
assembler->Goto(&loop);
}
@ -1499,7 +1533,8 @@ void ModulusStub::GenerateAssembly(CodeStubAssembler* assembler) const {
assembler->Bind(&divisor_is_not_number);
{
// Convert {divisor} to a number and loop.
Callable callable = CodeFactory::NonNumberToNumber(isolate());
Callable callable =
CodeFactory::NonNumberToNumber(assembler->isolate());
var_divisor.Bind(assembler->CallStub(callable, context, divisor));
assembler->Goto(&loop);
}
@ -1509,7 +1544,8 @@ void ModulusStub::GenerateAssembly(CodeStubAssembler* assembler) const {
assembler->Bind(&dividend_is_not_number);
{
// Convert {dividend} to a Number and loop.
Callable callable = CodeFactory::NonNumberToNumber(isolate());
Callable callable =
CodeFactory::NonNumberToNumber(assembler->isolate());
var_dividend.Bind(assembler->CallStub(callable, context, dividend));
assembler->Goto(&loop);
}
@ -1521,80 +1557,98 @@ void ModulusStub::GenerateAssembly(CodeStubAssembler* assembler) const {
Node* value = assembler->Float64Mod(var_dividend_float64.value(),
var_divisor_float64.value());
Node* result = assembler->ChangeFloat64ToTagged(value);
assembler->Return(result);
return result;
}
}
void ShiftLeftStub::GenerateAssembly(CodeStubAssembler* assembler) const {
// static
compiler::Node* ShiftLeftStub::Generate(CodeStubAssembler* assembler,
compiler::Node* left,
compiler::Node* right,
compiler::Node* context) {
using compiler::Node;
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* lhs_value = assembler->TruncateTaggedToWord32(context, left);
Node* rhs_value = assembler->TruncateTaggedToWord32(context, right);
Node* shift_count =
assembler->Word32And(rhs_value, assembler->Int32Constant(0x1f));
Node* value = assembler->Word32Shl(lhs_value, shift_count);
Node* result = assembler->ChangeInt32ToTagged(value);
assembler->Return(result);
return result;
}
void ShiftRightStub::GenerateAssembly(CodeStubAssembler* assembler) const {
// static
compiler::Node* ShiftRightStub::Generate(CodeStubAssembler* assembler,
compiler::Node* left,
compiler::Node* right,
compiler::Node* context) {
using compiler::Node;
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* lhs_value = assembler->TruncateTaggedToWord32(context, left);
Node* rhs_value = assembler->TruncateTaggedToWord32(context, right);
Node* shift_count =
assembler->Word32And(rhs_value, assembler->Int32Constant(0x1f));
Node* value = assembler->Word32Sar(lhs_value, shift_count);
Node* result = assembler->ChangeInt32ToTagged(value);
assembler->Return(result);
return result;
}
void ShiftRightLogicalStub::GenerateAssembly(
CodeStubAssembler* assembler) const {
// static
compiler::Node* ShiftRightLogicalStub::Generate(CodeStubAssembler* assembler,
compiler::Node* left,
compiler::Node* right,
compiler::Node* context) {
using compiler::Node;
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* lhs_value = assembler->TruncateTaggedToWord32(context, left);
Node* rhs_value = assembler->TruncateTaggedToWord32(context, right);
Node* shift_count =
assembler->Word32And(rhs_value, assembler->Int32Constant(0x1f));
Node* value = assembler->Word32Shr(lhs_value, shift_count);
Node* result = assembler->ChangeUint32ToTagged(value);
assembler->Return(result);
return result;
}
void BitwiseOrStub::GenerateAssembly(CodeStubAssembler* assembler) const {
// static
compiler::Node* BitwiseAndStub::Generate(CodeStubAssembler* assembler,
compiler::Node* left,
compiler::Node* right,
compiler::Node* context) {
using compiler::Node;
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* lhs_value = assembler->TruncateTaggedToWord32(context, left);
Node* rhs_value = assembler->TruncateTaggedToWord32(context, right);
Node* value = assembler->Word32And(lhs_value, rhs_value);
Node* result = assembler->ChangeInt32ToTagged(value);
return result;
}
// static
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* result = assembler->ChangeInt32ToTagged(value);
assembler->Return(result);
return result;
}
void BitwiseXorStub::GenerateAssembly(CodeStubAssembler* assembler) const {
// static
compiler::Node* BitwiseXorStub::Generate(CodeStubAssembler* assembler,
compiler::Node* left,
compiler::Node* right,
compiler::Node* context) {
using compiler::Node;
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* lhs_value = assembler->TruncateTaggedToWord32(context, left);
Node* rhs_value = assembler->TruncateTaggedToWord32(context, right);
Node* value = assembler->Word32Xor(lhs_value, rhs_value);
Node* result = assembler->ChangeInt32ToTagged(value);
assembler->Return(result);
return result;
}
void IncStub::GenerateAssembly(CodeStubAssembler* assembler) const {

View File

@ -402,6 +402,18 @@ class CodeStub BASE_EMBEDDED {
void GenerateAssembly(CodeStubAssembler* assembler) const override; \
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) \
public: \
Handle<Code> GenerateCode() override; \
@ -681,7 +693,7 @@ class AddStub final : public TurboFanCodeStub {
explicit AddStub(Isolate* isolate) : TurboFanCodeStub(isolate) {}
DEFINE_CALL_INTERFACE_DESCRIPTOR(BinaryOp);
DEFINE_TURBOFAN_CODE_STUB(Add, TurboFanCodeStub);
DEFINE_TURBOFAN_BINARY_OP_CODE_STUB(Add, TurboFanCodeStub);
};
class SubtractStub final : public TurboFanCodeStub {
@ -689,7 +701,7 @@ class SubtractStub final : public TurboFanCodeStub {
explicit SubtractStub(Isolate* isolate) : TurboFanCodeStub(isolate) {}
DEFINE_CALL_INTERFACE_DESCRIPTOR(BinaryOp);
DEFINE_TURBOFAN_CODE_STUB(Subtract, TurboFanCodeStub);
DEFINE_TURBOFAN_BINARY_OP_CODE_STUB(Subtract, TurboFanCodeStub);
};
class MultiplyStub final : public TurboFanCodeStub {
@ -697,7 +709,7 @@ class MultiplyStub final : public TurboFanCodeStub {
explicit MultiplyStub(Isolate* isolate) : TurboFanCodeStub(isolate) {}
DEFINE_CALL_INTERFACE_DESCRIPTOR(BinaryOp);
DEFINE_TURBOFAN_CODE_STUB(Multiply, TurboFanCodeStub);
DEFINE_TURBOFAN_BINARY_OP_CODE_STUB(Multiply, TurboFanCodeStub);
};
class DivideStub final : public TurboFanCodeStub {
@ -705,7 +717,7 @@ class DivideStub final : public TurboFanCodeStub {
explicit DivideStub(Isolate* isolate) : TurboFanCodeStub(isolate) {}
DEFINE_CALL_INTERFACE_DESCRIPTOR(BinaryOp);
DEFINE_TURBOFAN_CODE_STUB(Divide, TurboFanCodeStub);
DEFINE_TURBOFAN_BINARY_OP_CODE_STUB(Divide, TurboFanCodeStub);
};
class ModulusStub final : public TurboFanCodeStub {
@ -713,7 +725,7 @@ class ModulusStub final : public TurboFanCodeStub {
explicit ModulusStub(Isolate* isolate) : TurboFanCodeStub(isolate) {}
DEFINE_CALL_INTERFACE_DESCRIPTOR(BinaryOp);
DEFINE_TURBOFAN_CODE_STUB(Modulus, TurboFanCodeStub);
DEFINE_TURBOFAN_BINARY_OP_CODE_STUB(Modulus, TurboFanCodeStub);
};
class ShiftRightStub final : public TurboFanCodeStub {
@ -721,7 +733,7 @@ class ShiftRightStub final : public TurboFanCodeStub {
explicit ShiftRightStub(Isolate* isolate) : TurboFanCodeStub(isolate) {}
DEFINE_CALL_INTERFACE_DESCRIPTOR(BinaryOp);
DEFINE_TURBOFAN_CODE_STUB(ShiftRight, TurboFanCodeStub);
DEFINE_TURBOFAN_BINARY_OP_CODE_STUB(ShiftRight, TurboFanCodeStub);
};
class ShiftRightLogicalStub final : public TurboFanCodeStub {
@ -730,7 +742,7 @@ class ShiftRightLogicalStub final : public TurboFanCodeStub {
: TurboFanCodeStub(isolate) {}
DEFINE_CALL_INTERFACE_DESCRIPTOR(BinaryOp);
DEFINE_TURBOFAN_CODE_STUB(ShiftRightLogical, TurboFanCodeStub);
DEFINE_TURBOFAN_BINARY_OP_CODE_STUB(ShiftRightLogical, TurboFanCodeStub);
};
class ShiftLeftStub final : public TurboFanCodeStub {
@ -738,7 +750,7 @@ class ShiftLeftStub final : public TurboFanCodeStub {
explicit ShiftLeftStub(Isolate* isolate) : TurboFanCodeStub(isolate) {}
DEFINE_CALL_INTERFACE_DESCRIPTOR(BinaryOp);
DEFINE_TURBOFAN_CODE_STUB(ShiftLeft, TurboFanCodeStub);
DEFINE_TURBOFAN_BINARY_OP_CODE_STUB(ShiftLeft, TurboFanCodeStub);
};
class BitwiseAndStub final : public TurboFanCodeStub {
@ -746,7 +758,7 @@ class BitwiseAndStub final : public TurboFanCodeStub {
explicit BitwiseAndStub(Isolate* isolate) : TurboFanCodeStub(isolate) {}
DEFINE_CALL_INTERFACE_DESCRIPTOR(BinaryOp);
DEFINE_TURBOFAN_CODE_STUB(BitwiseAnd, TurboFanCodeStub);
DEFINE_TURBOFAN_BINARY_OP_CODE_STUB(BitwiseAnd, TurboFanCodeStub);
};
class BitwiseOrStub final : public TurboFanCodeStub {
@ -754,7 +766,7 @@ class BitwiseOrStub final : public TurboFanCodeStub {
explicit BitwiseOrStub(Isolate* isolate) : TurboFanCodeStub(isolate) {}
DEFINE_CALL_INTERFACE_DESCRIPTOR(BinaryOp);
DEFINE_TURBOFAN_CODE_STUB(BitwiseOr, TurboFanCodeStub);
DEFINE_TURBOFAN_BINARY_OP_CODE_STUB(BitwiseOr, TurboFanCodeStub);
};
class BitwiseXorStub final : public TurboFanCodeStub {
@ -762,7 +774,7 @@ class BitwiseXorStub final : public TurboFanCodeStub {
explicit BitwiseXorStub(Isolate* isolate) : TurboFanCodeStub(isolate) {}
DEFINE_CALL_INTERFACE_DESCRIPTOR(BinaryOp);
DEFINE_TURBOFAN_CODE_STUB(BitwiseXor, TurboFanCodeStub);
DEFINE_TURBOFAN_BINARY_OP_CODE_STUB(BitwiseXor, TurboFanCodeStub);
};
class IncStub final : public TurboFanCodeStub {

View File

@ -729,12 +729,22 @@ void Interpreter::DoBinaryOp(Runtime::FunctionId function_id,
__ 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 register <src> to accumulator.
void Interpreter::DoAdd(InterpreterAssembler* assembler) {
DoBinaryOp(CodeFactory::Add(isolate_), assembler);
DoBinaryOp<AddStub>(assembler);
}
@ -742,7 +752,7 @@ void Interpreter::DoAdd(InterpreterAssembler* assembler) {
//
// Subtract register <src> from accumulator.
void Interpreter::DoSub(InterpreterAssembler* assembler) {
DoBinaryOp(CodeFactory::Subtract(isolate_), assembler);
DoBinaryOp<SubtractStub>(assembler);
}
@ -750,7 +760,7 @@ void Interpreter::DoSub(InterpreterAssembler* assembler) {
//
// Multiply accumulator by register <src>.
void Interpreter::DoMul(InterpreterAssembler* assembler) {
DoBinaryOp(CodeFactory::Multiply(isolate_), assembler);
DoBinaryOp<MultiplyStub>(assembler);
}
@ -758,7 +768,7 @@ void Interpreter::DoMul(InterpreterAssembler* assembler) {
//
// Divide register <src> by accumulator.
void Interpreter::DoDiv(InterpreterAssembler* assembler) {
DoBinaryOp(CodeFactory::Divide(isolate_), assembler);
DoBinaryOp<DivideStub>(assembler);
}
@ -766,7 +776,7 @@ void Interpreter::DoDiv(InterpreterAssembler* assembler) {
//
// Modulo register <src> by accumulator.
void Interpreter::DoMod(InterpreterAssembler* assembler) {
DoBinaryOp(CodeFactory::Modulus(isolate_), assembler);
DoBinaryOp<ModulusStub>(assembler);
}
@ -774,7 +784,7 @@ void Interpreter::DoMod(InterpreterAssembler* assembler) {
//
// BitwiseOr register <src> to accumulator.
void Interpreter::DoBitwiseOr(InterpreterAssembler* assembler) {
DoBinaryOp(CodeFactory::BitwiseOr(isolate_), assembler);
DoBinaryOp<BitwiseOrStub>(assembler);
}
@ -782,7 +792,7 @@ void Interpreter::DoBitwiseOr(InterpreterAssembler* assembler) {
//
// BitwiseXor register <src> to accumulator.
void Interpreter::DoBitwiseXor(InterpreterAssembler* assembler) {
DoBinaryOp(CodeFactory::BitwiseXor(isolate_), assembler);
DoBinaryOp<BitwiseXorStub>(assembler);
}
@ -790,7 +800,7 @@ void Interpreter::DoBitwiseXor(InterpreterAssembler* assembler) {
//
// BitwiseAnd register <src> to accumulator.
void Interpreter::DoBitwiseAnd(InterpreterAssembler* assembler) {
DoBinaryOp(CodeFactory::BitwiseAnd(isolate_), assembler);
DoBinaryOp<BitwiseAndStub>(assembler);
}
@ -801,7 +811,7 @@ void Interpreter::DoBitwiseAnd(InterpreterAssembler* assembler) {
// before the operation. 5 lsb bits from the accumulator are used as count
// i.e. <src> << (accumulator & 0x1F).
void Interpreter::DoShiftLeft(InterpreterAssembler* assembler) {
DoBinaryOp(CodeFactory::ShiftLeft(isolate_), assembler);
DoBinaryOp<ShiftLeftStub>(assembler);
}
@ -812,7 +822,7 @@ void Interpreter::DoShiftLeft(InterpreterAssembler* assembler) {
// accumulator to uint32 before the operation. 5 lsb bits from the accumulator
// are used as count i.e. <src> >> (accumulator & 0x1F).
void Interpreter::DoShiftRight(InterpreterAssembler* assembler) {
DoBinaryOp(CodeFactory::ShiftRight(isolate_), assembler);
DoBinaryOp<ShiftRightStub>(assembler);
}
@ -823,7 +833,7 @@ void Interpreter::DoShiftRight(InterpreterAssembler* assembler) {
// uint32 before the operation 5 lsb bits from the accumulator are used as
// count i.e. <src> << (accumulator & 0x1F).
void Interpreter::DoShiftRightLogical(InterpreterAssembler* assembler) {
DoBinaryOp(CodeFactory::ShiftRightLogical(isolate_), assembler);
DoBinaryOp<ShiftRightLogicalStub>(assembler);
}
void Interpreter::DoCountOp(Callable callable,

View File

@ -73,6 +73,10 @@ class Interpreter {
void DoBinaryOp(Runtime::FunctionId function_id,
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|.
void DoCountOp(Callable callable, InterpreterAssembler* assembler);