Skip to content

Commit deca26f

Browse files
committed
[Custom Descriptors] Optimize descriptors in Unsubtyping
With the upcoming stricter validation rules for descriptor types, we can no longer use the placeholder describee trick in GlobalTypeOptimization, so its ability to optimize out unneeded descriptors will be significantly restricted. Because of the increasing coupling between the validation for subtyping and descriptor relationships, it makes most sense to optimize both at the same time in Unsubtyping. Update Unsubtyping to start the analysis assuming no descriptors are necessary, then add them in as it discovers that they are indeed necessary either to preserve behavior or validitiy. Discovering new required descriptors can imply that new subtypings are necessary and vice versa.
1 parent ed83899 commit deca26f

File tree

4 files changed

+1282
-86
lines changed

4 files changed

+1282
-86
lines changed

src/ir/subtype-exprs.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -311,8 +311,16 @@ struct SubtypingDiscoverer : public OverriddenVisitor<SubType> {
311311
void visitRefCast(RefCast* curr) { self()->noteCast(curr->ref, curr); }
312312
void visitRefGetDesc(RefGetDesc* curr) {}
313313
void visitBrOn(BrOn* curr) {
314-
if (curr->op == BrOnCast || curr->op == BrOnCastFail) {
315-
self()->noteCast(curr->ref, curr->castType);
314+
switch (curr->op) {
315+
case BrOnNull:
316+
case BrOnNonNull:
317+
break;
318+
case BrOnCast:
319+
case BrOnCastFail:
320+
case BrOnCastDesc:
321+
case BrOnCastDescFail:
322+
self()->noteCast(curr->ref, curr->castType);
323+
break;
316324
}
317325
self()->noteSubtype(curr->getSentType(),
318326
self()->findBreakTarget(curr->name));

0 commit comments

Comments
 (0)