Skip to content

Commit 9eaad3d

Browse files
Kraksahuoguobutterunderflow
authored
Init MiniWasmFX (#64)
* check in MiniWasmFX * Basic `(module bin ...)` support (#62) * basic .bin.wast working --------- Co-authored-by: butterunderflow <azhong.934@gmail.com> Co-authored-by: Guannan Wei <wei220@purdue.edu> * refactor value hierarchy * remove duplication * prelim impl of RefFunc and ContNew * callref * refactor to 2cps style * add handler * resumable try-catch * fix for deep handler * mechanize test * add test case * missing file * rename vars in resume, added some comments * comment tests for now --------- Co-authored-by: ahuoguo <52595524+ahuoguo@users.noreply.github.com> Co-authored-by: butterunderflow <azhong.934@gmail.com> Co-authored-by: ahuoguo <ahuoguo@gmail.com>
1 parent 2eb36f0 commit 9eaad3d

24 files changed

+3597
-2643
lines changed

.github/workflows/scala.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,5 @@ jobs:
7676
sbt 'testOnly gensym.TestLibrary'
7777
sbt 'testOnly gensym.wasm.TestEval'
7878
sbt 'testOnly gensym.wasm.TestScriptRun'
79+
sbt 'testOnly gensym.wasm.TestFx'
80+

benchmarks/wasm/trycatch/deep.wat

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
(module
2+
(type (;0;) (func (param i32)))
3+
(type (;1;) (func))
4+
(import "console" "log" (func (;0;) (type 0)))
5+
(func (;1;) (type 1)
6+
(local i32)
7+
try ;; 1 2 3 2 4 4 5
8+
i32.const 1
9+
call 0
10+
i32.const 42
11+
;; [42]
12+
throw
13+
i32.const 3
14+
call 0
15+
i32.const -1
16+
;; [-1]
17+
throw
18+
catch
19+
;; [42, resume]
20+
i32.const 2
21+
call 0
22+
drop
23+
resume0
24+
i32.const 4
25+
call 0
26+
end
27+
i32.const 5
28+
call 0
29+
)
30+
(start 1))
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
(module
2+
(type (;0;) (func (param i32)))
3+
(type (;1;) (func))
4+
(import "console" "log" (func (;0;) (type 0)))
5+
(func (;1;) (type 1)
6+
(local i32)
7+
try
8+
i32.const 1
9+
call 0
10+
i32.const 42
11+
;; [42]
12+
throw
13+
i32.const 3
14+
call 0
15+
catch
16+
;; [42, resume]
17+
i32.const 2
18+
call 0
19+
drop
20+
local.set 0 ;; now we are really abusing the type system ...
21+
local.get 0
22+
resume0
23+
i32.const 4
24+
call 0
25+
local.get 0
26+
resume0
27+
end
28+
i32.const 5
29+
call 0
30+
)
31+
(start 1))
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
(module
2+
(type (;0;) (func (param i32)))
3+
(type (;1;) (func))
4+
(import "console" "log" (func (;0;) (type 0)))
5+
(func (;1;) (type 1)
6+
(local i32)
7+
try
8+
i32.const 1
9+
call 0
10+
try
11+
i32.const 42
12+
;; [42]
13+
throw
14+
i32.const 3
15+
call 0
16+
catch
17+
;; [42, resume]
18+
i32.const 2
19+
call 0
20+
drop ;; [resume]
21+
resume0
22+
i32.const 4
23+
call 0
24+
end
25+
i32.const 5
26+
call 0
27+
i32.const -1
28+
throw
29+
i32.const 7
30+
call 0
31+
catch
32+
;; [-1, resume]
33+
drop
34+
i32.const 6
35+
call 0
36+
resume0
37+
i32.const 8
38+
call 0
39+
end
40+
i32.const 9
41+
call 0
42+
)
43+
(start 1))
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
(module
2+
(type (;0;) (func (param i32)))
3+
(type (;1;) (func))
4+
(import "console" "log" (func (;0;) (type 0)))
5+
(func (;1;) (type 1)
6+
(local i32)
7+
try
8+
i32.const 1
9+
call 0
10+
i32.const 42
11+
;; [42]
12+
throw
13+
i32.const 3
14+
call 0
15+
catch
16+
;; [42, resume]
17+
i32.const 2
18+
call 0
19+
drop
20+
resume0
21+
i32.const 4
22+
call 0
23+
end
24+
i32.const 5
25+
call 0
26+
)
27+
(start 1))
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
(module
2+
(type (;0;) (func (param i32)))
3+
(type (;1;) (func))
4+
(import "console" "log" (func (;0;) (type 0)))
5+
(func (;1;) (type 1)
6+
(local i32)
7+
try
8+
i32.const 1
9+
call 0
10+
block
11+
block
12+
i32.const 42
13+
;; [42]
14+
throw
15+
end
16+
end
17+
i32.const 3
18+
call 0
19+
catch
20+
;; [42, resume]
21+
i32.const 2
22+
call 0
23+
drop
24+
resume0
25+
i32.const 4
26+
call 0
27+
end
28+
i32.const 5
29+
call 0
30+
)
31+
(start 1))
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
(module
2+
(type (;0;) (func (param i32)))
3+
(type (;1;) (func))
4+
(import "console" "log" (func (;0;) (type 0)))
5+
(func (;1;) (type 1)
6+
(local i32)
7+
block (result i32)
8+
try
9+
i32.const 1
10+
call 0
11+
i32.const 42
12+
;; [42]
13+
throw
14+
i32.const 3
15+
call 0
16+
catch
17+
;; [42, resume]
18+
i32.const 2
19+
call 0
20+
;;drop
21+
br 0
22+
resume0
23+
i32.const 4
24+
call 0
25+
end
26+
i32.const 5
27+
call 0
28+
end
29+
i32.const 6
30+
call 0
31+
)
32+
(start 1))
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
(module
2+
(type (;0;) (func (param i32)))
3+
(type (;1;) (func))
4+
(import "console" "log" (func (;0;) (type 0)))
5+
(func (;1;) (type 1)
6+
(local i32)
7+
try
8+
i32.const 1
9+
call 0
10+
block
11+
i32.const 42
12+
;; [42]
13+
throw
14+
br 0
15+
i32.const 3
16+
call 0
17+
end
18+
i32.const 6
19+
call 0
20+
catch
21+
;; [42, resume]
22+
i32.const 2
23+
call 0
24+
drop
25+
resume0
26+
i32.const 4
27+
call 0
28+
end
29+
i32.const 5
30+
call 0
31+
)
32+
(start 1))
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
(module
2+
(type (;0;) (func (param i32)))
3+
(type (;1;) (func))
4+
(import "console" "log" (func (;0;) (type 0)))
5+
(func (;1;) (type 1)
6+
(local i32)
7+
try
8+
i32.const 1
9+
call 0
10+
i32.const 42
11+
;; [42]
12+
throw
13+
i32.const 3
14+
call 0
15+
catch
16+
;; [42, resume]
17+
call 0
18+
drop
19+
i32.const 4
20+
call 0
21+
end
22+
i32.const 5
23+
call 0
24+
)
25+
(start 1))
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
(module
2+
(type (;0;) (func (param i32)))
3+
(type (;1;) (func))
4+
(import "console" "log" (func (;0;) (type 0)))
5+
(func (;1;) (type 1)
6+
(local i32)
7+
try
8+
i32.const 1
9+
call 0
10+
i32.const 3
11+
call 0
12+
catch
13+
;; [42, resume]
14+
i32.const 2
15+
call 0
16+
drop
17+
resume0
18+
i32.const 4
19+
call 0
20+
end
21+
i32.const 5
22+
call 0
23+
)
24+
(start 1))

0 commit comments

Comments
 (0)