Skip to content

Commit d6b3187

Browse files
committed
propagate ref nonnull state
1 parent a9e874a commit d6b3187

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/flow.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ import {
7070
getUnaryValue,
7171
getCallOperandAt,
7272
getCallOperandCount,
73+
getRefIsNullValue,
7374
isConstZero,
7475
isConstNonZero
7576
} from "./module";
@@ -1049,6 +1050,10 @@ export class Flow {
10491050
}
10501051
break;
10511052
}
1053+
case ExpressionId.RefIsNull: {
1054+
this.inheritNonnullIfFalse(getRefIsNullValue(expr), iff); // value == null -> value must have been null
1055+
break;
1056+
}
10521057
}
10531058
}
10541059

@@ -1140,6 +1145,10 @@ export class Flow {
11401145
}
11411146
break;
11421147
}
1148+
case ExpressionId.RefIsNull: {
1149+
this.inheritNonnullIfTrue(getRefIsNullValue(expr), iff); // value == null -> value must have been non-null
1150+
break;
1151+
}
11431152
}
11441153
}
11451154

src/module.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3553,6 +3553,10 @@ export function getMemoryGrowDelta(expr: ExpressionRef): ExpressionRef {
35533553
return binaryen._BinaryenMemoryGrowGetDelta(expr);
35543554
}
35553555

3556+
export function getRefIsNullValue(expr: ExpressionRef): ExpressionRef {
3557+
return binaryen._BinaryenRefIsNullGetValue(expr);
3558+
}
3559+
35563560
// functions
35573561

35583562
export function getFunctionBody(func: FunctionRef): ExpressionRef {

0 commit comments

Comments
 (0)