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 part of ssa; | 5 part of ssa; |
6 | 6 |
7 /** | 7 /** |
8 * This phase simplifies interceptors in multiple ways: | 8 * This phase simplifies interceptors in multiple ways: |
9 * | 9 * |
10 * 1) If the interceptor is for an object whose type is known, it | 10 * 1) If the interceptor is for an object whose type is known, it |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 } | 93 } |
94 if (receiver.canBeNull() && | 94 if (receiver.canBeNull() && |
95 interceptedClasses.contains(helpers.jsNullClass)) { | 95 interceptedClasses.contains(helpers.jsNullClass)) { |
96 // Need the JSNull interceptor. | 96 // Need the JSNull interceptor. |
97 return false; | 97 return false; |
98 } | 98 } |
99 | 99 |
100 // All intercepted classes extend `Interceptor`, so if the receiver can't be | 100 // All intercepted classes extend `Interceptor`, so if the receiver can't be |
101 // a class extending `Interceptor` then it can be called directly. | 101 // a class extending `Interceptor` then it can be called directly. |
102 return new TypeMask.nonNullSubclass(helpers.jsInterceptorClass, classWorld) | 102 return new TypeMask.nonNullSubclass(helpers.jsInterceptorClass, classWorld) |
103 .intersection(receiver.instructionType, classWorld) | 103 .isDisjoint(receiver.instructionType, classWorld); |
104 .isEmpty; | |
105 } | 104 } |
106 | 105 |
107 HInstruction tryComputeConstantInterceptor( | 106 HInstruction tryComputeConstantInterceptor( |
108 HInstruction input, | 107 HInstruction input, |
109 Set<ClassElement> interceptedClasses) { | 108 Set<ClassElement> interceptedClasses) { |
110 if (input == graph.explicitReceiverParameter) { | 109 if (input == graph.explicitReceiverParameter) { |
111 // If `explicitReceiverParameter` is set it means the current method is an | 110 // If `explicitReceiverParameter` is set it means the current method is an |
112 // interceptor method, and `this` is the interceptor. The caller just did | 111 // interceptor method, and `this` is the interceptor. The caller just did |
113 // `getInterceptor(foo).currentMethod(foo)` to enter the current method. | 112 // `getInterceptor(foo).currentMethod(foo)` to enter the current method. |
114 return graph.thisInstruction; | 113 return graph.thisInstruction; |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 instruction = new HInvokeDynamicMethod( | 402 instruction = new HInvokeDynamicMethod( |
404 selector, mask, inputs, node.instructionType, true); | 403 selector, mask, inputs, node.instructionType, true); |
405 } | 404 } |
406 | 405 |
407 HBasicBlock block = node.block; | 406 HBasicBlock block = node.block; |
408 block.addAfter(node, instruction); | 407 block.addAfter(node, instruction); |
409 block.rewrite(node, instruction); | 408 block.rewrite(node, instruction); |
410 return true; | 409 return true; |
411 } | 410 } |
412 } | 411 } |
OLD | NEW |