michael@0: // Test optimized RetSub stubs. michael@0: var count = 0; michael@0: function f(x) { michael@0: try { michael@0: if (x < 0) michael@0: throw "negative"; michael@0: if (x & 1) michael@0: return "odd"; michael@0: count++; michael@0: } finally { michael@0: count += 3; michael@0: } michael@0: michael@0: return "even"; michael@0: } michael@0: for (var i=0; i<15; i++) { michael@0: var res = f(i); michael@0: if ((i % 2) === 0) michael@0: assertEq(res, "even"); michael@0: else michael@0: assertEq(res, "odd"); michael@0: } michael@0: try { michael@0: f(-1); michael@0: assertEq(0, 1); michael@0: } catch(e) { michael@0: assertEq(e, "negative"); michael@0: } michael@0: michael@0: assertEq(count, 56);