mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 13:17:35 +00:00
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);
This commit is contained in:
parent
8d68f94282
commit
350e6c54d7
8 changed files with 26 additions and 96 deletions
|
@ -1492,28 +1492,6 @@ public:
|
|||
DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const;
|
||||
};
|
||||
|
||||
class IteratorResultDone final : public Instruction {
|
||||
public:
|
||||
IteratorResultDone()
|
||||
: Instruction(Type::IteratorResultDone, sizeof(*this))
|
||||
{
|
||||
}
|
||||
|
||||
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
||||
DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const;
|
||||
};
|
||||
|
||||
class IteratorResultValue final : public Instruction {
|
||||
public:
|
||||
IteratorResultValue()
|
||||
: Instruction(Type::IteratorResultValue, sizeof(*this))
|
||||
{
|
||||
}
|
||||
|
||||
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
||||
DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const;
|
||||
};
|
||||
|
||||
class ResolveThisBinding final : public Instruction {
|
||||
public:
|
||||
explicit ResolveThisBinding()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue