Commit f9cb3fe6 authored by Hao Xu's avatar Hao Xu Committed by V8 LUCI CQ

[baseline] Optimize Binop with Smi rhs

Current Baseline compiler generates calls to Binop_Baseline for both
Binop and Binop with Smi rhs. This CL make BinopSmi calls to
BinopSmi_Baseline which does not do speculation for rhs.

Bug: v8:12442
Change-Id: Ied786af028429aa0842b9b6d2a5736779f24b568
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3303807Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
Commit-Queue: Hao A Xu <hao.a.xu@intel.com>
Cr-Commit-Position: refs/heads/main@{#78141}
parent 77f3e88a
......@@ -1043,33 +1043,33 @@ void BaselineCompiler::VisitShiftRightLogical() {
}
void BaselineCompiler::VisitAddSmi() {
CallBuiltin<Builtin::kAdd_Baseline>(kInterpreterAccumulatorRegister,
IntAsSmi(0), Index(1));
CallBuiltin<Builtin::kAddSmi_Baseline>(kInterpreterAccumulatorRegister,
IntAsSmi(0), Index(1));
}
void BaselineCompiler::VisitSubSmi() {
CallBuiltin<Builtin::kSubtract_Baseline>(kInterpreterAccumulatorRegister,
IntAsSmi(0), Index(1));
CallBuiltin<Builtin::kSubtractSmi_Baseline>(kInterpreterAccumulatorRegister,
IntAsSmi(0), Index(1));
}
void BaselineCompiler::VisitMulSmi() {
CallBuiltin<Builtin::kMultiply_Baseline>(kInterpreterAccumulatorRegister,
IntAsSmi(0), Index(1));
CallBuiltin<Builtin::kMultiplySmi_Baseline>(kInterpreterAccumulatorRegister,
IntAsSmi(0), Index(1));
}
void BaselineCompiler::VisitDivSmi() {
CallBuiltin<Builtin::kDivide_Baseline>(kInterpreterAccumulatorRegister,
IntAsSmi(0), Index(1));
CallBuiltin<Builtin::kDivideSmi_Baseline>(kInterpreterAccumulatorRegister,
IntAsSmi(0), Index(1));
}
void BaselineCompiler::VisitModSmi() {
CallBuiltin<Builtin::kModulus_Baseline>(kInterpreterAccumulatorRegister,
IntAsSmi(0), Index(1));
CallBuiltin<Builtin::kModulusSmi_Baseline>(kInterpreterAccumulatorRegister,
IntAsSmi(0), Index(1));
}
void BaselineCompiler::VisitExpSmi() {
CallBuiltin<Builtin::kExponentiate_Baseline>(kInterpreterAccumulatorRegister,
IntAsSmi(0), Index(1));
CallBuiltin<Builtin::kExponentiateSmi_Baseline>(
kInterpreterAccumulatorRegister, IntAsSmi(0), Index(1));
}
void BaselineCompiler::VisitBitwiseOrSmi() {
......
......@@ -704,11 +704,17 @@ namespace internal {
\
/* Binary ops with feedback collection */ \
TFC(Add_Baseline, BinaryOp_Baseline) \
TFC(AddSmi_Baseline, BinaryOp_Baseline) \
TFC(Subtract_Baseline, BinaryOp_Baseline) \
TFC(SubtractSmi_Baseline, BinaryOp_Baseline) \
TFC(Multiply_Baseline, BinaryOp_Baseline) \
TFC(MultiplySmi_Baseline, BinaryOp_Baseline) \
TFC(Divide_Baseline, BinaryOp_Baseline) \
TFC(DivideSmi_Baseline, BinaryOp_Baseline) \
TFC(Modulus_Baseline, BinaryOp_Baseline) \
TFC(ModulusSmi_Baseline, BinaryOp_Baseline) \
TFC(Exponentiate_Baseline, BinaryOp_Baseline) \
TFC(ExponentiateSmi_Baseline, BinaryOp_Baseline) \
TFC(BitwiseAnd_Baseline, BinaryOp_Baseline) \
TFC(BitwiseOr_Baseline, BinaryOp_Baseline) \
TFC(BitwiseXor_Baseline, BinaryOp_Baseline) \
......
......@@ -74,6 +74,28 @@ DEF_BINOP(ShiftRight_Baseline, Generate_ShiftRightWithFeedback)
DEF_BINOP(ShiftRightLogical_Baseline, Generate_ShiftRightLogicalWithFeedback)
#undef DEF_BINOP
#define DEF_BINOP_RHS_SMI(Name, Generator) \
TF_BUILTIN(Name, CodeStubAssembler) { \
auto lhs = Parameter<Object>(Descriptor::kLeft); \
auto rhs = Parameter<Object>(Descriptor::kRight); \
auto slot = UncheckedParameter<UintPtrT>(Descriptor::kSlot); \
\
BinaryOpAssembler binop_asm(state()); \
TNode<Object> result = binop_asm.Generator( \
[&]() { return LoadContextFromBaseline(); }, lhs, rhs, slot, \
[&]() { return LoadFeedbackVectorFromBaseline(); }, \
UpdateFeedbackMode::kGuaranteedFeedback, true); \
\
Return(result); \
}
DEF_BINOP_RHS_SMI(AddSmi_Baseline, Generate_AddWithFeedback)
DEF_BINOP_RHS_SMI(SubtractSmi_Baseline, Generate_SubtractWithFeedback)
DEF_BINOP_RHS_SMI(MultiplySmi_Baseline, Generate_MultiplyWithFeedback)
DEF_BINOP_RHS_SMI(DivideSmi_Baseline, Generate_DivideWithFeedback)
DEF_BINOP_RHS_SMI(ModulusSmi_Baseline, Generate_ModulusWithFeedback)
DEF_BINOP_RHS_SMI(ExponentiateSmi_Baseline, Generate_ExponentiateWithFeedback)
#undef DEF_BINOP_RHS_SMI
#define DEF_UNOP(Name, Generator) \
TF_BUILTIN(Name, CodeStubAssembler) { \
auto value = Parameter<Object>(Descriptor::kValue); \
......
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