| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 import '../common/codegen.dart' show CodegenWorkItem; | 5 import '../common/codegen.dart' show CodegenWorkItem; |
| 6 import '../compiler.dart' show Compiler; | 6 import '../compiler.dart' show Compiler; |
| 7 import '../constants/constant_system.dart'; | 7 import '../constants/constant_system.dart'; |
| 8 import '../constants/values.dart'; | 8 import '../constants/values.dart'; |
| 9 import '../elements/elements.dart'; | 9 import '../elements/elements.dart'; |
| 10 import '../js_backend/backend_helpers.dart' show BackendHelpers; | 10 import '../js_backend/backend_helpers.dart' show BackendHelpers; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 * | 33 * |
| 34 * 5) Some HIs operations on an interceptor are replaced with a HIs version that | 34 * 5) Some HIs operations on an interceptor are replaced with a HIs version that |
| 35 * uses 'instanceof' rather than testing a type flag. | 35 * uses 'instanceof' rather than testing a type flag. |
| 36 * | 36 * |
| 37 */ | 37 */ |
| 38 class SsaSimplifyInterceptors extends HBaseVisitor | 38 class SsaSimplifyInterceptors extends HBaseVisitor |
| 39 implements OptimizationPhase { | 39 implements OptimizationPhase { |
| 40 final String name = "SsaSimplifyInterceptors"; | 40 final String name = "SsaSimplifyInterceptors"; |
| 41 final ConstantSystem constantSystem; | 41 final ConstantSystem constantSystem; |
| 42 final Compiler compiler; | 42 final Compiler compiler; |
| 43 final CodegenWorkItem work; | 43 final Element element; |
| 44 HGraph graph; | 44 HGraph graph; |
| 45 | 45 |
| 46 SsaSimplifyInterceptors(this.compiler, this.constantSystem, this.work); | 46 SsaSimplifyInterceptors(this.compiler, this.constantSystem, this.element); |
| 47 | 47 |
| 48 JavaScriptBackend get backend => compiler.backend; | 48 JavaScriptBackend get backend => compiler.backend; |
| 49 | 49 |
| 50 BackendHelpers get helpers => backend.helpers; | 50 BackendHelpers get helpers => backend.helpers; |
| 51 | 51 |
| 52 ClassWorld get classWorld => compiler.world; | 52 ClassWorld get classWorld => compiler.world; |
| 53 | 53 |
| 54 void visitGraph(HGraph graph) { | 54 void visitGraph(HGraph graph) { |
| 55 this.graph = graph; | 55 this.graph = graph; |
| 56 visitDominatorTree(graph); | 56 visitDominatorTree(graph); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 return graph.thisInstruction; | 122 return graph.thisInstruction; |
| 123 } | 123 } |
| 124 | 124 |
| 125 ClassElement constantInterceptor = tryComputeConstantInterceptorFromType( | 125 ClassElement constantInterceptor = tryComputeConstantInterceptorFromType( |
| 126 input.instructionType, interceptedClasses); | 126 input.instructionType, interceptedClasses); |
| 127 | 127 |
| 128 if (constantInterceptor == null) return null; | 128 if (constantInterceptor == null) return null; |
| 129 | 129 |
| 130 // If we just happen to be in an instance method of the constant | 130 // If we just happen to be in an instance method of the constant |
| 131 // interceptor, `this` is a shorter alias. | 131 // interceptor, `this` is a shorter alias. |
| 132 if (constantInterceptor == work.element.enclosingClass && | 132 if (constantInterceptor == element.enclosingClass && |
| 133 graph.thisInstruction != null) { | 133 graph.thisInstruction != null) { |
| 134 return graph.thisInstruction; | 134 return graph.thisInstruction; |
| 135 } | 135 } |
| 136 | 136 |
| 137 ConstantValue constant = | 137 ConstantValue constant = |
| 138 new InterceptorConstantValue(constantInterceptor.thisType); | 138 new InterceptorConstantValue(constantInterceptor.thisType); |
| 139 return graph.addConstant(constant, compiler); | 139 return graph.addConstant(constant, compiler); |
| 140 } | 140 } |
| 141 | 141 |
| 142 ClassElement tryComputeConstantInterceptorFromType( | 142 ClassElement tryComputeConstantInterceptorFromType( |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 415 instruction = new HInvokeDynamicMethod( | 415 instruction = new HInvokeDynamicMethod( |
| 416 selector, mask, inputs, node.instructionType, true); | 416 selector, mask, inputs, node.instructionType, true); |
| 417 } | 417 } |
| 418 | 418 |
| 419 HBasicBlock block = node.block; | 419 HBasicBlock block = node.block; |
| 420 block.addAfter(node, instruction); | 420 block.addAfter(node, instruction); |
| 421 block.rewrite(node, instruction); | 421 block.rewrite(node, instruction); |
| 422 return true; | 422 return true; |
| 423 } | 423 } |
| 424 } | 424 } |
| OLD | NEW |