Skip to content

Commit 1b69018

Browse files
Kraksahuoguobutterunderflow
authored
TFP (#75)
* implemet multi tag, found bug at suspend16 for forgetting meta-continuation * forgor one test * only the control flow structure for failed suspend16 test * push wast file * newMk doesn't work also * push wast file * revert nested resume * some refactor; add test spec * revert accidental change * use the right remaining stack * rebase on Dinghong's version * check point * refactoring * minor refactor * handler * refactor eval, taking only single inst * try catch * rebase Dinghong's tests * some clean up * unify value repr for cont * test case: throw -> resume -> throw -> no resume * initial impl for wasmfx * unreachable not trap * rm redundant case * fix call ref * create tfp only, delete trail, simplify handlers * simplify contV, comment on handler * this brnach only runs tfp, not fx * reflect fix of return_call in #76 * drafting sem for fused eval * rm comment * support for loop Co-authored-by: Jiaaaaatai <151090562+Jiaaaaatai@users.noreply.github.com * first try with return_call.wast * look at return_call.wast failure * even odd had the same problem, ignore ASSERT_INVALID * forgor * rm wasmfx conflictst * both FX and TFP in CI --------- Co-authored-by: ahuoguo <ahuoguo@gmail.com> Co-authored-by: butterunderflow <azhong.934@gmail.com> Co-authored-by: Alex Bai <52595524+ahuoguo@users.noreply.github.com>
1 parent 7aebeb5 commit 1b69018

21 files changed

+4282
-3070
lines changed

.github/workflows/scala.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,5 +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-
79+
sbt 'testOnly gensym.wasm.TestTFP'
80+
sbt 'testOnly gensym.wasm.TestFX'

benchmarks/wasm/count.wat

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) (result i32)))
3+
(type (;1;) (func))
4+
(func (;0;) (type 0) (param i32) (result i32)
5+
local.get 0
6+
i32.eqz
7+
if (result i32) ;; label = @1
8+
local.get 0
9+
else
10+
local.get 0
11+
i32.const 1
12+
i32.sub
13+
return_call 0
14+
end
15+
)
16+
(func (;1;) (type 1)
17+
;; TODO: now setting it to 100K will result in stack overflow
18+
i32.const 10000 ;; it will not terminate when it's 1mil
19+
;; TODO: this doesn't seem like an error in our semantics
20+
;; but something about sbt. But why?
21+
call 0
22+
)
23+
(start 1)
24+
)

benchmarks/wasm/for_loop.wat

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
(module
2+
(func $for_loop (result i32)
3+
(local i32)
4+
(local i32)
5+
6+
for
7+
(
8+
;; init
9+
i32.const 0
10+
local.set 0
11+
i32.const 0
12+
local.set 1
13+
|
14+
;; cond
15+
local.get 1
16+
i32.const 10
17+
i32.gt_s
18+
i32.eqz
19+
|
20+
;; post
21+
local.get 1
22+
i32.const 1
23+
i32.add
24+
local.set 1
25+
)
26+
27+
;; es
28+
local.get 0
29+
local.get 1
30+
i32.add
31+
local.set 0
32+
33+
local.get 0
34+
35+
36+
)
37+
38+
(export "for_loop" (func 0))
39+
40+
)

