1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 03:07:43 +00:00
serenity/Userland/Libraries/LibJS/JIT
Andreas Kling 350e6c54d7 LibJS: Remove dedicated iterator result instructions in favor of GetById
When iterating over an iterable, we get back a JS object with the fields
"value" and "done".

Before this change, we've had two dedicated instructions for retrieving
the two fields: IteratorResultValue and IteratorResultDone. These had no
fast path whatsoever and just did a generic [[Get]] access to fetch the
corresponding property values.

By replacing the instructions with GetById("value") and GetById("done"),
they instantly get caching and JIT fast paths for free, making iterating
over iterables much faster. :^)

26% speed-up on this microbenchmark:

    function go(a) {
        for (const p of a) {
        }
    }
    const a = [];
    a.length = 1_000_000;
    go(a);
2023-12-07 18:12:24 +01:00
..
Compiler.cpp LibJS: Remove dedicated iterator result instructions in favor of GetById 2023-12-07 18:12:24 +01:00
Compiler.h LibJS: Remove dedicated iterator result instructions in favor of GetById 2023-12-07 18:12:24 +01:00
NativeExecutable.cpp LibJS: Always allocate ExecutionContext objects on the malloc heap 2023-11-29 09:48:18 +01:00
NativeExecutable.h LibJS/JIT: Support alternative entry point blocks 2023-11-03 07:31:11 +01:00