Commit 18d05c87 authored by Mythri's avatar Mythri Committed by Commit Bot

[Interpreter] Refactor arithmetic bytecode handlers.

The Smi versions of arithmetic bytecodes (AddSmi, SubSmi, MulSmi,
DivSmi, ModSmi) have a fast path for Smi case and call to a builtin
on the slow path. However, this builtin is only used by these bytecode
handlers. This cl removes the builtins and inlines them into
bytecode handlers. This will also save few checks in the slow-path.

Subtract, multiply, divide and modulus also share the same checks to 
collect type feedback on several cases. This cl also refactors them
to share the same code.

Also removed a couple of TODOs that are no longer relevant.

Bug: v8:4280, v8:6474
Change-Id: Id23bd61c2074564a1beacb0632165f52370ff226
Reviewed-on: https://chromium-review.googlesource.com/530845
Commit-Queue: Mythri Alle <mythria@chromium.org>
Reviewed-by: 's avatarIgor Sheludko <ishell@chromium.org>
Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/master@{#45982}
parent c2c4de29
......@@ -696,11 +696,6 @@ namespace internal {
TFC(GreaterThanOrEqual, Compare, 1) \
TFC(Equal, Compare, 1) \
TFC(StrictEqual, Compare, 1) \
TFC(AddWithFeedback, BinaryOpWithVector, 1) \
TFC(SubtractWithFeedback, BinaryOpWithVector, 1) \
TFC(MultiplyWithFeedback, BinaryOpWithVector, 1) \
TFC(DivideWithFeedback, BinaryOpWithVector, 1) \
TFC(ModulusWithFeedback, BinaryOpWithVector, 1) \
\
/* Object */ \
CPP(ObjectAssign) \
......
......@@ -838,65 +838,5 @@ TF_BUILTIN(StrictEqual, CodeStubAssembler) {
Return(StrictEqual(lhs, rhs));
}
TF_BUILTIN(AddWithFeedback, BinaryOpAssembler) {
Node* context = Parameter(Descriptor::kContext);
Node* left = Parameter(Descriptor::kLeft);
Node* right = Parameter(Descriptor::kRight);
Node* slot = Parameter(Descriptor::kSlot);
Node* vector = Parameter(Descriptor::kVector);
Node* function = Parameter(Descriptor::kFunction);
Return(Generate_AddWithFeedback(context, left, right,
ChangeUint32ToWord(slot), vector, function));
}
TF_BUILTIN(SubtractWithFeedback, BinaryOpAssembler) {
Node* context = Parameter(Descriptor::kContext);
Node* left = Parameter(Descriptor::kLeft);
Node* right = Parameter(Descriptor::kRight);
Node* slot = Parameter(Descriptor::kSlot);
Node* vector = Parameter(Descriptor::kVector);
Node* function = Parameter(Descriptor::kFunction);
Return(Generate_SubtractWithFeedback(
context, left, right, ChangeUint32ToWord(slot), vector, function));
}
TF_BUILTIN(MultiplyWithFeedback, BinaryOpAssembler) {
Node* context = Parameter(Descriptor::kContext);
Node* left = Parameter(Descriptor::kLeft);
Node* right = Parameter(Descriptor::kRight);
Node* slot = Parameter(Descriptor::kSlot);
Node* vector = Parameter(Descriptor::kVector);
Node* function = Parameter(Descriptor::kFunction);
Return(Generate_MultiplyWithFeedback(
context, left, right, ChangeUint32ToWord(slot), vector, function));
}
TF_BUILTIN(DivideWithFeedback, BinaryOpAssembler) {
Node* context = Parameter(Descriptor::kContext);
Node* left = Parameter(Descriptor::kLeft);
Node* right = Parameter(Descriptor::kRight);
Node* slot = Parameter(Descriptor::kSlot);
Node* vector = Parameter(Descriptor::kVector);
Node* function = Parameter(Descriptor::kFunction);
Return(Generate_DivideWithFeedback(
context, left, right, ChangeUint32ToWord(slot), vector, function));
}
TF_BUILTIN(ModulusWithFeedback, BinaryOpAssembler) {
Node* context = Parameter(Descriptor::kContext);
Node* left = Parameter(Descriptor::kLeft);
Node* right = Parameter(Descriptor::kRight);
Node* slot = Parameter(Descriptor::kSlot);
Node* vector = Parameter(Descriptor::kVector);
Node* function = Parameter(Descriptor::kFunction);
Return(Generate_ModulusWithFeedback(
context, left, right, ChangeUint32ToWord(slot), vector, function));
}
} // namespace internal
} // namespace v8
This diff is collapsed.
......@@ -5,6 +5,7 @@
#ifndef V8_SRC_IC_BINARY_OP_ASSEMBLER_H_
#define V8_SRC_IC_BINARY_OP_ASSEMBLER_H_
#include <functional>
#include "src/code-stub-assembler.h"
namespace v8 {
......@@ -23,23 +24,35 @@ class BinaryOpAssembler : public CodeStubAssembler {
Node* Generate_AddWithFeedback(Node* context, Node* lhs, Node* rhs,
Node* slot_id, Node* feedback_vector,
Node* function);
Node* function, bool rhs_is_smi);
Node* Generate_SubtractWithFeedback(Node* context, Node* lhs, Node* rhs,
Node* slot_id, Node* feedback_vector,
Node* function);
Node* function, bool rhs_is_smi);
Node* Generate_MultiplyWithFeedback(Node* context, Node* lhs, Node* rhs,
Node* slot_id, Node* feedback_vector,
Node* function);
Node* function, bool rhs_is_smi);
Node* Generate_DivideWithFeedback(Node* context, Node* dividend,
Node* divisor, Node* slot_id,
Node* feedback_vector, Node* function);
Node* feedback_vector, Node* function,
bool rhs_is_smi);
Node* Generate_ModulusWithFeedback(Node* context, Node* dividend,
Node* divisor, Node* slot_id,
Node* feedback_vector, Node* function);
Node* feedback_vector, Node* function,
bool rhs_is_smi);
private:
typedef std::function<Node*(Node*, Node*, Variable*)> SmiOperation;
typedef std::function<Node*(Node*, Node*)> FloatOperation;
Node* Generate_BinaryOperationWithFeedback(
Node* context, Node* lhs, Node* rhs, Node* slot_id, Node* feedback_vector,
Node* function, const SmiOperation& smiOperation,
const FloatOperation& floatOperation, Token::Value opcode,
bool rhs_is_smi);
};
} // namespace internal
......
This diff is collapsed.
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