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_cideclare function print(arg: any): string; 164514f5e3Sopenharmony_cideclare interface ArkTools { 174514f5e3Sopenharmony_ci isAOTCompiled(args: any): boolean; 184514f5e3Sopenharmony_ci} 194514f5e3Sopenharmony_cilet buffer = new ArrayBuffer(8); 204514f5e3Sopenharmony_cilet sample = new DataView(buffer, 0); 214514f5e3Sopenharmony_ci 224514f5e3Sopenharmony_ci//aot: [trace] aot inline builtin: DataView.prototype.SetFloat32, caller function name:func_main_0@builtinDataViewGet 234514f5e3Sopenharmony_cisample.setFloat32(0); 244514f5e3Sopenharmony_ci//aot: [trace] aot inline builtin: DataView.prototype.GetFloat32, caller function name:func_main_0@builtinDataViewGet 254514f5e3Sopenharmony_ciprint(sample.getFloat32(0)) //: NaN 264514f5e3Sopenharmony_ci//aot: [trace] aot inline builtin: DataView.prototype.GetFloat32, caller function name:func_main_0@builtinDataViewGet 274514f5e3Sopenharmony_ciprint(sample.getFloat32(0, true)) //: NaN 284514f5e3Sopenharmony_ci//aot: [trace] aot inline builtin: DataView.prototype.SetFloat64, caller function name:func_main_0@builtinDataViewGet 294514f5e3Sopenharmony_cisample.setFloat64(0) 304514f5e3Sopenharmony_ciprint(sample.getFloat64()) //: NaN 314514f5e3Sopenharmony_ci//aot: [trace] aot inline builtin: DataView.prototype.GetFloat64, caller function name:func_main_0@builtinDataViewGet 324514f5e3Sopenharmony_ciprint(sample.getFloat64(0)) //: NaN 334514f5e3Sopenharmony_ci 344514f5e3Sopenharmony_ci//aot: [trace] aot inline builtin: DataView.prototype.SetUint8, caller function name:func_main_0@builtinDataViewGet 354514f5e3Sopenharmony_cisample.setUint8(0, 127); 364514f5e3Sopenharmony_ci//aot: [trace] aot inline builtin: DataView.prototype.SetUint8, caller function name:func_main_0@builtinDataViewGet 374514f5e3Sopenharmony_cisample.setUint8(1, 128); 384514f5e3Sopenharmony_ci//aot: [trace] aot inline builtin: DataView.prototype.SetUint8, caller function name:func_main_0@builtinDataViewGet 394514f5e3Sopenharmony_cisample.setUint8(2, 0); 404514f5e3Sopenharmony_ci//aot: [trace] aot inline builtin: DataView.prototype.SetUint8, caller function name:func_main_0@builtinDataViewGet 414514f5e3Sopenharmony_cisample.setUint8(3, 0); 424514f5e3Sopenharmony_ci//aot: [trace] aot inline builtin: DataView.prototype.SetUint8, caller function name:func_main_0@builtinDataViewGet 434514f5e3Sopenharmony_cisample.setUint8(4, 255); 444514f5e3Sopenharmony_ci//aot: [trace] aot inline builtin: DataView.prototype.SetUint8, caller function name:func_main_0@builtinDataViewGet 454514f5e3Sopenharmony_cisample.setUint8(5, 128); 464514f5e3Sopenharmony_ci//aot: [trace] aot inline builtin: DataView.prototype.SetUint8, caller function name:func_main_0@builtinDataViewGet 474514f5e3Sopenharmony_cisample.setUint8(6, 0); 484514f5e3Sopenharmony_ci//aot: [trace] aot inline builtin: DataView.prototype.SetUint8, caller function name:func_main_0@builtinDataViewGet 494514f5e3Sopenharmony_cisample.setUint8(7, 0); 504514f5e3Sopenharmony_ci 514514f5e3Sopenharmony_ci//aot: [trace] aot inline builtin: DataView.prototype.GetFloat32, caller function name:func_main_0@builtinDataViewGet 524514f5e3Sopenharmony_ciprint(sample.getFloat32(0)) //: Infinity 534514f5e3Sopenharmony_ci//aot: [trace] aot inline builtin: DataView.prototype.GetFloat32, caller function name:func_main_0@builtinDataViewGet 544514f5e3Sopenharmony_ciprint(sample.getFloat32(4)) //: -Infinity 554514f5e3Sopenharmony_ci 564514f5e3Sopenharmony_ci//aot: [trace] aot inline builtin: DataView.prototype.SetUint8, caller function name:func_main_0@builtinDataViewGet 574514f5e3Sopenharmony_cisample.setUint8(0, 75); 584514f5e3Sopenharmony_ci//aot: [trace] aot inline builtin: DataView.prototype.SetUint8, caller function name:func_main_0@builtinDataViewGet 594514f5e3Sopenharmony_cisample.setUint8(1, 75); 604514f5e3Sopenharmony_ci//aot: [trace] aot inline builtin: DataView.prototype.SetUint8, caller function name:func_main_0@builtinDataViewGet 614514f5e3Sopenharmony_cisample.setUint8(2, 76); 624514f5e3Sopenharmony_ci//aot: [trace] aot inline builtin: DataView.prototype.SetUint8, caller function name:func_main_0@builtinDataViewGet 634514f5e3Sopenharmony_cisample.setUint8(3, 76); 644514f5e3Sopenharmony_ci//aot: [trace] aot inline builtin: DataView.prototype.SetUint8, caller function name:func_main_0@builtinDataViewGet 654514f5e3Sopenharmony_cisample.setUint8(4, 75); 664514f5e3Sopenharmony_ci//aot: [trace] aot inline builtin: DataView.prototype.SetUint8, caller function name:func_main_0@builtinDataViewGet 674514f5e3Sopenharmony_cisample.setUint8(5, 75); 684514f5e3Sopenharmony_ci//aot: [trace] aot inline builtin: DataView.prototype.SetUint8, caller function name:func_main_0@builtinDataViewGet 694514f5e3Sopenharmony_cisample.setUint8(6, 76); 704514f5e3Sopenharmony_ci//aot: [trace] aot inline builtin: DataView.prototype.SetUint8, caller function name:func_main_0@builtinDataViewGet 714514f5e3Sopenharmony_cisample.setUint8(7, 76); 724514f5e3Sopenharmony_ci 734514f5e3Sopenharmony_ci//32th bit is 1 744514f5e3Sopenharmony_ci//aot: [trace] aot inline builtin: DataView.prototype.SetInt32, caller function name:func_main_0@builtinDataViewGet 754514f5e3Sopenharmony_cisample.setInt32(0, -10000) 764514f5e3Sopenharmony_ci//aot: [trace] aot inline builtin: DataView.prototype.GetUint32, caller function name:func_main_0@builtinDataViewGet 774514f5e3Sopenharmony_ciprint(sample.getUint32(0)) //: 4294957296 784514f5e3Sopenharmony_ci 794514f5e3Sopenharmony_ci//16th bit is 1 804514f5e3Sopenharmony_ci//aot: [trace] aot inline builtin: DataView.prototype.SetInt16, caller function name:func_main_0@builtinDataViewGet 814514f5e3Sopenharmony_cisample.setInt16(0, -100) 824514f5e3Sopenharmony_ci//aot: [trace] aot inline builtin: DataView.prototype.GetUint16, caller function name:func_main_0@builtinDataViewGet 834514f5e3Sopenharmony_ciprint(sample.getUint16(0)) //: 65436 844514f5e3Sopenharmony_ci//set Int NaN 854514f5e3Sopenharmony_ci//aot: [trace] aot inline builtin: DataView.prototype.SetUint32, caller function name:func_main_0@builtinDataViewGet 864514f5e3Sopenharmony_cisample.setUint32(0, NaN) 874514f5e3Sopenharmony_ci//aot: [trace] aot inline builtin: DataView.prototype.GetUint32, caller function name:func_main_0@builtinDataViewGet 884514f5e3Sopenharmony_ciprint(sample.getUint32(0)) //: 0 894514f5e3Sopenharmony_ci//aot: [trace] aot inline builtin: DataView.prototype.GetUint32, caller function name:func_main_0@builtinDataViewGet 904514f5e3Sopenharmony_ciprint(sample.getUint32(4)) //: 1263225932 914514f5e3Sopenharmony_ci 924514f5e3Sopenharmony_ci//aot: [trace] aot inline builtin: DataView.prototype.SetUint8, caller function name:func_main_0@builtinDataViewGet 934514f5e3Sopenharmony_ciprint(sample.setUint8(0, -1)) //: undefined 944514f5e3Sopenharmony_ci//aot: [trace] aot inline builtin: DataView.prototype.GetUint8, caller function name:func_main_0@builtinDataViewGet 954514f5e3Sopenharmony_ciprint(sample.getUint8(0)) //: 255 964514f5e3Sopenharmony_ci//aot: [trace] aot inline builtin: DataView.prototype.GetInt8, caller function name:func_main_0@builtinDataViewGet 974514f5e3Sopenharmony_ciprint(sample.getInt8(0)) //: -1 984514f5e3Sopenharmony_ci 994514f5e3Sopenharmony_ciprint(sample.setUint8(0, -1, 90, 78)) //: undefined 1004514f5e3Sopenharmony_ci//aot: [trace] aot inline builtin: DataView.prototype.GetUint8, caller function name:func_main_0@builtinDataViewGet 1014514f5e3Sopenharmony_ciprint(sample.getUint8(0)) //: 255 1024514f5e3Sopenharmony_ci//aot: [trace] aot inline builtin: DataView.prototype.GetInt8, caller function name:func_main_0@builtinDataViewGet 1034514f5e3Sopenharmony_ciprint(sample.getInt8(0)) //: -1 1044514f5e3Sopenharmony_ci 1054514f5e3Sopenharmony_ci//break tagged mark 1064514f5e3Sopenharmony_ci//aot: [trace] aot inline builtin: DataView.prototype.SetFloat64, caller function name:func_main_0@builtinDataViewGet 1074514f5e3Sopenharmony_cisample.setFloat64(0, 9007199254740991) 1084514f5e3Sopenharmony_ci//aot: [trace] aot inline builtin: DataView.prototype.GetFloat64, caller function name:func_main_0@builtinDataViewGet 1094514f5e3Sopenharmony_ciprint(sample.getFloat64(0, true)) //: NaN 1104514f5e3Sopenharmony_ci//aot: [trace] aot inline builtin: DataView.prototype.GetFloat64, caller function name:func_main_0@builtinDataViewGet 1114514f5e3Sopenharmony_ciprint(sample.getFloat64(0, false)) //: 9007199254740991 1124514f5e3Sopenharmony_ci 1134514f5e3Sopenharmony_ci//greater safe number 1144514f5e3Sopenharmony_ci//aot: [trace] aot inline builtin: DataView.prototype.SetFloat64, caller function name:func_main_0@builtinDataViewGet 1154514f5e3Sopenharmony_cisample.setFloat64(0, 9007199254740992) 1164514f5e3Sopenharmony_ci//aot: [trace] aot inline builtin: DataView.prototype.GetFloat64, caller function name:func_main_0@builtinDataViewGet 1174514f5e3Sopenharmony_ciprint(sample.getFloat64(0, true)) //: 8.128e-320 1184514f5e3Sopenharmony_ci//aot: [trace] aot inline builtin: DataView.prototype.GetFloat64, caller function name:func_main_0@builtinDataViewGet 1194514f5e3Sopenharmony_ciprint(sample.getFloat64(0, false)) //: 9007199254740992 1204514f5e3Sopenharmony_ci 1214514f5e3Sopenharmony_ci//aot: [trace] aot inline builtin: DataView.prototype.SetFloat32, caller function name:func_main_0@builtinDataViewGet 1224514f5e3Sopenharmony_cisample.setFloat32(0, 0.50000001) 1234514f5e3Sopenharmony_ci//aot: [trace] aot inline builtin: DataView.prototype.GetFloat32, caller function name:func_main_0@builtinDataViewGet 1244514f5e3Sopenharmony_ciprint(sample.getFloat32(0, true)) //: 8.828180325246348e-44 1254514f5e3Sopenharmony_ci//aot: [trace] aot inline builtin: DataView.prototype.GetFloat32, caller function name:func_main_0@builtinDataViewGet 1264514f5e3Sopenharmony_ciprint(sample.getFloat32(0, false)) //: 0.5 1274514f5e3Sopenharmony_ci 1284514f5e3Sopenharmony_ci//special value 1294514f5e3Sopenharmony_ci//aot: [trace] aot inline builtin: DataView.prototype.SetFloat32, caller function name:func_main_0@builtinDataViewGet 1304514f5e3Sopenharmony_cisample.setFloat32(0, null) 1314514f5e3Sopenharmony_ci//aot: [trace] aot inline builtin: DataView.prototype.GetFloat32, caller function name:func_main_0@builtinDataViewGet 1324514f5e3Sopenharmony_ciprint(sample.getFloat32(0)) //: 0 1334514f5e3Sopenharmony_ci//aot: [trace] aot inline builtin: DataView.prototype.SetInt32, caller function name:func_main_0@builtinDataViewGet 1344514f5e3Sopenharmony_cisample.setInt32(0, null) 1354514f5e3Sopenharmony_ci//aot: [trace] aot inline builtin: DataView.prototype.GetInt32, caller function name:func_main_0@builtinDataViewGet 1364514f5e3Sopenharmony_ciprint(sample.getInt32(0)) //: 0 1374514f5e3Sopenharmony_ci//aot: [trace] aot inline builtin: DataView.prototype.SetFloat64, caller function name:func_main_0@builtinDataViewGet 1384514f5e3Sopenharmony_cisample.setFloat64(0, true) 1394514f5e3Sopenharmony_ci//aot: [trace] aot inline builtin: DataView.prototype.GetFloat64, caller function name:func_main_0@builtinDataViewGet 1404514f5e3Sopenharmony_ciprint(sample.getFloat64(0)) //: 1 1414514f5e3Sopenharmony_ci//aot: [trace] Check Type: NotBool1 1424514f5e3Sopenharmony_ciprint(sample.getFloat64(0, 'abc')) //: 3.03865e-319 1434514f5e3Sopenharmony_ciprint(sample.getFloat64('abc')) //: 1 1444514f5e3Sopenharmony_ci 1454514f5e3Sopenharmony_ci// Check inside try-block 1464514f5e3Sopenharmony_citry { 1474514f5e3Sopenharmony_ci print(sample.setUint8(0, -1, 90, 78)) //: undefined 1484514f5e3Sopenharmony_ci print(sample.getUint8(0)) //: 255 1494514f5e3Sopenharmony_ci} catch(e) { 1504514f5e3Sopenharmony_ci} 1514514f5e3Sopenharmony_ci 1524514f5e3Sopenharmony_cilet obj = {}; 1534514f5e3Sopenharmony_ciobj.valueOf = (() => { return 5; }) 1544514f5e3Sopenharmony_ciprint(sample.setUint8(obj)); //: undefined 1554514f5e3Sopenharmony_ci 1564514f5e3Sopenharmony_cifunction Throwing() { 1574514f5e3Sopenharmony_ci this.value = 2; 1584514f5e3Sopenharmony_ci Throwing.prototype.valueOf = function() { 1594514f5e3Sopenharmony_ci if (this.value > 0) { 1604514f5e3Sopenharmony_ci throw new Error("positive"); 1614514f5e3Sopenharmony_ci } 1624514f5e3Sopenharmony_ci return this.value; 1634514f5e3Sopenharmony_ci } 1644514f5e3Sopenharmony_ci} 1654514f5e3Sopenharmony_cilet throwingObj = new Throwing(); 1664514f5e3Sopenharmony_citry { 1674514f5e3Sopenharmony_ci print(sample.setUint8(throwingObj)); 1684514f5e3Sopenharmony_ci} catch(e) { 1694514f5e3Sopenharmony_ci print(e); //: Error: positive 1704514f5e3Sopenharmony_ci} finally { 1714514f5e3Sopenharmony_ci print(sample.setUint8(obj)); //: undefined 1724514f5e3Sopenharmony_ci} 1734514f5e3Sopenharmony_ci 1744514f5e3Sopenharmony_cisample.getUint8(0) 1754514f5e3Sopenharmony_cisample.setInt16(0, -100) 1764514f5e3Sopenharmony_ci 1774514f5e3Sopenharmony_ci// Replace standard builtin 1784514f5e3Sopenharmony_cifunction replace(a : any) { 1794514f5e3Sopenharmony_ci return a; 1804514f5e3Sopenharmony_ci} 1814514f5e3Sopenharmony_ci 1824514f5e3Sopenharmony_cilet true_get = sample.getInt8 1834514f5e3Sopenharmony_cisample.getInt8 = replace 1844514f5e3Sopenharmony_ci 1854514f5e3Sopenharmony_ciprint(sample.getInt8(0)); //: 0 1864514f5e3Sopenharmony_cisample.getInt8 = true_get 1874514f5e3Sopenharmony_ciprint(sample.getInt8(0)); //: -1 1884514f5e3Sopenharmony_ci 1894514f5e3Sopenharmony_ci 1904514f5e3Sopenharmony_cifunction doGet(x: any): any { 1914514f5e3Sopenharmony_ci return sample.getInt8(x); 1924514f5e3Sopenharmony_ci} 1934514f5e3Sopenharmony_ci 1944514f5e3Sopenharmony_cifunction printGet(x: any) { 1954514f5e3Sopenharmony_ci try { 1964514f5e3Sopenharmony_ci print(doGet(x)); 1974514f5e3Sopenharmony_ci } finally { 1984514f5e3Sopenharmony_ci } 1994514f5e3Sopenharmony_ci} 2004514f5e3Sopenharmony_ci 2014514f5e3Sopenharmony_ciif (ArkTools.isAOTCompiled(printGet)) { 2024514f5e3Sopenharmony_ci // Replace standard builtin after call to standard builtin was profiled 2034514f5e3Sopenharmony_ci sample.getInt8 = replace 2044514f5e3Sopenharmony_ci} 2054514f5e3Sopenharmony_ciprintGet(1); //pgo: -100 2064514f5e3Sopenharmony_ci//aot: [trace] Check Type: NotCallTarget1 2074514f5e3Sopenharmony_ci//aot: 1 2084514f5e3Sopenharmony_ci 2094514f5e3Sopenharmony_ciprintGet("abc"); //pgo: -1 2104514f5e3Sopenharmony_ci//aot: [trace] Check Type: NotCallTarget1 2114514f5e3Sopenharmony_ci//aot: abc 2124514f5e3Sopenharmony_ci 2134514f5e3Sopenharmony_cisample.getInt8 = true_get 2144514f5e3Sopenharmony_ci 2154514f5e3Sopenharmony_cifunction getCase1() { 2164514f5e3Sopenharmony_ci print('case 1 get') //: case 1 get 2174514f5e3Sopenharmony_ci let buffer = new ArrayBuffer(8); 2184514f5e3Sopenharmony_ci let sample1 = new DataView(buffer, 0); 2194514f5e3Sopenharmony_ci let sample2 = new DataView(buffer, 0); 2204514f5e3Sopenharmony_ci sample2.garbage = function(x: any): any { 2214514f5e3Sopenharmony_ci return undefined; 2224514f5e3Sopenharmony_ci } 2234514f5e3Sopenharmony_ci 2244514f5e3Sopenharmony_ci //aot: [trace] aot inline builtin: DataView.prototype.SetInt32, caller function name:#*#getCase1@builtinDataViewGet 2254514f5e3Sopenharmony_ci sample1.setInt32(0, null) 2264514f5e3Sopenharmony_ci //aot: [trace] aot inline builtin: DataView.prototype.SetInt32, caller function name:#*#getCase1@builtinDataViewGet 2274514f5e3Sopenharmony_ci sample2.setInt32(0, null) 2284514f5e3Sopenharmony_ci 2294514f5e3Sopenharmony_ci //aot: [trace] aot inline builtin: DataView.prototype.GetInt32, caller function name:#*#getCase1@builtinDataViewGet 2304514f5e3Sopenharmony_ci print(sample1.getInt32(0)); //: 0 2314514f5e3Sopenharmony_ci //aot: [trace] aot inline builtin: DataView.prototype.GetInt32, caller function name:#*#getCase1@builtinDataViewGet 2324514f5e3Sopenharmony_ci print(sample2.getInt32(0)); //: 0 2334514f5e3Sopenharmony_ci} 2344514f5e3Sopenharmony_cigetCase1() 2354514f5e3Sopenharmony_ci 2364514f5e3Sopenharmony_ci 2374514f5e3Sopenharmony_cifunction getCase2() { 2384514f5e3Sopenharmony_ci print('case 2 get') //: case 2 get 2394514f5e3Sopenharmony_ci let buffer = new ArrayBuffer(8); 2404514f5e3Sopenharmony_ci let sample1 = new DataView(buffer, 0); 2414514f5e3Sopenharmony_ci let sample2 = new DataView(buffer, 0); 2424514f5e3Sopenharmony_ci sample2.getInt32 = function(x: any) { 2434514f5e3Sopenharmony_ci return x + 1 2444514f5e3Sopenharmony_ci } 2454514f5e3Sopenharmony_ci 2464514f5e3Sopenharmony_ci //aot: [trace] aot inline builtin: Object.getPrototypeOf, caller function name:#*#getCase2@builtinDataViewGet 2474514f5e3Sopenharmony_ci print(Object.getPrototypeOf(sample2) === DataView.prototype) //: true 2484514f5e3Sopenharmony_ci 2494514f5e3Sopenharmony_ci //aot: [trace] aot inline builtin: DataView.prototype.SetInt32, caller function name:#*#getCase2@builtinDataViewGet 2504514f5e3Sopenharmony_ci sample1.setInt32(0, null) 2514514f5e3Sopenharmony_ci //aot: [trace] aot inline builtin: DataView.prototype.SetInt32, caller function name:#*#getCase2@builtinDataViewGet 2524514f5e3Sopenharmony_ci sample2.setInt32(0, null) 2534514f5e3Sopenharmony_ci 2544514f5e3Sopenharmony_ci //aot: [trace] aot inline builtin: DataView.prototype.GetInt32, caller function name:#*#getCase2@builtinDataViewGet 2554514f5e3Sopenharmony_ci print(sample1.getInt32(0)); //: 0 2564514f5e3Sopenharmony_ci //aot: [trace] aot inline function name: #*@2*#@builtinDataViewGet caller function name: #*#getCase2@builtinDataViewGet 2574514f5e3Sopenharmony_ci print(sample2.getInt32(0)); //: 1 2584514f5e3Sopenharmony_ci} 2594514f5e3Sopenharmony_cigetCase2() 2604514f5e3Sopenharmony_ci 2614514f5e3Sopenharmony_ci 2624514f5e3Sopenharmony_cifunction getCase3() { 2634514f5e3Sopenharmony_ci print('case 3 get') //: case 3 get 2644514f5e3Sopenharmony_ci let buffer = new ArrayBuffer(8); 2654514f5e3Sopenharmony_ci let msample = new DataView(buffer, 0); 2664514f5e3Sopenharmony_ci let true_getInt32 = msample.getInt32 2674514f5e3Sopenharmony_ci let mimicDataView = { 2684514f5e3Sopenharmony_ci getInt32: true_getInt32, 2694514f5e3Sopenharmony_ci } 2704514f5e3Sopenharmony_ci 2714514f5e3Sopenharmony_ci //aot: [trace] aot inline builtin: DataView.prototype.SetInt32, caller function name:#*#getCase3@builtinDataViewGet 2724514f5e3Sopenharmony_ci msample.setInt32(0, null) 2734514f5e3Sopenharmony_ci //aot: [trace] aot inline builtin: DataView.prototype.GetInt32, caller function name:#*#getCase3@builtinDataViewGet 2744514f5e3Sopenharmony_ci print(msample.getInt32(0)); //: 0 2754514f5e3Sopenharmony_ci Object.setPrototypeOf(msample, mimicDataView) 2764514f5e3Sopenharmony_ci 2774514f5e3Sopenharmony_ci //aot: [trace] aot inline builtin: DataView.prototype.GetInt32, caller function name:#*#getCase3@builtinDataViewGet 2784514f5e3Sopenharmony_ci print(msample.getInt32(0)); //: 0 2794514f5e3Sopenharmony_ci} 2804514f5e3Sopenharmony_cigetCase3() 2814514f5e3Sopenharmony_ci 2824514f5e3Sopenharmony_ci 2834514f5e3Sopenharmony_cifunction getCase4() { 2844514f5e3Sopenharmony_ci print('case 4 get') //: case 4 get 2854514f5e3Sopenharmony_ci let buffer = new ArrayBuffer(8); 2864514f5e3Sopenharmony_ci let sample1 = new DataView(buffer, 0); 2874514f5e3Sopenharmony_ci let sample2 = new DataView(buffer, 0); 2884514f5e3Sopenharmony_ci let true_setInt32 = sample2.setInt32 2894514f5e3Sopenharmony_ci let notDataView = { 2904514f5e3Sopenharmony_ci getInt32(x: any) { 2914514f5e3Sopenharmony_ci return -100 2924514f5e3Sopenharmony_ci }, 2934514f5e3Sopenharmony_ci setInt32: true_setInt32 2944514f5e3Sopenharmony_ci } 2954514f5e3Sopenharmony_ci Object.setPrototypeOf(sample2, notDataView) 2964514f5e3Sopenharmony_ci //aot: [trace] aot inline builtin: DataView.prototype.SetInt32, caller function name:#*#getCase4@builtinDataViewGet 2974514f5e3Sopenharmony_ci sample1.setInt32(0, null) 2984514f5e3Sopenharmony_ci //aot: [trace] aot inline builtin: DataView.prototype.SetInt32, caller function name:#*#getCase4@builtinDataViewGet 2994514f5e3Sopenharmony_ci sample2.setInt32(0, null) 3004514f5e3Sopenharmony_ci 3014514f5e3Sopenharmony_ci //aot: [trace] aot inline builtin: DataView.prototype.GetInt32, caller function name:#*#getCase4@builtinDataViewGet 3024514f5e3Sopenharmony_ci print(sample1.getInt32(0)); //: 0 3034514f5e3Sopenharmony_ci //aot: [trace] aot inline function name: #*@3*#getInt32@builtinDataViewGet caller function name: #*#getCase4@builtinDataViewGet 3044514f5e3Sopenharmony_ci print(sample2.getInt32(0)); //: -100 3054514f5e3Sopenharmony_ci} 3064514f5e3Sopenharmony_cigetCase4() 3074514f5e3Sopenharmony_ci 3084514f5e3Sopenharmony_ci 3094514f5e3Sopenharmony_cifunction getCase5() { 3104514f5e3Sopenharmony_ci print('case 5 get') //: case 5 get 3114514f5e3Sopenharmony_ci let buffer = new ArrayBuffer(8); 3124514f5e3Sopenharmony_ci let sample1 = new DataView(buffer, 0); 3134514f5e3Sopenharmony_ci DataView.prototype.getInt32 = function(x: any) { 3144514f5e3Sopenharmony_ci return x + 45 3154514f5e3Sopenharmony_ci } 3164514f5e3Sopenharmony_ci 3174514f5e3Sopenharmony_ci //aot: [trace] aot inline function name: #*@4*#@builtinDataViewGet caller function name: #*#getCase5@builtinDataViewGet 3184514f5e3Sopenharmony_ci print(sample1.getInt32(1)); //: 46 3194514f5e3Sopenharmony_ci} 3204514f5e3Sopenharmony_cigetCase5() 321