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:
Stephen Adams 2019-02-12 18:34:34 +00:00 committed by commit-bot@chromium.org
parent c812d5a373
commit 66c404a26e

View file

@ -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;
}