-
Notifications
You must be signed in to change notification settings - Fork 1
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
Reviews for Stage 2.7 #26
Comments
to clarify, reviewers are within stage 2, they're just a prerequisite for stage 2.7. |
|
LGTM |
My normative review:
My editorial review:
|
Will do my best to explain further, and happy to discuss more. The This is the required primitive for module expressions since a module expression would allow both The registry effectively consists of a Supporting I can work on more clearly motivating the above if it would help. The module full primitive goal is a crucial one to get right here though, we have to solve all of representation, postMessage and registry identity together, it's no use solving one without the other.
Can you clarify what you mean by this? The latest source phase spec it is based to is the one here - tc39/ecma262#3492, not the version in the spec repo, which is now out of date. Does that help?
Thanks, added in #39.
The benefit of defining this was that Wasm could define it in the same way for WebAssembly module records. I found myself writing this out in HTML explicitly, and it felt unnecessary there. Formally defining the meaning for equality for module sources needs to be done somewhere - either in HTML or ECMA-262. @michaelficarra also brought this one up though, maybe we should just cut it until it's needed to be called directly from ECMA-262 though? |
Oh I see, I completely misunderstood the use case then. I'll give it a second read tomorrow. |
I finished going through the spec -- consider my review as ✔ when 1/2/4 are solved (or explicitly not). |
Added #40 for points 1 & 2 above. For (3), yeah that's what we mean...
In the case where you do |
Thanks for the explanation, the use case makes sense to me. Step 9.b.i of EvaluateImportCall doesn't seem to allow
Ack. That helps and addresses my previous question. With the explanation, editorially LGTM. |
Thanks, added #42. |
Editorial: In EvaluateImportCall 10.a |
Apologies for the delay. Here's my editorial comments:
|
Moved the realm check to come after the options validation.
Updated in #44.
Added a readme section in #44. This uses the same path source phase imports already introduced for Abstract Module Record.
I've added a note to this section to more clearly define it. If we "DCE" this function, we effectively have the
Updated all of these in #44 as well.
In reality, [[ImportMeta]] is always allocated eagerly in all JS engines, and quite frankly this is a pretty bad state of affairs. While the ideal world is one in which implementers fine and implement these optimizations, I don't think that should preclude writing host calls in a way that avoids unnecessary work where possible. As you say the calling time itself could be deemed to be observable by definitions of observability. For these reasons I think we should stick with a clear lazy generation module, especially since most modules in the module system will never have their source phases imported, and we shouldn't risk engines slowing down the module system. |
To follow up on this one -
For WebAssembly modules, it calls a third-party defined concrete method though. |
That said, the Wasm implementation is very simple:
So maybe I'm overstating this one, and it could be an option. I guess I'm unsure about what benefit there is to an earlier initialization? Does it make the spec significantly simpler? |
Considering this further, I think refactoring out |
We don't usually spec unobservable optimisations, so when reading an algorithm which contains extra machinery like this one expects it to have observable consequences. The fact that it actually doesn't is then surprising. |
Thank you for carrying this forward. This is my review.
These are my only qualms with the specification as written and I would like an opportunity to review again and will make myself available tomorrow, on Tuesday. |
I've put together a PR with various wording adjustments to try to clarify these points in https://github.com/tc39/proposal-esm-phase-imports/pull/45/files. For module source objects I used the following:
Please let me know how that sounds. For (2) I thought this might be possible but of course it turns out to be a harder ask unfortunately - in order to specify So if we make the stringishness of We already have some spec text notes that this field is only used for equality and serialization, and no other features. The impliciation being hosts may optimize further. Not explicitly calling the source text a string while having this note should also discourage any "accessor" string use within ECMA-262 while ensuring clear serialization and deserialization definitions between specs. Let's perhaps continue the discussion in the PR. An alternative may be to add this as a Stage 3 exploration. |
Re (1), my expectation is that when defining the host hook that goes from a module source to a module record in the web integration we'd do it in a way that is equivalent to having a per-realm (or per-compartment, in a world where compartments exist) source->module mapping. When we call dynamic import of a module source in a realm that hasn't seen it before, the host hook would give us a new Module Record and add it to its cache/map.
I have not seen the details of the Re (2), I'm not sure about what the normative suggestion is (or is it just editorial?), but equality cannot be based just on the source text. For example, on the web it must also take into account the URL (two modules with the same contents at two different URLs are two different modules). Also note that Source Text Module Records already have a slot containing their source code, just as a parse node and not as a string. In the draft HTML integration I have seen, |
Thank you, this addresses the bulk of my concerns. I believe this ensures that all observable behavior emerging from specification is consistent, even on hosts that do not capture the literal [[SourceText]] and do not make module sources transferrable via mechanisms like I intend to approve advancement to Stage 2.7 contingent on #45. |
Yes, there is no requirement to maintain the source text, and any proxy for
While this is true today, when there exist multiple cohorts, depending on how this is specified, ModuleSourcesEqual may still be necessary if we want to support identity unification for cross-cohort source usage. |
Issue to track Stage 2 reviewers feedback.
Spec: https://tc39.es/proposal-esm-phase-imports/
Reviewers:
Editors:
The text was updated successfully, but these errors were encountered: