Skip to content

Commit

Permalink
Bug 1467071 - Wasm: import embedding_limits "limits.js" test and fix …
Browse files Browse the repository at this point in the history
…any resulting failures. r=lth.

The WebAssembly Specification, branch [1] (see also, more generally,
comments in [2]), contains a new test, limits.js, to check whether the
generally agreed embedding limits (numbers of functions, imports, etc) are
observed.  This bug is to import the test and fix any resulting breakage
detected with it.

[1] https://github.com/WebAssembly/spec/tree/embedding_limits
[2] WebAssembly/spec#607

* js/src/wasm/WasmBinaryConstants.h:
  - Added MaxTableMaximumLength as a counterpart to MaxTableInitialLength.
  - Split the constant group into two parts: spec-required, and those
    pertaining only to our own implementation.

* js/src/wasm/WasmJS.cpp  WasmTableObject::construct():
  - Update GetLimits call with correct max size bound

* js/src/wasm/WasmValidate.cpp  DecodeTableLimits():
  - Implement missing check for a Table's maximum size.

* js/src/jit-test/tests/wasm/import-export.js:
  js/src/jit-test/tests/wasm/spec/jsapi.js:
  testing/web-platform/mozilla/tests/wasm/js/jsapi.js:
  - Update Table maximum size tests.  All tests trying to make a Table
    with more than 10,000,000 entries now throw instead of succeeding.

* js/src/jit-test/tests/wasm/spec/harness/wasm-module-builder.js:
  - Import minimal updates and bug fixes from [1], needed to make the
    new tests work.

* js/src/jit-test/tests/wasm/spec/limits.js
  - New file.  Derived from [1], with comments added to each test to show
    SM's compliance situation, and with two tests disabled.

UltraBlame original commit: 710e191b76ff7f9d4afb8b6f47a51ed9b003d4d7
  • Loading branch information
marco-c committed Oct 3, 2019
1 parent 9b12dc7 commit 391a847
Showing 8 changed files with 3,351 additions and 66 deletions.
12 changes: 2 additions & 10 deletions js/src/jit-test/tests/wasm/import-export.js
Original file line number Diff line number Diff line change
@@ -489,12 +489,7 @@ initial
0
maximum
:
2
*
*
32
-
1
10000000
element
:
"
@@ -518,10 +513,7 @@ initial
0
maximum
:
2
*
*
32
10000001
element
:
"
166 changes: 142 additions & 24 deletions js/src/jit-test/tests/wasm/spec/harness/wasm-module-builder.js
Original file line number Diff line number Diff line change
@@ -459,7 +459,7 @@ t
know
yet
.
let
const
section
=
new
@@ -492,18 +492,24 @@ the
temporary
buffer
.
for
(
const
b
of
section
)
{
this
.
push
(
.
.
.
section
b
)
;
}
}
}
class
WasmFunctionBuilder
{
@@ -1370,6 +1376,45 @@ appendToTable
array
)
{
for
(
let
n
of
array
)
{
if
(
typeof
n
!
=
'
number
'
)
throw
new
Error
(
'
invalid
table
(
entries
have
to
be
numbers
)
:
'
+
array
)
;
}
return
this
.
@@ -1385,14 +1430,42 @@ array
)
;
}
setFunctionTableBounds
(
min
max
)
{
this
.
function_table_length_min
=
min
;
this
.
function_table_length_max
=
max
;
return
this
;
}
setFunctionTableLength
(
length
)
{
this
.
function_table_length
function_table_length_min
=
length
;
this
.
function_table_length_max
=
length
;
@@ -1992,7 +2065,7 @@ if
(
wasm
.
function_table_length
function_table_length_min
>
0
)
@@ -2041,11 +2114,31 @@ emit_u8
kWasmAnyFunctionTypeForm
)
;
const
max
=
wasm
.
function_table_length_max
;
const
has_max
=
max
!
=
=
undefined
;
section
.
emit_u8
(
1
has_max
?
kResizableMaximumFlag
:
0
)
;
section
@@ -2054,16 +2147,18 @@ emit_u32v
(
wasm
.
function_table_length
function_table_length_min
)
;
if
(
has_max
)
section
.
emit_u32v
(
wasm
.
function_table_length
max
)
;
}
@@ -2082,6 +2177,7 @@ wasm
memory
!
=
=
undefined
)
{
@@ -2122,11 +2218,33 @@ emit_u8
one
memory
entry
const
max
=
wasm
.
memory
.
max
;
const
has_max
=
max
!
=
=
undefined
;
section
.
emit_u32v
(
has_max
?
kResizableMaximumFlag
:
0
)
;
section
@@ -2140,14 +2258,14 @@ memory
min
)
;
if
(
has_max
)
section
.
emit_u32v
(
wasm
.
memory
.
max
)
;
@@ -2783,6 +2901,14 @@ inits
length
)
;
for
(
let
init
of
inits
)
{
section
.
emit_u8
@@ -2794,14 +2920,6 @@ emit_u8
/
table
index
for
(
let
init
of
inits
)
{
if
(
init
10 changes: 6 additions & 4 deletions js/src/jit-test/tests/wasm/spec/jsapi.js
Original file line number Diff line number Diff line change
@@ -5067,8 +5067,12 @@ Table
true
)
;
assert_equals
assertThrows
(
(
)
=
>
new
Table
(
@@ -5094,9 +5098,7 @@ anyfunc
"
}
)
instanceof
Table
true
RangeError
)
;
}
Loading

0 comments on commit 391a847

Please sign in to comment.