-
Notifications
You must be signed in to change notification settings - Fork 67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Stage 3 Reviewers #304
Comments
Here's some initial thoughts: In https://tc39.es/proposal-realms/#sec-wrapped-function-exotic-objects-call-thisargument-argumentslist: why do you need to wrap the completion record value in a new record, as opposed to just passing on the completion record (when its type is normal or return)? Related, why are you passing a completion record to GetWrappedValue? It seems like in the "if" branch, you could Additionally, since the only possible types of completion record from the invocation is "abrupt" or "normal or return", it kind of seems like you could branch on whether it's abrupt, and not have to explicitly mention normal/return. @bakkot Can eval, Function, and https://tc39.es/proposal-realms/#sec-performrealmeval be made to maximally share steps/AOs? It seems like it'd be helpful if they could all be expressed in terms of the same operation(s). Should the name of the [[Realm]] slot be the same on functions and Realm instances? Perhaps it should, if it's holding the same types of values, but perhaps it'd be better to differentiate the two? "Perform" is typically the verb associated with calling an AO and ignoring any non-abrupt return value. Can https://tc39.es/proposal-realms/#sec-performrealmimportvalue start with something besides "Perform"? I'm not sure what all the "Extensible web:" phrases are in the notes - we don't have this anywhere in the spec, and it doesn't link anywhere. What's the purpose of that note prefix? In https://tc39.es/proposal-realms/#sec-hostimportmodulebindingdynamically: the "failure path" sentence reads oddly to me, and I'm not sure what it means exactly. Also, for the "success path" case, should the completion record's type be constrained to be "normal"? |
First round review as follows.
|
Also doing a round of reviews, made a pr with the smaller stuff. I think I largely noticed the same things as Shu. One issue is that with, inFunction, inMethod, and inDerivedConstructor are always false, but I not sure how they are intended to be set from the spec text. Regarding suspending execution contexts: I think if it is possible to use push/pop instead it is preferable (currently having this discussion) Hopefully we can get general guidance on that. I think doing what shu suggested is a good idea, rather use push/pop for sync contexts. In 3.1.1 the two realms might be the same realm, should an assertion be added to prevent that? in 3.2.1 is there a case where the in 3.6.2 -- I found this segment difficult to read. It might benefit from another pass. For example, is the discrepancy in time between the success and failure path intentional? |
@syg:
This synchronously suspended for the following steps setting evalContext to be stacked in the running execution context, see step 21 ( This behavior matches steps 18 to 31 from PerformEval. The similar behavior happens in RealmImportValue to shift the running execution context of the Host import hook to the target realm.
As the Editor's note says, we might try an alternative, but I hope this can be an implementation detail for stage 3 defining how to better fit it in an eventual PR for ECMA-262. WDYT?
We have plans to revert HostImportModuleBindingDynamically to HostImportModuleDynamically and pick the binding value from it. This would remove the requirement for the HTML integration text. I'm answering @codehag feedback in a separate comment. |
Thanks! I believe those were originally intended to be used in direct evals from the
I hope this can be something we address after Stage 3, but in general I support the spec text improvement.
I don't think it's possible for the two realm being the same with the current proposed spec. PerformRealmEval only happens from
As the API can't transfer non callable objects across realms, it can't access any Also, the functions are not unwrapped... A realm could return a function that is sent and rewrapped to the function's original realm: const r = new Realm();
const wrapper = realm.evaluate('fn => fn');
const originalFn = x = x * 2;
const wrappedFn = wrapper(originalFn); // originalFn is wrapped in the realm r
// and wrapped again in the return of wrapper
originalFn !== wrappedFn; // true, the function is never unwrapped.
// wrappedFn is a wrapping of the realm r's received `fn`, and `fn` is a wrapped function of `originalFn`.
I just cleaned up the constructor text in 067c381. There are some consistency challenges here: the Realm constructor is not exactly an internal abstraction as the text for "The abstract operation" is seen on those only. The previous text saying "called with no arguments" is seen often in Annex B methods (e.g. WDYT?
The current This abstraction is indeed difficult to read and still confuses me a bit, that's why we are considering refactoring this to just reuse the original hook and fetch the requested value without adding a new hook. Ideally, this desired abstraction should operate on top of HostImportModuleDynamically, and if this one succeeds, it tries to get the property identified from I'll circle back when I have updates on this part. |
I've never worked on spec before, so please correct me if I'm wrong. If the realms currently can't be the same, why not add it to the spec that they shouldn't be the same? Wouldn't this extra explicitness make the spec more robust and maybe prevent weird situations when this spec is changed/expanded in lets say 2-3 years time? My comment is not meant as criticism, but rather as an inquiry as to the inner workings of speccing ES :D |
From this perspective, I probably misinterpreted @codehag's feedback and maybe this is just about having a "assert" line rather than an actual assertion that would prevent that by actually comparing both realms and throwing an error if they're equal. I'm fine adding the assert line if that's preferred. |
This comment has been minimized.
This comment has been minimized.
We extensively discussed these objections. Some of the suggestions are also hard objections from other delegates. I wonder if this can be considered in a path this proposal could in fact advance, ever. |
Pick utils from Web API into the ES API so they can be used everywhere (#284 (comment)) At least this one is the safest one we can choose. |
There is an answer for that comment. The current ES hook does not prevent this from happening, but we need to finish the HTML integration to have a proper list of properties that are known to be added. After that, we can have a new discussion at TC39 if we should add these names to ES and what it means. The current proposal does not request demand on things we desire to discuss in the HTML integration as the proper venue. Our ES requirements are already set in this draft. |
Oh wow, I've been misunderstanding "Suspend" all these years, thanks for pointing out what's going on in PerformEval. I thought Suspend was purely for actual suspension for things like generators, but it is in fact also used to mark which execution context is the running one. I thought "running" was purely distinguished by being top of the execution context stack. This is kind of confusing, I'll think about improving this editorially. |
* Fix steps for [[Call]] Ref https://github.com/tc39/proposal-realms/issues/304\#issuecomment-842736704 * Remove unused spec variables * Clarify the Realm constructor has no parameters Ref https://github.com/tc39/proposal-realms/issues/304\#issuecomment-843312644 * Consistency fix: If foo Contains bar is *true*
@Jack-Works this issue is for stage 3 editorial review feedback on the current proposal, not for objections about the proposal itself, I will recommend that you comment on the original issue if you haven't done that yet. |
Editorially, the spec text mostly looks okay to me modulo the following:
|
The spec LGTM; my main concern was addressed in #311 |
I found some issues with the spec text, but they all seem fairly easy to fix:
|
great feedback @gibson042, inline...
That is intentional, to have room for implementers to do optimizations. E.g.: if a realm calls a Wrapped Function Exotic Objects, and passes as an argument a regular function, which will be wrapped on the way in, if that Wrapped Function Exotic Objects comes back to the realm via another call, there is nothing that prevent the implements to optimize the new Wrapped Function Exotic Objects to have
We had some back-and-forward with this particular issue very recently. Initially, I specified that the Wrapped Function Exotic Objects should have a [[Realm]] slot so we could hit step
Good catch. @leobalter the value of
I believe the editorial note explains a little bit, but basically, for the value to be empty, it must be a return statement of some sort, which is not allow by syntax in this case. Maybe I'm missing something here.
An alternative here is to use the full reference to that TypeError, similar to what we do in
Probably an oversight, we should assert it.
I believe I asked the same question in the PR from @littledan, I agree with this.
Yes, there is a PR for that particular piece: #315
I can answer the first part: it is that strict to avoid the confusion with |
Ah, in that case I think the best fix is removing "from the other realm" text, leaving the description of [[WrappedTargetFunction]] as just "Stores the callable object
So |
This inherits from the PerformEval steps and we are just keeping some consistency. Maybe this was just excessive caution and it's not necessary due to evaluate not having the same distinction between direct/indirect evals?
It is not observable, but I remain tricked on how to change that. I'll try to get a PR soon.
Resolved at 932220c Thanks! |
Thanks everyone of the reviews! I'll sunset this thread while cleaning up the repo. We should have a new one soon for the Stage 4 roadmap. |
Tracking issue for spec reviews for advancement to Stage 3.
For this specific review I'd to consider the current spec minus the upcoming changes for the module graph aspect to be resolved.
The text was updated successfully, but these errors were encountered: