Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(283)

Unified Diff: src/compiler/representation-change.cc

Issue 2277283002: Reland of [turbofan] Insert dummy values when changing from None type. (Closed)
Patch Set: Workaround for uninhabited representations. Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/compiler/ppc/code-generator-ppc.cc ('k') | src/compiler/s390/code-generator-s390.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/representation-change.cc
diff --git a/src/compiler/representation-change.cc b/src/compiler/representation-change.cc
index 5427bdb1cd83bcd8589cfaf860df8004e6c498f7..88508e0516da60db1171ffb7a858d4e22390f8bb 100644
--- a/src/compiler/representation-change.cc
+++ b/src/compiler/representation-change.cc
@@ -204,10 +204,10 @@ Node* RepresentationChanger::GetTaggedRepresentationFor(
}
// Select the correct X -> Tagged operator.
const Operator* op;
- if (output_rep == MachineRepresentation::kNone) {
- // We should only asisgn this representation if the type is empty.
- CHECK(!output_type->IsInhabited());
- op = machine()->ImpossibleToTagged();
+ if (output_type->Is(Type::None())) {
+ // This is an impossible value; it should not be used at runtime.
+ // We just provide a dummy value here.
+ return jsgraph()->TheHoleConstant();
} else if (output_rep == MachineRepresentation::kBit) {
if (output_type->Is(Type::Boolean())) {
op = simplified()->ChangeBitToTagged();
@@ -283,10 +283,10 @@ Node* RepresentationChanger::GetFloat32RepresentationFor(
}
// Select the correct X -> Float32 operator.
const Operator* op = nullptr;
- if (output_rep == MachineRepresentation::kNone) {
- // We should only use kNone representation if the type is empty.
- CHECK(!output_type->IsInhabited());
- op = machine()->ImpossibleToFloat32();
+ if (output_type->Is(Type::None())) {
+ // This is an impossible value; it should not be used at runtime.
+ // We just provide a dummy value here.
+ return jsgraph()->Float32Constant(0.0f);
} else if (IsWord(output_rep)) {
if (output_type->Is(Type::Signed32())) {
// int32 -> float64 -> float32
@@ -352,10 +352,10 @@ Node* RepresentationChanger::GetFloat64RepresentationFor(
}
// Select the correct X -> Float64 operator.
const Operator* op = nullptr;
- if (output_rep == MachineRepresentation::kNone) {
- // We should only use kNone representation if the type is empty.
- CHECK(!output_type->IsInhabited());
- op = machine()->ImpossibleToFloat64();
+ if (output_type->Is(Type::None())) {
+ // This is an impossible value; it should not be used at runtime.
+ // We just provide a dummy value here.
+ return jsgraph()->Float64Constant(0.0);
} else if (IsWord(output_rep)) {
if (output_type->Is(Type::Signed32())) {
op = machine()->ChangeInt32ToFloat64();
@@ -435,10 +435,10 @@ Node* RepresentationChanger::GetWord32RepresentationFor(
// Select the correct X -> Word32 operator.
const Operator* op = nullptr;
- if (output_rep == MachineRepresentation::kNone) {
- // We should only use kNone representation if the type is empty.
- CHECK(!output_type->IsInhabited());
- op = machine()->ImpossibleToWord32();
+ if (output_type->Is(Type::None())) {
+ // This is an impossible value; it should not be used at runtime.
+ // We just provide a dummy value here.
+ return jsgraph()->Int32Constant(0);
} else if (output_rep == MachineRepresentation::kBit) {
return node; // Sloppy comparison -> word32
} else if (output_rep == MachineRepresentation::kFloat64) {
@@ -551,10 +551,10 @@ Node* RepresentationChanger::GetBitRepresentationFor(
}
// Select the correct X -> Bit operator.
const Operator* op;
- if (output_rep == MachineRepresentation::kNone) {
- // We should only use kNone representation if the type is empty.
- CHECK(!output_type->IsInhabited());
- op = machine()->ImpossibleToBit();
+ if (output_type->Is(Type::None())) {
+ // This is an impossible value; it should not be used at runtime.
+ // We just provide a dummy value here.
+ return jsgraph()->Int32Constant(0);
} else if (output_rep == MachineRepresentation::kTagged) {
op = simplified()->ChangeTaggedToBit();
} else {
@@ -566,10 +566,10 @@ Node* RepresentationChanger::GetBitRepresentationFor(
Node* RepresentationChanger::GetWord64RepresentationFor(
Node* node, MachineRepresentation output_rep, Type* output_type) {
- if (output_rep == MachineRepresentation::kNone) {
- // We should only use kNone representation if the type is empty.
- CHECK(!output_type->IsInhabited());
- return jsgraph()->graph()->NewNode(machine()->ImpossibleToFloat64(), node);
+ if (output_type->Is(Type::None())) {
+ // This is an impossible value; it should not be used at runtime.
+ // We just provide a dummy value here.
+ return jsgraph()->Int64Constant(0);
} else if (output_rep == MachineRepresentation::kBit) {
return node; // Sloppy comparison -> word64
}
« no previous file with comments | « src/compiler/ppc/code-generator-ppc.cc ('k') | src/compiler/s390/code-generator-s390.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698