diff --git a/Userland/Libraries/LibJS/Bytecode/Interpreter.cpp b/Userland/Libraries/LibJS/Bytecode/Interpreter.cpp index 28823598c2..d6aadca2bd 100644 --- a/Userland/Libraries/LibJS/Bytecode/Interpreter.cpp +++ b/Userland/Libraries/LibJS/Bytecode/Interpreter.cpp @@ -354,9 +354,11 @@ Interpreter::ValueAndFrame Interpreter::run_and_return_frame(Executable& executa if (auto native_executable = executable.get_or_create_native_executable()) { native_executable->run(vm()); +#if 0 for (size_t i = 0; i < vm().running_execution_context().local_variables.size(); ++i) { dbgln("%{}: {}", i, vm().running_execution_context().local_variables[i]); } +#endif } else { run_bytecode(); diff --git a/Userland/Libraries/LibJS/JIT/Compiler.cpp b/Userland/Libraries/LibJS/JIT/Compiler.cpp index fdd698d16c..f4eabf98ea 100644 --- a/Userland/Libraries/LibJS/JIT/Compiler.cpp +++ b/Userland/Libraries/LibJS/JIT/Compiler.cpp @@ -175,6 +175,22 @@ void Compiler::compile_increment(Bytecode::Op::Increment const&) check_exception(); } +static Value cxx_decrement(VM& vm, Value value) +{ + auto old_value = TRY_OR_SET_EXCEPTION(value.to_numeric(vm)); + if (old_value.is_number()) + return Value(old_value.as_double() - 1); + return BigInt::create(vm, old_value.as_bigint().big_integer().minus(Crypto::SignedBigInteger { 1 })); +} + +void Compiler::compile_decrement(Bytecode::Op::Decrement const&) +{ + load_vm_register(ARG1, Bytecode::Register::accumulator()); + m_assembler.native_call((void*)cxx_decrement); + store_vm_register(Bytecode::Register::accumulator(), RET); + check_exception(); +} + void Compiler::check_exception() { // if (exception.is_empty()) goto no_exception; @@ -474,6 +490,9 @@ OwnPtr Compiler::compile(Bytecode::Executable& bytecode_execut case Bytecode::Instruction::Type::Increment: compiler.compile_increment(static_cast(op)); break; + case Bytecode::Instruction::Type::Decrement: + compiler.compile_decrement(static_cast(op)); + break; case Bytecode::Instruction::Type::EnterUnwindContext: compiler.compile_enter_unwind_context(static_cast(op)); break; diff --git a/Userland/Libraries/LibJS/JIT/Compiler.h b/Userland/Libraries/LibJS/JIT/Compiler.h index 78e502b444..8b189acbb0 100644 --- a/Userland/Libraries/LibJS/JIT/Compiler.h +++ b/Userland/Libraries/LibJS/JIT/Compiler.h @@ -38,6 +38,7 @@ private: void compile_jump(Bytecode::Op::Jump const&); void compile_jump_conditional(Bytecode::Op::JumpConditional const&); void compile_increment(Bytecode::Op::Increment const&); + void compile_decrement(Bytecode::Op::Decrement const&); void compile_enter_unwind_context(Bytecode::Op::EnterUnwindContext const&); void compile_leave_unwind_context(Bytecode::Op::LeaveUnwindContext const&); void compile_throw(Bytecode::Op::Throw const&);