summaryrefslogtreecommitdiff
path: root/chromium/v8/src/compiler/representation-change.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/v8/src/compiler/representation-change.cc')
-rw-r--r--chromium/v8/src/compiler/representation-change.cc68
1 files changed, 57 insertions, 11 deletions
diff --git a/chromium/v8/src/compiler/representation-change.cc b/chromium/v8/src/compiler/representation-change.cc
index 7077f7d643f..5967d1005e5 100644
--- a/chromium/v8/src/compiler/representation-change.cc
+++ b/chromium/v8/src/compiler/representation-change.cc
@@ -11,6 +11,7 @@
#include "src/compiler/js-heap-broker.h"
#include "src/compiler/machine-operator.h"
#include "src/compiler/node-matchers.h"
+#include "src/compiler/simplified-operator.h"
#include "src/compiler/type-cache.h"
#include "src/heap/factory-inl.h"
@@ -210,6 +211,7 @@ Node* RepresentationChanger::GetRepresentationFor(
return GetFloat32RepresentationFor(node, output_rep, output_type,
use_info.truncation());
case MachineRepresentation::kFloat64:
+ DCHECK_NE(TypeCheckKind::kBigInt, use_info.type_check());
return GetFloat64RepresentationFor(node, output_rep, output_type,
use_node, use_info);
case MachineRepresentation::kBit:
@@ -402,7 +404,22 @@ Node* RepresentationChanger::GetTaggedPointerRepresentationFor(
return jsgraph()->graph()->NewNode(
jsgraph()->common()->DeadValue(MachineRepresentation::kTaggedPointer),
node);
- } else if (output_rep == MachineRepresentation::kBit) {
+ }
+
+ if (use_info.type_check() == TypeCheckKind::kBigInt &&
+ !output_type.Is(Type::BigInt())) {
+ // BigInt checks can only be performed on tagged representations. Note that
+ // a corresponding check is inserted down below.
+ if (!CanBeTaggedPointer(output_rep)) {
+ Node* unreachable =
+ InsertUnconditionalDeopt(use_node, DeoptimizeReason::kNotABigInt);
+ return jsgraph()->graph()->NewNode(
+ jsgraph()->common()->DeadValue(MachineRepresentation::kTaggedPointer),
+ unreachable);
+ }
+ }
+
+ if (output_rep == MachineRepresentation::kBit) {
if (output_type.Is(Type::Boolean())) {
op = simplified()->ChangeBitToTagged();
} else {
@@ -427,7 +444,8 @@ Node* RepresentationChanger::GetTaggedPointerRepresentationFor(
op = machine()->ChangeInt64ToFloat64();
node = jsgraph()->graph()->NewNode(op, node);
op = simplified()->ChangeFloat64ToTaggedPointer();
- } else if (output_type.Is(Type::BigInt())) {
+ } else if (output_type.Is(Type::BigInt()) &&
+ use_info.type_check() == TypeCheckKind::kBigInt) {
op = simplified()->ChangeUint64ToBigInt();
} else {
return TypeError(node, output_rep, output_type,
@@ -662,6 +680,7 @@ Node* RepresentationChanger::GetFloat64RepresentationFor(
switch (use_info.type_check()) {
case TypeCheckKind::kNone:
case TypeCheckKind::kNumber:
+ case TypeCheckKind::kNumberOrBoolean:
case TypeCheckKind::kNumberOrOddball:
return jsgraph()->Float64Constant(m.Value());
case TypeCheckKind::kBigInt:
@@ -695,6 +714,7 @@ Node* RepresentationChanger::GetFloat64RepresentationFor(
} else if (output_rep == MachineRepresentation::kBit) {
CHECK(output_type.Is(Type::Boolean()));
if (use_info.truncation().TruncatesOddballAndBigIntToNumber() ||
+ use_info.type_check() == TypeCheckKind::kNumberOrBoolean ||
use_info.type_check() == TypeCheckKind::kNumberOrOddball) {
op = machine()->ChangeUint32ToFloat64();
} else {
@@ -707,9 +727,16 @@ Node* RepresentationChanger::GetFloat64RepresentationFor(
}
} else if (IsAnyTagged(output_rep)) {
if (output_type.Is(Type::Undefined())) {
- return jsgraph()->Float64Constant(
- std::numeric_limits<double>::quiet_NaN());
-
+ if (use_info.type_check() == TypeCheckKind::kNumberOrBoolean) {
+ Node* unreachable = InsertUnconditionalDeopt(
+ use_node, DeoptimizeReason::kNotANumberOrBoolean);
+ return jsgraph()->graph()->NewNode(
+ jsgraph()->common()->DeadValue(MachineRepresentation::kFloat64),
+ unreachable);
+ } else {
+ return jsgraph()->Float64Constant(
+ std::numeric_limits<double>::quiet_NaN());
+ }
} else if (output_rep == MachineRepresentation::kTaggedSigned) {
node = InsertChangeTaggedSignedToInt32(node);
op = machine()->ChangeInt32ToFloat64();
@@ -732,6 +759,9 @@ Node* RepresentationChanger::GetFloat64RepresentationFor(
!output_type.Maybe(Type::BooleanOrNullOrNumber()))) {
op = simplified()->CheckedTaggedToFloat64(CheckTaggedInputMode::kNumber,
use_info.feedback());
+ } else if (use_info.type_check() == TypeCheckKind::kNumberOrBoolean) {
+ op = simplified()->CheckedTaggedToFloat64(
+ CheckTaggedInputMode::kNumberOrBoolean, use_info.feedback());
} else if (use_info.type_check() == TypeCheckKind::kNumberOrOddball) {
op = simplified()->CheckedTaggedToFloat64(
CheckTaggedInputMode::kNumberOrOddball, use_info.feedback());
@@ -1045,12 +1075,14 @@ Node* RepresentationChanger::GetWord64RepresentationFor(
case IrOpcode::kFloat64Constant:
UNREACHABLE();
case IrOpcode::kNumberConstant: {
- double const fv = OpParameter<double>(node->op());
- using limits = std::numeric_limits<int64_t>;
- if (fv <= limits::max() && fv >= limits::min()) {
- int64_t const iv = static_cast<int64_t>(fv);
- if (static_cast<double>(iv) == fv) {
- return jsgraph()->Int64Constant(iv);
+ if (use_info.type_check() != TypeCheckKind::kBigInt) {
+ double const fv = OpParameter<double>(node->op());
+ using limits = std::numeric_limits<int64_t>;
+ if (fv <= limits::max() && fv >= limits::min()) {
+ int64_t const iv = static_cast<int64_t>(fv);
+ if (static_cast<double>(iv) == fv) {
+ return jsgraph()->Int64Constant(iv);
+ }
}
}
break;
@@ -1069,6 +1101,19 @@ Node* RepresentationChanger::GetWord64RepresentationFor(
break;
}
+ if (use_info.type_check() == TypeCheckKind::kBigInt) {
+ // BigInts are only represented as tagged pointer and word64.
+ if (!CanBeTaggedPointer(output_rep) &&
+ output_rep != MachineRepresentation::kWord64) {
+ DCHECK(!output_type.Is(Type::BigInt()));
+ Node* unreachable =
+ InsertUnconditionalDeopt(use_node, DeoptimizeReason::kNotABigInt);
+ return jsgraph()->graph()->NewNode(
+ jsgraph()->common()->DeadValue(MachineRepresentation::kWord64),
+ unreachable);
+ }
+ }
+
// Select the correct X -> Word64 operator.
const Operator* op;
if (output_type.Is(Type::None())) {
@@ -1079,6 +1124,7 @@ Node* RepresentationChanger::GetWord64RepresentationFor(
CHECK(output_type.Is(Type::Boolean()));
CHECK_NE(use_info.type_check(), TypeCheckKind::kNone);
CHECK_NE(use_info.type_check(), TypeCheckKind::kNumberOrOddball);
+ CHECK_NE(use_info.type_check(), TypeCheckKind::kBigInt);
Node* unreachable =
InsertUnconditionalDeopt(use_node, DeoptimizeReason::kNotASmi);
return jsgraph()->graph()->NewNode(