Skip to content

Commit

Permalink
Address first review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben L. Titzer authored and littledan committed Oct 9, 2018
1 parent 2622ca2 commit ea78863
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 15 deletions.
7 changes: 4 additions & 3 deletions document/js-api/index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -993,8 +993,9 @@ Note: ECMAScript doesn't specify any sort of behavior on out-of-memory condition
<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.
Modules that exceed these limits are invalid and are rejected with a {{CompileError}}.
While each embedding of WebAssembly may choose to define its own limits, for predictability the standard WebAssembly JavaScript Interface described in this document defines the following exact limits.
An implementation must reject a module that exceeds these limits with a {{CompileError}}.
In practice, an implementation may run out of resources for valid modules below these limits.

<ul>
<li>The maximum size of a module is 1073741824 bytes (1 GiB).</li>
Expand All @@ -1012,7 +1013,7 @@ Modules that exceed these limits are invalid and are rejected with a {{CompileEr
<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>
<li>The maximum number of return values for any function is 1.</li>
<li>The maximum size of a function body, including locals declarations, is 7654321 bytes.</li>
<li>The maximum number of locals declared in a function, including implicitly declared as parameters, is 50000.</li>

Expand Down
2 changes: 1 addition & 1 deletion test/build.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3

import argparse
import sys
Expand Down
16 changes: 5 additions & 11 deletions test/js-api/limits.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ let kJSEmbeddingMaxFunctionLocals = 50000;
let kJSEmbeddingMaxFunctionParams = 1000;
let kJSEmbeddingMaxFunctionReturns = 1;
let kJSEmbeddingMaxTableSize = 10000000;
let kJSEmbeddingMaxTableEntries = 10000000;
let kJSEmbeddingMaxElementSegments = 10000000;
let kJSEmbeddingMaxTables = 1;
let kJSEmbeddingMaxMemories = 1;

Expand Down Expand Up @@ -92,6 +92,9 @@ function promise_test(func, description) {
}
//=======================================================================

// This function runs the {gen} function with the values {min}, {limit}, and
// {limit+1}, assuming that values below and including the limit should
// pass. {name} is used for debugging output.
function testLimit(name, min, limit, gen) {
print(`==== Test ${name} limit = ${limit} ====`);
function run_validate(count) {
Expand Down Expand Up @@ -196,10 +199,6 @@ function testLimit(name, min, limit, gen) {
}
}

// A little doodad to disable a test easily
let DISABLED = {testLimit: () => 0};
let X = DISABLED;

testLimit("types", 1, kJSEmbeddingMaxTypes, (builder, count) => {
for (let i = 0; i < count; i++) {
builder.addType(kSig_i_i);
Expand Down Expand Up @@ -264,11 +263,6 @@ testLimit("maximum imported memory pages", 1, kJSEmbeddingMaxMemoryPages,
builder.addImportedMemory("mod", "mem", 1, count);
});

// TODO(titzer): ugh, that's hard to test.
DISABLED.testLimit("module size", 1, kJSEmbeddingMaxModuleSize,
(builder, count) => {
});

testLimit("function size", 2, kJSEmbeddingMaxFunctionSize, (builder, count) => {
let type = builder.addType(kSig_v_v);
let nops = count-2;
Expand Down Expand Up @@ -311,7 +305,7 @@ testLimit("maximum table size", 1, kJSEmbeddingMaxTableSize, (builder, count) =>
builder.setFunctionTableBounds(1, count);
});

testLimit("table entries", 1, kJSEmbeddingMaxTableEntries, (builder, count) => {
testLimit("element segments", 1, kJSEmbeddingMaxElementSegments, (builder, count) => {
builder.setFunctionTableBounds(1, 1);
let array = [];
for (let i = 0; i < count; i++) {
Expand Down

0 comments on commit ea78863

Please sign in to comment.