Commit 91154b37 authored by Nico Hartmann's avatar Nico Hartmann Committed by Commit Bot

[turbofan] Non-speculative BigInt operators

This CL introduces new non-speculative operators BigIntAdd
and BigIntNegate. Instead of keeping speculative operators
until effect-control-linearization phase, they are now lowered
to non-speculative variants in the simplified lowering and
surrounded by the necessary checks. This adapts BigInt operators
to the common style of other operators (like Numbers).

Bug: v8:9407
Change-Id: I89ea7aef0d78c67b103971f8f63525b196ad3c0c
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1695467
Commit-Queue: Nico Hartmann <nicohartmann@google.com>
Reviewed-by: 's avatarSigurd Schneider <sigurds@chromium.org>
Reviewed-by: 's avatarGeorg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#62699}
parent 5664228a
......@@ -169,8 +169,8 @@ class EffectControlLinearizer {
Node* LowerStringEqual(Node* node);
Node* LowerStringLessThan(Node* node);
Node* LowerStringLessThanOrEqual(Node* node);
Node* LowerSpeculativeBigIntAdd(Node* node, Node* frame_state);
Node* LowerSpeculativeBigIntNegate(Node* node, Node* frame_state);
Node* LowerBigIntAdd(Node* node, Node* frame_state);
Node* LowerBigIntNegate(Node* node);
Node* LowerCheckFloat64Hole(Node* node, Node* frame_state);
Node* LowerCheckNotTaggedHole(Node* node, Node* frame_state);
Node* LowerConvertTaggedHoleToUndefined(Node* node);
......@@ -1174,11 +1174,11 @@ bool EffectControlLinearizer::TryWireInStateEffect(Node* node,
case IrOpcode::kStringLessThanOrEqual:
result = LowerStringLessThanOrEqual(node);
break;
case IrOpcode::kSpeculativeBigIntAdd:
result = LowerSpeculativeBigIntAdd(node, frame_state);
case IrOpcode::kBigIntAdd:
result = LowerBigIntAdd(node, frame_state);
break;
case IrOpcode::kSpeculativeBigIntNegate:
result = LowerSpeculativeBigIntNegate(node, frame_state);
case IrOpcode::kBigIntNegate:
result = LowerBigIntNegate(node);
break;
case IrOpcode::kNumberIsFloat64Hole:
result = LowerNumberIsFloat64Hole(node);
......@@ -4254,8 +4254,7 @@ Node* EffectControlLinearizer::LowerStringLessThanOrEqual(Node* node) {
Builtins::CallableFor(isolate(), Builtins::kStringLessThanOrEqual), node);
}
Node* EffectControlLinearizer::LowerSpeculativeBigIntAdd(Node* node,
Node* frame_state) {
Node* EffectControlLinearizer::LowerBigIntAdd(Node* node, Node* frame_state) {
Node* lhs = node->InputAt(0);
Node* rhs = node->InputAt(1);
......@@ -4276,8 +4275,7 @@ Node* EffectControlLinearizer::LowerSpeculativeBigIntAdd(Node* node,
return value;
}
Node* EffectControlLinearizer::LowerSpeculativeBigIntNegate(Node* node,
Node* frame_state) {
Node* EffectControlLinearizer::LowerBigIntNegate(Node* node) {
Callable const callable =
Builtins::CallableFor(isolate(), Builtins::kBigIntUnaryMinus);
auto call_descriptor = Linkage::GetStubCallDescriptor(
......
......@@ -323,6 +323,8 @@
V(NumberMin) \
V(NumberPow)
#define SIMPLIFIED_BIGINT_BINOP_LIST(V) V(BigIntAdd)
#define SIMPLIFIED_SPECULATIVE_NUMBER_BINOP_LIST(V) \
V(SpeculativeNumberAdd) \
V(SpeculativeNumberSubtract) \
......@@ -376,6 +378,7 @@
#define SIMPLIFIED_BIGINT_UNOP_LIST(V) \
V(BigIntAsUintN) \
V(BigIntNegate) \
V(CheckBigInt)
#define SIMPLIFIED_SPECULATIVE_NUMBER_UNOP_LIST(V) V(SpeculativeToNumber)
......@@ -482,6 +485,7 @@
SIMPLIFIED_CHECKED_OP_LIST(V) \
SIMPLIFIED_COMPARE_BINOP_LIST(V) \
SIMPLIFIED_NUMBER_BINOP_LIST(V) \
SIMPLIFIED_BIGINT_BINOP_LIST(V) \
SIMPLIFIED_SPECULATIVE_NUMBER_BINOP_LIST(V) \
SIMPLIFIED_NUMBER_UNOP_LIST(V) \
SIMPLIFIED_BIGINT_UNOP_LIST(V) \
......
......@@ -1120,6 +1120,16 @@ SPECULATIVE_NUMBER_BINOP(NumberShiftRight)
SPECULATIVE_NUMBER_BINOP(NumberShiftRightLogical)
#undef SPECULATIVE_NUMBER_BINOP
Type OperationTyper::BigIntAdd(Type lhs, Type rhs) {
if (lhs.IsNone() || rhs.IsNone()) return Type::None();
return Type::BigInt();
}
Type OperationTyper::BigIntNegate(Type type) {
if (type.IsNone()) return type;
return Type::BigInt();
}
Type OperationTyper::SpeculativeBigIntAdd(Type lhs, Type rhs) {
if (lhs.IsNone() || rhs.IsNone()) return Type::None();
return Type::BigInt();
......
......@@ -52,6 +52,7 @@ class V8_EXPORT_PRIVATE OperationTyper {
// Numeric binary operators.
#define DECLARE_METHOD(Name) Type Name(Type lhs, Type rhs);
SIMPLIFIED_NUMBER_BINOP_LIST(DECLARE_METHOD)
SIMPLIFIED_BIGINT_BINOP_LIST(DECLARE_METHOD)
SIMPLIFIED_SPECULATIVE_NUMBER_BINOP_LIST(DECLARE_METHOD)
SIMPLIFIED_SPECULATIVE_BIGINT_BINOP_LIST(DECLARE_METHOD)
#undef DECLARE_METHOD
......
......@@ -2711,6 +2711,9 @@ class RepresentationSelector {
VisitBinop(node,
UseInfo::CheckedBigIntAsTaggedPointer(VectorSlotPair{}),
MachineRepresentation::kTaggedPointer);
if (lower()) {
NodeProperties::ChangeOp(node, lowering->simplified()->BigIntAdd());
}
}
return;
}
......@@ -2727,6 +2730,9 @@ class RepresentationSelector {
VisitUnop(node,
UseInfo::CheckedBigIntAsTaggedPointer(VectorSlotPair{}),
MachineRepresentation::kTaggedPointer);
if (lower()) {
ChangeToPureOp(node, lowering->simplified()->BigIntNegate());
}
}
return;
}
......
......@@ -708,6 +708,7 @@ bool operator==(CheckMinusZeroParameters const& lhs,
V(NumberToUint32, Operator::kNoProperties, 1, 0) \
V(NumberToUint8Clamped, Operator::kNoProperties, 1, 0) \
V(NumberSilenceNaN, Operator::kNoProperties, 1, 0) \
V(BigIntNegate, Operator::kNoProperties, 1, 0) \
V(StringConcat, Operator::kNoProperties, 3, 0) \
V(StringToNumber, Operator::kNoProperties, 1, 0) \
V(StringFromSingleCharCode, Operator::kNoProperties, 1, 0) \
......@@ -781,6 +782,7 @@ bool operator==(CheckMinusZeroParameters const& lhs,
V(PoisonIndex, Operator::kNoProperties, 1, 0)
#define EFFECT_DEPENDENT_OP_LIST(V) \
V(BigIntAdd, Operator::kNoProperties, 2, 1) \
V(StringCharCodeAt, Operator::kNoProperties, 2, 1) \
V(StringCodePointAt, Operator::kNoProperties, 2, 1) \
V(StringFromCodePointAt, Operator::kNoProperties, 2, 1) \
......
......@@ -639,6 +639,9 @@ class V8_EXPORT_PRIVATE SimplifiedOperatorBuilder final
const Operator* NumberSilenceNaN();
const Operator* BigIntAdd();
const Operator* BigIntNegate();
const Operator* SpeculativeSafeIntegerAdd(NumberOperationHint hint);
const Operator* SpeculativeSafeIntegerSubtract(NumberOperationHint hint);
......
......@@ -91,6 +91,7 @@ class Typer::Visitor : public Reducer {
case IrOpcode::k##x: \
return UpdateType(node, TypeBinaryOp(node, x));
SIMPLIFIED_NUMBER_BINOP_LIST(DECLARE_CASE)
SIMPLIFIED_BIGINT_BINOP_LIST(DECLARE_CASE)
SIMPLIFIED_SPECULATIVE_NUMBER_BINOP_LIST(DECLARE_CASE)
SIMPLIFIED_SPECULATIVE_BIGINT_BINOP_LIST(DECLARE_CASE)
#undef DECLARE_CASE
......@@ -160,6 +161,7 @@ class Typer::Visitor : public Reducer {
case IrOpcode::k##x: \
return TypeBinaryOp(node, x);
SIMPLIFIED_NUMBER_BINOP_LIST(DECLARE_CASE)
SIMPLIFIED_BIGINT_BINOP_LIST(DECLARE_CASE)
SIMPLIFIED_SPECULATIVE_NUMBER_BINOP_LIST(DECLARE_CASE)
SIMPLIFIED_SPECULATIVE_BIGINT_BINOP_LIST(DECLARE_CASE)
#undef DECLARE_CASE
......@@ -291,6 +293,7 @@ class Typer::Visitor : public Reducer {
return t->operation_typer_.Name(lhs, rhs); \
}
SIMPLIFIED_NUMBER_BINOP_LIST(DECLARE_METHOD)
SIMPLIFIED_BIGINT_BINOP_LIST(DECLARE_METHOD)
SIMPLIFIED_SPECULATIVE_NUMBER_BINOP_LIST(DECLARE_METHOD)
SIMPLIFIED_SPECULATIVE_BIGINT_BINOP_LIST(DECLARE_METHOD)
#undef DECLARE_METHOD
......
......@@ -986,6 +986,15 @@ void Verifier::Visitor::Check(Node* node, const AllNodes& all) {
CheckValueInputIs(node, 0, Type::BigInt());
CheckTypeIs(node, Type::BigInt());
break;
case IrOpcode::kBigIntAdd:
CheckValueInputIs(node, 0, Type::BigInt());
CheckValueInputIs(node, 1, Type::BigInt());
CheckTypeIs(node, Type::BigInt());
break;
case IrOpcode::kBigIntNegate:
CheckValueInputIs(node, 0, Type::BigInt());
CheckTypeIs(node, Type::BigInt());
break;
case IrOpcode::kNumberAdd:
case IrOpcode::kNumberSubtract:
case IrOpcode::kNumberMultiply:
......
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