benchmarks/wasm/return_call.wat

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
(module
2+
(type (;0;) (func (param i64) (result i32)))
3+
(type (;1;) (func))
4+
(func (;0;) (type 0) (param i64) (result i32)
5+
local.get 0
6+
i64.eqz
7+
if (result i32) ;; label = @1
8+
i32.const 44
9+
else
10+
local.get 0
11+
i64.const 1
12+
i64.sub
13+
return_call 1
14+
end
15+
)
16+
(func (;1;) (type 0) (param i64) (result i32)
17+
local.get 0
18+
i64.eqz
19+
if (result i32) ;; label = @1
20+
i32.const 99
21+
else
22+
local.get 0
23+
i64.const 1
24+
i64.sub
25+
return_call 0
26+
end
27+
)
28+
(func (;2;) (type 1)
29+
i64.const 100000
30+
call 0
31+
)
32+
(start 2)
33+
)
Lines changed: 194 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,194 @@
1+
(module definition binary
2+
"\00\61\73\6d\01\00\00\00\01\c8\80\80\80\00\0e\60"
3+
"\00\01\7f\60\00\01\7e\60\00\01\7d\60\00\01\7c\60"
4+
"\01\7f\01\7f\60\01\7e\01\7e\60\01\7d\01\7d\60\01"
5+
"\7c\01\7c\60\02\7d\7f\01\7f\60\02\7f\7e\01\7e\60"
6+
"\02\7c\7d\01\7d\60\02\7e\7c\01\7c\60\02\7e\7e\01"
7+
"\7e\60\01\7e\01\7f\03\9d\80\80\80\00\1c\00\01\02"
8+
"\03\04\05\06\07\08\09\0a\0b\00\01\02\03\00\01\02"
9+
"\03\00\01\02\03\0c\05\0d\0d\07\d8\81\80\80\00\10"
10+
"\08\74\79\70\65\2d\69\33\32\00\0c\08\74\79\70\65"
11+
"\2d\69\36\34\00\0d\08\74\79\70\65\2d\66\33\32\00"
12+
"\0e\08\74\79\70\65\2d\66\36\34\00\0f\0e\74\79\70"
13+
"\65\2d\66\69\72\73\74\2d\69\33\32\00\10\0e\74\79"
14+
"\70\65\2d\66\69\72\73\74\2d\69\36\34\00\11\0e\74"
15+
"\79\70\65\2d\66\69\72\73\74\2d\66\33\32\00\12\0e"
16+
"\74\79\70\65\2d\66\69\72\73\74\2d\66\36\34\00\13"
17+
"\0f\74\79\70\65\2d\73\65\63\6f\6e\64\2d\69\33\32"
18+
"\00\14\0f\74\79\70\65\2d\73\65\63\6f\6e\64\2d\69"
19+
"\36\34\00\15\0f\74\79\70\65\2d\73\65\63\6f\6e\64"
20+
"\2d\66\33\32\00\16\0f\74\79\70\65\2d\73\65\63\6f"
21+
"\6e\64\2d\66\36\34\00\17\07\66\61\63\2d\61\63\63"
22+
"\00\18\05\63\6f\75\6e\74\00\19\04\65\76\65\6e\00"
23+
"\1a\03\6f\64\64\00\1b\0a\80\83\80\80\00\1c\85\80"
24+
"\80\80\00\00\41\b2\02\0b\85\80\80\80\00\00\42\e4"
25+
"\02\0b\87\80\80\80\00\00\43\00\20\73\45\0b\8b\80"
26+
"\80\80\00\00\44\00\00\00\00\00\c8\ae\40\0b\84\80"
27+
"\80\80\00\00\20\00\0b\84\80\80\80\00\00\20\00\0b"
28+
"\84\80\80\80\00\00\20\00\0b\84\80\80\80\00\00\20"
29+
"\00\0b\84\80\80\80\00\00\20\01\0b\84\80\80\80\00"
30+
"\00\20\01\0b\84\80\80\80\00\00\20\01\0b\84\80\80"
31+
"\80\00\00\20\01\0b\84\80\80\80\00\00\12\00\0b\84"
32+
"\80\80\80\00\00\12\01\0b\84\80\80\80\00\00\12\02"
33+
"\0b\84\80\80\80\00\00\12\03\0b\86\80\80\80\00\00"
34+
"\41\20\12\04\0b\87\80\80\80\00\00\42\c0\00\12\05"
35+
"\0b\89\80\80\80\00\00\43\c3\f5\a8\3f\12\06\0b\8d"
36+
"\80\80\80\00\00\44\3d\0a\d7\a3\70\3d\fa\3f\12\07"
37+
"\0b\8b\80\80\80\00\00\43\66\66\00\42\41\20\12\08"
38+
"\0b\89\80\80\80\00\00\41\20\42\c0\00\12\09\0b\92"
39+
"\80\80\80\00\00\44\00\00\00\00\00\00\50\40\43\00"
40+
"\00\00\42\12\0a\0b\90\80\80\80\00\00\42\c0\00\44"
41+
"\66\66\66\66\66\06\50\40\12\0b\0b\97\80\80\80\00"
42+
"\00\20\00\50\04\7e\20\01\05\20\00\42\01\7d\20\00"
43+
"\20\01\7e\12\18\0b\0b\92\80\80\80\00\00\20\00\50"
44+
"\04\7e\20\00\05\20\00\42\01\7d\12\19\0b\0b\92\80"
45+
"\80\80\00\00\20\00\50\04\7f\41\2c\05\20\00\42\01"
46+
"\7d\12\1b\0b\0b\93\80\80\80\00\00\20\00\50\04\7f"
47+
"\41\e3\00\05\20\00\42\01\7d\12\1a\0b\0b"
48+
)
49+
(module instance)
50+
(assert_return (invoke "type-i32") (i32.const 0x132))
51+
(assert_return (invoke "type-i64") (i64.const 0x164))
52+
;; (assert_return (invoke "type-f32") (f32.const 0x1.e64p+11))
53+
;; (assert_return (invoke "type-f64") (f64.const 0x1.ec8p+11))
54+
(assert_return (invoke "type-first-i32") (i32.const 0x20))
55+
(assert_return (invoke "type-first-i64") (i64.const 0x40))
56+
;; (assert_return (invoke "type-first-f32") (f32.const 0x1.51eb_86p+0))
57+
;; (assert_return (invoke "type-first-f64") (f64.const 0x1.a3d7_0a3d_70a3_dp+0))
58+
(assert_return (invoke "type-second-i32") (i32.const 0x20))
59+
(assert_return (invoke "type-second-i64") (i64.const 0x40))
60+
(assert_return (invoke "type-second-f32") (f32.const 0x1p+5))
61+
;; (assert_return (invoke "type-second-f64") (f64.const 0x1.0066_6666_6666_6p+6))
62+
(assert_return
63+
(invoke "fac-acc" (i64.const 0x0) (i64.const 0x1))
64+
(i64.const 0x1)
65+
)
66+
(assert_return
67+
(invoke "fac-acc" (i64.const 0x1) (i64.const 0x1))
68+
(i64.const 0x1)
69+
)
70+
(assert_return
71+
(invoke "fac-acc" (i64.const 0x5) (i64.const 0x1))
72+
(i64.const 0x78)
73+
)
74+
(assert_return (invoke "count" (i64.const 0x0)) (i64.const 0x0))
75+
(assert_return (invoke "count" (i64.const 0x3e8)) (i64.const 0x0))
76+
;; See `count.wat` for why this is commented out
77+
;; (assert_return (invoke "count" (i64.const 0xf_4240)) (i64.const 0x0))
78+
(assert_return (invoke "even" (i64.const 0x0)) (i32.const 0x2c))
79+
(assert_return (invoke "even" (i64.const 0x1)) (i32.const 0x63))
80+
(assert_return (invoke "even" (i64.const 0x64)) (i32.const 0x2c))
81+
(assert_return (invoke "even" (i64.const 0x4d)) (i32.const 0x63))
82+
;; See `return_call.wat` for why these are commented out
83+
;; (assert_return (invoke "even" (i64.const 0xf_4240)) (i32.const 0x2c))
84+
;; (assert_return (invoke "even" (i64.const 0xf_4241)) (i32.const 0x63))
85+
(assert_return (invoke "odd" (i64.const 0x0)) (i32.const 0x63))
86+
(assert_return (invoke "odd" (i64.const 0x1)) (i32.const 0x2c))
87+
(assert_return (invoke "odd" (i64.const 0xc8)) (i32.const 0x63))
88+
(assert_return (invoke "odd" (i64.const 0x4d)) (i32.const 0x2c))
89+
;; (assert_return (invoke "odd" (i64.const 0xf_4240)) (i32.const 0x63))
90+
;; (assert_return (invoke "odd" (i64.const 0xf_423f)) (i32.const 0x2c))
91+
(assert_invalid
92+
(module binary
93+
"\00\61\73\6d\01\00\00\00\01\88\80\80\80\00\02\60"
94+
"\00\01\7f\60\00\00\03\83\80\80\80\00\02\00\01\0a"
95+
"\93\80\80\80\00\02\86\80\80\80\00\00\12\01\41\00"
96+
"\0b\82\80\80\80\00\00\0b"
97+
)
98+
"type mismatch"
99+
)
100+
(assert_invalid
101+
(module binary
102+
"\00\61\73\6d\01\00\00\00\01\89\80\80\80\00\02\60"
103+
"\00\01\7f\60\00\01\7e\03\83\80\80\80\00\02\00\01"
104+
"\0a\95\80\80\80\00\02\86\80\80\80\00\00\12\01\41"
105+
"\00\0b\84\80\80\80\00\00\42\01\0b"
106+
)
107+
"type mismatch"
108+
)
109+
(assert_invalid
110+
(module binary
111+
"\00\61\73\6d\01\00\00\00\01\88\80\80\80\00\02\60"
112+
"\00\00\60\01\7f\00\03\83\80\80\80\00\02\00\01\0a"
113+
"\91\80\80\80\00\02\84\80\80\80\00\00\12\01\0b\82"
114+
"\80\80\80\00\00\0b"
115+
)
116+
"type mismatch"
117+
)
118+
(assert_invalid
119+
(module binary
120+
"\00\61\73\6d\01\00\00\00\01\89\80\80\80\00\02\60"
121+
"\00\00\60\02\7c\7f\00\03\83\80\80\80\00\02\00\01"
122+
"\0a\91\80\80\80\00\02\84\80\80\80\00\00\12\01\0b"
123+
"\82\80\80\80\00\00\0b"
124+
)
125+
"type mismatch"
126+
)
127+
(module definition binary
128+
"\00\61\73\6d\01\00\00\00\01\84\80\80\80\00\01\60"
129+
"\00\00\03\83\80\80\80\00\02\00\00\0a\93\80\80\80"
130+
"\00\02\86\80\80\80\00\00\41\01\12\01\0b\82\80\80"
131+
"\80\00\00\0b"
132+
)
133+
(module instance)
134+
(module definition binary
135+
"\00\61\73\6d\01\00\00\00\01\84\80\80\80\00\01\60"
136+
"\00\00\03\83\80\80\80\00\02\00\00\0a\9c\80\80\80"
137+
"\00\02\8f\80\80\80\00\00\44\00\00\00\00\00\00\00"
138+
"\40\41\01\12\01\0b\82\80\80\80\00\00\0b"
139+
)
140+
(module instance)
141+
(assert_invalid
142+
(module binary
143+
"\00\61\73\6d\01\00\00\00\01\89\80\80\80\00\02\60"
144+
"\00\00\60\02\7f\7f\00\03\83\80\80\80\00\02\00\01"
145+
"\0a\94\80\80\80\00\02\87\80\80\80\00\00\01\41\01"
146+
"\12\01\0b\82\80\80\80\00\00\0b"
147+
)
148+
"type mismatch"
149+
)
150+
(assert_invalid
151+
(module binary
152+
"\00\61\73\6d\01\00\00\00\01\89\80\80\80\00\02\60"
153+
"\00\00\60\02\7f\7f\00\03\83\80\80\80\00\02\00\01"
154+
"\0a\94\80\80\80\00\02\87\80\80\80\00\00\41\01\01"
155+
"\12\01\0b\82\80\80\80\00\00\0b"
156+
)
157+
"type mismatch"
158+
)
159+
(assert_invalid
160+
(module binary
161+
"\00\61\73\6d\01\00\00\00\01\89\80\80\80\00\02\60"
162+
"\00\00\60\02\7f\7c\00\03\83\80\80\80\00\02\00\01"
163+
"\0a\9c\80\80\80\00\02\8f\80\80\80\00\00\44\00\00"
164+
"\00\00\00\00\f0\3f\41\01\12\01\0b\82\80\80\80\00"
165+
"\00\0b"
166+
)
167+
"type mismatch"
168+
)
169+
(assert_invalid
170+
(module binary
171+
"\00\61\73\6d\01\00\00\00\01\89\80\80\80\00\02\60"
172+
"\00\00\60\02\7c\7f\00\03\83\80\80\80\00\02\00\01"
173+
"\0a\9c\80\80\80\00\02\8f\80\80\80\00\00\41\01\44"
174+
"\00\00\00\00\00\00\f0\3f\12\01\0b\82\80\80\80\00"
175+
"\00\0b"
176+
)
177+
"type mismatch"
178+
)
179+
(assert_invalid
180+
(module binary
181+
"\00\61\73\6d\01\00\00\00\01\84\80\80\80\00\01\60"
182+
"\00\00\03\82\80\80\80\00\01\00\0a\8a\80\80\80\00"
183+
"\01\84\80\80\80\00\00\12\01\0b"
184+
)
185+
"unknown function"
186+
)
187+
(assert_invalid
188+
(module binary
189+
"\00\61\73\6d\01\00\00\00\01\84\80\80\80\00\01\60"
190+
"\00\00\03\82\80\80\80\00\01\00\0a\8e\80\80\80\00"
191+
"\01\88\80\80\80\00\00\12\94\98\db\e2\03\0b"
192+
)
193+
"unknown function"
194+
)

0 commit comments

Comments
 (0)