OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 library dart2js.cps_ir.path_based_optimizer; | 4 library dart2js.cps_ir.path_based_optimizer; |
5 | 5 |
6 import 'cps_ir_nodes.dart'; | 6 import 'cps_ir_nodes.dart'; |
7 import 'optimizers.dart'; | 7 import 'optimizers.dart'; |
8 import 'cps_fragment.dart'; | 8 import 'cps_fragment.dart'; |
9 import '../js_backend/js_backend.dart'; | 9 import '../js_backend/js_backend.dart'; |
10 import '../constants/values.dart'; | 10 import '../constants/values.dart'; |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 } else if (values & negativeValues == 0) { | 150 } else if (values & negativeValues == 0) { |
151 destroyAndReplace(node, new InvokeContinuation(trueCont, [])); | 151 destroyAndReplace(node, new InvokeContinuation(trueCont, [])); |
152 valuesAt[trueCont] = valueOf; | 152 valuesAt[trueCont] = valueOf; |
153 } else { | 153 } else { |
154 valuesAt[trueCont] = copy(valueOf)..[condition] = values & positiveValues; | 154 valuesAt[trueCont] = copy(valueOf)..[condition] = values & positiveValues; |
155 valuesAt[falseCont] = valueOf..[condition] = values & negativeValues; | 155 valuesAt[falseCont] = valueOf..[condition] = values & negativeValues; |
156 } | 156 } |
157 } | 157 } |
158 | 158 |
159 void visitInvokeMethod(InvokeMethod node) { | 159 void visitInvokeMethod(InvokeMethod node) { |
160 int receiverValue = valueOf[node.dartReceiver] ?? ANY; | 160 int receiverValue = valueOf[node.receiver] ?? ANY; |
161 if (!backend.isInterceptedSelector(node.selector)) { | 161 if (!backend.isInterceptedSelector(node.selector)) { |
162 // Only self-interceptors can respond to a non-intercepted selector. | 162 // Only self-interceptors can respond to a non-intercepted selector. |
163 valueOf[node.dartReceiver] = receiverValue & SELF_INTERCEPTOR; | 163 valueOf[node.receiver] = receiverValue & SELF_INTERCEPTOR; |
164 } else if (receiverValue & ~SELF_INTERCEPTOR == 0 && | 164 } else if (receiverValue & ~SELF_INTERCEPTOR == 0 && |
165 node.callingConvention == CallingConvention.Intercepted) { | 165 node.callingConvention == CallingConvention.Intercepted) { |
166 // This is an intercepted call whose receiver is definitely a | 166 // This is an intercepted call whose receiver is definitely a |
167 // self-interceptor. | 167 // self-interceptor. |
168 // TODO(25646): If TypeMasks could represent "any self-interceptor" this | 168 // TODO(25646): If TypeMasks could represent "any self-interceptor" this |
169 // optimization should be subsumed by type propagation. | 169 // optimization should be subsumed by type propagation. |
170 node.receiverRef.changeTo(node.dartReceiver); | 170 node.interceptorRef.changeTo(node.receiver); |
171 | 171 |
172 // Replace the extra receiver argument with a dummy value if the | 172 // Replace the extra receiver argument with a dummy value if the |
173 // target definitely does not use it. | 173 // target definitely does not use it. |
174 if (typeSystem.targetIgnoresReceiverArgument(node.dartReceiver.type, | 174 if (typeSystem.targetIgnoresReceiverArgument(node.receiver.type, |
175 node.selector)) { | 175 node.selector)) { |
176 Constant dummy = new Constant(new IntConstantValue(0)) | 176 node.makeDummyIntercepted(); |
177 ..type = typeSystem.intType; | |
178 new LetPrim(dummy).insertAbove(node.parent); | |
179 node.argumentRefs[0].changeTo(dummy); | |
180 node.callingConvention = CallingConvention.DummyIntercepted; | |
181 } | 177 } |
182 } | 178 } |
183 } | 179 } |
184 } | 180 } |
OLD | NEW |