Index: pkg/compiler/lib/src/ssa/codegen_helpers.dart |
diff --git a/pkg/compiler/lib/src/ssa/codegen_helpers.dart b/pkg/compiler/lib/src/ssa/codegen_helpers.dart |
index abc6c8658399fa7253d83202f82b0d3e298e106e..3b5c557c617766f354cecd576021f22858df939f 100644 |
--- a/pkg/compiler/lib/src/ssa/codegen_helpers.dart |
+++ b/pkg/compiler/lib/src/ssa/codegen_helpers.dart |
@@ -273,6 +273,37 @@ class SsaTypeKnownRemover extends HBaseVisitor { |
} |
/** |
+ * Remove [HTypeConversion] instructions from the graph in '--trust-primitives' |
+ * mode. |
+ */ |
+class SsaTrustedCheckRemover extends HBaseVisitor { |
+ |
+ Compiler compiler; |
+ SsaTrustedCheckRemover(this.compiler); |
+ |
+ void visitGraph(HGraph graph) { |
+ if (!compiler.trustPrimitives) return; |
+ visitDominatorTree(graph); |
+ } |
+ |
+ void visitBasicBlock(HBasicBlock block) { |
+ HInstruction instruction = block.first; |
+ while (instruction != null) { |
+ HInstruction next = instruction.next; |
+ instruction.accept(this); |
+ instruction = next; |
+ } |
+ } |
+ |
+ void visitTypeConversion(HTypeConversion instruction) { |
+ if (instruction.isReceiverTypeCheck || instruction.isArgumentTypeCheck) { |
+ instruction.block.rewrite(instruction, instruction.checkedInput); |
+ instruction.block.remove(instruction); |
+ } |
+ } |
+} |
+ |
+/** |
* Instead of emitting each SSA instruction with a temporary variable |
* mark instructions that can be emitted at their use-site. |
* For example, in: |