mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-11 18:20:43 +09:00
LibJS+LibWeb: Replace GlobalObject with Realm in create() functions
This is a continuation of the previous two commits. As allocating a JS cell already primarily involves a realm instead of a global object, and we'll need to pass one to the allocate() function itself eventually (it's bridged via the global object right now), the create() functions need to receive a realm as well. The plan is for this to be the highest-level function that actually receives a realm and passes it around, AOs on an even higher level will use the "current realm" concept via VM::current_realm() as that's what the spec assumes; passing around realms (or global objects, for that matter) on higher AO levels is pointless and unlike for allocating individual objects, which may happen outside of regular JS execution, we don't need control over the specific realm that is being used there.
This commit is contained in:
parent
5dd5896588
commit
b99cc7d050
Notes:
sideshowbarker
2024-07-19 01:59:31 +09:00
Author: https://github.com/linusg
Commit: b99cc7d050
Pull-request: https://github.com/SerenityOS/serenity/pull/14973
Reviewed-by: https://github.com/davidot ✅
178 changed files with 883 additions and 609 deletions
|
@ -15,9 +15,9 @@
|
|||
|
||||
namespace JS {
|
||||
|
||||
ProxyObject* ProxyObject::create(GlobalObject& global_object, Object& target, Object& handler)
|
||||
ProxyObject* ProxyObject::create(Realm& realm, Object& target, Object& handler)
|
||||
{
|
||||
return global_object.heap().allocate<ProxyObject>(global_object, target, handler, *global_object.object_prototype());
|
||||
return realm.heap().allocate<ProxyObject>(realm.global_object(), target, handler, *realm.global_object().object_prototype());
|
||||
}
|
||||
|
||||
ProxyObject::ProxyObject(Object& target, Object& handler, Object& prototype)
|
||||
|
@ -756,6 +756,7 @@ ThrowCompletionOr<Value> ProxyObject::internal_call(Value this_argument, MarkedV
|
|||
{
|
||||
auto& vm = this->vm();
|
||||
auto& global_object = this->global_object();
|
||||
auto& realm = *global_object.associated_realm();
|
||||
|
||||
// A Proxy exotic object only has a [[Call]] internal method if the initial value of its [[ProxyTarget]] internal slot is an object that has a [[Call]] internal method.
|
||||
// TODO: We should be able to turn this into a VERIFY(), this must be checked at the call site.
|
||||
|
@ -783,7 +784,7 @@ ThrowCompletionOr<Value> ProxyObject::internal_call(Value this_argument, MarkedV
|
|||
}
|
||||
|
||||
// 7. Let argArray be CreateArrayFromList(argumentsList).
|
||||
auto* arguments_array = Array::create_from(global_object, arguments_list);
|
||||
auto* arguments_array = Array::create_from(realm, arguments_list);
|
||||
|
||||
// 8. Return ? Call(trap, handler, « target, thisArgument, argArray »).
|
||||
return call(global_object, trap, &m_handler, &m_target, this_argument, arguments_array);
|
||||
|
@ -804,6 +805,7 @@ ThrowCompletionOr<Object*> ProxyObject::internal_construct(MarkedVector<Value> a
|
|||
{
|
||||
auto& vm = this->vm();
|
||||
auto& global_object = this->global_object();
|
||||
auto& realm = *global_object.associated_realm();
|
||||
|
||||
// A Proxy exotic object only has a [[Construct]] internal method if the initial value of its [[ProxyTarget]] internal slot is an object that has a [[Construct]] internal method.
|
||||
// TODO: We should be able to turn this into a VERIFY(), this must be checked at the call site.
|
||||
|
@ -831,7 +833,7 @@ ThrowCompletionOr<Object*> ProxyObject::internal_construct(MarkedVector<Value> a
|
|||
}
|
||||
|
||||
// 8. Let argArray be CreateArrayFromList(argumentsList).
|
||||
auto* arguments_array = Array::create_from(global_object, arguments_list);
|
||||
auto* arguments_array = Array::create_from(realm, arguments_list);
|
||||
|
||||
// 9. Let newObj be ? Call(trap, handler, « target, argArray, newTarget »).
|
||||
auto new_object = TRY(call(global_object, trap, &m_handler, &m_target, arguments_array, &new_target));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue