1 // Copyright 2015 the V8 project authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 function counter() { 6 var i = 100; 7 return function() { 8 if (i-- > 0) return i; 9 throw "done"; 10 } 11 } 12 13 var c1 = counter(); 14 var c2 = counter(); 15 16 var f = (function() { 17 "use asm"; 18 return function f(i) { 19 i = i|0; 20 do { 21 if (i > 0) c1(); 22 else c2(); 23 } while (true); 24 } 25 })(); 26 27 assertThrows(function() { f(0); }); 28 assertThrows(function() { f(1); }); 29 30 var c3 = counter(); 31 32 var g = (function() { 33 "use asm"; 34 return function g(i) { 35 i = i + 1; 36 do { 37 i = c3(i); 38 } while (true); 39 } 40 })(); 41 42 assertThrows(function() { g(0); }); 43 assertThrows(function() { g(1); }); 44