1/* 2 * Copyright (c) 2024 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 16let str = "0"; 17function A() { 18 for (let j = 0; j < 2; j++) { 19 str = str + j; 20 } 21 let arr = new Array(); 22 for (let i = 0; i < 2; i++) { 23 arr.push(new Error()); 24 } 25 arr = null; 26 ArkTools.forceFullGC(); 27 28 arr = new Array(); 29 for (let i = 0; i < 2; i++) { 30 arr.push(new Error()); 31 } 32 arr = null; 33 34} 35 36function B() { 37 let arr = new Array(); 38 for (let i = 0; i < 2; i++) { 39 arr.push(new Error()); 40 } 41 A(); 42} 43 44function C(array) { 45 B(); 46 47 let i = 0; 48 let len = array.length; 49 50 for (let j = 0; j < len; j++) { 51 i = i + array[j]; 52 } 53 54 return i; 55} 56 57const array = new Array(); 58for (let i = 0; i < 2; i++) { 59 array.push(i); 60} 61 62C(array); 63ArkTools.jitCompileAsync(A); 64ArkTools.jitCompileAsync(B); 65ArkTools.jitCompileAsync(C); 66var compilerResult = ArkTools.waitJitCompileFinish(C); 67 68let str1 = "ArkTools" 69 70C(str1) 71print(compilerResult) 72