Skip to content
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions src/ir/subtype-exprs.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

#include "ir/branch-utils.h"
#include "wasm-traversal.h"
#include "wasm-type.h"
#include "wasm.h"

namespace wasm {
Expand Down Expand Up @@ -52,8 +53,9 @@ namespace wasm {
// subtype of anothers, for example,
// a block and its last child.
//
// * noteCast(HeapType, HeapType) - A fixed type is cast to another, for
// example, in a CallIndirect.
// * noteCast(HeapType, Type) - A fixed type is cast to another, for example,
// in a CallIndirect. The destination is a Type
// rather than HeapType because it may be exact.
// * noteCast(Expression, Type) - An expression's type is cast to a fixed type,
// for example, in RefTest.
// * noteCast(Expression, Expression) - An expression's type is cast to
Expand Down Expand Up @@ -165,7 +167,7 @@ struct SubtypingDiscoverer : public OverriddenVisitor<SubType> {
// this is a trivial situation that is not worth optimizing.
self()->noteSubtype(tableType, curr->heapType);
} else if (HeapType::isSubType(curr->heapType, tableType)) {
self()->noteCast(tableType, curr->heapType);
self()->noteCast(tableType, Type(curr->heapType, NonNullable, Inexact));
} else {
// The types are unrelated and the cast will fail. We can keep the types
// unrelated.
Expand Down Expand Up @@ -311,8 +313,16 @@ struct SubtypingDiscoverer : public OverriddenVisitor<SubType> {
void visitRefCast(RefCast* curr) { self()->noteCast(curr->ref, curr); }
void visitRefGetDesc(RefGetDesc* curr) {}
void visitBrOn(BrOn* curr) {
if (curr->op == BrOnCast || curr->op == BrOnCastFail) {
self()->noteCast(curr->ref, curr->castType);
switch (curr->op) {
case BrOnNull:
case BrOnNonNull:
break;
case BrOnCast:
case BrOnCastFail:
case BrOnCastDesc:
case BrOnCastDescFail:
self()->noteCast(curr->ref, curr->castType);
break;
}
self()->noteSubtype(curr->getSentType(),
self()->findBreakTarget(curr->name));
Expand Down
Loading
Loading