Remove HBoolify
HBoolify was used in Dart1 unchecked mode.
Change-Id: I1cdbff515fc7446c67fc255bb9599dee79dfd242
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/103569
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
diff --git a/pkg/compiler/lib/src/ssa/builder_kernel.dart b/pkg/compiler/lib/src/ssa/builder_kernel.dart
index 67cc980..0bd6b75 100644
--- a/pkg/compiler/lib/src/ssa/builder_kernel.dart
+++ b/pkg/compiler/lib/src/ssa/builder_kernel.dart
@@ -620,17 +620,11 @@
return _elementMap.getDartType(type);
}
- /// Pops the most recent instruction from the stack and 'boolifies' it.
- ///
- /// Boolification is checking if the value is '=== true'.
+ /// Pops the most recent instruction from the stack and ensures that it is a
+ /// non-null bool.
HInstruction popBoolified() {
HInstruction value = pop();
- if (_typeBuilder.checkOrTrustTypes) {
- return _typeBuilder.potentiallyCheckOrTrustTypeOfCondition(value);
- }
- HInstruction result = new HBoolify(value, _abstractValueDomain.boolType);
- add(result);
- return result;
+ return _typeBuilder.potentiallyCheckOrTrustTypeOfCondition(value);
}
/// Extend current method parameters with parameters for the class type
@@ -6110,8 +6104,6 @@
/// Generates type tests for the parameters of the inlined function.
void _potentiallyCheckInlinedParameterTypes(FunctionEntity function) {
- if (!_typeBuilder.checkOrTrustTypes) return;
-
// TODO(sra): Incorporate properties of call site to help determine which
// type parameters and value parameters need to be checked.
bool trusted = false;
diff --git a/pkg/compiler/lib/src/ssa/codegen.dart b/pkg/compiler/lib/src/ssa/codegen.dart
index 2018ff3..a060f85 100644
--- a/pkg/compiler/lib/src/ssa/codegen.dart
+++ b/pkg/compiler/lib/src/ssa/codegen.dart
@@ -1561,15 +1561,6 @@
visitGreaterEqual(HGreaterEqual node) => visitRelational(node, '>=');
@override
- visitBoolify(HBoolify node) {
- assert(node.inputs.length == 1);
- use(node.inputs[0]);
- push(new js.Binary(
- '===', pop(), newLiteralBool(true, node.sourceInformation))
- .withSourceInformation(node.sourceInformation));
- }
-
- @override
visitExit(HExit node) {
// Don't do anything.
}
@@ -2426,11 +2417,6 @@
use(input.inputs[0]);
} else if (input is HIdentity) {
emitIdentityComparison(input, sourceInformation, inverse: true);
- } else if (input is HBoolify) {
- use(input.inputs[0]);
- push(new js.Binary(
- "!==", pop(), newLiteralBool(true, input.sourceInformation))
- .withSourceInformation(sourceInformation));
} else if (canGenerateOptimizedComparison(input)) {
HRelational relational = input;
constant_system.BinaryOperation operation = relational.operation();
diff --git a/pkg/compiler/lib/src/ssa/nodes.dart b/pkg/compiler/lib/src/ssa/nodes.dart
index 573404b..e6bb87a 100644
--- a/pkg/compiler/lib/src/ssa/nodes.dart
+++ b/pkg/compiler/lib/src/ssa/nodes.dart
@@ -31,7 +31,6 @@
R visitBitNot(HBitNot node);
R visitBitOr(HBitOr node);
R visitBitXor(HBitXor node);
- R visitBoolify(HBoolify node);
R visitBoundsCheck(HBoundsCheck node);
R visitBreak(HBreak node);
R visitConstant(HConstant node);
@@ -433,8 +432,6 @@
@override
visitBitXor(HBitXor node) => visitBinaryBitOp(node);
@override
- visitBoolify(HBoolify node) => visitInstruction(node);
- @override
visitBoundsCheck(HBoundsCheck node) => visitCheck(node);
@override
visitBreak(HBreak node) => visitJump(node);
@@ -1019,7 +1016,6 @@
// Type codes.
static const int UNDEFINED_TYPECODE = -1;
- static const int BOOLIFY_TYPECODE = 0;
static const int TYPE_GUARD_TYPECODE = 1;
static const int BOUNDS_CHECK_TYPECODE = 2;
static const int INTEGER_CHECK_TYPECODE = 3;
@@ -1558,23 +1554,6 @@
: super(inputs, type);
}
-class HBoolify extends HInstruction {
- HBoolify(HInstruction value, AbstractValue type)
- : super(<HInstruction>[value], type) {
- setUseGvn();
- sourceInformation = value.sourceInformation;
- }
-
- @override
- accept(HVisitor visitor) => visitor.visitBoolify(this);
- @override
- int typeCode() => HInstruction.BOOLIFY_TYPECODE;
- @override
- bool typeEquals(other) => other is HBoolify;
- @override
- bool dataEquals(HInstruction other) => true;
-}
-
/// A [HCheck] instruction is an instruction that might do a dynamic
/// check at runtime on another instruction. To have proper instruction
/// dependencies in the graph, instructions that depend on the check
diff --git a/pkg/compiler/lib/src/ssa/optimize.dart b/pkg/compiler/lib/src/ssa/optimize.dart
index c9f34cc..3de059f 100644
--- a/pkg/compiler/lib/src/ssa/optimize.dart
+++ b/pkg/compiler/lib/src/ssa/optimize.dart
@@ -439,33 +439,6 @@
}
@override
- HInstruction visitBoolify(HBoolify node) {
- List<HInstruction> inputs = node.inputs;
- assert(inputs.length == 1);
- HInstruction input = inputs[0];
- if (input.isBoolean(_abstractValueDomain).isDefinitelyTrue) {
- return input;
- }
-
- // If the code is unreachable, remove the HBoolify. This can happen when
- // there is a throw expression in a short-circuit conditional. Removing the
- // unreachable HBoolify makes it easier to reconstruct the short-circuit
- // operation.
- if (_abstractValueDomain.isEmpty(input.instructionType).isDefinitelyTrue) {
- return input;
- }
-
- // All values that cannot be 'true' are boolified to false.
- AbstractValue mask = input.instructionType;
- if (_abstractValueDomain
- .containsType(mask, commonElements.jsBoolClass)
- .isPotentiallyFalse) {
- return _graph.addConstantBool(false, _closedWorld);
- }
- return node;
- }
-
- @override
HInstruction visitNot(HNot node) {
List<HInstruction> inputs = node.inputs;
assert(inputs.length == 1);
@@ -925,23 +898,8 @@
return node;
}
- bool allUsersAreBoolifies(HInstruction instruction) {
- List<HInstruction> users = instruction.usedBy;
- int length = users.length;
- for (int i = 0; i < length; i++) {
- if (users[i] is! HBoolify) return false;
- }
- return true;
- }
-
@override
HInstruction visitRelational(HRelational node) {
- if (allUsersAreBoolifies(node)) {
- // TODO(ngeoffray): Call a boolified selector.
- // This node stays the same, but the Boolify node will go away.
- }
- // Note that we still have to call [super] to make sure that we end up
- // in the remaining optimizations.
return super.visitRelational(node);
}
@@ -2928,10 +2886,6 @@
collectTargets(user, trueTargets, null);
}
}
- } else if (user is HBoolify) {
- // We collect targets for strictly boolean operations so HBoolify cannot
- // change the result.
- collectTargets(user, trueTargets, falseTargets);
}
}
}
diff --git a/pkg/compiler/lib/src/ssa/ssa_tracer.dart b/pkg/compiler/lib/src/ssa/ssa_tracer.dart
index 9a5b4ca..b622443 100644
--- a/pkg/compiler/lib/src/ssa/ssa_tracer.dart
+++ b/pkg/compiler/lib/src/ssa/ssa_tracer.dart
@@ -173,11 +173,6 @@
return "LateValue: ${temporaryId(node.inputs[0])}";
}
- @override
- String visitBoolify(HBoolify node) {
- return "Boolify: ${temporaryId(node.inputs[0])}";
- }
-
String handleInvokeBinary(HInvokeBinary node, String opcode) {
String left = temporaryId(node.left);
String right = temporaryId(node.right);
diff --git a/pkg/compiler/lib/src/ssa/type_builder.dart b/pkg/compiler/lib/src/ssa/type_builder.dart
index 710338c..7b07bd4 100644
--- a/pkg/compiler/lib/src/ssa/type_builder.dart
+++ b/pkg/compiler/lib/src/ssa/type_builder.dart
@@ -262,8 +262,6 @@
return result;
}
- bool get checkOrTrustTypes => true;
-
/// Build a [HTypeConversion] for converting [original] to type [type].
///
/// Invariant: [type] must be valid in the context.