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);
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