Commit 0bedf6f0 authored by bmeurer's avatar bmeurer Committed by Commit bot

[stubs] Introduce AddStub and SubtractStub.

This adds two new stubs, AddStub and SubtractStub, for the plus and the
minus operators, and hooks them up with TurboFan and Ignition.
Especially the addition case is very heavy and we might want to look
into splitting that up further into specialized stubs (similar to what
we did with ToNumberStub recently).

R=epertoso@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#34994}
parent 890f3dd7
...@@ -206,6 +206,18 @@ Callable CodeFactory::RegExpExec(Isolate* isolate) { ...@@ -206,6 +206,18 @@ Callable CodeFactory::RegExpExec(Isolate* isolate) {
return Callable(stub.GetCode(), stub.GetCallInterfaceDescriptor()); return Callable(stub.GetCode(), stub.GetCallInterfaceDescriptor());
} }
// static
Callable CodeFactory::Add(Isolate* isolate) {
AddStub stub(isolate);
return Callable(stub.GetCode(), stub.GetCallInterfaceDescriptor());
}
// static
Callable CodeFactory::Subtract(Isolate* isolate) {
SubtractStub stub(isolate);
return Callable(stub.GetCode(), stub.GetCallInterfaceDescriptor());
}
// static // static
Callable CodeFactory::LessThan(Isolate* isolate) { Callable CodeFactory::LessThan(Isolate* isolate) {
LessThanStub stub(isolate); LessThanStub stub(isolate);
......
...@@ -79,6 +79,8 @@ class CodeFactory final { ...@@ -79,6 +79,8 @@ class CodeFactory final {
static Callable RegExpConstructResult(Isolate* isolate); static Callable RegExpConstructResult(Isolate* isolate);
static Callable RegExpExec(Isolate* isolate); static Callable RegExpExec(Isolate* isolate);
static Callable Add(Isolate* isolate);
static Callable Subtract(Isolate* isolate);
static Callable LessThan(Isolate* isolate); static Callable LessThan(Isolate* isolate);
static Callable LessThanOrEqual(Isolate* isolate); static Callable LessThanOrEqual(Isolate* isolate);
static Callable GreaterThan(Isolate* isolate); static Callable GreaterThan(Isolate* isolate);
......
This diff is collapsed.
...@@ -111,6 +111,8 @@ namespace internal { ...@@ -111,6 +111,8 @@ namespace internal {
V(AllocateUint8x16) \ V(AllocateUint8x16) \
V(AllocateBool8x16) \ V(AllocateBool8x16) \
V(StringLength) \ V(StringLength) \
V(Add) \
V(Subtract) \
V(LessThan) \ V(LessThan) \
V(LessThanOrEqual) \ V(LessThanOrEqual) \
V(GreaterThan) \ V(GreaterThan) \
...@@ -667,6 +669,22 @@ class StringLengthStub : public TurboFanCodeStub { ...@@ -667,6 +669,22 @@ class StringLengthStub : public TurboFanCodeStub {
DEFINE_TURBOFAN_CODE_STUB(StringLength, TurboFanCodeStub); DEFINE_TURBOFAN_CODE_STUB(StringLength, TurboFanCodeStub);
}; };
class AddStub final : public TurboFanCodeStub {
public:
explicit AddStub(Isolate* isolate) : TurboFanCodeStub(isolate) {}
DEFINE_CALL_INTERFACE_DESCRIPTOR(BinaryOp);
DEFINE_TURBOFAN_CODE_STUB(Add, TurboFanCodeStub);
};
class SubtractStub final : public TurboFanCodeStub {
public:
explicit SubtractStub(Isolate* isolate) : TurboFanCodeStub(isolate) {}
DEFINE_CALL_INTERFACE_DESCRIPTOR(BinaryOp);
DEFINE_TURBOFAN_CODE_STUB(Subtract, TurboFanCodeStub);
};
class LessThanStub final : public TurboFanCodeStub { class LessThanStub final : public TurboFanCodeStub {
public: public:
explicit LessThanStub(Isolate* isolate) : TurboFanCodeStub(isolate) {} explicit LessThanStub(Isolate* isolate) : TurboFanCodeStub(isolate) {}
......
...@@ -175,6 +175,16 @@ Node* CodeStubAssembler::SmiToFloat64(Node* value) { ...@@ -175,6 +175,16 @@ Node* CodeStubAssembler::SmiToFloat64(Node* value) {
Node* CodeStubAssembler::SmiAdd(Node* a, Node* b) { return IntPtrAdd(a, b); } Node* CodeStubAssembler::SmiAdd(Node* a, Node* b) { return IntPtrAdd(a, b); }
Node* CodeStubAssembler::SmiAddWithOverflow(Node* a, Node* b) {
return IntPtrAddWithOverflow(a, b);
}
Node* CodeStubAssembler::SmiSub(Node* a, Node* b) { return IntPtrSub(a, b); }
Node* CodeStubAssembler::SmiSubWithOverflow(Node* a, Node* b) {
return IntPtrSubWithOverflow(a, b);
}
Node* CodeStubAssembler::SmiEqual(Node* a, Node* b) { return WordEqual(a, b); } Node* CodeStubAssembler::SmiEqual(Node* a, Node* b) { return WordEqual(a, b); }
Node* CodeStubAssembler::SmiLessThan(Node* a, Node* b) { Node* CodeStubAssembler::SmiLessThan(Node* a, Node* b) {
......
...@@ -63,8 +63,12 @@ class Schedule; ...@@ -63,8 +63,12 @@ class Schedule;
#define CODE_STUB_ASSEMBLER_BINARY_OP_LIST(V) \ #define CODE_STUB_ASSEMBLER_BINARY_OP_LIST(V) \
CODE_STUB_ASSEMBLER_COMPARE_BINARY_OP_LIST(V) \ CODE_STUB_ASSEMBLER_COMPARE_BINARY_OP_LIST(V) \
V(Float64Add) \
V(Float64Sub) \
V(IntPtrAdd) \ V(IntPtrAdd) \
V(IntPtrAddWithOverflow) \
V(IntPtrSub) \ V(IntPtrSub) \
V(IntPtrSubWithOverflow) \
V(Int32Add) \ V(Int32Add) \
V(Int32Sub) \ V(Int32Sub) \
V(Int32Mul) \ V(Int32Mul) \
...@@ -263,6 +267,9 @@ class CodeStubAssembler { ...@@ -263,6 +267,9 @@ class CodeStubAssembler {
// Smi operations. // Smi operations.
Node* SmiAdd(Node* a, Node* b); Node* SmiAdd(Node* a, Node* b);
Node* SmiAddWithOverflow(Node* a, Node* b);
Node* SmiSub(Node* a, Node* b);
Node* SmiSubWithOverflow(Node* a, Node* b);
Node* SmiEqual(Node* a, Node* b); Node* SmiEqual(Node* a, Node* b);
Node* SmiLessThan(Node* a, Node* b); Node* SmiLessThan(Node* a, Node* b);
Node* SmiLessThanOrEqual(Node* a, Node* b); Node* SmiLessThanOrEqual(Node* a, Node* b);
......
...@@ -76,8 +76,6 @@ REPLACE_BINARY_OP_IC_CALL(JSBitwiseAnd, Token::BIT_AND) ...@@ -76,8 +76,6 @@ REPLACE_BINARY_OP_IC_CALL(JSBitwiseAnd, Token::BIT_AND)
REPLACE_BINARY_OP_IC_CALL(JSShiftLeft, Token::SHL) REPLACE_BINARY_OP_IC_CALL(JSShiftLeft, Token::SHL)
REPLACE_BINARY_OP_IC_CALL(JSShiftRight, Token::SAR) REPLACE_BINARY_OP_IC_CALL(JSShiftRight, Token::SAR)
REPLACE_BINARY_OP_IC_CALL(JSShiftRightLogical, Token::SHR) REPLACE_BINARY_OP_IC_CALL(JSShiftRightLogical, Token::SHR)
REPLACE_BINARY_OP_IC_CALL(JSAdd, Token::ADD)
REPLACE_BINARY_OP_IC_CALL(JSSubtract, Token::SUB)
REPLACE_BINARY_OP_IC_CALL(JSMultiply, Token::MUL) REPLACE_BINARY_OP_IC_CALL(JSMultiply, Token::MUL)
REPLACE_BINARY_OP_IC_CALL(JSDivide, Token::DIV) REPLACE_BINARY_OP_IC_CALL(JSDivide, Token::DIV)
REPLACE_BINARY_OP_IC_CALL(JSModulus, Token::MOD) REPLACE_BINARY_OP_IC_CALL(JSModulus, Token::MOD)
...@@ -98,6 +96,8 @@ REPLACE_RUNTIME_CALL(JSConvertReceiver, Runtime::kConvertReceiver) ...@@ -98,6 +96,8 @@ REPLACE_RUNTIME_CALL(JSConvertReceiver, Runtime::kConvertReceiver)
Callable callable = CodeFactory::Name(isolate()); \ Callable callable = CodeFactory::Name(isolate()); \
ReplaceWithStubCall(node, callable, flags); \ ReplaceWithStubCall(node, callable, flags); \
} }
REPLACE_STUB_CALL(Add)
REPLACE_STUB_CALL(Subtract)
REPLACE_STUB_CALL(LessThan) REPLACE_STUB_CALL(LessThan)
REPLACE_STUB_CALL(LessThanOrEqual) REPLACE_STUB_CALL(LessThanOrEqual)
REPLACE_STUB_CALL(GreaterThan) REPLACE_STUB_CALL(GreaterThan)
......
...@@ -347,7 +347,9 @@ class RawMachineAssembler { ...@@ -347,7 +347,9 @@ class RawMachineAssembler {
} }
INTPTR_BINOP(Int, Add); INTPTR_BINOP(Int, Add);
INTPTR_BINOP(Int, AddWithOverflow);
INTPTR_BINOP(Int, Sub); INTPTR_BINOP(Int, Sub);
INTPTR_BINOP(Int, SubWithOverflow);
INTPTR_BINOP(Int, LessThan); INTPTR_BINOP(Int, LessThan);
INTPTR_BINOP(Int, LessThanOrEqual); INTPTR_BINOP(Int, LessThanOrEqual);
INTPTR_BINOP(Word, Equal); INTPTR_BINOP(Word, Equal);
......
...@@ -650,7 +650,7 @@ void Interpreter::DoBinaryOp(Runtime::FunctionId function_id, ...@@ -650,7 +650,7 @@ void Interpreter::DoBinaryOp(Runtime::FunctionId function_id,
// //
// Add register <src> to accumulator. // Add register <src> to accumulator.
void Interpreter::DoAdd(InterpreterAssembler* assembler) { void Interpreter::DoAdd(InterpreterAssembler* assembler) {
DoBinaryOp(Runtime::kAdd, assembler); DoBinaryOp(CodeFactory::Add(isolate_), assembler);
} }
...@@ -658,7 +658,7 @@ void Interpreter::DoAdd(InterpreterAssembler* assembler) { ...@@ -658,7 +658,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(Runtime::kSubtract, assembler); DoBinaryOp(CodeFactory::Subtract(isolate_), assembler);
} }
......
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