You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
One question however is if the GetWrappedValue operation should automatically unwrap a wrapped function if its [[Realm]] matches callerRealm. Right now it would double wrap it.
My comment: We need to discuss if the api should unwrap or double wrap functions going back and forth.
I don't see much value or the goal in sending the same function back and forth cross realms. If the goal is to get a unique identity, symbols should resolve this trick in a much more lightweight manner.
Adding an extra check for every function to see if it can be unwrapped might end with some cost, but at the same time, it cuts a chain of references here and there.
The text was updated successfully, but these errors were encountered:
leobalter
changed the title
One question however is if the GetWrappedValue operation should automatically unwrap a wrapped function if its [[Realm]] matches callerRealm. Right now it would double wrap it.
Discuss: automatically unwrap a wrapped function
Mar 27, 2021
Thinking about this more, I think not unwrapping is the right way to go.
Unwrapping wouldn't create full unique identity since passing a normal callable would always create a new wrapper even if a wrapper for that callable already exists in the target realm, so it wouldn't negate the need for symbols. While I don't believe you can build a membrane without the cross realm references that wrapped functions provide, at least until symbols or some other object based unique identity can be used as WeakMap keys, giving more identity power to wrapper functions does seem wrong.
So I agree that auto unwrapping wouldn't be super useful for identity, but it would simplify the chain of reference. However, not specifying unwrapping actually doesn't prevent the implementation from optimizing those references. The implementation could detect these double wrapped functions and substitute them for a local realm bound function, removing the cross realm references, as that wouldn't be observable.
Closing this one. This API is not a membrane, there we should avoid this as it's a potential identity tracking mechanism. This feature would find immediate objection to move forward in the stage process.
Originally posted by @mhofman in #291 (comment)
My comment: We need to discuss if the api should unwrap or double wrap functions going back and forth.
I don't see much value or the goal in sending the same function back and forth cross realms. If the goal is to get a unique identity, symbols should resolve this trick in a much more lightweight manner.
Adding an extra check for every function to see if it can be unwrapped might end with some cost, but at the same time, it cuts a chain of references here and there.
The text was updated successfully, but these errors were encountered: