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
6 changes: 6 additions & 0 deletions .github/workflows/scala.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ jobs:
make
sudo make install
sudo ldconfig
- name: Install wasmfx-tools
run: |
cd third-party/wasmfx-tools
cargo build --release
- name: Generate models
run: sbt 'runMain gensym.GenerateExternal'
- name: Run tests
Expand All @@ -72,3 +76,5 @@ jobs:
sbt 'testOnly gensym.TestLibrary'
sbt 'testOnly gensym.wasm.TestEval'
sbt 'testOnly gensym.wasm.TestScriptRun'
sbt 'testOnly gensym.wasm.TestFx'

3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,6 @@
path = third-party/lms-clean
url = https://github.com/TiarkRompf/lms-clean
ignore = dirty
[submodule "third-party/wasmfx-tools"]
path = third-party/wasmfx-tools
url = [email protected]:wasmfx/wasmfx-tools.git
7 changes: 7 additions & 0 deletions benchmarks/wasm/script/script_basic.bin.wast
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
(module binary
"\00\61\73\6d\01\00\00\00\01\85\80\80\80\00\01\60"
"\00\01\7f\03\82\80\80\80\00\01\00\07\87\80\80\80"
"\00\01\03\6f\6e\65\00\00\0a\8a\80\80\80\00\01\84"
"\80\80\80\00\00\41\01\0b"
)
(assert_return (invoke "one") (i32.const 0x1))
30 changes: 30 additions & 0 deletions benchmarks/wasm/trycatch/deep.wat
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
(module
(type (;0;) (func (param i32)))
(type (;1;) (func))
(import "console" "log" (func (;0;) (type 0)))
(func (;1;) (type 1)
(local i32)
try ;; 1 2 3 2 4 4 5
i32.const 1
call 0
i32.const 42
;; [42]
throw
i32.const 3
call 0
i32.const -1
;; [-1]
throw
catch
;; [42, resume]
i32.const 2
call 0
drop
resume0
i32.const 4
call 0
end
i32.const 5
call 0
)
(start 1))
31 changes: 31 additions & 0 deletions benchmarks/wasm/trycatch/multishot.wat
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
(module
(type (;0;) (func (param i32)))
(type (;1;) (func))
(import "console" "log" (func (;0;) (type 0)))
(func (;1;) (type 1)
(local i32)
try
i32.const 1
call 0
i32.const 42
;; [42]
throw
i32.const 3
call 0
catch
;; [42, resume]
i32.const 2
call 0
drop
local.set 0 ;; now we are really abusing the type system ...
local.get 0
resume0
i32.const 4
call 0
local.get 0
resume0
end
i32.const 5
call 0
)
(start 1))
43 changes: 43 additions & 0 deletions benchmarks/wasm/trycatch/nested_try_catch.wat
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
(module
(type (;0;) (func (param i32)))
(type (;1;) (func))
(import "console" "log" (func (;0;) (type 0)))
(func (;1;) (type 1)
(local i32)
try
i32.const 1
call 0
try
i32.const 42
;; [42]
throw
i32.const 3
call 0
catch
;; [42, resume]
i32.const 2
call 0
drop ;; [resume]
resume0
i32.const 4
call 0
end
i32.const 5
call 0
i32.const -1
throw
i32.const 7
call 0
catch
;; [-1, resume]
drop
i32.const 6
call 0
resume0
i32.const 8
call 0
end
i32.const 9
call 0
)
(start 1))
27 changes: 27 additions & 0 deletions benchmarks/wasm/trycatch/try_catch.wat
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
(module
(type (;0;) (func (param i32)))
(type (;1;) (func))
(import "console" "log" (func (;0;) (type 0)))
(func (;1;) (type 1)
(local i32)
try
i32.const 1
call 0
i32.const 42
;; [42]
throw
i32.const 3
call 0
catch
;; [42, resume]
i32.const 2
call 0
drop
resume0
i32.const 4
call 0
end
i32.const 5
call 0
)
(start 1))
31 changes: 31 additions & 0 deletions benchmarks/wasm/trycatch/try_catch_block.wat
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
(module
(type (;0;) (func (param i32)))
(type (;1;) (func))
(import "console" "log" (func (;0;) (type 0)))
(func (;1;) (type 1)
(local i32)
try
i32.const 1
call 0
block
block
i32.const 42
;; [42]
throw
end
end
i32.const 3
call 0
catch
;; [42, resume]
i32.const 2
call 0
drop
resume0
i32.const 4
call 0
end
i32.const 5
call 0
)
(start 1))
32 changes: 32 additions & 0 deletions benchmarks/wasm/trycatch/try_catch_br.wat
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
(module
(type (;0;) (func (param i32)))
(type (;1;) (func))
(import "console" "log" (func (;0;) (type 0)))
(func (;1;) (type 1)
(local i32)
block (result i32)
try
i32.const 1
call 0
i32.const 42
;; [42]
throw
i32.const 3
call 0
catch
;; [42, resume]
i32.const 2
call 0
;;drop
br 0
resume0
i32.const 4
call 0
end
i32.const 5
call 0
end
i32.const 6
call 0
)
(start 1))
32 changes: 32 additions & 0 deletions benchmarks/wasm/trycatch/try_catch_br2.wat
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
(module
(type (;0;) (func (param i32)))
(type (;1;) (func))
(import "console" "log" (func (;0;) (type 0)))
(func (;1;) (type 1)
(local i32)
try
i32.const 1
call 0
block
i32.const 42
;; [42]
throw
br 0
i32.const 3
call 0
end
i32.const 6
call 0
catch
;; [42, resume]
i32.const 2
call 0
drop
resume0
i32.const 4
call 0
end
i32.const 5
call 0
)
(start 1))
25 changes: 25 additions & 0 deletions benchmarks/wasm/trycatch/try_catch_discard.wat
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
(module
(type (;0;) (func (param i32)))
(type (;1;) (func))
(import "console" "log" (func (;0;) (type 0)))
(func (;1;) (type 1)
(local i32)
try
i32.const 1
call 0
i32.const 42
;; [42]
throw
i32.const 3
call 0
catch
;; [42, resume]
call 0
drop
i32.const 4
call 0
end
i32.const 5
call 0
)
(start 1))
24 changes: 24 additions & 0 deletions benchmarks/wasm/trycatch/try_catch_succ.wat
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
(module
(type (;0;) (func (param i32)))
(type (;1;) (func))
(import "console" "log" (func (;0;) (type 0)))
(func (;1;) (type 1)
(local i32)
try
i32.const 1
call 0
i32.const 3
call 0
catch
;; [42, resume]
i32.const 2
call 0
drop
resume0
i32.const 4
call 0
end
i32.const 5
call 0
)
(start 1))
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@
Shorter tests: https://github.com/titzer/wizard-engine/tree/master/test/regress/ext:stack-switching

