14514f5e3Sopenharmony_ci/* 24514f5e3Sopenharmony_ci * Copyright (c) 2024 Huawei Device Co., Ltd. 34514f5e3Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 44514f5e3Sopenharmony_ci * you may not use this file except in compliance with the License. 54514f5e3Sopenharmony_ci * You may obtain a copy of the License at 64514f5e3Sopenharmony_ci * 74514f5e3Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 84514f5e3Sopenharmony_ci * 94514f5e3Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 104514f5e3Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 114514f5e3Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 124514f5e3Sopenharmony_ci * See the License for the specific language governing permissions and 134514f5e3Sopenharmony_ci * limitations under the License. 144514f5e3Sopenharmony_ci */ 154514f5e3Sopenharmony_ci 164514f5e3Sopenharmony_cideclare interface ArkTools { 174514f5e3Sopenharmony_ci isAOTCompiled(args: any): boolean; 184514f5e3Sopenharmony_ci} 194514f5e3Sopenharmony_ci 204514f5e3Sopenharmony_cideclare function print(arg:any):string; 214514f5e3Sopenharmony_cifunction replace(a : number) 224514f5e3Sopenharmony_ci{ 234514f5e3Sopenharmony_ci return a; 244514f5e3Sopenharmony_ci} 254514f5e3Sopenharmony_ci 264514f5e3Sopenharmony_cifunction doCeil(x: any): number { 274514f5e3Sopenharmony_ci return Math.ceil(x); 284514f5e3Sopenharmony_ci} 294514f5e3Sopenharmony_ci 304514f5e3Sopenharmony_cifunction printCeil(x: any) { 314514f5e3Sopenharmony_ci try { 324514f5e3Sopenharmony_ci print(doCeil(x)); 334514f5e3Sopenharmony_ci } finally { 344514f5e3Sopenharmony_ci } 354514f5e3Sopenharmony_ci} 364514f5e3Sopenharmony_ci 374514f5e3Sopenharmony_ci// Check without params 384514f5e3Sopenharmony_ci//aot: [trace] aot inline builtin: Math.ceil, caller function name:func_main_0@builtinMathCeil 394514f5e3Sopenharmony_ciprint(Math.ceil()); //: NaN 404514f5e3Sopenharmony_ci 414514f5e3Sopenharmony_ci// Replace standart builtin 424514f5e3Sopenharmony_cilet backup = Math.ceil 434514f5e3Sopenharmony_ci//aot: [trace] Check Type: NotCallTarget1 444514f5e3Sopenharmony_ciMath.ceil = replace 454514f5e3Sopenharmony_ciprintCeil(111); //: 111 464514f5e3Sopenharmony_ciMath.ceil = backup 474514f5e3Sopenharmony_ci 484514f5e3Sopenharmony_ci// Check with NaN param 494514f5e3Sopenharmony_ci//aot: [trace] aot inline builtin: Math.ceil, caller function name:#*#doCeil@builtinMathCeil 504514f5e3Sopenharmony_ciprintCeil(NaN); //: NaN 514514f5e3Sopenharmony_ci 524514f5e3Sopenharmony_ci// Check with infinity param 534514f5e3Sopenharmony_ci//aot: [trace] aot inline builtin: Math.ceil, caller function name:#*#doCeil@builtinMathCeil 544514f5e3Sopenharmony_ciprintCeil(-Infinity); //: -Infinity 554514f5e3Sopenharmony_ci//aot: [trace] aot inline builtin: Math.ceil, caller function name:#*#doCeil@builtinMathCeil 564514f5e3Sopenharmony_ciprintCeil(+Infinity); //: Infinity 574514f5e3Sopenharmony_ci 584514f5e3Sopenharmony_ci// Check with zero param 594514f5e3Sopenharmony_ci//aot: [trace] aot inline builtin: Math.ceil, caller function name:#*#doCeil@builtinMathCeil 604514f5e3Sopenharmony_ciprintCeil(-0.0); //: 0 614514f5e3Sopenharmony_ci//aot: [trace] aot inline builtin: Math.ceil, caller function name:#*#doCeil@builtinMathCeil 624514f5e3Sopenharmony_ciprintCeil(0.0); //: 0 634514f5e3Sopenharmony_ci//aot: [trace] aot inline builtin: Math.ceil, caller function name:#*#doCeil@builtinMathCeil 644514f5e3Sopenharmony_ciprintCeil(+0.0); //: 0 654514f5e3Sopenharmony_ci 664514f5e3Sopenharmony_ci// Check with integer param 674514f5e3Sopenharmony_ci//aot: [trace] aot inline builtin: Math.ceil, caller function name:#*#doCeil@builtinMathCeil 684514f5e3Sopenharmony_ciprintCeil(-1.0); //: -1 694514f5e3Sopenharmony_ci//aot: [trace] aot inline builtin: Math.ceil, caller function name:#*#doCeil@builtinMathCeil 704514f5e3Sopenharmony_ciprintCeil(+1.0); //: 1 714514f5e3Sopenharmony_ci//aot: [trace] aot inline builtin: Math.ceil, caller function name:#*#doCeil@builtinMathCeil 724514f5e3Sopenharmony_ciprintCeil(-12.0); //: -12 734514f5e3Sopenharmony_ci//aot: [trace] aot inline builtin: Math.ceil, caller function name:#*#doCeil@builtinMathCeil 744514f5e3Sopenharmony_ciprintCeil(+12.0); //: 12 754514f5e3Sopenharmony_ci//aot: [trace] aot inline builtin: Math.ceil, caller function name:#*#doCeil@builtinMathCeil 764514f5e3Sopenharmony_ciprintCeil(-123.0); //: -123 774514f5e3Sopenharmony_ci//aot: [trace] aot inline builtin: Math.ceil, caller function name:#*#doCeil@builtinMathCeil 784514f5e3Sopenharmony_ciprintCeil(+123.0); //: 123 794514f5e3Sopenharmony_ci 804514f5e3Sopenharmony_ci//aot: [trace] aot inline builtin: Math.ceil, caller function name:#*#doCeil@builtinMathCeil 814514f5e3Sopenharmony_ciprintCeil(1.5); //: 2 824514f5e3Sopenharmony_ci// Call standard builtin with non-number param 834514f5e3Sopenharmony_ci//aot: [trace] aot inline builtin: Math.ceil, caller function name:#*#doCeil@builtinMathCeil 844514f5e3Sopenharmony_ciprintCeil("abc"); //aot: [trace] Check Type: NotNumber1 854514f5e3Sopenharmony_ci //: NaN 864514f5e3Sopenharmony_ci//aot: [trace] aot inline builtin: Math.ceil, caller function name:#*#doCeil@builtinMathCeil 874514f5e3Sopenharmony_ciprintCeil("1.5"); //aot: [trace] Check Type: NotNumber1 884514f5e3Sopenharmony_ci //: 2 894514f5e3Sopenharmony_ci 904514f5e3Sopenharmony_ciif (ArkTools.isAOTCompiled(printCeil)) { 914514f5e3Sopenharmony_ci // Replace standard builtin after call to standard builtin was profiled 924514f5e3Sopenharmony_ci Math.ceil = replace 934514f5e3Sopenharmony_ci} 944514f5e3Sopenharmony_ciprintCeil(1.5); //aot: [trace] Check Type: NotCallTarget1 954514f5e3Sopenharmony_ci //aot: 1.5 964514f5e3Sopenharmony_ci //pgo: 2 974514f5e3Sopenharmony_ciprintCeil("abc"); //aot: [trace] Check Type: NotCallTarget1 984514f5e3Sopenharmony_ci //aot: abc 994514f5e3Sopenharmony_ci //pgo: NaN 1004514f5e3Sopenharmony_ci 1014514f5e3Sopenharmony_ciMath.ceil = backup 1024514f5e3Sopenharmony_ci 1034514f5e3Sopenharmony_ci// Check with fractional param 1044514f5e3Sopenharmony_ci//aot: [trace] aot inline builtin: Math.ceil, caller function name:#*#doCeil@builtinMathCeil 1054514f5e3Sopenharmony_ciprintCeil(-1.25); //: -1 1064514f5e3Sopenharmony_ci//aot: [trace] aot inline builtin: Math.ceil, caller function name:#*#doCeil@builtinMathCeil 1074514f5e3Sopenharmony_ciprintCeil(+1.25); //: 2 1084514f5e3Sopenharmony_ci//aot: [trace] aot inline builtin: Math.ceil, caller function name:#*#doCeil@builtinMathCeil 1094514f5e3Sopenharmony_ciprintCeil(-1.50); //: -1 1104514f5e3Sopenharmony_ci//aot: [trace] aot inline builtin: Math.ceil, caller function name:#*#doCeil@builtinMathCeil 1114514f5e3Sopenharmony_ciprintCeil(+1.50); //: 2 1124514f5e3Sopenharmony_ci//aot: [trace] aot inline builtin: Math.ceil, caller function name:#*#doCeil@builtinMathCeil 1134514f5e3Sopenharmony_ciprintCeil(-1.75); //: -1 1144514f5e3Sopenharmony_ci//aot: [trace] aot inline builtin: Math.ceil, caller function name:#*#doCeil@builtinMathCeil 1154514f5e3Sopenharmony_ciprintCeil(+1.75); //: 2 1164514f5e3Sopenharmony_ci 1174514f5e3Sopenharmony_ci// Check with non-number param 1184514f5e3Sopenharmony_ci//aot: [trace] aot inline builtin: Math.ceil, caller function name:#*#doCeil@builtinMathCeil 1194514f5e3Sopenharmony_ciprintCeil("string"); //aot: [trace] Check Type: NotNumber1 1204514f5e3Sopenharmony_ci //: NaN 1214514f5e3Sopenharmony_ci//aot: [trace] aot inline builtin: Math.ceil, caller function name:#*#doCeil@builtinMathCeil 1224514f5e3Sopenharmony_ciprintCeil(null); //aot: [trace] Check Type: NotNumber1 1234514f5e3Sopenharmony_ci //: 0 1244514f5e3Sopenharmony_ci//aot: [trace] aot inline builtin: Math.ceil, caller function name:#*#doCeil@builtinMathCeil 1254514f5e3Sopenharmony_ciprintCeil(undefined); //aot: [trace] Check Type: NotNumber1 1264514f5e3Sopenharmony_ci //: NaN 1274514f5e3Sopenharmony_ci//aot: [trace] aot inline builtin: Math.ceil, caller function name:#*#doCeil@builtinMathCeil 1284514f5e3Sopenharmony_ciprintCeil(false); //aot: [trace] Check Type: NotNumber1 1294514f5e3Sopenharmony_ci //: 0 1304514f5e3Sopenharmony_ci//aot: [trace] aot inline builtin: Math.ceil, caller function name:#*#doCeil@builtinMathCeil 1314514f5e3Sopenharmony_ciprintCeil(true); //aot: [trace] Check Type: NotNumber1 1324514f5e3Sopenharmony_ci //: 1 1334514f5e3Sopenharmony_ci//aot: [trace] aot inline builtin: Math.ceil, caller function name:#*#doCeil@builtinMathCeil 1344514f5e3Sopenharmony_ciprintCeil(new Object); //aot: [trace] Check Type: NotNumber1 1354514f5e3Sopenharmony_ci //: NaN 1364514f5e3Sopenharmony_ciprintCeil("1.3333"); 1374514f5e3Sopenharmony_ci //: 2