Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(670)

Side by Side Diff: pkg/compiler/lib/src/js_backend/codegen/unsugar.dart

Issue 1571433002: dart2js cps: Compute intercepted classes in optimize_interceptors. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Address comments Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « pkg/compiler/lib/src/js_backend/codegen/task.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 library dart2js.unsugar_cps; 1 library dart2js.unsugar_cps;
2 2
3 import '../../cps_ir/cps_ir_nodes.dart'; 3 import '../../cps_ir/cps_ir_nodes.dart';
4 4
5 import '../../cps_ir/optimizers.dart' show ParentVisitor, Pass; 5 import '../../cps_ir/optimizers.dart' show Pass;
6 import '../../constants/values.dart'; 6 import '../../constants/values.dart';
7 import '../../elements/elements.dart'; 7 import '../../elements/elements.dart';
8 import '../../js_backend/codegen/glue.dart'; 8 import '../../js_backend/codegen/glue.dart';
9 import '../../universe/selector.dart' show Selector; 9 import '../../universe/selector.dart' show Selector;
10 import '../../cps_ir/cps_ir_builder.dart' show ThisParameterLocal; 10 import '../../cps_ir/cps_ir_builder.dart' show ThisParameterLocal;
11 import '../../cps_ir/cps_fragment.dart'; 11 import '../../cps_ir/cps_fragment.dart';
12 import '../../common/names.dart'; 12 import '../../common/names.dart';
13 13
14 class ExplicitReceiverParameterEntity implements Local { 14 class ExplicitReceiverParameterEntity implements Local {
15 String get name => 'receiver'; 15 String get name => 'receiver';
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 212
213 Primitive receiver = node.receiver.definition; 213 Primitive receiver = node.receiver.definition;
214 Primitive newReceiver; 214 Primitive newReceiver;
215 215
216 if (receiver == explicitReceiverParameter) { 216 if (receiver == explicitReceiverParameter) {
217 // If the receiver is the explicit receiver, we are calling a method in 217 // If the receiver is the explicit receiver, we are calling a method in
218 // the same interceptor: 218 // the same interceptor:
219 // Change 'receiver.foo()' to 'this.foo(receiver)'. 219 // Change 'receiver.foo()' to 'this.foo(receiver)'.
220 newReceiver = thisParameter; 220 newReceiver = thisParameter;
221 } else { 221 } else {
222 newReceiver = new Interceptor(receiver, node.sourceInformation) 222 newReceiver = new Interceptor(receiver, node.sourceInformation);
223 ..interceptedClasses.addAll(_glue.getInterceptedClassesOn(selector));
224 if (receiver.hint != null) { 223 if (receiver.hint != null) {
225 newReceiver.hint = new InterceptorEntity(receiver.hint); 224 newReceiver.hint = new InterceptorEntity(receiver.hint);
226 } 225 }
227 new LetPrim(newReceiver).insertAbove(node.parent); 226 new LetPrim(newReceiver).insertAbove(node.parent);
228 } 227 }
229 node.arguments.insert(0, node.receiver); 228 node.arguments.insert(0, node.receiver);
230 node.receiver = new Reference<Primitive>(newReceiver)..parent = node; 229 node.receiver = new Reference<Primitive>(newReceiver)..parent = node;
231 node.callingConvention = CallingConvention.Intercepted; 230 node.callingConvention = CallingConvention.Intercepted;
232 } 231 }
233 232
234 processInvokeMethodDirectly(InvokeMethodDirectly node) { 233 processInvokeMethodDirectly(InvokeMethodDirectly node) {
235 if (!_glue.isInterceptedMethod(node.target)) return; 234 if (!_glue.isInterceptedMethod(node.target)) return;
236 235
237 Selector selector = node.selector;
238 Primitive receiver = node.receiver.definition; 236 Primitive receiver = node.receiver.definition;
239 Primitive newReceiver; 237 Primitive newReceiver;
240 238
241 if (receiver == explicitReceiverParameter) { 239 if (receiver == explicitReceiverParameter) {
242 // If the receiver is the explicit receiver, we are calling a method in 240 // If the receiver is the explicit receiver, we are calling a method in
243 // the same interceptor: 241 // the same interceptor:
244 // Change 'receiver.foo()' to 'this.foo(receiver)'. 242 // Change 'receiver.foo()' to 'this.foo(receiver)'.
245 newReceiver = thisParameter; 243 newReceiver = thisParameter;
246 } else { 244 } else {
247 newReceiver = new Interceptor(receiver, node.sourceInformation) 245 newReceiver = new Interceptor(receiver, node.sourceInformation);
248 ..interceptedClasses.addAll(_glue.getInterceptedClassesOn(selector));
249 if (receiver.hint != null) { 246 if (receiver.hint != null) {
250 newReceiver.hint = new InterceptorEntity(receiver.hint); 247 newReceiver.hint = new InterceptorEntity(receiver.hint);
251 } 248 }
252 new LetPrim(newReceiver).insertAbove(node.parent); 249 new LetPrim(newReceiver).insertAbove(node.parent);
253 } 250 }
254 node.arguments.insert(0, node.receiver); 251 node.arguments.insert(0, node.receiver);
255 node.receiver = new Reference<Primitive>(newReceiver)..parent = node; 252 node.receiver = new Reference<Primitive>(newReceiver)..parent = node;
256 node.callingConvention = CallingConvention.Intercepted; 253 node.callingConvention = CallingConvention.Intercepted;
257 } 254 }
258
259 processInterceptor(Interceptor node) {
260 _glue.registerSpecializedGetInterceptor(node.interceptedClasses);
261 }
262 } 255 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/js_backend/codegen/task.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698