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 16declare function print(arg:any):string; 17function replace(a : number) 18{ 19 return a; 20} 21 22let res:number = 0; 23 24// Check without params 25res = Math.log2(); 26//aot: [trace] aot inline builtin: Math.log2, caller function name:func_main_0@builtinMathLog2 27print(res); //: NaN 28 29// Check with single param 30res = Math.log2(-0); 31//aot: [trace] aot inline builtin: Math.log2, caller function name:func_main_0@builtinMathLog2 32print(res); //: -Infinity 33 34res = Math.log2(+0); 35//aot: [trace] aot inline builtin: Math.log2, caller function name:func_main_0@builtinMathLog2 36print(res); //: -Infinity 37 38res = Math.log2(-123); 39//aot: [trace] aot inline builtin: Math.log2, caller function name:func_main_0@builtinMathLog2 40print(res); //: NaN 41 42res = Math.log2(2); 43//aot: [trace] aot inline builtin: Math.log2, caller function name:func_main_0@builtinMathLog2 44print(res); //: 1 45 46// Check with 2 params 47//aot: [trace] aot inline builtin: Math.log2, caller function name:func_main_0@builtinMathLog2 48res = Math.log2(2, 2); 49print(res); //: 1 50 51// Check with 3 params 52res = Math.log2(2, 2, 2); 53//aot: [trace] aot inline builtin: Math.log2, caller function name:func_main_0@builtinMathLog2 54print(res); //: 1 55 56// Check with 4 params 57res = Math.log2(2, 2, 2, 2); 58//aot: [trace] aot inline builtin: Math.log2, caller function name:func_main_0@builtinMathLog2 59print(res); //: 1 60 61// Check with 5 params 62res = Math.log2(2, 2, 2, 2, 2); 63//aot: [trace] aot inline builtin: Math.log2, caller function name:func_main_0@builtinMathLog2 64print(res); //: 1 65 66try { 67 //aot: [trace] aot inline builtin: Math.log2, caller function name:func_main_0@builtinMathLog2 68 print(Math.log2(2)); //: 1 69} catch(e) {} 70 71// Replace standart builtin 72let true_log2 = Math.log2 73Math.log2 = replace 74res = Math.log2(111); 75print(res); //: 111 76 77// Call standart builtin with non-number param 78Math.log2 = true_log2 79//aot: [trace] aot inline builtin: Math.log2, caller function name:func_main_0@builtinMathLog2 80//aot: [trace] Check Type: NotNumber1 81res = Math.log2("-0"); // deopt 82print(res); //: -Infinity 83