Skip to content
This repository was archived by the owner on Jan 15, 2025. It is now read-only.

Commit 1795669

Browse files
committed
Merge remote-tracking branch 'spec/wasm-3.0'
2 parents 86e22aa + 1e10102 commit 1795669

File tree

8 files changed

+50
-17
lines changed

8 files changed

+50
-17
lines changed

.github/workflows/ci-interpreter.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ name: CI for interpreter & tests
22

33
on:
44
push:
5-
branches: [ main ]
5+
branches: [ main, wasm-3.0 ]
66
paths: [ .github/**, interpreter/**, test/** ]
77

88
pull_request:
9-
branches: [ main ]
9+
branches: [ main, wasm-3.0 ]
1010
paths: [ .github/**, interpreter/**, test/** ]
1111

1212
# Allows you to run this workflow manually from the Actions tab

.github/workflows/ci-spec.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ name: CI for specs
22

33
on:
44
push:
5-
branches: [ main ]
5+
branches: [ main, wasm-3.0 ]
66
paths: [ .github/**, document/** ]
77

88
pull_request:
9-
branches: [ main ]
9+
branches: [ main, wasm-3.0 ]
1010
paths: [ .github/**, document/** ]
1111

1212
# Allows you to run this workflow manually from the Actions tab

document/core/appendix/embedding.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ Modules
164164
.. index:: instantiation, module instance
165165
.. _embed-module-instantiate:
166166

167-
:math:`\F{module\_instantiate}(\store, \module, \externval^\ast) : (\store, \moduleinst ~|~ \error)`
167+
:math:`\F{module\_instantiate}(\store, \module, \externval^\ast) : (\store, \moduleinst ~|~ \exception ~|~ \error)`
168168
....................................................................................................
169169

170170
1. Try :ref:`instantiating <exec-instantiation>` :math:`\module` in :math:`\store` with :ref:`external values <syntax-externval>` :math:`\externval^\ast` as imports:

document/core/exec/instructions.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -2142,7 +2142,7 @@ where :math:`\Large\times \{x^\ast\}^N` transforms a sequence of :math:`N` sets
21422142
.. math::
21432143
\begin{array}{lcl@{\qquad}l}
21442144
(\V128\K{.}\VCONST~c)~t\K{x}N\K{.}\BITMASK &\stepto& (\I32\K{.}\CONST~i)
2145-
& (\iff i = \ibits_{32}^{-1}(\ilts_{|t|}(\lanes_{t\K{x}N}(c), 0^N)))
2145+
& (\iff i = \ibits_{32}^{-1}(\ilts_{|t|}(\lanes_{t\K{x}N}(c), (0)^N) (0)^{32-N}))
21462146
\\
21472147
\end{array}
21482148

document/core/exec/numerics.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -2271,7 +2271,7 @@ where:
22712271
\begin{array}{@{}lcll}
22722272
\irelaxedswizzlelane(i^n, j) &=& i[j] & (\iff j < 16) \\
22732273
\irelaxedswizzlelane(i^n, j) &=& 0 & (\iff \signed_8(j) < 0) \\
2274-
\irelaxedswizzlelane(i^n, j) &=& \relaxed(R_{\F{swizzle}})[ 0, i[j \mod n] ] & (\otherwise) \\
2274+
\irelaxedswizzlelane(i^n, j) &=& \relaxed(R_{\F{swizzle}})[ 0, i^n[j \mod n] ] & (\otherwise) \\
22752275
\end{array}
22762276
22772277
.. note::

document/core/exec/runtime.rst

+2-1
Original file line numberDiff line numberDiff line change
@@ -897,7 +897,8 @@ Finally, the following definition of *evaluation context* and associated structu
897897
\production{evaluation contexts} & E &::=&
898898
[\_] ~|~
899899
\val^\ast~E~\instr^\ast ~|~
900-
\LABEL_n\{\instr^\ast\}~E~\END \\
900+
\LABEL_n\{\instr^\ast\}~E~\END ~|~
901+
\HANDLER_n\{\catch^\ast\}~E~\END \\
901902
\end{array}
902903
903904
.. math::

interpreter/script/js.ml

+40-8
Original file line numberDiff line numberDiff line change
@@ -312,8 +312,15 @@ let value v =
312312
| Num n -> [Const (n @@ v.at) @@ v.at]
313313
| Vec s -> [VecConst (s @@ v.at) @@ v.at]
314314
| Ref (NullRef ht) -> [RefNull (Match.bot_of_heap_type [] ht) @@ v.at]
315+
| Ref (HostRef n) ->
316+
[ Const (I32 n @@ v.at) @@ v.at;
317+
Call (hostref_idx @@ v.at) @@ v.at;
318+
]
315319
| Ref (Extern.ExternRef (HostRef n)) ->
316-
[Const (I32 n @@ v.at) @@ v.at; Call (hostref_idx @@ v.at) @@ v.at]
320+
[ Const (I32 n @@ v.at) @@ v.at;
321+
Call (hostref_idx @@ v.at) @@ v.at;
322+
ExternConvert Externalize @@ v.at;
323+
]
317324
| Ref _ -> assert false
318325

319326
let invoke ft vs at =
@@ -360,8 +367,14 @@ let rec type_of_result res =
360367
) (List.hd ts) ts
361368

362369
let assert_return ress ts at =
370+
let locals = ref [] in
363371
let rec test (res, t) =
364-
if not (Match.match_val_type [] t (type_of_result res)) then
372+
if
373+
not (
374+
Match.match_val_type [] t (type_of_result res) ||
375+
Match.match_val_type [] (type_of_result res) t
376+
)
377+
then
365378
[ Br (0l @@ at) @@ at ]
366379
else
367380
match res.it with
@@ -437,7 +450,14 @@ let assert_return ress ts at =
437450
| RefResult (RefPat {it = HostRef n; _}) ->
438451
[ Const (Value.I32 n @@ at) @@ at;
439452
Call (hostref_idx @@ at) @@ at;
440-
Call (eq_ref_idx @@ at) @@ at;
453+
Call (eq_ref_idx @@ at) @@ at;
454+
Test (Value.I32 I32Op.Eqz) @@ at;
455+
BrIf (0l @@ at) @@ at ]
456+
| RefResult (RefPat {it = Extern.ExternRef (HostRef n); _}) ->
457+
[ Const (Value.I32 n @@ at) @@ at;
458+
Call (hostref_idx @@ at) @@ at;
459+
ExternConvert Externalize @@ at;
460+
Call (eq_ref_idx @@ at) @@ at;
441461
Test (Value.I32 I32Op.Eqz) @@ at;
442462
BrIf (0l @@ at) @@ at ]
443463
| RefResult (RefPat _) ->
@@ -453,17 +473,21 @@ let assert_return ress ts at =
453473
Test (I32 I32Op.Eqz) @@ at;
454474
BrIf (0l @@ at) @@ at ]
455475
| EitherResult ress ->
456-
[ Block (ValBlockType None,
476+
let idx = Lib.List32.length !locals in
477+
locals := !locals @ [{ltype = t} @@ res.at];
478+
[ LocalSet (idx @@ res.at) @@ res.at;
479+
Block (ValBlockType None,
457480
List.map (fun resI ->
458481
Block (ValBlockType None,
482+
[LocalGet (idx @@ resI.at) @@ resI.at] @
459483
test (resI, t) @
460484
[Br (1l @@ resI.at) @@ resI.at]
461485
) @@ resI.at
462486
) ress @
463487
[Br (1l @@ at) @@ at]
464488
) @@ at
465489
]
466-
in [], List.flatten (List.rev_map test (List.combine ress ts))
490+
in !locals, List.flatten (List.rev_map test (List.combine ress ts))
467491

468492
let i32 = NumT I32T
469493
let anyref = RefT (Null, AnyHT)
@@ -502,12 +526,20 @@ let wrap item_name wrap_action wrap_assertion at =
502526
in
503527
let funcs = [{ftype = 0l @@ at; locals; body} @@ at] in
504528
let m = {empty_module with types; funcs; imports; exports} @@ at in
529+
(try
530+
Valid.check_module m; (* sanity check *)
531+
with Valid.Invalid _ as exn ->
532+
prerr_endline (string_of_region at ^
533+
": internal error in JS converter, invalid wrapper module generated:");
534+
Sexpr.output stderr 80 (Arrange.module_ m);
535+
raise exn
536+
);
505537
Encode.encode m
506538

507539

508540
let is_js_num_type = function
509-
| I32T -> true
510-
| I64T | F32T | F64T -> false
541+
| I32T | I64T -> true
542+
| F32T | F64T -> false
511543

512544
let is_js_vec_type = function
513545
| _ -> false
@@ -567,7 +599,7 @@ let of_num n =
567599
let open Value in
568600
match n with
569601
| I32 i -> I32.to_string_s i
570-
| I64 i -> "int64(\"" ^ I64.to_string_s i ^ "\")"
602+
| I64 i -> I64.to_string_s i ^ "n"
571603
| F32 z -> of_float (F32.to_float z)
572604
| F64 z -> of_float (F64.to_float z)
573605

test/js-api/wasm-module-builder.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -966,7 +966,7 @@ class WasmModuleBuilder {
966966
}
967967
let type_index = (typeof type) == "number" ? type : this.addType(type);
968968
this.imports.push({module: module, name: name, kind: kExternalFunction,
969-
type: type_index});
969+
type_index: type_index});
970970
return this.num_imported_funcs++;
971971
}
972972

0 commit comments

Comments
 (0)