Commit f43ed04f authored by epertoso's avatar epertoso Committed by Commit bot

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

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

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

Also disables the DCHECK(!is_default_snapshot) in snapshot-common.cc if --debug-code is specified. This was causing cctest to fail on arm64 debug builds.

Review-Url: https://codereview.chromium.org/1980333002
Cr-Commit-Position: refs/heads/master@{#36279}
parent aef828dc
This diff is collapsed.
...@@ -402,6 +402,18 @@ class CodeStub BASE_EMBEDDED { ...@@ -402,6 +402,18 @@ 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; \
...@@ -681,7 +693,7 @@ class AddStub final : public TurboFanCodeStub { ...@@ -681,7 +693,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_CODE_STUB(Add, TurboFanCodeStub); DEFINE_TURBOFAN_BINARY_OP_CODE_STUB(Add, TurboFanCodeStub);
}; };
class SubtractStub final : public TurboFanCodeStub { class SubtractStub final : public TurboFanCodeStub {
...@@ -689,7 +701,7 @@ class SubtractStub final : public TurboFanCodeStub { ...@@ -689,7 +701,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_CODE_STUB(Subtract, TurboFanCodeStub); DEFINE_TURBOFAN_BINARY_OP_CODE_STUB(Subtract, TurboFanCodeStub);
}; };
class MultiplyStub final : public TurboFanCodeStub { class MultiplyStub final : public TurboFanCodeStub {
...@@ -697,7 +709,7 @@ class MultiplyStub final : public TurboFanCodeStub { ...@@ -697,7 +709,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_CODE_STUB(Multiply, TurboFanCodeStub); DEFINE_TURBOFAN_BINARY_OP_CODE_STUB(Multiply, TurboFanCodeStub);
}; };
class DivideStub final : public TurboFanCodeStub { class DivideStub final : public TurboFanCodeStub {
...@@ -705,7 +717,7 @@ class DivideStub final : public TurboFanCodeStub { ...@@ -705,7 +717,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_CODE_STUB(Divide, TurboFanCodeStub); DEFINE_TURBOFAN_BINARY_OP_CODE_STUB(Divide, TurboFanCodeStub);
}; };
class ModulusStub final : public TurboFanCodeStub { class ModulusStub final : public TurboFanCodeStub {
...@@ -713,7 +725,7 @@ class ModulusStub final : public TurboFanCodeStub { ...@@ -713,7 +725,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_CODE_STUB(Modulus, TurboFanCodeStub); DEFINE_TURBOFAN_BINARY_OP_CODE_STUB(Modulus, TurboFanCodeStub);
}; };
class ShiftRightStub final : public TurboFanCodeStub { class ShiftRightStub final : public TurboFanCodeStub {
...@@ -721,7 +733,7 @@ class ShiftRightStub final : public TurboFanCodeStub { ...@@ -721,7 +733,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_CODE_STUB(ShiftRight, TurboFanCodeStub); DEFINE_TURBOFAN_BINARY_OP_CODE_STUB(ShiftRight, TurboFanCodeStub);
}; };
class ShiftRightLogicalStub final : public TurboFanCodeStub { class ShiftRightLogicalStub final : public TurboFanCodeStub {
...@@ -730,7 +742,7 @@ class ShiftRightLogicalStub final : public TurboFanCodeStub { ...@@ -730,7 +742,7 @@ class ShiftRightLogicalStub final : public TurboFanCodeStub {
: TurboFanCodeStub(isolate) {} : TurboFanCodeStub(isolate) {}
DEFINE_CALL_INTERFACE_DESCRIPTOR(BinaryOp); DEFINE_CALL_INTERFACE_DESCRIPTOR(BinaryOp);
DEFINE_TURBOFAN_CODE_STUB(ShiftRightLogical, TurboFanCodeStub); DEFINE_TURBOFAN_BINARY_OP_CODE_STUB(ShiftRightLogical, TurboFanCodeStub);
}; };
class ShiftLeftStub final : public TurboFanCodeStub { class ShiftLeftStub final : public TurboFanCodeStub {
...@@ -738,7 +750,7 @@ class ShiftLeftStub final : public TurboFanCodeStub { ...@@ -738,7 +750,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_CODE_STUB(ShiftLeft, TurboFanCodeStub); DEFINE_TURBOFAN_BINARY_OP_CODE_STUB(ShiftLeft, TurboFanCodeStub);
}; };
class BitwiseAndStub final : public TurboFanCodeStub { class BitwiseAndStub final : public TurboFanCodeStub {
...@@ -746,7 +758,7 @@ class BitwiseAndStub final : public TurboFanCodeStub { ...@@ -746,7 +758,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_CODE_STUB(BitwiseAnd, TurboFanCodeStub); DEFINE_TURBOFAN_BINARY_OP_CODE_STUB(BitwiseAnd, TurboFanCodeStub);
}; };
class BitwiseOrStub final : public TurboFanCodeStub { class BitwiseOrStub final : public TurboFanCodeStub {
...@@ -754,7 +766,7 @@ class BitwiseOrStub final : public TurboFanCodeStub { ...@@ -754,7 +766,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_CODE_STUB(BitwiseOr, TurboFanCodeStub); DEFINE_TURBOFAN_BINARY_OP_CODE_STUB(BitwiseOr, TurboFanCodeStub);
}; };
class BitwiseXorStub final : public TurboFanCodeStub { class BitwiseXorStub final : public TurboFanCodeStub {
...@@ -762,7 +774,7 @@ class BitwiseXorStub final : public TurboFanCodeStub { ...@@ -762,7 +774,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_CODE_STUB(BitwiseXor, TurboFanCodeStub); DEFINE_TURBOFAN_BINARY_OP_CODE_STUB(BitwiseXor, TurboFanCodeStub);
}; };
class IncStub final : public TurboFanCodeStub { class IncStub final : public TurboFanCodeStub {
......
...@@ -729,12 +729,22 @@ void Interpreter::DoBinaryOp(Runtime::FunctionId function_id, ...@@ -729,12 +729,22 @@ 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(CodeFactory::Add(isolate_), assembler); DoBinaryOp<AddStub>(assembler);
} }
...@@ -742,7 +752,7 @@ void Interpreter::DoAdd(InterpreterAssembler* assembler) { ...@@ -742,7 +752,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(CodeFactory::Subtract(isolate_), assembler); DoBinaryOp<SubtractStub>(assembler);
} }
...@@ -750,7 +760,7 @@ void Interpreter::DoSub(InterpreterAssembler* assembler) { ...@@ -750,7 +760,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(CodeFactory::Multiply(isolate_), assembler); DoBinaryOp<MultiplyStub>(assembler);
} }
...@@ -758,7 +768,7 @@ void Interpreter::DoMul(InterpreterAssembler* assembler) { ...@@ -758,7 +768,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(CodeFactory::Divide(isolate_), assembler); DoBinaryOp<DivideStub>(assembler);
} }
...@@ -766,7 +776,7 @@ void Interpreter::DoDiv(InterpreterAssembler* assembler) { ...@@ -766,7 +776,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(CodeFactory::Modulus(isolate_), assembler); DoBinaryOp<ModulusStub>(assembler);
} }
...@@ -774,7 +784,7 @@ void Interpreter::DoMod(InterpreterAssembler* assembler) { ...@@ -774,7 +784,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(CodeFactory::BitwiseOr(isolate_), assembler); DoBinaryOp<BitwiseOrStub>(assembler);
} }
...@@ -782,7 +792,7 @@ void Interpreter::DoBitwiseOr(InterpreterAssembler* assembler) { ...@@ -782,7 +792,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(CodeFactory::BitwiseXor(isolate_), assembler); DoBinaryOp<BitwiseXorStub>(assembler);
} }
...@@ -790,7 +800,7 @@ void Interpreter::DoBitwiseXor(InterpreterAssembler* assembler) { ...@@ -790,7 +800,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(CodeFactory::BitwiseAnd(isolate_), assembler); DoBinaryOp<BitwiseAndStub>(assembler);
} }
...@@ -801,7 +811,7 @@ void Interpreter::DoBitwiseAnd(InterpreterAssembler* assembler) { ...@@ -801,7 +811,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(CodeFactory::ShiftLeft(isolate_), assembler); DoBinaryOp<ShiftLeftStub>(assembler);
} }
...@@ -812,7 +822,7 @@ void Interpreter::DoShiftLeft(InterpreterAssembler* assembler) { ...@@ -812,7 +822,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(CodeFactory::ShiftRight(isolate_), assembler); DoBinaryOp<ShiftRightStub>(assembler);
} }
...@@ -823,7 +833,7 @@ void Interpreter::DoShiftRight(InterpreterAssembler* assembler) { ...@@ -823,7 +833,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(CodeFactory::ShiftRightLogical(isolate_), assembler); DoBinaryOp<ShiftRightLogicalStub>(assembler);
} }
void Interpreter::DoCountOp(Callable callable, void Interpreter::DoCountOp(Callable callable,
......
...@@ -73,6 +73,10 @@ class Interpreter { ...@@ -73,6 +73,10 @@ 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);
......
...@@ -142,8 +142,9 @@ void CalculateFirstPageSizes(bool is_default_snapshot, ...@@ -142,8 +142,9 @@ void CalculateFirstPageSizes(bool is_default_snapshot,
Page::kObjectStartOffset; Page::kObjectStartOffset;
// Add a small allowance to the code space for small scripts. // Add a small allowance to the code space for small scripts.
if (space == CODE_SPACE) required += 32 * KB; if (space == CODE_SPACE) required += 32 * KB;
} else { } else if (!FLAG_debug_code) {
// We expect the vanilla snapshot to only require on page per space. // We expect the vanilla snapshot to only require one page per space,
// unless we are emitting debug code.
DCHECK(!is_default_snapshot); DCHECK(!is_default_snapshot);
} }
......
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