tzagallo@apple.com | 58b7747 | 2018-11-07 09:05:15 +0000 | [diff] [blame] | 1 | //@ skip if $architecture == "x86" |
| 2 | |
commit-queue@webkit.org | a4201b0 | 2015-08-17 22:24:20 +0000 | [diff] [blame] | 3 | "use strict"; |
| 4 | |
| 5 | var n = 1000000; |
| 6 | |
| 7 | function shouldThrowTDZ(func) { |
| 8 | var hasThrown = false; |
| 9 | try { |
| 10 | func(); |
| 11 | } catch(e) { |
| 12 | if (e.name.indexOf("ReferenceError") !== -1) |
| 13 | hasThrown = true; |
| 14 | } |
| 15 | if (!hasThrown) |
| 16 | throw new Error("Did not throw TDZ error"); |
| 17 | } |
| 18 | |
| 19 | function bar(f) { } |
| 20 | |
| 21 | function foo(b) { |
| 22 | let result = 0; |
| 23 | var set = (x) => { result = x; return tdzPerpetrator; } |
| 24 | if (b) { |
| 25 | OSRExit(); |
| 26 | if (b) { |
| 27 | bar(set); |
| 28 | return tdzPerpetrator; |
| 29 | } |
| 30 | } |
| 31 | let tdzPerpetrator; |
| 32 | return result; |
| 33 | } |
| 34 | |
| 35 | noInline(bar); |
| 36 | noInline(foo); |
| 37 | noInline(shouldThrowTDZ); |
| 38 | |
| 39 | for (var i = 0; i < n; i++) { |
| 40 | var bool = !(i % 100); |
| 41 | if (bool) |
| 42 | shouldThrowTDZ(()=> { foo(bool); }); |
| 43 | else { |
| 44 | var result = foo(bool); |
| 45 | if (result != 0) |
| 46 | throw "Error: bad result: " + result; |
| 47 | } |
| 48 | } |