[turbofan] Rename Float64 truncation to OddballAndBigIntToNumber.
Truncation::Float64 is confusing; in reality, we mean that oddballs and big-ints are identified with their ToNumber counterparts. Bug: v8:9183 Change-Id: Ibcce990327ac7e01e36a2237ad39c374ac9922aa Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1632224 Commit-Queue: Jaroslav Sevcik <jarin@chromium.org> Reviewed-by: Tobias Tebbi <tebbi@chromium.org> Cr-Commit-Position: refs/heads/master@{#61937}
This commit is contained in:
parent
088eda6235
commit
8839d8f6e3
@ -25,12 +25,12 @@ const char* Truncation::description() const {
|
||||
return "truncate-to-bool";
|
||||
case TruncationKind::kWord32:
|
||||
return "truncate-to-word32";
|
||||
case TruncationKind::kFloat64:
|
||||
case TruncationKind::kOddballAndBigIntToNumber:
|
||||
switch (identify_zeros()) {
|
||||
case kIdentifyZeros:
|
||||
return "truncate-to-float64 (identify zeros)";
|
||||
return "truncate-oddball&bigint-to-number (identify zeros)";
|
||||
case kDistinguishZeros:
|
||||
return "truncate-to-float64 (distinguish zeros)";
|
||||
return "truncate-oddball&bigint-to-number (distinguish zeros)";
|
||||
}
|
||||
case TruncationKind::kAny:
|
||||
switch (identify_zeros()) {
|
||||
@ -45,22 +45,22 @@ const char* Truncation::description() const {
|
||||
|
||||
// Partial order for truncations:
|
||||
//
|
||||
// kAny <-------+
|
||||
// ^ |
|
||||
// | |
|
||||
// kFloat64 |
|
||||
// ^ |
|
||||
// / |
|
||||
// kWord32 kBool
|
||||
// ^ ^
|
||||
// \ /
|
||||
// \ /
|
||||
// \ /
|
||||
// \ /
|
||||
// \ /
|
||||
// kNone
|
||||
// kAny <-------+
|
||||
// ^ |
|
||||
// | |
|
||||
// kOddballAndBigIntToNumber |
|
||||
// ^ |
|
||||
// / |
|
||||
// kWord32 kBool
|
||||
// ^ ^
|
||||
// \ /
|
||||
// \ /
|
||||
// \ /
|
||||
// \ /
|
||||
// \ /
|
||||
// kNone
|
||||
//
|
||||
// TODO(jarin) We might consider making kBool < kFloat64.
|
||||
// TODO(jarin) We might consider making kBool < kOddballAndBigIntToNumber.
|
||||
|
||||
// static
|
||||
Truncation::TruncationKind Truncation::Generalize(TruncationKind rep1,
|
||||
@ -68,9 +68,9 @@ Truncation::TruncationKind Truncation::Generalize(TruncationKind rep1,
|
||||
if (LessGeneral(rep1, rep2)) return rep2;
|
||||
if (LessGeneral(rep2, rep1)) return rep1;
|
||||
// Handle the generalization of float64-representable values.
|
||||
if (LessGeneral(rep1, TruncationKind::kFloat64) &&
|
||||
LessGeneral(rep2, TruncationKind::kFloat64)) {
|
||||
return TruncationKind::kFloat64;
|
||||
if (LessGeneral(rep1, TruncationKind::kOddballAndBigIntToNumber) &&
|
||||
LessGeneral(rep2, TruncationKind::kOddballAndBigIntToNumber)) {
|
||||
return TruncationKind::kOddballAndBigIntToNumber;
|
||||
}
|
||||
// Handle the generalization of any-representable values.
|
||||
if (LessGeneral(rep1, TruncationKind::kAny) &&
|
||||
@ -101,9 +101,11 @@ bool Truncation::LessGeneral(TruncationKind rep1, TruncationKind rep2) {
|
||||
return rep2 == TruncationKind::kBool || rep2 == TruncationKind::kAny;
|
||||
case TruncationKind::kWord32:
|
||||
return rep2 == TruncationKind::kWord32 ||
|
||||
rep2 == TruncationKind::kFloat64 || rep2 == TruncationKind::kAny;
|
||||
case TruncationKind::kFloat64:
|
||||
return rep2 == TruncationKind::kFloat64 || rep2 == TruncationKind::kAny;
|
||||
rep2 == TruncationKind::kOddballAndBigIntToNumber ||
|
||||
rep2 == TruncationKind::kAny;
|
||||
case TruncationKind::kOddballAndBigIntToNumber:
|
||||
return rep2 == TruncationKind::kOddballAndBigIntToNumber ||
|
||||
rep2 == TruncationKind::kAny;
|
||||
case TruncationKind::kAny:
|
||||
return rep2 == TruncationKind::kAny;
|
||||
}
|
||||
@ -560,7 +562,7 @@ Node* RepresentationChanger::GetTaggedRepresentationFor(
|
||||
op = simplified()->ChangeUint32ToTagged();
|
||||
} else if (output_type.Is(Type::Number()) ||
|
||||
(output_type.Is(Type::NumberOrOddball()) &&
|
||||
truncation.IsUsedAsFloat64())) {
|
||||
truncation.TruncatesOddballAndBigIntToNumber())) {
|
||||
op = simplified()->ChangeFloat64ToTagged(
|
||||
output_type.Maybe(Type::MinusZero())
|
||||
? CheckForMinusZeroMode::kCheckForMinusZero
|
||||
@ -843,9 +845,7 @@ Node* RepresentationChanger::GetFloat64RepresentationFor(
|
||||
}
|
||||
} else if (output_rep == MachineRepresentation::kBit) {
|
||||
CHECK(output_type.Is(Type::Boolean()));
|
||||
// TODO(tebbi): TypeCheckKind::kNumberOrOddball should imply Float64
|
||||
// truncation, since this exactly means that we treat Oddballs as Numbers.
|
||||
if (use_info.truncation().IsUsedAsFloat64() ||
|
||||
if (use_info.truncation().TruncatesOddballAndBigIntToNumber() ||
|
||||
use_info.type_check() == TypeCheckKind::kNumberOrOddball) {
|
||||
op = machine()->ChangeUint32ToFloat64();
|
||||
} else {
|
||||
@ -867,7 +867,7 @@ Node* RepresentationChanger::GetFloat64RepresentationFor(
|
||||
} else if (output_type.Is(Type::Number())) {
|
||||
op = simplified()->ChangeTaggedToFloat64();
|
||||
} else if ((output_type.Is(Type::NumberOrOddball()) &&
|
||||
use_info.truncation().IsUsedAsFloat64()) ||
|
||||
use_info.truncation().TruncatesOddballAndBigIntToNumber()) ||
|
||||
output_type.Is(Type::NumberOrHole())) {
|
||||
// JavaScript 'null' is an Oddball that results in +0 when truncated to
|
||||
// Number. In a context like -0 == null, which must evaluate to false,
|
||||
|
@ -29,8 +29,10 @@ class Truncation final {
|
||||
static Truncation Word32() {
|
||||
return Truncation(TruncationKind::kWord32, kIdentifyZeros);
|
||||
}
|
||||
static Truncation Float64(IdentifyZeros identify_zeros = kDistinguishZeros) {
|
||||
return Truncation(TruncationKind::kFloat64, identify_zeros);
|
||||
static Truncation OddballAndBigIntToNumber(
|
||||
IdentifyZeros identify_zeros = kDistinguishZeros) {
|
||||
return Truncation(TruncationKind::kOddballAndBigIntToNumber,
|
||||
identify_zeros);
|
||||
}
|
||||
static Truncation Any(IdentifyZeros identify_zeros = kDistinguishZeros) {
|
||||
return Truncation(TruncationKind::kAny, identify_zeros);
|
||||
@ -50,8 +52,8 @@ class Truncation final {
|
||||
bool IsUsedAsWord32() const {
|
||||
return LessGeneral(kind_, TruncationKind::kWord32);
|
||||
}
|
||||
bool IsUsedAsFloat64() const {
|
||||
return LessGeneral(kind_, TruncationKind::kFloat64);
|
||||
bool TruncatesOddballAndBigIntToNumber() const {
|
||||
return LessGeneral(kind_, TruncationKind::kOddballAndBigIntToNumber);
|
||||
}
|
||||
bool IdentifiesUndefinedAndZero() {
|
||||
return LessGeneral(kind_, TruncationKind::kWord32) ||
|
||||
@ -81,13 +83,14 @@ class Truncation final {
|
||||
kNone,
|
||||
kBool,
|
||||
kWord32,
|
||||
kFloat64,
|
||||
kOddballAndBigIntToNumber,
|
||||
kAny
|
||||
};
|
||||
|
||||
explicit Truncation(TruncationKind kind, IdentifyZeros identify_zeros)
|
||||
: kind_(kind), identify_zeros_(identify_zeros) {
|
||||
DCHECK(kind == TruncationKind::kAny || kind == TruncationKind::kFloat64 ||
|
||||
DCHECK(kind == TruncationKind::kAny ||
|
||||
kind == TruncationKind::kOddballAndBigIntToNumber ||
|
||||
identify_zeros == kIdentifyZeros);
|
||||
}
|
||||
TruncationKind kind() const { return kind_; }
|
||||
@ -175,7 +178,7 @@ class UseInfo {
|
||||
static UseInfo TruncatingFloat64(
|
||||
IdentifyZeros identify_zeros = kDistinguishZeros) {
|
||||
return UseInfo(MachineRepresentation::kFloat64,
|
||||
Truncation::Float64(identify_zeros));
|
||||
Truncation::OddballAndBigIntToNumber(identify_zeros));
|
||||
}
|
||||
static UseInfo AnyTagged() {
|
||||
return UseInfo(MachineRepresentation::kTagged, Truncation::Any());
|
||||
@ -240,8 +243,6 @@ class UseInfo {
|
||||
}
|
||||
static UseInfo CheckedNumberOrOddballAsFloat64(
|
||||
IdentifyZeros identify_zeros, const VectorSlotPair& feedback) {
|
||||
// TODO(tebbi): We should use Float64 truncation here, since this exactly
|
||||
// means that we treat Oddballs as Numbers.
|
||||
return UseInfo(MachineRepresentation::kFloat64,
|
||||
Truncation::Any(identify_zeros),
|
||||
TypeCheckKind::kNumberOrOddball, feedback);
|
||||
|
@ -958,7 +958,8 @@ class RepresentationSelector {
|
||||
return MachineRepresentation::kWord32;
|
||||
} else if (type.Is(Type::Boolean())) {
|
||||
return MachineRepresentation::kBit;
|
||||
} else if (type.Is(Type::NumberOrOddball()) && use.IsUsedAsFloat64()) {
|
||||
} else if (type.Is(Type::NumberOrOddball()) &&
|
||||
use.TruncatesOddballAndBigIntToNumber()) {
|
||||
return MachineRepresentation::kFloat64;
|
||||
} else if (type.Is(Type::Union(Type::SignedSmall(), Type::NaN(), zone()))) {
|
||||
// TODO(turbofan): For Phis that return either NaN or some Smi, it's
|
||||
@ -1715,13 +1716,15 @@ class RepresentationSelector {
|
||||
case IrOpcode::kJSToNumber:
|
||||
case IrOpcode::kJSToNumberConvertBigInt:
|
||||
case IrOpcode::kJSToNumeric: {
|
||||
DCHECK(NodeProperties::GetType(node).Is(Type::Union(
|
||||
Type::BigInt(), Type::NumberOrOddball(), graph()->zone())));
|
||||
VisitInputs(node);
|
||||
// TODO(bmeurer): Optimize somewhat based on input type?
|
||||
if (truncation.IsUsedAsWord32()) {
|
||||
SetOutput(node, MachineRepresentation::kWord32);
|
||||
if (lower())
|
||||
lowering->DoJSToNumberOrNumericTruncatesToWord32(node, this);
|
||||
} else if (truncation.IsUsedAsFloat64()) {
|
||||
} else if (truncation.TruncatesOddballAndBigIntToNumber()) {
|
||||
SetOutput(node, MachineRepresentation::kFloat64);
|
||||
if (lower())
|
||||
lowering->DoJSToNumberOrNumericTruncatesToFloat64(node, this);
|
||||
@ -2983,7 +2986,7 @@ class RepresentationSelector {
|
||||
simplified()->PlainPrimitiveToWord32());
|
||||
}
|
||||
}
|
||||
} else if (truncation.IsUsedAsFloat64()) {
|
||||
} else if (truncation.TruncatesOddballAndBigIntToNumber()) {
|
||||
if (InputIs(node, Type::NumberOrOddball())) {
|
||||
VisitUnop(node, UseInfo::TruncatingFloat64(),
|
||||
MachineRepresentation::kFloat64);
|
||||
@ -3236,7 +3239,7 @@ class RepresentationSelector {
|
||||
// identifies NaN and undefined, we can just pass along
|
||||
// the {truncation} and completely wipe the {node}.
|
||||
if (truncation.IsUnused()) return VisitUnused(node);
|
||||
if (truncation.IsUsedAsFloat64()) {
|
||||
if (truncation.TruncatesOddballAndBigIntToNumber()) {
|
||||
VisitUnop(node, UseInfo::TruncatingFloat64(),
|
||||
MachineRepresentation::kFloat64);
|
||||
if (lower()) DeferReplacement(node, node->InputAt(0));
|
||||
@ -3263,7 +3266,7 @@ class RepresentationSelector {
|
||||
MachineRepresentation::kWord32);
|
||||
if (lower()) DeferReplacement(node, node->InputAt(0));
|
||||
} else if (InputIs(node, Type::NumberOrOddball()) &&
|
||||
truncation.IsUsedAsFloat64()) {
|
||||
truncation.TruncatesOddballAndBigIntToNumber()) {
|
||||
// Propagate the Float64 truncation.
|
||||
VisitUnop(node, UseInfo::TruncatingFloat64(),
|
||||
MachineRepresentation::kFloat64);
|
||||
|
@ -544,7 +544,8 @@ TEST(SingleChanges) {
|
||||
Type::Number(), MachineRepresentation::kFloat64);
|
||||
CheckChange(IrOpcode::kTruncateTaggedToFloat64,
|
||||
MachineRepresentation::kTagged, Type::NumberOrUndefined(),
|
||||
UseInfo(MachineRepresentation::kFloat64, Truncation::Float64()));
|
||||
UseInfo(MachineRepresentation::kFloat64,
|
||||
Truncation::OddballAndBigIntToNumber()));
|
||||
CheckChange(IrOpcode::kChangeTaggedToFloat64, MachineRepresentation::kTagged,
|
||||
Type::Signed31(), MachineRepresentation::kFloat64);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user