-
Notifications
You must be signed in to change notification settings - Fork 694
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
Provide more details in FeatureTest.md #412
Conversation
The [MVP](MVP.md) allows an application to query which post-MVP features are | ||
supported via [`has_feature`](AstSemantics.md#feature-test). This accounts for | ||
the pragmatic reality that features are shipped in different orders at different | ||
times by different engines on the Web. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd drop "on the Web" since this applies equally to non-Web (node, or any other usage of wasm).
Ok, posted update to address most comments. |
Feature tests will be available from | ||
[WebAssembly itself](AstSemantics.md#feature-test), as well as from JavaScript. | ||
Since some WebAssembly features add operators and all WebAssembly code in a | ||
module is validated ahead-of-time, the usual JS feature detection pattern: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"JavaScript" :)
@jfbastien @mtrofin Some of these ideas sound like they could be followups you could propose. The goal here is just to add some more detail and clarification, not to be the last word on polyfilling. Perhaps you could evaluate this PR just on what it has and then file new PRs to further improve? |
lgtm |
|
@JSStats In FF, asm.js code cache entries simply include the buildid in the key (since any new FF binary may change struct layouts baked into the machien code). Assuming |
Provide more details in FeatureTest.md
@lukewagner |
@JSStats I'm talking about the engine-internal code cache. |
@lukewagner I am also 'talking about the engine-internal code cache'. The runtime engine needs to be able to reason about the provenance of the wasm code it is compiling in order to manage this cache. The The upper layers need to be deterministic even if user defined so that the runtime will know that the result of decompression does not change if the compressed source does not change, and that the product of the layer-1 code writing does not change if the inputs (including the The runtime can note the calls made to For example, consider two orthogonal features A and B. The code might only need feature B if feature A is available, so it probes A first and only probes B if true. If A is not available then the key need not depend on B. |
@JSStats The internal cache is keyed on the content, which would be the output of layer 1. |
@lukewagner Your response misses the key points:
We want the runtime to be able to note that the input source (the compressed and pre-transformed code) has not changed, and that the inputs into the various stages in the pipeline have not changed, and then (without re-computing the input into the final stage) be able to reason that the compiled code will not changed and to reuse it. In some ways getting this right is more important than even the binary encoding. Developers can deal with differences in the binary code between implementations using transforms at upper layers, but an inefficient pipeline cache blocks client side decompression and transforms in user defined code. |
@JSStats (1) I realize that, but the engine can choose to have it be. I do not see us adding arbitrary constants, but rather only static, boolean detection of features (it's in the name; this isn't |
(1.1) If features are only defined to be static per-instance then an engine can choose to change them per-instance, and would still want to implement an effective cache. wasm should not be designed to only work efficiently with an engine with per-build static features. (1.2) There is a need for per-instance static constants input into the upper layers. Very significantly the memory size to allow the upper layers to emit code optimized for a static size. Even if you can answer the performance challenges of eliminating bounds checks without a fixed memory size (and no one here has), as mentioned many times in discussions there are applications that can naturally take advantage of a fixed memory size - and they need a negotiated size to work on a range of instances with different amounts of available vm. (2) In order for the outputs of upper layers for be cached, the inputs need to be part of the cache key. The runtime should be able to reason across layers in the data flow and not have to do a cache lookup on each stage and compare the output to the key of the next stage - it's often referred to as 'provenance'. It's news to me that the 'long-term goal is that these upper layers get standardized'. Part of the appeal of supporting user defined upper layers was the flexibility to meet a range of uses. I get the impression that web developers are frustrated by being locked into a fixed stack, and are desperate for lower level access (that can also be used efficiently). You'll be bike-shedding for the next decade over a lost cause spec'ing a stack. Please consider supporting a user defined stack and this might mean some support for managing the data flow (which I think would be a much better investment). |
As requested in spec/#120, this PR adds some more details on how polyfilling and feature testing could work in practice in the MVP.