Revert of [turbofan] Use PlainPrimitiveToNumber whenever possible. (patchset #1 id...
authorbmeurer <bmeurer@chromium.org>
Thu, 15 Jan 2015 13:26:40 +0000 (05:26 -0800)
committerCommit bot <commit-bot@chromium.org>
Thu, 15 Jan 2015 13:26:55 +0000 (13:26 +0000)
Reason for revert:
Tanks performance of SQLite and towers.c.

Original issue's description:
> [turbofan] Use PlainPrimitiveToNumber whenever possible.
>
> TEST=cctest,unittests
> R=jarin@chromium.org
>
> Committed: https://crrev.com/1a5db24e6bf831e61e3f4aa0c252f77e48c3689c
> Cr-Commit-Position: refs/heads/master@{#26071}

TBR=jarin@chromium.org,dcarney@chromium.org
NOTREECHECKS=true
NOTRY=true

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

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

src/compiler/js-typed-lowering.cc
test/cctest/compiler/test-js-typed-lowering.cc
test/unittests/compiler/js-typed-lowering-unittest.cc
test/unittests/compiler/node-test-utils.cc
test/unittests/compiler/node-test-utils.h

index ba2c975..56ffc5f 100644 (file)
@@ -537,7 +537,7 @@ Reduction JSTypedLowering::ReduceJSToNumberInput(Node* input) {
     return Changed(input);  // JSToNumber(JSToNumber(x)) => JSToNumber(x)
   }
   // Check if we have a cached conversion.
-  Node* conversion = FindConversion<IrOpcode::kPlainPrimitiveToNumber>(input);
+  Node* conversion = FindConversion<IrOpcode::kJSToNumber>(input);
   if (conversion) return Replace(conversion);
   Type* input_type = NodeProperties::GetBounds(input).upper;
   if (input_type->Is(Type::Number())) {
@@ -571,19 +571,18 @@ Reduction JSTypedLowering::ReduceJSToNumber(Node* node) {
   }
   Type* const input_type = NodeProperties::GetBounds(input).upper;
   if (input_type->Is(Type::PlainPrimitive())) {
-    RelaxEffects(node);
     if (input->opcode() == IrOpcode::kPhi) {
       // JSToNumber(phi(x1,...,xn,control):plain-primitive,context)
-      //   => phi(PlainPrimitiveToNumber(x1),
+      //   => phi(JSToNumber(x1,no-context),
       //          ...,
-      //          PlainPrimitiveToNumber(xn),
-      //          control)
+      //          JSToNumber(xn,no-context),control)
       int const input_count = input->InputCount() - 1;
       Node* const control = input->InputAt(input_count);
       DCHECK_LE(0, input_count);
       DCHECK(NodeProperties::IsControl(control));
       DCHECK(NodeProperties::GetBounds(node).upper->Is(Type::Number()));
       DCHECK(!NodeProperties::GetBounds(input).upper->Is(Type::Number()));
+      RelaxEffects(node);
       node->set_op(common()->Phi(kMachAnyTagged, input_count));
       for (int i = 0; i < input_count; ++i) {
         // We must be very careful not to introduce cycles when pushing
@@ -609,12 +608,13 @@ Reduction JSTypedLowering::ReduceJSToNumber(Node* node) {
     }
     if (input->opcode() == IrOpcode::kSelect) {
       // JSToNumber(select(c,x1,x2):plain-primitive,context)
-      //   => select(c,PlainPrimitiveToNumber(x1),PlainPrimitiveToNumber(x2))
+      //   => select(c,JSToNumber(x1,no-context),JSToNumber(x2,no-context))
       int const input_count = input->InputCount();
       BranchHint const input_hint = SelectParametersOf(input->op()).hint();
       DCHECK_EQ(3, input_count);
       DCHECK(NodeProperties::GetBounds(node).upper->Is(Type::Number()));
       DCHECK(!NodeProperties::GetBounds(input).upper->Is(Type::Number()));
+      RelaxEffects(node);
       node->set_op(common()->Select(kMachAnyTagged, input_hint));
       node->ReplaceInput(0, input->InputAt(0));
       for (int i = 1; i < input_count; ++i) {
@@ -630,12 +630,24 @@ Reduction JSTypedLowering::ReduceJSToNumber(Node* node) {
       node->TrimInputCount(input_count);
       return Changed(node);
     }
-    // JSToNumber(x:plain-primitive,context) => PlainPrimitiveToNumber(x)
-    node->set_op(simplified()->PlainPrimitiveToNumber());
-    node->TrimInputCount(1);
     // Remember this conversion.
     InsertConversion(node);
-    return Changed(node);
+    if (NodeProperties::GetContextInput(node) !=
+            jsgraph()->NoContextConstant() ||
+        NodeProperties::GetEffectInput(node) != graph()->start() ||
+        NodeProperties::GetControlInput(node) != graph()->start()) {
+      // JSToNumber(x:plain-primitive,context,effect,control)
+      //   => JSToNumber(x,no-context,start,start)
+      RelaxEffects(node);
+      NodeProperties::ReplaceContextInput(node, jsgraph()->NoContextConstant());
+      NodeProperties::ReplaceControlInput(node, graph()->start());
+      NodeProperties::ReplaceEffectInput(node, graph()->start());
+      if (OperatorProperties::HasFrameStateInput(node->op())) {
+        NodeProperties::ReplaceFrameStateInput(node,
+                                               jsgraph()->EmptyFrameState());
+      }
+      return Changed(node);
+    }
   }
   return NoChange();
 }
@@ -940,8 +952,16 @@ Node* JSTypedLowering::ConvertToNumber(Node* input) {
   // Avoid inserting too many eager ToNumber() operations.
   Reduction const reduction = ReduceJSToNumberInput(input);
   if (reduction.Changed()) return reduction.replacement();
+  // TODO(jarin) Use PlainPrimitiveToNumber once we have it.
   Node* const conversion =
-      graph()->NewNode(simplified()->PlainPrimitiveToNumber(), input);
+      FLAG_turbo_deoptimization
+          ? graph()->NewNode(javascript()->ToNumber(), input,
+                             jsgraph()->NoContextConstant(),
+                             jsgraph()->EmptyFrameState(), graph()->start(),
+                             graph()->start())
+          : graph()->NewNode(javascript()->ToNumber(), input,
+                             jsgraph()->NoContextConstant(), graph()->start(),
+                             graph()->start());
   InsertConversion(conversion);
   return conversion;
 }
@@ -961,7 +981,7 @@ Node* JSTypedLowering::FindConversion(Node* input) {
 
 
 void JSTypedLowering::InsertConversion(Node* conversion) {
-  DCHECK(conversion->opcode() == IrOpcode::kPlainPrimitiveToNumber);
+  DCHECK(conversion->opcode() == IrOpcode::kJSToNumber);
   size_t const input_id = conversion->InputAt(0)->id();
   if (input_id >= conversions_.size()) {
     conversions_.resize(2 * input_id + 1);
index f51c2f2..e23ad0c 100644 (file)
@@ -488,7 +488,7 @@ TEST(JSToNumberOfNumberOrOtherPrimitive) {
   for (size_t i = 0; i < arraysize(others); i++) {
     Type* t = Type::Union(Type::Number(), others[i], R.main_zone());
     Node* r = R.ReduceUnop(R.javascript.ToNumber(), t);
-    CHECK_EQ(IrOpcode::kPlainPrimitiveToNumber, r->opcode());
+    CHECK_EQ(IrOpcode::kJSToNumber, r->opcode());
   }
 }
 
@@ -1033,8 +1033,7 @@ TEST(OrderCompareEffects) {
     BinopEffectsTester B(ops[j], Type::Symbol(), Type::String());
     CHECK_EQ(ops[j + 1]->opcode(), B.result->op()->opcode());
 
-    Node* i0 =
-        B.CheckConvertedInput(IrOpcode::kPlainPrimitiveToNumber, 0, false);
+    Node* i0 = B.CheckConvertedInput(IrOpcode::kJSToNumber, 0, true);
     Node* i1 = B.CheckConvertedInput(IrOpcode::kJSToNumber, 1, true);
 
     // Inputs should be commuted.
index 53f41ea..97ff106 100644 (file)
@@ -372,7 +372,8 @@ TEST_F(JSTypedLoweringTest, JSToNumberWithPlainPrimitive) {
   Reduction r = Reduce(graph()->NewNode(javascript()->ToNumber(), input,
                                         context, effect, control));
   ASSERT_TRUE(r.Changed());
-  EXPECT_THAT(r.replacement(), IsPlainPrimitiveToNumber(input));
+  EXPECT_THAT(r.replacement(), IsToNumber(input, IsNumberConstant(BitEq(0.0)),
+                                          graph()->start(), control));
 }
 
 
index 8c78288..74afda9 100644 (file)
@@ -1308,7 +1308,6 @@ IS_UNOP_MATCHER(Float64RoundTruncate)
 IS_UNOP_MATCHER(Float64RoundTiesAway)
 IS_UNOP_MATCHER(NumberToInt32)
 IS_UNOP_MATCHER(NumberToUint32)
-IS_UNOP_MATCHER(PlainPrimitiveToNumber)
 #undef IS_UNOP_MATCHER
 
 }  // namespace compiler
index 9d542cd..02b6e43 100644 (file)
@@ -85,7 +85,6 @@ Matcher<Node*> IsNumberSubtract(const Matcher<Node*>& lhs_matcher,
                                 const Matcher<Node*>& rhs_matcher);
 Matcher<Node*> IsNumberMultiply(const Matcher<Node*>& lhs_matcher,
                                 const Matcher<Node*>& rhs_matcher);
-Matcher<Node*> IsPlainPrimitiveToNumber(const Matcher<Node*>& value_matcher);
 Matcher<Node*> IsLoadField(const Matcher<FieldAccess>& access_matcher,
                            const Matcher<Node*>& base_matcher,
                            const Matcher<Node*>& effect_matcher,