Skip to content

Commit c3d3c5a

Browse files
committed
test
1 parent 891f616 commit c3d3c5a

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed

test/lit/passes/gsi-desc.wast

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,35 @@
342342
)
343343
)
344344

345+
;; Zero descriptor instances in globals.
346+
(module
347+
(rec
348+
;; CHECK: (rec
349+
;; CHECK-NEXT: (type $A (sub (descriptor $A.desc (struct))))
350+
(type $A (sub (descriptor $A.desc (struct))))
351+
;; CHECK: (type $A.desc (sub (describes $A (struct))))
352+
(type $A.desc (sub (describes $A (struct))))
353+
)
354+
355+
;; CHECK: (type $2 (func (param anyref)))
356+
357+
;; CHECK: (func $test (type $2) (param $any anyref)
358+
;; CHECK-NEXT: (drop
359+
;; CHECK-NEXT: (ref.cast (ref $A)
360+
;; CHECK-NEXT: (local.get $any)
361+
;; CHECK-NEXT: )
362+
;; CHECK-NEXT: )
363+
;; CHECK-NEXT: )
364+
(func $test (param $any anyref)
365+
;; We do not optimize here. TODO: we could make this trap
366+
(drop
367+
(ref.cast (ref $A)
368+
(local.get $any)
369+
)
370+
)
371+
)
372+
)
373+
345374
;; Two descriptor instances in globals.
346375
(module
347376
(rec
@@ -414,3 +443,37 @@
414443
)
415444
)
416445

446+
;; Nullable cast.
447+
(module
448+
(rec
449+
;; CHECK: (rec
450+
;; CHECK-NEXT: (type $A (sub (descriptor $A.desc (struct))))
451+
(type $A (sub (descriptor $A.desc (struct))))
452+
;; CHECK: (type $A.desc (sub (describes $A (struct))))
453+
(type $A.desc (sub (describes $A (struct))))
454+
)
455+
456+
;; CHECK: (type $2 (func (param anyref)))
457+
458+
;; CHECK: (global $A.desc (ref $A.desc) (struct.new_default $A.desc))
459+
(global $A.desc (ref $A.desc) (struct.new $A.desc))
460+
461+
;; CHECK: (func $test (type $2) (param $any anyref)
462+
;; CHECK-NEXT: (drop
463+
;; CHECK-NEXT: (ref.cast_desc (ref null $A)
464+
;; CHECK-NEXT: (local.get $any)
465+
;; CHECK-NEXT: (global.get $A.desc)
466+
;; CHECK-NEXT: )
467+
;; CHECK-NEXT: )
468+
;; CHECK-NEXT: )
469+
(func $test (param $any anyref)
470+
;; The cast is nullable, which we can still optimize: null will succeed as
471+
;; expected.
472+
(drop
473+
(ref.cast (ref null $A)
474+
(local.get $any)
475+
)
476+
)
477+
)
478+
)
479+

0 commit comments

Comments
 (0)