LibJS+LibWeb: Use realm.create<T> instead of heap.allocate<T>

The main motivation behind this is to remove JS specifics of the Realm
from the implementation of the Heap.

As a side effect of this change, this is a bit nicer to read than the
previous approach, and in my opinion, also makes it a little more clear
that this method is specific to a JavaScript Realm.
This commit is contained in:
Shannon Booth 2024-11-14 05:50:17 +13:00 committed by Tim Flynn
commit 9b79a686eb
Notes: github-actions[bot] 2024-11-13 21:52:48 +00:00
326 changed files with 697 additions and 714 deletions

View file

@ -76,7 +76,7 @@ void DedicatedWorkerHost::run(JS::NonnullGCPtr<Web::Page> page, Web::HTML::Trans
// FIXME: support for 'owner' set on WorkerGlobalScope
// IMPLEMENTATION DEFINED: We need an object to represent the fetch response's client
auto outside_settings = inner_settings->heap().allocate<Web::HTML::EnvironmentSettingsSnapshot>(inner_settings->realm(), inner_settings->realm_execution_context().copy(), outside_settings_snapshot);
auto outside_settings = inner_settings->realm().create<Web::HTML::EnvironmentSettingsSnapshot>(inner_settings->realm_execution_context().copy(), outside_settings_snapshot);
// 12. If is shared is true, then:
if (is_shared) {
@ -168,7 +168,7 @@ void DedicatedWorkerHost::run(JS::NonnullGCPtr<Web::Page> page, Web::HTML::Trans
MUST(inside_port->transfer_receiving_steps(message_port_data));
// 6. Create a new WorkerLocation object and associate it with worker global scope.
worker_global_scope->set_location(realm.heap().allocate<Web::HTML::WorkerLocation>(realm, *worker_global_scope));
worker_global_scope->set_location(realm.create<Web::HTML::WorkerLocation>(*worker_global_scope));
// FIXME: 7. Closing orphan workers: Start monitoring the worker such that no sooner than it
// stops being a protected worker, and no later than it stops being a permissible worker,