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

Roundtrip printer incompatible with reference interpreter #96

Open
dhil opened this issue Jun 7, 2024 · 0 comments
Open

Roundtrip printer incompatible with reference interpreter #96

dhil opened this issue Jun 7, 2024 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@dhil
Copy link
Member

dhil commented Jun 7, 2024

The code produced by the roundtrip pretty printer appears to be incompatible with the reference interpreter. Hence we must have a bug in one of them. The following output is produced by the wasm-tools prettyprinter on the cont.wast program:

(module
    	          (type $f1 (;0;) (func))
    	          (type $k1 (;1;) (cont $f1))
    	          (type (;2;) (func (param (ref $k1))))
    	          (func $f1 (;0;) (type $f1)
    	            suspend $e1
    	          )
    	          (func (;1;) (type $f1)
    	            ref.func $f1
    	            cont.new $k1
    	            resume $k1
    	          )
    	          (func (;2;) (type $f1)
    	            block $h (result (ref $k1))
    	              ref.func $f1
    	              cont.new $k1
    	              resume $k1 (tag $e2 $h)
    	              unreachable
    	            end
    	            drop
    	          )
    	          (func (;3;) (type $f1)
    	            block $h (result (ref $k1))
    	              ref.func $f1
    	              cont.new $k1
    	              resume $k1 (tag $e1 $h)
    	              unreachable
    	            end
    	            drop
    	          )
    	          (func $f2 (;4;) (type $f1)
    	            throw $exn
    	          )
    	          (func (;5;) (type $f1)
    	            block $h (result (ref $k1))
    	              ref.func $f2
    	              cont.new $k1
    	              resume $k1 (tag $e1 $h)
    	              unreachable
    	            end
    	            drop
    	          )
    	          (func (;6;) (type $f1)
    	            block $h (result (ref $k1))
    	              ref.func $f1
    	              cont.new $k1
    	              resume $k1 (tag $e1 $h)
    	              unreachable
    	            end
    	            resume_throw $k1 $exn
    	          )
    	          (func $f3 (;7;) (type $f1)
    	           barrier ;; label = @1
    	             call $f4
    	           end
    	          )
    	          (func $f4 (;8;) (type $f1)
    	            suspend $e1
    	          )
    	          (func (;9;) (type $f1)
    	            block $h (result (ref $k1))
    	              ref.func $f3
    	              cont.new $k1
    	              resume $k1 (tag $e1 $h)
    	              unreachable
    	            end
    	            resume_throw $k1 $exn
    	          )
    	          (func $r0 (;10;) (type $f1))
    	          (func $r1 (;11;) (type $f1)
    	            suspend $e1
    	            suspend $e1
    	          )
    	          (func $nl1 (;12;) (type 2) (param $k (ref $k1))
    	            local.get $k
    	            resume $k1
    	            local.get $k
    	            resume $k1
    	          )
    	          (func $nl2 (;13;) (type 2) (param $k (ref $k1))
    	            block $h (result (ref $k1))
    	              local.get $k
    	              resume $k1 (tag $e1 $h)
    	              unreachable
    	            end
    	            local.get $k
    	            resume $k1
    	            unreachable
    	          )
    	          (func $nl3 (;14;) (type 2) (param $k (ref $k1))
    	            (local $k' (ref null $k1))
    	            block $h1 (result (ref $k1))
    	              local.get $k
    	              resume $k1 (tag $e1 $h1)
    	              unreachable
    	            end
    	            local.set $k'
    	            block $h2 (result (ref $k1))
    	              local.get $k'
    	              resume $k1 (tag $e1 $h2)
    	              unreachable
    	            end
    	            local.get $k'
    	            resume $k1
    	            unreachable
    	          )
    	          (func $nl4 (;15;) (type 2) (param $k (ref $k1))
    	            local.get $k
    	            cont.bind $k1 $k1
    	            drop
    	            local.get $k
    	            resume $k1
    	          )
    	          (func (;16;) (type $f1)
    	            ref.func $r0
    	            cont.new $k1
    	            call $nl1
    	          )
    	          (func (;17;) (type $f1)
    	            ref.func $r1
    	            cont.new $k1
    	            call $nl2
    	          )
    	          (func (;18;) (type $f1)
    	            ref.func $r1
    	            cont.new $k1
    	            call $nl3
    	          )
    	          (func (;19;) (type $f1)
    	            ref.func $r1
    	            cont.new $k1
    	            call $nl4
    	          )
    	          (tag $exn (;0;) (type $f1))
    	          (tag $e1 (;1;) (type $f1))
    	          (tag $e2 (;2;) (type $f1))
    	          (export "unhandled-1" (func $f1))
    	          (export "unhandled-2" (func 1))
    	          (export "unhandled-3" (func 2))
    	          (export "handled" (func 3))
    	          (export "uncaught-1" (func 5))
    	          (export "uncaught-2" (func 6))
    	          (export "barrier" (func 9))
    	          (export "non-linear-1" (func 16))
    	          (export "non-linear-2" (func 17))
    	          (export "non-linear-3" (func 18))
    	          (export "non-linear-4" (func 19))
    	          (elem (;0;) declare func $f2)
    	          (elem (;1;) declare func $f3)
    	          (elem (;2;) declare func $r0 $r1)
    	        )

When feeding this program to the reference interpreter, I seem to get a syntax error whenever there is a resume or resume_throw in tail position.

@dhil dhil added the bug Something isn't working label Jun 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants