From 83e14103203f581b9b741d2b0612374e88855625 Mon Sep 17 00:00:00 2001 From: bmeurer Date: Wed, 31 Aug 2016 23:26:41 -0700 Subject: [PATCH] [turbofan] Float32Constant/Float64Constant cannot occur in JS level graph. Now that the hole NaN is no longer represented as Float64Constant early on, we should never see such a constant node in any JS-level graph, but we will only see them after representation selection. Change Typer and SimplifiedLowering appropriately (and fix the invalid tests). R=jarin@chromium.org BUG=v8:5267 Review-Url: https://codereview.chromium.org/2299883003 Cr-Commit-Position: refs/heads/master@{#39063} --- src/compiler/simplified-lowering.cc | 2 - src/compiler/typer.cc | 8 +- .../cctest/compiler/test-js-constant-cache.cc | 79 ------------------- .../cctest/compiler/test-js-typed-lowering.cc | 7 +- .../effect-control-linearizer-unittest.cc | 4 +- 5 files changed, 9 insertions(+), 91 deletions(-) diff --git a/src/compiler/simplified-lowering.cc b/src/compiler/simplified-lowering.cc index 463bf030cd..c7956b7bd2 100644 --- a/src/compiler/simplified-lowering.cc +++ b/src/compiler/simplified-lowering.cc @@ -1317,8 +1317,6 @@ class RepresentationSelector { return VisitLeaf(node, MachineRepresentation::kWord32); case IrOpcode::kInt64Constant: return VisitLeaf(node, MachineRepresentation::kWord64); - case IrOpcode::kFloat64Constant: - return VisitLeaf(node, MachineRepresentation::kFloat64); case IrOpcode::kExternalConstant: return VisitLeaf(node, MachineType::PointerRepresentation()); case IrOpcode::kNumberConstant: diff --git a/src/compiler/typer.cc b/src/compiler/typer.cc index 89a74ada89..4f97772c8b 100644 --- a/src/compiler/typer.cc +++ b/src/compiler/typer.cc @@ -580,14 +580,14 @@ Type* Typer::Visitor::TypeRelocatableInt64Constant(Node* node) { } Type* Typer::Visitor::TypeFloat32Constant(Node* node) { - return Type::Intersect(Type::Of(OpParameter(node), zone()), - Type::UntaggedFloat32(), zone()); + UNREACHABLE(); + return nullptr; } Type* Typer::Visitor::TypeFloat64Constant(Node* node) { - return Type::Intersect(Type::Of(OpParameter(node), zone()), - Type::UntaggedFloat64(), zone()); + UNREACHABLE(); + return nullptr; } diff --git a/test/cctest/compiler/test-js-constant-cache.cc b/test/cctest/compiler/test-js-constant-cache.cc index 06169f3ba6..3b8f3f982b 100644 --- a/test/cctest/compiler/test-js-constant-cache.cc +++ b/test/cctest/compiler/test-js-constant-cache.cc @@ -5,8 +5,6 @@ #include "src/assembler.h" #include "src/compiler/js-graph.h" #include "src/compiler/node-properties.h" -#include "src/compiler/typer.h" -#include "src/types.h" #include "test/cctest/cctest.h" #include "test/cctest/compiler/value-helper.h" @@ -20,12 +18,10 @@ class JSCacheTesterHelper { : main_graph_(zone), main_common_(zone), main_javascript_(zone), - main_typer_(isolate, &main_graph_), main_machine_(zone) {} Graph main_graph_; CommonOperatorBuilder main_common_; JSOperatorBuilder main_javascript_; - Typer main_typer_; MachineOperatorBuilder main_machine_; }; @@ -42,11 +38,8 @@ class JSConstantCacheTester : public HandleAndZoneScope, main_graph_.SetStart(main_graph_.NewNode(common()->Start(0))); main_graph_.SetEnd( main_graph_.NewNode(common()->End(1), main_graph_.start())); - main_typer_.Run(); } - Type* TypeOf(Node* node) { return NodeProperties::GetType(node); } - Handle handle(Node* node) { CHECK_EQ(IrOpcode::kHeapConstant, node->opcode()); return OpParameter>(node); @@ -68,15 +61,6 @@ TEST(ZeroConstant1) { CHECK_NE(zero, T.Constant(std::numeric_limits::quiet_NaN())); CHECK_NE(zero, T.Float64Constant(0)); CHECK_NE(zero, T.Int32Constant(0)); - - Type* t = T.TypeOf(zero); - - CHECK(t->Is(Type::Number())); - CHECK(t->Is(Type::Integral32())); - CHECK(t->Is(Type::Signed32())); - CHECK(t->Is(Type::Unsigned32())); - CHECK(t->Is(Type::SignedSmall())); - CHECK(t->Is(Type::UnsignedSmall())); } @@ -90,16 +74,6 @@ TEST(MinusZeroConstant) { CHECK_EQ(minus_zero, T.Constant(-0.0)); CHECK_NE(zero, minus_zero); - Type* t = T.TypeOf(minus_zero); - - CHECK(t->Is(Type::Number())); - CHECK(t->Is(Type::MinusZero())); - CHECK(!t->Is(Type::Integral32())); - CHECK(!t->Is(Type::Signed32())); - CHECK(!t->Is(Type::Unsigned32())); - CHECK(!t->Is(Type::SignedSmall())); - CHECK(!t->Is(Type::UnsignedSmall())); - double zero_value = OpParameter(zero); double minus_zero_value = OpParameter(minus_zero); @@ -122,15 +96,6 @@ TEST(ZeroConstant2) { CHECK_NE(zero, T.Constant(std::numeric_limits::quiet_NaN())); CHECK_NE(zero, T.Float64Constant(0)); CHECK_NE(zero, T.Int32Constant(0)); - - Type* t = T.TypeOf(zero); - - CHECK(t->Is(Type::Number())); - CHECK(t->Is(Type::Integral32())); - CHECK(t->Is(Type::Signed32())); - CHECK(t->Is(Type::Unsigned32())); - CHECK(t->Is(Type::SignedSmall())); - CHECK(t->Is(Type::UnsignedSmall())); } @@ -147,15 +112,6 @@ TEST(OneConstant1) { CHECK_NE(one, T.Constant(std::numeric_limits::quiet_NaN())); CHECK_NE(one, T.Float64Constant(1.0)); CHECK_NE(one, T.Int32Constant(1)); - - Type* t = T.TypeOf(one); - - CHECK(t->Is(Type::Number())); - CHECK(t->Is(Type::Integral32())); - CHECK(t->Is(Type::Signed32())); - CHECK(t->Is(Type::Unsigned32())); - CHECK(t->Is(Type::SignedSmall())); - CHECK(t->Is(Type::UnsignedSmall())); } @@ -172,15 +128,6 @@ TEST(OneConstant2) { CHECK_NE(one, T.Constant(std::numeric_limits::quiet_NaN())); CHECK_NE(one, T.Float64Constant(1.0)); CHECK_NE(one, T.Int32Constant(1)); - - Type* t = T.TypeOf(one); - - CHECK(t->Is(Type::Number())); - CHECK(t->Is(Type::Integral32())); - CHECK(t->Is(Type::Signed32())); - CHECK(t->Is(Type::Unsigned32())); - CHECK(t->Is(Type::SignedSmall())); - CHECK(t->Is(Type::UnsignedSmall())); } @@ -227,17 +174,6 @@ TEST(CanonicalizingNumbers) { } -TEST(NumberTypes) { - JSConstantCacheTester T; - - FOR_FLOAT64_INPUTS(i) { - double value = *i; - Node* node = T.Constant(value); - CHECK(T.TypeOf(node)->Is(Type::Of(value, T.main_zone()))); - } -} - - TEST(HeapNumbers) { JSConstantCacheTester T; @@ -277,21 +213,6 @@ TEST(OddballValues) { } -TEST(OddballTypes) { - JSConstantCacheTester T; - - CHECK(T.TypeOf(T.UndefinedConstant())->Is(Type::Undefined())); - // TODO(dcarney): figure this out. - // CHECK(T.TypeOf(T.TheHoleConstant())->Is(Type::Internal())); - CHECK(T.TypeOf(T.TrueConstant())->Is(Type::Boolean())); - CHECK(T.TypeOf(T.FalseConstant())->Is(Type::Boolean())); - CHECK(T.TypeOf(T.NullConstant())->Is(Type::Null())); - CHECK(T.TypeOf(T.ZeroConstant())->Is(Type::Number())); - CHECK(T.TypeOf(T.OneConstant())->Is(Type::Number())); - CHECK(T.TypeOf(T.NaNConstant())->Is(Type::NaN())); -} - - TEST(ExternalReferences) { // TODO(titzer): test canonicalization of external references. } diff --git a/test/cctest/compiler/test-js-typed-lowering.cc b/test/cctest/compiler/test-js-typed-lowering.cc index 88cd6c663c..aa124d34ef 100644 --- a/test/cctest/compiler/test-js-typed-lowering.cc +++ b/test/cctest/compiler/test-js-typed-lowering.cc @@ -463,10 +463,9 @@ TEST(JSToNumber_replacement) { TEST(JSToNumberOfConstant) { JSTypedLoweringTester R; - const Operator* ops[] = { - R.common.NumberConstant(0), R.common.NumberConstant(-1), - R.common.NumberConstant(0.1), R.common.Int32Constant(1177), - R.common.Float64Constant(0.99)}; + const Operator* ops[] = {R.common.NumberConstant(0), + R.common.NumberConstant(-1), + R.common.NumberConstant(0.1)}; for (size_t i = 0; i < arraysize(ops); i++) { Node* n = R.graph.NewNode(ops[i]); diff --git a/test/unittests/compiler/effect-control-linearizer-unittest.cc b/test/unittests/compiler/effect-control-linearizer-unittest.cc index 71a8696d09..0a12ea371a 100644 --- a/test/unittests/compiler/effect-control-linearizer-unittest.cc +++ b/test/unittests/compiler/effect-control-linearizer-unittest.cc @@ -21,10 +21,10 @@ namespace compiler { using testing::Capture; -class EffectControlLinearizerTest : public TypedGraphTest { +class EffectControlLinearizerTest : public GraphTest { public: EffectControlLinearizerTest() - : TypedGraphTest(3), + : GraphTest(3), machine_(zone()), javascript_(zone()), simplified_(zone()),