[rab/gsab|turbofan] Add missing DataView tests
Bug: v8:11111 Change-Id: I03fd90900fae521cb3e738f011fb0832770ff04a Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4218351 Reviewed-by: Nico Hartmann <nicohartmann@chromium.org> Commit-Queue: Marja Hölttä <marja@chromium.org> Cr-Commit-Position: refs/heads/main@{#85622}
This commit is contained in:
parent
87ab6f5500
commit
28771bf519
@ -451,6 +451,83 @@ assertEquals(9, ByteLength(dv));
|
||||
assertOptimized(ByteLength);
|
||||
})();
|
||||
|
||||
const dataview_data_sizes = ['Int8', 'Uint8', 'Int16', 'Uint16', 'Int32',
|
||||
'Uint32', 'Float32', 'Float64', 'BigInt64',
|
||||
'BigUint64'];
|
||||
|
||||
// Global variable used for DataViews; this is important for triggering some
|
||||
// optimizations.
|
||||
var dv;
|
||||
(function() {
|
||||
for (let use_global_var of [true, false]) {
|
||||
for (let shared of [false, true]) {
|
||||
for (let length_tracking of [false, true]) {
|
||||
for (let with_offset of [false, true]) {
|
||||
for (let data_size of dataview_data_sizes) {
|
||||
const test_case = `Testing: Get_${
|
||||
data_size}_${
|
||||
shared ? 'GSAB' : 'RAB'}_${
|
||||
length_tracking ?
|
||||
'LengthTracking' :
|
||||
'FixedLength'}${with_offset ? 'WithOffset' : ''}_${
|
||||
use_global_var ? 'UseGlobalVar' : ''}_DataView`;
|
||||
// console.log(test_case);
|
||||
const is_bigint = data_size.startsWith('Big');
|
||||
const expected_value = is_bigint ? 0n : 0;
|
||||
|
||||
const get_code = 'return dv.get' + data_size + '(0); // ' + test_case;
|
||||
const Get = use_global_var ?
|
||||
new Function(get_code) : new Function('dv', get_code);
|
||||
|
||||
const offset = with_offset ? 8 : 0;
|
||||
|
||||
let blen = 8; // Enough for one element.
|
||||
const fixed_blen = length_tracking ? undefined : blen;
|
||||
const ab = CreateBuffer(shared, 8*10, 8*20);
|
||||
// Assign to the global var.
|
||||
dv = new DataView(ab, offset, fixed_blen);
|
||||
const Resize = MakeResize(DataView, shared, offset, fixed_blen);
|
||||
|
||||
assertUnoptimized(Get);
|
||||
%PrepareFunctionForOptimization(Get);
|
||||
assertEquals(expected_value, Get(dv));
|
||||
assertEquals(expected_value, Get(dv));
|
||||
%OptimizeFunctionOnNextCall(Get);
|
||||
assertEquals(expected_value, Get(dv));
|
||||
assertOptimized(Get);
|
||||
|
||||
// Enough for one element or more (even with offset).
|
||||
blen = Resize(ab, 8 + offset);
|
||||
assertEquals(expected_value, Get(dv));
|
||||
assertOptimized(Get);
|
||||
|
||||
blen = Resize(ab, 0); // Not enough for one element.
|
||||
if (shared) {
|
||||
assertEquals(expected_value, Get(dv));
|
||||
} else {
|
||||
if (!length_tracking || with_offset) {
|
||||
// DataView is out of bounds.
|
||||
assertThrows(() => { Get(dv); }, TypeError);
|
||||
} else {
|
||||
// DataView is valid, the index is out of bounds.
|
||||
assertThrows(() => { Get(dv); }, RangeError);
|
||||
}
|
||||
}
|
||||
|
||||
blen = Resize(ab, 64);
|
||||
assertEquals(expected_value, Get(dv));
|
||||
|
||||
if (!shared) {
|
||||
%ArrayBufferDetach(ab);
|
||||
assertThrows(() => { Get(dv); }, TypeError);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})();
|
||||
|
||||
(function() {
|
||||
function Read_TA_RAB_LengthTracking_Mixed(ta, index) {
|
||||
return ta[index];
|
||||
|
Loading…
Reference in New Issue
Block a user