diff --git a/Userland/Libraries/LibJS/Bytecode/CommonImplementations.cpp b/Userland/Libraries/LibJS/Bytecode/CommonImplementations.cpp index 6638928102..a0436f16ca 100644 --- a/Userland/Libraries/LibJS/Bytecode/CommonImplementations.cpp +++ b/Userland/Libraries/LibJS/Bytecode/CommonImplementations.cpp @@ -89,12 +89,11 @@ ThrowCompletionOr get_by_value(VM& vm, Value base_value, Value property_k return TRY(object->internal_get(property_key, base_value)); } -ThrowCompletionOr get_global(Bytecode::Interpreter& interpreter, DeprecatedFlyString const& identifier, u32 cache_index) +ThrowCompletionOr get_global(Bytecode::Interpreter& interpreter, DeprecatedFlyString const& identifier, GlobalVariableCache& cache) { auto& vm = interpreter.vm(); auto& realm = *vm.current_realm(); - auto& cache = interpreter.current_executable().global_variable_caches[cache_index]; auto& binding_object = realm.global_environment().object_record().binding_object(); auto& declarative_record = realm.global_environment().declarative_record(); diff --git a/Userland/Libraries/LibJS/Bytecode/CommonImplementations.h b/Userland/Libraries/LibJS/Bytecode/CommonImplementations.h index 85f3e7fac3..8939c51f3c 100644 --- a/Userland/Libraries/LibJS/Bytecode/CommonImplementations.h +++ b/Userland/Libraries/LibJS/Bytecode/CommonImplementations.h @@ -15,7 +15,7 @@ namespace JS::Bytecode { ThrowCompletionOr> base_object_for_get(VM&, Value base_value); ThrowCompletionOr get_by_id(VM&, DeprecatedFlyString const& property, Value base_value, Value this_value, PropertyLookupCache&); ThrowCompletionOr get_by_value(VM&, Value base_value, Value property_key_value); -ThrowCompletionOr get_global(Bytecode::Interpreter&, DeprecatedFlyString const& identifier, u32 cache_index); +ThrowCompletionOr get_global(Bytecode::Interpreter&, DeprecatedFlyString const& identifier, GlobalVariableCache&); ThrowCompletionOr put_by_property_key(VM&, Value base, Value this_value, Value value, PropertyKey name, Op::PropertyKind kind); ThrowCompletionOr perform_call(Interpreter&, Value this_value, Op::CallType, Value callee, MarkedVector argument_values); ThrowCompletionOr throw_if_needed_for_call(Interpreter&, Value callee, Op::CallType, Optional const& expression_string); diff --git a/Userland/Libraries/LibJS/Bytecode/Interpreter.cpp b/Userland/Libraries/LibJS/Bytecode/Interpreter.cpp index acbde0abcd..713496d0c5 100644 --- a/Userland/Libraries/LibJS/Bytecode/Interpreter.cpp +++ b/Userland/Libraries/LibJS/Bytecode/Interpreter.cpp @@ -697,7 +697,10 @@ ThrowCompletionOr GetCalleeAndThisFromEnvironment::execute_impl(Bytecode:: ThrowCompletionOr GetGlobal::execute_impl(Bytecode::Interpreter& interpreter) const { - interpreter.accumulator() = TRY(get_global(interpreter, interpreter.current_executable().get_identifier(m_identifier), m_cache_index)); + interpreter.accumulator() = TRY(get_global( + interpreter, + interpreter.current_executable().get_identifier(m_identifier), + interpreter.current_executable().global_variable_caches[m_cache_index])); return {}; } diff --git a/Userland/Libraries/LibJS/JIT/Compiler.cpp b/Userland/Libraries/LibJS/JIT/Compiler.cpp index e21f9215fa..5d36b9d638 100644 --- a/Userland/Libraries/LibJS/JIT/Compiler.cpp +++ b/Userland/Libraries/LibJS/JIT/Compiler.cpp @@ -952,9 +952,9 @@ void Compiler::compile_get_by_value(Bytecode::Op::GetByValue const& op) check_exception(); } -static Value cxx_get_global(VM& vm, DeprecatedFlyString const& identifier, u32 cache_index) +static Value cxx_get_global(VM& vm, DeprecatedFlyString const& identifier, Bytecode::GlobalVariableCache& cache) { - return TRY_OR_SET_EXCEPTION(Bytecode::get_global(vm.bytecode_interpreter(), identifier, cache_index)); + return TRY_OR_SET_EXCEPTION(Bytecode::get_global(vm.bytecode_interpreter(), identifier, cache)); } void Compiler::compile_get_global(Bytecode::Op::GetGlobal const& op) @@ -964,7 +964,7 @@ void Compiler::compile_get_global(Bytecode::Op::GetGlobal const& op) Assembler::Operand::Imm(bit_cast(&m_bytecode_executable.get_identifier(op.identifier())))); m_assembler.mov( Assembler::Operand::Register(ARG2), - Assembler::Operand::Imm(op.cache_index())); + Assembler::Operand::Imm(bit_cast(&m_bytecode_executable.global_variable_caches[op.cache_index()]))); native_call((void*)cxx_get_global); store_accumulator(RET); check_exception();