mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-26 01:35:08 +02:00
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.
32 lines
767 B
JavaScript
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");
|