mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 22:17:45 +00:00
LibJS: Instantiate primitive array expressions using a single operation
This will not meaningfully affect short array literals, but it does give us a bit of extra perf when evaluating huge array expressions like in Kraken/imaging-darkroom.js
This commit is contained in:
parent
5e3a799e97
commit
f19349e1b6
7 changed files with 92 additions and 6 deletions
|
@ -8,6 +8,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/FixedArray.h>
|
||||
#include <AK/StdLibExtras.h>
|
||||
#include <LibCrypto/BigInt/SignedBigInteger.h>
|
||||
#include <LibJS/Bytecode/Builtins.h>
|
||||
|
@ -313,6 +314,23 @@ private:
|
|||
Register m_elements[];
|
||||
};
|
||||
|
||||
class NewPrimitiveArray final : public Instruction {
|
||||
public:
|
||||
explicit NewPrimitiveArray(FixedArray<Value> values)
|
||||
: Instruction(Type::NewPrimitiveArray, sizeof(*this))
|
||||
, m_values(move(values))
|
||||
{
|
||||
}
|
||||
|
||||
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
||||
DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const;
|
||||
|
||||
ReadonlySpan<Value> values() const { return m_values.span(); }
|
||||
|
||||
private:
|
||||
FixedArray<Value> m_values;
|
||||
};
|
||||
|
||||
class Append final : public Instruction {
|
||||
public:
|
||||
Append(Register lhs, bool is_spread)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue