Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Flags: --allow-natives-syntax --harmony-explicit-tailcalls | 5 // Flags: --allow-natives-syntax --harmony-explicit-tailcalls |
| 6 | 6 |
| 7 Error.prepareStackTrace = (error,stack) => { | 7 Error.prepareStackTrace = (error,stack) => { |
| 8 error.strace = stack; | 8 error.strace = stack; |
| 9 return error.message + "\n at " + stack.join("\n at "); | 9 return error.message + "\n at " + stack.join("\n at "); |
| 10 } | 10 } |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 216 test(); | 216 test(); |
| 217 test(); | 217 test(); |
| 218 %OptimizeFunctionOnNextCall(test); | 218 %OptimizeFunctionOnNextCall(test); |
| 219 test(); | 219 test(); |
| 220 })(); | 220 })(); |
| 221 | 221 |
| 222 | 222 |
| 223 // Tail calling via various expressions. | 223 // Tail calling via various expressions. |
| 224 (function() { | 224 (function() { |
| 225 function g1(a) { | 225 function g1(a) { |
| 226 return continue f([f, g1, test], false) || f([f, test], true); | 226 return f([f, g1, test], false) || continue f([f, test], true); |
| 227 } | 227 } |
| 228 | 228 |
| 229 function g2(a) { | 229 function g2(a) { |
| 230 return continue f([f, g2, test], true) && f([f, test], true); | 230 return f([f, g2, test], true) && continue f([f, test], true); |
| 231 } | 231 } |
| 232 | 232 |
| 233 function g3(a) { | 233 function g3(a) { |
| 234 return continue f([f, g3, test], 13), f([f, test], 153); | 234 return f([f, g3, test], 13), continue f([f, test], 153); |
| 235 } | 235 } |
| 236 | 236 |
| 237 function test() { | 237 function test() { |
| 238 assertEquals(true, g1()); | 238 assertEquals(true, g1()); |
| 239 assertEquals(true, g2()); | 239 assertEquals(true, g2()); |
| 240 assertEquals(153, g3()); | 240 assertEquals(153, g3()); |
| 241 } | 241 } |
| 242 test(); | 242 test(); |
| 243 test(); | 243 test(); |
| 244 %OptimizeFunctionOnNextCall(test); | 244 %OptimizeFunctionOnNextCall(test); |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 397 (function () { | 397 (function () { |
| 398 function g1(a) { | 398 function g1(a) { |
| 399 return continue (() => { return continue f_153([f_153, test]); })(); | 399 return continue (() => { return continue f_153([f_153, test]); })(); |
| 400 } | 400 } |
| 401 | 401 |
| 402 function g2(a) { | 402 function g2(a) { |
| 403 return continue (() => continue f_153([f_153, test]))(); | 403 return continue (() => continue f_153([f_153, test]))(); |
| 404 } | 404 } |
| 405 | 405 |
| 406 function g3(a) { | 406 function g3(a) { |
| 407 var closure = () => continue f([f, closure, test], true) | 407 var closure = () => f([f, closure, test], true) |
| 408 ? f_153([f_153, test]) | 408 ? continue f_153([f_153, test]) |
| 409 : f_153([f_153, test]); | 409 : f_153([f_153, test]); |
|
rossberg
2016/05/02 10:59:40
Shouldn't you need a `continue` here, too, to be e
Igor Sheludko
2016/05/04 10:28:55
The call f([f, closure, test], true) returns true.
| |
| 410 | |
| 411 return continue closure(); | 410 return continue closure(); |
| 412 } | 411 } |
| 413 | 412 |
| 414 function test() { | 413 function test() { |
| 415 assertEquals(153, g1()); | 414 assertEquals(153, g1()); |
| 416 assertEquals(153, g2()); | 415 assertEquals(153, g2()); |
| 417 assertEquals(153, g3()); | 416 assertEquals(153, g3()); |
| 418 } | 417 } |
| 419 test(); | 418 test(); |
| 420 test(); | 419 test(); |
| 421 %OptimizeFunctionOnNextCall(test); | 420 %OptimizeFunctionOnNextCall(test); |
| 422 test(); | 421 test(); |
| 423 })(); | 422 })(); |
| OLD | NEW |