From 064bcd8f5cc888f9ecd41d0f5e93ab938bf4f539 Mon Sep 17 00:00:00 2001 From: legendecas Date: Wed, 16 Mar 2022 12:00:07 +0800 Subject: [PATCH 1/2] Normative: GetFunctionRealm may throw on revoked proxies --- spec.html | 50 +++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 45 insertions(+), 5 deletions(-) diff --git a/spec.html b/spec.html index 8d4a00b..b70ca97 100644 --- a/spec.html +++ b/spec.html @@ -108,11 +108,34 @@

a wrapped function exotic object _F_
+ 1. Let _callerContext_ be the running execution context. 1. Let _target_ be _F_.[[WrappedTargetFunction]]. 1. Assert: IsCallable(_target_) is *true*. - 1. Let _targetRealm_ be ? GetFunctionRealm(_target_). - 1. Let _callerRealm_ be ? GetFunctionRealm(_F_). + 1. Let _calleeContext_ be PrepareForWrappedFunctionCall(_F_). + 1. Assert: _calleeContext_ is now the running execution context. + 1. Let result be OrdinaryWrappedFunctionCall(_F_, _thisArgument_, _argumentsList_). + 1. Remove _calleeContext_ from the execution context stack and restore _callerContext_ as the running execution context. + 1. If result.[[Type]] is return, return result.[[Value]]. + 1. ReturnIfAbrupt(result). + 1. Return *undefined*. + + + In the case of an abrupt ~throw~ completion, the type of error to be created should match the type of the abrupt throw completion record. This could be revisited when merging into the main specification. Additionally, in the case of a ~break~ or ~continue~ completion, since those are not supported, a TypeError is expected. + + + + +

+ OrdinaryWrappedFunctionCall ( + _F_: a wrapped function exotic object, + _thisArgument_: an ECMAScript language value, + _argumentsList_: a List of ECMAScript language values, + ) +

+ + 1. Let _callerRealm_ be _F_.[[Realm]]. 1. NOTE: Any exception objects produced after this point are associated with _callerRealm_. + 1. Let _targetRealm_ be ? GetFunctionRealm(_target_). 1. Let _wrappedArgs_ be a new empty List. 1. For each element _arg_ of _argumentsList_, do 1. Let _wrappedValue_ be ? GetWrappedValue(_targetRealm_, _arg_). @@ -124,9 +147,26 @@

1. Else, 1. Throw a *TypeError* exception. - - In the case of an abrupt ~throw~ completion, the type of error to be created should match the type of the abrupt throw completion record. This could be revisited when merging into the main specification. Additionally, in the case of a ~break~ or ~continue~ completion, since those are not supported, a TypeError is expected. - + + + +

+ PrepareForWrappedFunctionCall ( + _F_: a wrapped function exotic object, + ) +

+ + 1. Let callerContext be the running execution context. + 1. Let calleeContext be a new execution context. + 1. Set the Function of calleeContext to F. + 1. Let calleeRealm be F.[[Realm]]. + 1. Set the Realm of calleeContext to calleeRealm. + 1. Set the ScriptOrModule of calleeContext to *null*. + 1. If callerContext is not already suspended, suspend callerContext. + 1. Push calleeContext onto the execution context stack; calleeContext is now the running execution context. + 1. NOTE: Any exception objects produced after this point are associated with calleeRealm. + 1. Return calleeContext. +
From 4834cf3ef69298ceb487d2e0ac582b64024a9f54 Mon Sep 17 00:00:00 2001 From: legendecas Date: Fri, 1 Apr 2022 23:32:40 +0800 Subject: [PATCH 2/2] fixup! --- spec.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec.html b/spec.html index b70ca97..1ee9fbe 100644 --- a/spec.html +++ b/spec.html @@ -109,8 +109,6 @@

1. Let _callerContext_ be the running execution context. - 1. Let _target_ be _F_.[[WrappedTargetFunction]]. - 1. Assert: IsCallable(_target_) is *true*. 1. Let _calleeContext_ be PrepareForWrappedFunctionCall(_F_). 1. Assert: _calleeContext_ is now the running execution context. 1. Let result be OrdinaryWrappedFunctionCall(_F_, _thisArgument_, _argumentsList_). @@ -133,6 +131,8 @@

)

+ 1. Let _target_ be _F_.[[WrappedTargetFunction]]. + 1. Assert: IsCallable(_target_) is *true*. 1. Let _callerRealm_ be _F_.[[Realm]]. 1. NOTE: Any exception objects produced after this point are associated with _callerRealm_. 1. Let _targetRealm_ be ? GetFunctionRealm(_target_).