1/* 2 * Copyright (c) 2025 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16class A {} 17 18let var0 = 0; 19 20Object.defineProperty(globalThis, 'var1', { 21 value: 1, 22 configurable: true 23}); 24 25 26function TestLoadA() { 27 A.a = 1; 28 var0 = 1; 29 return A.a + var0; 30} 31 32function TestBuiltinMath() { 33 return Math.E; 34} 35 36function TestAccessor() { 37 let a = var1; 38 return a; 39} 40 41function TestAccessor1() { 42 Object.defineProperty(globalThis, 'var1', { 43 configurable: true, 44 get: function () {print("TestAccessor1");return 2;} 45 }); 46} 47 48for (var i = 0; i < 10; i++) { 49 TestLoadA(); 50 TestAccessor(); 51 TestBuiltinMath(); 52} 53 54ArkTools.jitCompileAsync(TestLoadA); 55var ret = ArkTools.waitJitCompileFinish(TestLoadA); 56print(ret) 57print(TestLoadA()); 58 59ArkTools.jitCompileAsync(TestAccessor); 60ret = ArkTools.waitJitCompileFinish(TestAccessor); 61print(ret) 62print(TestAccessor()) 63 64// invaild property box 65TestAccessor1(); 66// deopt 67print(TestAccessor()); 68 69ArkTools.jitCompileAsync(TestBuiltinMath); 70ret = ArkTools.waitJitCompileFinish(TestBuiltinMath); 71print(ret) 72print(TestBuiltinMath()); 73 74