shape-guard-for-extensible-global-lex-env-2.js (2036B)
1 this.a = 0; 2 3 function f(y) { 4 // Direct eval to make an extensible environment. Variables lookups within 5 // nested environments are now dynamic. 6 eval(""); 7 8 let w = y; 9 10 // Class with class-body lexical environment whose shape guard we want to omit. 11 class C { 12 // Add a private brand to generate a class-body lexical environment. 13 #private; 14 15 static m() { 16 // BindName "a" # ENV 17 // Dup # ENV ENV 18 // GetBoundName "a" # ENV ENV.a 19 // GetAliasedVar "w" (hops = 2, slot = 2) # ENV ENV.a w 20 // CheckAliasedLexical "w" (hops = 2, slot = 2) # ENV ENV.a w 21 // Add # ENV (ENV.a += w) 22 // NopIsAssignOp # ENV (ENV.a += w) 23 // StrictSetName "a" # (ENV.a += w) 24 // Pop # 25 a += w; 26 } 27 } 28 29 let g = C.m; 30 31 for (var i = 0; i < 150; ++i) { 32 // Introduce a new binding in the global lexical environment which 33 // shadows the global property "a". 34 if (i === 100) { 35 evaluate("let a = 1000"); 36 } 37 g(); 38 } 39 40 assertEq(a, 1050); 41 assertEq(globalThis.a, 100); 42 } 43 f(1);