[turbofan] Relax effects and context for JSToNumber(x:plain-primitive).
authorBenedikt Meurer <bmeurer@chromium.org>
Mon, 15 Dec 2014 13:42:37 +0000 (14:42 +0100)
committerBenedikt Meurer <bmeurer@chromium.org>
Mon, 15 Dec 2014 13:42:54 +0000 (13:42 +0000)
TEST=unittests
R=svenpanne@chromium.org

Review URL: https://codereview.chromium.org/799413002

Cr-Commit-Position: refs/heads/master@{#25818}

src/compiler/js-typed-lowering.cc
test/unittests/compiler/js-typed-lowering-unittest.cc

index 9094a66..20f33ee 100644 (file)
@@ -18,7 +18,6 @@ namespace compiler {
 // TODO(turbofan): js-typed-lowering improvements possible
 // - immediately put in type bounds for all new nodes
 // - relax effects from generic but not-side-effecting operations
-// - relax effects for ToNumber(mixed)
 
 
 // Relax the effects of {node} by immediately replacing effect uses of {node}
@@ -731,6 +730,9 @@ Reduction JSTypedLowering::ReduceJSToNumber(Node* node) {
         node->ReplaceInput(i, value);
       }
       node->TrimInputCount(input_count);
+    } else {
+      // JSToNumber(x:plain-primitive,context) => JSToNumber(x,no-context)
+      node->ReplaceInput(1, jsgraph()->NoContextConstant());
     }
     return Changed(node);
   }
index 2c03d88..d0c465f 100644 (file)
@@ -197,6 +197,23 @@ TEST_F(JSTypedLoweringTest, JSToBooleanWithSelect) {
 
 
 // -----------------------------------------------------------------------------
+// JSToNumber
+
+
+TEST_F(JSTypedLoweringTest, JSToNumberWithPlainPrimitive) {
+  Node* const input = Parameter(Type::PlainPrimitive(), 0);
+  Node* const context = Parameter(Type::Any(), 1);
+  Node* const effect = graph()->start();
+  Node* const control = graph()->start();
+  Reduction r = Reduce(graph()->NewNode(javascript()->ToNumber(), input,
+                                        context, effect, control));
+  ASSERT_TRUE(r.Changed());
+  EXPECT_THAT(r.replacement(), IsToNumber(input, IsNumberConstant(0),
+                                          graph()->start(), control));
+}
+
+
+// -----------------------------------------------------------------------------
 // JSStrictEqual