mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 22:27:35 +00:00
LibJS: Rename the overridden Instruction methods to foo_impl
These are pretty hairy if someone forgets to override one, as the catchall function in Instruction will keep calling itself over and over again, leading to really hard-to-debug situations.
This commit is contained in:
parent
4c7c7c38e2
commit
e81fd7106b
2 changed files with 150 additions and 150 deletions
|
@ -27,8 +27,8 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
void execute(Bytecode::Interpreter&) const;
|
||||
String to_string(Bytecode::Executable const&) const;
|
||||
void execute_impl(Bytecode::Interpreter&) const;
|
||||
String to_string_impl(Bytecode::Executable const&) const;
|
||||
|
||||
private:
|
||||
Register m_src;
|
||||
|
@ -42,8 +42,8 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
void execute(Bytecode::Interpreter&) const;
|
||||
String to_string(Bytecode::Executable const&) const;
|
||||
void execute_impl(Bytecode::Interpreter&) const;
|
||||
String to_string_impl(Bytecode::Executable const&) const;
|
||||
|
||||
private:
|
||||
Value m_value;
|
||||
|
@ -57,8 +57,8 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
void execute(Bytecode::Interpreter&) const;
|
||||
String to_string(Bytecode::Executable const&) const;
|
||||
void execute_impl(Bytecode::Interpreter&) const;
|
||||
String to_string_impl(Bytecode::Executable const&) const;
|
||||
|
||||
private:
|
||||
Register m_dst;
|
||||
|
@ -88,20 +88,20 @@ private:
|
|||
O(RightShift, right_shift) \
|
||||
O(UnsignedRightShift, unsigned_right_shift)
|
||||
|
||||
#define JS_DECLARE_COMMON_BINARY_OP(OpTitleCase, op_snake_case) \
|
||||
class OpTitleCase final : public Instruction { \
|
||||
public: \
|
||||
explicit OpTitleCase(Register lhs_reg) \
|
||||
: Instruction(Type::OpTitleCase) \
|
||||
, m_lhs_reg(lhs_reg) \
|
||||
{ \
|
||||
} \
|
||||
\
|
||||
void execute(Bytecode::Interpreter&) const; \
|
||||
String to_string(Bytecode::Executable const&) const; \
|
||||
\
|
||||
private: \
|
||||
Register m_lhs_reg; \
|
||||
#define JS_DECLARE_COMMON_BINARY_OP(OpTitleCase, op_snake_case) \
|
||||
class OpTitleCase final : public Instruction { \
|
||||
public: \
|
||||
explicit OpTitleCase(Register lhs_reg) \
|
||||
: Instruction(Type::OpTitleCase) \
|
||||
, m_lhs_reg(lhs_reg) \
|
||||
{ \
|
||||
} \
|
||||
\
|
||||
void execute_impl(Bytecode::Interpreter&) const; \
|
||||
String to_string_impl(Bytecode::Executable const&) const; \
|
||||
\
|
||||
private: \
|
||||
Register m_lhs_reg; \
|
||||
};
|
||||
|
||||
JS_ENUMERATE_COMMON_BINARY_OPS(JS_DECLARE_COMMON_BINARY_OP)
|
||||
|
@ -114,16 +114,16 @@ JS_ENUMERATE_COMMON_BINARY_OPS(JS_DECLARE_COMMON_BINARY_OP)
|
|||
O(UnaryMinus, unary_minus) \
|
||||
O(Typeof, typeof_)
|
||||
|
||||
#define JS_DECLARE_COMMON_UNARY_OP(OpTitleCase, op_snake_case) \
|
||||
class OpTitleCase final : public Instruction { \
|
||||
public: \
|
||||
OpTitleCase() \
|
||||
: Instruction(Type::OpTitleCase) \
|
||||
{ \
|
||||
} \
|
||||
\
|
||||
void execute(Bytecode::Interpreter&) const; \
|
||||
String to_string(Bytecode::Executable const&) const; \
|
||||
#define JS_DECLARE_COMMON_UNARY_OP(OpTitleCase, op_snake_case) \
|
||||
class OpTitleCase final : public Instruction { \
|
||||
public: \
|
||||
OpTitleCase() \
|
||||
: Instruction(Type::OpTitleCase) \
|
||||
{ \
|
||||
} \
|
||||
\
|
||||
void execute_impl(Bytecode::Interpreter&) const; \
|
||||
String to_string_impl(Bytecode::Executable const&) const; \
|
||||
};
|
||||
|
||||
JS_ENUMERATE_COMMON_UNARY_OPS(JS_DECLARE_COMMON_UNARY_OP)
|
||||
|
@ -137,8 +137,8 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
void execute(Bytecode::Interpreter&) const;
|
||||
String to_string(Bytecode::Executable const&) const;
|
||||
void execute_impl(Bytecode::Interpreter&) const;
|
||||
String to_string_impl(Bytecode::Executable const&) const;
|
||||
|
||||
private:
|
||||
StringTableIndex m_string;
|
||||
|
@ -151,8 +151,8 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
void execute(Bytecode::Interpreter&) const;
|
||||
String to_string(Bytecode::Executable const&) const;
|
||||
void execute_impl(Bytecode::Interpreter&) const;
|
||||
String to_string_impl(Bytecode::Executable const&) const;
|
||||
};
|
||||
|
||||
class NewBigInt final : public Instruction {
|
||||
|
@ -163,8 +163,8 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
void execute(Bytecode::Interpreter&) const;
|
||||
String to_string(Bytecode::Executable const&) const;
|
||||
void execute_impl(Bytecode::Interpreter&) const;
|
||||
String to_string_impl(Bytecode::Executable const&) const;
|
||||
|
||||
private:
|
||||
Crypto::SignedBigInteger m_bigint;
|
||||
|
@ -181,10 +181,10 @@ public:
|
|||
m_elements[i] = elements[i];
|
||||
}
|
||||
|
||||
void execute(Bytecode::Interpreter&) const;
|
||||
String to_string(Bytecode::Executable const&) const;
|
||||
void execute_impl(Bytecode::Interpreter&) const;
|
||||
String to_string_impl(Bytecode::Executable const&) const;
|
||||
|
||||
size_t length() const { return sizeof(*this) + sizeof(Register) * m_element_count; }
|
||||
size_t length_impl() const { return sizeof(*this) + sizeof(Register) * m_element_count; }
|
||||
|
||||
private:
|
||||
size_t m_element_count { 0 };
|
||||
|
@ -199,8 +199,8 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
void execute(Bytecode::Interpreter&) const;
|
||||
String to_string(Bytecode::Executable const&) const;
|
||||
void execute_impl(Bytecode::Interpreter&) const;
|
||||
String to_string_impl(Bytecode::Executable const&) const;
|
||||
|
||||
private:
|
||||
Register m_lhs;
|
||||
|
@ -214,8 +214,8 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
void execute(Bytecode::Interpreter&) const;
|
||||
String to_string(Bytecode::Executable const&) const;
|
||||
void execute_impl(Bytecode::Interpreter&) const;
|
||||
String to_string_impl(Bytecode::Executable const&) const;
|
||||
|
||||
private:
|
||||
StringTableIndex m_identifier;
|
||||
|
@ -229,8 +229,8 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
void execute(Bytecode::Interpreter&) const;
|
||||
String to_string(Bytecode::Executable const&) const;
|
||||
void execute_impl(Bytecode::Interpreter&) const;
|
||||
String to_string_impl(Bytecode::Executable const&) const;
|
||||
|
||||
private:
|
||||
StringTableIndex m_identifier;
|
||||
|
@ -244,8 +244,8 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
void execute(Bytecode::Interpreter&) const;
|
||||
String to_string(Bytecode::Executable const&) const;
|
||||
void execute_impl(Bytecode::Interpreter&) const;
|
||||
String to_string_impl(Bytecode::Executable const&) const;
|
||||
|
||||
private:
|
||||
StringTableIndex m_property;
|
||||
|
@ -260,8 +260,8 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
void execute(Bytecode::Interpreter&) const;
|
||||
String to_string(Bytecode::Executable const&) const;
|
||||
void execute_impl(Bytecode::Interpreter&) const;
|
||||
String to_string_impl(Bytecode::Executable const&) const;
|
||||
|
||||
private:
|
||||
Register m_base;
|
||||
|
@ -276,8 +276,8 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
void execute(Bytecode::Interpreter&) const;
|
||||
String to_string(Bytecode::Executable const&) const;
|
||||
void execute_impl(Bytecode::Interpreter&) const;
|
||||
String to_string_impl(Bytecode::Executable const&) const;
|
||||
|
||||
private:
|
||||
Register m_base;
|
||||
|
@ -292,8 +292,8 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
void execute(Bytecode::Interpreter&) const;
|
||||
String to_string(Bytecode::Executable const&) const;
|
||||
void execute_impl(Bytecode::Interpreter&) const;
|
||||
String to_string_impl(Bytecode::Executable const&) const;
|
||||
|
||||
private:
|
||||
Register m_base;
|
||||
|
@ -324,8 +324,8 @@ public:
|
|||
m_false_target = move(false_target);
|
||||
}
|
||||
|
||||
void execute(Bytecode::Interpreter&) const;
|
||||
String to_string(Bytecode::Executable const&) const;
|
||||
void execute_impl(Bytecode::Interpreter&) const;
|
||||
String to_string_impl(Bytecode::Executable const&) const;
|
||||
|
||||
protected:
|
||||
Optional<Label> m_true_target;
|
||||
|
@ -339,8 +339,8 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
void execute(Bytecode::Interpreter&) const;
|
||||
String to_string(Bytecode::Executable const&) const;
|
||||
void execute_impl(Bytecode::Interpreter&) const;
|
||||
String to_string_impl(Bytecode::Executable const&) const;
|
||||
};
|
||||
|
||||
class JumpNullish final : public Jump {
|
||||
|
@ -350,8 +350,8 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
void execute(Bytecode::Interpreter&) const;
|
||||
String to_string(Bytecode::Executable const&) const;
|
||||
void execute_impl(Bytecode::Interpreter&) const;
|
||||
String to_string_impl(Bytecode::Executable const&) const;
|
||||
};
|
||||
|
||||
// NOTE: This instruction is variable-width depending on the number of arguments!
|
||||
|
@ -373,10 +373,10 @@ public:
|
|||
m_arguments[i] = arguments[i];
|
||||
}
|
||||
|
||||
void execute(Bytecode::Interpreter&) const;
|
||||
String to_string(Bytecode::Executable const&) const;
|
||||
void execute_impl(Bytecode::Interpreter&) const;
|
||||
String to_string_impl(Bytecode::Executable const&) const;
|
||||
|
||||
size_t length() const { return sizeof(*this) + sizeof(Register) * m_argument_count; }
|
||||
size_t length_impl() const { return sizeof(*this) + sizeof(Register) * m_argument_count; }
|
||||
|
||||
private:
|
||||
Register m_callee;
|
||||
|
@ -394,8 +394,8 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
void execute(Bytecode::Interpreter&) const;
|
||||
String to_string(Bytecode::Executable const&) const;
|
||||
void execute_impl(Bytecode::Interpreter&) const;
|
||||
String to_string_impl(Bytecode::Executable const&) const;
|
||||
|
||||
private:
|
||||
FunctionNode const& m_function_node;
|
||||
|
@ -410,8 +410,8 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
void execute(Bytecode::Interpreter&) const;
|
||||
String to_string(Bytecode::Executable const&) const;
|
||||
void execute_impl(Bytecode::Interpreter&) const;
|
||||
String to_string_impl(Bytecode::Executable const&) const;
|
||||
};
|
||||
|
||||
class Increment final : public Instruction {
|
||||
|
@ -421,8 +421,8 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
void execute(Bytecode::Interpreter&) const;
|
||||
String to_string(Bytecode::Executable const&) const;
|
||||
void execute_impl(Bytecode::Interpreter&) const;
|
||||
String to_string_impl(Bytecode::Executable const&) const;
|
||||
};
|
||||
|
||||
class Decrement final : public Instruction {
|
||||
|
@ -432,8 +432,8 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
void execute(Bytecode::Interpreter&) const;
|
||||
String to_string(Bytecode::Executable const&) const;
|
||||
void execute_impl(Bytecode::Interpreter&) const;
|
||||
String to_string_impl(Bytecode::Executable const&) const;
|
||||
};
|
||||
|
||||
class Throw final : public Instruction {
|
||||
|
@ -445,8 +445,8 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
void execute(Bytecode::Interpreter&) const;
|
||||
String to_string(Bytecode::Executable const&) const;
|
||||
void execute_impl(Bytecode::Interpreter&) const;
|
||||
String to_string_impl(Bytecode::Executable const&) const;
|
||||
};
|
||||
|
||||
class EnterUnwindContext final : public Instruction {
|
||||
|
@ -461,8 +461,8 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
void execute(Bytecode::Interpreter&) const;
|
||||
String to_string(Bytecode::Executable const&) const;
|
||||
void execute_impl(Bytecode::Interpreter&) const;
|
||||
String to_string_impl(Bytecode::Executable const&) const;
|
||||
|
||||
private:
|
||||
Label m_entry_point;
|
||||
|
@ -477,8 +477,8 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
void execute(Bytecode::Interpreter&) const;
|
||||
String to_string(Bytecode::Executable const&) const;
|
||||
void execute_impl(Bytecode::Interpreter&) const;
|
||||
String to_string_impl(Bytecode::Executable const&) const;
|
||||
};
|
||||
|
||||
class ContinuePendingUnwind final : public Instruction {
|
||||
|
@ -491,8 +491,8 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
void execute(Bytecode::Interpreter&) const;
|
||||
String to_string(Bytecode::Executable const&) const;
|
||||
void execute_impl(Bytecode::Interpreter&) const;
|
||||
String to_string_impl(Bytecode::Executable const&) const;
|
||||
|
||||
private:
|
||||
Label m_resume_target;
|
||||
|
@ -513,8 +513,8 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
void execute(Bytecode::Interpreter&) const;
|
||||
String to_string(Bytecode::Executable const&) const;
|
||||
void execute_impl(Bytecode::Interpreter&) const;
|
||||
String to_string_impl(Bytecode::Executable const&) const;
|
||||
|
||||
private:
|
||||
Optional<Label> m_continuation_label;
|
||||
|
@ -527,8 +527,8 @@ public:
|
|||
, m_variables(move(variables))
|
||||
{
|
||||
}
|
||||
void execute(Bytecode::Interpreter&) const;
|
||||
String to_string(Bytecode::Executable const&) const;
|
||||
void execute_impl(Bytecode::Interpreter&) const;
|
||||
String to_string_impl(Bytecode::Executable const&) const;
|
||||
|
||||
private:
|
||||
HashMap<u32, Variable> m_variables;
|
||||
|
@ -542,8 +542,8 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
void execute(Bytecode::Interpreter&) const;
|
||||
String to_string(Bytecode::Executable const&) const;
|
||||
void execute_impl(Bytecode::Interpreter&) const;
|
||||
String to_string_impl(Bytecode::Executable const&) const;
|
||||
|
||||
private:
|
||||
size_t m_index { 0 };
|
||||
|
@ -557,7 +557,7 @@ ALWAYS_INLINE void Instruction::execute(Bytecode::Interpreter& interpreter) cons
|
|||
{
|
||||
#define __BYTECODE_OP(op) \
|
||||
case Instruction::Type::op: \
|
||||
return static_cast<Bytecode::Op::op const&>(*this).execute(interpreter);
|
||||
return static_cast<Bytecode::Op::op const&>(*this).execute_impl(interpreter);
|
||||
|
||||
switch (type()) {
|
||||
ENUMERATE_BYTECODE_OPS(__BYTECODE_OP)
|
||||
|
@ -571,9 +571,9 @@ ALWAYS_INLINE void Instruction::execute(Bytecode::Interpreter& interpreter) cons
|
|||
ALWAYS_INLINE size_t Instruction::length() const
|
||||
{
|
||||
if (type() == Type::Call)
|
||||
return static_cast<Op::Call const&>(*this).length();
|
||||
return static_cast<Op::Call const&>(*this).length_impl();
|
||||
else if (type() == Type::NewArray)
|
||||
return static_cast<Op::NewArray const&>(*this).length();
|
||||
return static_cast<Op::NewArray const&>(*this).length_impl();
|
||||
|
||||
#define __BYTECODE_OP(op) \
|
||||
case Type::op: \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue