diff --git a/Userland/Libraries/LibJS/Bytecode/Interpreter.cpp b/Userland/Libraries/LibJS/Bytecode/Interpreter.cpp index 882b21cbe9..2671ecfc17 100644 --- a/Userland/Libraries/LibJS/Bytecode/Interpreter.cpp +++ b/Userland/Libraries/LibJS/Bytecode/Interpreter.cpp @@ -58,8 +58,8 @@ void Interpreter::visit_edges(Cell::Visitor& visitor) visitor.visit(*m_saved_return_value); if (m_saved_exception.has_value()) visitor.visit(*m_saved_exception); - for (auto& window : m_register_windows) { - window.visit([&](auto& value) { value->visit_edges(visitor); }); + for (auto& frame : m_call_frames) { + frame.visit([&](auto& value) { value->visit_edges(visitor); }); } } @@ -193,7 +193,7 @@ ThrowCompletionOr Interpreter::run(SourceTextModule& module) return js_undefined(); } -Interpreter::ValueAndFrame Interpreter::run_and_return_frame(Realm& realm, Executable& executable, BasicBlock const* entry_point, RegisterWindow* in_frame) +Interpreter::ValueAndFrame Interpreter::run_and_return_frame(Realm& realm, Executable& executable, BasicBlock const* entry_point, CallFrame* in_frame) { dbgln_if(JS_BYTECODE_DEBUG, "Bytecode::Interpreter will run unit {:p}", &executable); @@ -219,9 +219,9 @@ Interpreter::ValueAndFrame Interpreter::run_and_return_frame(Realm& realm, Execu TemporaryChange restore_current_block { m_current_block, entry_point ?: executable.basic_blocks.first() }; if (in_frame) - push_register_window(in_frame, executable.number_of_registers); + push_call_frame(in_frame, executable.number_of_registers); else - push_register_window(make(), executable.number_of_registers); + push_call_frame(make(), executable.number_of_registers); for (;;) { Bytecode::InstructionStreamIterator pc(m_current_block->instruction_stream()); @@ -321,7 +321,7 @@ Interpreter::ValueAndFrame Interpreter::run_and_return_frame(Realm& realm, Execu } } - auto frame = pop_register_window(); + auto frame = pop_call_frame(); Value return_value = js_undefined(); if (m_return_value.has_value()) { @@ -331,8 +331,8 @@ Interpreter::ValueAndFrame Interpreter::run_and_return_frame(Realm& realm, Execu } // NOTE: The return value from a called function is put into $0 in the caller context. - if (!m_register_windows.is_empty()) - window().registers[0] = return_value; + if (!m_call_frames.is_empty()) + call_frame().registers[0] = return_value; // At this point we may have already run any queued promise jobs via on_call_stack_emptied, // in which case this is a no-op. @@ -349,13 +349,13 @@ Interpreter::ValueAndFrame Interpreter::run_and_return_frame(Realm& realm, Execu Value thrown_value = m_saved_exception.value(); m_saved_exception = {}; m_saved_return_value = {}; - if (auto* register_window = frame.get_pointer>()) - return { throw_completion(thrown_value), move(*register_window) }; + if (auto* call_frame = frame.get_pointer>()) + return { throw_completion(thrown_value), move(*call_frame) }; return { throw_completion(thrown_value), nullptr }; } - if (auto* register_window = frame.get_pointer>()) - return { return_value, move(*register_window) }; + if (auto* call_frame = frame.get_pointer>()) + return { return_value, move(*call_frame) }; return { return_value, nullptr }; } @@ -462,18 +462,18 @@ Realm& Interpreter::realm() return *m_vm.current_realm(); } -void Interpreter::push_register_window(Variant, RegisterWindow*> window, size_t register_count) +void Interpreter::push_call_frame(Variant, CallFrame*> frame, size_t register_count) { - m_register_windows.append(move(window)); - this->window().registers.resize(register_count); - m_current_register_window = this->window().registers; + m_call_frames.append(move(frame)); + this->call_frame().registers.resize(register_count); + m_current_call_frame = this->call_frame().registers; } -Variant, RegisterWindow*> Interpreter::pop_register_window() +Variant, CallFrame*> Interpreter::pop_call_frame() { - auto window = m_register_windows.take_last(); - m_current_register_window = m_register_windows.is_empty() ? Span {} : this->window().registers; - return window; + auto frame = m_call_frames.take_last(); + m_current_call_frame = m_call_frames.is_empty() ? Span {} : this->call_frame().registers; + return frame; } } diff --git a/Userland/Libraries/LibJS/Bytecode/Interpreter.h b/Userland/Libraries/LibJS/Bytecode/Interpreter.h index 24eefaedfe..019837dc10 100644 --- a/Userland/Libraries/LibJS/Bytecode/Interpreter.h +++ b/Userland/Libraries/LibJS/Bytecode/Interpreter.h @@ -19,7 +19,7 @@ namespace JS::Bytecode { class InstructionStreamIterator; class PassManager; -struct RegisterWindow { +struct CallFrame { void visit_edges(Cell::Visitor& visitor) { for (auto const& value : registers) @@ -58,15 +58,15 @@ public: struct ValueAndFrame { ThrowCompletionOr value; - OwnPtr frame; + OwnPtr frame; }; - ValueAndFrame run_and_return_frame(Realm&, Bytecode::Executable&, Bytecode::BasicBlock const* entry_point, RegisterWindow* = nullptr); + ValueAndFrame run_and_return_frame(Realm&, Bytecode::Executable&, Bytecode::BasicBlock const* entry_point, CallFrame* = nullptr); ALWAYS_INLINE Value& accumulator() { return reg(Register::accumulator()); } Value& reg(Register const& r) { return registers()[r.index()]; } - auto& saved_lexical_environment_stack() { return window().saved_lexical_environments; } - auto& unwind_contexts() { return window().unwind_contexts; } + auto& saved_lexical_environment_stack() { return call_frame().saved_lexical_environments; } + auto& unwind_contexts() { return call_frame().unwind_contexts; } void jump(Label const& label) { @@ -101,25 +101,25 @@ public: void visit_edges(Cell::Visitor&); private: - RegisterWindow& window() + CallFrame& call_frame() { - return m_register_windows.last().visit([](auto& x) -> RegisterWindow& { return *x; }); + return m_call_frames.last().visit([](auto& x) -> CallFrame& { return *x; }); } - RegisterWindow const& window() const + CallFrame const& call_frame() const { - return const_cast(this)->window(); + return const_cast(this)->call_frame(); } - Span registers() { return m_current_register_window; } - ReadonlySpan registers() const { return m_current_register_window; } + Span registers() { return m_current_call_frame; } + ReadonlySpan registers() const { return m_current_call_frame; } - void push_register_window(Variant, RegisterWindow*>, size_t register_count); - [[nodiscard]] Variant, RegisterWindow*> pop_register_window(); + void push_call_frame(Variant, CallFrame*>, size_t register_count); + [[nodiscard]] Variant, CallFrame*> pop_call_frame(); VM& m_vm; - Vector, RegisterWindow*>> m_register_windows; - Span m_current_register_window; + Vector, CallFrame*>> m_call_frames; + Span m_current_call_frame; Optional m_pending_jump; BasicBlock const* m_scheduled_jump { nullptr }; Optional m_return_value; diff --git a/Userland/Libraries/LibJS/Runtime/AsyncGenerator.cpp b/Userland/Libraries/LibJS/Runtime/AsyncGenerator.cpp index 18a7a57412..178fdde703 100644 --- a/Userland/Libraries/LibJS/Runtime/AsyncGenerator.cpp +++ b/Userland/Libraries/LibJS/Runtime/AsyncGenerator.cpp @@ -14,7 +14,7 @@ namespace JS { -ThrowCompletionOr> AsyncGenerator::create(Realm& realm, Value initial_value, ECMAScriptFunctionObject* generating_function, ExecutionContext execution_context, Bytecode::RegisterWindow frame) +ThrowCompletionOr> AsyncGenerator::create(Realm& realm, Value initial_value, ECMAScriptFunctionObject* generating_function, ExecutionContext execution_context, Bytecode::CallFrame frame) { auto& vm = realm.vm(); // This is "g1.prototype" in figure-2 (https://tc39.es/ecma262/img/figure-2.png) @@ -190,7 +190,7 @@ void AsyncGenerator::execute(VM& vm, Completion completion) VERIFY(!m_generating_function->bytecode_executable()->basic_blocks.find_if([next_block](auto& block) { return block == next_block; }).is_end()); - Bytecode::RegisterWindow* frame = nullptr; + Bytecode::CallFrame* frame = nullptr; if (m_frame.has_value()) frame = &m_frame.value(); diff --git a/Userland/Libraries/LibJS/Runtime/AsyncGenerator.h b/Userland/Libraries/LibJS/Runtime/AsyncGenerator.h index 933fe199c6..51ed6ab20e 100644 --- a/Userland/Libraries/LibJS/Runtime/AsyncGenerator.h +++ b/Userland/Libraries/LibJS/Runtime/AsyncGenerator.h @@ -27,7 +27,7 @@ public: Completed, }; - static ThrowCompletionOr> create(Realm&, Value, ECMAScriptFunctionObject*, ExecutionContext, Bytecode::RegisterWindow); + static ThrowCompletionOr> create(Realm&, Value, ECMAScriptFunctionObject*, ExecutionContext, Bytecode::CallFrame); virtual ~AsyncGenerator() override = default; @@ -59,7 +59,7 @@ private: GCPtr m_generating_function; Value m_previous_value; - Optional m_frame; + Optional m_frame; GCPtr m_current_promise; }; diff --git a/Userland/Libraries/LibJS/Runtime/GeneratorObject.cpp b/Userland/Libraries/LibJS/Runtime/GeneratorObject.cpp index 63b3a55446..1c7fc6e9bf 100644 --- a/Userland/Libraries/LibJS/Runtime/GeneratorObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/GeneratorObject.cpp @@ -14,7 +14,7 @@ namespace JS { -ThrowCompletionOr> GeneratorObject::create(Realm& realm, Value initial_value, ECMAScriptFunctionObject* generating_function, ExecutionContext execution_context, Bytecode::RegisterWindow frame) +ThrowCompletionOr> GeneratorObject::create(Realm& realm, Value initial_value, ECMAScriptFunctionObject* generating_function, ExecutionContext execution_context, Bytecode::CallFrame frame) { auto& vm = realm.vm(); // This is "g1.prototype" in figure-2 (https://tc39.es/ecma262/img/figure-2.png) @@ -111,7 +111,7 @@ ThrowCompletionOr GeneratorObject::execute(VM& vm, Completion const& comp VERIFY(!m_generating_function->bytecode_executable()->basic_blocks.find_if([next_block](auto& block) { return block == next_block; }).is_end()); - Bytecode::RegisterWindow* frame = nullptr; + Bytecode::CallFrame* frame = nullptr; if (m_frame.has_value()) frame = &m_frame.value(); diff --git a/Userland/Libraries/LibJS/Runtime/GeneratorObject.h b/Userland/Libraries/LibJS/Runtime/GeneratorObject.h index 1217870e92..bfbadddec0 100644 --- a/Userland/Libraries/LibJS/Runtime/GeneratorObject.h +++ b/Userland/Libraries/LibJS/Runtime/GeneratorObject.h @@ -16,7 +16,7 @@ class GeneratorObject : public Object { JS_OBJECT(GeneratorObject, Object); public: - static ThrowCompletionOr> create(Realm&, Value, ECMAScriptFunctionObject*, ExecutionContext, Bytecode::RegisterWindow); + static ThrowCompletionOr> create(Realm&, Value, ECMAScriptFunctionObject*, ExecutionContext, Bytecode::CallFrame); virtual ~GeneratorObject() override = default; void visit_edges(Cell::Visitor&) override; @@ -42,7 +42,7 @@ private: ExecutionContext m_execution_context; GCPtr m_generating_function; Value m_previous_value; - Optional m_frame; + Optional m_frame; GeneratorState m_generator_state { GeneratorState::SuspendedStart }; Optional m_generator_brand; };