mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 06:57:44 +00:00
LibJS/JIT: Compile the NewClass bytecode instruction
This commit is contained in:
parent
f9fbb8cff2
commit
4b23a7dfb4
3 changed files with 25 additions and 0 deletions
|
@ -1005,6 +1005,9 @@ 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;
|
||||||
|
|
||||||
|
ClassExpression const& class_expression() const { return m_class_expression; }
|
||||||
|
Optional<IdentifierTableIndex> const& lhs_name() const { return m_lhs_name; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ClassExpression const& m_class_expression;
|
ClassExpression const& m_class_expression;
|
||||||
Optional<IdentifierTableIndex> m_lhs_name;
|
Optional<IdentifierTableIndex> m_lhs_name;
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
#include <LibJS/Runtime/AbstractOperations.h>
|
#include <LibJS/Runtime/AbstractOperations.h>
|
||||||
#include <LibJS/Runtime/Array.h>
|
#include <LibJS/Runtime/Array.h>
|
||||||
#include <LibJS/Runtime/DeclarativeEnvironment.h>
|
#include <LibJS/Runtime/DeclarativeEnvironment.h>
|
||||||
|
#include <LibJS/Runtime/ECMAScriptFunctionObject.h>
|
||||||
#include <LibJS/Runtime/VM.h>
|
#include <LibJS/Runtime/VM.h>
|
||||||
#include <LibJS/Runtime/ValueInlines.h>
|
#include <LibJS/Runtime/ValueInlines.h>
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
|
@ -708,6 +709,23 @@ void Compiler::compile_new_function(Bytecode::Op::NewFunction const& op)
|
||||||
store_vm_register(Bytecode::Register::accumulator(), RET);
|
store_vm_register(Bytecode::Register::accumulator(), RET);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Value cxx_new_class(VM& vm, ClassExpression const& class_expression, Optional<Bytecode::IdentifierTableIndex> const& lhs_name)
|
||||||
|
{
|
||||||
|
return TRY_OR_SET_EXCEPTION(Bytecode::new_class(vm, class_expression, lhs_name));
|
||||||
|
}
|
||||||
|
|
||||||
|
void Compiler::compile_new_class(Bytecode::Op::NewClass const& op)
|
||||||
|
{
|
||||||
|
m_assembler.mov(
|
||||||
|
Assembler::Operand::Register(ARG1),
|
||||||
|
Assembler::Operand::Imm(bit_cast<u64>(&op.class_expression())));
|
||||||
|
m_assembler.mov(
|
||||||
|
Assembler::Operand::Register(ARG2),
|
||||||
|
Assembler::Operand::Imm(bit_cast<u64>(&op.lhs_name())));
|
||||||
|
native_call((void*)cxx_new_class);
|
||||||
|
store_vm_register(Bytecode::Register::accumulator(), RET);
|
||||||
|
}
|
||||||
|
|
||||||
static Value cxx_get_by_id(VM& vm, Value base, Bytecode::IdentifierTableIndex property, u32 cache_index)
|
static Value cxx_get_by_id(VM& vm, Value base, Bytecode::IdentifierTableIndex property, u32 cache_index)
|
||||||
{
|
{
|
||||||
return TRY_OR_SET_EXCEPTION(Bytecode::get_by_id(vm.bytecode_interpreter(), property, base, base, cache_index));
|
return TRY_OR_SET_EXCEPTION(Bytecode::get_by_id(vm.bytecode_interpreter(), property, base, base, cache_index));
|
||||||
|
@ -1251,6 +1269,9 @@ OwnPtr<NativeExecutable> Compiler::compile(Bytecode::Executable& bytecode_execut
|
||||||
case Bytecode::Instruction::Type::CreateVariable:
|
case Bytecode::Instruction::Type::CreateVariable:
|
||||||
compiler.compile_create_variable(static_cast<Bytecode::Op::CreateVariable const&>(op));
|
compiler.compile_create_variable(static_cast<Bytecode::Op::CreateVariable const&>(op));
|
||||||
break;
|
break;
|
||||||
|
case Bytecode::Instruction::Type::NewClass:
|
||||||
|
compiler.compile_new_class(static_cast<Bytecode::Op::NewClass 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: \
|
||||||
|
|
|
@ -100,6 +100,7 @@ private:
|
||||||
void compile_new_function(Bytecode::Op::NewFunction const&);
|
void compile_new_function(Bytecode::Op::NewFunction const&);
|
||||||
void compile_new_regexp(Bytecode::Op::NewRegExp const&);
|
void compile_new_regexp(Bytecode::Op::NewRegExp const&);
|
||||||
void compile_new_bigint(Bytecode::Op::NewBigInt const&);
|
void compile_new_bigint(Bytecode::Op::NewBigInt const&);
|
||||||
|
void compile_new_class(Bytecode::Op::NewClass const&);
|
||||||
|
|
||||||
void compile_create_variable(Bytecode::Op::CreateVariable const&);
|
void compile_create_variable(Bytecode::Op::CreateVariable const&);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue