@@ -761,7 +761,9 @@ class SsaInstructionSimplifier extends HBaseVisitor
761761 _closedWorld.elementEnvironment.getFieldType (field);
762762 HInstruction closureCall = new HInvokeClosure (
763763 callSelector,
764- _abstractValueDomain.createFromStaticType (fieldType).abstractValue,
764+ _abstractValueDomain
765+ .createFromStaticType (fieldType, nullable: true )
766+ .abstractValue,
765767 inputs,
766768 node.instructionType,
767769 node.typeArguments)
@@ -1877,7 +1879,7 @@ class SsaInstructionSimplifier extends HBaseVisitor
18771879 dartType, node.isTypeError, _closedWorld.commonElements);
18781880 if (specializedCheck != null ) {
18791881 AbstractValueWithPrecision checkedType =
1880- _abstractValueDomain.createFromStaticType (dartType);
1882+ _abstractValueDomain.createFromStaticType (dartType, nullable : true );
18811883 return HAsCheckSimple (node.checkedInput, dartType, checkedType,
18821884 node.isTypeError, specializedCheck, node.instructionType);
18831885 }
@@ -1891,6 +1893,27 @@ class SsaInstructionSimplifier extends HBaseVisitor
18911893 return node;
18921894 }
18931895
1896+ @override
1897+ HInstruction visitIsTest (HIsTest node) {
1898+ AbstractValueWithPrecision checkedAbstractValue = node.checkedAbstractValue;
1899+ HInstruction checkedInput = node.checkedInput;
1900+ AbstractValue inputType = checkedInput.instructionType;
1901+
1902+ AbstractBool isIn = _abstractValueDomain.isIn (
1903+ inputType, checkedAbstractValue.abstractValue);
1904+
1905+ if (isIn.isDefinitelyFalse) {
1906+ return _graph.addConstantBool (false , _closedWorld);
1907+ }
1908+ if (! checkedAbstractValue.isPrecise) return node;
1909+
1910+ if (isIn.isDefinitelyTrue) {
1911+ return _graph.addConstantBool (true , _closedWorld);
1912+ }
1913+
1914+ return node;
1915+ }
1916+
18941917 @override
18951918 HInstruction visitInstanceEnvironment (HInstanceEnvironment node) {
18961919 HInstruction instance = node.inputs.single;
@@ -2954,6 +2977,27 @@ class SsaTypeConversionInserter extends HBaseVisitor
29542977 // false. Avoid strengthening to `null`.
29552978 }
29562979
2980+ @override
2981+ void visitIsTest (HIsTest instruction) {
2982+ List <HBasicBlock > trueTargets = < HBasicBlock > [];
2983+ List <HBasicBlock > falseTargets = < HBasicBlock > [];
2984+
2985+ collectTargets (instruction, trueTargets, falseTargets);
2986+
2987+ if (trueTargets.isEmpty && falseTargets.isEmpty) return ;
2988+
2989+ AbstractValue convertedType =
2990+ instruction.checkedAbstractValue.abstractValue;
2991+ HInstruction input = instruction.checkedInput;
2992+
2993+ for (HBasicBlock block in trueTargets) {
2994+ insertTypePropagationForDominatedUsers (block, input, convertedType);
2995+ }
2996+ // TODO(sra): Also strengthen uses for when the condition is precise and
2997+ // known false (e.g. int? x; ... if (x is! int) use(x)). Avoid strengthening
2998+ // to `null`.
2999+ }
3000+
29573001 @override
29583002 void visitIdentity (HIdentity instruction) {
29593003 // At HIf(HIdentity(x, null)) strengthens x to non-null on else branch.
0 commit comments