1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 00:37:35 +00:00

LibJS: Introduce Builtins

Builtins are functions that can be detected during bytecode generation
and enable fast-paths in the JIT.
This commit is contained in:
Simon Wanner 2023-11-17 11:48:30 +01:00 committed by Andreas Kling
parent b9141d85d8
commit 86b85aa68b
13 changed files with 191 additions and 4 deletions

View file

@ -9,6 +9,7 @@
#include <AK/Platform.h>
#include <LibJIT/Assembler.h>
#include <LibJS/Bytecode/Builtins.h>
#include <LibJS/Bytecode/Executable.h>
#include <LibJS/Bytecode/Op.h>
#include <LibJS/JIT/NativeExecutable.h>
@ -44,6 +45,8 @@ private:
static constexpr auto RUNNING_EXECUTION_CONTEXT_BASE = Assembler::Reg::R15;
# endif
static Assembler::Reg argument_register(u32);
# define JS_ENUMERATE_COMMON_BINARY_OPS_WITHOUT_FAST_PATH(O) \
O(Div, div) \
O(Exp, exp) \
@ -147,6 +150,12 @@ private:
JS_ENUMERATE_IMPLEMENTED_JIT_OPS(DECLARE_COMPILE_OP)
# undef DECLARE_COMPILE_OP
void compile_builtin(Bytecode::Builtin, Assembler::Label& slow_case, Assembler::Label& end);
# define DECLARE_COMPILE_BUILTIN(name, snake_case_name, ...) \
void compile_builtin_##snake_case_name(Assembler::Label& slow_case, Assembler::Label& end);
JS_ENUMERATE_BUILTINS(DECLARE_COMPILE_BUILTIN)
# undef DECLARE_COMPILE_BUILTIN
void store_vm_register(Bytecode::Register, Assembler::Reg);
void load_vm_register(Assembler::Reg, Bytecode::Register);