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

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

Issue 23581017: Re-apply r27739: Fix invocation_mirror_test.dart. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | sdk/lib/_internal/compiler/implementation/types/type_graph_inferrer.dart » ('j') | 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 /** 7 /**
8 * A special element for the extra parameter taken by intercepted 8 * A special element for the extra parameter taken by intercepted
9 * methods. We need to override [Element.computeType] because our 9 * methods. We need to override [Element.computeType] because our
10 * optimizers may look at its declared type. 10 * optimizers may look at its declared type.
(...skipping 3259 matching lines...) Expand 10 before | Expand all | Expand 10 after
3270 } else { 3270 } else {
3271 throw "Unknown foreign: ${selector}"; 3271 throw "Unknown foreign: ${selector}";
3272 } 3272 }
3273 } 3273 }
3274 3274
3275 generateSuperNoSuchMethodSend(Send node, 3275 generateSuperNoSuchMethodSend(Send node,
3276 Selector selector, 3276 Selector selector,
3277 List<HInstruction> arguments) { 3277 List<HInstruction> arguments) {
3278 SourceString name = selector.name; 3278 SourceString name = selector.name;
3279 3279
3280 ClassElement cls = currentElement.getEnclosingClass(); 3280 ClassElement cls = currentNonClosureClass;
3281 Element element = cls.lookupSuperMember(Compiler.NO_SUCH_METHOD); 3281 Element element = cls.lookupSuperMember(Compiler.NO_SUCH_METHOD);
3282 if (element.enclosingElement.declaration != compiler.objectClass) { 3282 if (element.enclosingElement.declaration != compiler.objectClass) {
3283 // Register the call as dynamic if [noSuchMethod] on the super 3283 // Register the call as dynamic if [noSuchMethod] on the super
3284 // class is _not_ the default implementation from [Object], in 3284 // class is _not_ the default implementation from [Object], in
3285 // case the [noSuchMethod] implementation calls 3285 // case the [noSuchMethod] implementation calls
3286 // [JSInvocationMirror._invokeOn]. 3286 // [JSInvocationMirror._invokeOn].
3287 compiler.enqueuer.codegen.registerSelectorUse(selector); 3287 compiler.enqueuer.codegen.registerSelectorUse(selector);
3288 } 3288 }
3289 String publicName = name.slowToString();
3290 if (selector.isSetter()) publicName += '=';
3291
3289 Constant nameConstant = constantSystem.createString( 3292 Constant nameConstant = constantSystem.createString(
3290 new DartString.literal(name.slowToString()), node); 3293 new DartString.literal(publicName), node);
3291 3294
3292 String internalName = backend.namer.invocationName(selector); 3295 String internalName = backend.namer.invocationName(selector);
3293 Constant internalNameConstant = 3296 Constant internalNameConstant =
3294 constantSystem.createString(new DartString.literal(internalName), node); 3297 constantSystem.createString(new DartString.literal(internalName), node);
3295 3298
3296 Element createInvocationMirror = backend.getCreateInvocationMirror(); 3299 Element createInvocationMirror = backend.getCreateInvocationMirror();
3297 var argumentsInstruction = buildLiteralList(arguments); 3300 var argumentsInstruction = buildLiteralList(arguments);
3298 add(argumentsInstruction); 3301 add(argumentsInstruction);
3299 3302
3300 var argumentNames = new List<HInstruction>(); 3303 var argumentNames = new List<HInstruction>();
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
3338 List<HInstruction> arguments = <HInstruction>[]; 3341 List<HInstruction> arguments = <HInstruction>[];
3339 if (!node.isPropertyAccess) { 3342 if (!node.isPropertyAccess) {
3340 addGenericSendArgumentsToList(node.arguments, arguments); 3343 addGenericSendArgumentsToList(node.arguments, arguments);
3341 } 3344 }
3342 return generateSuperNoSuchMethodSend(node, selector, arguments); 3345 return generateSuperNoSuchMethodSend(node, selector, arguments);
3343 } 3346 }
3344 List<HInstruction> inputs = <HInstruction>[]; 3347 List<HInstruction> inputs = <HInstruction>[];
3345 if (node.isPropertyAccess) { 3348 if (node.isPropertyAccess) {
3346 push(buildInvokeSuper(selector, element, inputs)); 3349 push(buildInvokeSuper(selector, element, inputs));
3347 } else if (element.isFunction() || element.isGenerativeConstructor()) { 3350 } else if (element.isFunction() || element.isGenerativeConstructor()) {
3348 // TODO(5347): Try to avoid the need for calling [implementation] before 3351 if (selector.applies(element, compiler)) {
3349 // calling [addStaticSendArgumentsToList]. 3352 // TODO(5347): Try to avoid the need for calling [implementation] before
3350 FunctionElement function = element.implementation; 3353 // calling [addStaticSendArgumentsToList].
3351 bool succeeded = addStaticSendArgumentsToList(selector, node.arguments, 3354 FunctionElement function = element.implementation;
3352 function, inputs); 3355 bool succeeded = addStaticSendArgumentsToList(selector, node.arguments,
3353 if (!succeeded) { 3356 function, inputs);
3357 assert(succeeded);
3358 push(buildInvokeSuper(selector, element, inputs));
3359 } else if (element.isGenerativeConstructor()) {
3354 generateWrongArgumentCountError(node, element, node.arguments); 3360 generateWrongArgumentCountError(node, element, node.arguments);
3355 } else { 3361 } else {
3356 push(buildInvokeSuper(selector, element, inputs)); 3362 addGenericSendArgumentsToList(node.arguments, inputs);
3363 generateSuperNoSuchMethodSend(node, selector, inputs);
3357 } 3364 }
3358 } else { 3365 } else {
3359 HInstruction target = buildInvokeSuper(selector, element, inputs); 3366 HInstruction target = buildInvokeSuper(selector, element, inputs);
3360 add(target); 3367 add(target);
3361 inputs = <HInstruction>[target]; 3368 inputs = <HInstruction>[target];
3362 addDynamicSendArgumentsToList(node, inputs); 3369 addDynamicSendArgumentsToList(node, inputs);
3363 Selector closureSelector = new Selector.callClosureFrom(selector); 3370 Selector closureSelector = new Selector.callClosureFrom(selector);
3364 push(new HInvokeClosure(closureSelector, inputs)); 3371 push(new HInvokeClosure(closureSelector, inputs));
3365 } 3372 }
3366 } 3373 }
(...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after
3922 inputs.add(invokeInterceptor(receiver)); 3929 inputs.add(invokeInterceptor(receiver));
3923 } 3930 }
3924 inputs.add(receiver); 3931 inputs.add(receiver);
3925 inputs.addAll(arguments); 3932 inputs.addAll(arguments);
3926 HInstruction instruction = new HInvokeSuper( 3933 HInstruction instruction = new HInvokeSuper(
3927 element, 3934 element,
3928 currentNonClosureClass, 3935 currentNonClosureClass,
3929 selector, 3936 selector,
3930 inputs, 3937 inputs,
3931 isSetter: selector.isSetter() || selector.isIndexSet()); 3938 isSetter: selector.isSetter() || selector.isIndexSet());
3932 instruction.instructionType = 3939 if (element.isField() && selector.isGetter()) {
3933 new HType.inferredReturnTypeForElement(element, compiler); 3940 instruction.instructionType =
3941 new HType.inferredTypeForElement(element, compiler);
3942 } else {
3943 instruction.instructionType =
3944 new HType.inferredReturnTypeForElement(element, compiler);
3945 }
3934 instruction.sideEffects = compiler.world.getSideEffectsOfElement(element); 3946 instruction.sideEffects = compiler.world.getSideEffectsOfElement(element);
3935 return instruction; 3947 return instruction;
3936 } 3948 }
3937 3949
3938 void handleComplexOperatorSend(SendSet node, 3950 void handleComplexOperatorSend(SendSet node,
3939 HInstruction receiver, 3951 HInstruction receiver,
3940 Link<Node> arguments) { 3952 Link<Node> arguments) {
3941 HInstruction rhs; 3953 HInstruction rhs;
3942 if (node.isPrefix || node.isPostfix) { 3954 if (node.isPrefix || node.isPostfix) {
3943 rhs = graph.addConstantInt(1, compiler); 3955 rhs = graph.addConstantInt(1, compiler);
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
3997 handleComplexOperatorSend(node, getterInstruction, arguments); 4009 handleComplexOperatorSend(node, getterInstruction, arguments);
3998 setterInputs.add(pop()); 4010 setterInputs.add(pop());
3999 4011
4000 if (node.isPostfix) { 4012 if (node.isPostfix) {
4001 result = getterInstruction; 4013 result = getterInstruction;
4002 } else { 4014 } else {
4003 result = setterInputs.last; 4015 result = setterInputs.last;
4004 } 4016 }
4005 } 4017 }
4006 Selector setterSelector = elements.getSelector(node); 4018 Selector setterSelector = elements.getSelector(node);
4007 if (Elements.isUnresolved(element)) { 4019 if (Elements.isUnresolved(element)
4020 || !setterSelector.applies(element, compiler)) {
4008 generateSuperNoSuchMethodSend( 4021 generateSuperNoSuchMethodSend(
4009 node, setterSelector, setterInputs); 4022 node, setterSelector, setterInputs);
4010 pop(); 4023 pop();
4011 } else { 4024 } else {
4012 add(buildInvokeSuper(setterSelector, element, setterInputs)); 4025 add(buildInvokeSuper(setterSelector, element, setterInputs));
4013 } 4026 }
4014 stack.add(result); 4027 stack.add(result);
4015 } else if (node.isIndex) { 4028 } else if (node.isIndex) {
4016 if (const SourceString("=") == op.source) { 4029 if (const SourceString("=") == op.source) {
4017 visitDynamicSend(node); 4030 visitDynamicSend(node);
(...skipping 1523 matching lines...) Expand 10 before | Expand all | Expand 10 after
5541 new HSubGraphBlockInformation(elseBranch.graph)); 5554 new HSubGraphBlockInformation(elseBranch.graph));
5542 5555
5543 HBasicBlock conditionStartBlock = conditionBranch.block; 5556 HBasicBlock conditionStartBlock = conditionBranch.block;
5544 conditionStartBlock.setBlockFlow(info, joinBlock); 5557 conditionStartBlock.setBlockFlow(info, joinBlock);
5545 SubGraph conditionGraph = conditionBranch.graph; 5558 SubGraph conditionGraph = conditionBranch.graph;
5546 HIf branch = conditionGraph.end.last; 5559 HIf branch = conditionGraph.end.last;
5547 assert(branch is HIf); 5560 assert(branch is HIf);
5548 branch.blockInformation = conditionStartBlock.blockFlow; 5561 branch.blockInformation = conditionStartBlock.blockFlow;
5549 } 5562 }
5550 } 5563 }
OLDNEW
« no previous file with comments | « no previous file | sdk/lib/_internal/compiler/implementation/types/type_graph_inferrer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698