Files
ladybird/Tests/LibJS/Bytecode/input/indexed-append-guards.js
Andreas Kling b4185f0ecd LibJS: Split packed and holey asm indexed fast paths
Use dedicated Packed branches in GetByValue and PutByValue so
in-bounds indexed accesses can skip hole checks and slot
reloads.

Keep Holey writes on the guarded arm, and keep append writes on
the C++ slow path so PutByValue still respects non-extensible
indexed objects and arrays with a non-writable length.

Add a bytecode regression that exercises both append failure
cases through the real js binary path.
2026-03-17 22:28:35 -05:00

32 lines
767 B
JavaScript

"use strict";
function expect_type_error(callback) {
let did_throw = false;
try {
callback();
} catch (error) {
if (!(error instanceof TypeError))
throw error;
did_throw = true;
}
if (!did_throw)
throw new Error("Expected TypeError");
}
let object = Object.preventExtensions({ 0: 1 });
expect_type_error(() => {
object[1] = 2;
});
if (object[1] !== undefined)
throw new Error("Indexed object append mutated");
let array = [1, 2];
Object.defineProperty(array, "length", { writable: false });
expect_type_error(() => {
array[array.length] = 3;
});
if (array.length !== 2)
throw new Error("Array length changed");
if (array[2] !== undefined)
throw new Error("Array append mutated");