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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/ssa/builder.dart

Issue 11275316: Add a new interceptor class JsArray, and support intercepting some list methods with the new interc… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/resolution/members.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 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 class Interceptors { 7 class Interceptors {
8 Compiler compiler; 8 Compiler compiler;
9 Interceptors(Compiler this.compiler); 9 Interceptors(Compiler this.compiler);
10 10
(...skipping 2273 matching lines...) Expand 10 before | Expand all | Expand 10 after
2284 } 2284 }
2285 2285
2286 String getTargetName(ErroneousElement error, [String prefix]) { 2286 String getTargetName(ErroneousElement error, [String prefix]) {
2287 String result = error.name.slowToString(); 2287 String result = error.name.slowToString();
2288 if (?prefix) { 2288 if (?prefix) {
2289 result = '$prefix $result'; 2289 result = '$prefix $result';
2290 } 2290 }
2291 return result; 2291 return result;
2292 } 2292 }
2293 2293
2294 Element getInterceptor(Send send, Selector selector) {
2295 if (!methodInterceptionEnabled) return null;
2296 if (!backend.isInterceptorClass(currentElement.getEnclosingClass())
2297 && send.receiver == null) {
2298 // The call applies to [:this:] which can not be an interceptor
2299 // object.
2300 return null;
2301 }
2302 return interceptors.getStaticInterceptor(selector);
2303 }
2304
2294 void generateInstanceGetterWithCompiledReceiver(Send send, 2305 void generateInstanceGetterWithCompiledReceiver(Send send,
2295 HInstruction receiver) { 2306 HInstruction receiver) {
2296 assert(Elements.isInstanceSend(send, elements)); 2307 assert(Elements.isInstanceSend(send, elements));
2297 // TODO(kasperl): This is a convoluted way of checking if we're 2308 // TODO(kasperl): This is a convoluted way of checking if we're
2298 // generating code for a compound assignment. If we are, we need 2309 // generating code for a compound assignment. If we are, we need
2299 // to get the selector from the mapping for the AST selector node. 2310 // to get the selector from the mapping for the AST selector node.
2300 Selector selector = (send.asSendSet() == null) 2311 Selector selector = (send.asSendSet() == null)
2301 ? elements.getSelector(send) 2312 ? elements.getSelector(send)
2302 : elements.getSelector(send.selector); 2313 : elements.getSelector(send.selector);
2303 assert(selector.isGetter()); 2314 assert(selector.isGetter());
2304 SourceString getterName = selector.name; 2315 SourceString getterName = selector.name;
2305 Element interceptor = null; 2316 Element interceptor = getInterceptor(send, selector);
2306 if (methodInterceptionEnabled) { 2317
2307 interceptor = interceptors.getStaticInterceptor(selector);
2308 }
2309 bool hasGetter = compiler.world.hasAnyUserDefinedGetter(selector); 2318 bool hasGetter = compiler.world.hasAnyUserDefinedGetter(selector);
2310 if (interceptor == backend.getInterceptorMethod && interceptor != null) { 2319 if (interceptor == backend.getInterceptorMethod && interceptor != null) {
2311 // If we're using an interceptor class, emit a call to the 2320 // If we're using an interceptor class, emit a call to the
2312 // interceptor method and then the actual dynamic call on the 2321 // interceptor method and then the actual dynamic call on the
2313 // interceptor object. 2322 // interceptor object.
2314 HInstruction instruction; 2323 HInstruction instruction;
2315 if (backend.isInterceptorClass(currentElement.getEnclosingClass()) 2324 if (backend.isInterceptorClass(currentElement.getEnclosingClass())
2316 && send.receiver == null) { 2325 && send.receiver == null) {
2317 instruction = thisInstruction; 2326 instruction = thisInstruction;
2318 } else { 2327 } else {
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
2379 } 2388 }
2380 } 2389 }
2381 2390
2382 void generateInstanceSetterWithCompiledReceiver(Send send, 2391 void generateInstanceSetterWithCompiledReceiver(Send send,
2383 HInstruction receiver, 2392 HInstruction receiver,
2384 HInstruction value) { 2393 HInstruction value) {
2385 assert(Elements.isInstanceSend(send, elements)); 2394 assert(Elements.isInstanceSend(send, elements));
2386 Selector selector = elements.getSelector(send); 2395 Selector selector = elements.getSelector(send);
2387 assert(selector.isSetter()); 2396 assert(selector.isSetter());
2388 SourceString setterName = selector.name; 2397 SourceString setterName = selector.name;
2389 Element interceptor = null; 2398 Element interceptor = getInterceptor(send, selector);
2390 if (methodInterceptionEnabled) {
2391 interceptor = interceptors.getStaticInterceptor(selector);
2392 }
2393 bool hasSetter = compiler.world.hasAnyUserDefinedSetter(selector); 2399 bool hasSetter = compiler.world.hasAnyUserDefinedSetter(selector);
2394 if (interceptor != null && interceptor == backend.getInterceptorMethod) { 2400 if (interceptor != null && interceptor == backend.getInterceptorMethod) {
2395 compiler.internalError( 2401 compiler.internalError(
2396 'Unimplemented intercepted setter call with interceptor classes'); 2402 'Unimplemented intercepted setter call with interceptor classes');
2397 } else if (interceptor != null && elements[send] == null) { 2403 } else if (interceptor != null && elements[send] == null) {
2398 HStatic target = new HStatic(interceptor); 2404 HStatic target = new HStatic(interceptor);
2399 add(target); 2405 add(target);
2400 List<HInstruction> inputs = <HInstruction>[target, receiver, value]; 2406 List<HInstruction> inputs = <HInstruction>[target, receiver, value];
2401 addWithPosition(new HInvokeInterceptor(selector, inputs), send); 2407 addWithPosition(new HInvokeInterceptor(selector, inputs), send);
2402 } else { 2408 } else {
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
2652 const SourceString('[]='), false); 2658 const SourceString('[]='), false);
2653 } else if (node.selector.asOperator() != null) { 2659 } else if (node.selector.asOperator() != null) {
2654 SourceString name = node.selector.asIdentifier().source; 2660 SourceString name = node.selector.asIdentifier().source;
2655 isNotEquals = identical(name.stringValue, '!='); 2661 isNotEquals = identical(name.stringValue, '!=');
2656 dartMethodName = Elements.constructOperatorName( 2662 dartMethodName = Elements.constructOperatorName(
2657 name, node.argumentsNode is Prefix); 2663 name, node.argumentsNode is Prefix);
2658 } else { 2664 } else {
2659 dartMethodName = node.selector.asIdentifier().source; 2665 dartMethodName = node.selector.asIdentifier().source;
2660 } 2666 }
2661 2667
2662 Element interceptor = null; 2668 Element interceptor = getInterceptor(node, selector);
2663 if (methodInterceptionEnabled) {
2664 interceptor = interceptors.getStaticInterceptor(selector);
2665 }
2666 2669
2667 if (interceptor != null) { 2670 if (interceptor != null) {
2668 if (interceptor == backend.getInterceptorMethod) { 2671 if (interceptor == backend.getInterceptorMethod) {
2669 if (backend.isInterceptorClass(currentElement.getEnclosingClass()) 2672 if (backend.isInterceptorClass(currentElement.getEnclosingClass())
2670 && node.receiver == null) { 2673 && node.receiver == null) {
2671 inputs.add(thisInstruction); 2674 inputs.add(thisInstruction);
2672 inputs.add(localsHandler.readThis()); 2675 inputs.add(localsHandler.readThis());
2673 } else { 2676 } else {
2674 HStatic target = new HStatic(interceptor); 2677 HStatic target = new HStatic(interceptor);
2675 add(target); 2678 add(target);
(...skipping 2165 matching lines...) Expand 10 before | Expand all | Expand 10 after
4841 new HSubGraphBlockInformation(elseBranch.graph)); 4844 new HSubGraphBlockInformation(elseBranch.graph));
4842 4845
4843 HBasicBlock conditionStartBlock = conditionBranch.block; 4846 HBasicBlock conditionStartBlock = conditionBranch.block;
4844 conditionStartBlock.setBlockFlow(info, joinBlock); 4847 conditionStartBlock.setBlockFlow(info, joinBlock);
4845 SubGraph conditionGraph = conditionBranch.graph; 4848 SubGraph conditionGraph = conditionBranch.graph;
4846 HIf branch = conditionGraph.end.last; 4849 HIf branch = conditionGraph.end.last;
4847 assert(branch is HIf); 4850 assert(branch is HIf);
4848 branch.blockInformation = conditionStartBlock.blockFlow; 4851 branch.blockInformation = conditionStartBlock.blockFlow;
4849 } 4852 }
4850 } 4853 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/resolution/members.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698