Reviewers: Michael Starzinger, titzer,

Description:
Simplify inlining now that the scheduler is smart(er).

* Only control adjustment is to move everything from the inlinee's
  start block to the block the call was in.
* Add a unit test to ensure that the scheduler actually picks the
  right order when placing the code.

[email protected],[email protected]

Please review this at https://codereview.chromium.org/508953002/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files (+12, -44 lines):
  M src/compiler/js-inlining.cc
  M test/cctest/compiler/test-run-inlining.cc


Index: src/compiler/js-inlining.cc
diff --git a/src/compiler/js-inlining.cc b/src/compiler/js-inlining.cc
index 4e8adb25a076dfafaf18c2f4a7d12ba2c0455ffe..75bf4f2f53fc6518fb8448b2a8e84c3b181575a8 100644
--- a/src/compiler/js-inlining.cc
+++ b/src/compiler/js-inlining.cc
@@ -49,35 +49,6 @@ void JSInliner::Inline() {
 }


-static void MoveWithDependencies(Graph* graph, Node* node, Node* old_block,
-                                 Node* new_block) {
-  if (OperatorProperties::HasControlInput(node->op())) {
-    // Check if we have left the old_block.
-    if (NodeProperties::GetControlInput(node) != old_block) return;
-    // If not, move this node to the new_block.
-    NodeProperties::ReplaceControlInput(node, new_block);
-  }
-  // Independent of whether a node has a control input or not,
-  // it might have a dependency that is pinned to old_block.
- for (InputIter iter = node->inputs().begin(); iter != node->inputs().end();
-       ++iter) {
-    if (NodeProperties::IsControlEdge(iter.edge())) continue;
-    MoveWithDependencies(graph, *iter, old_block, new_block);
-  }
-}
-
-
-static void MoveAllControlNodes(Node* from, Node* to) {
-  for (UseIter iter = from->uses().begin(); iter != from->uses().end();) {
-    if (NodeProperties::IsControlEdge(iter.edge())) {
-      iter.UpdateToAndIncrement(to);
-    } else {
-      ++iter;
-    }
-  }
-}
-
-
// TODO(sigurds) Find a home for this function and reuse it everywhere (esp. in
 // test cases, where similar code is currently duplicated).
static void Parse(Handle<JSFunction> function, CompilationInfoWithZone* info) {
@@ -187,13 +158,9 @@ void Inlinee::UnifyReturn() {
 void Inlinee::InlineAtCall(JSGraph* jsgraph, Node* call) {
   MachineOperatorBuilder machine(jsgraph->zone());

+ // The scheduler is smart enough to place our code; we just ensure {control}
+  // becomes the control input of the start of the inlinee.
   Node* control = NodeProperties::GetControlInput(call);
-  // Move all the nodes to the end block.
-  MoveAllControlNodes(control, end_block());
-  // Now move the ones the call depends on back up.
-  // We have to do this back-and-forth to treat the case where the call is
-  // pinned to the start block.
-  MoveWithDependencies(graph(), call, end_block(), control);

   // The inlinee uses the context from the JSFunction object. This will
// also be the effect dependency for the inlinee as it produces an effect.
Index: test/cctest/compiler/test-run-inlining.cc
diff --git a/test/cctest/compiler/test-run-inlining.cc b/test/cctest/compiler/test-run-inlining.cc index 5e5b604b1da645ca1c0a6a8e59f62bbab98cd319..e33e2a13109487a5b1172474690aa8c8b96093e8 100644
--- a/test/cctest/compiler/test-run-inlining.cc
+++ b/test/cctest/compiler/test-run-inlining.cc
@@ -164,31 +164,32 @@ TEST(InlineTwiceDependentDiamond) {
   FLAG_turbo_inlining = true;
   FunctionTester T(
       "(function () {"
-      "function foo(s) { if (true) {"
-      "                  return 12 } else { return 13; } };"
-      "function bar(s,t) { return foo(foo(1)); };"
+      "var x = 41;"
+      "function foo(s) { AssertStackDepth(1); if (s % 2 == 0) {"
+      "                  return x - s } else { return x + s; } };"
+      "function bar(s,t) { return foo(foo(s)); };"
       "return bar;"
       "})();");

   InstallAssertStackDepthHelper(CcTest::isolate());
-  T.CheckCall(T.Val(12), T.undefined(), T.undefined());
+  T.CheckCall(T.Val(-11), T.Val(11), T.Val(4));
 }


-TEST(InlineTwiceDependentDiamondReal) {
+TEST(InlineTwiceDependentDiamondDifferent) {
   FLAG_context_specialization = true;
   FLAG_turbo_inlining = true;
   FunctionTester T(
       "(function () {"
       "var x = 41;"
-      "function foo(s) { AssertStackDepth(1); if (s % 2 == 0) {"
-      "                  return x - s } else { return x + s; } };"
-      "function bar(s,t) { return foo(foo(s)); };"
+      "function foo(s,t) { AssertStackDepth(1); if (s % 2 == 0) {"
+ " return x - s * t } else { return x + s * t; } };"
+      "function bar(s,t) { return foo(foo(s, 3), 5); };"
       "return bar;"
       "})();");

   InstallAssertStackDepthHelper(CcTest::isolate());
-  T.CheckCall(T.Val(-11), T.Val(11), T.Val(4));
+  T.CheckCall(T.Val(-329), T.Val(11), T.Val(4));
 }

 #endif  // V8_TURBOFAN_TARGET


--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to