mirror of
https://github.com/dart-lang/sdk
synced 2024-10-06 16:47:20 +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:
parent
b233061a90
commit
e643b423ca
|
@ -112,13 +112,31 @@ class SsaInstructionSelection extends HBaseVisitor with CodegenPhase {
|
||||||
if (current is HGetLength) return current;
|
if (current is HGetLength) return current;
|
||||||
if (current is HIndex) return current;
|
if (current is HIndex) return current;
|
||||||
if (current is HIndexAssign) 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 is HForeignCode) {
|
||||||
if (current.isNullGuardFor(nullCheck)) return current;
|
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) ||
|
if (current.canThrow(_abstractValueDomain) ||
|
||||||
current.sideEffects.hasSideEffects()) {
|
current.sideEffects.hasSideEffects()) {
|
||||||
return null;
|
return null;
|
||||||
|
|
Loading…
Reference in a new issue