2021-06-03 10:46:30 +02:00
|
|
|
/*
|
2024-10-04 13:19:50 +02:00
|
|
|
* Copyright (c) 2021-2023, Andreas Kling <andreas@ladybird.org>
|
2021-06-07 21:13:37 +01:00
|
|
|
* Copyright (c) 2021, Linus Groh <linusg@serenityos.org>
|
2021-06-09 18:18:56 +02:00
|
|
|
* Copyright (c) 2021, Gunnar Beutner <gbeutner@serenityos.org>
|
2021-06-03 10:46:30 +02:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2023-11-17 22:07:23 +02:00
|
|
|
#include <AK/FixedArray.h>
|
2022-09-09 16:47:42 +02:00
|
|
|
#include <AK/StdLibExtras.h>
|
2021-06-08 07:59:25 +02:00
|
|
|
#include <LibCrypto/BigInt/SignedBigInteger.h>
|
2023-11-17 11:48:30 +01:00
|
|
|
#include <LibJS/Bytecode/Builtins.h>
|
2021-10-24 15:34:30 +02:00
|
|
|
#include <LibJS/Bytecode/IdentifierTable.h>
|
2021-06-03 10:46:30 +02:00
|
|
|
#include <LibJS/Bytecode/Instruction.h>
|
2021-06-04 12:07:38 +02:00
|
|
|
#include <LibJS/Bytecode/Label.h>
|
2024-02-04 08:00:54 +01:00
|
|
|
#include <LibJS/Bytecode/Operand.h>
|
2023-07-13 10:49:07 +02:00
|
|
|
#include <LibJS/Bytecode/RegexTable.h>
|
2021-06-03 10:46:30 +02:00
|
|
|
#include <LibJS/Bytecode/Register.h>
|
2024-05-07 21:36:56 +02:00
|
|
|
#include <LibJS/Bytecode/ScopedOperand.h>
|
2021-06-09 10:02:01 +02:00
|
|
|
#include <LibJS/Bytecode/StringTable.h>
|
2021-06-03 10:46:30 +02:00
|
|
|
#include <LibJS/Heap/Cell.h>
|
2021-07-01 12:24:46 +02:00
|
|
|
#include <LibJS/Runtime/Environment.h>
|
2023-07-19 06:54:48 -04:00
|
|
|
#include <LibJS/Runtime/Iterator.h>
|
2021-06-03 10:46:30 +02:00
|
|
|
#include <LibJS/Runtime/Value.h>
|
2022-02-12 00:48:23 -08:00
|
|
|
#include <LibJS/Runtime/ValueTraits.h>
|
2021-06-03 10:46:30 +02:00
|
|
|
|
2023-06-23 14:27:42 +02:00
|
|
|
namespace JS {
|
|
|
|
class FunctionExpression;
|
|
|
|
}
|
|
|
|
|
2021-06-03 10:46:30 +02:00
|
|
|
namespace JS::Bytecode::Op {
|
|
|
|
|
2024-05-05 22:06:55 +02:00
|
|
|
class CreateRestParams final : public Instruction {
|
|
|
|
public:
|
|
|
|
CreateRestParams(Operand dst, u32 rest_index)
|
|
|
|
: Instruction(Type::CreateRestParams)
|
|
|
|
, m_dst(dst)
|
|
|
|
, m_rest_index(rest_index)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2024-05-12 18:49:03 +02:00
|
|
|
void visit_operands_impl(Function<void(Operand&)> visitor)
|
|
|
|
{
|
|
|
|
visitor(m_dst);
|
|
|
|
}
|
2024-05-05 22:06:55 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
Operand m_dst;
|
|
|
|
u32 m_rest_index;
|
|
|
|
};
|
|
|
|
|
|
|
|
class CreateArguments final : public Instruction {
|
|
|
|
public:
|
|
|
|
enum class Kind {
|
|
|
|
Mapped,
|
|
|
|
Unmapped,
|
|
|
|
};
|
|
|
|
|
2024-05-21 09:32:51 +01:00
|
|
|
CreateArguments(Optional<Operand> dst, Kind kind, bool is_immutable)
|
2024-05-05 22:06:55 +02:00
|
|
|
: Instruction(Type::CreateArguments)
|
2024-05-21 09:32:51 +01:00
|
|
|
, m_dst(dst)
|
2024-05-05 22:06:55 +02:00
|
|
|
, m_kind(kind)
|
|
|
|
, m_is_immutable(is_immutable)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2024-05-21 09:32:51 +01:00
|
|
|
void visit_operands_impl(Function<void(Operand&)> visitor)
|
|
|
|
{
|
|
|
|
if (m_dst.has_value())
|
|
|
|
visitor(m_dst.value());
|
|
|
|
}
|
2024-05-05 22:06:55 +02:00
|
|
|
|
|
|
|
private:
|
2024-05-21 09:32:51 +01:00
|
|
|
Optional<Operand> m_dst;
|
2024-05-05 22:06:55 +02:00
|
|
|
Kind m_kind;
|
|
|
|
bool m_is_immutable { false };
|
|
|
|
};
|
|
|
|
|
2024-02-04 08:00:54 +01:00
|
|
|
class Mov final : public Instruction {
|
2021-06-03 10:46:30 +02:00
|
|
|
public:
|
2024-02-04 08:00:54 +01:00
|
|
|
Mov(Operand dst, Operand src)
|
2024-05-06 11:09:09 +02:00
|
|
|
: Instruction(Type::Mov)
|
2021-06-07 22:05:09 +02:00
|
|
|
, m_dst(dst)
|
2024-02-04 08:00:54 +01:00
|
|
|
, m_src(src)
|
2021-06-07 22:05:09 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2023-12-16 17:49:34 +03:30
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2024-05-12 18:49:03 +02:00
|
|
|
void visit_operands_impl(Function<void(Operand&)> visitor)
|
|
|
|
{
|
|
|
|
visitor(m_dst);
|
|
|
|
visitor(m_src);
|
|
|
|
}
|
2021-06-07 22:05:09 +02:00
|
|
|
|
2024-02-04 08:00:54 +01:00
|
|
|
Operand dst() const { return m_dst; }
|
|
|
|
Operand src() const { return m_src; }
|
2022-10-22 20:21:08 +02:00
|
|
|
|
2021-06-07 22:05:09 +02:00
|
|
|
private:
|
2024-02-04 08:00:54 +01:00
|
|
|
Operand m_dst;
|
|
|
|
Operand m_src;
|
2021-06-07 22:05:09 +02:00
|
|
|
};
|
|
|
|
|
2024-02-20 11:59:46 +01:00
|
|
|
#define JS_ENUMERATE_COMMON_BINARY_OPS_WITH_FAST_PATH(O) \
|
|
|
|
O(Add, add) \
|
|
|
|
O(BitwiseAnd, bitwise_and) \
|
|
|
|
O(BitwiseOr, bitwise_or) \
|
|
|
|
O(BitwiseXor, bitwise_xor) \
|
|
|
|
O(GreaterThan, greater_than) \
|
|
|
|
O(GreaterThanEquals, greater_than_equals) \
|
2024-03-04 10:01:40 +01:00
|
|
|
O(LeftShift, left_shift) \
|
2024-02-20 11:59:46 +01:00
|
|
|
O(LessThan, less_than) \
|
|
|
|
O(LessThanEquals, less_than_equals) \
|
|
|
|
O(Mul, mul) \
|
|
|
|
O(RightShift, right_shift) \
|
|
|
|
O(Sub, sub) \
|
2021-06-07 23:08:35 +02:00
|
|
|
O(UnsignedRightShift, unsigned_right_shift)
|
|
|
|
|
2024-02-20 11:59:46 +01:00
|
|
|
#define JS_ENUMERATE_COMMON_BINARY_OPS_WITHOUT_FAST_PATH(O) \
|
|
|
|
O(Div, div) \
|
|
|
|
O(Exp, exp) \
|
|
|
|
O(Mod, mod) \
|
|
|
|
O(In, in) \
|
|
|
|
O(InstanceOf, instance_of) \
|
|
|
|
O(LooselyInequals, loosely_inequals) \
|
|
|
|
O(LooselyEquals, loosely_equals) \
|
|
|
|
O(StrictlyInequals, strict_inequals) \
|
2024-03-04 10:01:40 +01:00
|
|
|
O(StrictlyEquals, strict_equals)
|
2024-02-20 11:59:46 +01:00
|
|
|
|
2024-03-06 08:36:19 +01:00
|
|
|
#define JS_DECLARE_COMMON_BINARY_OP(OpTitleCase, op_snake_case) \
|
|
|
|
class OpTitleCase final : public Instruction { \
|
|
|
|
public: \
|
|
|
|
explicit OpTitleCase(Operand dst, Operand lhs, Operand rhs) \
|
2024-05-06 11:09:09 +02:00
|
|
|
: Instruction(Type::OpTitleCase) \
|
2024-03-06 08:36:19 +01:00
|
|
|
, m_dst(dst) \
|
|
|
|
, m_lhs(lhs) \
|
|
|
|
, m_rhs(rhs) \
|
|
|
|
{ \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const; \
|
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const; \
|
2024-05-12 18:49:03 +02:00
|
|
|
void visit_operands_impl(Function<void(Operand&)> visitor) \
|
|
|
|
{ \
|
|
|
|
visitor(m_dst); \
|
|
|
|
visitor(m_lhs); \
|
|
|
|
visitor(m_rhs); \
|
|
|
|
} \
|
2024-03-06 08:36:19 +01:00
|
|
|
\
|
|
|
|
Operand dst() const { return m_dst; } \
|
|
|
|
Operand lhs() const { return m_lhs; } \
|
|
|
|
Operand rhs() const { return m_rhs; } \
|
|
|
|
\
|
|
|
|
private: \
|
|
|
|
Operand m_dst; \
|
|
|
|
Operand m_lhs; \
|
|
|
|
Operand m_rhs; \
|
2021-06-07 23:08:35 +02:00
|
|
|
};
|
|
|
|
|
2024-02-20 11:59:46 +01:00
|
|
|
JS_ENUMERATE_COMMON_BINARY_OPS_WITHOUT_FAST_PATH(JS_DECLARE_COMMON_BINARY_OP)
|
|
|
|
JS_ENUMERATE_COMMON_BINARY_OPS_WITH_FAST_PATH(JS_DECLARE_COMMON_BINARY_OP)
|
2021-06-07 23:08:35 +02:00
|
|
|
#undef JS_DECLARE_COMMON_BINARY_OP
|
|
|
|
|
|
|
|
#define JS_ENUMERATE_COMMON_UNARY_OPS(O) \
|
|
|
|
O(BitwiseNot, bitwise_not) \
|
|
|
|
O(Not, not_) \
|
|
|
|
O(UnaryPlus, unary_plus) \
|
|
|
|
O(UnaryMinus, unary_minus) \
|
|
|
|
O(Typeof, typeof_)
|
|
|
|
|
2024-03-06 08:36:19 +01:00
|
|
|
#define JS_DECLARE_COMMON_UNARY_OP(OpTitleCase, op_snake_case) \
|
|
|
|
class OpTitleCase final : public Instruction { \
|
|
|
|
public: \
|
|
|
|
OpTitleCase(Operand dst, Operand src) \
|
2024-05-06 11:09:09 +02:00
|
|
|
: Instruction(Type::OpTitleCase) \
|
2024-03-06 08:36:19 +01:00
|
|
|
, m_dst(dst) \
|
|
|
|
, m_src(src) \
|
|
|
|
{ \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const; \
|
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const; \
|
2024-05-12 18:49:03 +02:00
|
|
|
void visit_operands_impl(Function<void(Operand&)> visitor) \
|
|
|
|
{ \
|
|
|
|
visitor(m_dst); \
|
|
|
|
visitor(m_src); \
|
|
|
|
} \
|
2024-03-06 08:36:19 +01:00
|
|
|
\
|
|
|
|
Operand dst() const { return m_dst; } \
|
|
|
|
Operand src() const { return m_src; } \
|
|
|
|
\
|
|
|
|
private: \
|
|
|
|
Operand m_dst; \
|
|
|
|
Operand m_src; \
|
2021-06-07 23:08:35 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
JS_ENUMERATE_COMMON_UNARY_OPS(JS_DECLARE_COMMON_UNARY_OP)
|
|
|
|
#undef JS_DECLARE_COMMON_UNARY_OP
|
2021-06-07 19:53:47 +01:00
|
|
|
|
2021-06-04 20:30:23 +02:00
|
|
|
class NewObject final : public Instruction {
|
|
|
|
public:
|
2024-02-04 08:00:54 +01:00
|
|
|
explicit NewObject(Operand dst)
|
2024-05-06 11:09:09 +02:00
|
|
|
: Instruction(Type::NewObject)
|
2024-02-04 08:00:54 +01:00
|
|
|
, m_dst(dst)
|
2021-06-04 20:30:23 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2024-05-10 17:32:19 +02:00
|
|
|
void execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 17:49:34 +03:30
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2024-05-12 18:49:03 +02:00
|
|
|
void visit_operands_impl(Function<void(Operand&)> visitor)
|
|
|
|
{
|
|
|
|
visitor(m_dst);
|
|
|
|
}
|
2024-02-04 08:00:54 +01:00
|
|
|
|
|
|
|
Operand dst() const { return m_dst; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
Operand m_dst;
|
2021-06-04 20:30:23 +02:00
|
|
|
};
|
|
|
|
|
2021-06-19 17:17:40 -07:00
|
|
|
class NewRegExp final : public Instruction {
|
|
|
|
public:
|
2024-02-04 08:00:54 +01:00
|
|
|
NewRegExp(Operand dst, StringTableIndex source_index, StringTableIndex flags_index, RegexTableIndex regex_index)
|
2024-05-06 11:09:09 +02:00
|
|
|
: Instruction(Type::NewRegExp)
|
2024-02-04 08:00:54 +01:00
|
|
|
, m_dst(dst)
|
2021-06-19 17:17:40 -07:00
|
|
|
, m_source_index(source_index)
|
|
|
|
, m_flags_index(flags_index)
|
2023-07-13 10:49:07 +02:00
|
|
|
, m_regex_index(regex_index)
|
2021-06-19 17:17:40 -07:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2024-05-10 17:32:19 +02:00
|
|
|
void execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 17:49:34 +03:30
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2024-05-12 18:49:03 +02:00
|
|
|
void visit_operands_impl(Function<void(Operand&)> visitor)
|
|
|
|
{
|
|
|
|
visitor(m_dst);
|
|
|
|
}
|
2021-06-19 17:17:40 -07:00
|
|
|
|
2024-02-04 08:00:54 +01:00
|
|
|
Operand dst() const { return m_dst; }
|
2023-10-27 17:07:30 +02:00
|
|
|
StringTableIndex source_index() const { return m_source_index; }
|
|
|
|
StringTableIndex flags_index() const { return m_flags_index; }
|
|
|
|
RegexTableIndex regex_index() const { return m_regex_index; }
|
|
|
|
|
2021-06-19 17:17:40 -07:00
|
|
|
private:
|
2024-02-04 08:00:54 +01:00
|
|
|
Operand m_dst;
|
2021-06-19 17:17:40 -07:00
|
|
|
StringTableIndex m_source_index;
|
|
|
|
StringTableIndex m_flags_index;
|
2023-07-13 10:49:07 +02:00
|
|
|
RegexTableIndex m_regex_index;
|
2021-06-19 17:17:40 -07:00
|
|
|
};
|
|
|
|
|
2022-12-09 18:48:57 +00:00
|
|
|
#define JS_ENUMERATE_NEW_BUILTIN_ERROR_OPS(O) \
|
|
|
|
O(TypeError)
|
|
|
|
|
2024-05-10 17:32:19 +02:00
|
|
|
#define JS_DECLARE_NEW_BUILTIN_ERROR_OP(ErrorName) \
|
|
|
|
class New##ErrorName final : public Instruction { \
|
|
|
|
public: \
|
|
|
|
New##ErrorName(Operand dst, StringTableIndex error_string) \
|
|
|
|
: Instruction(Type::New##ErrorName) \
|
|
|
|
, m_dst(dst) \
|
|
|
|
, m_error_string(error_string) \
|
|
|
|
{ \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
void execute_impl(Bytecode::Interpreter&) const; \
|
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const; \
|
2024-05-12 18:49:03 +02:00
|
|
|
void visit_operands_impl(Function<void(Operand&)> visitor) \
|
|
|
|
{ \
|
|
|
|
visitor(m_dst); \
|
|
|
|
} \
|
2024-05-10 17:32:19 +02:00
|
|
|
\
|
|
|
|
Operand dst() const { return m_dst; } \
|
|
|
|
StringTableIndex error_string() const { return m_error_string; } \
|
|
|
|
\
|
|
|
|
private: \
|
|
|
|
Operand m_dst; \
|
|
|
|
StringTableIndex m_error_string; \
|
2022-12-09 18:48:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
JS_ENUMERATE_NEW_BUILTIN_ERROR_OPS(JS_DECLARE_NEW_BUILTIN_ERROR_OP)
|
|
|
|
#undef JS_DECLARE_NEW_BUILTIN_ERROR_OP
|
|
|
|
|
2021-06-13 15:30:32 -07:00
|
|
|
// NOTE: This instruction is variable-width depending on the number of excluded names
|
|
|
|
class CopyObjectExcludingProperties final : public Instruction {
|
|
|
|
public:
|
2024-05-06 10:42:52 +02:00
|
|
|
static constexpr bool IsVariableLength = true;
|
|
|
|
|
2024-05-07 21:36:56 +02:00
|
|
|
CopyObjectExcludingProperties(Operand dst, Operand from_object, Vector<ScopedOperand> const& excluded_names)
|
2024-05-06 11:09:09 +02:00
|
|
|
: Instruction(Type::CopyObjectExcludingProperties)
|
2024-02-04 08:00:54 +01:00
|
|
|
, m_dst(dst)
|
2021-06-13 15:30:32 -07:00
|
|
|
, m_from_object(from_object)
|
|
|
|
, m_excluded_names_count(excluded_names.size())
|
|
|
|
{
|
|
|
|
for (size_t i = 0; i < m_excluded_names_count; i++)
|
|
|
|
m_excluded_names[i] = excluded_names[i];
|
|
|
|
}
|
|
|
|
|
2022-02-07 14:36:45 +01:00
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 17:49:34 +03:30
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2024-05-12 18:49:03 +02:00
|
|
|
void visit_operands_impl(Function<void(Operand&)> visitor)
|
|
|
|
{
|
|
|
|
visitor(m_dst);
|
|
|
|
visitor(m_from_object);
|
|
|
|
for (size_t i = 0; i < m_excluded_names_count; i++)
|
|
|
|
visitor(m_excluded_names[i]);
|
|
|
|
}
|
2021-06-13 15:30:32 -07:00
|
|
|
|
2024-05-06 11:09:09 +02:00
|
|
|
size_t length_impl() const
|
2023-09-13 21:32:51 +02:00
|
|
|
{
|
2024-05-06 11:09:09 +02:00
|
|
|
return round_up_to_power_of_two(alignof(void*), sizeof(*this) + sizeof(Operand) * m_excluded_names_count);
|
2023-09-13 21:32:51 +02:00
|
|
|
}
|
2021-06-13 15:30:32 -07:00
|
|
|
|
2024-02-04 08:00:54 +01:00
|
|
|
Operand dst() const { return m_dst; }
|
|
|
|
Operand from_object() const { return m_from_object; }
|
2023-10-30 02:00:53 +01:00
|
|
|
size_t excluded_names_count() const { return m_excluded_names_count; }
|
2024-02-04 08:00:54 +01:00
|
|
|
Operand const* excluded_names() const { return m_excluded_names; }
|
2023-10-30 02:00:53 +01:00
|
|
|
|
2021-06-13 15:30:32 -07:00
|
|
|
private:
|
2024-02-04 08:00:54 +01:00
|
|
|
Operand m_dst;
|
|
|
|
Operand m_from_object;
|
2021-06-13 15:30:32 -07:00
|
|
|
size_t m_excluded_names_count { 0 };
|
2024-02-04 08:00:54 +01:00
|
|
|
Operand m_excluded_names[];
|
2021-06-13 15:30:32 -07:00
|
|
|
};
|
|
|
|
|
2021-06-08 23:06:52 +02:00
|
|
|
// NOTE: This instruction is variable-width depending on the number of elements!
|
|
|
|
class NewArray final : public Instruction {
|
|
|
|
public:
|
2024-05-06 10:42:52 +02:00
|
|
|
static constexpr bool IsVariableLength = true;
|
|
|
|
|
2024-02-04 08:00:54 +01:00
|
|
|
explicit NewArray(Operand dst)
|
2024-05-06 11:09:09 +02:00
|
|
|
: Instruction(Type::NewArray)
|
2024-02-04 08:00:54 +01:00
|
|
|
, m_dst(dst)
|
2021-06-13 14:06:26 -07:00
|
|
|
, m_element_count(0)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2024-05-08 12:43:08 +02:00
|
|
|
NewArray(Operand dst, ReadonlySpan<ScopedOperand> elements)
|
2024-05-06 11:09:09 +02:00
|
|
|
: Instruction(Type::NewArray)
|
2024-02-04 08:00:54 +01:00
|
|
|
, m_dst(dst)
|
2024-05-08 12:43:08 +02:00
|
|
|
, m_element_count(elements.size())
|
2021-06-08 23:06:52 +02:00
|
|
|
{
|
2024-05-08 12:43:08 +02:00
|
|
|
for (size_t i = 0; i < m_element_count; ++i)
|
|
|
|
m_elements[i] = elements[i];
|
2021-06-08 23:06:52 +02:00
|
|
|
}
|
|
|
|
|
2024-05-10 17:32:19 +02:00
|
|
|
void execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 17:49:34 +03:30
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2024-05-12 18:49:03 +02:00
|
|
|
void visit_operands_impl(Function<void(Operand&)> visitor)
|
|
|
|
{
|
|
|
|
visitor(m_dst);
|
|
|
|
for (size_t i = 0; i < m_element_count; i++)
|
|
|
|
visitor(m_elements[i]);
|
|
|
|
}
|
2021-06-08 23:06:52 +02:00
|
|
|
|
2024-02-04 08:00:54 +01:00
|
|
|
Operand dst() const { return m_dst; }
|
|
|
|
|
2024-05-06 11:09:09 +02:00
|
|
|
size_t length_impl() const
|
2021-06-13 20:40:20 +04:30
|
|
|
{
|
2024-05-08 12:43:08 +02:00
|
|
|
return round_up_to_power_of_two(alignof(void*), sizeof(*this) + sizeof(Operand) * m_element_count);
|
2022-10-22 20:21:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
size_t element_count() const { return m_element_count; }
|
|
|
|
|
2021-06-08 23:06:52 +02:00
|
|
|
private:
|
2024-02-04 08:00:54 +01:00
|
|
|
Operand m_dst;
|
2021-06-08 23:06:52 +02:00
|
|
|
size_t m_element_count { 0 };
|
2024-02-04 08:00:54 +01:00
|
|
|
Operand m_elements[];
|
2021-06-08 23:06:52 +02:00
|
|
|
};
|
|
|
|
|
2023-11-17 22:07:23 +02:00
|
|
|
class NewPrimitiveArray final : public Instruction {
|
|
|
|
public:
|
2024-05-06 10:42:52 +02:00
|
|
|
static constexpr bool IsVariableLength = true;
|
|
|
|
|
2024-03-03 12:37:28 +01:00
|
|
|
NewPrimitiveArray(Operand dst, ReadonlySpan<Value> elements)
|
2024-05-06 11:09:09 +02:00
|
|
|
: Instruction(Type::NewPrimitiveArray)
|
2024-02-04 08:00:54 +01:00
|
|
|
, m_dst(dst)
|
2024-03-03 12:37:28 +01:00
|
|
|
, m_element_count(elements.size())
|
2023-11-17 22:07:23 +02:00
|
|
|
{
|
2024-03-03 12:37:28 +01:00
|
|
|
for (size_t i = 0; i < m_element_count; ++i)
|
|
|
|
m_elements[i] = elements[i];
|
|
|
|
}
|
|
|
|
|
2024-05-06 11:09:09 +02:00
|
|
|
size_t length_impl() const
|
2024-03-03 12:37:28 +01:00
|
|
|
{
|
2024-05-06 11:09:09 +02:00
|
|
|
return round_up_to_power_of_two(alignof(void*), sizeof(*this) + sizeof(Value) * m_element_count);
|
2023-11-17 22:07:23 +02:00
|
|
|
}
|
|
|
|
|
2024-05-10 17:32:19 +02:00
|
|
|
void execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 17:49:34 +03:30
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2024-05-12 18:49:03 +02:00
|
|
|
void visit_operands_impl(Function<void(Operand&)> visitor)
|
|
|
|
{
|
|
|
|
visitor(m_dst);
|
|
|
|
}
|
2023-11-17 22:07:23 +02:00
|
|
|
|
2024-02-04 08:00:54 +01:00
|
|
|
Operand dst() const { return m_dst; }
|
2024-03-03 12:37:28 +01:00
|
|
|
ReadonlySpan<Value> elements() const { return { m_elements, m_element_count }; }
|
2023-11-17 22:07:23 +02:00
|
|
|
|
|
|
|
private:
|
2024-02-04 08:00:54 +01:00
|
|
|
Operand m_dst;
|
2024-03-03 12:37:28 +01:00
|
|
|
size_t m_element_count { 0 };
|
|
|
|
Value m_elements[];
|
2023-11-17 22:07:23 +02:00
|
|
|
};
|
|
|
|
|
2024-05-11 22:54:41 +00:00
|
|
|
class AddPrivateName final : public Instruction {
|
|
|
|
public:
|
|
|
|
explicit AddPrivateName(IdentifierTableIndex name)
|
|
|
|
: Instruction(Type::AddPrivateName)
|
|
|
|
, m_name(name)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void execute_impl(Bytecode::Interpreter&) const;
|
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
IdentifierTableIndex m_name;
|
|
|
|
};
|
|
|
|
|
2024-02-04 08:00:54 +01:00
|
|
|
class ArrayAppend final : public Instruction {
|
2022-09-09 15:23:02 +02:00
|
|
|
public:
|
2024-02-04 08:00:54 +01:00
|
|
|
ArrayAppend(Operand dst, Operand src, bool is_spread)
|
2024-05-06 11:09:09 +02:00
|
|
|
: Instruction(Type::ArrayAppend)
|
2024-02-04 08:00:54 +01:00
|
|
|
, m_dst(dst)
|
|
|
|
, m_src(src)
|
2022-09-09 15:23:02 +02:00
|
|
|
, m_is_spread(is_spread)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 17:49:34 +03:30
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2024-05-12 18:49:03 +02:00
|
|
|
void visit_operands_impl(Function<void(Operand&)> visitor)
|
|
|
|
{
|
|
|
|
visitor(m_dst);
|
|
|
|
visitor(m_src);
|
|
|
|
}
|
2022-10-22 20:19:16 +02:00
|
|
|
|
2024-02-04 08:00:54 +01:00
|
|
|
Operand dst() const { return m_dst; }
|
|
|
|
Operand src() const { return m_src; }
|
2023-10-29 17:25:49 +01:00
|
|
|
bool is_spread() const { return m_is_spread; }
|
|
|
|
|
2022-09-09 15:23:02 +02:00
|
|
|
private:
|
2024-02-04 08:00:54 +01:00
|
|
|
Operand m_dst;
|
|
|
|
Operand m_src;
|
2022-09-09 15:23:02 +02:00
|
|
|
bool m_is_spread = false;
|
|
|
|
};
|
|
|
|
|
2023-06-24 15:22:16 +02:00
|
|
|
class ImportCall final : public Instruction {
|
|
|
|
public:
|
2024-02-04 08:00:54 +01:00
|
|
|
ImportCall(Operand dst, Operand specifier, Operand options)
|
2024-05-06 11:09:09 +02:00
|
|
|
: Instruction(Type::ImportCall)
|
2024-02-04 08:00:54 +01:00
|
|
|
, m_dst(dst)
|
2023-06-24 15:22:16 +02:00
|
|
|
, m_specifier(specifier)
|
|
|
|
, m_options(options)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 17:49:34 +03:30
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2024-05-12 18:49:03 +02:00
|
|
|
void visit_operands_impl(Function<void(Operand&)> visitor)
|
|
|
|
{
|
|
|
|
visitor(m_dst);
|
|
|
|
visitor(m_specifier);
|
|
|
|
visitor(m_options);
|
|
|
|
}
|
2023-06-24 15:22:16 +02:00
|
|
|
|
2024-02-04 08:00:54 +01:00
|
|
|
Operand dst() const { return m_dst; }
|
|
|
|
Operand specifier() const { return m_specifier; }
|
|
|
|
Operand options() const { return m_options; }
|
2023-10-29 23:41:33 +01:00
|
|
|
|
2023-06-24 15:22:16 +02:00
|
|
|
private:
|
2024-02-04 08:00:54 +01:00
|
|
|
Operand m_dst;
|
|
|
|
Operand m_specifier;
|
|
|
|
Operand m_options;
|
2023-06-24 15:22:16 +02:00
|
|
|
};
|
|
|
|
|
2021-06-13 14:06:26 -07:00
|
|
|
class IteratorToArray final : public Instruction {
|
|
|
|
public:
|
2024-02-04 08:00:54 +01:00
|
|
|
explicit IteratorToArray(Operand dst, Operand iterator)
|
2024-05-06 11:09:09 +02:00
|
|
|
: Instruction(Type::IteratorToArray)
|
2024-02-04 08:00:54 +01:00
|
|
|
, m_dst(dst)
|
|
|
|
, m_iterator(iterator)
|
2021-06-13 14:06:26 -07:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2022-02-07 14:36:45 +01:00
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 17:49:34 +03:30
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2024-02-04 08:00:54 +01:00
|
|
|
|
|
|
|
Operand dst() const { return m_dst; }
|
|
|
|
Operand iterator() const { return m_iterator; }
|
|
|
|
|
2024-05-12 18:49:03 +02:00
|
|
|
void visit_operands_impl(Function<void(Operand&)> visitor)
|
|
|
|
{
|
|
|
|
visitor(m_dst);
|
|
|
|
visitor(m_iterator);
|
|
|
|
}
|
|
|
|
|
2024-02-04 08:00:54 +01:00
|
|
|
private:
|
|
|
|
Operand m_dst;
|
|
|
|
Operand m_iterator;
|
2021-06-13 14:06:26 -07:00
|
|
|
};
|
|
|
|
|
2021-06-07 20:58:36 -07:00
|
|
|
class ConcatString final : public Instruction {
|
|
|
|
public:
|
2024-02-04 08:00:54 +01:00
|
|
|
explicit ConcatString(Operand dst, Operand src)
|
2024-05-06 11:09:09 +02:00
|
|
|
: Instruction(Type::ConcatString)
|
2024-02-04 08:00:54 +01:00
|
|
|
, m_dst(dst)
|
|
|
|
, m_src(src)
|
2021-06-07 20:58:36 -07:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2022-02-07 14:36:45 +01:00
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 17:49:34 +03:30
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2021-06-07 20:58:36 -07:00
|
|
|
|
2024-02-04 08:00:54 +01:00
|
|
|
Operand dst() const { return m_dst; }
|
|
|
|
Operand src() const { return m_src; }
|
2023-10-29 00:06:54 +02:00
|
|
|
|
2024-05-12 18:49:03 +02:00
|
|
|
void visit_operands_impl(Function<void(Operand&)> visitor)
|
|
|
|
{
|
|
|
|
visitor(m_dst);
|
|
|
|
visitor(m_src);
|
|
|
|
}
|
|
|
|
|
2021-06-07 20:58:36 -07:00
|
|
|
private:
|
2024-02-04 08:00:54 +01:00
|
|
|
Operand m_dst;
|
|
|
|
Operand m_src;
|
2021-06-07 20:58:36 -07:00
|
|
|
};
|
|
|
|
|
2022-02-12 19:48:45 +03:30
|
|
|
enum class EnvironmentMode {
|
|
|
|
Lexical,
|
|
|
|
Var,
|
|
|
|
};
|
|
|
|
|
2024-05-14 11:30:30 +02:00
|
|
|
enum class BindingInitializationMode {
|
|
|
|
Initialize,
|
|
|
|
Set,
|
|
|
|
};
|
|
|
|
|
2023-06-16 16:43:24 +02:00
|
|
|
class CreateLexicalEnvironment final : public Instruction {
|
2022-02-12 19:48:45 +03:30
|
|
|
public:
|
2024-05-09 17:10:20 +02:00
|
|
|
explicit CreateLexicalEnvironment(u32 capacity = 0)
|
2024-05-06 11:09:09 +02:00
|
|
|
: Instruction(Type::CreateLexicalEnvironment)
|
2024-05-09 17:10:20 +02:00
|
|
|
, m_capacity(capacity)
|
2022-02-12 19:48:45 +03:30
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2024-05-10 17:32:19 +02:00
|
|
|
void execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 17:49:34 +03:30
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2024-05-09 17:10:20 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
u32 m_capacity { 0 };
|
2022-02-12 19:48:45 +03:30
|
|
|
};
|
|
|
|
|
2024-05-05 22:06:55 +02:00
|
|
|
class CreateVariableEnvironment final : public Instruction {
|
|
|
|
public:
|
2024-05-09 17:10:20 +02:00
|
|
|
explicit CreateVariableEnvironment(u32 capacity = 0)
|
2024-05-05 22:06:55 +02:00
|
|
|
: Instruction(Type::CreateVariableEnvironment)
|
2024-05-09 17:10:20 +02:00
|
|
|
, m_capacity(capacity)
|
2024-05-05 22:06:55 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2024-05-12 10:47:52 +02:00
|
|
|
void execute_impl(Bytecode::Interpreter&) const;
|
2024-05-05 22:06:55 +02:00
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2024-05-09 17:10:20 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
u32 m_capacity { 0 };
|
2024-05-05 22:06:55 +02:00
|
|
|
};
|
|
|
|
|
2024-05-11 22:54:41 +00:00
|
|
|
class CreatePrivateEnvironment final : public Instruction {
|
|
|
|
public:
|
|
|
|
explicit CreatePrivateEnvironment()
|
|
|
|
: Instruction(Type::CreatePrivateEnvironment)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void execute_impl(Bytecode::Interpreter&) const;
|
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
|
|
|
};
|
|
|
|
|
2022-03-13 16:01:18 +03:30
|
|
|
class EnterObjectEnvironment final : public Instruction {
|
|
|
|
public:
|
2024-02-04 08:00:54 +01:00
|
|
|
explicit EnterObjectEnvironment(Operand object)
|
2024-05-06 11:09:09 +02:00
|
|
|
: Instruction(Type::EnterObjectEnvironment)
|
2024-02-04 08:00:54 +01:00
|
|
|
, m_object(object)
|
2022-03-13 16:01:18 +03:30
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2023-11-11 23:19:46 +01:00
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 17:49:34 +03:30
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2024-02-04 08:00:54 +01:00
|
|
|
|
|
|
|
Operand object() const { return m_object; }
|
|
|
|
|
2024-05-12 18:49:03 +02:00
|
|
|
void visit_operands_impl(Function<void(Operand&)> visitor)
|
|
|
|
{
|
|
|
|
visitor(m_object);
|
|
|
|
}
|
|
|
|
|
2024-02-04 08:00:54 +01:00
|
|
|
private:
|
|
|
|
Operand m_object;
|
2023-11-11 23:19:46 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
class Catch final : public Instruction {
|
|
|
|
public:
|
2024-02-04 08:00:54 +01:00
|
|
|
explicit Catch(Operand dst)
|
2024-05-06 11:09:09 +02:00
|
|
|
: Instruction(Type::Catch)
|
2024-02-04 08:00:54 +01:00
|
|
|
, m_dst(dst)
|
2023-11-11 23:19:46 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2024-05-10 17:32:19 +02:00
|
|
|
void execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 17:49:34 +03:30
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2024-02-04 08:00:54 +01:00
|
|
|
|
|
|
|
Operand dst() const { return m_dst; }
|
|
|
|
|
2024-05-12 18:49:03 +02:00
|
|
|
void visit_operands_impl(Function<void(Operand&)> visitor)
|
|
|
|
{
|
|
|
|
visitor(m_dst);
|
|
|
|
}
|
|
|
|
|
2024-02-04 08:00:54 +01:00
|
|
|
private:
|
|
|
|
Operand m_dst;
|
2022-03-13 16:01:18 +03:30
|
|
|
};
|
|
|
|
|
2024-04-11 11:58:18 +02:00
|
|
|
class LeaveFinally final : public Instruction {
|
|
|
|
public:
|
|
|
|
explicit LeaveFinally()
|
2024-05-06 11:09:09 +02:00
|
|
|
: Instruction(Type::LeaveFinally)
|
2024-04-11 11:58:18 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2024-05-10 17:32:19 +02:00
|
|
|
void execute_impl(Bytecode::Interpreter&) const;
|
2024-04-11 11:58:18 +02:00
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
|
|
|
};
|
|
|
|
|
2024-04-11 11:07:35 +02:00
|
|
|
class RestoreScheduledJump final : public Instruction {
|
|
|
|
public:
|
|
|
|
explicit RestoreScheduledJump()
|
2024-05-06 11:09:09 +02:00
|
|
|
: Instruction(Type::RestoreScheduledJump)
|
2024-04-11 11:07:35 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2024-05-10 17:32:19 +02:00
|
|
|
void execute_impl(Bytecode::Interpreter&) const;
|
2024-04-11 11:07:35 +02:00
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
|
|
|
};
|
|
|
|
|
2022-02-12 19:48:45 +03:30
|
|
|
class CreateVariable final : public Instruction {
|
|
|
|
public:
|
2023-09-17 21:53:48 +12:00
|
|
|
explicit CreateVariable(IdentifierTableIndex identifier, EnvironmentMode mode, bool is_immutable, bool is_global = false, bool is_strict = false)
|
2024-05-06 11:09:09 +02:00
|
|
|
: Instruction(Type::CreateVariable)
|
2022-02-12 19:48:45 +03:30
|
|
|
, m_identifier(identifier)
|
|
|
|
, m_mode(mode)
|
|
|
|
, m_is_immutable(is_immutable)
|
2022-07-17 19:06:44 +01:00
|
|
|
, m_is_global(is_global)
|
2023-09-17 21:53:48 +12:00
|
|
|
, m_is_strict(is_strict)
|
2022-02-12 19:48:45 +03:30
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 17:49:34 +03:30
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2022-02-12 19:48:45 +03:30
|
|
|
|
2023-10-29 02:26:15 +02:00
|
|
|
IdentifierTableIndex identifier() const { return m_identifier; }
|
|
|
|
EnvironmentMode mode() const { return m_mode; }
|
|
|
|
bool is_immutable() const { return m_is_immutable; }
|
|
|
|
bool is_global() const { return m_is_global; }
|
|
|
|
bool is_strict() const { return m_is_strict; }
|
|
|
|
|
2022-02-12 19:48:45 +03:30
|
|
|
private:
|
|
|
|
IdentifierTableIndex m_identifier;
|
|
|
|
EnvironmentMode m_mode;
|
2022-07-17 19:06:44 +01:00
|
|
|
bool m_is_immutable : 4 { false };
|
|
|
|
bool m_is_global : 4 { false };
|
2023-09-17 21:53:48 +12:00
|
|
|
bool m_is_strict { false };
|
2022-02-12 19:48:45 +03:30
|
|
|
};
|
|
|
|
|
2024-05-14 11:30:30 +02:00
|
|
|
class InitializeLexicalBinding final : public Instruction {
|
2021-06-03 18:26:32 +02:00
|
|
|
public:
|
2024-05-14 11:30:30 +02:00
|
|
|
explicit InitializeLexicalBinding(IdentifierTableIndex identifier, Operand src)
|
|
|
|
: Instruction(Type::InitializeLexicalBinding)
|
|
|
|
, m_identifier(identifier)
|
|
|
|
, m_src(src)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
|
|
|
void visit_operands_impl(Function<void(Operand&)> visitor)
|
|
|
|
{
|
|
|
|
visitor(m_src);
|
|
|
|
}
|
|
|
|
|
|
|
|
IdentifierTableIndex identifier() const { return m_identifier; }
|
|
|
|
Operand src() const { return m_src; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
IdentifierTableIndex m_identifier;
|
|
|
|
Operand m_src;
|
|
|
|
mutable EnvironmentCoordinate m_cache;
|
|
|
|
};
|
|
|
|
|
|
|
|
class InitializeVariableBinding final : public Instruction {
|
|
|
|
public:
|
|
|
|
explicit InitializeVariableBinding(IdentifierTableIndex identifier, Operand src)
|
|
|
|
: Instruction(Type::InitializeVariableBinding)
|
|
|
|
, m_identifier(identifier)
|
|
|
|
, m_src(src)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
|
|
|
void visit_operands_impl(Function<void(Operand&)> visitor)
|
|
|
|
{
|
|
|
|
visitor(m_src);
|
|
|
|
}
|
|
|
|
|
|
|
|
IdentifierTableIndex identifier() const { return m_identifier; }
|
|
|
|
Operand src() const { return m_src; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
IdentifierTableIndex m_identifier;
|
|
|
|
Operand m_src;
|
|
|
|
mutable EnvironmentCoordinate m_cache;
|
|
|
|
};
|
|
|
|
|
|
|
|
class SetLexicalBinding final : public Instruction {
|
|
|
|
public:
|
|
|
|
explicit SetLexicalBinding(IdentifierTableIndex identifier, Operand src)
|
|
|
|
: Instruction(Type::SetLexicalBinding)
|
|
|
|
, m_identifier(identifier)
|
|
|
|
, m_src(src)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
|
|
|
void visit_operands_impl(Function<void(Operand&)> visitor)
|
|
|
|
{
|
|
|
|
visitor(m_src);
|
|
|
|
}
|
|
|
|
|
|
|
|
IdentifierTableIndex identifier() const { return m_identifier; }
|
|
|
|
Operand src() const { return m_src; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
IdentifierTableIndex m_identifier;
|
|
|
|
Operand m_src;
|
|
|
|
mutable EnvironmentCoordinate m_cache;
|
|
|
|
};
|
|
|
|
|
|
|
|
class SetVariableBinding final : public Instruction {
|
|
|
|
public:
|
|
|
|
explicit SetVariableBinding(IdentifierTableIndex identifier, Operand src)
|
|
|
|
: Instruction(Type::SetVariableBinding)
|
2021-06-12 11:22:46 +02:00
|
|
|
, m_identifier(identifier)
|
2024-02-04 08:00:54 +01:00
|
|
|
, m_src(src)
|
2021-06-03 18:26:32 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2022-02-07 14:36:45 +01:00
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 17:49:34 +03:30
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2024-05-12 18:49:03 +02:00
|
|
|
void visit_operands_impl(Function<void(Operand&)> visitor)
|
|
|
|
{
|
|
|
|
visitor(m_src);
|
|
|
|
}
|
2021-06-03 18:26:32 +02:00
|
|
|
|
2022-10-22 20:21:08 +02:00
|
|
|
IdentifierTableIndex identifier() const { return m_identifier; }
|
2024-02-04 08:00:54 +01:00
|
|
|
Operand src() const { return m_src; }
|
2022-10-22 20:21:08 +02:00
|
|
|
|
2021-06-03 18:26:32 +02:00
|
|
|
private:
|
2021-10-24 15:34:30 +02:00
|
|
|
IdentifierTableIndex m_identifier;
|
2024-02-04 08:00:54 +01:00
|
|
|
Operand m_src;
|
2024-05-11 18:28:03 +02:00
|
|
|
mutable EnvironmentCoordinate m_cache;
|
2021-06-03 18:26:32 +02:00
|
|
|
};
|
|
|
|
|
2024-05-05 22:06:55 +02:00
|
|
|
class SetArgument final : public Instruction {
|
|
|
|
public:
|
|
|
|
SetArgument(size_t index, Operand src)
|
|
|
|
: Instruction(Type::SetArgument)
|
|
|
|
, m_index(index)
|
|
|
|
, m_src(src)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2024-05-12 18:49:03 +02:00
|
|
|
void visit_operands_impl(Function<void(Operand&)> visitor)
|
|
|
|
{
|
|
|
|
visitor(m_src);
|
|
|
|
}
|
2024-05-05 22:06:55 +02:00
|
|
|
|
|
|
|
size_t index() const { return m_index; }
|
|
|
|
Operand src() const { return m_src; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
u32 m_index;
|
|
|
|
Operand m_src;
|
|
|
|
};
|
|
|
|
|
|
|
|
class GetArgument final : public Instruction {
|
|
|
|
public:
|
|
|
|
GetArgument(Operand dst, size_t index)
|
|
|
|
: Instruction(Type::GetArgument)
|
|
|
|
, m_index(index)
|
|
|
|
, m_dst(dst)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2024-05-12 18:49:03 +02:00
|
|
|
void visit_operands_impl(Function<void(Operand&)> visitor)
|
|
|
|
{
|
|
|
|
visitor(m_dst);
|
|
|
|
}
|
2024-05-05 22:06:55 +02:00
|
|
|
|
|
|
|
u32 index() const { return m_index; }
|
|
|
|
Operand dst() const { return m_dst; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
u32 m_index;
|
|
|
|
Operand m_dst;
|
|
|
|
};
|
|
|
|
|
2023-08-01 14:33:58 +02:00
|
|
|
class GetCalleeAndThisFromEnvironment final : public Instruction {
|
|
|
|
public:
|
2024-05-11 18:28:03 +02:00
|
|
|
explicit GetCalleeAndThisFromEnvironment(Operand callee, Operand this_value, IdentifierTableIndex identifier)
|
2024-05-06 11:09:09 +02:00
|
|
|
: Instruction(Type::GetCalleeAndThisFromEnvironment)
|
2023-08-01 14:33:58 +02:00
|
|
|
, m_identifier(identifier)
|
2024-02-04 08:00:54 +01:00
|
|
|
, m_callee(callee)
|
|
|
|
, m_this_value(this_value)
|
2023-08-01 14:33:58 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 17:49:34 +03:30
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2024-05-12 18:49:03 +02:00
|
|
|
void visit_operands_impl(Function<void(Operand&)> visitor)
|
|
|
|
{
|
|
|
|
visitor(m_callee);
|
|
|
|
visitor(m_this_value);
|
|
|
|
}
|
2023-08-01 14:33:58 +02:00
|
|
|
|
|
|
|
IdentifierTableIndex identifier() const { return m_identifier; }
|
2024-02-04 08:00:54 +01:00
|
|
|
Operand callee() const { return m_callee; }
|
|
|
|
Operand this_() const { return m_this_value; }
|
2023-08-01 14:33:58 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
IdentifierTableIndex m_identifier;
|
2024-02-04 08:00:54 +01:00
|
|
|
Operand m_callee;
|
|
|
|
Operand m_this_value;
|
2024-05-11 18:28:03 +02:00
|
|
|
mutable EnvironmentCoordinate m_cache;
|
2023-08-01 14:33:58 +02:00
|
|
|
};
|
|
|
|
|
2024-05-14 11:32:04 +02:00
|
|
|
class GetBinding final : public Instruction {
|
2021-06-03 18:26:32 +02:00
|
|
|
public:
|
2024-05-14 11:32:04 +02:00
|
|
|
explicit GetBinding(Operand dst, IdentifierTableIndex identifier)
|
|
|
|
: Instruction(Type::GetBinding)
|
2024-02-04 08:00:54 +01:00
|
|
|
, m_dst(dst)
|
2021-06-12 11:22:46 +02:00
|
|
|
, m_identifier(identifier)
|
2021-06-03 18:26:32 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2022-02-07 14:36:45 +01:00
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 17:49:34 +03:30
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2021-06-03 18:26:32 +02:00
|
|
|
|
2024-02-04 08:00:54 +01:00
|
|
|
Operand dst() const { return m_dst; }
|
2022-10-22 20:21:08 +02:00
|
|
|
IdentifierTableIndex identifier() const { return m_identifier; }
|
|
|
|
|
2024-05-12 18:49:03 +02:00
|
|
|
void visit_operands_impl(Function<void(Operand&)> visitor)
|
|
|
|
{
|
|
|
|
visitor(m_dst);
|
|
|
|
}
|
|
|
|
|
2021-06-03 18:26:32 +02:00
|
|
|
private:
|
2024-02-04 08:00:54 +01:00
|
|
|
Operand m_dst;
|
2021-10-24 15:34:30 +02:00
|
|
|
IdentifierTableIndex m_identifier;
|
2024-05-11 18:28:03 +02:00
|
|
|
mutable EnvironmentCoordinate m_cache;
|
2021-06-03 18:26:32 +02:00
|
|
|
};
|
|
|
|
|
2023-07-12 04:06:59 +02:00
|
|
|
class GetGlobal final : public Instruction {
|
|
|
|
public:
|
2024-02-04 08:00:54 +01:00
|
|
|
GetGlobal(Operand dst, IdentifierTableIndex identifier, u32 cache_index)
|
2024-05-06 11:09:09 +02:00
|
|
|
: Instruction(Type::GetGlobal)
|
2024-02-04 08:00:54 +01:00
|
|
|
, m_dst(dst)
|
2023-07-12 04:06:59 +02:00
|
|
|
, m_identifier(identifier)
|
|
|
|
, m_cache_index(cache_index)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 17:49:34 +03:30
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2023-07-12 04:06:59 +02:00
|
|
|
|
2024-02-04 08:00:54 +01:00
|
|
|
Operand dst() const { return m_dst; }
|
2023-10-20 12:56:12 +02:00
|
|
|
IdentifierTableIndex identifier() const { return m_identifier; }
|
|
|
|
u32 cache_index() const { return m_cache_index; }
|
|
|
|
|
2024-05-12 18:49:03 +02:00
|
|
|
void visit_operands_impl(Function<void(Operand&)> visitor)
|
|
|
|
{
|
|
|
|
visitor(m_dst);
|
|
|
|
}
|
|
|
|
|
2023-07-12 04:06:59 +02:00
|
|
|
private:
|
2024-02-04 08:00:54 +01:00
|
|
|
Operand m_dst;
|
2023-07-12 04:06:59 +02:00
|
|
|
IdentifierTableIndex m_identifier;
|
|
|
|
u32 m_cache_index { 0 };
|
|
|
|
};
|
|
|
|
|
2022-03-27 19:50:09 +01:00
|
|
|
class DeleteVariable final : public Instruction {
|
|
|
|
public:
|
2024-02-04 08:00:54 +01:00
|
|
|
explicit DeleteVariable(Operand dst, IdentifierTableIndex identifier)
|
2024-05-06 11:09:09 +02:00
|
|
|
: Instruction(Type::DeleteVariable)
|
2024-02-04 08:00:54 +01:00
|
|
|
, m_dst(dst)
|
2022-03-27 19:50:09 +01:00
|
|
|
, m_identifier(identifier)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 17:49:34 +03:30
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2022-03-27 19:50:09 +01:00
|
|
|
|
2024-02-04 08:00:54 +01:00
|
|
|
Operand dst() const { return m_dst; }
|
2022-10-22 20:21:08 +02:00
|
|
|
IdentifierTableIndex identifier() const { return m_identifier; }
|
|
|
|
|
2024-05-12 18:49:03 +02:00
|
|
|
void visit_operands_impl(Function<void(Operand&)> visitor)
|
|
|
|
{
|
|
|
|
visitor(m_dst);
|
|
|
|
}
|
|
|
|
|
2022-03-27 19:50:09 +01:00
|
|
|
private:
|
2024-02-04 08:00:54 +01:00
|
|
|
Operand m_dst;
|
2022-03-27 19:50:09 +01:00
|
|
|
IdentifierTableIndex m_identifier;
|
|
|
|
};
|
|
|
|
|
2021-06-04 21:03:53 +02:00
|
|
|
class GetById final : public Instruction {
|
|
|
|
public:
|
2024-03-29 11:26:10 -04:00
|
|
|
GetById(Operand dst, Operand base, IdentifierTableIndex property, Optional<IdentifierTableIndex> base_identifier, u32 cache_index)
|
2024-05-06 11:09:09 +02:00
|
|
|
: Instruction(Type::GetById)
|
2024-02-04 08:00:54 +01:00
|
|
|
, m_dst(dst)
|
|
|
|
, m_base(base)
|
2021-06-12 11:22:46 +02:00
|
|
|
, m_property(property)
|
2024-03-29 11:26:10 -04:00
|
|
|
, m_base_identifier(move(base_identifier))
|
2023-07-08 17:43:26 +02:00
|
|
|
, m_cache_index(cache_index)
|
2021-06-04 21:03:53 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2022-02-07 14:36:45 +01:00
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 17:49:34 +03:30
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2024-05-12 18:49:03 +02:00
|
|
|
void visit_operands_impl(Function<void(Operand&)> visitor)
|
|
|
|
{
|
|
|
|
visitor(m_dst);
|
|
|
|
visitor(m_base);
|
|
|
|
}
|
2021-06-04 21:03:53 +02:00
|
|
|
|
2024-02-04 08:00:54 +01:00
|
|
|
Operand dst() const { return m_dst; }
|
|
|
|
Operand base() const { return m_base; }
|
2023-10-18 13:27:56 +02:00
|
|
|
IdentifierTableIndex property() const { return m_property; }
|
|
|
|
u32 cache_index() const { return m_cache_index; }
|
|
|
|
|
2021-06-04 21:03:53 +02:00
|
|
|
private:
|
2024-02-04 08:00:54 +01:00
|
|
|
Operand m_dst;
|
|
|
|
Operand m_base;
|
2021-10-24 15:34:30 +02:00
|
|
|
IdentifierTableIndex m_property;
|
2024-03-29 11:26:10 -04:00
|
|
|
Optional<IdentifierTableIndex> m_base_identifier;
|
2023-07-08 17:43:26 +02:00
|
|
|
u32 m_cache_index { 0 };
|
2021-06-04 21:03:53 +02:00
|
|
|
};
|
|
|
|
|
2023-07-02 19:26:31 +01:00
|
|
|
class GetByIdWithThis final : public Instruction {
|
|
|
|
public:
|
2024-02-04 08:00:54 +01:00
|
|
|
GetByIdWithThis(Operand dst, Operand base, IdentifierTableIndex property, Operand this_value, u32 cache_index)
|
2024-05-06 11:09:09 +02:00
|
|
|
: Instruction(Type::GetByIdWithThis)
|
2024-02-04 08:00:54 +01:00
|
|
|
, m_dst(dst)
|
|
|
|
, m_base(base)
|
2023-07-02 19:26:31 +01:00
|
|
|
, m_property(property)
|
|
|
|
, m_this_value(this_value)
|
2023-07-08 17:43:26 +02:00
|
|
|
, m_cache_index(cache_index)
|
2023-07-02 19:26:31 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 17:49:34 +03:30
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2024-05-12 18:49:03 +02:00
|
|
|
void visit_operands_impl(Function<void(Operand&)> visitor)
|
|
|
|
{
|
|
|
|
visitor(m_dst);
|
|
|
|
visitor(m_base);
|
|
|
|
visitor(m_this_value);
|
|
|
|
}
|
2023-07-02 19:26:31 +01:00
|
|
|
|
2024-02-04 08:00:54 +01:00
|
|
|
Operand dst() const { return m_dst; }
|
|
|
|
Operand base() const { return m_base; }
|
2023-10-29 21:39:02 +01:00
|
|
|
IdentifierTableIndex property() const { return m_property; }
|
2024-02-04 08:00:54 +01:00
|
|
|
Operand this_value() const { return m_this_value; }
|
2023-10-29 21:39:02 +01:00
|
|
|
u32 cache_index() const { return m_cache_index; }
|
|
|
|
|
2023-07-02 19:26:31 +01:00
|
|
|
private:
|
2024-02-04 08:00:54 +01:00
|
|
|
Operand m_dst;
|
|
|
|
Operand m_base;
|
2023-07-02 19:26:31 +01:00
|
|
|
IdentifierTableIndex m_property;
|
2024-02-04 08:00:54 +01:00
|
|
|
Operand m_this_value;
|
2023-07-08 17:43:26 +02:00
|
|
|
u32 m_cache_index { 0 };
|
2023-07-02 19:26:31 +01:00
|
|
|
};
|
|
|
|
|
2024-05-20 11:53:28 +02:00
|
|
|
class GetLength final : public Instruction {
|
|
|
|
public:
|
|
|
|
GetLength(Operand dst, Operand base, Optional<IdentifierTableIndex> base_identifier, u32 cache_index)
|
|
|
|
: Instruction(Type::GetLength)
|
|
|
|
, m_dst(dst)
|
|
|
|
, m_base(base)
|
|
|
|
, m_base_identifier(move(base_identifier))
|
|
|
|
, m_cache_index(cache_index)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
|
|
|
void visit_operands_impl(Function<void(Operand&)> visitor)
|
|
|
|
{
|
|
|
|
visitor(m_dst);
|
|
|
|
visitor(m_base);
|
|
|
|
}
|
|
|
|
|
|
|
|
Operand dst() const { return m_dst; }
|
|
|
|
Operand base() const { return m_base; }
|
|
|
|
u32 cache_index() const { return m_cache_index; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
Operand m_dst;
|
|
|
|
Operand m_base;
|
|
|
|
Optional<IdentifierTableIndex> m_base_identifier;
|
|
|
|
u32 m_cache_index { 0 };
|
|
|
|
};
|
|
|
|
|
|
|
|
class GetLengthWithThis final : public Instruction {
|
|
|
|
public:
|
|
|
|
GetLengthWithThis(Operand dst, Operand base, Operand this_value, u32 cache_index)
|
|
|
|
: Instruction(Type::GetLengthWithThis)
|
|
|
|
, m_dst(dst)
|
|
|
|
, m_base(base)
|
|
|
|
, m_this_value(this_value)
|
|
|
|
, m_cache_index(cache_index)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
|
|
|
void visit_operands_impl(Function<void(Operand&)> visitor)
|
|
|
|
{
|
|
|
|
visitor(m_dst);
|
|
|
|
visitor(m_base);
|
|
|
|
visitor(m_this_value);
|
|
|
|
}
|
|
|
|
|
|
|
|
Operand dst() const { return m_dst; }
|
|
|
|
Operand base() const { return m_base; }
|
|
|
|
Operand this_value() const { return m_this_value; }
|
|
|
|
u32 cache_index() const { return m_cache_index; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
Operand m_dst;
|
|
|
|
Operand m_base;
|
|
|
|
Operand m_this_value;
|
|
|
|
u32 m_cache_index { 0 };
|
|
|
|
};
|
|
|
|
|
2023-06-23 08:16:17 +02:00
|
|
|
class GetPrivateById final : public Instruction {
|
|
|
|
public:
|
2024-02-04 08:00:54 +01:00
|
|
|
explicit GetPrivateById(Operand dst, Operand base, IdentifierTableIndex property)
|
2024-05-06 11:09:09 +02:00
|
|
|
: Instruction(Type::GetPrivateById)
|
2024-02-04 08:00:54 +01:00
|
|
|
, m_dst(dst)
|
|
|
|
, m_base(base)
|
2023-06-23 08:16:17 +02:00
|
|
|
, m_property(property)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 17:49:34 +03:30
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2024-05-12 18:49:03 +02:00
|
|
|
void visit_operands_impl(Function<void(Operand&)> visitor)
|
|
|
|
{
|
|
|
|
visitor(m_dst);
|
|
|
|
visitor(m_base);
|
|
|
|
}
|
2023-06-23 08:16:17 +02:00
|
|
|
|
2024-02-04 08:00:54 +01:00
|
|
|
Operand dst() const { return m_dst; }
|
|
|
|
Operand base() const { return m_base; }
|
2023-10-29 21:24:50 +01:00
|
|
|
IdentifierTableIndex property() const { return m_property; }
|
|
|
|
|
2023-06-23 08:16:17 +02:00
|
|
|
private:
|
2024-02-04 08:00:54 +01:00
|
|
|
Operand m_dst;
|
|
|
|
Operand m_base;
|
2023-06-23 08:16:17 +02:00
|
|
|
IdentifierTableIndex m_property;
|
|
|
|
};
|
|
|
|
|
2023-07-05 12:42:50 +02:00
|
|
|
class HasPrivateId final : public Instruction {
|
|
|
|
public:
|
2024-02-04 08:00:54 +01:00
|
|
|
HasPrivateId(Operand dst, Operand base, IdentifierTableIndex property)
|
2024-05-06 11:09:09 +02:00
|
|
|
: Instruction(Type::HasPrivateId)
|
2024-02-04 08:00:54 +01:00
|
|
|
, m_dst(dst)
|
|
|
|
, m_base(base)
|
2023-07-05 12:42:50 +02:00
|
|
|
, m_property(property)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 17:49:34 +03:30
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2024-05-12 18:49:03 +02:00
|
|
|
void visit_operands_impl(Function<void(Operand&)> visitor)
|
|
|
|
{
|
|
|
|
visitor(m_dst);
|
|
|
|
visitor(m_base);
|
|
|
|
}
|
2023-07-05 12:42:50 +02:00
|
|
|
|
2024-02-04 08:00:54 +01:00
|
|
|
Operand dst() const { return m_dst; }
|
|
|
|
Operand base() const { return m_base; }
|
2023-10-30 00:28:13 +01:00
|
|
|
IdentifierTableIndex property() const { return m_property; }
|
|
|
|
|
2023-07-05 12:42:50 +02:00
|
|
|
private:
|
2024-02-04 08:00:54 +01:00
|
|
|
Operand m_dst;
|
|
|
|
Operand m_base;
|
2023-07-05 12:42:50 +02:00
|
|
|
IdentifierTableIndex m_property;
|
|
|
|
};
|
|
|
|
|
2022-03-31 00:59:58 +04:30
|
|
|
enum class PropertyKind {
|
|
|
|
Getter,
|
|
|
|
Setter,
|
|
|
|
KeyValue,
|
2023-07-10 08:44:28 +02:00
|
|
|
DirectKeyValue, // Used for Object expressions. Always sets an own property, never calls a setter.
|
2022-03-31 00:59:58 +04:30
|
|
|
Spread,
|
|
|
|
ProtoSetter,
|
|
|
|
};
|
|
|
|
|
2021-06-04 20:47:07 +02:00
|
|
|
class PutById final : public Instruction {
|
|
|
|
public:
|
2024-03-29 12:10:52 -04:00
|
|
|
explicit PutById(Operand base, IdentifierTableIndex property, Operand src, PropertyKind kind, u32 cache_index, Optional<IdentifierTableIndex> base_identifier = {})
|
2024-05-06 11:09:09 +02:00
|
|
|
: Instruction(Type::PutById)
|
2021-06-07 15:12:43 +02:00
|
|
|
, m_base(base)
|
2021-06-12 11:22:46 +02:00
|
|
|
, m_property(property)
|
2024-02-04 08:00:54 +01:00
|
|
|
, m_src(src)
|
2022-03-31 00:59:58 +04:30
|
|
|
, m_kind(kind)
|
2023-11-08 20:51:26 +01:00
|
|
|
, m_cache_index(cache_index)
|
2024-03-29 12:10:52 -04:00
|
|
|
, m_base_identifier(move(base_identifier))
|
2021-06-04 20:47:07 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2023-06-23 08:16:17 +02:00
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 17:49:34 +03:30
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2024-05-12 18:49:03 +02:00
|
|
|
void visit_operands_impl(Function<void(Operand&)> visitor)
|
|
|
|
{
|
|
|
|
visitor(m_base);
|
|
|
|
visitor(m_src);
|
|
|
|
}
|
2023-06-23 08:16:17 +02:00
|
|
|
|
2024-02-04 08:00:54 +01:00
|
|
|
Operand base() const { return m_base; }
|
2023-10-20 13:09:35 +02:00
|
|
|
IdentifierTableIndex property() const { return m_property; }
|
2024-02-04 08:00:54 +01:00
|
|
|
Operand src() const { return m_src; }
|
2023-10-20 13:09:35 +02:00
|
|
|
PropertyKind kind() const { return m_kind; }
|
2023-11-08 20:51:26 +01:00
|
|
|
u32 cache_index() const { return m_cache_index; }
|
2023-10-20 13:09:35 +02:00
|
|
|
|
2023-06-23 08:16:17 +02:00
|
|
|
private:
|
2024-02-04 08:00:54 +01:00
|
|
|
Operand m_base;
|
2023-06-23 08:16:17 +02:00
|
|
|
IdentifierTableIndex m_property;
|
2024-02-04 08:00:54 +01:00
|
|
|
Operand m_src;
|
2023-06-23 08:16:17 +02:00
|
|
|
PropertyKind m_kind;
|
2023-11-08 20:51:26 +01:00
|
|
|
u32 m_cache_index { 0 };
|
2024-03-29 12:10:52 -04:00
|
|
|
Optional<IdentifierTableIndex> m_base_identifier {};
|
2023-06-23 08:16:17 +02:00
|
|
|
};
|
|
|
|
|
2023-07-02 19:26:31 +01:00
|
|
|
class PutByIdWithThis final : public Instruction {
|
|
|
|
public:
|
2024-02-04 08:00:54 +01:00
|
|
|
PutByIdWithThis(Operand base, Operand this_value, IdentifierTableIndex property, Operand src, PropertyKind kind, u32 cache_index)
|
2024-05-06 11:09:09 +02:00
|
|
|
: Instruction(Type::PutByIdWithThis)
|
2023-07-02 19:26:31 +01:00
|
|
|
, m_base(base)
|
|
|
|
, m_this_value(this_value)
|
|
|
|
, m_property(property)
|
2024-02-04 08:00:54 +01:00
|
|
|
, m_src(src)
|
2023-07-02 19:26:31 +01:00
|
|
|
, m_kind(kind)
|
2023-11-08 20:51:26 +01:00
|
|
|
, m_cache_index(cache_index)
|
2023-07-02 19:26:31 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 17:49:34 +03:30
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2024-05-12 18:49:03 +02:00
|
|
|
void visit_operands_impl(Function<void(Operand&)> visitor)
|
|
|
|
{
|
|
|
|
visitor(m_base);
|
|
|
|
visitor(m_this_value);
|
|
|
|
visitor(m_src);
|
|
|
|
}
|
2023-07-02 19:26:31 +01:00
|
|
|
|
2024-02-04 08:00:54 +01:00
|
|
|
Operand base() const { return m_base; }
|
|
|
|
Operand this_value() const { return m_this_value; }
|
2023-10-29 22:14:39 +01:00
|
|
|
IdentifierTableIndex property() const { return m_property; }
|
2024-02-04 08:00:54 +01:00
|
|
|
Operand src() const { return m_src; }
|
2023-10-29 22:14:39 +01:00
|
|
|
PropertyKind kind() const { return m_kind; }
|
2023-11-08 20:51:26 +01:00
|
|
|
u32 cache_index() const { return m_cache_index; }
|
2023-10-29 22:14:39 +01:00
|
|
|
|
2023-07-02 19:26:31 +01:00
|
|
|
private:
|
2024-02-04 08:00:54 +01:00
|
|
|
Operand m_base;
|
|
|
|
Operand m_this_value;
|
2023-07-02 19:26:31 +01:00
|
|
|
IdentifierTableIndex m_property;
|
2024-02-04 08:00:54 +01:00
|
|
|
Operand m_src;
|
2023-07-02 19:26:31 +01:00
|
|
|
PropertyKind m_kind;
|
2023-11-08 20:51:26 +01:00
|
|
|
u32 m_cache_index { 0 };
|
2023-07-02 19:26:31 +01:00
|
|
|
};
|
|
|
|
|
2023-06-23 08:16:17 +02:00
|
|
|
class PutPrivateById final : public Instruction {
|
|
|
|
public:
|
2024-02-04 08:00:54 +01:00
|
|
|
explicit PutPrivateById(Operand base, IdentifierTableIndex property, Operand src, PropertyKind kind = PropertyKind::KeyValue)
|
2024-05-06 11:09:09 +02:00
|
|
|
: Instruction(Type::PutPrivateById)
|
2023-06-23 08:16:17 +02:00
|
|
|
, m_base(base)
|
|
|
|
, m_property(property)
|
2024-02-04 08:00:54 +01:00
|
|
|
, m_src(src)
|
2023-06-23 08:16:17 +02:00
|
|
|
, m_kind(kind)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2022-02-07 14:36:45 +01:00
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 17:49:34 +03:30
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2024-05-12 18:49:03 +02:00
|
|
|
void visit_operands_impl(Function<void(Operand&)> visitor)
|
|
|
|
{
|
|
|
|
visitor(m_base);
|
|
|
|
visitor(m_src);
|
|
|
|
}
|
2021-06-04 20:47:07 +02:00
|
|
|
|
2024-02-04 08:00:54 +01:00
|
|
|
Operand base() const { return m_base; }
|
2023-10-29 22:20:47 +01:00
|
|
|
IdentifierTableIndex property() const { return m_property; }
|
2024-02-04 08:00:54 +01:00
|
|
|
Operand src() const { return m_src; }
|
2023-10-29 22:20:47 +01:00
|
|
|
|
2021-06-04 20:47:07 +02:00
|
|
|
private:
|
2024-02-04 08:00:54 +01:00
|
|
|
Operand m_base;
|
2021-10-24 15:34:30 +02:00
|
|
|
IdentifierTableIndex m_property;
|
2024-02-04 08:00:54 +01:00
|
|
|
Operand m_src;
|
2022-03-31 00:59:58 +04:30
|
|
|
PropertyKind m_kind;
|
2021-06-04 20:47:07 +02:00
|
|
|
};
|
|
|
|
|
2022-03-27 19:50:09 +01:00
|
|
|
class DeleteById final : public Instruction {
|
|
|
|
public:
|
2024-02-04 08:00:54 +01:00
|
|
|
explicit DeleteById(Operand dst, Operand base, IdentifierTableIndex property)
|
2024-05-06 11:09:09 +02:00
|
|
|
: Instruction(Type::DeleteById)
|
2024-02-04 08:00:54 +01:00
|
|
|
, m_dst(dst)
|
|
|
|
, m_base(base)
|
2022-03-27 19:50:09 +01:00
|
|
|
, m_property(property)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 17:49:34 +03:30
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2024-05-12 18:49:03 +02:00
|
|
|
void visit_operands_impl(Function<void(Operand&)> visitor)
|
|
|
|
{
|
|
|
|
visitor(m_dst);
|
|
|
|
visitor(m_base);
|
|
|
|
}
|
2022-03-27 19:50:09 +01:00
|
|
|
|
2024-02-04 08:00:54 +01:00
|
|
|
Operand dst() const { return m_dst; }
|
|
|
|
Operand base() const { return m_base; }
|
2023-10-29 20:29:14 +01:00
|
|
|
IdentifierTableIndex property() const { return m_property; }
|
|
|
|
|
2022-03-27 19:50:09 +01:00
|
|
|
private:
|
2024-02-04 08:00:54 +01:00
|
|
|
Operand m_dst;
|
|
|
|
Operand m_base;
|
2022-03-27 19:50:09 +01:00
|
|
|
IdentifierTableIndex m_property;
|
|
|
|
};
|
|
|
|
|
2023-07-06 17:10:40 -04:00
|
|
|
class DeleteByIdWithThis final : public Instruction {
|
|
|
|
public:
|
2024-02-04 08:00:54 +01:00
|
|
|
DeleteByIdWithThis(Operand dst, Operand base, Operand this_value, IdentifierTableIndex property)
|
2024-05-06 11:09:09 +02:00
|
|
|
: Instruction(Type::DeleteByIdWithThis)
|
2024-02-04 08:00:54 +01:00
|
|
|
, m_dst(dst)
|
|
|
|
, m_base(base)
|
2023-07-06 17:10:40 -04:00
|
|
|
, m_this_value(this_value)
|
|
|
|
, m_property(property)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 17:49:34 +03:30
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2024-05-12 18:49:03 +02:00
|
|
|
void visit_operands_impl(Function<void(Operand&)> visitor)
|
|
|
|
{
|
|
|
|
visitor(m_dst);
|
|
|
|
visitor(m_base);
|
|
|
|
visitor(m_this_value);
|
|
|
|
}
|
2023-07-06 17:10:40 -04:00
|
|
|
|
2024-02-04 08:00:54 +01:00
|
|
|
Operand dst() const { return m_dst; }
|
|
|
|
Operand base() const { return m_base; }
|
|
|
|
Operand this_value() const { return m_this_value; }
|
2023-10-29 22:05:09 +01:00
|
|
|
IdentifierTableIndex property() const { return m_property; }
|
|
|
|
|
2023-07-06 17:10:40 -04:00
|
|
|
private:
|
2024-02-04 08:00:54 +01:00
|
|
|
Operand m_dst;
|
|
|
|
Operand m_base;
|
|
|
|
Operand m_this_value;
|
2023-07-06 17:10:40 -04:00
|
|
|
IdentifierTableIndex m_property;
|
|
|
|
};
|
|
|
|
|
2021-06-11 00:35:25 +02:00
|
|
|
class GetByValue final : public Instruction {
|
|
|
|
public:
|
2024-03-29 11:26:10 -04:00
|
|
|
GetByValue(Operand dst, Operand base, Operand property, Optional<IdentifierTableIndex> base_identifier = {})
|
2024-05-06 11:09:09 +02:00
|
|
|
: Instruction(Type::GetByValue)
|
2024-02-04 08:00:54 +01:00
|
|
|
, m_dst(dst)
|
2021-06-11 00:35:25 +02:00
|
|
|
, m_base(base)
|
2024-02-04 08:00:54 +01:00
|
|
|
, m_property(property)
|
2024-03-29 11:26:10 -04:00
|
|
|
, m_base_identifier(move(base_identifier))
|
2021-06-11 00:35:25 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2022-02-07 14:36:45 +01:00
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 17:49:34 +03:30
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2024-05-12 18:49:03 +02:00
|
|
|
void visit_operands_impl(Function<void(Operand&)> visitor)
|
|
|
|
{
|
|
|
|
visitor(m_dst);
|
|
|
|
visitor(m_base);
|
|
|
|
visitor(m_property);
|
|
|
|
}
|
2021-06-11 00:35:25 +02:00
|
|
|
|
2024-02-04 08:00:54 +01:00
|
|
|
Operand dst() const { return m_dst; }
|
|
|
|
Operand base() const { return m_base; }
|
|
|
|
Operand property() const { return m_property; }
|
2023-10-20 12:38:43 +02:00
|
|
|
|
2024-03-29 11:26:10 -04:00
|
|
|
Optional<DeprecatedFlyString const&> base_identifier(Bytecode::Interpreter const&) const;
|
|
|
|
|
2021-06-11 00:35:25 +02:00
|
|
|
private:
|
2024-02-04 08:00:54 +01:00
|
|
|
Operand m_dst;
|
|
|
|
Operand m_base;
|
|
|
|
Operand m_property;
|
2024-03-29 11:26:10 -04:00
|
|
|
Optional<IdentifierTableIndex> m_base_identifier;
|
2021-06-11 00:35:25 +02:00
|
|
|
};
|
|
|
|
|
2023-07-02 19:26:31 +01:00
|
|
|
class GetByValueWithThis final : public Instruction {
|
|
|
|
public:
|
2024-02-04 08:00:54 +01:00
|
|
|
GetByValueWithThis(Operand dst, Operand base, Operand property, Operand this_value)
|
2024-05-06 11:09:09 +02:00
|
|
|
: Instruction(Type::GetByValueWithThis)
|
2024-02-04 08:00:54 +01:00
|
|
|
, m_dst(dst)
|
2023-07-02 19:26:31 +01:00
|
|
|
, m_base(base)
|
2024-02-04 08:00:54 +01:00
|
|
|
, m_property(property)
|
2023-07-02 19:26:31 +01:00
|
|
|
, m_this_value(this_value)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 17:49:34 +03:30
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2024-05-12 18:49:03 +02:00
|
|
|
void visit_operands_impl(Function<void(Operand&)> visitor)
|
|
|
|
{
|
|
|
|
visitor(m_dst);
|
|
|
|
visitor(m_base);
|
|
|
|
visitor(m_property);
|
|
|
|
visitor(m_this_value);
|
|
|
|
}
|
2023-07-02 19:26:31 +01:00
|
|
|
|
2024-02-04 08:00:54 +01:00
|
|
|
Operand dst() const { return m_dst; }
|
|
|
|
Operand base() const { return m_base; }
|
|
|
|
Operand property() const { return m_property; }
|
|
|
|
Operand this_value() const { return m_this_value; }
|
2023-10-29 21:49:41 +01:00
|
|
|
|
2023-07-02 19:26:31 +01:00
|
|
|
private:
|
2024-02-04 08:00:54 +01:00
|
|
|
Operand m_dst;
|
|
|
|
Operand m_base;
|
|
|
|
Operand m_property;
|
|
|
|
Operand m_this_value;
|
2023-07-02 19:26:31 +01:00
|
|
|
};
|
|
|
|
|
2021-06-11 00:35:25 +02:00
|
|
|
class PutByValue final : public Instruction {
|
|
|
|
public:
|
2024-03-29 12:10:52 -04:00
|
|
|
PutByValue(Operand base, Operand property, Operand src, PropertyKind kind = PropertyKind::KeyValue, Optional<IdentifierTableIndex> base_identifier = {})
|
2024-05-06 11:09:09 +02:00
|
|
|
: Instruction(Type::PutByValue)
|
2021-06-11 00:35:25 +02:00
|
|
|
, m_base(base)
|
|
|
|
, m_property(property)
|
2024-02-04 08:00:54 +01:00
|
|
|
, m_src(src)
|
2022-03-31 00:59:58 +04:30
|
|
|
, m_kind(kind)
|
2024-03-29 12:10:52 -04:00
|
|
|
, m_base_identifier(move(base_identifier))
|
2021-06-11 00:35:25 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2022-02-07 14:36:45 +01:00
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 17:49:34 +03:30
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2024-05-12 18:49:03 +02:00
|
|
|
void visit_operands_impl(Function<void(Operand&)> visitor)
|
|
|
|
{
|
|
|
|
visitor(m_base);
|
|
|
|
visitor(m_property);
|
|
|
|
visitor(m_src);
|
|
|
|
}
|
2023-07-02 19:26:31 +01:00
|
|
|
|
2024-02-04 08:00:54 +01:00
|
|
|
Operand base() const { return m_base; }
|
|
|
|
Operand property() const { return m_property; }
|
|
|
|
Operand src() const { return m_src; }
|
2023-10-21 15:55:15 +02:00
|
|
|
PropertyKind kind() const { return m_kind; }
|
|
|
|
|
2023-07-02 19:26:31 +01:00
|
|
|
private:
|
2024-02-04 08:00:54 +01:00
|
|
|
Operand m_base;
|
|
|
|
Operand m_property;
|
|
|
|
Operand m_src;
|
2023-07-02 19:26:31 +01:00
|
|
|
PropertyKind m_kind;
|
2024-03-29 12:10:52 -04:00
|
|
|
Optional<IdentifierTableIndex> m_base_identifier;
|
2023-07-02 19:26:31 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
class PutByValueWithThis final : public Instruction {
|
|
|
|
public:
|
2024-02-04 08:00:54 +01:00
|
|
|
PutByValueWithThis(Operand base, Operand property, Operand this_value, Operand src, PropertyKind kind = PropertyKind::KeyValue)
|
2024-05-06 11:09:09 +02:00
|
|
|
: Instruction(Type::PutByValueWithThis)
|
2023-07-02 19:26:31 +01:00
|
|
|
, m_base(base)
|
|
|
|
, m_property(property)
|
|
|
|
, m_this_value(this_value)
|
2024-02-04 08:00:54 +01:00
|
|
|
, m_src(src)
|
2023-07-02 19:26:31 +01:00
|
|
|
, m_kind(kind)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 17:49:34 +03:30
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2024-05-12 18:49:03 +02:00
|
|
|
void visit_operands_impl(Function<void(Operand&)> visitor)
|
|
|
|
{
|
|
|
|
visitor(m_base);
|
|
|
|
visitor(m_property);
|
|
|
|
visitor(m_this_value);
|
|
|
|
visitor(m_src);
|
|
|
|
}
|
2021-06-11 00:35:25 +02:00
|
|
|
|
2024-02-04 08:00:54 +01:00
|
|
|
Operand base() const { return m_base; }
|
|
|
|
Operand property() const { return m_property; }
|
|
|
|
Operand this_value() const { return m_this_value; }
|
|
|
|
Operand src() const { return m_src; }
|
2023-10-30 01:32:20 +01:00
|
|
|
PropertyKind kind() const { return m_kind; }
|
|
|
|
|
2021-06-11 00:35:25 +02:00
|
|
|
private:
|
2024-02-04 08:00:54 +01:00
|
|
|
Operand m_base;
|
|
|
|
Operand m_property;
|
|
|
|
Operand m_this_value;
|
|
|
|
Operand m_src;
|
2022-03-31 00:59:58 +04:30
|
|
|
PropertyKind m_kind;
|
2021-06-11 00:35:25 +02:00
|
|
|
};
|
|
|
|
|
2022-03-27 19:50:09 +01:00
|
|
|
class DeleteByValue final : public Instruction {
|
|
|
|
public:
|
2024-02-04 08:00:54 +01:00
|
|
|
DeleteByValue(Operand dst, Operand base, Operand property)
|
2024-05-06 11:09:09 +02:00
|
|
|
: Instruction(Type::DeleteByValue)
|
2024-02-04 08:00:54 +01:00
|
|
|
, m_dst(dst)
|
2022-03-27 19:50:09 +01:00
|
|
|
, m_base(base)
|
2024-02-04 08:00:54 +01:00
|
|
|
, m_property(property)
|
2022-03-27 19:50:09 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 17:49:34 +03:30
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2024-05-12 18:49:03 +02:00
|
|
|
void visit_operands_impl(Function<void(Operand&)> visitor)
|
|
|
|
{
|
|
|
|
visitor(m_dst);
|
|
|
|
visitor(m_base);
|
|
|
|
visitor(m_property);
|
|
|
|
}
|
2022-03-27 19:50:09 +01:00
|
|
|
|
2024-02-04 08:00:54 +01:00
|
|
|
Operand dst() const { return m_dst; }
|
|
|
|
Operand base() const { return m_base; }
|
|
|
|
Operand property() const { return m_property; }
|
2023-10-29 21:20:25 +01:00
|
|
|
|
2022-03-27 19:50:09 +01:00
|
|
|
private:
|
2024-02-04 08:00:54 +01:00
|
|
|
Operand m_dst;
|
|
|
|
Operand m_base;
|
|
|
|
Operand m_property;
|
2022-03-27 19:50:09 +01:00
|
|
|
};
|
|
|
|
|
2023-07-06 17:10:40 -04:00
|
|
|
class DeleteByValueWithThis final : public Instruction {
|
|
|
|
public:
|
2024-02-04 08:00:54 +01:00
|
|
|
DeleteByValueWithThis(Operand dst, Operand base, Operand this_value, Operand property)
|
2024-05-06 11:09:09 +02:00
|
|
|
: Instruction(Type::DeleteByValueWithThis)
|
2024-02-04 08:00:54 +01:00
|
|
|
, m_dst(dst)
|
2023-07-06 17:10:40 -04:00
|
|
|
, m_base(base)
|
|
|
|
, m_this_value(this_value)
|
2024-02-04 08:00:54 +01:00
|
|
|
, m_property(property)
|
2023-07-06 17:10:40 -04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2024-02-04 08:00:54 +01:00
|
|
|
Operand dst() const { return m_dst; }
|
|
|
|
Operand base() const { return m_base; }
|
|
|
|
Operand this_value() const { return m_this_value; }
|
|
|
|
Operand property() const { return m_property; }
|
2023-10-29 21:37:52 +01:00
|
|
|
|
2023-07-06 17:10:40 -04:00
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 17:49:34 +03:30
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2024-05-12 18:49:03 +02:00
|
|
|
void visit_operands_impl(Function<void(Operand&)> visitor)
|
|
|
|
{
|
|
|
|
visitor(m_dst);
|
|
|
|
visitor(m_base);
|
|
|
|
visitor(m_this_value);
|
|
|
|
visitor(m_property);
|
|
|
|
}
|
2023-07-06 17:10:40 -04:00
|
|
|
|
|
|
|
private:
|
2024-02-04 08:00:54 +01:00
|
|
|
Operand m_dst;
|
|
|
|
Operand m_base;
|
|
|
|
Operand m_this_value;
|
|
|
|
Operand m_property;
|
2023-07-06 17:10:40 -04:00
|
|
|
};
|
|
|
|
|
2024-05-05 11:52:14 +02:00
|
|
|
class Jump final : public Instruction {
|
2021-06-04 12:07:38 +02:00
|
|
|
public:
|
2021-06-09 06:49:58 +04:30
|
|
|
constexpr static bool IsTerminator = true;
|
|
|
|
|
2024-05-05 11:52:14 +02:00
|
|
|
explicit Jump(Label target)
|
2024-05-06 11:09:09 +02:00
|
|
|
: Instruction(Type::Jump)
|
2024-05-05 11:52:14 +02:00
|
|
|
, m_target(target)
|
2021-06-04 12:07:38 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2023-12-16 17:49:34 +03:30
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2024-05-06 06:44:08 +02:00
|
|
|
void visit_labels_impl(Function<void(Label&)> visitor)
|
|
|
|
{
|
|
|
|
visitor(m_target);
|
|
|
|
}
|
2021-06-13 20:40:20 +04:30
|
|
|
|
2024-05-05 11:52:14 +02:00
|
|
|
auto& target() const { return m_target; }
|
2021-06-09 06:49:58 +04:30
|
|
|
|
|
|
|
protected:
|
2024-05-05 11:52:14 +02:00
|
|
|
Label m_target;
|
2021-06-04 12:07:38 +02:00
|
|
|
};
|
|
|
|
|
2024-05-05 11:52:14 +02:00
|
|
|
class JumpIf final : public Instruction {
|
2021-06-04 12:20:44 +02:00
|
|
|
public:
|
2024-05-05 11:52:14 +02:00
|
|
|
constexpr static bool IsTerminator = true;
|
|
|
|
|
2024-02-04 08:00:54 +01:00
|
|
|
explicit JumpIf(Operand condition, Label true_target, Label false_target)
|
2024-05-06 11:09:09 +02:00
|
|
|
: Instruction(Type::JumpIf)
|
2024-02-04 08:00:54 +01:00
|
|
|
, m_condition(condition)
|
2024-05-05 11:52:14 +02:00
|
|
|
, m_true_target(true_target)
|
|
|
|
, m_false_target(false_target)
|
2021-06-04 12:20:44 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2023-12-16 17:49:34 +03:30
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2024-05-06 06:44:08 +02:00
|
|
|
void visit_labels_impl(Function<void(Label&)> visitor)
|
|
|
|
{
|
|
|
|
visitor(m_true_target);
|
|
|
|
visitor(m_false_target);
|
|
|
|
}
|
2024-05-12 18:49:03 +02:00
|
|
|
void visit_operands_impl(Function<void(Operand&)> visitor)
|
|
|
|
{
|
|
|
|
visitor(m_condition);
|
|
|
|
}
|
2024-02-04 08:00:54 +01:00
|
|
|
|
|
|
|
Operand condition() const { return m_condition; }
|
2024-05-05 11:52:14 +02:00
|
|
|
auto& true_target() const { return m_true_target; }
|
|
|
|
auto& false_target() const { return m_false_target; }
|
2024-02-04 08:00:54 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
Operand m_condition;
|
2024-05-05 11:52:14 +02:00
|
|
|
Label m_true_target;
|
|
|
|
Label m_false_target;
|
2021-06-04 12:20:44 +02:00
|
|
|
};
|
|
|
|
|
2024-05-06 10:15:17 +02:00
|
|
|
class JumpTrue final : public Instruction {
|
|
|
|
public:
|
|
|
|
constexpr static bool IsTerminator = true;
|
|
|
|
|
|
|
|
explicit JumpTrue(Operand condition, Label target)
|
2024-05-06 11:09:09 +02:00
|
|
|
: Instruction(Type::JumpTrue)
|
2024-05-06 10:15:17 +02:00
|
|
|
, m_condition(condition)
|
|
|
|
, m_target(target)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
|
|
|
void visit_labels_impl(Function<void(Label&)> visitor)
|
|
|
|
{
|
|
|
|
visitor(m_target);
|
|
|
|
}
|
2024-05-12 18:49:03 +02:00
|
|
|
void visit_operands_impl(Function<void(Operand&)> visitor)
|
|
|
|
{
|
|
|
|
visitor(m_condition);
|
|
|
|
}
|
2024-05-06 10:15:17 +02:00
|
|
|
|
|
|
|
Operand condition() const { return m_condition; }
|
|
|
|
auto& target() const { return m_target; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
Operand m_condition;
|
|
|
|
Label m_target;
|
|
|
|
};
|
|
|
|
|
|
|
|
class JumpFalse final : public Instruction {
|
|
|
|
public:
|
|
|
|
constexpr static bool IsTerminator = true;
|
|
|
|
|
|
|
|
explicit JumpFalse(Operand condition, Label target)
|
2024-05-06 11:09:09 +02:00
|
|
|
: Instruction(Type::JumpFalse)
|
2024-05-06 10:15:17 +02:00
|
|
|
, m_condition(condition)
|
|
|
|
, m_target(target)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
|
|
|
void visit_labels_impl(Function<void(Label&)> visitor)
|
|
|
|
{
|
|
|
|
visitor(m_target);
|
|
|
|
}
|
2024-05-12 18:49:03 +02:00
|
|
|
void visit_operands_impl(Function<void(Operand&)> visitor)
|
|
|
|
{
|
|
|
|
visitor(m_condition);
|
|
|
|
}
|
2024-05-06 10:15:17 +02:00
|
|
|
|
|
|
|
Operand condition() const { return m_condition; }
|
|
|
|
auto& target() const { return m_target; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
Operand m_condition;
|
|
|
|
Label m_target;
|
|
|
|
};
|
|
|
|
|
2024-05-13 09:23:53 +02:00
|
|
|
#define JS_ENUMERATE_COMPARISON_OPS(X) \
|
|
|
|
X(LessThan, less_than, <) \
|
|
|
|
X(LessThanEquals, less_than_equals, <=) \
|
|
|
|
X(GreaterThan, greater_than, >) \
|
|
|
|
X(GreaterThanEquals, greater_than_equals, >=) \
|
|
|
|
X(LooselyEquals, loosely_equals, ==) \
|
|
|
|
X(LooselyInequals, loosely_inequals, !=) \
|
|
|
|
X(StrictlyEquals, strict_equals, ==) \
|
|
|
|
X(StrictlyInequals, strict_inequals, !=)
|
|
|
|
|
|
|
|
#define DECLARE_COMPARISON_OP(op_TitleCase, op_snake_case, numeric_operator) \
|
2024-05-09 15:13:31 +02:00
|
|
|
class Jump##op_TitleCase final : public Instruction { \
|
|
|
|
public: \
|
|
|
|
constexpr static bool IsTerminator = true; \
|
|
|
|
\
|
|
|
|
explicit Jump##op_TitleCase(Operand lhs, Operand rhs, Label true_target, Label false_target) \
|
|
|
|
: Instruction(Type::Jump##op_TitleCase) \
|
|
|
|
, m_lhs(lhs) \
|
|
|
|
, m_rhs(rhs) \
|
|
|
|
, m_true_target(true_target) \
|
|
|
|
, m_false_target(false_target) \
|
|
|
|
{ \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const; \
|
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const; \
|
|
|
|
void visit_labels_impl(Function<void(Label&)> visitor) \
|
|
|
|
{ \
|
|
|
|
visitor(m_true_target); \
|
|
|
|
visitor(m_false_target); \
|
2024-05-12 18:49:03 +02:00
|
|
|
} \
|
|
|
|
void visit_operands_impl(Function<void(Operand&)> visitor) \
|
|
|
|
{ \
|
|
|
|
visitor(m_lhs); \
|
|
|
|
visitor(m_rhs); \
|
2024-05-09 15:13:31 +02:00
|
|
|
} \
|
|
|
|
\
|
|
|
|
Operand lhs() const { return m_lhs; } \
|
|
|
|
Operand rhs() const { return m_rhs; } \
|
|
|
|
auto& true_target() const { return m_true_target; } \
|
|
|
|
auto& false_target() const { return m_false_target; } \
|
|
|
|
\
|
|
|
|
private: \
|
|
|
|
Operand m_lhs; \
|
|
|
|
Operand m_rhs; \
|
|
|
|
Label m_true_target; \
|
|
|
|
Label m_false_target; \
|
|
|
|
};
|
|
|
|
|
|
|
|
JS_ENUMERATE_COMPARISON_OPS(DECLARE_COMPARISON_OP)
|
|
|
|
|
2024-05-05 11:52:14 +02:00
|
|
|
class JumpNullish final : public Instruction {
|
2021-06-08 02:18:47 +02:00
|
|
|
public:
|
2024-05-05 11:52:14 +02:00
|
|
|
constexpr static bool IsTerminator = true;
|
|
|
|
|
2024-02-04 08:00:54 +01:00
|
|
|
explicit JumpNullish(Operand condition, Label true_target, Label false_target)
|
2024-05-06 11:09:09 +02:00
|
|
|
: Instruction(Type::JumpNullish)
|
2024-02-04 08:00:54 +01:00
|
|
|
, m_condition(condition)
|
2024-05-05 11:52:14 +02:00
|
|
|
, m_true_target(true_target)
|
|
|
|
, m_false_target(false_target)
|
2021-06-08 02:18:47 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2023-12-16 17:49:34 +03:30
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2024-05-06 06:44:08 +02:00
|
|
|
void visit_labels_impl(Function<void(Label&)> visitor)
|
|
|
|
{
|
|
|
|
visitor(m_true_target);
|
|
|
|
visitor(m_false_target);
|
|
|
|
}
|
2024-05-12 18:49:03 +02:00
|
|
|
void visit_operands_impl(Function<void(Operand&)> visitor)
|
|
|
|
{
|
|
|
|
visitor(m_condition);
|
|
|
|
}
|
2024-02-04 08:00:54 +01:00
|
|
|
|
|
|
|
Operand condition() const { return m_condition; }
|
2024-05-05 11:52:14 +02:00
|
|
|
auto& true_target() const { return m_true_target; }
|
|
|
|
auto& false_target() const { return m_false_target; }
|
2024-02-04 08:00:54 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
Operand m_condition;
|
2024-05-05 11:52:14 +02:00
|
|
|
Label m_true_target;
|
|
|
|
Label m_false_target;
|
2021-06-08 02:18:47 +02:00
|
|
|
};
|
|
|
|
|
2024-05-05 11:52:14 +02:00
|
|
|
class JumpUndefined final : public Instruction {
|
2021-06-13 12:24:40 -07:00
|
|
|
public:
|
2024-05-05 11:52:14 +02:00
|
|
|
constexpr static bool IsTerminator = true;
|
|
|
|
|
2024-02-04 08:00:54 +01:00
|
|
|
explicit JumpUndefined(Operand condition, Label true_target, Label false_target)
|
2024-05-06 11:09:09 +02:00
|
|
|
: Instruction(Type::JumpUndefined)
|
2024-02-04 08:00:54 +01:00
|
|
|
, m_condition(condition)
|
2024-05-05 11:52:14 +02:00
|
|
|
, m_true_target(true_target)
|
|
|
|
, m_false_target(false_target)
|
2021-06-13 12:24:40 -07:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2023-12-16 17:49:34 +03:30
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2024-05-06 06:44:08 +02:00
|
|
|
void visit_labels_impl(Function<void(Label&)> visitor)
|
|
|
|
{
|
|
|
|
visitor(m_true_target);
|
|
|
|
visitor(m_false_target);
|
|
|
|
}
|
2024-05-12 18:49:03 +02:00
|
|
|
void visit_operands_impl(Function<void(Operand&)> visitor)
|
|
|
|
{
|
|
|
|
visitor(m_condition);
|
|
|
|
}
|
2024-02-04 08:00:54 +01:00
|
|
|
|
|
|
|
Operand condition() const { return m_condition; }
|
2024-05-05 11:52:14 +02:00
|
|
|
auto& true_target() const { return m_true_target; }
|
|
|
|
auto& false_target() const { return m_false_target; }
|
2024-02-04 08:00:54 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
Operand m_condition;
|
2024-05-05 11:52:14 +02:00
|
|
|
Label m_true_target;
|
|
|
|
Label m_false_target;
|
2021-06-13 12:24:40 -07:00
|
|
|
};
|
|
|
|
|
2024-05-10 07:12:18 +02:00
|
|
|
enum class CallType : u8 {
|
2023-07-02 15:59:54 +02:00
|
|
|
Call,
|
|
|
|
Construct,
|
|
|
|
DirectEval,
|
|
|
|
};
|
2021-06-10 23:01:49 +02:00
|
|
|
|
2023-07-02 16:33:00 +02:00
|
|
|
class Call final : public Instruction {
|
|
|
|
public:
|
2024-05-06 10:42:52 +02:00
|
|
|
static constexpr bool IsVariableLength = true;
|
|
|
|
|
2024-05-07 21:36:56 +02:00
|
|
|
Call(CallType type, Operand dst, Operand callee, Operand this_value, ReadonlySpan<ScopedOperand> arguments, Optional<StringTableIndex> expression_string = {}, Optional<Builtin> builtin = {})
|
2024-05-06 11:09:09 +02:00
|
|
|
: Instruction(Type::Call)
|
2024-02-04 08:00:54 +01:00
|
|
|
, m_dst(dst)
|
2023-07-02 16:33:00 +02:00
|
|
|
, m_callee(callee)
|
|
|
|
, m_this_value(this_value)
|
2024-02-20 15:59:45 +01:00
|
|
|
, m_argument_count(arguments.size())
|
2023-07-02 16:33:00 +02:00
|
|
|
, m_type(type)
|
2023-11-17 11:48:30 +01:00
|
|
|
, m_builtin(builtin)
|
2024-05-10 07:12:18 +02:00
|
|
|
, m_expression_string(expression_string)
|
2023-07-02 16:33:00 +02:00
|
|
|
{
|
2024-02-20 15:59:45 +01:00
|
|
|
for (size_t i = 0; i < arguments.size(); ++i)
|
|
|
|
m_arguments[i] = arguments[i];
|
|
|
|
}
|
|
|
|
|
2024-05-06 11:09:09 +02:00
|
|
|
size_t length_impl() const
|
2024-02-20 15:59:45 +01:00
|
|
|
{
|
2024-05-06 11:09:09 +02:00
|
|
|
return round_up_to_power_of_two(alignof(void*), sizeof(*this) + sizeof(Operand) * m_argument_count);
|
2023-07-02 16:33:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
CallType call_type() const { return m_type; }
|
2024-02-04 08:00:54 +01:00
|
|
|
Operand dst() const { return m_dst; }
|
|
|
|
Operand callee() const { return m_callee; }
|
|
|
|
Operand this_value() const { return m_this_value; }
|
2023-07-02 16:33:00 +02:00
|
|
|
Optional<StringTableIndex> const& expression_string() const { return m_expression_string; }
|
|
|
|
|
2023-07-03 15:15:24 +02:00
|
|
|
u32 argument_count() const { return m_argument_count; }
|
|
|
|
|
2023-11-17 11:48:30 +01:00
|
|
|
Optional<Builtin> const& builtin() const { return m_builtin; }
|
|
|
|
|
2023-07-02 16:33:00 +02:00
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 17:49:34 +03:30
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2024-05-12 18:49:03 +02:00
|
|
|
void visit_operands_impl(Function<void(Operand&)> visitor)
|
|
|
|
{
|
|
|
|
visitor(m_dst);
|
|
|
|
visitor(m_callee);
|
|
|
|
visitor(m_this_value);
|
|
|
|
for (size_t i = 0; i < m_argument_count; i++)
|
|
|
|
visitor(m_arguments[i]);
|
|
|
|
}
|
2023-07-02 16:33:00 +02:00
|
|
|
|
|
|
|
private:
|
2024-02-04 08:00:54 +01:00
|
|
|
Operand m_dst;
|
|
|
|
Operand m_callee;
|
|
|
|
Operand m_this_value;
|
2023-07-02 16:33:00 +02:00
|
|
|
u32 m_argument_count { 0 };
|
|
|
|
CallType m_type;
|
2023-11-17 11:48:30 +01:00
|
|
|
Optional<Builtin> m_builtin;
|
2024-05-10 07:12:18 +02:00
|
|
|
Optional<StringTableIndex> m_expression_string;
|
2024-02-20 15:59:45 +01:00
|
|
|
Operand m_arguments[];
|
2023-07-02 16:33:00 +02:00
|
|
|
};
|
|
|
|
|
2023-07-02 15:59:54 +02:00
|
|
|
class CallWithArgumentArray final : public Instruction {
|
|
|
|
public:
|
2024-02-04 08:00:54 +01:00
|
|
|
CallWithArgumentArray(CallType type, Operand dst, Operand callee, Operand this_value, Operand arguments, Optional<StringTableIndex> expression_string = {})
|
2024-05-06 11:09:09 +02:00
|
|
|
: Instruction(Type::CallWithArgumentArray)
|
2024-02-04 08:00:54 +01:00
|
|
|
, m_dst(dst)
|
2021-06-05 15:15:30 +02:00
|
|
|
, m_callee(callee)
|
|
|
|
, m_this_value(this_value)
|
2024-02-04 08:00:54 +01:00
|
|
|
, m_arguments(arguments)
|
2021-06-10 23:01:49 +02:00
|
|
|
, m_type(type)
|
2022-10-01 01:36:06 +02:00
|
|
|
, m_expression_string(expression_string)
|
2021-06-05 15:15:30 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2024-02-04 08:00:54 +01:00
|
|
|
Operand dst() const { return m_dst; }
|
2023-07-02 16:33:00 +02:00
|
|
|
CallType call_type() const { return m_type; }
|
2024-02-04 08:00:54 +01:00
|
|
|
Operand callee() const { return m_callee; }
|
|
|
|
Operand this_value() const { return m_this_value; }
|
|
|
|
Operand arguments() const { return m_arguments; }
|
2023-07-02 16:33:00 +02:00
|
|
|
Optional<StringTableIndex> const& expression_string() const { return m_expression_string; }
|
|
|
|
|
2022-02-07 14:36:45 +01:00
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 17:49:34 +03:30
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2024-05-12 18:49:03 +02:00
|
|
|
void visit_operands_impl(Function<void(Operand&)> visitor)
|
|
|
|
{
|
|
|
|
visitor(m_dst);
|
|
|
|
visitor(m_callee);
|
|
|
|
visitor(m_this_value);
|
|
|
|
visitor(m_arguments);
|
|
|
|
}
|
2021-06-07 15:12:43 +02:00
|
|
|
|
2021-06-05 15:15:30 +02:00
|
|
|
private:
|
2024-02-04 08:00:54 +01:00
|
|
|
Operand m_dst;
|
|
|
|
Operand m_callee;
|
|
|
|
Operand m_this_value;
|
|
|
|
Operand m_arguments;
|
2021-06-10 23:01:49 +02:00
|
|
|
CallType m_type;
|
2022-10-01 01:36:06 +02:00
|
|
|
Optional<StringTableIndex> m_expression_string;
|
2021-06-05 15:15:30 +02:00
|
|
|
};
|
|
|
|
|
2023-07-02 15:59:54 +02:00
|
|
|
class SuperCallWithArgumentArray : public Instruction {
|
2022-08-30 18:03:02 +02:00
|
|
|
public:
|
2024-02-04 08:00:54 +01:00
|
|
|
explicit SuperCallWithArgumentArray(Operand dst, Operand arguments, bool is_synthetic)
|
2024-05-06 11:09:09 +02:00
|
|
|
: Instruction(Type::SuperCallWithArgumentArray)
|
2024-02-04 08:00:54 +01:00
|
|
|
, m_dst(dst)
|
|
|
|
, m_arguments(arguments)
|
2022-08-30 18:03:02 +02:00
|
|
|
, m_is_synthetic(is_synthetic)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 17:49:34 +03:30
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2024-05-12 18:49:03 +02:00
|
|
|
void visit_operands_impl(Function<void(Operand&)> visitor)
|
|
|
|
{
|
|
|
|
visitor(m_dst);
|
|
|
|
visitor(m_arguments);
|
|
|
|
}
|
2022-08-30 18:03:02 +02:00
|
|
|
|
2024-02-04 08:00:54 +01:00
|
|
|
Operand dst() const { return m_dst; }
|
|
|
|
Operand arguments() const { return m_arguments; }
|
2023-10-29 15:34:01 +01:00
|
|
|
bool is_synthetic() const { return m_is_synthetic; }
|
|
|
|
|
2022-08-30 18:03:02 +02:00
|
|
|
private:
|
2024-02-04 08:00:54 +01:00
|
|
|
Operand m_dst;
|
|
|
|
Operand m_arguments;
|
2022-08-30 18:03:02 +02:00
|
|
|
bool m_is_synthetic;
|
|
|
|
};
|
|
|
|
|
2021-06-30 15:42:13 -03:00
|
|
|
class NewClass final : public Instruction {
|
|
|
|
public:
|
2024-05-11 22:54:41 +00:00
|
|
|
static constexpr bool IsVariableLength = true;
|
|
|
|
|
|
|
|
explicit NewClass(Operand dst, Optional<Operand> super_class, ClassExpression const& class_expression, Optional<IdentifierTableIndex> lhs_name, ReadonlySpan<Optional<ScopedOperand>> elements_keys)
|
2024-05-06 11:09:09 +02:00
|
|
|
: Instruction(Type::NewClass)
|
2024-02-04 08:00:54 +01:00
|
|
|
, m_dst(dst)
|
|
|
|
, m_super_class(super_class)
|
2021-06-30 15:42:13 -03:00
|
|
|
, m_class_expression(class_expression)
|
2023-06-28 18:17:13 +02:00
|
|
|
, m_lhs_name(lhs_name)
|
2024-05-11 22:54:41 +00:00
|
|
|
, m_element_keys_count(elements_keys.size())
|
|
|
|
{
|
|
|
|
for (size_t i = 0; i < m_element_keys_count; i++) {
|
|
|
|
if (elements_keys[i].has_value())
|
|
|
|
m_element_keys[i] = elements_keys[i]->operand();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t length_impl() const
|
2021-06-30 15:42:13 -03:00
|
|
|
{
|
2024-05-11 22:54:41 +00:00
|
|
|
return round_up_to_power_of_two(alignof(void*), sizeof(*this) + sizeof(Optional<Operand>) * m_element_keys_count);
|
2021-06-30 15:42:13 -03:00
|
|
|
}
|
|
|
|
|
2022-02-07 14:36:45 +01:00
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 17:49:34 +03:30
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2024-05-12 18:49:03 +02:00
|
|
|
void visit_operands_impl(Function<void(Operand&)> visitor)
|
|
|
|
{
|
|
|
|
visitor(m_dst);
|
|
|
|
if (m_super_class.has_value())
|
|
|
|
visitor(m_super_class.value());
|
|
|
|
for (size_t i = 0; i < m_element_keys_count; i++) {
|
|
|
|
if (m_element_keys[i].has_value())
|
|
|
|
visitor(m_element_keys[i].value());
|
|
|
|
}
|
|
|
|
}
|
2021-06-30 15:42:13 -03:00
|
|
|
|
2024-02-04 08:00:54 +01:00
|
|
|
Operand dst() const { return m_dst; }
|
|
|
|
Optional<Operand> const& super_class() const { return m_super_class; }
|
2023-10-29 02:59:50 +01:00
|
|
|
ClassExpression const& class_expression() const { return m_class_expression; }
|
|
|
|
Optional<IdentifierTableIndex> const& lhs_name() const { return m_lhs_name; }
|
|
|
|
|
2021-06-30 15:42:13 -03:00
|
|
|
private:
|
2024-02-04 08:00:54 +01:00
|
|
|
Operand m_dst;
|
|
|
|
Optional<Operand> m_super_class;
|
2021-06-30 15:42:13 -03:00
|
|
|
ClassExpression const& m_class_expression;
|
2023-06-28 18:17:13 +02:00
|
|
|
Optional<IdentifierTableIndex> m_lhs_name;
|
2024-05-11 22:54:41 +00:00
|
|
|
size_t m_element_keys_count { 0 };
|
|
|
|
Optional<Operand> m_element_keys[];
|
2021-06-30 15:42:13 -03:00
|
|
|
};
|
|
|
|
|
2021-06-10 00:49:23 +02:00
|
|
|
class NewFunction final : public Instruction {
|
2021-06-05 15:14:09 +02:00
|
|
|
public:
|
2024-05-09 05:18:23 +00:00
|
|
|
explicit NewFunction(Operand dst, FunctionNode const& function_node, Optional<IdentifierTableIndex> lhs_name, Optional<Operand> home_object = {})
|
2024-05-06 11:09:09 +02:00
|
|
|
: Instruction(Type::NewFunction)
|
2024-02-04 08:00:54 +01:00
|
|
|
, m_dst(dst)
|
2021-06-10 00:49:23 +02:00
|
|
|
, m_function_node(function_node)
|
2023-06-28 18:17:13 +02:00
|
|
|
, m_lhs_name(lhs_name)
|
2023-06-16 10:25:05 +02:00
|
|
|
, m_home_object(move(home_object))
|
2021-06-05 15:14:09 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2024-05-10 17:32:19 +02:00
|
|
|
void execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 17:49:34 +03:30
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2024-05-12 18:49:03 +02:00
|
|
|
void visit_operands_impl(Function<void(Operand&)> visitor)
|
|
|
|
{
|
|
|
|
visitor(m_dst);
|
|
|
|
if (m_home_object.has_value())
|
|
|
|
visitor(m_home_object.value());
|
|
|
|
}
|
2021-06-05 15:14:09 +02:00
|
|
|
|
2024-02-04 08:00:54 +01:00
|
|
|
Operand dst() const { return m_dst; }
|
2024-05-09 05:18:23 +00:00
|
|
|
FunctionNode const& function_node() const { return m_function_node; }
|
2023-10-21 15:49:04 +02:00
|
|
|
Optional<IdentifierTableIndex> const& lhs_name() const { return m_lhs_name; }
|
2024-02-04 08:00:54 +01:00
|
|
|
Optional<Operand> const& home_object() const { return m_home_object; }
|
2023-10-21 15:49:04 +02:00
|
|
|
|
2021-06-05 15:14:09 +02:00
|
|
|
private:
|
2024-02-04 08:00:54 +01:00
|
|
|
Operand m_dst;
|
2024-05-09 05:18:23 +00:00
|
|
|
FunctionNode const& m_function_node;
|
2023-06-28 18:17:13 +02:00
|
|
|
Optional<IdentifierTableIndex> m_lhs_name;
|
2024-02-04 08:00:54 +01:00
|
|
|
Optional<Operand> m_home_object;
|
2021-06-05 15:14:09 +02:00
|
|
|
};
|
|
|
|
|
2023-06-16 16:34:47 +02:00
|
|
|
class BlockDeclarationInstantiation final : public Instruction {
|
|
|
|
public:
|
|
|
|
explicit BlockDeclarationInstantiation(ScopeNode const& scope_node)
|
2024-05-06 11:09:09 +02:00
|
|
|
: Instruction(Type::BlockDeclarationInstantiation)
|
2023-06-16 16:34:47 +02:00
|
|
|
, m_scope_node(scope_node)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2024-05-10 17:32:19 +02:00
|
|
|
void execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 17:49:34 +03:30
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2023-06-16 16:34:47 +02:00
|
|
|
|
2023-10-29 15:13:28 +01:00
|
|
|
ScopeNode const& scope_node() const { return m_scope_node; }
|
|
|
|
|
2023-06-16 16:34:47 +02:00
|
|
|
private:
|
|
|
|
ScopeNode const& m_scope_node;
|
|
|
|
};
|
|
|
|
|
2021-06-05 15:53:36 +02:00
|
|
|
class Return final : public Instruction {
|
|
|
|
public:
|
2021-06-09 06:49:58 +04:30
|
|
|
constexpr static bool IsTerminator = true;
|
|
|
|
|
2024-02-04 08:00:54 +01:00
|
|
|
explicit Return(Optional<Operand> value = {})
|
2024-05-06 11:09:09 +02:00
|
|
|
: Instruction(Type::Return)
|
2024-02-04 08:00:54 +01:00
|
|
|
, m_value(value)
|
2021-06-05 15:53:36 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2024-05-10 17:32:19 +02:00
|
|
|
void execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 17:49:34 +03:30
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2024-05-12 18:49:03 +02:00
|
|
|
void visit_operands_impl(Function<void(Operand&)> visitor)
|
|
|
|
{
|
|
|
|
if (m_value.has_value())
|
|
|
|
visitor(m_value.value());
|
|
|
|
}
|
2024-02-04 08:00:54 +01:00
|
|
|
|
|
|
|
Optional<Operand> const& value() const { return m_value; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
Optional<Operand> m_value;
|
2021-06-05 15:53:36 +02:00
|
|
|
};
|
|
|
|
|
2021-06-09 11:40:38 +02:00
|
|
|
class Increment final : public Instruction {
|
|
|
|
public:
|
2024-02-04 08:00:54 +01:00
|
|
|
explicit Increment(Operand dst)
|
2024-05-06 11:09:09 +02:00
|
|
|
: Instruction(Type::Increment)
|
2024-02-04 08:00:54 +01:00
|
|
|
, m_dst(dst)
|
2021-06-09 11:40:38 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2022-02-07 14:36:45 +01:00
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 17:49:34 +03:30
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2024-05-12 18:49:03 +02:00
|
|
|
void visit_operands_impl(Function<void(Operand&)> visitor)
|
|
|
|
{
|
|
|
|
visitor(m_dst);
|
|
|
|
}
|
2024-02-04 08:00:54 +01:00
|
|
|
|
|
|
|
Operand dst() const { return m_dst; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
Operand m_dst;
|
2021-06-09 11:40:38 +02:00
|
|
|
};
|
|
|
|
|
2024-02-20 11:45:01 +01:00
|
|
|
class PostfixIncrement final : public Instruction {
|
|
|
|
public:
|
|
|
|
explicit PostfixIncrement(Operand dst, Operand src)
|
2024-05-06 11:09:09 +02:00
|
|
|
: Instruction(Type::PostfixIncrement)
|
2024-02-20 11:45:01 +01:00
|
|
|
, m_dst(dst)
|
|
|
|
, m_src(src)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2024-05-12 18:49:03 +02:00
|
|
|
void visit_operands_impl(Function<void(Operand&)> visitor)
|
|
|
|
{
|
|
|
|
visitor(m_dst);
|
|
|
|
visitor(m_src);
|
|
|
|
}
|
2024-02-20 11:45:01 +01:00
|
|
|
|
|
|
|
Operand dst() const { return m_dst; }
|
|
|
|
Operand src() const { return m_src; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
Operand m_dst;
|
|
|
|
Operand m_src;
|
|
|
|
};
|
|
|
|
|
2021-06-09 11:40:38 +02:00
|
|
|
class Decrement final : public Instruction {
|
|
|
|
public:
|
2024-02-04 08:00:54 +01:00
|
|
|
explicit Decrement(Operand dst)
|
2024-05-06 11:09:09 +02:00
|
|
|
: Instruction(Type::Decrement)
|
2024-02-04 08:00:54 +01:00
|
|
|
, m_dst(dst)
|
2021-06-09 11:40:38 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2022-02-07 14:36:45 +01:00
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 17:49:34 +03:30
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2024-05-12 18:49:03 +02:00
|
|
|
void visit_operands_impl(Function<void(Operand&)> visitor)
|
|
|
|
{
|
|
|
|
visitor(m_dst);
|
|
|
|
}
|
2024-02-04 08:00:54 +01:00
|
|
|
|
|
|
|
Operand dst() const { return m_dst; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
Operand m_dst;
|
2021-06-09 11:40:38 +02:00
|
|
|
};
|
|
|
|
|
2024-02-20 11:45:01 +01:00
|
|
|
class PostfixDecrement final : public Instruction {
|
2023-06-16 10:51:40 +02:00
|
|
|
public:
|
2024-02-20 11:45:01 +01:00
|
|
|
explicit PostfixDecrement(Operand dst, Operand src)
|
2024-05-06 11:09:09 +02:00
|
|
|
: Instruction(Type::PostfixDecrement)
|
2024-02-04 08:00:54 +01:00
|
|
|
, m_dst(dst)
|
|
|
|
, m_src(src)
|
2023-06-16 10:51:40 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 17:49:34 +03:30
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2024-05-12 18:49:03 +02:00
|
|
|
void visit_operands_impl(Function<void(Operand&)> visitor)
|
|
|
|
{
|
|
|
|
visitor(m_dst);
|
|
|
|
visitor(m_src);
|
|
|
|
}
|
2024-02-04 08:00:54 +01:00
|
|
|
|
|
|
|
Operand dst() const { return m_dst; }
|
|
|
|
Operand src() const { return m_src; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
Operand m_dst;
|
|
|
|
Operand m_src;
|
2023-06-16 10:51:40 +02:00
|
|
|
};
|
|
|
|
|
2021-06-09 18:18:56 +02:00
|
|
|
class Throw final : public Instruction {
|
|
|
|
public:
|
|
|
|
constexpr static bool IsTerminator = true;
|
|
|
|
|
2024-02-04 08:00:54 +01:00
|
|
|
explicit Throw(Operand src)
|
2024-05-06 11:09:09 +02:00
|
|
|
: Instruction(Type::Throw)
|
2024-02-04 08:00:54 +01:00
|
|
|
, m_src(src)
|
2021-06-09 18:18:56 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2022-02-07 14:36:45 +01:00
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 17:49:34 +03:30
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2024-05-12 18:49:03 +02:00
|
|
|
void visit_operands_impl(Function<void(Operand&)> visitor)
|
|
|
|
{
|
|
|
|
visitor(m_src);
|
|
|
|
}
|
2024-02-04 08:00:54 +01:00
|
|
|
|
|
|
|
Operand src() const { return m_src; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
Operand m_src;
|
2021-06-09 18:18:56 +02:00
|
|
|
};
|
|
|
|
|
2022-12-09 18:48:57 +00:00
|
|
|
class ThrowIfNotObject final : public Instruction {
|
|
|
|
public:
|
2024-02-04 08:00:54 +01:00
|
|
|
ThrowIfNotObject(Operand src)
|
2024-05-06 11:09:09 +02:00
|
|
|
: Instruction(Type::ThrowIfNotObject)
|
2024-02-04 08:00:54 +01:00
|
|
|
, m_src(src)
|
2022-12-09 18:48:57 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 17:49:34 +03:30
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2024-05-12 18:49:03 +02:00
|
|
|
void visit_operands_impl(Function<void(Operand&)> visitor)
|
|
|
|
{
|
|
|
|
visitor(m_src);
|
|
|
|
}
|
2024-02-04 08:00:54 +01:00
|
|
|
|
|
|
|
Operand src() const { return m_src; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
Operand m_src;
|
2022-12-09 18:48:57 +00:00
|
|
|
};
|
|
|
|
|
2023-06-25 08:50:07 +02:00
|
|
|
class ThrowIfNullish final : public Instruction {
|
|
|
|
public:
|
2024-02-04 08:00:54 +01:00
|
|
|
explicit ThrowIfNullish(Operand src)
|
2024-05-06 11:09:09 +02:00
|
|
|
: Instruction(Type::ThrowIfNullish)
|
2024-02-04 08:00:54 +01:00
|
|
|
, m_src(src)
|
2023-06-25 08:50:07 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 17:49:34 +03:30
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2024-05-12 18:49:03 +02:00
|
|
|
void visit_operands_impl(Function<void(Operand&)> visitor)
|
|
|
|
{
|
|
|
|
visitor(m_src);
|
|
|
|
}
|
2024-02-04 08:00:54 +01:00
|
|
|
|
|
|
|
Operand src() const { return m_src; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
Operand m_src;
|
|
|
|
};
|
|
|
|
|
|
|
|
class ThrowIfTDZ final : public Instruction {
|
|
|
|
public:
|
|
|
|
explicit ThrowIfTDZ(Operand src)
|
2024-05-06 11:09:09 +02:00
|
|
|
: Instruction(Type::ThrowIfTDZ)
|
2024-02-04 08:00:54 +01:00
|
|
|
, m_src(src)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2024-05-12 18:49:03 +02:00
|
|
|
void visit_operands_impl(Function<void(Operand&)> visitor)
|
|
|
|
{
|
|
|
|
visitor(m_src);
|
|
|
|
}
|
2024-02-04 08:00:54 +01:00
|
|
|
|
|
|
|
Operand src() const { return m_src; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
Operand m_src;
|
2023-06-25 08:50:07 +02:00
|
|
|
};
|
|
|
|
|
2021-06-10 15:04:38 +02:00
|
|
|
class EnterUnwindContext final : public Instruction {
|
|
|
|
public:
|
2021-06-13 20:39:40 +04:30
|
|
|
constexpr static bool IsTerminator = true;
|
|
|
|
|
2024-03-06 08:36:19 +01:00
|
|
|
EnterUnwindContext(Label entry_point)
|
2024-05-06 11:09:09 +02:00
|
|
|
: Instruction(Type::EnterUnwindContext)
|
2021-06-13 20:39:40 +04:30
|
|
|
, m_entry_point(move(entry_point))
|
2021-06-10 15:04:38 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2023-12-16 17:49:34 +03:30
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2024-05-06 06:44:08 +02:00
|
|
|
void visit_labels_impl(Function<void(Label&)> visitor)
|
|
|
|
{
|
|
|
|
visitor(m_entry_point);
|
|
|
|
}
|
2021-06-13 20:40:20 +04:30
|
|
|
|
|
|
|
auto& entry_point() const { return m_entry_point; }
|
2021-06-10 15:04:38 +02:00
|
|
|
|
|
|
|
private:
|
2021-06-13 20:39:40 +04:30
|
|
|
Label m_entry_point;
|
2021-06-10 15:04:38 +02:00
|
|
|
};
|
|
|
|
|
2022-11-25 16:15:34 +01:00
|
|
|
class ScheduleJump final : public Instruction {
|
|
|
|
public:
|
|
|
|
// Note: We use this instruction to tell the next `finally` block to
|
|
|
|
// continue execution with a specific break/continue target;
|
|
|
|
constexpr static bool IsTerminator = true;
|
|
|
|
|
|
|
|
ScheduleJump(Label target)
|
2024-05-06 11:09:09 +02:00
|
|
|
: Instruction(Type::ScheduleJump)
|
2022-11-25 16:15:34 +01:00
|
|
|
, m_target(target)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
Label target() const { return m_target; }
|
|
|
|
|
2023-12-16 17:49:34 +03:30
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2024-05-06 06:44:08 +02:00
|
|
|
void visit_labels_impl(Function<void(Label&)> visitor)
|
|
|
|
{
|
|
|
|
visitor(m_target);
|
|
|
|
}
|
2022-11-25 16:15:34 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
Label m_target;
|
|
|
|
};
|
|
|
|
|
2023-06-16 16:43:24 +02:00
|
|
|
class LeaveLexicalEnvironment final : public Instruction {
|
2022-02-12 19:48:45 +03:30
|
|
|
public:
|
2023-06-16 16:43:24 +02:00
|
|
|
LeaveLexicalEnvironment()
|
2024-05-06 11:09:09 +02:00
|
|
|
: Instruction(Type::LeaveLexicalEnvironment)
|
2022-02-12 19:48:45 +03:30
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2024-05-10 17:32:19 +02:00
|
|
|
void execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 17:49:34 +03:30
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2022-02-12 19:48:45 +03:30
|
|
|
};
|
|
|
|
|
2024-05-11 22:54:41 +00:00
|
|
|
class LeavePrivateEnvironment final : public Instruction {
|
|
|
|
public:
|
|
|
|
LeavePrivateEnvironment()
|
|
|
|
: Instruction(Type::LeavePrivateEnvironment)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void execute_impl(Bytecode::Interpreter&) const;
|
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
|
|
|
};
|
|
|
|
|
2021-06-10 15:04:38 +02:00
|
|
|
class LeaveUnwindContext final : public Instruction {
|
|
|
|
public:
|
|
|
|
LeaveUnwindContext()
|
2024-05-06 11:09:09 +02:00
|
|
|
: Instruction(Type::LeaveUnwindContext)
|
2021-06-10 15:04:38 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2024-05-10 17:32:19 +02:00
|
|
|
void execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 17:49:34 +03:30
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2021-06-10 15:04:38 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
class ContinuePendingUnwind final : public Instruction {
|
|
|
|
public:
|
|
|
|
constexpr static bool IsTerminator = true;
|
|
|
|
|
2021-06-12 11:22:46 +02:00
|
|
|
explicit ContinuePendingUnwind(Label resume_target)
|
2024-05-06 11:09:09 +02:00
|
|
|
: Instruction(Type::ContinuePendingUnwind)
|
2021-06-10 15:04:38 +02:00
|
|
|
, m_resume_target(resume_target)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2023-12-16 17:49:34 +03:30
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2024-05-06 06:44:08 +02:00
|
|
|
void visit_labels_impl(Function<void(Label&)> visitor)
|
|
|
|
{
|
|
|
|
visitor(m_resume_target);
|
|
|
|
}
|
2021-06-13 20:40:20 +04:30
|
|
|
|
|
|
|
auto& resume_target() const { return m_resume_target; }
|
2021-06-10 15:04:38 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
Label m_resume_target;
|
|
|
|
};
|
2021-06-10 22:12:21 +02:00
|
|
|
|
2021-06-11 01:38:30 +04:30
|
|
|
class Yield final : public Instruction {
|
|
|
|
public:
|
|
|
|
constexpr static bool IsTerminator = true;
|
|
|
|
|
2024-02-04 08:00:54 +01:00
|
|
|
explicit Yield(Label continuation_label, Operand value)
|
2024-05-06 11:09:09 +02:00
|
|
|
: Instruction(Type::Yield)
|
2021-06-11 01:38:30 +04:30
|
|
|
, m_continuation_label(continuation_label)
|
2024-02-04 08:00:54 +01:00
|
|
|
, m_value(value)
|
2021-06-11 01:38:30 +04:30
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2024-02-04 08:00:54 +01:00
|
|
|
explicit Yield(nullptr_t, Operand value)
|
2024-05-06 11:09:09 +02:00
|
|
|
: Instruction(Type::Yield)
|
2024-02-04 08:00:54 +01:00
|
|
|
, m_value(value)
|
2021-06-11 01:38:30 +04:30
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2024-05-12 10:47:52 +02:00
|
|
|
void execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 17:49:34 +03:30
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2024-05-06 06:44:08 +02:00
|
|
|
void visit_labels_impl(Function<void(Label&)> visitor)
|
|
|
|
{
|
|
|
|
if (m_continuation_label.has_value())
|
|
|
|
visitor(m_continuation_label.value());
|
|
|
|
}
|
2024-05-12 18:49:03 +02:00
|
|
|
void visit_operands_impl(Function<void(Operand&)> visitor)
|
|
|
|
{
|
|
|
|
visitor(m_value);
|
|
|
|
}
|
2021-06-13 20:40:20 +04:30
|
|
|
|
|
|
|
auto& continuation() const { return m_continuation_label; }
|
2024-02-04 08:00:54 +01:00
|
|
|
Operand value() const { return m_value; }
|
2021-06-11 01:38:30 +04:30
|
|
|
|
|
|
|
private:
|
|
|
|
Optional<Label> m_continuation_label;
|
2024-02-04 08:00:54 +01:00
|
|
|
Operand m_value;
|
2021-06-11 01:38:30 +04:30
|
|
|
};
|
|
|
|
|
2024-05-18 17:25:43 +02:00
|
|
|
class PrepareYield final : public Instruction {
|
|
|
|
public:
|
|
|
|
explicit PrepareYield(Operand dest, Operand value)
|
|
|
|
: Instruction(Type::PrepareYield)
|
|
|
|
, m_dest(dest)
|
|
|
|
, m_value(value)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void execute_impl(Bytecode::Interpreter&) const;
|
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
|
|
|
void visit_operands_impl(Function<void(Operand&)> visitor)
|
|
|
|
{
|
|
|
|
visitor(m_dest);
|
|
|
|
visitor(m_value);
|
|
|
|
}
|
|
|
|
|
|
|
|
Operand destination() const { return m_dest; }
|
|
|
|
Operand value() const { return m_value; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
Operand m_dest;
|
|
|
|
Operand m_value;
|
|
|
|
};
|
|
|
|
|
2023-07-14 21:42:43 +01:00
|
|
|
class Await final : public Instruction {
|
|
|
|
public:
|
|
|
|
constexpr static bool IsTerminator = true;
|
|
|
|
|
2024-02-04 08:00:54 +01:00
|
|
|
explicit Await(Label continuation_label, Operand argument)
|
2024-05-06 11:09:09 +02:00
|
|
|
: Instruction(Type::Await)
|
2023-07-14 21:42:43 +01:00
|
|
|
, m_continuation_label(continuation_label)
|
2024-02-04 08:00:54 +01:00
|
|
|
, m_argument(argument)
|
2023-07-14 21:42:43 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2024-05-12 10:47:52 +02:00
|
|
|
void execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 17:49:34 +03:30
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2024-05-06 06:44:08 +02:00
|
|
|
void visit_labels_impl(Function<void(Label&)> visitor)
|
|
|
|
{
|
|
|
|
visitor(m_continuation_label);
|
|
|
|
}
|
2024-05-12 18:49:03 +02:00
|
|
|
void visit_operands_impl(Function<void(Operand&)> visitor)
|
|
|
|
{
|
|
|
|
visitor(m_argument);
|
|
|
|
}
|
2023-07-14 21:42:43 +01:00
|
|
|
|
|
|
|
auto& continuation() const { return m_continuation_label; }
|
2024-02-04 08:00:54 +01:00
|
|
|
Operand argument() const { return m_argument; }
|
2023-07-14 21:42:43 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
Label m_continuation_label;
|
2024-02-04 08:00:54 +01:00
|
|
|
Operand m_argument;
|
2023-07-14 21:42:43 +01:00
|
|
|
};
|
|
|
|
|
2021-06-13 13:40:48 -07:00
|
|
|
class GetIterator final : public Instruction {
|
|
|
|
public:
|
2024-02-04 08:00:54 +01:00
|
|
|
GetIterator(Operand dst, Operand iterable, IteratorHint hint = IteratorHint::Sync)
|
2024-05-06 11:09:09 +02:00
|
|
|
: Instruction(Type::GetIterator)
|
2024-02-04 08:00:54 +01:00
|
|
|
, m_dst(dst)
|
|
|
|
, m_iterable(iterable)
|
2023-06-27 19:24:34 +01:00
|
|
|
, m_hint(hint)
|
2021-06-13 13:40:48 -07:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2022-02-07 14:36:45 +01:00
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 17:49:34 +03:30
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2024-05-12 18:49:03 +02:00
|
|
|
void visit_operands_impl(Function<void(Operand&)> visitor)
|
|
|
|
{
|
|
|
|
visitor(m_dst);
|
|
|
|
visitor(m_iterable);
|
|
|
|
}
|
2023-06-27 19:24:34 +01:00
|
|
|
|
2024-02-04 08:00:54 +01:00
|
|
|
Operand dst() const { return m_dst; }
|
|
|
|
Operand iterable() const { return m_iterable; }
|
2023-10-29 15:53:36 +01:00
|
|
|
IteratorHint hint() const { return m_hint; }
|
|
|
|
|
2023-06-27 19:24:34 +01:00
|
|
|
private:
|
2024-02-04 08:00:54 +01:00
|
|
|
Operand m_dst;
|
|
|
|
Operand m_iterable;
|
2023-06-27 19:24:34 +01:00
|
|
|
IteratorHint m_hint { IteratorHint::Sync };
|
2021-06-13 13:40:48 -07:00
|
|
|
};
|
|
|
|
|
2023-12-07 10:44:41 +01:00
|
|
|
class GetObjectFromIteratorRecord final : public Instruction {
|
|
|
|
public:
|
2024-02-04 08:00:54 +01:00
|
|
|
GetObjectFromIteratorRecord(Operand object, Operand iterator_record)
|
2024-05-06 11:09:09 +02:00
|
|
|
: Instruction(Type::GetObjectFromIteratorRecord)
|
2023-12-07 10:44:41 +01:00
|
|
|
, m_object(object)
|
|
|
|
, m_iterator_record(iterator_record)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 17:49:34 +03:30
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2024-05-12 18:49:03 +02:00
|
|
|
void visit_operands_impl(Function<void(Operand&)> visitor)
|
|
|
|
{
|
|
|
|
visitor(m_object);
|
|
|
|
visitor(m_iterator_record);
|
|
|
|
}
|
2023-12-07 10:44:41 +01:00
|
|
|
|
2024-02-04 08:00:54 +01:00
|
|
|
Operand object() const { return m_object; }
|
|
|
|
Operand iterator_record() const { return m_iterator_record; }
|
2023-12-07 10:44:41 +01:00
|
|
|
|
|
|
|
private:
|
2024-02-04 08:00:54 +01:00
|
|
|
Operand m_object;
|
|
|
|
Operand m_iterator_record;
|
2023-12-07 10:44:41 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
class GetNextMethodFromIteratorRecord final : public Instruction {
|
|
|
|
public:
|
2024-02-04 08:00:54 +01:00
|
|
|
GetNextMethodFromIteratorRecord(Operand next_method, Operand iterator_record)
|
2024-05-06 11:09:09 +02:00
|
|
|
: Instruction(Type::GetNextMethodFromIteratorRecord)
|
2023-12-07 10:44:41 +01:00
|
|
|
, m_next_method(next_method)
|
|
|
|
, m_iterator_record(iterator_record)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 17:49:34 +03:30
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2024-05-12 18:49:03 +02:00
|
|
|
void visit_operands_impl(Function<void(Operand&)> visitor)
|
|
|
|
{
|
|
|
|
visitor(m_next_method);
|
|
|
|
visitor(m_iterator_record);
|
|
|
|
}
|
2023-12-07 10:44:41 +01:00
|
|
|
|
2024-02-04 08:00:54 +01:00
|
|
|
Operand next_method() const { return m_next_method; }
|
|
|
|
Operand iterator_record() const { return m_iterator_record; }
|
2023-12-07 10:44:41 +01:00
|
|
|
|
|
|
|
private:
|
2024-02-04 08:00:54 +01:00
|
|
|
Operand m_next_method;
|
|
|
|
Operand m_iterator_record;
|
2023-12-07 10:44:41 +01:00
|
|
|
};
|
|
|
|
|
2022-12-09 18:48:57 +00:00
|
|
|
class GetMethod final : public Instruction {
|
|
|
|
public:
|
2024-02-04 08:00:54 +01:00
|
|
|
GetMethod(Operand dst, Operand object, IdentifierTableIndex property)
|
2024-05-06 11:09:09 +02:00
|
|
|
: Instruction(Type::GetMethod)
|
2024-02-04 08:00:54 +01:00
|
|
|
, m_dst(dst)
|
|
|
|
, m_object(object)
|
2022-12-09 18:48:57 +00:00
|
|
|
, m_property(property)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 17:49:34 +03:30
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2024-05-12 18:49:03 +02:00
|
|
|
void visit_operands_impl(Function<void(Operand&)> visitor)
|
|
|
|
{
|
|
|
|
visitor(m_dst);
|
|
|
|
visitor(m_object);
|
|
|
|
}
|
2022-12-09 18:48:57 +00:00
|
|
|
|
2024-02-04 08:00:54 +01:00
|
|
|
Operand dst() const { return m_dst; }
|
|
|
|
Operand object() const { return m_object; }
|
2023-10-30 00:04:52 +01:00
|
|
|
IdentifierTableIndex property() const { return m_property; }
|
|
|
|
|
2022-12-09 18:48:57 +00:00
|
|
|
private:
|
2024-02-04 08:00:54 +01:00
|
|
|
Operand m_dst;
|
|
|
|
Operand m_object;
|
2022-12-09 18:48:57 +00:00
|
|
|
IdentifierTableIndex m_property;
|
|
|
|
};
|
|
|
|
|
2022-03-18 20:18:19 +03:30
|
|
|
class GetObjectPropertyIterator final : public Instruction {
|
|
|
|
public:
|
2024-02-04 08:00:54 +01:00
|
|
|
GetObjectPropertyIterator(Operand dst, Operand object)
|
2024-05-06 11:09:09 +02:00
|
|
|
: Instruction(Type::GetObjectPropertyIterator)
|
2024-02-04 08:00:54 +01:00
|
|
|
, m_dst(dst)
|
|
|
|
, m_object(object)
|
2022-03-18 20:18:19 +03:30
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 17:49:34 +03:30
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2024-05-12 18:49:03 +02:00
|
|
|
void visit_operands_impl(Function<void(Operand&)> visitor)
|
|
|
|
{
|
|
|
|
visitor(m_dst);
|
|
|
|
visitor(m_object);
|
|
|
|
}
|
2024-02-04 08:00:54 +01:00
|
|
|
|
|
|
|
Operand dst() const { return m_dst; }
|
|
|
|
Operand object() const { return m_object; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
Operand m_dst;
|
|
|
|
Operand m_object;
|
2022-03-18 20:18:19 +03:30
|
|
|
};
|
|
|
|
|
2022-12-09 18:48:57 +00:00
|
|
|
class IteratorClose final : public Instruction {
|
|
|
|
public:
|
2024-02-04 08:00:54 +01:00
|
|
|
IteratorClose(Operand iterator_record, Completion::Type completion_type, Optional<Value> completion_value)
|
2024-05-06 11:09:09 +02:00
|
|
|
: Instruction(Type::IteratorClose)
|
2024-02-04 08:00:54 +01:00
|
|
|
, m_iterator_record(iterator_record)
|
2022-12-09 18:48:57 +00:00
|
|
|
, m_completion_type(completion_type)
|
|
|
|
, m_completion_value(completion_value)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 17:49:34 +03:30
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2024-05-12 18:49:03 +02:00
|
|
|
void visit_operands_impl(Function<void(Operand&)> visitor)
|
|
|
|
{
|
|
|
|
visitor(m_iterator_record);
|
|
|
|
}
|
2022-12-09 18:48:57 +00:00
|
|
|
|
2024-02-04 08:00:54 +01:00
|
|
|
Operand iterator_record() const { return m_iterator_record; }
|
2023-10-29 16:59:53 +01:00
|
|
|
Completion::Type completion_type() const { return m_completion_type; }
|
|
|
|
Optional<Value> const& completion_value() const { return m_completion_value; }
|
|
|
|
|
2022-12-09 18:48:57 +00:00
|
|
|
private:
|
2024-02-04 08:00:54 +01:00
|
|
|
Operand m_iterator_record;
|
2022-12-09 18:48:57 +00:00
|
|
|
Completion::Type m_completion_type { Completion::Type::Normal };
|
|
|
|
Optional<Value> m_completion_value;
|
|
|
|
};
|
|
|
|
|
2023-07-14 21:42:43 +01:00
|
|
|
class AsyncIteratorClose final : public Instruction {
|
|
|
|
public:
|
2024-02-04 08:00:54 +01:00
|
|
|
AsyncIteratorClose(Operand iterator_record, Completion::Type completion_type, Optional<Value> completion_value)
|
2024-05-06 11:09:09 +02:00
|
|
|
: Instruction(Type::AsyncIteratorClose)
|
2024-02-04 08:00:54 +01:00
|
|
|
, m_iterator_record(iterator_record)
|
2023-07-14 21:42:43 +01:00
|
|
|
, m_completion_type(completion_type)
|
|
|
|
, m_completion_value(completion_value)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 17:49:34 +03:30
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2024-05-12 18:49:03 +02:00
|
|
|
void visit_operands_impl(Function<void(Operand&)> visitor)
|
|
|
|
{
|
|
|
|
visitor(m_iterator_record);
|
|
|
|
}
|
2023-07-14 21:42:43 +01:00
|
|
|
|
2024-02-04 08:00:54 +01:00
|
|
|
Operand iterator_record() const { return m_iterator_record; }
|
2023-10-30 02:17:24 +01:00
|
|
|
Completion::Type completion_type() const { return m_completion_type; }
|
|
|
|
Optional<Value> const& completion_value() const { return m_completion_value; }
|
|
|
|
|
2023-07-14 21:42:43 +01:00
|
|
|
private:
|
2024-02-04 08:00:54 +01:00
|
|
|
Operand m_iterator_record;
|
2023-07-14 21:42:43 +01:00
|
|
|
Completion::Type m_completion_type { Completion::Type::Normal };
|
|
|
|
Optional<Value> m_completion_value;
|
|
|
|
};
|
|
|
|
|
2021-06-13 13:40:48 -07:00
|
|
|
class IteratorNext final : public Instruction {
|
|
|
|
public:
|
2024-02-04 08:00:54 +01:00
|
|
|
IteratorNext(Operand dst, Operand iterator_record)
|
2024-05-06 11:09:09 +02:00
|
|
|
: Instruction(Type::IteratorNext)
|
2024-02-04 08:00:54 +01:00
|
|
|
, m_dst(dst)
|
|
|
|
, m_iterator_record(iterator_record)
|
2021-06-13 13:40:48 -07:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2022-02-07 14:36:45 +01:00
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 17:49:34 +03:30
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2024-05-12 18:49:03 +02:00
|
|
|
void visit_operands_impl(Function<void(Operand&)> visitor)
|
|
|
|
{
|
|
|
|
visitor(m_dst);
|
|
|
|
visitor(m_iterator_record);
|
|
|
|
}
|
2024-02-04 08:00:54 +01:00
|
|
|
|
|
|
|
Operand dst() const { return m_dst; }
|
|
|
|
Operand iterator_record() const { return m_iterator_record; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
Operand m_dst;
|
|
|
|
Operand m_iterator_record;
|
2021-06-13 13:40:48 -07:00
|
|
|
};
|
|
|
|
|
2021-10-24 14:43:00 +02:00
|
|
|
class ResolveThisBinding final : public Instruction {
|
|
|
|
public:
|
2024-05-31 20:41:29 +02:00
|
|
|
ResolveThisBinding()
|
2024-05-06 11:09:09 +02:00
|
|
|
: Instruction(Type::ResolveThisBinding)
|
2021-10-24 14:43:00 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2022-02-07 14:36:45 +01:00
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 17:49:34 +03:30
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2024-05-31 20:41:29 +02:00
|
|
|
void visit_operands_impl(Function<void(Operand&)>) { }
|
2021-10-24 14:43:00 +02:00
|
|
|
};
|
|
|
|
|
2023-05-15 18:45:16 +01:00
|
|
|
class ResolveSuperBase final : public Instruction {
|
|
|
|
public:
|
2024-02-04 08:00:54 +01:00
|
|
|
explicit ResolveSuperBase(Operand dst)
|
2024-05-06 11:09:09 +02:00
|
|
|
: Instruction(Type::ResolveSuperBase)
|
2024-02-04 08:00:54 +01:00
|
|
|
, m_dst(dst)
|
2023-05-15 18:45:16 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 17:49:34 +03:30
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2024-05-12 18:49:03 +02:00
|
|
|
void visit_operands_impl(Function<void(Operand&)> visitor)
|
|
|
|
{
|
|
|
|
visitor(m_dst);
|
|
|
|
}
|
2024-02-04 08:00:54 +01:00
|
|
|
|
|
|
|
Operand dst() const { return m_dst; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
Operand m_dst;
|
2023-05-15 18:45:16 +01:00
|
|
|
};
|
|
|
|
|
2022-03-19 19:40:21 +00:00
|
|
|
class GetNewTarget final : public Instruction {
|
|
|
|
public:
|
2024-02-04 08:00:54 +01:00
|
|
|
explicit GetNewTarget(Operand dst)
|
2024-05-06 11:09:09 +02:00
|
|
|
: Instruction(Type::GetNewTarget)
|
2024-02-04 08:00:54 +01:00
|
|
|
, m_dst(dst)
|
2022-03-19 19:40:21 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2024-05-10 17:32:19 +02:00
|
|
|
void execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 17:49:34 +03:30
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2024-05-12 18:49:03 +02:00
|
|
|
void visit_operands_impl(Function<void(Operand&)> visitor)
|
|
|
|
{
|
|
|
|
visitor(m_dst);
|
|
|
|
}
|
2024-02-04 08:00:54 +01:00
|
|
|
|
|
|
|
Operand dst() const { return m_dst; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
Operand m_dst;
|
2022-03-19 19:40:21 +00:00
|
|
|
};
|
|
|
|
|
2023-07-11 23:07:12 -04:00
|
|
|
class GetImportMeta final : public Instruction {
|
|
|
|
public:
|
2024-02-04 08:00:54 +01:00
|
|
|
explicit GetImportMeta(Operand dst)
|
2024-05-06 11:09:09 +02:00
|
|
|
: Instruction(Type::GetImportMeta)
|
2024-02-04 08:00:54 +01:00
|
|
|
, m_dst(dst)
|
2023-07-11 23:07:12 -04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2024-05-10 17:32:19 +02:00
|
|
|
void execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 17:49:34 +03:30
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2024-05-12 18:49:03 +02:00
|
|
|
void visit_operands_impl(Function<void(Operand&)> visitor)
|
|
|
|
{
|
|
|
|
visitor(m_dst);
|
|
|
|
}
|
2024-02-04 08:00:54 +01:00
|
|
|
|
|
|
|
Operand dst() const { return m_dst; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
Operand m_dst;
|
2023-07-11 23:07:12 -04:00
|
|
|
};
|
|
|
|
|
2024-06-14 09:37:26 +02:00
|
|
|
class TypeofBinding final : public Instruction {
|
2022-06-11 23:12:22 +01:00
|
|
|
public:
|
2024-06-14 09:37:26 +02:00
|
|
|
TypeofBinding(Operand dst, IdentifierTableIndex identifier)
|
|
|
|
: Instruction(Type::TypeofBinding)
|
2024-02-04 08:00:54 +01:00
|
|
|
, m_dst(dst)
|
2022-06-11 23:12:22 +01:00
|
|
|
, m_identifier(identifier)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 17:49:34 +03:30
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2024-05-12 18:49:03 +02:00
|
|
|
void visit_operands_impl(Function<void(Operand&)> visitor)
|
|
|
|
{
|
|
|
|
visitor(m_dst);
|
|
|
|
}
|
2022-06-11 23:12:22 +01:00
|
|
|
|
2024-02-04 08:00:54 +01:00
|
|
|
Operand dst() const { return m_dst; }
|
2023-10-21 15:26:03 +02:00
|
|
|
IdentifierTableIndex identifier() const { return m_identifier; }
|
|
|
|
|
2022-06-11 23:12:22 +01:00
|
|
|
private:
|
2024-02-04 08:00:54 +01:00
|
|
|
Operand m_dst;
|
2022-06-11 23:12:22 +01:00
|
|
|
IdentifierTableIndex m_identifier;
|
2024-06-14 13:57:51 +02:00
|
|
|
mutable EnvironmentCoordinate m_cache;
|
2022-06-11 23:12:22 +01:00
|
|
|
};
|
|
|
|
|
2024-02-04 08:00:54 +01:00
|
|
|
class End final : public Instruction {
|
2023-07-05 02:17:10 +02:00
|
|
|
public:
|
2024-02-04 08:00:54 +01:00
|
|
|
constexpr static bool IsTerminator = true;
|
|
|
|
|
|
|
|
explicit End(Operand value)
|
2024-05-06 11:09:09 +02:00
|
|
|
: Instruction(Type::End)
|
2024-02-04 08:00:54 +01:00
|
|
|
, m_value(value)
|
2023-07-05 02:17:10 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2023-12-16 17:49:34 +03:30
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2024-05-12 18:49:03 +02:00
|
|
|
void visit_operands_impl(Function<void(Operand&)> visitor)
|
|
|
|
{
|
|
|
|
visitor(m_value);
|
|
|
|
}
|
2023-07-05 02:17:10 +02:00
|
|
|
|
2024-02-04 08:00:54 +01:00
|
|
|
Operand value() const { return m_value; }
|
2023-10-27 16:22:14 +02:00
|
|
|
|
2023-07-05 02:17:10 +02:00
|
|
|
private:
|
2024-02-04 08:00:54 +01:00
|
|
|
Operand m_value;
|
2023-07-05 02:17:10 +02:00
|
|
|
};
|
2024-02-04 08:00:54 +01:00
|
|
|
|
|
|
|
class Dump final : public Instruction {
|
|
|
|
public:
|
|
|
|
explicit Dump(StringView text, Operand value)
|
2024-05-06 11:09:09 +02:00
|
|
|
: Instruction(Type::Dump)
|
2024-02-04 08:00:54 +01:00
|
|
|
, m_text(text)
|
|
|
|
, m_value(value)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2024-05-10 17:32:19 +02:00
|
|
|
void execute_impl(Bytecode::Interpreter&) const;
|
2024-02-04 08:00:54 +01:00
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2024-05-12 18:49:03 +02:00
|
|
|
void visit_operands_impl(Function<void(Operand&)> visitor)
|
|
|
|
{
|
|
|
|
visitor(m_value);
|
|
|
|
}
|
2024-02-04 08:00:54 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
StringView m_text;
|
|
|
|
Operand m_value;
|
|
|
|
};
|
|
|
|
|
2021-06-03 10:46:30 +02:00
|
|
|
}
|