mirror of
https://github.com/dart-lang/sdk
synced 2024-09-15 22:51:29 +00:00
dart2js: Reduce assert helpers
Change-Id: Ic2ce0e485e3fd27b8f4e92371eb17a076d5192c1 Reviewed-on: https://dart-review.googlesource.com/c/92668 Reviewed-by: Sigmund Cherem <sigmund@google.com> Commit-Queue: Stephen Adams <sra@google.com>
This commit is contained in:
parent
c812d5a373
commit
66c404a26e
|
@ -1369,7 +1369,25 @@ class SsaInstructionSimplifier extends HBaseVisitor
|
|||
return argument;
|
||||
}
|
||||
}
|
||||
} else if (element == commonElements.assertHelper ||
|
||||
element == commonElements.assertTest) {
|
||||
if (node.inputs.length == 1) {
|
||||
HInstruction argument = node.inputs[0];
|
||||
if (argument is HConstant) {
|
||||
ConstantValue constant = argument.constant;
|
||||
if (constant.isBool) {
|
||||
bool value = constant.isTrue;
|
||||
if (element == commonElements.assertTest) {
|
||||
// `assertTest(argument)` effectively negates the argument.
|
||||
return _graph.addConstantBool(!value, _closedWorld);
|
||||
}
|
||||
// `assertHelper(true)` is a no-op, other values throw.
|
||||
if (value) return argument;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue