mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 03:57:44 +00:00
LibJS: Make Bytecode::Executable GC-allocated
This is a step towards making ExecutionContext easier to allocate.
This commit is contained in:
parent
ece961f882
commit
ecfcc9aef3
13 changed files with 34 additions and 19 deletions
|
@ -679,7 +679,7 @@ ThrowCompletionOr<Value> perform_eval(VM& vm, Value x, CallerMode strict_caller,
|
|||
|
||||
// 29. If result.[[Type]] is normal, then
|
||||
// a. Set result to the result of evaluating body.
|
||||
auto executable_result = Bytecode::Generator::generate(program);
|
||||
auto executable_result = Bytecode::Generator::generate(vm, program);
|
||||
if (executable_result.is_error())
|
||||
return vm.throw_completion<InternalError>(ErrorType::NotImplemented, TRY_OR_THROW_OOM(vm, executable_result.error().to_string()));
|
||||
|
||||
|
|
|
@ -527,6 +527,10 @@ void ECMAScriptFunctionObject::visit_edges(Visitor& visitor)
|
|||
visitor.visit(m_realm);
|
||||
visitor.visit(m_home_object);
|
||||
|
||||
visitor.visit(m_bytecode_executable);
|
||||
for (auto& executable : m_default_parameter_bytecode_executables)
|
||||
visitor.visit(executable);
|
||||
|
||||
for (auto& field : m_fields) {
|
||||
if (auto* property_key_ptr = field.name.get_pointer<PropertyKey>(); property_key_ptr && property_key_ptr->is_symbol())
|
||||
visitor.visit(property_key_ptr->as_symbol());
|
||||
|
|
|
@ -112,8 +112,8 @@ private:
|
|||
ThrowCompletionOr<void> function_declaration_instantiation();
|
||||
|
||||
DeprecatedFlyString m_name;
|
||||
RefPtr<Bytecode::Executable> m_bytecode_executable;
|
||||
Vector<NonnullRefPtr<Bytecode::Executable>> m_default_parameter_bytecode_executables;
|
||||
GCPtr<Bytecode::Executable> m_bytecode_executable;
|
||||
Vector<NonnullGCPtr<Bytecode::Executable>> m_default_parameter_bytecode_executables;
|
||||
i32 m_function_length { 0 };
|
||||
Vector<DeprecatedFlyString> m_local_variables_names;
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibJS/Bytecode/Executable.h>
|
||||
#include <LibJS/Runtime/ExecutionContext.h>
|
||||
#include <LibJS/Runtime/FunctionObject.h>
|
||||
|
||||
|
@ -50,6 +51,8 @@ void ExecutionContext::visit_edges(Cell::Visitor& visitor)
|
|||
visitor.visit(private_environment);
|
||||
visitor.visit(context_owner);
|
||||
visitor.visit(this_value);
|
||||
if (instruction_stream_iterator.has_value())
|
||||
visitor.visit(const_cast<Bytecode::Executable*>(instruction_stream_iterator.value().executable()));
|
||||
script_or_module.visit(
|
||||
[](Empty) {},
|
||||
[&](auto& script_or_module) {
|
||||
|
|
|
@ -55,7 +55,7 @@ public:
|
|||
MarkedVector<Value> local_variables;
|
||||
bool is_strict_mode { false };
|
||||
|
||||
RefPtr<Bytecode::Executable> executable;
|
||||
GCPtr<Bytecode::Executable> executable;
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/webappapis.html#skip-when-determining-incumbent-counter
|
||||
// FIXME: Move this out of LibJS (e.g. by using the CustomData concept), as it's used exclusively by LibWeb.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue