MCPcopy Create free account
hub / github.com/nodejs/node / VerifyBoundsCheck

Function VerifyBoundsCheck

deps/v8/test/mjsunit/wasm/atomics.js:131–146  ·  view source on GitHub ↗
(func, memtype_size)

Source from the content-addressed store, hash-verified

129}
130
131function VerifyBoundsCheck(func, memtype_size) {
132 const kPageSize = 65536;
133 // Test out of bounds at boundary
134 for (let i = memory.buffer.byteLength - memtype_size + 1;
135 i < memory.buffer.byteLength + memtype_size + 4; i++) {
136 assertTrapsOneOf(
137 // If an underlying platform uses traps for a bounds check,
138 // kTrapUnalignedAccess will be thrown before kTrapMemOutOfBounds.
139 // Otherwise, kTrapMemOutOfBounds will be first.
140 [kTrapMemOutOfBounds, kTrapUnalignedAccess],
141 () => func(i, 5, 10)
142 );
143 }
144 // Test out of bounds at maximum + 1
145 assertTraps(kTrapMemOutOfBounds, () => func((maxSize + 1) * kPageSize, 5, 1));
146}
147
148// Test many elements in the small range, make bigger steps later. This is still
149// O(2^n), but takes 213 steps to reach 2^32.

Callers 6

Test32OpFunction · 0.85
Test16OpFunction · 0.85
Test8OpFunction · 0.85
TestCmpExchangeFunction · 0.85
TestLoadFunction · 0.85
TestStoreFunction · 0.85

Calls 3

assertTrapsOneOfFunction · 0.85
funcFunction · 0.70
assertTrapsFunction · 0.70

Tested by

no test coverage detected