mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 23:50:19 +00:00
LibJS: Add fast path for Array.length in the bytecode interpreter
13.8% speed-up on Kraken/ai-astar.js in interpreter mode. :^)
This commit is contained in:
parent
514af065a5
commit
9fcd6776cf
Notes:
sideshowbarker
2024-07-17 00:57:24 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/9fcd6776cf Pull-request: https://github.com/SerenityOS/serenity/pull/22969
1 changed files with 5 additions and 0 deletions
|
@ -84,6 +84,11 @@ inline ThrowCompletionOr<Value> get_by_id(VM& vm, DeprecatedFlyString const& pro
|
|||
|
||||
auto base_obj = TRY(base_object_for_get(vm, base_value));
|
||||
|
||||
// OPTIMIZATION: Fast path for the magical "length" property on Array objects.
|
||||
if (base_obj->has_magical_length_property() && property == vm.names.length.as_string()) {
|
||||
return Value { base_obj->indexed_properties().array_like_size() };
|
||||
}
|
||||
|
||||
// OPTIMIZATION: If the shape of the object hasn't changed, we can use the cached property offset.
|
||||
auto& shape = base_obj->shape();
|
||||
if (&shape == cache.shape) {
|
||||
|
|
Loading…
Reference in a new issue