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

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

Issue 12211112: Start work on a non-complete type inferrer. Currently only analyzes return types. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 10 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
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 3347 matching lines...) Expand 10 before | Expand all | Expand 10 after
3358 generateWrongArgumentCountError(node, element, node.arguments); 3358 generateWrongArgumentCountError(node, element, node.arguments);
3359 return; 3359 return;
3360 } 3360 }
3361 3361
3362 if (isIdenticalFunction) { 3362 if (isIdenticalFunction) {
3363 pushWithPosition(new HIdentity(inputs[1], inputs[2]), node); 3363 pushWithPosition(new HIdentity(inputs[1], inputs[2]), node);
3364 return; 3364 return;
3365 } 3365 }
3366 3366
3367 HInvokeStatic instruction = new HInvokeStatic(inputs, HType.UNKNOWN); 3367 HInvokeStatic instruction = new HInvokeStatic(inputs, HType.UNKNOWN);
3368 // TODO(ngeoffray): Only do this if knowing the return type is 3368 // TODO(ngeoffray): Only do this if knowing the return type is
kasperl 2013/02/12 10:33:44 Move TODO to recompilation branch.
ngeoffray 2013/02/12 11:58:22 Done.
3369 // useful. 3369 // useful.
3370 HType returnType = 3370 HType returnType = mapInferredType(
kasperl 2013/02/12 10:33:44 Maybe add a helper for getting the guaranteed HTyp
ngeoffray 2013/02/12 11:58:22 Done.
3371 builder.backend.optimisticReturnTypesWithRecompilationOnTypeChange( 3371 compiler.typesTask.getGuaranteedTypeOfElement(element));
3372 currentElement, element); 3372 if (returnType.isUnknown()) {
3373 returnType =
3374 builder.backend.optimisticReturnTypesWithRecompilationOnTypeChange(
3375 currentElement, element);
3376 }
3373 if (returnType != null) instruction.guaranteedType = returnType; 3377 if (returnType != null) instruction.guaranteedType = returnType;
3374 pushWithPosition(instruction, node); 3378 pushWithPosition(instruction, node);
3375 } else { 3379 } else {
3376 generateGetter(node, element); 3380 generateGetter(node, element);
3377 List<HInstruction> inputs = <HInstruction>[pop()]; 3381 List<HInstruction> inputs = <HInstruction>[pop()];
3378 addDynamicSendArgumentsToList(node, inputs); 3382 addDynamicSendArgumentsToList(node, inputs);
3379 Selector closureSelector = new Selector.callClosureFrom(selector); 3383 Selector closureSelector = new Selector.callClosureFrom(selector);
3380 pushWithPosition(new HInvokeClosure(closureSelector, inputs), node); 3384 pushWithPosition(new HInvokeClosure(closureSelector, inputs), node);
3381 } 3385 }
3382 } 3386 }
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
3554 List<HInstruction> arguments) { 3558 List<HInstruction> arguments) {
3555 Set<ClassElement> interceptedClasses = getInterceptedClassesOn(selector); 3559 Set<ClassElement> interceptedClasses = getInterceptedClassesOn(selector);
3556 List<HInstruction> inputs = <HInstruction>[]; 3560 List<HInstruction> inputs = <HInstruction>[];
3557 bool isIntercepted = interceptedClasses != null; 3561 bool isIntercepted = interceptedClasses != null;
3558 if (isIntercepted) { 3562 if (isIntercepted) {
3559 assert(!interceptedClasses.isEmpty); 3563 assert(!interceptedClasses.isEmpty);
3560 inputs.add(invokeInterceptor(interceptedClasses, receiver, node)); 3564 inputs.add(invokeInterceptor(interceptedClasses, receiver, node));
3561 } 3565 }
3562 inputs.add(receiver); 3566 inputs.add(receiver);
3563 inputs.addAll(arguments); 3567 inputs.addAll(arguments);
3564 return new HInvokeDynamicMethod(selector, inputs, isIntercepted); 3568 HInstruction invoke = new HInvokeDynamicMethod(
3569 selector, inputs, isIntercepted);
3570 HType returnType = mapInferredType(
3571 compiler.typesTask.getGuaranteedTypeOfNode(work.element, node));
3572 if (returnType != null) {
3573 invoke.guaranteedType = returnType;
3574 }
3575 return invoke;
3565 } 3576 }
3566 3577
3567 visitSendSet(SendSet node) { 3578 visitSendSet(SendSet node) {
3568 Element element = elements[node]; 3579 Element element = elements[node];
3569 if (!Elements.isUnresolved(element) && element.impliesType()) { 3580 if (!Elements.isUnresolved(element) && element.impliesType()) {
3570 Identifier selector = node.selector; 3581 Identifier selector = node.selector;
3571 generateThrowNoSuchMethod(node, selector.source.slowToString(), 3582 generateThrowNoSuchMethod(node, selector.source.slowToString(),
3572 argumentNodes: node.arguments); 3583 argumentNodes: node.arguments);
3573 return; 3584 return;
3574 } 3585 }
(...skipping 1476 matching lines...) Expand 10 before | Expand all | Expand 10 after
5051 new HSubGraphBlockInformation(elseBranch.graph)); 5062 new HSubGraphBlockInformation(elseBranch.graph));
5052 5063
5053 HBasicBlock conditionStartBlock = conditionBranch.block; 5064 HBasicBlock conditionStartBlock = conditionBranch.block;
5054 conditionStartBlock.setBlockFlow(info, joinBlock); 5065 conditionStartBlock.setBlockFlow(info, joinBlock);
5055 SubGraph conditionGraph = conditionBranch.graph; 5066 SubGraph conditionGraph = conditionBranch.graph;
5056 HIf branch = conditionGraph.end.last; 5067 HIf branch = conditionGraph.end.last;
5057 assert(branch is HIf); 5068 assert(branch is HIf);
5058 branch.blockInformation = conditionStartBlock.blockFlow; 5069 branch.blockInformation = conditionStartBlock.blockFlow;
5059 } 5070 }
5060 } 5071 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698