Wasm reference interpreter tests: https://github.com/WebAssembly/stack-switching/blob/wasmfx/test/core/stack-switching/cont.wast

Stack Switching proposal examples: https://github.com/WebAssembly/stack-switching/tree/main/proposals/stack-switching/examples


58 changes: 58 additions & 0 deletions benchmarks/wasm/wasmfx/callref-strip.wast
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
(module
(type (;0;) (func (param i32)))
(type (;1;) (func (param i32 i32)))
(type (;2;) (func (param (ref 0) (ref 0))))
(type (;3;) (func))
(import "spectest" "print_i32" (func (;0;) (type 0)))
(export "_start" (func 6))
(start 6)
(elem (;0;) declare func 4)
(elem (;1;) declare func 5)
(func (;1;) (type 0) (param i32)
local.get 0
call 0
)
(func (;2;) (type 1) (param i32 i32)
(local i32)
local.get 0
local.set 2
block ;; label = @1
loop ;; label = @2
local.get 2
local.get 1
i32.gt_u
br_if 1 (;@1;)
local.get 2
call 1
local.get 2
i32.const 1
i32.add
local.set 2
br 0 (;@2;)
end
end
)
(func (;3;) (type 2) (param (ref 0) (ref 0))
i32.const 10
local.get 0
call_ref 0
i32.const 20
local.get 1
call_ref 0
)
(func (;4;) (type 0) (param i32)
local.get 0
i32.const 13
call 2
)
(func (;5;) (type 0) (param i32)
local.get 0
i32.const 23
call 2
)
(func (;6;) (type 3)
ref.func 4
ref.func 5
call 3
)
)
13 changes: 13 additions & 0 deletions benchmarks/wasm/wasmfx/cont_bind3.bin.wast
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
(module binary
"\00\61\73\6d\01\00\00\00\01\91\80\80\80\00\05\60"
"\00\00\5d\00\60\01\7f\00\5d\02\60\01\7f\01\7f\03"
"\83\80\80\80\00\02\02\04\06\86\80\80\80\00\01\7f"
"\01\41\0b\0b\07\88\80\80\80\00\01\04\6d\61\69\6e"
"\00\01\09\85\80\80\80\00\01\03\00\01\00\0a\a1\80"
"\80\80\00\02\86\80\80\80\00\00\20\00\24\00\0b\90"
"\80\80\80\00\00\20\00\d2\00\e0\03\e1\03\01\e3\01"
"\00\23\00\0b"
)
;; (module instance)
(assert_return (invoke "main" (i32.const 0x16)) (i32.const 0x16))
(assert_return (invoke "main" (i32.const 0xffff_fe44)) (i32.const 0xffff_fe44))
Loading
Loading