-
Notifications
You must be signed in to change notification settings - Fork 454
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
Embedding limits #873
Embedding limits #873
Conversation
test/js-api/limits.js
Outdated
builder.setFunctionTableBounds(1, 1); | ||
let array = []; | ||
for (let i = 0; i < count; i++) { | ||
builder.addFunctionTableInit(0, false, array, false); |
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.
This terminology confused me at first; "FunctionTableInit" here is what the spec calls an "Element Segment". I've opened a PR to rename these: #874
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.
ack
test/js-api/limits.js
Outdated
let kJSEmbeddingMaxFunctionParams = 1000; | ||
let kJSEmbeddingMaxFunctionReturns = 1; | ||
let kJSEmbeddingMaxTableSize = 10000000; | ||
let kJSEmbeddingMaxTableEntries = 10000000; |
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.
This should probably be called kJSEmbeddingMaxElementSegments
based on the test below.
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.
Done
document/js-api/index.bs
Outdated
|
||
The WebAssembly core specification allows an implementation to define limits on the syntactic structure of the module. | ||
The standard WebAssembly JavaScript Interface described in this document hereby defines a set of standard limits on the syntactic module structure as below. | ||
Modules that exceed these limits are invalid and are rejected with a {{CompileError}}. |
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 presume it's implied that lower implementation limits may exist?
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 think the idea here is that there actually shouldn't be lower implementation limits, that these are exact. Should the text be clarified?
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.
Probably, since low-resource devices (like embedded) and computationally-sensitive uses (think: Etherum's eWASM) won't be able to cope with these limits particularly well.
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.
These limits only apply to JavaScript embeddings and are not relevant to others, including blockchain platforms.
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.
@rossberg What about JS embeddings without sufficient RAM? For one concrete example, mobile devices might have performance problems processing large WASM bundles due to a slower clock speed + less RAM available. (The max amount of allocatable memory per this, for example, is 2GB. Low-end smartphones don't usually have this much available - some only have 2GB of RAM.)
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.
PTAL at new text
Cc @Ms2ger if you could review these tests, it would be great. |
document/js-api/index.bs
Outdated
<h2 id="limits">Implementation-defined Limits</h2> | ||
|
||
The WebAssembly core specification allows an implementation to define limits on the syntactic structure of the module. | ||
The standard WebAssembly JavaScript Interface described in this document hereby defines a set of standard limits on the syntactic module structure as below. |
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.
The word "hereby" is not used like this in standards very much; I'd eliminate it (or use formally defined terms like "SHOULD" or "MUST"). But this is editorial and can be done in a follow-on editorial patch.
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.
PTAL
document/js-api/index.bs
Outdated
<li>The initial or maximum number of pages for any memory, declared or imported, is at most 32767.</li> | ||
|
||
<li>The maximum number of parameters to any function is 1000.</li> | ||
<li>The maximum number of return types for any function is 1.</li> |
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.
s/types/values/? Again, an editorial change that we can consider in a follow-on PR.
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.
done
test/build.py
Outdated
@@ -1,4 +1,4 @@ | |||
#!/usr/bin/env python3 | |||
#!/usr/bin/env python |
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.
Not sure if this change was intentional
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.
done
document/js-api/index.bs
Outdated
|
||
The WebAssembly core specification allows an implementation to define limits on the syntactic structure of the module. | ||
The standard WebAssembly JavaScript Interface described in this document hereby defines a set of standard limits on the syntactic module structure as below. | ||
Modules that exceed these limits are invalid and are rejected with a {{CompileError}}. |
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 think the idea here is that there actually shouldn't be lower implementation limits, that these are exact. Should the text be clarified?
if (failures.length > 0) { | ||
throw failures[0]; | ||
} | ||
//======================================================================= |
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.
Does this part need to be removed? (And the similar segment above)
document/js-api/index.bs
Outdated
|
||
The WebAssembly core specification allows an implementation to define limits on the syntactic structure of the module. | ||
The standard WebAssembly JavaScript Interface described in this document hereby defines a set of standard limits on the syntactic module structure as below. | ||
Modules that exceed these limits are invalid and are rejected with a {{CompileError}}. |
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.
This is a "Statement of fact" with no normative prose to back it up.
It's also a "COMEFROM" statement; it's not in the place where you look when for a definition of compiling or validating modules. Perhaps a better place would be in #compile-a-webassembly-module
. We'd need to make sure that HTML calls through that, then.
It's perhaps worth elaborating on why this is in js-api, though, since that seems like a weird layering on first sight.
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.
PTAL
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ |
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.
Please submit the test to wpt directly, under its license(s).
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 don't think we agreed that all tests need to be submitted directly to wpt; they can be added through either side.
let kTestAsyncCompile = true; | ||
|
||
//======================================================================= | ||
// HARNESS SNIPPET, DO NOT COMMIT |
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.
Do not commit.
let kJSEmbeddingMaxMemories = 1; | ||
|
||
function verbose(...args) { | ||
if (false) print(...args); |
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.
Don't use print()
.
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.
Is there a better alternative? I've found it helpful to have console/print output while developing the tests. Any suggestion?
|
||
let kTestValidate = true; | ||
let kTestSyncCompile = true; | ||
let kTestAsyncCompile = true; |
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.
Remove these; split into three files if needed.
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 think I'd prefer not to split this into three files. The flags were useful in developing the test. Is that worth keeping in your opinion?
test/js-api/limits.js
Outdated
} | ||
//======================================================================= | ||
|
||
function testLimit(name, min, limit, gen) { |
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.
Some documentation, please.
document/js-api/index.bs
Outdated
|
||
<li>The maximum number of parameters to any function is 1000.</li> | ||
<li>The maximum number of return types for any function is 1.</li> | ||
<li>The maximum size of a function body, including locals declarations, is 7654321 bytes.</li> |
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.
Is that really the number you want to go with?
}) | ||
.catch(err => { | ||
if (expected) { | ||
let msg = `UNEXPECTED FAIL: ${name} == ${count} (${e})`; |
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.
Same question about putting this in the same function.
test/js-api/limits.js
Outdated
}); | ||
|
||
// TODO(titzer): ugh, that's hard to test. | ||
DISABLED.testLimit("module size", 1, kJSEmbeddingMaxModuleSize, |
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.
File an issue and remove this, please.
let type = builder.addType(kSig_v_v); | ||
let nops = count-2; | ||
let array = new Array(nops); | ||
for (let i = 0; i < nops; i++) array[i] = kExprNop; |
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 think array.fill() is probably well-supported enough, if you want.
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.
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ |
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 don't think we agreed that all tests need to be submitted directly to wpt; they can be added through either side.
This PR has very important spec text material, so I'm landing it; @Ms2ger , could you clean up the tests in a follow-on patch? |
This PR contains additional spec text and tests for embedding limits as discussed in #607.