tco-body-strict.js (643B)
1 // |reftest| skip -- tail-call-optimization is not supported 2 'use strict'; 3 // Copyright (C) 2016 the V8 project authors. All rights reserved. 4 // This code is governed by the BSD license found in the LICENSE file. 5 /*--- 6 description: Statement within statement is a candidate for tail-call optimization. 7 esid: sec-static-semantics-hascallintailposition 8 flags: [onlyStrict] 9 features: [tail-call-optimization] 10 includes: [tcoHelper.js] 11 ---*/ 12 13 var callCount = 0; 14 (function f(n) { 15 if (n === 0) { 16 callCount += 1 17 return; 18 } 19 while (true) { 20 return f(n - 1); 21 } 22 }($MAX_ITERATIONS)); 23 assert.sameValue(callCount, 1); 24 25 reportCompare(0, 0);