@@ -426,6 +426,7 @@ GC_DEFINE_ALLOCATOR(SharedFunctionInstanceData);
426426void SharedFunctionInstanceData::visit_edges (Visitor& visitor)
427427{
428428 Base::visit_edges (visitor);
429+ visitor.visit (m_executable);
429430}
430431
431432SharedFunctionInstanceData::~SharedFunctionInstanceData () = default ;
@@ -498,17 +499,15 @@ void ECMAScriptFunctionObject::initialize(Realm& realm)
498499
499500ThrowCompletionOr<void > ECMAScriptFunctionObject::get_stack_frame_size (size_t & registers_and_constants_and_locals_count, size_t & argument_count)
500501{
501- if (!m_bytecode_executable) {
502- if (!ecmascript_code ().bytecode_executable ()) {
503- if (is_module_wrapper ()) {
504- const_cast <Statement&>(ecmascript_code ()).set_bytecode_executable (TRY (Bytecode::compile (vm (), ecmascript_code (), kind (), name ())));
505- } else {
506- const_cast <Statement&>(ecmascript_code ()).set_bytecode_executable (TRY (Bytecode::compile (vm (), *this )));
507- }
502+ auto & executable = shared_data ().m_executable ;
503+ if (!executable) {
504+ if (is_module_wrapper ()) {
505+ executable = TRY (Bytecode::compile (vm (), ecmascript_code (), kind (), name ()));
506+ } else {
507+ executable = TRY (Bytecode::compile (vm (), *this ));
508508 }
509- m_bytecode_executable = ecmascript_code ().bytecode_executable ();
510509 }
511- registers_and_constants_and_locals_count = m_bytecode_executable ->number_of_registers + m_bytecode_executable ->constants .size () + m_bytecode_executable ->local_variable_names .size ();
510+ registers_and_constants_and_locals_count = executable ->number_of_registers + executable ->constants .size () + executable ->local_variable_names .size ();
512511 argument_count = max (argument_count, formal_parameters ().size ());
513512 return {};
514513}
@@ -518,7 +517,7 @@ FLATTEN ThrowCompletionOr<Value> ECMAScriptFunctionObject::internal_call(Executi
518517{
519518 auto & vm = this ->vm ();
520519
521- ASSERT (m_bytecode_executable );
520+ ASSERT (bytecode_executable () );
522521
523522 // 1. Let callerContext be the running execution context.
524523 // NOTE: No-op, kept by the VM in its execution context stack.
@@ -563,7 +562,7 @@ FLATTEN ThrowCompletionOr<GC::Ref<Object>> ECMAScriptFunctionObject::internal_co
563562{
564563 auto & vm = this ->vm ();
565564
566- ASSERT (m_bytecode_executable );
565+ ASSERT (bytecode_executable () );
567566
568567 // 1. Let callerContext be the running execution context.
569568 // NOTE: No-op, kept by the VM in its execution context stack.
@@ -652,7 +651,6 @@ void ECMAScriptFunctionObject::visit_edges(Visitor& visitor)
652651 visitor.visit (m_home_object);
653652 visitor.visit (m_name_string);
654653 visitor.visit (m_shared_data);
655- visitor.visit (m_bytecode_executable);
656654
657655 if (m_class_data) {
658656 for (auto & field : m_class_data->fields ) {
@@ -892,7 +890,7 @@ template void async_function_start(VM&, PromiseCapability const&, GC::Function<C
892890// 15.8.4 Runtime Semantics: EvaluateAsyncFunctionBody, https://tc39.es/ecma262/#sec-runtime-semantics-evaluatefunctionbody
893891ThrowCompletionOr<Value> ECMAScriptFunctionObject::ordinary_call_evaluate_body (VM& vm)
894892{
895- auto result_and_frame = vm.bytecode_interpreter ().run_executable (*m_bytecode_executable , {});
893+ auto result_and_frame = vm.bytecode_interpreter ().run_executable (*bytecode_executable () , {});
896894
897895 if (result_and_frame.value .is_error ()) [[unlikely]] {
898896 return result_and_frame.value .release_error ();
0 commit comments