Skip to content

Commit 98de5b4

Browse files
authored
[Custom Descriptors][SharedEverything] Handle shared descriptors in AbstractTypeRefining (#8010)
1 parent 7d7dd66 commit 98de5b4

File tree

2 files changed

+57
-1
lines changed

2 files changed

+57
-1
lines changed

src/passes/AbstractTypeRefining.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,8 @@ struct AbstractTypeRefining : public Pass {
406406
auto subDescriptor = *optimized;
407407

408408
Builder builder(*getModule());
409-
if (curr->type.isExact() || subDescriptor == HeapTypes::none) {
409+
if (curr->type.isExact() ||
410+
subDescriptor.isMaybeShared(HeapType::none)) {
410411
// This is exact, so we can ignore subtypes, or there is no subtype to
411412
// optimize to. In this case it must trap.
412413
replaceCurrent(builder.makeSequence(builder.makeDrop(curr->ref),

test/lit/passes/abstract-type-refining-desc.wast

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1189,3 +1189,58 @@
11891189
)
11901190
)
11911191

1192+
;; Shared abstract described types.
1193+
(module
1194+
(rec
1195+
(type $A (sub (shared (descriptor $B (struct)))))
1196+
(type $B (sub (shared (describes $A (descriptor $C (struct))))))
1197+
(type $C (sub (shared (describes $B (struct)))))
1198+
)
1199+
1200+
;; YESTNH: (rec
1201+
;; YESTNH-NEXT: (type $0 (func (param (ref (shared none))) (result (ref (shared none)))))
1202+
1203+
;; YESTNH: (type $1 (func (param (ref (shared none))) (result (ref (shared none)))))
1204+
1205+
;; YESTNH: (func $A (type $0) (param $x (ref (shared none))) (result (ref (shared none)))
1206+
;; YESTNH-NEXT: (drop
1207+
;; YESTNH-NEXT: (local.get $x)
1208+
;; YESTNH-NEXT: )
1209+
;; YESTNH-NEXT: (unreachable)
1210+
;; YESTNH-NEXT: )
1211+
;; NO_TNH: (rec
1212+
;; NO_TNH-NEXT: (type $0 (func (param (ref (shared none))) (result (ref (shared none)))))
1213+
1214+
;; NO_TNH: (type $1 (func (param (ref (shared none))) (result (ref (shared none)))))
1215+
1216+
;; NO_TNH: (func $A (type $0) (param $x (ref (shared none))) (result (ref (shared none)))
1217+
;; NO_TNH-NEXT: (drop
1218+
;; NO_TNH-NEXT: (local.get $x)
1219+
;; NO_TNH-NEXT: )
1220+
;; NO_TNH-NEXT: (unreachable)
1221+
;; NO_TNH-NEXT: )
1222+
(func $A (param $x (ref $A)) (result (ref $B))
1223+
(ref.get_desc $A
1224+
(local.get $x)
1225+
)
1226+
)
1227+
1228+
;; YESTNH: (func $B (type $1) (param $x (ref (shared none))) (result (ref (shared none)))
1229+
;; YESTNH-NEXT: (drop
1230+
;; YESTNH-NEXT: (local.get $x)
1231+
;; YESTNH-NEXT: )
1232+
;; YESTNH-NEXT: (unreachable)
1233+
;; YESTNH-NEXT: )
1234+
;; NO_TNH: (func $B (type $1) (param $x (ref (shared none))) (result (ref (shared none)))
1235+
;; NO_TNH-NEXT: (drop
1236+
;; NO_TNH-NEXT: (local.get $x)
1237+
;; NO_TNH-NEXT: )
1238+
;; NO_TNH-NEXT: (unreachable)
1239+
;; NO_TNH-NEXT: )
1240+
(func $B (param $x (ref $B)) (result (ref $C))
1241+
(ref.get_desc $B
1242+
(local.get $x)
1243+
)
1244+
)
1245+
)
1246+

0 commit comments

Comments
 (0)