mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 03:37:43 +00:00
LibJS/JIT: Stub out the JIT compiler on everything but ARCH(X86_64)
We don't support other architectures yet!
This commit is contained in:
parent
d1c701f79f
commit
a645b9c6c3
2 changed files with 100 additions and 81 deletions
|
@ -5,6 +5,7 @@
|
|||
*/
|
||||
|
||||
#include <AK/OwnPtr.h>
|
||||
#include <AK/Platform.h>
|
||||
#include <LibJS/Bytecode/CommonImplementations.h>
|
||||
#include <LibJS/Bytecode/Instruction.h>
|
||||
#include <LibJS/Bytecode/Interpreter.h>
|
||||
|
@ -17,11 +18,13 @@
|
|||
#include <sys/mman.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#define LOG_JIT_SUCCESS 1
|
||||
#define LOG_JIT_FAILURE 1
|
||||
#define DUMP_JIT_MACHINE_CODE_TO_STDOUT 0
|
||||
#if ARCH(X86_64)
|
||||
|
||||
#define TRY_OR_SET_EXCEPTION(expression) \
|
||||
# define LOG_JIT_SUCCESS 1
|
||||
# define LOG_JIT_FAILURE 1
|
||||
# define DUMP_JIT_MACHINE_CODE_TO_STDOUT 0
|
||||
|
||||
# define TRY_OR_SET_EXCEPTION(expression) \
|
||||
({ \
|
||||
/* Ignore -Wshadow to allow nesting the macro. */ \
|
||||
AK_IGNORE_DIAGNOSTIC("-Wshadow", \
|
||||
|
@ -434,7 +437,7 @@ static ThrowCompletionOr<Value> typed_equals(VM&, Value src1, Value src2)
|
|||
return Value(is_strictly_equal(src1, src2));
|
||||
}
|
||||
|
||||
#define DO_COMPILE_COMMON_BINARY_OP(TitleCaseName, snake_case_name) \
|
||||
# define DO_COMPILE_COMMON_BINARY_OP(TitleCaseName, snake_case_name) \
|
||||
static Value cxx_##snake_case_name(VM& vm, Value lhs, Value rhs) \
|
||||
{ \
|
||||
return TRY_OR_SET_EXCEPTION(snake_case_name(vm, lhs, rhs)); \
|
||||
|
@ -450,7 +453,7 @@ static ThrowCompletionOr<Value> typed_equals(VM&, Value src1, Value src2)
|
|||
}
|
||||
|
||||
JS_ENUMERATE_COMMON_BINARY_OPS_WITHOUT_FAST_PATH(DO_COMPILE_COMMON_BINARY_OP)
|
||||
#undef DO_COMPILE_COMMON_BINARY_OP
|
||||
# undef DO_COMPILE_COMMON_BINARY_OP
|
||||
|
||||
static Value cxx_less_than(VM& vm, Value lhs, Value rhs)
|
||||
{
|
||||
|
@ -509,7 +512,7 @@ static ThrowCompletionOr<Value> typeof_(VM& vm, Value value)
|
|||
return PrimitiveString::create(vm, value.typeof());
|
||||
}
|
||||
|
||||
#define DO_COMPILE_COMMON_UNARY_OP(TitleCaseName, snake_case_name) \
|
||||
# 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)); \
|
||||
|
@ -524,7 +527,7 @@ static ThrowCompletionOr<Value> typeof_(VM& vm, Value value)
|
|||
}
|
||||
|
||||
JS_ENUMERATE_COMMON_UNARY_OPS(DO_COMPILE_COMMON_UNARY_OP)
|
||||
#undef DO_COMPILE_COMMON_UNARY_OP
|
||||
# undef DO_COMPILE_COMMON_UNARY_OP
|
||||
|
||||
void Compiler::compile_return(Bytecode::Op::Return const&)
|
||||
{
|
||||
|
@ -1016,19 +1019,19 @@ OwnPtr<NativeExecutable> Compiler::compile(Bytecode::Executable& bytecode_execut
|
|||
compiler.compile_less_than(static_cast<Bytecode::Op::LessThan 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: \
|
||||
compiler.compile_##snake_case_name(static_cast<Bytecode::Op::TitleCaseName const&>(op)); \
|
||||
break;
|
||||
JS_ENUMERATE_COMMON_BINARY_OPS_WITHOUT_FAST_PATH(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) \
|
||||
# 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
|
||||
# undef DO_COMPILE_COMMON_UNARY_OP
|
||||
|
||||
default:
|
||||
if constexpr (LOG_JIT_FAILURE) {
|
||||
|
@ -1088,3 +1091,5 @@ OwnPtr<NativeExecutable> Compiler::compile(Bytecode::Executable& bytecode_execut
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -6,10 +6,11 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <LibJIT/Assembler.h>
|
||||
#include <LibJS/Bytecode/Executable.h>
|
||||
#include <LibJS/Bytecode/Op.h>
|
||||
#include <LibJS/JIT/NativeExecutable.h>
|
||||
#if ARCH(X86_64)
|
||||
# include <LibJIT/Assembler.h>
|
||||
# include <LibJS/Bytecode/Executable.h>
|
||||
# include <LibJS/Bytecode/Op.h>
|
||||
# include <LibJS/JIT/NativeExecutable.h>
|
||||
|
||||
namespace JS::JIT {
|
||||
|
||||
|
@ -20,6 +21,7 @@ public:
|
|||
static OwnPtr<NativeExecutable> compile(Bytecode::Executable&);
|
||||
|
||||
private:
|
||||
# if ARCH(X86_64)
|
||||
static constexpr auto GPR0 = Assembler::Reg::RAX;
|
||||
static constexpr auto GPR1 = Assembler::Reg::RCX;
|
||||
static constexpr auto ARG0 = Assembler::Reg::RDI;
|
||||
|
@ -33,6 +35,7 @@ private:
|
|||
static constexpr auto REGISTER_ARRAY_BASE = Assembler::Reg::R13;
|
||||
static constexpr auto LOCALS_ARRAY_BASE = Assembler::Reg::R14;
|
||||
static constexpr auto UNWIND_CONTEXT_BASE = Assembler::Reg::R15;
|
||||
# endif
|
||||
|
||||
void compile_load_immediate(Bytecode::Op::LoadImmediate const&);
|
||||
void compile_load(Bytecode::Op::Load const&);
|
||||
|
@ -51,7 +54,7 @@ private:
|
|||
void compile_to_numeric(Bytecode::Op::ToNumeric const&);
|
||||
void compile_resolve_this_binding(Bytecode::Op::ResolveThisBinding const&);
|
||||
|
||||
#define JS_ENUMERATE_COMMON_BINARY_OPS_WITHOUT_FAST_PATH(O) \
|
||||
# define JS_ENUMERATE_COMMON_BINARY_OPS_WITHOUT_FAST_PATH(O) \
|
||||
O(Add, add) \
|
||||
O(Sub, sub) \
|
||||
O(Mul, mul) \
|
||||
|
@ -74,17 +77,17 @@ private:
|
|||
O(RightShift, right_shift) \
|
||||
O(UnsignedRightShift, unsigned_right_shift)
|
||||
|
||||
#define DO_COMPILE_COMMON_BINARY_OP(OpTitleCase, op_snake_case) \
|
||||
# define DO_COMPILE_COMMON_BINARY_OP(OpTitleCase, op_snake_case) \
|
||||
void compile_##op_snake_case(Bytecode::Op::OpTitleCase const&);
|
||||
|
||||
JS_ENUMERATE_COMMON_BINARY_OPS_WITHOUT_FAST_PATH(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) \
|
||||
# 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
|
||||
# undef DO_COMPILE_COMMON_UNARY_OP
|
||||
|
||||
void compile_less_than(Bytecode::Op::LessThan const&);
|
||||
|
||||
|
@ -157,3 +160,14 @@ private:
|
|||
};
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
namespace JS::JIT {
|
||||
class Compiler {
|
||||
public:
|
||||
static OwnPtr<NativeExecutable> compile(Bytecode::Executable&) { return nullptr; }
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue