mirror of
https://github.com/RGBCube/serenity
synced 2025-07-23 16:17:41 +00:00
LibJS/JIT: Compile all the unary bytecode instructions
This commit is contained in:
parent
640455b1d2
commit
c65aecd878
2 changed files with 40 additions and 0 deletions
|
@ -361,6 +361,33 @@ static ThrowCompletionOr<Value> typed_equals(VM&, Value src1, Value src2)
|
||||||
JS_ENUMERATE_COMMON_BINARY_OPS(DO_COMPILE_COMMON_BINARY_OP)
|
JS_ENUMERATE_COMMON_BINARY_OPS(DO_COMPILE_COMMON_BINARY_OP)
|
||||||
#undef DO_COMPILE_COMMON_BINARY_OP
|
#undef DO_COMPILE_COMMON_BINARY_OP
|
||||||
|
|
||||||
|
static ThrowCompletionOr<Value> not_(VM&, Value value)
|
||||||
|
{
|
||||||
|
return Value(!value.to_boolean());
|
||||||
|
}
|
||||||
|
|
||||||
|
static ThrowCompletionOr<Value> typeof_(VM& vm, Value value)
|
||||||
|
{
|
||||||
|
return PrimitiveString::create(vm, value.typeof());
|
||||||
|
}
|
||||||
|
|
||||||
|
#define DO_COMPILE_COMMON_UNARY_OP(TitleCaseName, snake_case_name) \
|
||||||
|
static Value cxx_##snake_case_name(VM& vm, Value value) \
|
||||||
|
{ \
|
||||||
|
return TRY_OR_SET_EXCEPTION(snake_case_name(vm, value)); \
|
||||||
|
} \
|
||||||
|
\
|
||||||
|
void Compiler::compile_##snake_case_name(Bytecode::Op::TitleCaseName const&) \
|
||||||
|
{ \
|
||||||
|
load_vm_register(ARG1, Bytecode::Register::accumulator()); \
|
||||||
|
m_assembler.native_call((void*)cxx_##snake_case_name); \
|
||||||
|
store_vm_register(Bytecode::Register::accumulator(), RET); \
|
||||||
|
check_exception(); \
|
||||||
|
}
|
||||||
|
|
||||||
|
JS_ENUMERATE_COMMON_UNARY_OPS(DO_COMPILE_COMMON_UNARY_OP)
|
||||||
|
#undef DO_COMPILE_COMMON_UNARY_OP
|
||||||
|
|
||||||
void Compiler::compile_return(Bytecode::Op::Return const&)
|
void Compiler::compile_return(Bytecode::Op::Return const&)
|
||||||
{
|
{
|
||||||
load_vm_register(GPR0, Bytecode::Register::accumulator());
|
load_vm_register(GPR0, Bytecode::Register::accumulator());
|
||||||
|
@ -622,6 +649,13 @@ OwnPtr<NativeExecutable> Compiler::compile(Bytecode::Executable& bytecode_execut
|
||||||
JS_ENUMERATE_COMMON_BINARY_OPS(DO_COMPILE_COMMON_BINARY_OP)
|
JS_ENUMERATE_COMMON_BINARY_OPS(DO_COMPILE_COMMON_BINARY_OP)
|
||||||
#undef DO_COMPILE_COMMON_BINARY_OP
|
#undef DO_COMPILE_COMMON_BINARY_OP
|
||||||
|
|
||||||
|
#define DO_COMPILE_COMMON_UNARY_OP(TitleCaseName, snake_case_name) \
|
||||||
|
case Bytecode::Instruction::Type::TitleCaseName: \
|
||||||
|
compiler.compile_##snake_case_name(static_cast<Bytecode::Op::TitleCaseName const&>(op)); \
|
||||||
|
break;
|
||||||
|
JS_ENUMERATE_COMMON_UNARY_OPS(DO_COMPILE_COMMON_UNARY_OP)
|
||||||
|
#undef DO_COMPILE_COMMON_UNARY_OP
|
||||||
|
|
||||||
default:
|
default:
|
||||||
dbgln("\033[31;1mJIT compilation failed\033[0m: {}", bytecode_executable.name);
|
dbgln("\033[31;1mJIT compilation failed\033[0m: {}", bytecode_executable.name);
|
||||||
dbgln("Unsupported bytecode op: {}", op.to_deprecated_string(bytecode_executable));
|
dbgln("Unsupported bytecode op: {}", op.to_deprecated_string(bytecode_executable));
|
||||||
|
|
|
@ -53,6 +53,12 @@ private:
|
||||||
JS_ENUMERATE_COMMON_BINARY_OPS(DO_COMPILE_COMMON_BINARY_OP)
|
JS_ENUMERATE_COMMON_BINARY_OPS(DO_COMPILE_COMMON_BINARY_OP)
|
||||||
#undef DO_COMPILE_COMMON_BINARY_OP
|
#undef DO_COMPILE_COMMON_BINARY_OP
|
||||||
|
|
||||||
|
#define DO_COMPILE_COMMON_UNARY_OP(OpTitleCase, op_snake_case) \
|
||||||
|
void compile_##op_snake_case(Bytecode::Op::OpTitleCase const&);
|
||||||
|
|
||||||
|
JS_ENUMERATE_COMMON_UNARY_OPS(DO_COMPILE_COMMON_UNARY_OP)
|
||||||
|
#undef DO_COMPILE_COMMON_UNARY_OP
|
||||||
|
|
||||||
void compile_return(Bytecode::Op::Return const&);
|
void compile_return(Bytecode::Op::Return const&);
|
||||||
void compile_new_string(Bytecode::Op::NewString const&);
|
void compile_new_string(Bytecode::Op::NewString const&);
|
||||||
void compile_new_object(Bytecode::Op::NewObject const&);
|
void compile_new_object(Bytecode::Op::NewObject const&);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue