Reviewers: jarin,
Description:
[turbofan] Disable recursive inlining for now.
The deoptimizer (and probably various other places) cannot deal properly
with recursive function inlining, so we disallow it in TurboFan as well.
We might want to reconsider that decision at some point in the future.
[email protected]
Please review this at https://codereview.chromium.org/1211243007/
Base URL: https://chromium.googlesource.com/v8/v8.git@master
Affected files (+51, -0 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
6d7de1d30df21621c02dda5590a722d387eb5dff..1251952ab0d1e8ab02b82dbe9025546297c9edb7
100644
--- a/src/compiler/js-inlining.cc
+++ b/src/compiler/js-inlining.cc
@@ -251,6 +251,23 @@ Reduction JSInliner::Reduce(Node* node) {
return NoChange();
}
+ // TODO(turbofan): TranslatedState::GetAdaptedArguments() currently
relies on
+ // not inlining recursive functions. We might want to relax that at some
+ // point.
+ for (Node* frame_state = call.frame_state();
+ frame_state->opcode() == IrOpcode::kFrameState;
+ frame_state = frame_state->InputAt(kFrameStateOuterStateInput)) {
+ FrameStateInfo const& info = OpParameter<FrameStateInfo>(frame_state);
+ Handle<SharedFunctionInfo> shared_info;
+ if (info.shared_info().ToHandle(&shared_info) &&
+ *shared_info == function->shared()) {
+ TRACE("Not inlining %s into %s because call is recursive\n",
+ function->shared()->DebugName()->ToCString().get(),
+ info_->shared_info()->DebugName()->ToCString().get());
+ return NoChange();
+ }
+ }
+
Zone zone;
ParseInfo parse_info(&zone, function);
CompilationInfo info(&parse_info);
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
76cd4a8eb6335ba4b1c4a2b5c28a423f1d793d36..7f8ae256198d4a017d507ad25e262814f90a8ca3
100644
--- a/test/cctest/compiler/test-run-inlining.cc
+++ b/test/cctest/compiler/test-run-inlining.cc
@@ -541,4 +541,38 @@ TEST(StrongModeArityOuter) {
T.CheckThrows(T.undefined(), T.undefined());
}
+
+TEST(InlineSelfRecursive) {
+ FunctionTester T(
+ "(function () {"
+ " function foo(x) { "
+ " AssertInlineCount(1);"
+ " if (x == 1) return foo(12);"
+ " return x;"
+ " }"
+ " return foo;"
+ "})();",
+ kInlineFlags);
+
+ InstallAssertInlineCountHelper(CcTest::isolate());
+ T.CheckCall(T.Val(12), T.Val(1));
+}
+
+
+TEST(InlineMutuallyRecursive) {
+ FunctionTester T(
+ "(function () {"
+ " function bar(x) { AssertInlineCount(2); return foo(x); }"
+ " function foo(x) { "
+ " if (x == 1) return bar(42);"
+ " return x;"
+ " }"
+ " return foo;"
+ "})();",
+ kInlineFlags);
+
+ InstallAssertInlineCountHelper(CcTest::isolate());
+ T.CheckCall(T.Val(42), T.Val(1));
+}
+
#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.