mirror of
https://github.com/RGBCube/serenity
synced 2025-07-19 04:47:39 +00:00
LibJS/JIT: Compile the ConcatString bytecode instruction
This commit is contained in:
parent
cafe60d713
commit
1d3062de9e
3 changed files with 21 additions and 0 deletions
|
@ -362,6 +362,8 @@ public:
|
||||||
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;
|
||||||
|
|
||||||
|
Register lhs() const { return m_lhs; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Register m_lhs;
|
Register m_lhs;
|
||||||
};
|
};
|
||||||
|
|
|
@ -1027,6 +1027,21 @@ void Compiler::compile_leave_lexical_environment(Bytecode::Op::LeaveLexicalEnvir
|
||||||
native_call((void*)cxx_leave_lexical_environment);
|
native_call((void*)cxx_leave_lexical_environment);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Value cxx_concat_string(VM& vm, Value lhs, Value rhs)
|
||||||
|
{
|
||||||
|
auto string = TRY_OR_SET_EXCEPTION(rhs.to_primitive_string(vm));
|
||||||
|
return PrimitiveString::create(vm, lhs.as_string(), string);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Compiler::compile_concat_string(Bytecode::Op::ConcatString const& op)
|
||||||
|
{
|
||||||
|
load_vm_register(ARG1, op.lhs());
|
||||||
|
load_vm_register(ARG2, Bytecode::Register::accumulator());
|
||||||
|
native_call((void*)cxx_concat_string);
|
||||||
|
store_vm_register(op.lhs(), RET);
|
||||||
|
check_exception();
|
||||||
|
}
|
||||||
|
|
||||||
void Compiler::jump_to_exit()
|
void Compiler::jump_to_exit()
|
||||||
{
|
{
|
||||||
m_assembler.jump(m_exit_label);
|
m_assembler.jump(m_exit_label);
|
||||||
|
@ -1190,6 +1205,9 @@ OwnPtr<NativeExecutable> Compiler::compile(Bytecode::Executable& bytecode_execut
|
||||||
case Bytecode::Instruction::Type::ContinuePendingUnwind:
|
case Bytecode::Instruction::Type::ContinuePendingUnwind:
|
||||||
compiler.compile_continue_pending_unwind(static_cast<Bytecode::Op::ContinuePendingUnwind const&>(op));
|
compiler.compile_continue_pending_unwind(static_cast<Bytecode::Op::ContinuePendingUnwind const&>(op));
|
||||||
break;
|
break;
|
||||||
|
case Bytecode::Instruction::Type::ConcatString:
|
||||||
|
compiler.compile_concat_string(static_cast<Bytecode::Op::ConcatString const&>(op));
|
||||||
|
break;
|
||||||
|
|
||||||
# define DO_COMPILE_COMMON_BINARY_OP(TitleCaseName, snake_case_name) \
|
# define DO_COMPILE_COMMON_BINARY_OP(TitleCaseName, snake_case_name) \
|
||||||
case Bytecode::Instruction::Type::TitleCaseName: \
|
case Bytecode::Instruction::Type::TitleCaseName: \
|
||||||
|
|
|
@ -115,6 +115,7 @@ private:
|
||||||
void compile_typeof_variable(Bytecode::Op::TypeofVariable const&);
|
void compile_typeof_variable(Bytecode::Op::TypeofVariable const&);
|
||||||
void compile_set_variable(Bytecode::Op::SetVariable const&);
|
void compile_set_variable(Bytecode::Op::SetVariable const&);
|
||||||
void compile_continue_pending_unwind(Bytecode::Op::ContinuePendingUnwind const&);
|
void compile_continue_pending_unwind(Bytecode::Op::ContinuePendingUnwind const&);
|
||||||
|
void compile_concat_string(Bytecode::Op::ConcatString const&);
|
||||||
|
|
||||||
void store_vm_register(Bytecode::Register, Assembler::Reg);
|
void store_vm_register(Bytecode::Register, Assembler::Reg);
|
||||||
void load_vm_register(Assembler::Reg, Bytecode::Register);
|
void load_vm_register(Assembler::Reg, Bytecode::Register);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue