Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions .github/workflows/ci-interpreter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,21 @@ jobs:
- name: Checkout repo
uses: actions/checkout@v2
- name: Setup OCaml
uses: ocaml/setup-ocaml@v2
uses: ocaml/setup-ocaml@v3
with:
ocaml-compiler: 4.12.x
- name: Setup OCaml tools
run: opam install --yes ocamlbuild.0.14.0 ocamlfind.1.9.5 js_of_ocaml.4.0.0 js_of_ocaml-ppx.4.0.0
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: 19.x
run: opam install --yes ocamlfind.1.9.5 js_of_ocaml.4.0.0 js_of_ocaml-ppx.4.0.0
- name: Build interpreter
run: cd interpreter && opam exec make
# Neither V8 nor SpiderMonkey can currently handle all 3.0 tests, so we disable checking JS translation for now.
#- name: Setup Node.js
# uses: actions/setup-node@v4
# with:
# node-version: 25-nightly
#- name: Setup SpiderMonkey
# run: curl -O https://archive.mozilla.org/pub/firefox/nightly/latest-mozilla-central/jsshell-linux-x86_64.zip && unzip jsshell-linux-x86_64.zip
- name: Run tests
run: cd interpreter && opam exec make JS=node ci
run: cd interpreter && opam exec make ci # don't test JS translation
# run: cd interpreter && opam exec make JS=node ci # test with V8
# run: cd interpreter && opam exec make JS=../js ci # test with SM
37 changes: 22 additions & 15 deletions interpreter/valid/valid.ml
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,9 @@ let check_vec_binop binop at =
error at "invalid lane index"
| _ -> ()

let check_memop (c : context) (memop : ('t, 's) memop) ty_size get_sz at =
type mem_mode = NonAtomic | Atomic

let check_memop (mode : mem_mode) (c : context) (memop : ('t, 's) memop) ty_size get_sz at =
let _mt = memory c (0l @@ at) in
let size =
match get_sz memop.pack with
Expand All @@ -198,8 +200,13 @@ let check_memop (c : context) (memop : ('t, 's) memop) ty_size get_sz at =
check_pack sz (ty_size memop.ty) at;
packed_size sz
in
require (1 lsl memop.align <= size) at
"alignment must not be larger than natural"
match mode with
| NonAtomic ->
require (1 lsl memop.align <= size) at
"alignment must not be larger than natural";
| Atomic ->
require (1 lsl memop.align = size) at
"atomic alignment must be natural"


(*
Expand Down Expand Up @@ -354,29 +361,29 @@ let rec check_instr (c : context) (e : instr) (s : infer_result_type) : op_type
[] --> []

| Load memop ->
check_memop c memop num_size (Lib.Option.map fst) e.at;
check_memop NonAtomic c memop num_size (Lib.Option.map fst) e.at;
[NumType I32Type] --> [NumType memop.ty]

| Store memop ->
check_memop c memop num_size (fun sz -> sz) e.at;
check_memop NonAtomic c memop num_size (fun sz -> sz) e.at;
[NumType I32Type; NumType memop.ty] --> []

| VecLoad memop ->
check_memop c memop vec_size (Lib.Option.map fst) e.at;
check_memop NonAtomic c memop vec_size (Lib.Option.map fst) e.at;
[NumType I32Type] --> [VecType memop.ty]

| VecStore memop ->
check_memop c memop vec_size (fun _ -> None) e.at;
check_memop NonAtomic c memop vec_size (fun _ -> None) e.at;
[NumType I32Type; VecType memop.ty] --> []

| VecLoadLane (memop, i) ->
check_memop c memop vec_size (fun sz -> Some sz) e.at;
check_memop NonAtomic c memop vec_size (fun sz -> Some sz) e.at;
require (i < vec_size memop.ty / packed_size memop.pack) e.at
"invalid lane index";
[NumType I32Type; VecType memop.ty] --> [VecType memop.ty]

| VecStoreLane (memop, i) ->
check_memop c memop vec_size (fun sz -> Some sz) e.at;
check_memop NonAtomic c memop vec_size (fun sz -> Some sz) e.at;
require (i < vec_size memop.ty / packed_size memop.pack) e.at
"invalid lane index";
[NumType I32Type; VecType memop.ty] --> []
Expand Down Expand Up @@ -514,23 +521,23 @@ let rec check_instr (c : context) (e : instr) (s : infer_result_type) : op_type
"invalid lane index";
[t; NumType t2] --> [t]
| MemoryAtomicWait atomicop ->
check_memop c atomicop num_size (fun sz -> sz) e.at;
check_memop Atomic c atomicop num_size (fun sz -> sz) e.at;
[NumType I32Type; NumType atomicop.ty; NumType I64Type] --> [NumType I32Type]
| MemoryAtomicNotify atomicop ->
check_memop c atomicop num_size (fun sz -> sz) e.at;
check_memop Atomic c atomicop num_size (fun sz -> sz) e.at;
[NumType I32Type; NumType I32Type] --> [NumType I32Type]
| AtomicFence -> [] --> []
| AtomicLoad atomicop ->
check_memop c atomicop num_size (fun sz -> sz) e.at;
check_memop Atomic c atomicop num_size (fun sz -> sz) e.at;
[NumType I32Type] --> [NumType atomicop.ty]
| AtomicStore atomicop ->
check_memop c atomicop num_size (fun sz -> sz) e.at;
check_memop Atomic c atomicop num_size (fun sz -> sz) e.at;
[NumType I32Type; NumType atomicop.ty] --> []
| AtomicRmw (rmwop, atomicop) ->
check_memop c atomicop num_size (fun sz -> sz) e.at;
check_memop Atomic c atomicop num_size (fun sz -> sz) e.at;
[NumType I32Type; NumType atomicop.ty] --> [NumType atomicop.ty]
| AtomicRmwCmpXchg atomicop ->
check_memop c atomicop num_size (fun sz -> sz) e.at;
check_memop Atomic c atomicop num_size (fun sz -> sz) e.at;
[NumType I32Type; NumType atomicop.ty; NumType atomicop.ty] --> [NumType atomicop.ty]

and check_seq (c : context) (s : infer_result_type) (es : instr list)
Expand Down
3 changes: 1 addition & 2 deletions test/core/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,7 @@ def _runTestFile(self, inputPath):


if __name__ == "__main__":
if not os.path.exists(outputDir):
os.makedirs(outputDir)
os.makedirs(outputDir, exist_ok=True)
for fileName in inputFiles:
testName = 'test ' + os.path.basename(fileName)
setattr(RunTests, testName, lambda self, file=fileName: self._runTestFile(file))
Expand Down
Loading