aboutsummaryrefslogtreecommitdiff
path: root/deps/v8/src/compiler/js-type-hint-lowering.cc
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/src/compiler/js-type-hint-lowering.cc')
-rw-r--r--deps/v8/src/compiler/js-type-hint-lowering.cc58
1 files changed, 58 insertions, 0 deletions
diff --git a/deps/v8/src/compiler/js-type-hint-lowering.cc b/deps/v8/src/compiler/js-type-hint-lowering.cc
index 9d882e8238..f3696bcc48 100644
--- a/deps/v8/src/compiler/js-type-hint-lowering.cc
+++ b/deps/v8/src/compiler/js-type-hint-lowering.cc
@@ -44,6 +44,25 @@ bool BinaryOperationHintToNumberOperationHint(
return false;
}
+bool BinaryOperationHintToBigIntOperationHint(
+ BinaryOperationHint binop_hint, BigIntOperationHint* bigint_hint) {
+ switch (binop_hint) {
+ case BinaryOperationHint::kSignedSmall:
+ case BinaryOperationHint::kSignedSmallInputs:
+ case BinaryOperationHint::kSigned32:
+ case BinaryOperationHint::kNumber:
+ case BinaryOperationHint::kNumberOrOddball:
+ case BinaryOperationHint::kAny:
+ case BinaryOperationHint::kNone:
+ case BinaryOperationHint::kString:
+ return false;
+ case BinaryOperationHint::kBigInt:
+ *bigint_hint = BigIntOperationHint::kBigInt;
+ return true;
+ }
+ UNREACHABLE();
+}
+
} // namespace
class JSSpeculativeBinopBuilder final {
@@ -74,6 +93,11 @@ class JSSpeculativeBinopBuilder final {
hint);
}
+ bool GetBinaryBigIntOperationHint(BigIntOperationHint* hint) {
+ return BinaryOperationHintToBigIntOperationHint(GetBinaryOperationHint(),
+ hint);
+ }
+
bool GetCompareNumberOperationHint(NumberOperationHint* hint) {
switch (GetCompareOperationHint()) {
case CompareOperationHint::kSignedSmall:
@@ -138,6 +162,16 @@ class JSSpeculativeBinopBuilder final {
UNREACHABLE();
}
+ const Operator* SpeculativeBigIntOp(BigIntOperationHint hint) {
+ switch (op_->opcode()) {
+ case IrOpcode::kJSAdd:
+ return simplified()->SpeculativeBigIntAdd(hint);
+ default:
+ break;
+ }
+ UNREACHABLE();
+ }
+
const Operator* SpeculativeCompareOp(NumberOperationHint hint) {
switch (op_->opcode()) {
case IrOpcode::kJSEqual:
@@ -179,6 +213,16 @@ class JSSpeculativeBinopBuilder final {
return nullptr;
}
+ Node* TryBuildBigIntBinop() {
+ BigIntOperationHint hint;
+ if (GetBinaryBigIntOperationHint(&hint)) {
+ const Operator* op = SpeculativeBigIntOp(hint);
+ Node* node = BuildSpeculativeOperation(op);
+ return node;
+ }
+ return nullptr;
+ }
+
Node* TryBuildNumberCompare() {
NumberOperationHint hint;
if (GetCompareNumberOperationHint(&hint)) {
@@ -264,6 +308,15 @@ JSTypeHintLowering::LoweringResult JSTypeHintLowering::ReduceUnaryOperation(
operand, jsgraph()->SmiConstant(-1), effect,
control, slot);
node = b.TryBuildNumberBinop();
+ if (!node) {
+ FeedbackNexus nexus(feedback_vector(), slot);
+ if (nexus.GetBinaryOperationFeedback() ==
+ BinaryOperationHint::kBigInt) {
+ const Operator* op = jsgraph()->simplified()->SpeculativeBigIntNegate(
+ BigIntOperationHint::kBigInt);
+ node = jsgraph()->graph()->NewNode(op, operand, effect, control);
+ }
+ }
break;
}
default:
@@ -345,6 +398,11 @@ JSTypeHintLowering::LoweringResult JSTypeHintLowering::ReduceBinaryOperation(
if (Node* node = b.TryBuildNumberBinop()) {
return LoweringResult::SideEffectFree(node, node, control);
}
+ if (op->opcode() == IrOpcode::kJSAdd) {
+ if (Node* node = b.TryBuildBigIntBinop()) {
+ return LoweringResult::SideEffectFree(node, node, control);
+ }
+ }
break;
}
case IrOpcode::kJSExponentiate: {