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 */ 15declare function print(arg: any): string; 16declare interface ArkTools { 17 isAOTCompiled(args: any): boolean; 18} 19let buffer = new ArrayBuffer(8); 20let sample = new DataView(buffer, 0); 21 22//aot: [trace] aot inline builtin: DataView.prototype.SetFloat64, caller function name:func_main_0@builtinDataViewFloat64 23sample.setFloat64(0) 24print(sample.getFloat64()) //: NaN 25//aot: [trace] aot inline builtin: DataView.prototype.GetFloat64, caller function name:func_main_0@builtinDataViewFloat64 26print(sample.getFloat64(0)) //: NaN 27print(sample.getBigInt64(0).toString(16)) //: 7ff8000000000000 28 29//aot: [trace] aot inline builtin: DataView.prototype.SetFloat64, caller function name:func_main_0@builtinDataViewFloat64 30sample.setFloat64(0, NaN, true) 31//aot: [trace] aot inline builtin: DataView.prototype.GetFloat64, caller function name:func_main_0@builtinDataViewFloat64 32print(sample.getFloat64(0, true)) //: NaN 33print(sample.getBigInt64(0, true).toString(16)) //: 7ff8000000000000 34 35sample.setBigUint64 (0, 0xf87fn); 36//aot: [trace] aot inline builtin: DataView.prototype.GetFloat64, caller function name:func_main_0@builtinDataViewFloat64 37print(sample.getFloat64(0)) //: 3.143e-319 38print(sample.getBigInt64(0).toString(16)) //: f87f 39 40sample.setBigUint64 (0, 0xf87fn, true); 41//aot: [trace] aot inline builtin: DataView.prototype.GetFloat64, caller function name:func_main_0@builtinDataViewFloat64 42print(sample.getFloat64(0, true)) //: 3.143e-319 43print(sample.getBigInt64(0, true).toString(16)) //: f87f 44 45//aot: [trace] aot inline builtin: DataView.prototype.SetUint8, caller function name:func_main_0@builtinDataViewFloat64 46sample.setUint8(0, 0x7f); 47//aot: [trace] aot inline builtin: DataView.prototype.SetUint8, caller function name:func_main_0@builtinDataViewFloat64 48sample.setUint8(1, 0xf8); 49//aot: [trace] aot inline builtin: DataView.prototype.SetUint8, caller function name:func_main_0@builtinDataViewFloat64 50sample.setUint8(2, 0x00); 51//aot: [trace] aot inline builtin: DataView.prototype.SetUint8, caller function name:func_main_0@builtinDataViewFloat64 52sample.setUint8(3, 0x00); 53//aot: [trace] aot inline builtin: DataView.prototype.SetUint8, caller function name:func_main_0@builtinDataViewFloat64 54sample.setUint8(4, 0x00); 55//aot: [trace] aot inline builtin: DataView.prototype.SetUint8, caller function name:func_main_0@builtinDataViewFloat64 56sample.setUint8(5, 0x00); 57//aot: [trace] aot inline builtin: DataView.prototype.SetUint8, caller function name:func_main_0@builtinDataViewFloat64 58sample.setUint8(6, 0x00); 59//aot: [trace] aot inline builtin: DataView.prototype.SetUint8, caller function name:func_main_0@builtinDataViewFloat64 60sample.setUint8(7, 0x00); 61//aot: [trace] aot inline builtin: DataView.prototype.GetFloat64, caller function name:func_main_0@builtinDataViewFloat64 62print(sample.getFloat64(0)) //: NaN 63print(sample.getBigInt64(0).toString(16)) //: 7ff8000000000000 64 65//aot: [trace] aot inline builtin: DataView.prototype.SetUint8, caller function name:func_main_0@builtinDataViewFloat64 66sample.setUint8(0, 0x7f); 67//aot: [trace] aot inline builtin: DataView.prototype.SetUint8, caller function name:func_main_0@builtinDataViewFloat64 68sample.setUint8(1, 0xf8); 69//aot: [trace] aot inline builtin: DataView.prototype.SetUint8, caller function name:func_main_0@builtinDataViewFloat64 70sample.setUint8(2, 0x00); 71//aot: [trace] aot inline builtin: DataView.prototype.SetUint8, caller function name:func_main_0@builtinDataViewFloat64 72sample.setUint8(3, 0x00); 73//aot: [trace] aot inline builtin: DataView.prototype.SetUint8, caller function name:func_main_0@builtinDataViewFloat64 74sample.setUint8(4, 0x00); 75//aot: [trace] aot inline builtin: DataView.prototype.SetUint8, caller function name:func_main_0@builtinDataViewFloat64 76sample.setUint8(5, 0x00); 77//aot: [trace] aot inline builtin: DataView.prototype.SetUint8, caller function name:func_main_0@builtinDataViewFloat64 78sample.setUint8(6, 0x00); 79//aot: [trace] aot inline builtin: DataView.prototype.SetUint8, caller function name:func_main_0@builtinDataViewFloat64 80sample.setUint8(7, 0x00); 81//aot: [trace] aot inline builtin: DataView.prototype.GetFloat64, caller function name:func_main_0@builtinDataViewFloat64 82print(sample.getFloat64(0, true)) //: 3.143e-319 83print(sample.getBigInt64(0, true).toString(16)) //: f87f 84 85//aot: [trace] aot inline builtin: DataView.prototype.SetUint8, caller function name:func_main_0@builtinDataViewFloat64 86sample.setUint8(0, 0x00); 87//aot: [trace] aot inline builtin: DataView.prototype.SetUint8, caller function name:func_main_0@builtinDataViewFloat64 88sample.setUint8(1, 0x00); 89//aot: [trace] aot inline builtin: DataView.prototype.SetUint8, caller function name:func_main_0@builtinDataViewFloat64 90sample.setUint8(2, 0x00); 91//aot: [trace] aot inline builtin: DataView.prototype.SetUint8, caller function name:func_main_0@builtinDataViewFloat64 92sample.setUint8(3, 0x00); 93//aot: [trace] aot inline builtin: DataView.prototype.SetUint8, caller function name:func_main_0@builtinDataViewFloat64 94sample.setUint8(4, 0x00); 95//aot: [trace] aot inline builtin: DataView.prototype.SetUint8, caller function name:func_main_0@builtinDataViewFloat64 96sample.setUint8(5, 0x00); 97//aot: [trace] aot inline builtin: DataView.prototype.SetUint8, caller function name:func_main_0@builtinDataViewFloat64 98sample.setUint8(6, 0xf8); 99//aot: [trace] aot inline builtin: DataView.prototype.SetUint8, caller function name:func_main_0@builtinDataViewFloat64 100sample.setUint8(7, 0x7f); 101//aot: [trace] aot inline builtin: DataView.prototype.GetFloat64, caller function name:func_main_0@builtinDataViewFloat64 102print(sample.getFloat64(0)) //: 3.143e-319 103print(sample.getBigInt64(0).toString(16)) //: f87f 104 105//aot: [trace] aot inline builtin: DataView.prototype.SetUint8, caller function name:func_main_0@builtinDataViewFloat64 106sample.setUint8(0, 0x00); 107//aot: [trace] aot inline builtin: DataView.prototype.SetUint8, caller function name:func_main_0@builtinDataViewFloat64 108sample.setUint8(1, 0x00); 109//aot: [trace] aot inline builtin: DataView.prototype.SetUint8, caller function name:func_main_0@builtinDataViewFloat64 110sample.setUint8(2, 0x00); 111//aot: [trace] aot inline builtin: DataView.prototype.SetUint8, caller function name:func_main_0@builtinDataViewFloat64 112sample.setUint8(3, 0x00); 113//aot: [trace] aot inline builtin: DataView.prototype.SetUint8, caller function name:func_main_0@builtinDataViewFloat64 114sample.setUint8(4, 0x00); 115//aot: [trace] aot inline builtin: DataView.prototype.SetUint8, caller function name:func_main_0@builtinDataViewFloat64 116sample.setUint8(5, 0x00); 117//aot: [trace] aot inline builtin: DataView.prototype.SetUint8, caller function name:func_main_0@builtinDataViewFloat64 118sample.setUint8(6, 0xf8); 119//aot: [trace] aot inline builtin: DataView.prototype.SetUint8, caller function name:func_main_0@builtinDataViewFloat64 120sample.setUint8(7, 0x7f); 121//aot: [trace] aot inline builtin: DataView.prototype.GetFloat64, caller function name:func_main_0@builtinDataViewFloat64 122print(sample.getFloat64(0, true)) //: NaN 123print(sample.getBigInt64(0, true).toString(16)) //: 7ff8000000000000 124 125// Test case coverage for crash scenarios 126let buff = new ArrayBuffer(8); 127let u64 = new BigUint64Array(buff); 128let dv = new DataView(buff); 129u64[0] = 0xfff78715227b5c40n; 130//aot: [trace] aot inline builtin: DataView.prototype.GetFloat64, caller function name:func_main_0@builtinDataViewFloat64 131let res = dv.getFloat64(0, false); 132//aot: [trace] aot inline builtin: Math.abs, caller function name:func_main_0@builtinDataViewFloat64 133print(Math.abs(res - 0)); //: 113.92395532873341