diff --git a/Userland/Libraries/LibJS/Bytecode/Op.h b/Userland/Libraries/LibJS/Bytecode/Op.h index 7d98a9484f..633febe80e 100644 --- a/Userland/Libraries/LibJS/Bytecode/Op.h +++ b/Userland/Libraries/LibJS/Bytecode/Op.h @@ -1047,6 +1047,8 @@ public: ThrowCompletionOr execute_impl(Bytecode::Interpreter&) const; DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const; + ScopeNode const& scope_node() const { return m_scope_node; } + private: ScopeNode const& m_scope_node; }; diff --git a/Userland/Libraries/LibJS/JIT/Compiler.cpp b/Userland/Libraries/LibJS/JIT/Compiler.cpp index 68d2f8451b..6d704069a1 100644 --- a/Userland/Libraries/LibJS/JIT/Compiler.cpp +++ b/Userland/Libraries/LibJS/JIT/Compiler.cpp @@ -1162,6 +1162,22 @@ void Compiler::compile_concat_string(Bytecode::Op::ConcatString const& op) check_exception(); } +static void cxx_block_declaration_instantiation(VM& vm, ScopeNode const& scope_node) +{ + auto old_environment = vm.running_execution_context().lexical_environment; + vm.bytecode_interpreter().saved_lexical_environment_stack().append(old_environment); + vm.running_execution_context().lexical_environment = new_declarative_environment(*old_environment); + scope_node.block_declaration_instantiation(vm, vm.running_execution_context().lexical_environment); +} + +void Compiler::compile_block_declaration_instantiation(Bytecode::Op::BlockDeclarationInstantiation const& op) +{ + m_assembler.mov( + Assembler::Operand::Register(ARG1), + Assembler::Operand::Imm(bit_cast(&op.scope_node()))); + native_call((void*)cxx_block_declaration_instantiation); +} + void Compiler::jump_to_exit() { m_assembler.jump(m_exit_label); diff --git a/Userland/Libraries/LibJS/JIT/Compiler.h b/Userland/Libraries/LibJS/JIT/Compiler.h index ec0dbc2324..bb6d1d17f3 100644 --- a/Userland/Libraries/LibJS/JIT/Compiler.h +++ b/Userland/Libraries/LibJS/JIT/Compiler.h @@ -103,7 +103,8 @@ private: O(TypeofVariable, typeof_variable) \ O(SetVariable, set_variable) \ O(ContinuePendingUnwind, continue_pending_unwind) \ - O(ConcatString, concat_string) + O(ConcatString, concat_string) \ + O(BlockDeclarationInstantiation, block_declaration_instantiation) # define DECLARE_COMPILE_OP(OpTitleCase, op_snake_case) \ void compile_##op_snake_case(Bytecode::Op::OpTitleCase const&);