mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 19:37:36 +00:00
LibJS/JIT: Compile the New##ErrorName instructions
This commit is contained in:
parent
fd059d4e4a
commit
847889343f
3 changed files with 25 additions and 2 deletions
|
@ -212,6 +212,8 @@ private:
|
||||||
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const; \
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const; \
|
||||||
DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const; \
|
DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const; \
|
||||||
\
|
\
|
||||||
|
StringTableIndex error_string() const { return m_error_string; } \
|
||||||
|
\
|
||||||
private: \
|
private: \
|
||||||
StringTableIndex m_error_string; \
|
StringTableIndex m_error_string; \
|
||||||
};
|
};
|
||||||
|
|
|
@ -1635,6 +1635,23 @@ void Compiler::compile_has_private_id(Bytecode::Op::HasPrivateId const& op)
|
||||||
check_exception();
|
check_exception();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# define COMPILE_NEW_BUILTIN_ERROR_OP(NewErrorName, new_error_name, ErrorName) \
|
||||||
|
static Value cxx_##new_error_name(VM& vm, DeprecatedString const& error_string) \
|
||||||
|
{ \
|
||||||
|
return ErrorName::create(*vm.current_realm(), error_string); \
|
||||||
|
} \
|
||||||
|
\
|
||||||
|
void Compiler::compile_##new_error_name(Bytecode::Op::NewErrorName const& op) \
|
||||||
|
{ \
|
||||||
|
m_assembler.mov( \
|
||||||
|
Assembler::Operand::Register(ARG1), \
|
||||||
|
Assembler::Operand::Imm(bit_cast<u64>(&m_bytecode_executable.get_string(op.error_string())))); \
|
||||||
|
native_call((void*)cxx_##new_error_name); \
|
||||||
|
store_vm_register(Bytecode::Register::accumulator(), RET); \
|
||||||
|
}
|
||||||
|
JS_ENUMERATE_NEW_BUILTIN_ERROR_BYTECODE_OPS(COMPILE_NEW_BUILTIN_ERROR_OP)
|
||||||
|
# undef COMPILE_NEW_BUILTIN_ERROR_OP
|
||||||
|
|
||||||
void Compiler::jump_to_exit()
|
void Compiler::jump_to_exit()
|
||||||
{
|
{
|
||||||
m_assembler.jump(m_exit_label);
|
m_assembler.jump(m_exit_label);
|
||||||
|
@ -1684,7 +1701,7 @@ OwnPtr<NativeExecutable> Compiler::compile(Bytecode::Executable& bytecode_execut
|
||||||
while (!it.at_end()) {
|
while (!it.at_end()) {
|
||||||
auto const& op = *it;
|
auto const& op = *it;
|
||||||
switch (op.type()) {
|
switch (op.type()) {
|
||||||
# define CASE_BYTECODE_OP(OpTitleCase, op_snake_case) \
|
# define CASE_BYTECODE_OP(OpTitleCase, op_snake_case, ...) \
|
||||||
case Bytecode::Instruction::Type::OpTitleCase: \
|
case Bytecode::Instruction::Type::OpTitleCase: \
|
||||||
compiler.compile_##op_snake_case(static_cast<Bytecode::Op::OpTitleCase const&>(op)); \
|
compiler.compile_##op_snake_case(static_cast<Bytecode::Op::OpTitleCase const&>(op)); \
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -62,9 +62,13 @@ private:
|
||||||
O(RightShift, right_shift) \
|
O(RightShift, right_shift) \
|
||||||
O(UnsignedRightShift, unsigned_right_shift)
|
O(UnsignedRightShift, unsigned_right_shift)
|
||||||
|
|
||||||
|
# define JS_ENUMERATE_NEW_BUILTIN_ERROR_BYTECODE_OPS(O) \
|
||||||
|
O(NewTypeError, new_type_error, TypeError)
|
||||||
|
|
||||||
# define JS_ENUMERATE_IMPLEMENTED_JIT_OPS(O) \
|
# define JS_ENUMERATE_IMPLEMENTED_JIT_OPS(O) \
|
||||||
JS_ENUMERATE_COMMON_BINARY_OPS(O) \
|
JS_ENUMERATE_COMMON_BINARY_OPS(O) \
|
||||||
JS_ENUMERATE_COMMON_UNARY_OPS(O) \
|
JS_ENUMERATE_COMMON_UNARY_OPS(O) \
|
||||||
|
JS_ENUMERATE_NEW_BUILTIN_ERROR_BYTECODE_OPS(O) \
|
||||||
O(LoadImmediate, load_immediate) \
|
O(LoadImmediate, load_immediate) \
|
||||||
O(Load, load) \
|
O(Load, load) \
|
||||||
O(Store, store) \
|
O(Store, store) \
|
||||||
|
@ -135,7 +139,7 @@ private:
|
||||||
O(GetNewTarget, get_new_target) \
|
O(GetNewTarget, get_new_target) \
|
||||||
O(HasPrivateId, has_private_id)
|
O(HasPrivateId, has_private_id)
|
||||||
|
|
||||||
# define DECLARE_COMPILE_OP(OpTitleCase, op_snake_case) \
|
# define DECLARE_COMPILE_OP(OpTitleCase, op_snake_case, ...) \
|
||||||
void compile_##op_snake_case(Bytecode::Op::OpTitleCase const&);
|
void compile_##op_snake_case(Bytecode::Op::OpTitleCase const&);
|
||||||
|
|
||||||
JS_ENUMERATE_IMPLEMENTED_JIT_OPS(DECLARE_COMPILE_OP)
|
JS_ENUMERATE_IMPLEMENTED_JIT_OPS(DECLARE_COMPILE_OP)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue