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

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

Issue 22903036: Use predicates to check simple function types. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Small updates. Created 7 years, 4 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 1758 matching lines...) Expand 10 before | Expand all | Expand 10 after
1769 HInstruction representations = buildTypeArgumentRepresentations(type); 1769 HInstruction representations = buildTypeArgumentRepresentations(type);
1770 add(representations); 1770 add(representations);
1771 return new HTypeConversion.withTypeRepresentation(type, kind, subtype, 1771 return new HTypeConversion.withTypeRepresentation(type, kind, subtype,
1772 original, representations); 1772 original, representations);
1773 } else if (type.kind == TypeKind.TYPE_VARIABLE) { 1773 } else if (type.kind == TypeKind.TYPE_VARIABLE) {
1774 HType subtype = original.instructionType; 1774 HType subtype = original.instructionType;
1775 HInstruction typeVariable = addTypeVariableReference(type); 1775 HInstruction typeVariable = addTypeVariableReference(type);
1776 return new HTypeConversion.withTypeRepresentation(type, kind, subtype, 1776 return new HTypeConversion.withTypeRepresentation(type, kind, subtype,
1777 original, typeVariable); 1777 original, typeVariable);
1778 } else if (type.kind == TypeKind.FUNCTION) { 1778 } else if (type.kind == TypeKind.FUNCTION) {
1779 FunctionType functionType = type;
1780 if (functionType.isSimple) {
1781 return original.convertType(compiler, type, kind);
1782 }
1779 HType subtype = original.instructionType; 1783 HType subtype = original.instructionType;
1780 if (type.containsTypeVariables) { 1784 if (type.containsTypeVariables) {
1781 bool contextIsTypeArguments = false; 1785 bool contextIsTypeArguments = false;
1782 HInstruction context; 1786 HInstruction context;
1783 if (currentElement.isInstanceMember()) { 1787 if (currentElement.isInstanceMember()) {
1784 context = localsHandler.readThis(); 1788 context = localsHandler.readThis();
1785 } else { 1789 } else {
1786 ClassElement contextClass = Types.getClassContext(type); 1790 ClassElement contextClass = Types.getClassContext(type);
1787 context = buildTypeVariableList(contextClass); 1791 context = buildTypeVariableList(contextClass);
1788 add(context); 1792 add(context);
(...skipping 998 matching lines...) Expand 10 before | Expand all | Expand 10 after
2787 !link.isEmpty; 2791 !link.isEmpty;
2788 link = link.tail) { 2792 link = link.tail) {
2789 inputs.add(addTypeVariableReference(link.head)); 2793 inputs.add(addTypeVariableReference(link.head));
2790 } 2794 }
2791 return buildLiteralList(inputs); 2795 return buildLiteralList(inputs);
2792 } 2796 }
2793 2797
2794 HInstruction buildIsNode(Node node, DartType type, HInstruction expression) { 2798 HInstruction buildIsNode(Node node, DartType type, HInstruction expression) {
2795 type = type.unalias(compiler); 2799 type = type.unalias(compiler);
2796 if (type.kind == TypeKind.FUNCTION) { 2800 if (type.kind == TypeKind.FUNCTION) {
2801 FunctionType functionType = type;
2802 if (functionType.isSimple) {
2803 return new HIs(type, <HInstruction>[expression], HIs.RAW_CHECK);
2804 }
2797 Element checkFunctionSubtype = backend.getCheckFunctionSubtype(); 2805 Element checkFunctionSubtype = backend.getCheckFunctionSubtype();
2798 2806
2799 HInstruction signatureName = graph.addConstantString( 2807 HInstruction signatureName = graph.addConstantString(
2800 new DartString.literal(backend.namer.getFunctionTypeName(type)), 2808 new DartString.literal(backend.namer.getFunctionTypeName(type)),
2801 node, compiler); 2809 node, compiler);
2802 2810
2803 HInstruction contextName; 2811 HInstruction contextName;
2804 HInstruction context; 2812 HInstruction context;
2805 HInstruction typeArguments; 2813 HInstruction typeArguments;
2806 if (type.containsTypeVariables) { 2814 if (type.containsTypeVariables) {
(...skipping 2656 matching lines...) Expand 10 before | Expand all | Expand 10 after
5463 new HSubGraphBlockInformation(elseBranch.graph)); 5471 new HSubGraphBlockInformation(elseBranch.graph));
5464 5472
5465 HBasicBlock conditionStartBlock = conditionBranch.block; 5473 HBasicBlock conditionStartBlock = conditionBranch.block;
5466 conditionStartBlock.setBlockFlow(info, joinBlock); 5474 conditionStartBlock.setBlockFlow(info, joinBlock);
5467 SubGraph conditionGraph = conditionBranch.graph; 5475 SubGraph conditionGraph = conditionBranch.graph;
5468 HIf branch = conditionGraph.end.last; 5476 HIf branch = conditionGraph.end.last;
5469 assert(branch is HIf); 5477 assert(branch is HIf);
5470 branch.blockInformation = conditionStartBlock.blockFlow; 5478 branch.blockInformation = conditionStartBlock.blockFlow;
5471 } 5479 }
5472 } 5480 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698