2021-06-03 08:46:30 +00:00
|
|
|
/*
|
2023-06-24 13:22:16 +00:00
|
|
|
* Copyright (c) 2021-2023, Andreas Kling <kling@serenityos.org>
|
2021-06-07 20:13:37 +00:00
|
|
|
* Copyright (c) 2021, Linus Groh <linusg@serenityos.org>
|
2021-06-09 16:18:56 +00:00
|
|
|
* Copyright (c) 2021, Gunnar Beutner <gbeutner@serenityos.org>
|
2021-06-03 08:46:30 +00:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2023-11-17 20:07:23 +00:00
|
|
|
#include <AK/FixedArray.h>
|
2022-09-09 14:47:42 +00:00
|
|
|
#include <AK/StdLibExtras.h>
|
2021-06-08 05:59:25 +00:00
|
|
|
#include <LibCrypto/BigInt/SignedBigInteger.h>
|
2023-11-17 10:48:30 +00:00
|
|
|
#include <LibJS/Bytecode/Builtins.h>
|
2021-10-24 13:34:30 +00:00
|
|
|
#include <LibJS/Bytecode/IdentifierTable.h>
|
2021-06-03 08:46:30 +00:00
|
|
|
#include <LibJS/Bytecode/Instruction.h>
|
2021-06-04 10:07:38 +00:00
|
|
|
#include <LibJS/Bytecode/Label.h>
|
2024-02-04 07:00:54 +00:00
|
|
|
#include <LibJS/Bytecode/Operand.h>
|
2023-07-13 08:49:07 +00:00
|
|
|
#include <LibJS/Bytecode/RegexTable.h>
|
2021-06-03 08:46:30 +00:00
|
|
|
#include <LibJS/Bytecode/Register.h>
|
2021-06-09 08:02:01 +00:00
|
|
|
#include <LibJS/Bytecode/StringTable.h>
|
2021-06-03 08:46:30 +00:00
|
|
|
#include <LibJS/Heap/Cell.h>
|
2021-07-01 10:24:46 +00:00
|
|
|
#include <LibJS/Runtime/Environment.h>
|
2023-07-19 10:54:48 +00:00
|
|
|
#include <LibJS/Runtime/Iterator.h>
|
2021-06-03 08:46:30 +00:00
|
|
|
#include <LibJS/Runtime/Value.h>
|
2022-02-12 08:48:23 +00:00
|
|
|
#include <LibJS/Runtime/ValueTraits.h>
|
2021-06-03 08:46:30 +00:00
|
|
|
|
2023-06-23 12:27:42 +00:00
|
|
|
namespace JS {
|
|
|
|
class FunctionExpression;
|
|
|
|
}
|
|
|
|
|
2021-06-03 08:46:30 +00:00
|
|
|
namespace JS::Bytecode::Op {
|
|
|
|
|
2024-02-04 07:00:54 +00:00
|
|
|
class Mov final : public Instruction {
|
2021-06-03 08:46:30 +00:00
|
|
|
public:
|
2024-02-04 07:00:54 +00:00
|
|
|
Mov(Operand dst, Operand src)
|
|
|
|
: Instruction(Type::Mov, sizeof(*this))
|
2021-06-07 20:05:09 +00:00
|
|
|
, m_dst(dst)
|
2024-02-04 07:00:54 +00:00
|
|
|
, m_src(src)
|
2021-06-07 20:05:09 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2022-02-07 13:36:45 +00:00
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 14:19:34 +00:00
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2021-06-07 20:05:09 +00:00
|
|
|
|
2024-02-04 07:00:54 +00:00
|
|
|
Operand dst() const { return m_dst; }
|
|
|
|
Operand src() const { return m_src; }
|
2022-10-22 18:21:08 +00:00
|
|
|
|
2021-06-07 20:05:09 +00:00
|
|
|
private:
|
2024-02-04 07:00:54 +00:00
|
|
|
Operand m_dst;
|
|
|
|
Operand m_src;
|
2021-06-07 20:05:09 +00:00
|
|
|
};
|
|
|
|
|
2021-06-07 21:08:35 +00:00
|
|
|
#define JS_ENUMERATE_COMMON_BINARY_OPS(O) \
|
|
|
|
O(Add, add) \
|
|
|
|
O(Sub, sub) \
|
|
|
|
O(Mul, mul) \
|
|
|
|
O(Div, div) \
|
|
|
|
O(Exp, exp) \
|
|
|
|
O(Mod, mod) \
|
|
|
|
O(In, in) \
|
|
|
|
O(InstanceOf, instance_of) \
|
|
|
|
O(GreaterThan, greater_than) \
|
|
|
|
O(GreaterThanEquals, greater_than_equals) \
|
|
|
|
O(LessThan, less_than) \
|
|
|
|
O(LessThanEquals, less_than_equals) \
|
2023-11-11 20:29:29 +00:00
|
|
|
O(LooselyInequals, loosely_inequals) \
|
|
|
|
O(LooselyEquals, loosely_equals) \
|
|
|
|
O(StrictlyInequals, strict_inequals) \
|
|
|
|
O(StrictlyEquals, strict_equals) \
|
2021-06-07 21:08:35 +00:00
|
|
|
O(BitwiseAnd, bitwise_and) \
|
|
|
|
O(BitwiseOr, bitwise_or) \
|
|
|
|
O(BitwiseXor, bitwise_xor) \
|
|
|
|
O(LeftShift, left_shift) \
|
|
|
|
O(RightShift, right_shift) \
|
|
|
|
O(UnsignedRightShift, unsigned_right_shift)
|
|
|
|
|
2023-12-16 14:19:34 +00:00
|
|
|
#define JS_DECLARE_COMMON_BINARY_OP(OpTitleCase, op_snake_case) \
|
|
|
|
class OpTitleCase final : public Instruction { \
|
|
|
|
public: \
|
2024-02-04 07:00:54 +00:00
|
|
|
explicit OpTitleCase(Operand dst, Operand lhs, Operand rhs) \
|
2023-12-16 14:19:34 +00:00
|
|
|
: Instruction(Type::OpTitleCase, sizeof(*this)) \
|
2024-02-04 07:00:54 +00:00
|
|
|
, m_dst(dst) \
|
|
|
|
, m_lhs(lhs) \
|
|
|
|
, m_rhs(rhs) \
|
2023-12-16 14:19:34 +00:00
|
|
|
{ \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const; \
|
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const; \
|
|
|
|
\
|
2024-02-04 07:00:54 +00:00
|
|
|
Operand dst() const { return m_dst; } \
|
|
|
|
Operand lhs() const { return m_lhs; } \
|
|
|
|
Operand rhs() const { return m_rhs; } \
|
2023-12-16 14:19:34 +00:00
|
|
|
\
|
|
|
|
private: \
|
2024-02-04 07:00:54 +00:00
|
|
|
Operand m_dst; \
|
|
|
|
Operand m_lhs; \
|
|
|
|
Operand m_rhs; \
|
2021-06-07 21:08:35 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
JS_ENUMERATE_COMMON_BINARY_OPS(JS_DECLARE_COMMON_BINARY_OP)
|
|
|
|
#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_)
|
|
|
|
|
2023-12-16 14:19:34 +00:00
|
|
|
#define JS_DECLARE_COMMON_UNARY_OP(OpTitleCase, op_snake_case) \
|
|
|
|
class OpTitleCase final : public Instruction { \
|
|
|
|
public: \
|
2024-02-04 07:00:54 +00:00
|
|
|
OpTitleCase(Operand dst, Operand src) \
|
2023-12-16 14:19:34 +00:00
|
|
|
: Instruction(Type::OpTitleCase, sizeof(*this)) \
|
2024-02-04 07:00:54 +00:00
|
|
|
, m_dst(dst) \
|
|
|
|
, m_src(src) \
|
2023-12-16 14:19:34 +00:00
|
|
|
{ \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const; \
|
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const; \
|
2024-02-04 07:00:54 +00:00
|
|
|
\
|
|
|
|
Operand dst() const { return m_dst; } \
|
|
|
|
Operand src() const { return m_src; } \
|
|
|
|
\
|
|
|
|
private: \
|
|
|
|
Operand m_dst; \
|
|
|
|
Operand m_src; \
|
2021-06-07 21:08:35 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
JS_ENUMERATE_COMMON_UNARY_OPS(JS_DECLARE_COMMON_UNARY_OP)
|
|
|
|
#undef JS_DECLARE_COMMON_UNARY_OP
|
2021-06-07 18:53:47 +00:00
|
|
|
|
2021-06-03 16:26:32 +00:00
|
|
|
class NewString final : public Instruction {
|
|
|
|
public:
|
2024-02-04 07:00:54 +00:00
|
|
|
NewString(Operand dst, StringTableIndex string)
|
2023-09-13 19:32:51 +00:00
|
|
|
: Instruction(Type::NewString, sizeof(*this))
|
2024-02-04 07:00:54 +00:00
|
|
|
, m_dst(dst)
|
2021-06-12 09:22:46 +00:00
|
|
|
, m_string(string)
|
2021-06-03 16:26:32 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2022-02-07 13:36:45 +00:00
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 14:19:34 +00:00
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2021-06-03 16:26:32 +00:00
|
|
|
|
2024-02-04 07:00:54 +00:00
|
|
|
Operand dst() const { return m_dst; }
|
2023-10-18 10:55:00 +00:00
|
|
|
StringTableIndex index() const { return m_string; }
|
|
|
|
|
2021-06-03 16:26:32 +00:00
|
|
|
private:
|
2024-02-04 07:00:54 +00:00
|
|
|
Operand m_dst;
|
2021-06-09 08:02:01 +00:00
|
|
|
StringTableIndex m_string;
|
2021-06-03 16:26:32 +00:00
|
|
|
};
|
|
|
|
|
2021-06-04 18:30:23 +00:00
|
|
|
class NewObject final : public Instruction {
|
|
|
|
public:
|
2024-02-04 07:00:54 +00:00
|
|
|
explicit NewObject(Operand dst)
|
2023-09-13 19:32:51 +00:00
|
|
|
: Instruction(Type::NewObject, sizeof(*this))
|
2024-02-04 07:00:54 +00:00
|
|
|
, m_dst(dst)
|
2021-06-04 18:30:23 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2022-02-07 13:36:45 +00:00
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 14:19:34 +00:00
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2024-02-04 07:00:54 +00:00
|
|
|
|
|
|
|
Operand dst() const { return m_dst; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
Operand m_dst;
|
2021-06-04 18:30:23 +00:00
|
|
|
};
|
|
|
|
|
2021-06-20 00:17:40 +00:00
|
|
|
class NewRegExp final : public Instruction {
|
|
|
|
public:
|
2024-02-04 07:00:54 +00:00
|
|
|
NewRegExp(Operand dst, StringTableIndex source_index, StringTableIndex flags_index, RegexTableIndex regex_index)
|
2023-09-13 19:32:51 +00:00
|
|
|
: Instruction(Type::NewRegExp, sizeof(*this))
|
2024-02-04 07:00:54 +00:00
|
|
|
, m_dst(dst)
|
2021-06-20 00:17:40 +00:00
|
|
|
, m_source_index(source_index)
|
|
|
|
, m_flags_index(flags_index)
|
2023-07-13 08:49:07 +00:00
|
|
|
, m_regex_index(regex_index)
|
2021-06-20 00:17:40 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2022-02-07 13:36:45 +00:00
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 14:19:34 +00:00
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2021-06-20 00:17:40 +00:00
|
|
|
|
2024-02-04 07:00:54 +00:00
|
|
|
Operand dst() const { return m_dst; }
|
2023-10-27 15:07:30 +00: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-20 00:17:40 +00:00
|
|
|
private:
|
2024-02-04 07:00:54 +00:00
|
|
|
Operand m_dst;
|
2021-06-20 00:17:40 +00:00
|
|
|
StringTableIndex m_source_index;
|
|
|
|
StringTableIndex m_flags_index;
|
2023-07-13 08:49:07 +00:00
|
|
|
RegexTableIndex m_regex_index;
|
2021-06-20 00:17:40 +00:00
|
|
|
};
|
|
|
|
|
2022-12-09 18:48:57 +00:00
|
|
|
#define JS_ENUMERATE_NEW_BUILTIN_ERROR_OPS(O) \
|
|
|
|
O(TypeError)
|
|
|
|
|
2023-12-16 14:19:34 +00:00
|
|
|
#define JS_DECLARE_NEW_BUILTIN_ERROR_OP(ErrorName) \
|
|
|
|
class New##ErrorName final : public Instruction { \
|
|
|
|
public: \
|
2024-02-04 07:00:54 +00:00
|
|
|
New##ErrorName(Operand dst, StringTableIndex error_string) \
|
2023-12-16 14:19:34 +00:00
|
|
|
: Instruction(Type::New##ErrorName, sizeof(*this)) \
|
2024-02-04 07:00:54 +00:00
|
|
|
, m_dst(dst) \
|
2023-12-16 14:19:34 +00:00
|
|
|
, m_error_string(error_string) \
|
|
|
|
{ \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const; \
|
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const; \
|
|
|
|
\
|
2024-02-04 07:00:54 +00:00
|
|
|
Operand dst() const { return m_dst; } \
|
2023-12-16 14:19:34 +00:00
|
|
|
StringTableIndex error_string() const { return m_error_string; } \
|
|
|
|
\
|
|
|
|
private: \
|
2024-02-04 07:00:54 +00:00
|
|
|
Operand m_dst; \
|
2023-12-16 14:19:34 +00:00
|
|
|
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 22:30:32 +00:00
|
|
|
// NOTE: This instruction is variable-width depending on the number of excluded names
|
|
|
|
class CopyObjectExcludingProperties final : public Instruction {
|
|
|
|
public:
|
2024-02-04 07:00:54 +00:00
|
|
|
CopyObjectExcludingProperties(Operand dst, Operand from_object, Vector<Operand> const& excluded_names)
|
2023-09-13 19:32:51 +00:00
|
|
|
: Instruction(Type::CopyObjectExcludingProperties, length_impl(excluded_names.size()))
|
2024-02-04 07:00:54 +00:00
|
|
|
, m_dst(dst)
|
2021-06-13 22:30:32 +00: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 13:36:45 +00:00
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 14:19:34 +00:00
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2021-06-13 22:30:32 +00:00
|
|
|
|
2023-09-13 19:32:51 +00:00
|
|
|
size_t length_impl(size_t excluded_names_count) const
|
|
|
|
{
|
2024-02-04 07:00:54 +00:00
|
|
|
return round_up_to_power_of_two(alignof(void*), sizeof(*this) + sizeof(Operand) * excluded_names_count);
|
2023-09-13 19:32:51 +00:00
|
|
|
}
|
2021-06-13 22:30:32 +00:00
|
|
|
|
2024-02-04 07:00:54 +00:00
|
|
|
Operand dst() const { return m_dst; }
|
|
|
|
Operand from_object() const { return m_from_object; }
|
2023-10-30 01:00:53 +00:00
|
|
|
size_t excluded_names_count() const { return m_excluded_names_count; }
|
2024-02-04 07:00:54 +00:00
|
|
|
Operand const* excluded_names() const { return m_excluded_names; }
|
2023-10-30 01:00:53 +00:00
|
|
|
|
2021-06-13 22:30:32 +00:00
|
|
|
private:
|
2024-02-04 07:00:54 +00:00
|
|
|
Operand m_dst;
|
|
|
|
Operand m_from_object;
|
2021-06-13 22:30:32 +00:00
|
|
|
size_t m_excluded_names_count { 0 };
|
2024-02-04 07:00:54 +00:00
|
|
|
Operand m_excluded_names[];
|
2021-06-13 22:30:32 +00:00
|
|
|
};
|
|
|
|
|
2021-06-08 05:59:25 +00:00
|
|
|
class NewBigInt final : public Instruction {
|
|
|
|
public:
|
2024-02-04 07:00:54 +00:00
|
|
|
NewBigInt(Operand dst, Crypto::SignedBigInteger bigint)
|
2023-09-13 19:32:51 +00:00
|
|
|
: Instruction(Type::NewBigInt, sizeof(*this))
|
2024-02-04 07:00:54 +00:00
|
|
|
, m_dst(dst)
|
2021-06-08 05:59:25 +00:00
|
|
|
, m_bigint(move(bigint))
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2022-02-07 13:36:45 +00:00
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 14:19:34 +00:00
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2021-06-08 05:59:25 +00:00
|
|
|
|
2024-02-04 07:00:54 +00:00
|
|
|
Operand dst() const { return m_dst; }
|
2023-10-28 16:58:36 +00:00
|
|
|
Crypto::SignedBigInteger const& bigint() const { return m_bigint; }
|
|
|
|
|
2021-06-08 05:59:25 +00:00
|
|
|
private:
|
2024-02-04 07:00:54 +00:00
|
|
|
Operand m_dst;
|
2021-06-08 05:59:25 +00:00
|
|
|
Crypto::SignedBigInteger m_bigint;
|
|
|
|
};
|
|
|
|
|
2021-06-08 21:06:52 +00:00
|
|
|
// NOTE: This instruction is variable-width depending on the number of elements!
|
|
|
|
class NewArray final : public Instruction {
|
|
|
|
public:
|
2024-02-04 07:00:54 +00:00
|
|
|
explicit NewArray(Operand dst)
|
2023-09-13 19:32:51 +00:00
|
|
|
: Instruction(Type::NewArray, length_impl(0))
|
2024-02-04 07:00:54 +00:00
|
|
|
, m_dst(dst)
|
2021-06-13 21:06:26 +00:00
|
|
|
, m_element_count(0)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2024-02-04 07:00:54 +00:00
|
|
|
NewArray(Operand dst, AK::Array<Operand, 2> const& elements_range)
|
2023-09-13 19:32:51 +00:00
|
|
|
: Instruction(Type::NewArray, length_impl(elements_range[1].index() - elements_range[0].index() + 1))
|
2024-02-04 07:00:54 +00:00
|
|
|
, m_dst(dst)
|
2022-03-14 14:48:42 +00:00
|
|
|
, m_element_count(elements_range[1].index() - elements_range[0].index() + 1)
|
2021-06-08 21:06:52 +00:00
|
|
|
{
|
2022-03-14 14:48:42 +00:00
|
|
|
m_elements[0] = elements_range[0];
|
|
|
|
m_elements[1] = elements_range[1];
|
2021-06-08 21:06:52 +00:00
|
|
|
}
|
|
|
|
|
2022-02-07 13:36:45 +00:00
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 14:19:34 +00:00
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2021-06-08 21:06:52 +00:00
|
|
|
|
2024-02-04 07:00:54 +00:00
|
|
|
Operand dst() const { return m_dst; }
|
|
|
|
|
2023-09-13 19:32:51 +00:00
|
|
|
size_t length_impl(size_t element_count) const
|
2021-06-13 16:10:20 +00:00
|
|
|
{
|
2024-02-04 07:00:54 +00:00
|
|
|
return round_up_to_power_of_two(alignof(void*), sizeof(*this) + sizeof(Operand) * (element_count == 0 ? 0 : 2));
|
2021-06-13 16:10:20 +00:00
|
|
|
}
|
2021-06-12 03:49:09 +00:00
|
|
|
|
2024-02-04 07:00:54 +00:00
|
|
|
Operand start() const
|
2022-10-22 18:21:08 +00:00
|
|
|
{
|
|
|
|
VERIFY(m_element_count);
|
|
|
|
return m_elements[0];
|
|
|
|
}
|
|
|
|
|
2024-02-04 07:00:54 +00:00
|
|
|
Operand end() const
|
2022-10-22 18:21:08 +00:00
|
|
|
{
|
|
|
|
VERIFY(m_element_count);
|
|
|
|
return m_elements[1];
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t element_count() const { return m_element_count; }
|
|
|
|
|
2021-06-08 21:06:52 +00:00
|
|
|
private:
|
2024-02-04 07:00:54 +00:00
|
|
|
Operand m_dst;
|
2021-06-08 21:06:52 +00:00
|
|
|
size_t m_element_count { 0 };
|
2024-02-04 07:00:54 +00:00
|
|
|
Operand m_elements[];
|
2021-06-08 21:06:52 +00:00
|
|
|
};
|
|
|
|
|
2023-11-17 20:07:23 +00:00
|
|
|
class NewPrimitiveArray final : public Instruction {
|
|
|
|
public:
|
2024-02-04 07:00:54 +00:00
|
|
|
NewPrimitiveArray(Operand dst, FixedArray<Value> values)
|
2023-11-17 20:07:23 +00:00
|
|
|
: Instruction(Type::NewPrimitiveArray, sizeof(*this))
|
2024-02-04 07:00:54 +00:00
|
|
|
, m_dst(dst)
|
2023-11-17 20:07:23 +00:00
|
|
|
, m_values(move(values))
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 14:19:34 +00:00
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2023-11-17 20:07:23 +00:00
|
|
|
|
2024-02-04 07:00:54 +00:00
|
|
|
Operand dst() const { return m_dst; }
|
2023-11-17 20:07:23 +00:00
|
|
|
ReadonlySpan<Value> values() const { return m_values.span(); }
|
|
|
|
|
|
|
|
private:
|
2024-02-04 07:00:54 +00:00
|
|
|
Operand m_dst;
|
2023-11-17 20:07:23 +00:00
|
|
|
FixedArray<Value> m_values;
|
|
|
|
};
|
|
|
|
|
2024-02-04 07:00:54 +00:00
|
|
|
class ArrayAppend final : public Instruction {
|
2022-09-09 13:23:02 +00:00
|
|
|
public:
|
2024-02-04 07:00:54 +00:00
|
|
|
ArrayAppend(Operand dst, Operand src, bool is_spread)
|
|
|
|
: Instruction(Type::ArrayAppend, sizeof(*this))
|
|
|
|
, m_dst(dst)
|
|
|
|
, m_src(src)
|
2022-09-09 13:23:02 +00:00
|
|
|
, m_is_spread(is_spread)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 14:19:34 +00:00
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2022-10-22 18:19:16 +00:00
|
|
|
|
2024-02-04 07:00:54 +00:00
|
|
|
Operand dst() const { return m_dst; }
|
|
|
|
Operand src() const { return m_src; }
|
2023-10-29 16:25:49 +00:00
|
|
|
bool is_spread() const { return m_is_spread; }
|
|
|
|
|
2022-09-09 13:23:02 +00:00
|
|
|
private:
|
2024-02-04 07:00:54 +00:00
|
|
|
Operand m_dst;
|
|
|
|
Operand m_src;
|
2022-09-09 13:23:02 +00:00
|
|
|
bool m_is_spread = false;
|
|
|
|
};
|
|
|
|
|
2023-06-24 13:22:16 +00:00
|
|
|
class ImportCall final : public Instruction {
|
|
|
|
public:
|
2024-02-04 07:00:54 +00:00
|
|
|
ImportCall(Operand dst, Operand specifier, Operand options)
|
2023-09-13 19:32:51 +00:00
|
|
|
: Instruction(Type::ImportCall, sizeof(*this))
|
2024-02-04 07:00:54 +00:00
|
|
|
, m_dst(dst)
|
2023-06-24 13:22:16 +00:00
|
|
|
, m_specifier(specifier)
|
|
|
|
, m_options(options)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 14:19:34 +00:00
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2023-06-24 13:22:16 +00:00
|
|
|
|
2024-02-04 07:00:54 +00:00
|
|
|
Operand dst() const { return m_dst; }
|
|
|
|
Operand specifier() const { return m_specifier; }
|
|
|
|
Operand options() const { return m_options; }
|
2023-10-29 22:41:33 +00:00
|
|
|
|
2023-06-24 13:22:16 +00:00
|
|
|
private:
|
2024-02-04 07:00:54 +00:00
|
|
|
Operand m_dst;
|
|
|
|
Operand m_specifier;
|
|
|
|
Operand m_options;
|
2023-06-24 13:22:16 +00:00
|
|
|
};
|
|
|
|
|
2021-06-13 21:06:26 +00:00
|
|
|
class IteratorToArray final : public Instruction {
|
|
|
|
public:
|
2024-02-04 07:00:54 +00:00
|
|
|
explicit IteratorToArray(Operand dst, Operand iterator)
|
2023-09-13 19:32:51 +00:00
|
|
|
: Instruction(Type::IteratorToArray, sizeof(*this))
|
2024-02-04 07:00:54 +00:00
|
|
|
, m_dst(dst)
|
|
|
|
, m_iterator(iterator)
|
2021-06-13 21:06:26 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2022-02-07 13:36:45 +00:00
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 14:19:34 +00:00
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2024-02-04 07:00:54 +00:00
|
|
|
|
|
|
|
Operand dst() const { return m_dst; }
|
|
|
|
Operand iterator() const { return m_iterator; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
Operand m_dst;
|
|
|
|
Operand m_iterator;
|
2021-06-13 21:06:26 +00:00
|
|
|
};
|
|
|
|
|
2021-06-08 03:58:36 +00:00
|
|
|
class ConcatString final : public Instruction {
|
|
|
|
public:
|
2024-02-04 07:00:54 +00:00
|
|
|
explicit ConcatString(Operand dst, Operand src)
|
2023-09-13 19:32:51 +00:00
|
|
|
: Instruction(Type::ConcatString, sizeof(*this))
|
2024-02-04 07:00:54 +00:00
|
|
|
, m_dst(dst)
|
|
|
|
, m_src(src)
|
2021-06-08 03:58:36 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2022-02-07 13:36:45 +00:00
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 14:19:34 +00:00
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2021-06-08 03:58:36 +00:00
|
|
|
|
2024-02-04 07:00:54 +00:00
|
|
|
Operand dst() const { return m_dst; }
|
|
|
|
Operand src() const { return m_src; }
|
2023-10-28 22:06:54 +00:00
|
|
|
|
2021-06-08 03:58:36 +00:00
|
|
|
private:
|
2024-02-04 07:00:54 +00:00
|
|
|
Operand m_dst;
|
|
|
|
Operand m_src;
|
2021-06-08 03:58:36 +00:00
|
|
|
};
|
|
|
|
|
2022-02-12 16:18:45 +00:00
|
|
|
enum class EnvironmentMode {
|
|
|
|
Lexical,
|
|
|
|
Var,
|
|
|
|
};
|
|
|
|
|
2023-06-16 14:43:24 +00:00
|
|
|
class CreateLexicalEnvironment final : public Instruction {
|
2022-02-12 16:18:45 +00:00
|
|
|
public:
|
2023-06-16 14:43:24 +00:00
|
|
|
explicit CreateLexicalEnvironment()
|
2023-09-13 19:32:51 +00:00
|
|
|
: Instruction(Type::CreateLexicalEnvironment, sizeof(*this))
|
2022-02-12 16:18:45 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 14:19:34 +00:00
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2022-02-12 16:18:45 +00:00
|
|
|
};
|
|
|
|
|
2022-03-13 12:31:18 +00:00
|
|
|
class EnterObjectEnvironment final : public Instruction {
|
|
|
|
public:
|
2024-02-04 07:00:54 +00:00
|
|
|
explicit EnterObjectEnvironment(Operand object)
|
2023-09-13 19:32:51 +00:00
|
|
|
: Instruction(Type::EnterObjectEnvironment, sizeof(*this))
|
2024-02-04 07:00:54 +00:00
|
|
|
, m_object(object)
|
2022-03-13 12:31:18 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2023-11-11 22:19:46 +00:00
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 14:19:34 +00:00
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2024-02-04 07:00:54 +00:00
|
|
|
|
|
|
|
Operand object() const { return m_object; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
Operand m_object;
|
2023-11-11 22:19:46 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class Catch final : public Instruction {
|
|
|
|
public:
|
2024-02-04 07:00:54 +00:00
|
|
|
explicit Catch(Operand dst)
|
2023-11-11 22:19:46 +00:00
|
|
|
: Instruction(Type::Catch, sizeof(*this))
|
2024-02-04 07:00:54 +00:00
|
|
|
, m_dst(dst)
|
2023-11-11 22:19:46 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2022-03-13 12:31:18 +00:00
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 14:19:34 +00:00
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2024-02-04 07:00:54 +00:00
|
|
|
|
|
|
|
Operand dst() const { return m_dst; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
Operand m_dst;
|
2022-03-13 12:31:18 +00:00
|
|
|
};
|
|
|
|
|
2022-02-12 16:18:45 +00:00
|
|
|
class CreateVariable final : public Instruction {
|
|
|
|
public:
|
2023-09-17 09:53:48 +00:00
|
|
|
explicit CreateVariable(IdentifierTableIndex identifier, EnvironmentMode mode, bool is_immutable, bool is_global = false, bool is_strict = false)
|
2023-09-13 19:32:51 +00:00
|
|
|
: Instruction(Type::CreateVariable, sizeof(*this))
|
2022-02-12 16:18:45 +00:00
|
|
|
, m_identifier(identifier)
|
|
|
|
, m_mode(mode)
|
|
|
|
, m_is_immutable(is_immutable)
|
2022-07-17 18:06:44 +00:00
|
|
|
, m_is_global(is_global)
|
2023-09-17 09:53:48 +00:00
|
|
|
, m_is_strict(is_strict)
|
2022-02-12 16:18:45 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 14:19:34 +00:00
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2022-02-12 16:18:45 +00:00
|
|
|
|
2023-10-29 00:26:15 +00: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 16:18:45 +00:00
|
|
|
private:
|
|
|
|
IdentifierTableIndex m_identifier;
|
|
|
|
EnvironmentMode m_mode;
|
2022-07-17 18:06:44 +00:00
|
|
|
bool m_is_immutable : 4 { false };
|
|
|
|
bool m_is_global : 4 { false };
|
2023-09-17 09:53:48 +00:00
|
|
|
bool m_is_strict { false };
|
2022-02-12 16:18:45 +00:00
|
|
|
};
|
|
|
|
|
2021-06-03 16:26:32 +00:00
|
|
|
class SetVariable final : public Instruction {
|
|
|
|
public:
|
2022-02-12 16:18:45 +00:00
|
|
|
enum class InitializationMode {
|
|
|
|
Initialize,
|
|
|
|
Set,
|
|
|
|
};
|
2024-02-04 07:00:54 +00:00
|
|
|
explicit SetVariable(IdentifierTableIndex identifier, Operand src, u32 cache_index, InitializationMode initialization_mode = InitializationMode::Set, EnvironmentMode mode = EnvironmentMode::Lexical)
|
2023-09-13 19:32:51 +00:00
|
|
|
: Instruction(Type::SetVariable, sizeof(*this))
|
2021-06-12 09:22:46 +00:00
|
|
|
, m_identifier(identifier)
|
2024-02-04 07:00:54 +00:00
|
|
|
, m_src(src)
|
2022-02-12 16:18:45 +00:00
|
|
|
, m_mode(mode)
|
|
|
|
, m_initialization_mode(initialization_mode)
|
2023-11-16 06:13:35 +00:00
|
|
|
, m_cache_index(cache_index)
|
2021-06-03 16:26:32 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2022-02-07 13:36:45 +00:00
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 14:19:34 +00:00
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2021-06-03 16:26:32 +00:00
|
|
|
|
2022-10-22 18:21:08 +00:00
|
|
|
IdentifierTableIndex identifier() const { return m_identifier; }
|
2024-02-04 07:00:54 +00:00
|
|
|
Operand src() const { return m_src; }
|
2023-10-21 13:30:39 +00:00
|
|
|
EnvironmentMode mode() const { return m_mode; }
|
|
|
|
InitializationMode initialization_mode() const { return m_initialization_mode; }
|
2023-11-16 06:13:35 +00:00
|
|
|
u32 cache_index() const { return m_cache_index; }
|
2022-10-22 18:21:08 +00:00
|
|
|
|
2021-06-03 16:26:32 +00:00
|
|
|
private:
|
2021-10-24 13:34:30 +00:00
|
|
|
IdentifierTableIndex m_identifier;
|
2024-02-04 07:00:54 +00:00
|
|
|
Operand m_src;
|
2022-02-12 16:18:45 +00:00
|
|
|
EnvironmentMode m_mode;
|
|
|
|
InitializationMode m_initialization_mode { InitializationMode::Set };
|
2023-11-16 06:13:35 +00:00
|
|
|
u32 m_cache_index { 0 };
|
2021-06-03 16:26:32 +00:00
|
|
|
};
|
|
|
|
|
2023-07-05 00:17:10 +00:00
|
|
|
class SetLocal final : public Instruction {
|
|
|
|
public:
|
2024-02-04 07:00:54 +00:00
|
|
|
SetLocal(size_t index, Operand src)
|
2023-09-13 19:32:51 +00:00
|
|
|
: Instruction(Type::SetLocal, sizeof(*this))
|
2023-07-05 00:17:10 +00:00
|
|
|
, m_index(index)
|
2024-02-04 07:00:54 +00:00
|
|
|
, m_src(src)
|
2023-07-05 00:17:10 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 14:19:34 +00:00
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2023-07-05 00:17:10 +00:00
|
|
|
|
|
|
|
size_t index() const { return m_index; }
|
2024-02-04 07:00:54 +00:00
|
|
|
Operand dst() const { return Operand(Operand::Type::Local, m_index); }
|
|
|
|
Operand src() const { return m_src; }
|
2023-07-05 00:17:10 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
size_t m_index;
|
2024-02-04 07:00:54 +00:00
|
|
|
Operand m_src;
|
2023-07-05 00:17:10 +00:00
|
|
|
};
|
|
|
|
|
2023-08-01 12:33:58 +00:00
|
|
|
class GetCalleeAndThisFromEnvironment final : public Instruction {
|
|
|
|
public:
|
2024-02-04 07:00:54 +00:00
|
|
|
explicit GetCalleeAndThisFromEnvironment(Operand callee, Operand this_value, IdentifierTableIndex identifier, u32 cache_index)
|
2023-09-13 19:32:51 +00:00
|
|
|
: Instruction(Type::GetCalleeAndThisFromEnvironment, sizeof(*this))
|
2023-08-01 12:33:58 +00:00
|
|
|
, m_identifier(identifier)
|
2024-02-04 07:00:54 +00:00
|
|
|
, m_callee(callee)
|
|
|
|
, m_this_value(this_value)
|
2023-10-26 08:39:40 +00:00
|
|
|
, m_cache_index(cache_index)
|
2023-08-01 12:33:58 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 14:19:34 +00:00
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2023-08-01 12:33:58 +00:00
|
|
|
|
|
|
|
IdentifierTableIndex identifier() const { return m_identifier; }
|
2023-10-26 08:39:40 +00:00
|
|
|
u32 cache_index() const { return m_cache_index; }
|
2024-02-04 07:00:54 +00:00
|
|
|
Operand callee() const { return m_callee; }
|
|
|
|
Operand this_() const { return m_this_value; }
|
2023-08-01 12:33:58 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
IdentifierTableIndex m_identifier;
|
2024-02-04 07:00:54 +00:00
|
|
|
Operand m_callee;
|
|
|
|
Operand m_this_value;
|
2023-10-26 08:39:40 +00:00
|
|
|
u32 m_cache_index { 0 };
|
2023-08-01 12:33:58 +00:00
|
|
|
};
|
|
|
|
|
2021-06-03 16:26:32 +00:00
|
|
|
class GetVariable final : public Instruction {
|
|
|
|
public:
|
2024-02-04 07:00:54 +00:00
|
|
|
explicit GetVariable(Operand dst, IdentifierTableIndex identifier, u32 cache_index)
|
2023-09-13 19:32:51 +00:00
|
|
|
: Instruction(Type::GetVariable, sizeof(*this))
|
2024-02-04 07:00:54 +00:00
|
|
|
, m_dst(dst)
|
2021-06-12 09:22:46 +00:00
|
|
|
, m_identifier(identifier)
|
2023-10-26 08:39:40 +00:00
|
|
|
, m_cache_index(cache_index)
|
2021-06-03 16:26:32 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2022-02-07 13:36:45 +00:00
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 14:19:34 +00:00
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2021-06-03 16:26:32 +00:00
|
|
|
|
2024-02-04 07:00:54 +00:00
|
|
|
Operand dst() const { return m_dst; }
|
2022-10-22 18:21:08 +00:00
|
|
|
IdentifierTableIndex identifier() const { return m_identifier; }
|
2023-10-26 08:39:40 +00:00
|
|
|
u32 cache_index() const { return m_cache_index; }
|
2022-10-22 18:21:08 +00:00
|
|
|
|
2021-06-03 16:26:32 +00:00
|
|
|
private:
|
2024-02-04 07:00:54 +00:00
|
|
|
Operand m_dst;
|
2021-10-24 13:34:30 +00:00
|
|
|
IdentifierTableIndex m_identifier;
|
2023-10-26 08:39:40 +00:00
|
|
|
u32 m_cache_index { 0 };
|
2021-06-03 16:26:32 +00:00
|
|
|
};
|
|
|
|
|
2023-07-12 02:06:59 +00:00
|
|
|
class GetGlobal final : public Instruction {
|
|
|
|
public:
|
2024-02-04 07:00:54 +00:00
|
|
|
GetGlobal(Operand dst, IdentifierTableIndex identifier, u32 cache_index)
|
2023-09-13 19:32:51 +00:00
|
|
|
: Instruction(Type::GetGlobal, sizeof(*this))
|
2024-02-04 07:00:54 +00:00
|
|
|
, m_dst(dst)
|
2023-07-12 02:06:59 +00:00
|
|
|
, m_identifier(identifier)
|
|
|
|
, m_cache_index(cache_index)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 14:19:34 +00:00
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2023-07-12 02:06:59 +00:00
|
|
|
|
2024-02-04 07:00:54 +00:00
|
|
|
Operand dst() const { return m_dst; }
|
2023-10-20 10:56:12 +00:00
|
|
|
IdentifierTableIndex identifier() const { return m_identifier; }
|
|
|
|
u32 cache_index() const { return m_cache_index; }
|
|
|
|
|
2023-07-12 02:06:59 +00:00
|
|
|
private:
|
2024-02-04 07:00:54 +00:00
|
|
|
Operand m_dst;
|
2023-07-12 02:06:59 +00:00
|
|
|
IdentifierTableIndex m_identifier;
|
|
|
|
u32 m_cache_index { 0 };
|
|
|
|
};
|
|
|
|
|
2022-03-27 18:50:09 +00:00
|
|
|
class DeleteVariable final : public Instruction {
|
|
|
|
public:
|
2024-02-04 07:00:54 +00:00
|
|
|
explicit DeleteVariable(Operand dst, IdentifierTableIndex identifier)
|
2023-09-13 19:32:51 +00:00
|
|
|
: Instruction(Type::DeleteVariable, sizeof(*this))
|
2024-02-04 07:00:54 +00:00
|
|
|
, m_dst(dst)
|
2022-03-27 18:50:09 +00:00
|
|
|
, m_identifier(identifier)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 14:19:34 +00:00
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2022-03-27 18:50:09 +00:00
|
|
|
|
2024-02-04 07:00:54 +00:00
|
|
|
Operand dst() const { return m_dst; }
|
2022-10-22 18:21:08 +00:00
|
|
|
IdentifierTableIndex identifier() const { return m_identifier; }
|
|
|
|
|
2022-03-27 18:50:09 +00:00
|
|
|
private:
|
2024-02-04 07:00:54 +00:00
|
|
|
Operand m_dst;
|
2022-03-27 18:50:09 +00:00
|
|
|
IdentifierTableIndex m_identifier;
|
|
|
|
};
|
|
|
|
|
2021-06-04 19:03:53 +00:00
|
|
|
class GetById final : public Instruction {
|
|
|
|
public:
|
2024-02-04 07:00:54 +00:00
|
|
|
GetById(Operand dst, Operand base, IdentifierTableIndex property, u32 cache_index)
|
2023-09-13 19:32:51 +00:00
|
|
|
: Instruction(Type::GetById, sizeof(*this))
|
2024-02-04 07:00:54 +00:00
|
|
|
, m_dst(dst)
|
|
|
|
, m_base(base)
|
2021-06-12 09:22:46 +00:00
|
|
|
, m_property(property)
|
2023-07-08 15:43:26 +00:00
|
|
|
, m_cache_index(cache_index)
|
2021-06-04 19:03:53 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2022-02-07 13:36:45 +00:00
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 14:19:34 +00:00
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2021-06-04 19:03:53 +00:00
|
|
|
|
2024-02-04 07:00:54 +00:00
|
|
|
Operand dst() const { return m_dst; }
|
|
|
|
Operand base() const { return m_base; }
|
2023-10-18 11:27:56 +00:00
|
|
|
IdentifierTableIndex property() const { return m_property; }
|
|
|
|
u32 cache_index() const { return m_cache_index; }
|
|
|
|
|
2021-06-04 19:03:53 +00:00
|
|
|
private:
|
2024-02-04 07:00:54 +00:00
|
|
|
Operand m_dst;
|
|
|
|
Operand m_base;
|
2021-10-24 13:34:30 +00:00
|
|
|
IdentifierTableIndex m_property;
|
2023-07-08 15:43:26 +00:00
|
|
|
u32 m_cache_index { 0 };
|
2021-06-04 19:03:53 +00:00
|
|
|
};
|
|
|
|
|
2023-07-02 18:26:31 +00:00
|
|
|
class GetByIdWithThis final : public Instruction {
|
|
|
|
public:
|
2024-02-04 07:00:54 +00:00
|
|
|
GetByIdWithThis(Operand dst, Operand base, IdentifierTableIndex property, Operand this_value, u32 cache_index)
|
2023-09-13 19:32:51 +00:00
|
|
|
: Instruction(Type::GetByIdWithThis, sizeof(*this))
|
2024-02-04 07:00:54 +00:00
|
|
|
, m_dst(dst)
|
|
|
|
, m_base(base)
|
2023-07-02 18:26:31 +00:00
|
|
|
, m_property(property)
|
|
|
|
, m_this_value(this_value)
|
2023-07-08 15:43:26 +00:00
|
|
|
, m_cache_index(cache_index)
|
2023-07-02 18:26:31 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 14:19:34 +00:00
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2023-07-02 18:26:31 +00:00
|
|
|
|
2024-02-04 07:00:54 +00:00
|
|
|
Operand dst() const { return m_dst; }
|
|
|
|
Operand base() const { return m_base; }
|
2023-10-29 20:39:02 +00:00
|
|
|
IdentifierTableIndex property() const { return m_property; }
|
2024-02-04 07:00:54 +00:00
|
|
|
Operand this_value() const { return m_this_value; }
|
2023-10-29 20:39:02 +00:00
|
|
|
u32 cache_index() const { return m_cache_index; }
|
|
|
|
|
2023-07-02 18:26:31 +00:00
|
|
|
private:
|
2024-02-04 07:00:54 +00:00
|
|
|
Operand m_dst;
|
|
|
|
Operand m_base;
|
2023-07-02 18:26:31 +00:00
|
|
|
IdentifierTableIndex m_property;
|
2024-02-04 07:00:54 +00:00
|
|
|
Operand m_this_value;
|
2023-07-08 15:43:26 +00:00
|
|
|
u32 m_cache_index { 0 };
|
2023-07-02 18:26:31 +00:00
|
|
|
};
|
|
|
|
|
2023-06-23 06:16:17 +00:00
|
|
|
class GetPrivateById final : public Instruction {
|
|
|
|
public:
|
2024-02-04 07:00:54 +00:00
|
|
|
explicit GetPrivateById(Operand dst, Operand base, IdentifierTableIndex property)
|
2023-09-13 19:32:51 +00:00
|
|
|
: Instruction(Type::GetPrivateById, sizeof(*this))
|
2024-02-04 07:00:54 +00:00
|
|
|
, m_dst(dst)
|
|
|
|
, m_base(base)
|
2023-06-23 06:16:17 +00:00
|
|
|
, m_property(property)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 14:19:34 +00:00
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2023-06-23 06:16:17 +00:00
|
|
|
|
2024-02-04 07:00:54 +00:00
|
|
|
Operand dst() const { return m_dst; }
|
|
|
|
Operand base() const { return m_base; }
|
2023-10-29 20:24:50 +00:00
|
|
|
IdentifierTableIndex property() const { return m_property; }
|
|
|
|
|
2023-06-23 06:16:17 +00:00
|
|
|
private:
|
2024-02-04 07:00:54 +00:00
|
|
|
Operand m_dst;
|
|
|
|
Operand m_base;
|
2023-06-23 06:16:17 +00:00
|
|
|
IdentifierTableIndex m_property;
|
|
|
|
};
|
|
|
|
|
2023-07-05 10:42:50 +00:00
|
|
|
class HasPrivateId final : public Instruction {
|
|
|
|
public:
|
2024-02-04 07:00:54 +00:00
|
|
|
HasPrivateId(Operand dst, Operand base, IdentifierTableIndex property)
|
2023-09-13 19:32:51 +00:00
|
|
|
: Instruction(Type::HasPrivateId, sizeof(*this))
|
2024-02-04 07:00:54 +00:00
|
|
|
, m_dst(dst)
|
|
|
|
, m_base(base)
|
2023-07-05 10:42:50 +00:00
|
|
|
, m_property(property)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 14:19:34 +00:00
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2023-07-05 10:42:50 +00:00
|
|
|
|
2024-02-04 07:00:54 +00:00
|
|
|
Operand dst() const { return m_dst; }
|
|
|
|
Operand base() const { return m_base; }
|
2023-10-29 23:28:13 +00:00
|
|
|
IdentifierTableIndex property() const { return m_property; }
|
|
|
|
|
2023-07-05 10:42:50 +00:00
|
|
|
private:
|
2024-02-04 07:00:54 +00:00
|
|
|
Operand m_dst;
|
|
|
|
Operand m_base;
|
2023-07-05 10:42:50 +00:00
|
|
|
IdentifierTableIndex m_property;
|
|
|
|
};
|
|
|
|
|
2022-03-30 20:29:58 +00:00
|
|
|
enum class PropertyKind {
|
|
|
|
Getter,
|
|
|
|
Setter,
|
|
|
|
KeyValue,
|
2023-07-10 06:44:28 +00:00
|
|
|
DirectKeyValue, // Used for Object expressions. Always sets an own property, never calls a setter.
|
2022-03-30 20:29:58 +00:00
|
|
|
Spread,
|
|
|
|
ProtoSetter,
|
|
|
|
};
|
|
|
|
|
2021-06-04 18:47:07 +00:00
|
|
|
class PutById final : public Instruction {
|
|
|
|
public:
|
2024-02-04 07:00:54 +00:00
|
|
|
explicit PutById(Operand base, IdentifierTableIndex property, Operand src, PropertyKind kind, u32 cache_index)
|
2023-09-13 19:32:51 +00:00
|
|
|
: Instruction(Type::PutById, sizeof(*this))
|
2021-06-07 13:12:43 +00:00
|
|
|
, m_base(base)
|
2021-06-12 09:22:46 +00:00
|
|
|
, m_property(property)
|
2024-02-04 07:00:54 +00:00
|
|
|
, m_src(src)
|
2022-03-30 20:29:58 +00:00
|
|
|
, m_kind(kind)
|
2023-11-08 19:51:26 +00:00
|
|
|
, m_cache_index(cache_index)
|
2021-06-04 18:47:07 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2023-06-23 06:16:17 +00:00
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 14:19:34 +00:00
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2023-06-23 06:16:17 +00:00
|
|
|
|
2024-02-04 07:00:54 +00:00
|
|
|
Operand base() const { return m_base; }
|
2023-10-20 11:09:35 +00:00
|
|
|
IdentifierTableIndex property() const { return m_property; }
|
2024-02-04 07:00:54 +00:00
|
|
|
Operand src() const { return m_src; }
|
2023-10-20 11:09:35 +00:00
|
|
|
PropertyKind kind() const { return m_kind; }
|
2023-11-08 19:51:26 +00:00
|
|
|
u32 cache_index() const { return m_cache_index; }
|
2023-10-20 11:09:35 +00:00
|
|
|
|
2023-06-23 06:16:17 +00:00
|
|
|
private:
|
2024-02-04 07:00:54 +00:00
|
|
|
Operand m_base;
|
2023-06-23 06:16:17 +00:00
|
|
|
IdentifierTableIndex m_property;
|
2024-02-04 07:00:54 +00:00
|
|
|
Operand m_src;
|
2023-06-23 06:16:17 +00:00
|
|
|
PropertyKind m_kind;
|
2023-11-08 19:51:26 +00:00
|
|
|
u32 m_cache_index { 0 };
|
2023-06-23 06:16:17 +00:00
|
|
|
};
|
|
|
|
|
2023-07-02 18:26:31 +00:00
|
|
|
class PutByIdWithThis final : public Instruction {
|
|
|
|
public:
|
2024-02-04 07:00:54 +00:00
|
|
|
PutByIdWithThis(Operand base, Operand this_value, IdentifierTableIndex property, Operand src, PropertyKind kind, u32 cache_index)
|
2023-09-13 19:32:51 +00:00
|
|
|
: Instruction(Type::PutByIdWithThis, sizeof(*this))
|
2023-07-02 18:26:31 +00:00
|
|
|
, m_base(base)
|
|
|
|
, m_this_value(this_value)
|
|
|
|
, m_property(property)
|
2024-02-04 07:00:54 +00:00
|
|
|
, m_src(src)
|
2023-07-02 18:26:31 +00:00
|
|
|
, m_kind(kind)
|
2023-11-08 19:51:26 +00:00
|
|
|
, m_cache_index(cache_index)
|
2023-07-02 18:26:31 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 14:19:34 +00:00
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2023-07-02 18:26:31 +00:00
|
|
|
|
2024-02-04 07:00:54 +00:00
|
|
|
Operand base() const { return m_base; }
|
|
|
|
Operand this_value() const { return m_this_value; }
|
2023-10-29 21:14:39 +00:00
|
|
|
IdentifierTableIndex property() const { return m_property; }
|
2024-02-04 07:00:54 +00:00
|
|
|
Operand src() const { return m_src; }
|
2023-10-29 21:14:39 +00:00
|
|
|
PropertyKind kind() const { return m_kind; }
|
2023-11-08 19:51:26 +00:00
|
|
|
u32 cache_index() const { return m_cache_index; }
|
2023-10-29 21:14:39 +00:00
|
|
|
|
2023-07-02 18:26:31 +00:00
|
|
|
private:
|
2024-02-04 07:00:54 +00:00
|
|
|
Operand m_base;
|
|
|
|
Operand m_this_value;
|
2023-07-02 18:26:31 +00:00
|
|
|
IdentifierTableIndex m_property;
|
2024-02-04 07:00:54 +00:00
|
|
|
Operand m_src;
|
2023-07-02 18:26:31 +00:00
|
|
|
PropertyKind m_kind;
|
2023-11-08 19:51:26 +00:00
|
|
|
u32 m_cache_index { 0 };
|
2023-07-02 18:26:31 +00:00
|
|
|
};
|
|
|
|
|
2023-06-23 06:16:17 +00:00
|
|
|
class PutPrivateById final : public Instruction {
|
|
|
|
public:
|
2024-02-04 07:00:54 +00:00
|
|
|
explicit PutPrivateById(Operand base, IdentifierTableIndex property, Operand src, PropertyKind kind = PropertyKind::KeyValue)
|
2023-09-13 19:32:51 +00:00
|
|
|
: Instruction(Type::PutPrivateById, sizeof(*this))
|
2023-06-23 06:16:17 +00:00
|
|
|
, m_base(base)
|
|
|
|
, m_property(property)
|
2024-02-04 07:00:54 +00:00
|
|
|
, m_src(src)
|
2023-06-23 06:16:17 +00:00
|
|
|
, m_kind(kind)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2022-02-07 13:36:45 +00:00
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 14:19:34 +00:00
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2021-06-04 18:47:07 +00:00
|
|
|
|
2024-02-04 07:00:54 +00:00
|
|
|
Operand base() const { return m_base; }
|
2023-10-29 21:20:47 +00:00
|
|
|
IdentifierTableIndex property() const { return m_property; }
|
2024-02-04 07:00:54 +00:00
|
|
|
Operand src() const { return m_src; }
|
2023-10-29 21:20:47 +00:00
|
|
|
|
2021-06-04 18:47:07 +00:00
|
|
|
private:
|
2024-02-04 07:00:54 +00:00
|
|
|
Operand m_base;
|
2021-10-24 13:34:30 +00:00
|
|
|
IdentifierTableIndex m_property;
|
2024-02-04 07:00:54 +00:00
|
|
|
Operand m_src;
|
2022-03-30 20:29:58 +00:00
|
|
|
PropertyKind m_kind;
|
2021-06-04 18:47:07 +00:00
|
|
|
};
|
|
|
|
|
2022-03-27 18:50:09 +00:00
|
|
|
class DeleteById final : public Instruction {
|
|
|
|
public:
|
2024-02-04 07:00:54 +00:00
|
|
|
explicit DeleteById(Operand dst, Operand base, IdentifierTableIndex property)
|
2023-09-13 19:32:51 +00:00
|
|
|
: Instruction(Type::DeleteById, sizeof(*this))
|
2024-02-04 07:00:54 +00:00
|
|
|
, m_dst(dst)
|
|
|
|
, m_base(base)
|
2022-03-27 18:50:09 +00:00
|
|
|
, m_property(property)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 14:19:34 +00:00
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2022-03-27 18:50:09 +00:00
|
|
|
|
2024-02-04 07:00:54 +00:00
|
|
|
Operand dst() const { return m_dst; }
|
|
|
|
Operand base() const { return m_base; }
|
2023-10-29 19:29:14 +00:00
|
|
|
IdentifierTableIndex property() const { return m_property; }
|
|
|
|
|
2022-03-27 18:50:09 +00:00
|
|
|
private:
|
2024-02-04 07:00:54 +00:00
|
|
|
Operand m_dst;
|
|
|
|
Operand m_base;
|
2022-03-27 18:50:09 +00:00
|
|
|
IdentifierTableIndex m_property;
|
|
|
|
};
|
|
|
|
|
2023-07-06 21:10:40 +00:00
|
|
|
class DeleteByIdWithThis final : public Instruction {
|
|
|
|
public:
|
2024-02-04 07:00:54 +00:00
|
|
|
DeleteByIdWithThis(Operand dst, Operand base, Operand this_value, IdentifierTableIndex property)
|
2023-09-13 19:32:51 +00:00
|
|
|
: Instruction(Type::DeleteByIdWithThis, sizeof(*this))
|
2024-02-04 07:00:54 +00:00
|
|
|
, m_dst(dst)
|
|
|
|
, m_base(base)
|
2023-07-06 21:10:40 +00:00
|
|
|
, m_this_value(this_value)
|
|
|
|
, m_property(property)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 14:19:34 +00:00
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2023-07-06 21:10:40 +00:00
|
|
|
|
2024-02-04 07:00:54 +00:00
|
|
|
Operand dst() const { return m_dst; }
|
|
|
|
Operand base() const { return m_base; }
|
|
|
|
Operand this_value() const { return m_this_value; }
|
2023-10-29 21:05:09 +00:00
|
|
|
IdentifierTableIndex property() const { return m_property; }
|
|
|
|
|
2023-07-06 21:10:40 +00:00
|
|
|
private:
|
2024-02-04 07:00:54 +00:00
|
|
|
Operand m_dst;
|
|
|
|
Operand m_base;
|
|
|
|
Operand m_this_value;
|
2023-07-06 21:10:40 +00:00
|
|
|
IdentifierTableIndex m_property;
|
|
|
|
};
|
|
|
|
|
2021-06-10 22:35:25 +00:00
|
|
|
class GetByValue final : public Instruction {
|
|
|
|
public:
|
2024-02-04 07:00:54 +00:00
|
|
|
explicit GetByValue(Operand dst, Operand base, Operand property)
|
2023-09-13 19:32:51 +00:00
|
|
|
: Instruction(Type::GetByValue, sizeof(*this))
|
2024-02-04 07:00:54 +00:00
|
|
|
, m_dst(dst)
|
2021-06-10 22:35:25 +00:00
|
|
|
, m_base(base)
|
2024-02-04 07:00:54 +00:00
|
|
|
, m_property(property)
|
2021-06-10 22:35:25 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2022-02-07 13:36:45 +00:00
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 14:19:34 +00:00
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2021-06-10 22:35:25 +00:00
|
|
|
|
2024-02-04 07:00:54 +00:00
|
|
|
Operand dst() const { return m_dst; }
|
|
|
|
Operand base() const { return m_base; }
|
|
|
|
Operand property() const { return m_property; }
|
2023-10-20 10:38:43 +00:00
|
|
|
|
2021-06-10 22:35:25 +00:00
|
|
|
private:
|
2024-02-04 07:00:54 +00:00
|
|
|
Operand m_dst;
|
|
|
|
Operand m_base;
|
|
|
|
Operand m_property;
|
2021-06-10 22:35:25 +00:00
|
|
|
};
|
|
|
|
|
2023-07-02 18:26:31 +00:00
|
|
|
class GetByValueWithThis final : public Instruction {
|
|
|
|
public:
|
2024-02-04 07:00:54 +00:00
|
|
|
GetByValueWithThis(Operand dst, Operand base, Operand property, Operand this_value)
|
2023-09-13 19:32:51 +00:00
|
|
|
: Instruction(Type::GetByValueWithThis, sizeof(*this))
|
2024-02-04 07:00:54 +00:00
|
|
|
, m_dst(dst)
|
2023-07-02 18:26:31 +00:00
|
|
|
, m_base(base)
|
2024-02-04 07:00:54 +00:00
|
|
|
, m_property(property)
|
2023-07-02 18:26:31 +00:00
|
|
|
, m_this_value(this_value)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 14:19:34 +00:00
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2023-07-02 18:26:31 +00:00
|
|
|
|
2024-02-04 07:00:54 +00: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 20:49:41 +00:00
|
|
|
|
2023-07-02 18:26:31 +00:00
|
|
|
private:
|
2024-02-04 07:00:54 +00:00
|
|
|
Operand m_dst;
|
|
|
|
Operand m_base;
|
|
|
|
Operand m_property;
|
|
|
|
Operand m_this_value;
|
2023-07-02 18:26:31 +00:00
|
|
|
};
|
|
|
|
|
2021-06-10 22:35:25 +00:00
|
|
|
class PutByValue final : public Instruction {
|
|
|
|
public:
|
2024-02-04 07:00:54 +00:00
|
|
|
PutByValue(Operand base, Operand property, Operand src, PropertyKind kind = PropertyKind::KeyValue)
|
2023-09-13 19:32:51 +00:00
|
|
|
: Instruction(Type::PutByValue, sizeof(*this))
|
2021-06-10 22:35:25 +00:00
|
|
|
, m_base(base)
|
|
|
|
, m_property(property)
|
2024-02-04 07:00:54 +00:00
|
|
|
, m_src(src)
|
2022-03-30 20:29:58 +00:00
|
|
|
, m_kind(kind)
|
2021-06-10 22:35:25 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2022-02-07 13:36:45 +00:00
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 14:19:34 +00:00
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2023-07-02 18:26:31 +00:00
|
|
|
|
2024-02-04 07:00:54 +00:00
|
|
|
Operand base() const { return m_base; }
|
|
|
|
Operand property() const { return m_property; }
|
|
|
|
Operand src() const { return m_src; }
|
2023-10-21 13:55:15 +00:00
|
|
|
PropertyKind kind() const { return m_kind; }
|
|
|
|
|
2023-07-02 18:26:31 +00:00
|
|
|
private:
|
2024-02-04 07:00:54 +00:00
|
|
|
Operand m_base;
|
|
|
|
Operand m_property;
|
|
|
|
Operand m_src;
|
2023-07-02 18:26:31 +00:00
|
|
|
PropertyKind m_kind;
|
|
|
|
};
|
|
|
|
|
|
|
|
class PutByValueWithThis final : public Instruction {
|
|
|
|
public:
|
2024-02-04 07:00:54 +00:00
|
|
|
PutByValueWithThis(Operand base, Operand property, Operand this_value, Operand src, PropertyKind kind = PropertyKind::KeyValue)
|
2023-09-13 19:32:51 +00:00
|
|
|
: Instruction(Type::PutByValueWithThis, sizeof(*this))
|
2023-07-02 18:26:31 +00:00
|
|
|
, m_base(base)
|
|
|
|
, m_property(property)
|
|
|
|
, m_this_value(this_value)
|
2024-02-04 07:00:54 +00:00
|
|
|
, m_src(src)
|
2023-07-02 18:26:31 +00:00
|
|
|
, m_kind(kind)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 14:19:34 +00:00
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2021-06-10 22:35:25 +00:00
|
|
|
|
2024-02-04 07:00:54 +00: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 00:32:20 +00:00
|
|
|
PropertyKind kind() const { return m_kind; }
|
|
|
|
|
2021-06-10 22:35:25 +00:00
|
|
|
private:
|
2024-02-04 07:00:54 +00:00
|
|
|
Operand m_base;
|
|
|
|
Operand m_property;
|
|
|
|
Operand m_this_value;
|
|
|
|
Operand m_src;
|
2022-03-30 20:29:58 +00:00
|
|
|
PropertyKind m_kind;
|
2021-06-10 22:35:25 +00:00
|
|
|
};
|
|
|
|
|
2022-03-27 18:50:09 +00:00
|
|
|
class DeleteByValue final : public Instruction {
|
|
|
|
public:
|
2024-02-04 07:00:54 +00:00
|
|
|
DeleteByValue(Operand dst, Operand base, Operand property)
|
2023-09-13 19:32:51 +00:00
|
|
|
: Instruction(Type::DeleteByValue, sizeof(*this))
|
2024-02-04 07:00:54 +00:00
|
|
|
, m_dst(dst)
|
2022-03-27 18:50:09 +00:00
|
|
|
, m_base(base)
|
2024-02-04 07:00:54 +00:00
|
|
|
, m_property(property)
|
2022-03-27 18:50:09 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 14:19:34 +00:00
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2022-03-27 18:50:09 +00:00
|
|
|
|
2024-02-04 07:00:54 +00:00
|
|
|
Operand dst() const { return m_dst; }
|
|
|
|
Operand base() const { return m_base; }
|
|
|
|
Operand property() const { return m_property; }
|
2023-10-29 20:20:25 +00:00
|
|
|
|
2022-03-27 18:50:09 +00:00
|
|
|
private:
|
2024-02-04 07:00:54 +00:00
|
|
|
Operand m_dst;
|
|
|
|
Operand m_base;
|
|
|
|
Operand m_property;
|
2022-03-27 18:50:09 +00:00
|
|
|
};
|
|
|
|
|
2023-07-06 21:10:40 +00:00
|
|
|
class DeleteByValueWithThis final : public Instruction {
|
|
|
|
public:
|
2024-02-04 07:00:54 +00:00
|
|
|
DeleteByValueWithThis(Operand dst, Operand base, Operand this_value, Operand property)
|
2023-09-13 19:32:51 +00:00
|
|
|
: Instruction(Type::DeleteByValueWithThis, sizeof(*this))
|
2024-02-04 07:00:54 +00:00
|
|
|
, m_dst(dst)
|
2023-07-06 21:10:40 +00:00
|
|
|
, m_base(base)
|
|
|
|
, m_this_value(this_value)
|
2024-02-04 07:00:54 +00:00
|
|
|
, m_property(property)
|
2023-07-06 21:10:40 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2024-02-04 07:00:54 +00: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 20:37:52 +00:00
|
|
|
|
2023-07-06 21:10:40 +00:00
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 14:19:34 +00:00
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2023-07-06 21:10:40 +00:00
|
|
|
|
|
|
|
private:
|
2024-02-04 07:00:54 +00:00
|
|
|
Operand m_dst;
|
|
|
|
Operand m_base;
|
|
|
|
Operand m_this_value;
|
|
|
|
Operand m_property;
|
2023-07-06 21:10:40 +00:00
|
|
|
};
|
|
|
|
|
2021-06-08 09:28:27 +00:00
|
|
|
class Jump : public Instruction {
|
2021-06-04 10:07:38 +00:00
|
|
|
public:
|
2021-06-09 02:19:58 +00:00
|
|
|
constexpr static bool IsTerminator = true;
|
|
|
|
|
2023-09-28 10:43:11 +00:00
|
|
|
explicit Jump(Type type, Label taken_target, Optional<Label> nontaken_target = {})
|
2023-09-13 19:32:51 +00:00
|
|
|
: Instruction(type, sizeof(*this))
|
2021-06-09 02:19:58 +00:00
|
|
|
, m_true_target(move(taken_target))
|
|
|
|
, m_false_target(move(nontaken_target))
|
2021-06-08 09:28:27 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2024-02-04 07:00:54 +00:00
|
|
|
explicit Jump(Type type, Label taken_target, Label nontaken_target, size_t sizeof_self)
|
|
|
|
: Instruction(type, sizeof_self)
|
|
|
|
, m_true_target(move(taken_target))
|
|
|
|
, m_false_target(move(nontaken_target))
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2023-09-28 10:43:11 +00:00
|
|
|
explicit Jump(Label taken_target, Optional<Label> nontaken_target = {})
|
2023-09-13 19:32:51 +00:00
|
|
|
: Instruction(Type::Jump, sizeof(*this))
|
2021-06-09 02:19:58 +00:00
|
|
|
, m_true_target(move(taken_target))
|
|
|
|
, m_false_target(move(nontaken_target))
|
2021-06-04 10:07:38 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2022-02-07 13:36:45 +00:00
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 14:19:34 +00:00
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2021-06-13 16:10:20 +00:00
|
|
|
|
|
|
|
auto& true_target() const { return m_true_target; }
|
|
|
|
auto& false_target() const { return m_false_target; }
|
2021-06-09 02:19:58 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
Optional<Label> m_true_target;
|
|
|
|
Optional<Label> m_false_target;
|
2021-06-04 10:07:38 +00:00
|
|
|
};
|
|
|
|
|
2024-02-04 07:00:54 +00:00
|
|
|
class JumpIf final : public Jump {
|
2021-06-04 10:20:44 +00:00
|
|
|
public:
|
2024-02-04 07:00:54 +00:00
|
|
|
explicit JumpIf(Operand condition, Label true_target, Label false_target)
|
|
|
|
: Jump(Type::JumpIf, move(true_target), move(false_target), sizeof(*this))
|
|
|
|
, m_condition(condition)
|
2021-06-04 10:20:44 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2022-02-07 13:36:45 +00:00
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 14:19:34 +00:00
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2024-02-04 07:00:54 +00:00
|
|
|
|
|
|
|
Operand condition() const { return m_condition; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
Operand m_condition;
|
2021-06-04 10:20:44 +00:00
|
|
|
};
|
|
|
|
|
2021-06-09 02:19:58 +00:00
|
|
|
class JumpNullish final : public Jump {
|
2021-06-08 00:18:47 +00:00
|
|
|
public:
|
2024-02-04 07:00:54 +00:00
|
|
|
explicit JumpNullish(Operand condition, Label true_target, Label false_target)
|
|
|
|
: Jump(Type::JumpNullish, move(true_target), move(false_target), sizeof(*this))
|
|
|
|
, m_condition(condition)
|
2021-06-08 00:18:47 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2022-02-07 13:36:45 +00:00
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 14:19:34 +00:00
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2024-02-04 07:00:54 +00:00
|
|
|
|
|
|
|
Operand condition() const { return m_condition; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
Operand m_condition;
|
2021-06-08 00:18:47 +00:00
|
|
|
};
|
|
|
|
|
2021-06-13 19:24:40 +00:00
|
|
|
class JumpUndefined final : public Jump {
|
|
|
|
public:
|
2024-02-04 07:00:54 +00:00
|
|
|
explicit JumpUndefined(Operand condition, Label true_target, Label false_target)
|
|
|
|
: Jump(Type::JumpUndefined, move(true_target), move(false_target), sizeof(*this))
|
|
|
|
, m_condition(condition)
|
2021-06-13 19:24:40 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2022-02-07 13:36:45 +00:00
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 14:19:34 +00:00
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2024-02-04 07:00:54 +00:00
|
|
|
|
|
|
|
Operand condition() const { return m_condition; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
Operand m_condition;
|
2021-06-13 19:24:40 +00:00
|
|
|
};
|
|
|
|
|
2023-07-02 13:59:54 +00:00
|
|
|
enum class CallType {
|
|
|
|
Call,
|
|
|
|
Construct,
|
|
|
|
DirectEval,
|
|
|
|
};
|
2021-06-10 21:01:49 +00:00
|
|
|
|
2023-07-02 14:33:00 +00:00
|
|
|
class Call final : public Instruction {
|
|
|
|
public:
|
2024-02-04 07:00:54 +00:00
|
|
|
Call(CallType type, Operand dst, Operand callee, Operand this_value, Register first_argument, u32 argument_count, Optional<StringTableIndex> expression_string = {}, Optional<Builtin> builtin = {})
|
2023-09-13 19:32:51 +00:00
|
|
|
: Instruction(Type::Call, sizeof(*this))
|
2024-02-04 07:00:54 +00:00
|
|
|
, m_dst(dst)
|
2023-07-02 14:33:00 +00:00
|
|
|
, m_callee(callee)
|
|
|
|
, m_this_value(this_value)
|
|
|
|
, m_first_argument(first_argument)
|
|
|
|
, m_argument_count(argument_count)
|
|
|
|
, m_type(type)
|
|
|
|
, m_expression_string(expression_string)
|
2023-11-17 10:48:30 +00:00
|
|
|
, m_builtin(builtin)
|
2023-07-02 14:33:00 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
CallType call_type() const { return m_type; }
|
2024-02-04 07:00:54 +00:00
|
|
|
Operand dst() const { return m_dst; }
|
|
|
|
Operand callee() const { return m_callee; }
|
|
|
|
Operand this_value() const { return m_this_value; }
|
2023-07-02 14:33:00 +00:00
|
|
|
Optional<StringTableIndex> const& expression_string() const { return m_expression_string; }
|
|
|
|
|
2023-07-03 13:15:24 +00:00
|
|
|
Register first_argument() const { return m_first_argument; }
|
|
|
|
u32 argument_count() const { return m_argument_count; }
|
|
|
|
|
2023-11-17 10:48:30 +00:00
|
|
|
Optional<Builtin> const& builtin() const { return m_builtin; }
|
|
|
|
|
2023-07-02 14:33:00 +00:00
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 14:19:34 +00:00
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2023-07-02 14:33:00 +00:00
|
|
|
|
|
|
|
private:
|
2024-02-04 07:00:54 +00:00
|
|
|
Operand m_dst;
|
|
|
|
Operand m_callee;
|
|
|
|
Operand m_this_value;
|
2023-07-02 14:33:00 +00:00
|
|
|
Register m_first_argument;
|
|
|
|
u32 m_argument_count { 0 };
|
|
|
|
CallType m_type;
|
|
|
|
Optional<StringTableIndex> m_expression_string;
|
2023-11-17 10:48:30 +00:00
|
|
|
Optional<Builtin> m_builtin;
|
2023-07-02 14:33:00 +00:00
|
|
|
};
|
|
|
|
|
2023-07-02 13:59:54 +00:00
|
|
|
class CallWithArgumentArray final : public Instruction {
|
|
|
|
public:
|
2024-02-04 07:00:54 +00:00
|
|
|
CallWithArgumentArray(CallType type, Operand dst, Operand callee, Operand this_value, Operand arguments, Optional<StringTableIndex> expression_string = {})
|
2023-09-13 19:32:51 +00:00
|
|
|
: Instruction(Type::CallWithArgumentArray, sizeof(*this))
|
2024-02-04 07:00:54 +00:00
|
|
|
, m_dst(dst)
|
2021-06-05 13:15:30 +00:00
|
|
|
, m_callee(callee)
|
|
|
|
, m_this_value(this_value)
|
2024-02-04 07:00:54 +00:00
|
|
|
, m_arguments(arguments)
|
2021-06-10 21:01:49 +00:00
|
|
|
, m_type(type)
|
2022-09-30 23:36:06 +00:00
|
|
|
, m_expression_string(expression_string)
|
2021-06-05 13:15:30 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2024-02-04 07:00:54 +00:00
|
|
|
Operand dst() const { return m_dst; }
|
2023-07-02 14:33:00 +00:00
|
|
|
CallType call_type() const { return m_type; }
|
2024-02-04 07:00:54 +00:00
|
|
|
Operand callee() const { return m_callee; }
|
|
|
|
Operand this_value() const { return m_this_value; }
|
|
|
|
Operand arguments() const { return m_arguments; }
|
2023-07-02 14:33:00 +00:00
|
|
|
Optional<StringTableIndex> const& expression_string() const { return m_expression_string; }
|
|
|
|
|
2022-02-07 13:36:45 +00:00
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 14:19:34 +00:00
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2021-06-07 13:12:43 +00:00
|
|
|
|
2021-06-05 13:15:30 +00:00
|
|
|
private:
|
2024-02-04 07:00:54 +00:00
|
|
|
Operand m_dst;
|
|
|
|
Operand m_callee;
|
|
|
|
Operand m_this_value;
|
|
|
|
Operand m_arguments;
|
2021-06-10 21:01:49 +00:00
|
|
|
CallType m_type;
|
2022-09-30 23:36:06 +00:00
|
|
|
Optional<StringTableIndex> m_expression_string;
|
2021-06-05 13:15:30 +00:00
|
|
|
};
|
|
|
|
|
2023-07-02 13:59:54 +00:00
|
|
|
class SuperCallWithArgumentArray : public Instruction {
|
2022-08-30 16:03:02 +00:00
|
|
|
public:
|
2024-02-04 07:00:54 +00:00
|
|
|
explicit SuperCallWithArgumentArray(Operand dst, Operand arguments, bool is_synthetic)
|
2023-09-13 19:32:51 +00:00
|
|
|
: Instruction(Type::SuperCallWithArgumentArray, sizeof(*this))
|
2024-02-04 07:00:54 +00:00
|
|
|
, m_dst(dst)
|
|
|
|
, m_arguments(arguments)
|
2022-08-30 16:03:02 +00:00
|
|
|
, m_is_synthetic(is_synthetic)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 14:19:34 +00:00
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2022-08-30 16:03:02 +00:00
|
|
|
|
2024-02-04 07:00:54 +00:00
|
|
|
Operand dst() const { return m_dst; }
|
|
|
|
Operand arguments() const { return m_arguments; }
|
2023-10-29 14:34:01 +00:00
|
|
|
bool is_synthetic() const { return m_is_synthetic; }
|
|
|
|
|
2022-08-30 16:03:02 +00:00
|
|
|
private:
|
2024-02-04 07:00:54 +00:00
|
|
|
Operand m_dst;
|
|
|
|
Operand m_arguments;
|
2022-08-30 16:03:02 +00:00
|
|
|
bool m_is_synthetic;
|
|
|
|
};
|
|
|
|
|
2021-06-30 18:42:13 +00:00
|
|
|
class NewClass final : public Instruction {
|
|
|
|
public:
|
2024-02-04 07:00:54 +00:00
|
|
|
explicit NewClass(Operand dst, Optional<Operand> super_class, ClassExpression const& class_expression, Optional<IdentifierTableIndex> lhs_name)
|
2023-09-13 19:32:51 +00:00
|
|
|
: Instruction(Type::NewClass, sizeof(*this))
|
2024-02-04 07:00:54 +00:00
|
|
|
, m_dst(dst)
|
|
|
|
, m_super_class(super_class)
|
2021-06-30 18:42:13 +00:00
|
|
|
, m_class_expression(class_expression)
|
2023-06-28 16:17:13 +00:00
|
|
|
, m_lhs_name(lhs_name)
|
2021-06-30 18:42:13 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2022-02-07 13:36:45 +00:00
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 14:19:34 +00:00
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2021-06-30 18:42:13 +00:00
|
|
|
|
2024-02-04 07:00:54 +00:00
|
|
|
Operand dst() const { return m_dst; }
|
|
|
|
Optional<Operand> const& super_class() const { return m_super_class; }
|
2023-10-29 01:59:50 +00:00
|
|
|
ClassExpression const& class_expression() const { return m_class_expression; }
|
|
|
|
Optional<IdentifierTableIndex> const& lhs_name() const { return m_lhs_name; }
|
|
|
|
|
2021-06-30 18:42:13 +00:00
|
|
|
private:
|
2024-02-04 07:00:54 +00:00
|
|
|
Operand m_dst;
|
|
|
|
Optional<Operand> m_super_class;
|
2021-06-30 18:42:13 +00:00
|
|
|
ClassExpression const& m_class_expression;
|
2023-06-28 16:17:13 +00:00
|
|
|
Optional<IdentifierTableIndex> m_lhs_name;
|
2021-06-30 18:42:13 +00:00
|
|
|
};
|
|
|
|
|
2021-06-09 22:49:23 +00:00
|
|
|
class NewFunction final : public Instruction {
|
2021-06-05 13:14:09 +00:00
|
|
|
public:
|
2024-02-04 07:00:54 +00:00
|
|
|
explicit NewFunction(Operand dst, FunctionExpression const& function_node, Optional<IdentifierTableIndex> lhs_name, Optional<Operand> home_object = {})
|
2023-09-13 19:32:51 +00:00
|
|
|
: Instruction(Type::NewFunction, sizeof(*this))
|
2024-02-04 07:00:54 +00:00
|
|
|
, m_dst(dst)
|
2021-06-09 22:49:23 +00:00
|
|
|
, m_function_node(function_node)
|
2023-06-28 16:17:13 +00:00
|
|
|
, m_lhs_name(lhs_name)
|
2023-06-16 08:25:05 +00:00
|
|
|
, m_home_object(move(home_object))
|
2021-06-05 13:14:09 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2022-02-07 13:36:45 +00:00
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 14:19:34 +00:00
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2021-06-05 13:14:09 +00:00
|
|
|
|
2024-02-04 07:00:54 +00:00
|
|
|
Operand dst() const { return m_dst; }
|
2023-10-21 13:49:04 +00:00
|
|
|
FunctionExpression const& function_node() const { return m_function_node; }
|
|
|
|
Optional<IdentifierTableIndex> const& lhs_name() const { return m_lhs_name; }
|
2024-02-04 07:00:54 +00:00
|
|
|
Optional<Operand> const& home_object() const { return m_home_object; }
|
2023-10-21 13:49:04 +00:00
|
|
|
|
2021-06-05 13:14:09 +00:00
|
|
|
private:
|
2024-02-04 07:00:54 +00:00
|
|
|
Operand m_dst;
|
2023-06-23 12:27:42 +00:00
|
|
|
FunctionExpression const& m_function_node;
|
2023-06-28 16:17:13 +00:00
|
|
|
Optional<IdentifierTableIndex> m_lhs_name;
|
2024-02-04 07:00:54 +00:00
|
|
|
Optional<Operand> m_home_object;
|
2021-06-05 13:14:09 +00:00
|
|
|
};
|
|
|
|
|
2023-06-16 14:34:47 +00:00
|
|
|
class BlockDeclarationInstantiation final : public Instruction {
|
|
|
|
public:
|
|
|
|
explicit BlockDeclarationInstantiation(ScopeNode const& scope_node)
|
2023-09-13 19:32:51 +00:00
|
|
|
: Instruction(Type::BlockDeclarationInstantiation, sizeof(*this))
|
2023-06-16 14:34:47 +00:00
|
|
|
, m_scope_node(scope_node)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 14:19:34 +00:00
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2023-06-16 14:34:47 +00:00
|
|
|
|
2023-10-29 14:13:28 +00:00
|
|
|
ScopeNode const& scope_node() const { return m_scope_node; }
|
|
|
|
|
2023-06-16 14:34:47 +00:00
|
|
|
private:
|
|
|
|
ScopeNode const& m_scope_node;
|
|
|
|
};
|
|
|
|
|
2021-06-05 13:53:36 +00:00
|
|
|
class Return final : public Instruction {
|
|
|
|
public:
|
2021-06-09 02:19:58 +00:00
|
|
|
constexpr static bool IsTerminator = true;
|
|
|
|
|
2024-02-04 07:00:54 +00:00
|
|
|
explicit Return(Optional<Operand> value = {})
|
2023-09-13 19:32:51 +00:00
|
|
|
: Instruction(Type::Return, sizeof(*this))
|
2024-02-04 07:00:54 +00:00
|
|
|
, m_value(value)
|
2021-06-05 13:53:36 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2022-02-07 13:36:45 +00:00
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 14:19:34 +00:00
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2024-02-04 07:00:54 +00:00
|
|
|
|
|
|
|
Optional<Operand> const& value() const { return m_value; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
Optional<Operand> m_value;
|
2021-06-05 13:53:36 +00:00
|
|
|
};
|
|
|
|
|
2021-06-09 09:40:38 +00:00
|
|
|
class Increment final : public Instruction {
|
|
|
|
public:
|
2024-02-04 07:00:54 +00:00
|
|
|
explicit Increment(Operand dst)
|
2023-09-13 19:32:51 +00:00
|
|
|
: Instruction(Type::Increment, sizeof(*this))
|
2024-02-04 07:00:54 +00:00
|
|
|
, m_dst(dst)
|
2021-06-09 09:40:38 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2022-02-07 13:36:45 +00:00
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 14:19:34 +00:00
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2024-02-04 07:00:54 +00:00
|
|
|
|
|
|
|
Operand dst() const { return m_dst; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
Operand m_dst;
|
2021-06-09 09:40:38 +00:00
|
|
|
};
|
|
|
|
|
2024-02-20 10:45:01 +00:00
|
|
|
class PostfixIncrement final : public Instruction {
|
|
|
|
public:
|
|
|
|
explicit PostfixIncrement(Operand dst, Operand src)
|
|
|
|
: Instruction(Type::PostfixIncrement, sizeof(*this))
|
|
|
|
, m_dst(dst)
|
|
|
|
, m_src(src)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
|
|
|
|
|
|
|
Operand dst() const { return m_dst; }
|
|
|
|
Operand src() const { return m_src; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
Operand m_dst;
|
|
|
|
Operand m_src;
|
|
|
|
};
|
|
|
|
|
2021-06-09 09:40:38 +00:00
|
|
|
class Decrement final : public Instruction {
|
|
|
|
public:
|
2024-02-04 07:00:54 +00:00
|
|
|
explicit Decrement(Operand dst)
|
2023-09-13 19:32:51 +00:00
|
|
|
: Instruction(Type::Decrement, sizeof(*this))
|
2024-02-04 07:00:54 +00:00
|
|
|
, m_dst(dst)
|
2021-06-09 09:40:38 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2022-02-07 13:36:45 +00:00
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 14:19:34 +00:00
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2024-02-04 07:00:54 +00:00
|
|
|
|
|
|
|
Operand dst() const { return m_dst; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
Operand m_dst;
|
2021-06-09 09:40:38 +00:00
|
|
|
};
|
|
|
|
|
2024-02-20 10:45:01 +00:00
|
|
|
class PostfixDecrement final : public Instruction {
|
2023-06-16 08:51:40 +00:00
|
|
|
public:
|
2024-02-20 10:45:01 +00:00
|
|
|
explicit PostfixDecrement(Operand dst, Operand src)
|
|
|
|
: Instruction(Type::PostfixDecrement, sizeof(*this))
|
2024-02-04 07:00:54 +00:00
|
|
|
, m_dst(dst)
|
|
|
|
, m_src(src)
|
2023-06-16 08:51:40 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 14:19:34 +00:00
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2024-02-04 07:00:54 +00:00
|
|
|
|
|
|
|
Operand dst() const { return m_dst; }
|
|
|
|
Operand src() const { return m_src; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
Operand m_dst;
|
|
|
|
Operand m_src;
|
2023-06-16 08:51:40 +00:00
|
|
|
};
|
|
|
|
|
2021-06-09 16:18:56 +00:00
|
|
|
class Throw final : public Instruction {
|
|
|
|
public:
|
|
|
|
constexpr static bool IsTerminator = true;
|
|
|
|
|
2024-02-04 07:00:54 +00:00
|
|
|
explicit Throw(Operand src)
|
2023-09-13 19:32:51 +00:00
|
|
|
: Instruction(Type::Throw, sizeof(*this))
|
2024-02-04 07:00:54 +00:00
|
|
|
, m_src(src)
|
2021-06-09 16:18:56 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2022-02-07 13:36:45 +00:00
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 14:19:34 +00:00
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2024-02-04 07:00:54 +00:00
|
|
|
|
|
|
|
Operand src() const { return m_src; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
Operand m_src;
|
2021-06-09 16:18:56 +00:00
|
|
|
};
|
|
|
|
|
2022-12-09 18:48:57 +00:00
|
|
|
class ThrowIfNotObject final : public Instruction {
|
|
|
|
public:
|
2024-02-04 07:00:54 +00:00
|
|
|
ThrowIfNotObject(Operand src)
|
2023-09-13 19:32:51 +00:00
|
|
|
: Instruction(Type::ThrowIfNotObject, sizeof(*this))
|
2024-02-04 07:00:54 +00:00
|
|
|
, m_src(src)
|
2022-12-09 18:48:57 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 14:19:34 +00:00
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2024-02-04 07:00:54 +00:00
|
|
|
|
|
|
|
Operand src() const { return m_src; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
Operand m_src;
|
2022-12-09 18:48:57 +00:00
|
|
|
};
|
|
|
|
|
2023-06-25 06:50:07 +00:00
|
|
|
class ThrowIfNullish final : public Instruction {
|
|
|
|
public:
|
2024-02-04 07:00:54 +00:00
|
|
|
explicit ThrowIfNullish(Operand src)
|
2023-09-13 19:32:51 +00:00
|
|
|
: Instruction(Type::ThrowIfNullish, sizeof(*this))
|
2024-02-04 07:00:54 +00:00
|
|
|
, m_src(src)
|
2023-06-25 06:50:07 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 14:19:34 +00:00
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2024-02-04 07:00:54 +00:00
|
|
|
|
|
|
|
Operand src() const { return m_src; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
Operand m_src;
|
|
|
|
};
|
|
|
|
|
|
|
|
class ThrowIfTDZ final : public Instruction {
|
|
|
|
public:
|
|
|
|
explicit ThrowIfTDZ(Operand src)
|
|
|
|
: Instruction(Type::ThrowIfTDZ, sizeof(*this))
|
|
|
|
, m_src(src)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
|
|
|
|
|
|
|
Operand src() const { return m_src; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
Operand m_src;
|
2023-06-25 06:50:07 +00:00
|
|
|
};
|
|
|
|
|
2021-06-10 13:04:38 +00:00
|
|
|
class EnterUnwindContext final : public Instruction {
|
|
|
|
public:
|
2021-06-13 16:09:40 +00:00
|
|
|
constexpr static bool IsTerminator = true;
|
|
|
|
|
2023-11-11 20:35:38 +00:00
|
|
|
EnterUnwindContext(Label entry_point)
|
2023-09-13 19:32:51 +00:00
|
|
|
: Instruction(Type::EnterUnwindContext, sizeof(*this))
|
2021-06-13 16:09:40 +00:00
|
|
|
, m_entry_point(move(entry_point))
|
2021-06-10 13:04:38 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2022-02-07 13:36:45 +00:00
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 14:19:34 +00:00
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2021-06-13 16:10:20 +00:00
|
|
|
|
|
|
|
auto& entry_point() const { return m_entry_point; }
|
2021-06-10 13:04:38 +00:00
|
|
|
|
|
|
|
private:
|
2021-06-13 16:09:40 +00:00
|
|
|
Label m_entry_point;
|
2021-06-10 13:04:38 +00:00
|
|
|
};
|
|
|
|
|
2022-11-25 15:15:34 +00: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;
|
|
|
|
// FIXME: We currently don't clear the interpreter internal flag, when we change
|
|
|
|
// the control-flow (`break`, `continue`) in a finally-block,
|
|
|
|
// FIXME: .NET on x86_64 uses a call to the finally instead, which could make this
|
|
|
|
// easier, at the cost of making control-flow changes (`break`, `continue`, `return`)
|
|
|
|
// in the finally-block more difficult, but as stated above, those
|
|
|
|
// aren't handled 100% correctly at the moment anyway
|
|
|
|
// It might be worth investigating a similar mechanism
|
|
|
|
constexpr static bool IsTerminator = true;
|
|
|
|
|
|
|
|
ScheduleJump(Label target)
|
2023-09-13 19:32:51 +00:00
|
|
|
: Instruction(Type::ScheduleJump, sizeof(*this))
|
2022-11-25 15:15:34 +00:00
|
|
|
, m_target(target)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
Label target() const { return m_target; }
|
|
|
|
|
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 14:19:34 +00:00
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2022-11-25 15:15:34 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
Label m_target;
|
|
|
|
};
|
|
|
|
|
2023-06-16 14:43:24 +00:00
|
|
|
class LeaveLexicalEnvironment final : public Instruction {
|
2022-02-12 16:18:45 +00:00
|
|
|
public:
|
2023-06-16 14:43:24 +00:00
|
|
|
LeaveLexicalEnvironment()
|
2023-09-13 19:32:51 +00:00
|
|
|
: Instruction(Type::LeaveLexicalEnvironment, sizeof(*this))
|
2022-02-12 16:18:45 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 14:19:34 +00:00
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2022-02-12 16:18:45 +00:00
|
|
|
};
|
|
|
|
|
2021-06-10 13:04:38 +00:00
|
|
|
class LeaveUnwindContext final : public Instruction {
|
|
|
|
public:
|
|
|
|
LeaveUnwindContext()
|
2023-09-13 19:32:51 +00:00
|
|
|
: Instruction(Type::LeaveUnwindContext, sizeof(*this))
|
2021-06-10 13:04:38 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2022-02-07 13:36:45 +00:00
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 14:19:34 +00:00
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2021-06-10 13:04:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class ContinuePendingUnwind final : public Instruction {
|
|
|
|
public:
|
|
|
|
constexpr static bool IsTerminator = true;
|
|
|
|
|
2021-06-12 09:22:46 +00:00
|
|
|
explicit ContinuePendingUnwind(Label resume_target)
|
2023-09-13 19:32:51 +00:00
|
|
|
: Instruction(Type::ContinuePendingUnwind, sizeof(*this))
|
2021-06-10 13:04:38 +00:00
|
|
|
, m_resume_target(resume_target)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2022-02-07 13:36:45 +00:00
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 14:19:34 +00:00
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2021-06-13 16:10:20 +00:00
|
|
|
|
|
|
|
auto& resume_target() const { return m_resume_target; }
|
2021-06-10 13:04:38 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
Label m_resume_target;
|
|
|
|
};
|
2021-06-10 20:12:21 +00:00
|
|
|
|
2021-06-10 21:08:30 +00:00
|
|
|
class Yield final : public Instruction {
|
|
|
|
public:
|
|
|
|
constexpr static bool IsTerminator = true;
|
|
|
|
|
2024-02-04 07:00:54 +00:00
|
|
|
explicit Yield(Label continuation_label, Operand value)
|
2023-09-13 19:32:51 +00:00
|
|
|
: Instruction(Type::Yield, sizeof(*this))
|
2021-06-10 21:08:30 +00:00
|
|
|
, m_continuation_label(continuation_label)
|
2024-02-04 07:00:54 +00:00
|
|
|
, m_value(value)
|
2021-06-10 21:08:30 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2024-02-04 07:00:54 +00:00
|
|
|
explicit Yield(nullptr_t, Operand value)
|
2023-09-13 19:32:51 +00:00
|
|
|
: Instruction(Type::Yield, sizeof(*this))
|
2024-02-04 07:00:54 +00:00
|
|
|
, m_value(value)
|
2021-06-10 21:08:30 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2022-02-07 13:36:45 +00:00
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 14:19:34 +00:00
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2021-06-13 16:10:20 +00:00
|
|
|
|
|
|
|
auto& continuation() const { return m_continuation_label; }
|
2024-02-04 07:00:54 +00:00
|
|
|
Operand value() const { return m_value; }
|
2021-06-10 21:08:30 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
Optional<Label> m_continuation_label;
|
2024-02-04 07:00:54 +00:00
|
|
|
Operand m_value;
|
2021-06-10 21:08:30 +00:00
|
|
|
};
|
|
|
|
|
2023-07-14 20:42:43 +00:00
|
|
|
class Await final : public Instruction {
|
|
|
|
public:
|
|
|
|
constexpr static bool IsTerminator = true;
|
|
|
|
|
2024-02-04 07:00:54 +00:00
|
|
|
explicit Await(Label continuation_label, Operand argument)
|
2023-09-13 19:32:51 +00:00
|
|
|
: Instruction(Type::Await, sizeof(*this))
|
2023-07-14 20:42:43 +00:00
|
|
|
, m_continuation_label(continuation_label)
|
2024-02-04 07:00:54 +00:00
|
|
|
, m_argument(argument)
|
2023-07-14 20:42:43 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 14:19:34 +00:00
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2023-07-14 20:42:43 +00:00
|
|
|
|
|
|
|
auto& continuation() const { return m_continuation_label; }
|
2024-02-04 07:00:54 +00:00
|
|
|
Operand argument() const { return m_argument; }
|
2023-07-14 20:42:43 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
Label m_continuation_label;
|
2024-02-04 07:00:54 +00:00
|
|
|
Operand m_argument;
|
2023-07-14 20:42:43 +00:00
|
|
|
};
|
|
|
|
|
2021-06-13 20:40:48 +00:00
|
|
|
class GetIterator final : public Instruction {
|
|
|
|
public:
|
2024-02-04 07:00:54 +00:00
|
|
|
GetIterator(Operand dst, Operand iterable, IteratorHint hint = IteratorHint::Sync)
|
2023-09-13 19:32:51 +00:00
|
|
|
: Instruction(Type::GetIterator, sizeof(*this))
|
2024-02-04 07:00:54 +00:00
|
|
|
, m_dst(dst)
|
|
|
|
, m_iterable(iterable)
|
2023-06-27 18:24:34 +00:00
|
|
|
, m_hint(hint)
|
2021-06-13 20:40:48 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2022-02-07 13:36:45 +00:00
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 14:19:34 +00:00
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2023-06-27 18:24:34 +00:00
|
|
|
|
2024-02-04 07:00:54 +00:00
|
|
|
Operand dst() const { return m_dst; }
|
|
|
|
Operand iterable() const { return m_iterable; }
|
2023-10-29 14:53:36 +00:00
|
|
|
IteratorHint hint() const { return m_hint; }
|
|
|
|
|
2023-06-27 18:24:34 +00:00
|
|
|
private:
|
2024-02-04 07:00:54 +00:00
|
|
|
Operand m_dst;
|
|
|
|
Operand m_iterable;
|
2023-06-27 18:24:34 +00:00
|
|
|
IteratorHint m_hint { IteratorHint::Sync };
|
2021-06-13 20:40:48 +00:00
|
|
|
};
|
|
|
|
|
2023-12-07 09:44:41 +00:00
|
|
|
class GetObjectFromIteratorRecord final : public Instruction {
|
|
|
|
public:
|
2024-02-04 07:00:54 +00:00
|
|
|
GetObjectFromIteratorRecord(Operand object, Operand iterator_record)
|
2023-12-07 09:44:41 +00:00
|
|
|
: Instruction(Type::GetObjectFromIteratorRecord, sizeof(*this))
|
|
|
|
, m_object(object)
|
|
|
|
, m_iterator_record(iterator_record)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 14:19:34 +00:00
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2023-12-07 09:44:41 +00:00
|
|
|
|
2024-02-04 07:00:54 +00:00
|
|
|
Operand object() const { return m_object; }
|
|
|
|
Operand iterator_record() const { return m_iterator_record; }
|
2023-12-07 09:44:41 +00:00
|
|
|
|
|
|
|
private:
|
2024-02-04 07:00:54 +00:00
|
|
|
Operand m_object;
|
|
|
|
Operand m_iterator_record;
|
2023-12-07 09:44:41 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class GetNextMethodFromIteratorRecord final : public Instruction {
|
|
|
|
public:
|
2024-02-04 07:00:54 +00:00
|
|
|
GetNextMethodFromIteratorRecord(Operand next_method, Operand iterator_record)
|
2023-12-07 09:44:41 +00:00
|
|
|
: Instruction(Type::GetNextMethodFromIteratorRecord, sizeof(*this))
|
|
|
|
, m_next_method(next_method)
|
|
|
|
, m_iterator_record(iterator_record)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 14:19:34 +00:00
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2023-12-07 09:44:41 +00:00
|
|
|
|
2024-02-04 07:00:54 +00:00
|
|
|
Operand next_method() const { return m_next_method; }
|
|
|
|
Operand iterator_record() const { return m_iterator_record; }
|
2023-12-07 09:44:41 +00:00
|
|
|
|
|
|
|
private:
|
2024-02-04 07:00:54 +00:00
|
|
|
Operand m_next_method;
|
|
|
|
Operand m_iterator_record;
|
2023-12-07 09:44:41 +00:00
|
|
|
};
|
|
|
|
|
2022-12-09 18:48:57 +00:00
|
|
|
class GetMethod final : public Instruction {
|
|
|
|
public:
|
2024-02-04 07:00:54 +00:00
|
|
|
GetMethod(Operand dst, Operand object, IdentifierTableIndex property)
|
2023-09-13 19:32:51 +00:00
|
|
|
: Instruction(Type::GetMethod, sizeof(*this))
|
2024-02-04 07:00:54 +00: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 14:19:34 +00:00
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2022-12-09 18:48:57 +00:00
|
|
|
|
2024-02-04 07:00:54 +00:00
|
|
|
Operand dst() const { return m_dst; }
|
|
|
|
Operand object() const { return m_object; }
|
2023-10-29 23:04:52 +00:00
|
|
|
IdentifierTableIndex property() const { return m_property; }
|
|
|
|
|
2022-12-09 18:48:57 +00:00
|
|
|
private:
|
2024-02-04 07:00:54 +00:00
|
|
|
Operand m_dst;
|
|
|
|
Operand m_object;
|
2022-12-09 18:48:57 +00:00
|
|
|
IdentifierTableIndex m_property;
|
|
|
|
};
|
|
|
|
|
2022-03-18 16:48:19 +00:00
|
|
|
class GetObjectPropertyIterator final : public Instruction {
|
|
|
|
public:
|
2024-02-04 07:00:54 +00:00
|
|
|
GetObjectPropertyIterator(Operand dst, Operand object)
|
2023-09-13 19:32:51 +00:00
|
|
|
: Instruction(Type::GetObjectPropertyIterator, sizeof(*this))
|
2024-02-04 07:00:54 +00:00
|
|
|
, m_dst(dst)
|
|
|
|
, m_object(object)
|
2022-03-18 16:48:19 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 14:19:34 +00:00
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2024-02-04 07:00:54 +00:00
|
|
|
|
|
|
|
Operand dst() const { return m_dst; }
|
|
|
|
Operand object() const { return m_object; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
Operand m_dst;
|
|
|
|
Operand m_object;
|
2022-03-18 16:48:19 +00:00
|
|
|
};
|
|
|
|
|
2022-12-09 18:48:57 +00:00
|
|
|
class IteratorClose final : public Instruction {
|
|
|
|
public:
|
2024-02-04 07:00:54 +00:00
|
|
|
IteratorClose(Operand iterator_record, Completion::Type completion_type, Optional<Value> completion_value)
|
2023-09-13 19:32:51 +00:00
|
|
|
: Instruction(Type::IteratorClose, sizeof(*this))
|
2024-02-04 07:00:54 +00: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 14:19:34 +00:00
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2022-12-09 18:48:57 +00:00
|
|
|
|
2024-02-04 07:00:54 +00:00
|
|
|
Operand iterator_record() const { return m_iterator_record; }
|
2023-10-29 15:59:53 +00: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 07:00:54 +00: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 20:42:43 +00:00
|
|
|
class AsyncIteratorClose final : public Instruction {
|
|
|
|
public:
|
2024-02-04 07:00:54 +00:00
|
|
|
AsyncIteratorClose(Operand iterator_record, Completion::Type completion_type, Optional<Value> completion_value)
|
2023-09-13 19:32:51 +00:00
|
|
|
: Instruction(Type::AsyncIteratorClose, sizeof(*this))
|
2024-02-04 07:00:54 +00:00
|
|
|
, m_iterator_record(iterator_record)
|
2023-07-14 20:42:43 +00:00
|
|
|
, m_completion_type(completion_type)
|
|
|
|
, m_completion_value(completion_value)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 14:19:34 +00:00
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2023-07-14 20:42:43 +00:00
|
|
|
|
2024-02-04 07:00:54 +00:00
|
|
|
Operand iterator_record() const { return m_iterator_record; }
|
2023-10-30 01:17:24 +00:00
|
|
|
Completion::Type completion_type() const { return m_completion_type; }
|
|
|
|
Optional<Value> const& completion_value() const { return m_completion_value; }
|
|
|
|
|
2023-07-14 20:42:43 +00:00
|
|
|
private:
|
2024-02-04 07:00:54 +00:00
|
|
|
Operand m_iterator_record;
|
2023-07-14 20:42:43 +00:00
|
|
|
Completion::Type m_completion_type { Completion::Type::Normal };
|
|
|
|
Optional<Value> m_completion_value;
|
|
|
|
};
|
|
|
|
|
2021-06-13 20:40:48 +00:00
|
|
|
class IteratorNext final : public Instruction {
|
|
|
|
public:
|
2024-02-04 07:00:54 +00:00
|
|
|
IteratorNext(Operand dst, Operand iterator_record)
|
2023-09-13 19:32:51 +00:00
|
|
|
: Instruction(Type::IteratorNext, sizeof(*this))
|
2024-02-04 07:00:54 +00:00
|
|
|
, m_dst(dst)
|
|
|
|
, m_iterator_record(iterator_record)
|
2021-06-13 20:40:48 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2022-02-07 13:36:45 +00:00
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 14:19:34 +00:00
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2024-02-04 07:00:54 +00: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 20:40:48 +00:00
|
|
|
};
|
|
|
|
|
2021-10-24 12:43:00 +00:00
|
|
|
class ResolveThisBinding final : public Instruction {
|
|
|
|
public:
|
2024-02-04 07:00:54 +00:00
|
|
|
explicit ResolveThisBinding(Operand dst)
|
2023-09-13 19:32:51 +00:00
|
|
|
: Instruction(Type::ResolveThisBinding, sizeof(*this))
|
2024-02-04 07:00:54 +00:00
|
|
|
, m_dst(dst)
|
2021-10-24 12:43:00 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2022-02-07 13:36:45 +00:00
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 14:19:34 +00:00
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2024-02-04 07:00:54 +00:00
|
|
|
|
|
|
|
Operand dst() const { return m_dst; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
Operand m_dst;
|
2021-10-24 12:43:00 +00:00
|
|
|
};
|
|
|
|
|
2023-05-15 17:45:16 +00:00
|
|
|
class ResolveSuperBase final : public Instruction {
|
|
|
|
public:
|
2024-02-04 07:00:54 +00:00
|
|
|
explicit ResolveSuperBase(Operand dst)
|
2023-09-13 19:32:51 +00:00
|
|
|
: Instruction(Type::ResolveSuperBase, sizeof(*this))
|
2024-02-04 07:00:54 +00:00
|
|
|
, m_dst(dst)
|
2023-05-15 17:45:16 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 14:19:34 +00:00
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2024-02-04 07:00:54 +00:00
|
|
|
|
|
|
|
Operand dst() const { return m_dst; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
Operand m_dst;
|
2023-05-15 17:45:16 +00:00
|
|
|
};
|
|
|
|
|
2022-03-19 19:40:21 +00:00
|
|
|
class GetNewTarget final : public Instruction {
|
|
|
|
public:
|
2024-02-04 07:00:54 +00:00
|
|
|
explicit GetNewTarget(Operand dst)
|
2023-09-13 19:32:51 +00:00
|
|
|
: Instruction(Type::GetNewTarget, sizeof(*this))
|
2024-02-04 07:00:54 +00:00
|
|
|
, m_dst(dst)
|
2022-03-19 19:40:21 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 14:19:34 +00:00
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2024-02-04 07:00:54 +00:00
|
|
|
|
|
|
|
Operand dst() const { return m_dst; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
Operand m_dst;
|
2022-03-19 19:40:21 +00:00
|
|
|
};
|
|
|
|
|
2023-07-12 03:07:12 +00:00
|
|
|
class GetImportMeta final : public Instruction {
|
|
|
|
public:
|
2024-02-04 07:00:54 +00:00
|
|
|
explicit GetImportMeta(Operand dst)
|
2023-09-13 19:32:51 +00:00
|
|
|
: Instruction(Type::GetImportMeta, sizeof(*this))
|
2024-02-04 07:00:54 +00:00
|
|
|
, m_dst(dst)
|
2023-07-12 03:07:12 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 14:19:34 +00:00
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2024-02-04 07:00:54 +00:00
|
|
|
|
|
|
|
Operand dst() const { return m_dst; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
Operand m_dst;
|
2023-07-12 03:07:12 +00:00
|
|
|
};
|
|
|
|
|
2022-06-11 22:12:22 +00:00
|
|
|
class TypeofVariable final : public Instruction {
|
|
|
|
public:
|
2024-02-04 07:00:54 +00:00
|
|
|
TypeofVariable(Operand dst, IdentifierTableIndex identifier)
|
2023-09-13 19:32:51 +00:00
|
|
|
: Instruction(Type::TypeofVariable, sizeof(*this))
|
2024-02-04 07:00:54 +00:00
|
|
|
, m_dst(dst)
|
2022-06-11 22:12:22 +00:00
|
|
|
, m_identifier(identifier)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 14:19:34 +00:00
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2022-06-11 22:12:22 +00:00
|
|
|
|
2024-02-04 07:00:54 +00:00
|
|
|
Operand dst() const { return m_dst; }
|
2023-10-21 13:26:03 +00:00
|
|
|
IdentifierTableIndex identifier() const { return m_identifier; }
|
|
|
|
|
2022-06-11 22:12:22 +00:00
|
|
|
private:
|
2024-02-04 07:00:54 +00:00
|
|
|
Operand m_dst;
|
2022-06-11 22:12:22 +00:00
|
|
|
IdentifierTableIndex m_identifier;
|
|
|
|
};
|
|
|
|
|
2024-02-04 07:00:54 +00:00
|
|
|
class End final : public Instruction {
|
2023-07-05 00:17:10 +00:00
|
|
|
public:
|
2024-02-04 07:00:54 +00:00
|
|
|
constexpr static bool IsTerminator = true;
|
|
|
|
|
|
|
|
explicit End(Operand value)
|
|
|
|
: Instruction(Type::End, sizeof(*this))
|
|
|
|
, m_value(value)
|
2023-07-05 00:17:10 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
2023-12-16 14:19:34 +00:00
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
2023-07-05 00:17:10 +00:00
|
|
|
|
2024-02-04 07:00:54 +00:00
|
|
|
Operand value() const { return m_value; }
|
2023-10-27 14:22:14 +00:00
|
|
|
|
2023-07-05 00:17:10 +00:00
|
|
|
private:
|
2024-02-04 07:00:54 +00:00
|
|
|
Operand m_value;
|
2023-07-05 00:17:10 +00:00
|
|
|
};
|
2024-02-04 07:00:54 +00:00
|
|
|
|
|
|
|
class Dump final : public Instruction {
|
|
|
|
public:
|
|
|
|
explicit Dump(StringView text, Operand value)
|
|
|
|
: Instruction(Type::Dump, sizeof(*this))
|
|
|
|
, m_text(text)
|
|
|
|
, m_value(value)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
|
|
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
StringView m_text;
|
|
|
|
Operand m_value;
|
|
|
|
};
|
|
|
|
|
2021-06-03 08:46:30 +00:00
|
|
|
}
|
2021-06-09 07:19:34 +00:00
|
|
|
|
|
|
|
namespace JS::Bytecode {
|
|
|
|
|
2022-02-07 13:36:45 +00:00
|
|
|
ALWAYS_INLINE ThrowCompletionOr<void> Instruction::execute(Bytecode::Interpreter& interpreter) const
|
2021-06-09 07:19:34 +00:00
|
|
|
{
|
|
|
|
#define __BYTECODE_OP(op) \
|
|
|
|
case Instruction::Type::op: \
|
2021-06-15 13:38:12 +00:00
|
|
|
return static_cast<Bytecode::Op::op const&>(*this).execute_impl(interpreter);
|
2021-06-09 07:19:34 +00:00
|
|
|
|
|
|
|
switch (type()) {
|
|
|
|
ENUMERATE_BYTECODE_OPS(__BYTECODE_OP)
|
2021-06-13 16:10:20 +00:00
|
|
|
default:
|
|
|
|
VERIFY_NOT_REACHED();
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef __BYTECODE_OP
|
|
|
|
}
|
|
|
|
|
2021-06-09 07:19:34 +00:00
|
|
|
}
|