Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(73)

Unified Diff: test/cctest/test-debug.cc

Issue 1842763002: [api] Add a switch that controls if ES2015 tail call elimination feature is enabled or not. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@tco-dynamic
Patch Set: Added workaround and TODO to investigate TurboFan issue. Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/parsing/parser.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-debug.cc
diff --git a/test/cctest/test-debug.cc b/test/cctest/test-debug.cc
index c1cfc4ac799dcef15bb531f31626060ddb121acb..253842d152efd6565bebf30f9dd9b2ab0c95b518 100644
--- a/test/cctest/test-debug.cc
+++ b/test/cctest/test-debug.cc
@@ -8070,3 +8070,60 @@ TEST(BreakLocationIterator) {
DisableDebugger(isolate);
}
+
+TEST(DisableTailCallElimination) {
+ i::FLAG_allow_natives_syntax = true;
+ i::FLAG_harmony_tailcalls = true;
+ // TODO(ishell, 4698): Investigate why TurboFan in --always-opt mode makes
+ // stack[2].getFunctionName() return null.
+ i::FLAG_turbo_inlining = false;
+
+ DebugLocalContext env;
+ v8::Isolate* isolate = env->GetIsolate();
+ v8::HandleScope scope(isolate);
+ CHECK(v8::Debug::IsTailCallEliminationEnabled(isolate));
+
+ CompileRun(
+ "'use strict'; \n"
+ "Error.prepareStackTrace = (error,stack) => { \n"
+ " error.strace = stack; \n"
+ " return error.message + \"\\n at \" + stack.join(\"\\n at \"); \n"
+ "} \n"
+ " \n"
+ "function getCaller() { \n"
+ " var e = new Error(); \n"
+ " e.stack; // prepare stack trace \n"
+ " var stack = e.strace; \n"
+ " %GlobalPrint('caller: '); \n"
+ " %GlobalPrint(stack[2].getFunctionName()); \n"
+ " %GlobalPrint('\\n'); \n"
+ " return stack[2].getFunctionName(); \n"
+ "} \n"
+ "function f() { \n"
+ " var caller = getCaller(); \n"
+ " if (caller === 'g') return 1; \n"
+ " if (caller === 'h') return 2; \n"
+ " return 0; \n"
+ "} \n"
+ "function g() { \n"
+ " return f(); \n"
+ "} \n"
+ "function h() { \n"
+ " var result = g(); \n"
+ " return result; \n"
+ "} \n"
+ "%NeverOptimizeFunction(getCaller); \n"
+ "%NeverOptimizeFunction(f); \n"
+ "%NeverOptimizeFunction(h); \n"
+ "");
+ ExpectInt32("h();", 2);
+ ExpectInt32("h(); %OptimizeFunctionOnNextCall(g); h();", 2);
+ v8::Debug::SetTailCallEliminationEnabled(isolate, false);
+ CHECK(!v8::Debug::IsTailCallEliminationEnabled(isolate));
+ ExpectInt32("h();", 1);
+ ExpectInt32("h(); %OptimizeFunctionOnNextCall(g); h();", 1);
+ v8::Debug::SetTailCallEliminationEnabled(isolate, true);
+ CHECK(v8::Debug::IsTailCallEliminationEnabled(isolate));
+ ExpectInt32("h();", 2);
+ ExpectInt32("h(); %OptimizeFunctionOnNextCall(g); h();", 2);
+}
« no previous file with comments | « src/parsing/parser.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698