File tree Expand file tree Collapse file tree 2 files changed +45
-0
lines changed Expand file tree Collapse file tree 2 files changed +45
-0
lines changed Original file line number Diff line number Diff line change @@ -1107,6 +1107,12 @@ class EffectAnalyzer {
11071107 void visitContBind (ContBind* curr) {
11081108 // traps when curr->cont is null ref.
11091109 parent.implicitTrap = true ;
1110+
1111+ // The input continuation is modified, as it will trap if resumed. This is
1112+ // a globally-noticeable effect, which we model as a call for now, but we
1113+ // could in theory use something more refined here (|modifiesContinuation|
1114+ // perhaps, to parallel |writesMemory| etc.).
1115+ parent.calls = true ;
11101116 }
11111117 void visitSuspend (Suspend* curr) {
11121118 // Similar to resume/call: Suspending means that we execute arbitrary
Original file line number Diff line number Diff line change 99 ;; CHECK: (type $cont (cont $func))
1010 (type $cont (cont $func ))
1111
12+ ;; CHECK: (type $func-i32 (func (param i32)))
13+ (type $func-i32 (func (param i32 )))
14+ ;; CHECK: (type $cont-i32 (cont $func-i32))
15+ (type $cont-i32 (cont $func-i32 ))
16+
17+ ;; CHECK: (type $4 (func (param (ref $cont-i32))))
18+
1219 ;; CHECK: (elem declare func $cont.new)
1320
1421 ;; CHECK: (func $cont.new (type $func)
3643 )
3744 )
3845 )
46+
47+ ;; CHECK: (func $cont.bind (type $4) (param $cont-i32 (ref $cont-i32))
48+ ;; CHECK-NEXT: (drop
49+ ;; CHECK-NEXT: (cont.bind $cont-i32 $cont
50+ ;; CHECK-NEXT: (i32.const 42)
51+ ;; CHECK-NEXT: (local.get $cont-i32)
52+ ;; CHECK-NEXT: )
53+ ;; CHECK-NEXT: )
54+ ;; CHECK-NEXT: (drop
55+ ;; CHECK-NEXT: (cont.bind $cont-i32 $cont
56+ ;; CHECK-NEXT: (i32.const 42)
57+ ;; CHECK-NEXT: (local.get $cont-i32)
58+ ;; CHECK-NEXT: )
59+ ;; CHECK-NEXT: )
60+ ;; CHECK-NEXT: )
61+ (func $cont.bind (param $cont-i32 (ref $cont-i32 ))
62+ ;; We cannot optimize here: Each of these has a side effect of modifying the
63+ ;; continuation they were given, as it will trap if resumed, and in fact the
64+ ;; second cont.bind here should trap, which we should not remove.
65+ (drop
66+ (cont.bind $cont-i32 $cont
67+ (i32.const 42 )
68+ (local.get $cont-i32 )
69+ )
70+ )
71+ (drop
72+ (cont.bind $cont-i32 $cont
73+ (i32.const 42 )
74+ (local.get $cont-i32 )
75+ )
76+ )
77+ )
3978)
4079
You can’t perform that action at this time.
0 commit comments