Reviewers: Michael Starzinger,
Description:
[turbofan] Support inlining of unguarded loops.
Also allow inlining of native functions.
[email protected]
Please review this at https://codereview.chromium.org/962963006/
Base URL: https://chromium.googlesource.com/v8/v8.git@master
Affected files (+65, -11 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
135e6a1c8319abc828d302754dda491f650853c6..e1d3fcbc0465dfd47ddea53208adff2b53025188
100644
--- a/src/compiler/js-inlining.cc
+++ b/src/compiler/js-inlining.cc
@@ -79,6 +79,11 @@ class Inlinee {
Node* value_output() {
return NodeProperties::GetValueInput(unique_return(), 0);
}
+ // Return the control output of the graph,
+ // that is the control input of the return statement of the inlinee.
+ Node* control_output() {
+ return NodeProperties::GetControlInput(unique_return(), 0);
+ }
// Return the unique return statement of the graph.
Node* unique_return() {
Node* unique_return = NodeProperties::GetControlInput(end_);
@@ -263,7 +268,19 @@ Reduction Inlinee::InlineAtCall(JSGraph* jsgraph,
Node* call) {
}
}
- NodeProperties::ReplaceWithValue(call, value_output(), effect_output());
+ for (Edge edge : call->use_edges()) {
+ if (NodeProperties::IsControlEdge(edge)) {
+ // TODO(turbofan): Handle kIfException uses.
+ DCHECK_EQ(IrOpcode::kIfSuccess, edge.from()->opcode());
+ edge.from()->ReplaceUses(control_output());
+ edge.UpdateTo(nullptr);
+ } else if (NodeProperties::IsEffectEdge(edge)) {
+ edge.UpdateTo(effect_output());
+ } else {
+ edge.UpdateTo(value_output());
+ }
+ }
+
return Reducer::Replace(value_output());
}
@@ -312,16 +329,6 @@ Reduction JSInliner::Reduce(Node* node) {
Handle<JSFunction> function = match.Value().handle();
- if (function->shared()->native()) {
- if (FLAG_trace_turbo_inlining) {
- SmartArrayPointer<char> name =
- function->shared()->DebugName()->ToCString();
- PrintF("Not Inlining %s into %s because inlinee is native\n",
name.get(),
- info_->shared_info()->DebugName()->ToCString().get());
- }
- return NoChange();
- }
-
CompilationInfoWithZone info(function);
if (!Compiler::ParseAndAnalyze(&info)) return NoChange();
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
19b96bad504afd5277650e147da1e7566da59417..783ed5471e161fbd19d79859c05d0a07f3f21df1
100644
--- a/test/cctest/compiler/test-run-inlining.cc
+++ b/test/cctest/compiler/test-run-inlining.cc
@@ -320,6 +320,53 @@ TEST(InlineLoopGuardedTwice) {
}
+TEST(InlineLoopUnguardedEmpty) {
+ FLAG_turbo_deoptimization = true;
+ FunctionTester T(
+ "(function () {"
+ " function foo(s) { AssertInlineCount(2); while (s); return s; };"
+ " function bar(s, t) { return foo(s); };"
+ " return bar;"
+ "})();",
+ kInlineFlags);
+
+ InstallAssertInlineCountHelper(CcTest::isolate());
+ T.CheckCall(T.Val(0.0), T.Val(0.0), T.Val(4));
+}
+
+
+TEST(InlineLoopUnguardedOnce) {
+ FLAG_turbo_deoptimization = true;
+ FunctionTester T(
+ "(function () {"
+ " function foo(s) { AssertInlineCount(2); while (s) {"
+ " s = s - 1; }; return s; };"
+ " function bar(s, t) { return foo(s); };"
+ " return bar;"
+ "})();",
+ kInlineFlags);
+
+ InstallAssertInlineCountHelper(CcTest::isolate());
+ T.CheckCall(T.Val(0.0), T.Val(0.0), T.Val(4));
+}
+
+
+TEST(InlineLoopUnguardedTwice) {
+ FLAG_turbo_deoptimization = true;
+ FunctionTester T(
+ "(function () {"
+ " function foo(s) { AssertInlineCount(2); while (s > 0) {"
+ " s = s - 1; }; return s; };"
+ " function bar(s,t) { return foo(foo(s,t),t); };"
+ " return bar;"
+ "})();",
+ kInlineFlags);
+
+ InstallAssertInlineCountHelper(CcTest::isolate());
+ T.CheckCall(T.Val(0.0), T.Val(0.0), T.Val(4));
+}
+
+
TEST(InlineStrictIntoNonStrict) {
FLAG_turbo_deoptimization = true;
FunctionTester T(
--
--
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.