diff --git a/Userland/Libraries/LibJS/Bytecode/CommonImplementations.cpp b/Userland/Libraries/LibJS/Bytecode/CommonImplementations.cpp index 69ed663fbd..036d36535c 100644 --- a/Userland/Libraries/LibJS/Bytecode/CommonImplementations.cpp +++ b/Userland/Libraries/LibJS/Bytecode/CommonImplementations.cpp @@ -18,9 +18,8 @@ namespace JS::Bytecode { -ThrowCompletionOr> base_object_for_get(Bytecode::Interpreter& interpreter, Value base_value) +ThrowCompletionOr> base_object_for_get(VM& vm, Value base_value) { - auto& vm = interpreter.vm(); if (base_value.is_object()) return base_value.as_object(); @@ -35,10 +34,9 @@ ThrowCompletionOr> base_object_for_get(Bytecode::Interprete return base_value.to_object(vm); } -ThrowCompletionOr get_by_id(Bytecode::Interpreter& interpreter, DeprecatedFlyString const& property, Value base_value, Value this_value, u32 cache_index) +ThrowCompletionOr get_by_id(VM& vm, DeprecatedFlyString const& property, Value base_value, Value this_value, u32 cache_index) { - auto& vm = interpreter.vm(); - auto& cache = interpreter.current_executable().property_lookup_caches[cache_index]; + auto& cache = vm.bytecode_interpreter().current_executable().property_lookup_caches[cache_index]; if (base_value.is_string()) { auto string_value = TRY(base_value.as_string().get(vm, property)); @@ -46,7 +44,7 @@ ThrowCompletionOr get_by_id(Bytecode::Interpreter& interpreter, Deprecate return *string_value; } - auto base_obj = TRY(base_object_for_get(interpreter, base_value)); + auto base_obj = TRY(base_object_for_get(vm, base_value)); // OPTIMIZATION: If the shape of the object hasn't changed, we can use the cached property offset. // NOTE: Unique shapes don't change identity, so we compare their serial numbers instead. @@ -68,10 +66,9 @@ ThrowCompletionOr get_by_id(Bytecode::Interpreter& interpreter, Deprecate return value; } -ThrowCompletionOr get_by_value(Bytecode::Interpreter& interpreter, Value base_value, Value property_key_value) +ThrowCompletionOr get_by_value(VM& vm, Value base_value, Value property_key_value) { - auto& vm = interpreter.vm(); - auto object = TRY(base_object_for_get(interpreter, base_value)); + auto object = TRY(base_object_for_get(vm, base_value)); // OPTIMIZATION: Fast path for simple Int32 indexes in array-like objects. if (property_key_value.is_int32() diff --git a/Userland/Libraries/LibJS/Bytecode/CommonImplementations.h b/Userland/Libraries/LibJS/Bytecode/CommonImplementations.h index 355a5486d1..addb7d5104 100644 --- a/Userland/Libraries/LibJS/Bytecode/CommonImplementations.h +++ b/Userland/Libraries/LibJS/Bytecode/CommonImplementations.h @@ -12,9 +12,9 @@ namespace JS::Bytecode { -ThrowCompletionOr> base_object_for_get(Bytecode::Interpreter&, Value base_value); -ThrowCompletionOr get_by_id(Bytecode::Interpreter&, DeprecatedFlyString const& property, Value base_value, Value this_value, u32 cache_index); -ThrowCompletionOr get_by_value(Bytecode::Interpreter&, Value base_value, Value property_key_value); +ThrowCompletionOr> base_object_for_get(VM&, Value base_value); +ThrowCompletionOr get_by_id(VM&, DeprecatedFlyString const& property, Value base_value, Value this_value, u32 cache_index); +ThrowCompletionOr get_by_value(VM&, Value base_value, Value property_key_value); ThrowCompletionOr get_global(Bytecode::Interpreter&, DeprecatedFlyString const& identifier, u32 cache_index); 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); diff --git a/Userland/Libraries/LibJS/Bytecode/Interpreter.cpp b/Userland/Libraries/LibJS/Bytecode/Interpreter.cpp index c26c199885..c789e29533 100644 --- a/Userland/Libraries/LibJS/Bytecode/Interpreter.cpp +++ b/Userland/Libraries/LibJS/Bytecode/Interpreter.cpp @@ -760,7 +760,7 @@ ThrowCompletionOr SetLocal::execute_impl(Bytecode::Interpreter&) const ThrowCompletionOr GetById::execute_impl(Bytecode::Interpreter& interpreter) const { auto base_value = interpreter.accumulator(); - interpreter.accumulator() = TRY(get_by_id(interpreter, interpreter.current_executable().get_identifier(m_property), base_value, base_value, m_cache_index)); + interpreter.accumulator() = TRY(get_by_id(interpreter.vm(), interpreter.current_executable().get_identifier(m_property), base_value, base_value, m_cache_index)); return {}; } @@ -768,7 +768,7 @@ ThrowCompletionOr GetByIdWithThis::execute_impl(Bytecode::Interpreter& int { auto base_value = interpreter.accumulator(); auto this_value = interpreter.reg(m_this_value); - interpreter.accumulator() = TRY(get_by_id(interpreter, interpreter.current_executable().get_identifier(m_property), base_value, this_value, m_cache_index)); + interpreter.accumulator() = TRY(get_by_id(interpreter.vm(), interpreter.current_executable().get_identifier(m_property), base_value, this_value, m_cache_index)); return {}; } @@ -1071,7 +1071,7 @@ ThrowCompletionOr Await::execute_impl(Bytecode::Interpreter& interpreter) ThrowCompletionOr GetByValue::execute_impl(Bytecode::Interpreter& interpreter) const { - interpreter.accumulator() = TRY(get_by_value(interpreter, interpreter.reg(m_base), interpreter.accumulator())); + interpreter.accumulator() = TRY(get_by_value(interpreter.vm(), interpreter.reg(m_base), interpreter.accumulator())); return {}; } diff --git a/Userland/Libraries/LibJS/JIT/Compiler.cpp b/Userland/Libraries/LibJS/JIT/Compiler.cpp index 00a3c498a3..5ded7822d3 100644 --- a/Userland/Libraries/LibJS/JIT/Compiler.cpp +++ b/Userland/Libraries/LibJS/JIT/Compiler.cpp @@ -921,7 +921,7 @@ void Compiler::compile_new_class(Bytecode::Op::NewClass const& op) static Value cxx_get_by_id(VM& vm, Value base, DeprecatedFlyString const& 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, property, base, base, cache_index)); } void Compiler::compile_get_by_id(Bytecode::Op::GetById const& op) @@ -940,7 +940,7 @@ void Compiler::compile_get_by_id(Bytecode::Op::GetById const& op) static Value cxx_get_by_value(VM& vm, Value base, Value property) { - return TRY_OR_SET_EXCEPTION(Bytecode::get_by_value(vm.bytecode_interpreter(), base, property)); + return TRY_OR_SET_EXCEPTION(Bytecode::get_by_value(vm, base, property)); } void Compiler::compile_get_by_value(Bytecode::Op::GetByValue const& op) @@ -1577,7 +1577,7 @@ void Compiler::compile_resolve_super_base(Bytecode::Op::ResolveSuperBase const&) static Value cxx_get_by_id_with_this(VM& vm, DeprecatedFlyString const& property, Value base_value, Value this_value, u32 cache_index) { - return TRY_OR_SET_EXCEPTION(get_by_id(vm.bytecode_interpreter(), property, base_value, this_value, cache_index)); + return TRY_OR_SET_EXCEPTION(Bytecode::get_by_id(vm, property, base_value, this_value, cache_index)); } void Compiler::compile_get_by_id_with_this(Bytecode::Op::GetByIdWithThis const& op)