Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wasmfx #76

Merged
merged 40 commits into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
dbbeff8
implemet multi tag, found bug at suspend16 for forgetting meta-contin…
ahuoguo Nov 28, 2024
f2c64bb
forgor one test
ahuoguo Nov 28, 2024
57e271d
only the control flow structure for failed suspend16 test
ahuoguo Nov 28, 2024
1f9f250
push wast file
ahuoguo Nov 28, 2024
55f95d4
newMk doesn't work also
ahuoguo Nov 28, 2024
a918024
push wast file
ahuoguo Nov 29, 2024
da67bcb
revert nested resume
ahuoguo Nov 29, 2024
f310fcf
some refactor; add test spec
Kraks Dec 1, 2024
7f9b086
revert accidental change
Kraks Dec 1, 2024
928c501
use the right remaining stack
Kraks Dec 1, 2024
5ad02d4
rebase on Dinghong's version
Kraks Dec 1, 2024
885df1c
check point
Kraks Dec 1, 2024
be08771
refactoring
Kraks Dec 2, 2024
f625623
minor refactor
Kraks Dec 2, 2024
6022e7b
handler
Kraks Dec 2, 2024
2671a81
refactor eval, taking only single inst
Kraks Dec 2, 2024
d934f58
try catch
Kraks Dec 3, 2024
b719421
rebase Dinghong's tests
Kraks Dec 3, 2024
a7b7315
some clean up
Kraks Dec 3, 2024
c6a0e06
unify value repr for cont
Kraks Dec 3, 2024
4f65d3e
test case: throw -> resume -> throw -> no resume
butterunderflow Dec 3, 2024
ff5e0d4
initial impl for wasmfx
Kraks Dec 4, 2024
fd8890c
unreachable not trap
ahuoguo Dec 6, 2024
d1e5548
rm redundant case
ahuoguo Dec 6, 2024
b7fd82a
fix call ref
Kraks Dec 6, 2024
e952a41
utilize trail
butterunderflow Dec 11, 2024
2deea4c
wrap continuations in trail with tags
butterunderflow Dec 12, 2024
1842695
drop tail of trail by tagid
butterunderflow Dec 12, 2024
5014a2e
fix fun-state
ahuoguo Dec 13, 2024
1dab0cc
some progress on debugging pipes
ahuoguo Dec 13, 2024
3841afc
Merge pull request #77 from Generative-Program-Analysis/fix-fun-state
ahuoguo Dec 13, 2024
98523fe
fix pipes
ahuoguo Dec 13, 2024
85968f0
even more nested resume
ahuoguo Dec 14, 2024
2e894fb
ignore all tags in newTrail when suspend
butterunderflow Dec 18, 2024
8ee376d
handler needs only a stack & remove try-catch stuff
butterunderflow Dec 23, 2024
55593e7
remove mcont
butterunderflow Jan 15, 2025
b513e03
trail compostion is different with list concat when haltK is there
butterunderflow Jan 15, 2025
0c99725
when start evaluation: store initK in brtable and haltK in trail
butterunderflow Jan 16, 2025
d5293da
comment on initK
ahuoguo Jan 29, 2025
3996c50
Merge pull request #78 from Generative-Program-Analysis/zdh/remove-mk
ahuoguo Jan 29, 2025
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
38 changes: 38 additions & 0 deletions benchmarks/wasm/trycatch/throw_twice.wat
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
;; kept in delimited continuation example
(module
;; output: 1, 2, 6, 2, 3, 4, 4, 5
(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
i32.const 6
call 0
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))
38 changes: 38 additions & 0 deletions benchmarks/wasm/trycatch/throw_twice2.wat
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
;; pushed to meta continuation example
(module
;; output: 1, 2, 6, 2, 3, 4, 5
(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
i32.const 6
call 0
i32.const 42
;; [42]
throw
end
i32.const 3
call 0
catch
;; [42, resume]
i32.const 2
call 0
drop
resume0
i32.const 4 ;; |---> adk
call 0 ;; |
end
i32.const 5
call 0
)
(start 1))
36 changes: 36 additions & 0 deletions benchmarks/wasm/trycatch/try_catch_br3.wat
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
;; ignored example
(module
;; output: 1, 2, 3, 4, 5
;; 4 is printed, because the delimited continuation is kept when breaking out of the block,
;; it's inside the trail1
(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
br 0
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))
52 changes: 52 additions & 0 deletions benchmarks/wasm/trycatch/try_catch_br4.wat
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
;; pushed to meta continuation example
(module
(type (;0;) (func (param i32)))
(type (;1;) (func))
(import "console" "log" (func (;0;) (type 0)))
(func (;1;) (type 1)
(local i32 i32)
i32.const 0
local.set 1
try
i32.const 1
call 0
block
block
i32.const 42
;; [42]
throw
end
i32.const 6
call 0
i32.const 42
;; [42]
throw
end
i32.const 3
call 0
catch
;; increment local 1
i32.const 1
local.get 1
i32.add
local.set 1
;; [42, resume]
i32.const 2
call 0
drop
local.get 1
i32.const 1
i32.eq
if (param i32 (; input cont actually ;))
resume0
else
i32.const 7
call 0
end
i32.const 4
call 0
end
i32.const 5
call 0
)
(start 1))
39 changes: 39 additions & 0 deletions benchmarks/wasm/trycatch/try_catch_catch_br.wat
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
(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]
drop
local.set 0 ;; abusing the type system
local.get 0 ;;
block (param i32) ;;
i32.const 2
call 0
resume0
br 0
end
i32.const 4
call 0
local.get 0
resume0
end
i32.const 5
call 0
)
(start 1))
42 changes: 42 additions & 0 deletions benchmarks/wasm/wasmfx/diff_handler.wast
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
(module
(type (;0;) (func))
(type (;1;) (cont 0))
(type (;2;) (func (param i32)))
(import "spectest" "print_i32" (func (;0;) (type 2)))
(tag (;0;) (type 0))
(tag (;1;) (type 0))
(export "_start" (func 3))
(start 3)
(elem (;0;) declare func 1 2)
(func (;1;) (type 0)
suspend 0
suspend 1
)
(func (;2;) (type 0)
block ;; label = @1
block (result (ref 1)) ;; label = @2
ref.func 1
cont.new 1
resume 1 (on 0 0 (;@2;))
call 0
br 1 (;@1;)
end
i32.const 0
call 0
resume 1
end
)
(func (;3;) (type 0)
block ;; label = @1
block (result (ref 1)) ;; label = @2
ref.func 2
cont.new 1
resume 1 (on 1 0 (;@2;))
br 1 (;@1;)
end
drop
i32.const 1
call 0
end
)
)
4 changes: 2 additions & 2 deletions benchmarks/wasm/wasmfx/diff_resume.wast
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
(local.set $i (i32.const 10))
(block $h
(block $on_yield (result (ref $cont))
(resume $cont
(on $yield $on_yield)
(resume $cont
(on $yield $on_yield)
(local.get $i)
(local.get $k)
)
Expand Down
111 changes: 111 additions & 0 deletions benchmarks/wasm/wasmfx/fun-pipes-strip.wast
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
(module
(type (;0;) (func (result i32)))
(type (;1;) (func (param i32) (result i32)))
(type (;2;) (cont 0))
(type (;3;) (cont 1))
(type (;4;) (func (param i32)))
(type (;5;) (func (param i32 (ref 2) (ref 3))))
(type (;6;) (func (param (ref 3) (ref 2))))
(type (;7;) (func (result i32 (ref 2))))
(type (;8;) (func (param (ref 2) (ref 3))))
(type (;9;) (func))
(import "spectest" "print_i32" (func (;0;) (type 4)))
(tag (;0;) (type 4) (param i32))
(tag (;1;) (type 0) (result i32))
(export "pipe" (func 3))
(export "run" (func 6))
(start 7)
(elem (;0;) declare func 4 5)
(func (;1;) (type 5) (param i32 (ref 2) (ref 3))
block (result (ref 3)) ;; label = @1
local.get 0
local.get 2
resume 3 (on 1 0 (;@1;))
return
end
local.set 2
local.get 2
local.get 1
return_call 2
)
(func (;2;) (type 6) (param (ref 3) (ref 2))
(local i32)
block (type 7) (result i32 (ref 2)) ;; label = @1
local.get 1
resume 2 (on 0 0 (;@1;))
return
end
local.set 1
local.set 2
local.get 2
local.get 1
local.get 0
return_call 1
)
(func (;3;) (type 8) (param (ref 2) (ref 3))
i32.const -1
local.get 0
local.get 1
call 1
)
(func (;4;) (type 1) (param i32) (result i32)
loop ;; label = @1
i32.const -1
call 0
local.get 0
call 0
local.get 0
suspend 0
i32.const 44444
call 0
local.get 0
i32.const 1
i32.add
local.set 0
br 0 (;@1;)
end
unreachable
)
(func (;5;) (type 1) (param i32) (result i32)
(local i32 i32)
i32.const 10
local.set 1
i32.const 0
local.set 2
loop ;; label = @1
local.get 2
suspend 1
i32.const 55555
call 0
i32.add
local.set 2
i32.const -2
call 0
local.get 2
call 0
local.get 1
i32.const 1
i32.sub
local.set 1
local.get 1
i32.const 0
i32.ne
br_if 0 (;@1;)
end
local.get 2
return
)
(func (;6;) (type 4) (param i32)
local.get 0
ref.func 4
cont.new 3
cont.bind 3 2
ref.func 5
cont.new 3
call 3
)
(func (;7;) (type 9)
i32.const 0
call 6
)
)
Loading