1
0
mirror of https://github.com/dart-lang/sdk synced 2024-07-05 17:30:16 +00:00

[dart2js] Fix over-eager NullCheck removal

Change-Id: I6a6a7ca3bb4621eac35305b96dec6039bc630d9e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/130966
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
This commit is contained in:
Stephen Adams 2020-01-10 05:08:07 +00:00 committed by commit-bot@chromium.org
parent b233061a90
commit e643b423ca

View File

@ -112,13 +112,31 @@ class SsaInstructionSelection extends HBaseVisitor with CodegenPhase {
if (current is HGetLength) return current;
if (current is HIndex) return current;
if (current is HIndexAssign) return current;
if (current is HInvokeDynamic) return current;
if (current is HInvokeDynamic) {
HInstruction receiver = current.receiver;
// Either no interceptor or self-interceptor:
if (receiver == nullCheck) return current;
return null;
}
}
if (current is HForeignCode) {
if (current.isNullGuardFor(nullCheck)) return current;
}
// TODO(sra): Recognize other usable faulting patterns:
//
// - HInstanceEnvironment when the generated code is `receiver.$ti`.
//
// - super-calls using aliases.
//
// - one-shot interceptor receiver for selector not defined on
// null. The fault will appear to happen in the one-shot
// interceptor.
//
// - a constant interceptor can be replaced with a conditional
// HInterceptor (e.g. (a && JSArray_methods).get$first(a)).
if (current.canThrow(_abstractValueDomain) ||
current.sideEffects.hasSideEffects()) {
return null;