blob: 905073e998f0a00b261825a9de65eac347f48f5b [file] [log] [blame]
tzagallo@apple.com58b77472018-11-07 09:05:15 +00001//@ skip if $architecture == "x86"
2
commit-queue@webkit.orga4201b02015-08-17 22:24:20 +00003"use strict";
4
5var n = 1000000;
6
7function 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
19function bar(f) { }
20
21function 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
35noInline(bar);
36noInline(foo);
37noInline(shouldThrowTDZ);
38
39for (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}