LibJS: Update ShadowRealm to not hold an ExecutionContext

Noone needs to use this any more :^)

This is somewhat AD-HOC in the constructor as it is based on an open
shadow realm merge request, but applies the intent of the change without
any change in behaviour.
This commit is contained in:
Shannon Booth 2024-11-03 21:09:21 +13:00 committed by Andrew Kaster
parent 3cb62265ab
commit b927d7f658
Notes: github-actions[bot] 2024-11-05 00:16:22 +00:00
2 changed files with 4 additions and 12 deletions

View file

@ -24,10 +24,6 @@ public:
[[nodiscard]] Realm& shadow_realm() { return *m_shadow_realm; }
void set_shadow_realm(NonnullGCPtr<Realm> realm) { m_shadow_realm = realm; }
[[nodiscard]] ExecutionContext const& execution_context() const { return *m_execution_context; }
[[nodiscard]] ExecutionContext& execution_context() { return *m_execution_context; }
void set_execution_context(NonnullOwnPtr<ExecutionContext> context) { m_execution_context = move(context); }
private:
ShadowRealm(Object& prototype);
@ -35,7 +31,6 @@ private:
// 3.5 Properties of ShadowRealm Instances, https://tc39.es/proposal-shadowrealm/#sec-properties-of-shadowrealm-instances
GCPtr<Realm> m_shadow_realm; // [[ShadowRealm]]
OwnPtr<ExecutionContext> m_execution_context; // [[ExecutionContext]]
};
ThrowCompletionOr<void> copy_name_and_length(VM&, FunctionObject& function, FunctionObject& target, Optional<StringView> prefix = {}, Optional<unsigned> arg_count = {});

View file

@ -56,7 +56,6 @@ static ThrowCompletionOr<NonnullGCPtr<Object>> initialize_shadow_realm(ShadowRea
// AD-HOC: Fallback for when there is no host defined implementation.
vm.pop_execution_context();
object.set_execution_context(vm.running_execution_context().copy());
object.set_shadow_realm(*vm.running_execution_context().realm);
return Object::create(realm, realm.intrinsics().object_prototype());
}
@ -74,15 +73,13 @@ ThrowCompletionOr<NonnullGCPtr<Object>> ShadowRealmConstructor::construct(Functi
// 4. Let context be the running Javascript execution context.
auto context = TRY(Realm::initialize_host_defined_realm(vm, [&object](JS::Realm&) -> JS::Object* { return MUST(initialize_shadow_realm(object)); }, nullptr));
// 5. Set O.[[ExecutionContext]] to context.
// 6. Let realmRec be the Realm of context.
// 5. Let realmRec be the Realm of context.
auto& realm_record = *context->realm;
object->set_execution_context(move(context));
// 7. Set O.[[ShadowRealm]] to realmRec.
// 6. Set O.[[ShadowRealm]] to realmRec.
object->set_shadow_realm(realm_record);
// 8. Return O.
// 7. Return O.
return object;
}