OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 8109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8120 ExpectInt32("h(); %OptimizeFunctionOnNextCall(g); h();", 2); | 8120 ExpectInt32("h(); %OptimizeFunctionOnNextCall(g); h();", 2); |
8121 v8::Debug::SetTailCallEliminationEnabled(isolate, false); | 8121 v8::Debug::SetTailCallEliminationEnabled(isolate, false); |
8122 CHECK(!v8::Debug::IsTailCallEliminationEnabled(isolate)); | 8122 CHECK(!v8::Debug::IsTailCallEliminationEnabled(isolate)); |
8123 ExpectInt32("h();", 1); | 8123 ExpectInt32("h();", 1); |
8124 ExpectInt32("h(); %OptimizeFunctionOnNextCall(g); h();", 1); | 8124 ExpectInt32("h(); %OptimizeFunctionOnNextCall(g); h();", 1); |
8125 v8::Debug::SetTailCallEliminationEnabled(isolate, true); | 8125 v8::Debug::SetTailCallEliminationEnabled(isolate, true); |
8126 CHECK(v8::Debug::IsTailCallEliminationEnabled(isolate)); | 8126 CHECK(v8::Debug::IsTailCallEliminationEnabled(isolate)); |
8127 ExpectInt32("h();", 2); | 8127 ExpectInt32("h();", 2); |
8128 ExpectInt32("h(); %OptimizeFunctionOnNextCall(g); h();", 2); | 8128 ExpectInt32("h(); %OptimizeFunctionOnNextCall(g); h();", 2); |
8129 } | 8129 } |
| 8130 |
| 8131 TEST(DebugStepNextTailCallEliminiation) { |
| 8132 i::FLAG_allow_natives_syntax = true; |
| 8133 i::FLAG_harmony_tailcalls = true; |
| 8134 // TODO(ishell, 4698): Investigate why TurboFan in --always-opt mode makes |
| 8135 // stack[2].getFunctionName() return null. |
| 8136 i::FLAG_turbo_inlining = false; |
| 8137 |
| 8138 DebugLocalContext env; |
| 8139 env.ExposeDebug(); |
| 8140 v8::Isolate* isolate = env->GetIsolate(); |
| 8141 v8::HandleScope scope(isolate); |
| 8142 CHECK(v8::Debug::IsTailCallEliminationEnabled(isolate)); |
| 8143 |
| 8144 const char* source = |
| 8145 "'use strict'; \n" |
| 8146 "var Debug = debug.Debug; \n" |
| 8147 "var exception = null; \n" |
| 8148 "var breaks = 0; \n" |
| 8149 "var log = []; \n" |
| 8150 "function f(x) { \n" |
| 8151 " if (x == 2) { \n" |
| 8152 " debugger; // Break a \n" |
| 8153 " } \n" |
| 8154 " if (x-- > 0) { // Break b \n" |
| 8155 " return f(x); // Break c \n" |
| 8156 " } \n" |
| 8157 "} // Break e \n" |
| 8158 "function listener(event, exec_state, event_data, data) {\n" |
| 8159 " if (event != Debug.DebugEvent.Break) return; \n" |
| 8160 " try { \n" |
| 8161 " var line = exec_state.frame(0).sourceLineText(); \n" |
| 8162 " var col = exec_state.frame(0).sourceColumn(); \n" |
| 8163 " var match = line.match(/\\/\\/ Break (\\w)/); \n" |
| 8164 " log.push(match[1] + col); \n" |
| 8165 " exec_state.prepareStep(Debug.StepAction.StepNext); \n" |
| 8166 " } catch (e) { \n" |
| 8167 " exception = e; \n" |
| 8168 " }; \n" |
| 8169 "}; \n" |
| 8170 "Debug.setListener(listener); \n" |
| 8171 "f(4); \n" |
| 8172 "Debug.setListener(null); // Break d \n"; |
| 8173 |
| 8174 CompileRun(source); |
| 8175 ExpectNull("exception"); |
| 8176 ExpectString("JSON.stringify(log)", "[\"a4\",\"b2\",\"c4\",\"c11\",\"d0\"]"); |
| 8177 |
| 8178 v8::Debug::SetTailCallEliminationEnabled(isolate, false); |
| 8179 CompileRun( |
| 8180 "log = []; \n" |
| 8181 "Debug.setListener(listener); \n" |
| 8182 "f(5); \n" |
| 8183 "Debug.setListener(null); // Break f \n"); |
| 8184 ExpectNull("exception"); |
| 8185 ExpectString("JSON.stringify(log)", |
| 8186 "[\"a4\",\"b2\",\"c4\",\"e0\",\"e0\",\"e0\",\"e0\",\"f0\"]"); |
| 8187 } |
OLD | NEW |