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

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

Issue 11086074: Give different runtime type representations to different types with the same name. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 2 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 class Interceptors { 5 class Interceptors {
6 Compiler compiler; 6 Compiler compiler;
7 Interceptors(Compiler this.compiler); 7 Interceptors(Compiler this.compiler);
8 8
9 SourceString mapOperatorToMethodName(Operator op) { 9 SourceString mapOperatorToMethodName(Operator op) {
10 String name = op.source.stringValue; 10 String name = op.source.stringValue;
(...skipping 835 matching lines...) Expand 10 before | Expand all | Expand 10 after
846 final SsaBuilderTask builder; 846 final SsaBuilderTask builder;
847 final JavaScriptBackend backend; 847 final JavaScriptBackend backend;
848 final Interceptors interceptors; 848 final Interceptors interceptors;
849 final WorkItem work; 849 final WorkItem work;
850 final ConstantSystem constantSystem; 850 final ConstantSystem constantSystem;
851 bool methodInterceptionEnabled; 851 bool methodInterceptionEnabled;
852 HGraph graph; 852 HGraph graph;
853 LocalsHandler localsHandler; 853 LocalsHandler localsHandler;
854 HInstruction rethrowableException; 854 HInstruction rethrowableException;
855 Map<Element, HParameterValue> parameters; 855 Map<Element, HParameterValue> parameters;
856 final RuntimeTypeInformation rti;
856 857
857 Map<TargetElement, JumpHandler> jumpTargets; 858 Map<TargetElement, JumpHandler> jumpTargets;
858 859
859 /** 860 /**
860 * Variables stored in the current activation. These variables are 861 * Variables stored in the current activation. These variables are
861 * being updated in try/catch blocks, and should be 862 * being updated in try/catch blocks, and should be
862 * accessed indirectly through [HLocalGet] and [HLocalSet]. 863 * accessed indirectly through [HLocalGet] and [HLocalSet].
863 */ 864 */
864 Map<Element, HLocalValue> activationVariables; 865 Map<Element, HLocalValue> activationVariables;
865 866
(...skipping 21 matching lines...) Expand all
887 this.work = work, 888 this.work = work,
888 interceptors = builder.interceptors, 889 interceptors = builder.interceptors,
889 methodInterceptionEnabled = true, 890 methodInterceptionEnabled = true,
890 graph = new HGraph(), 891 graph = new HGraph(),
891 stack = new List<HInstruction>(), 892 stack = new List<HInstruction>(),
892 activationVariables = new Map<Element, HLocalValue>(), 893 activationVariables = new Map<Element, HLocalValue>(),
893 jumpTargets = new Map<TargetElement, JumpHandler>(), 894 jumpTargets = new Map<TargetElement, JumpHandler>(),
894 parameters = new Map<Element, HParameterValue>(), 895 parameters = new Map<Element, HParameterValue>(),
895 sourceElementStack = <Element>[work.element], 896 sourceElementStack = <Element>[work.element],
896 inliningStack = <InliningState>[], 897 inliningStack = <InliningState>[],
898 rti = builder.compiler.codegenWorld.rti,
897 super(work.resolutionTree) { 899 super(work.resolutionTree) {
898 localsHandler = new LocalsHandler(this); 900 localsHandler = new LocalsHandler(this);
899 } 901 }
900 902
901 static const MAX_INLINING_DEPTH = 3; 903 static const MAX_INLINING_DEPTH = 3;
902 static const MAX_INLINING_SOURCE_SIZE = 100; 904 static const MAX_INLINING_SOURCE_SIZE = 100;
903 List<InliningState> inliningStack; 905 List<InliningState> inliningStack;
904 Element returnElement = null; 906 Element returnElement = null;
905 907
906 void disableMethodInterception() { 908 void disableMethodInterception() {
(...skipping 1878 matching lines...) Expand 10 before | Expand all | Expand 10 after
2785 */ 2787 */
2786 void buildTypeString(DartType type, {isInQuotes: false}) { 2788 void buildTypeString(DartType type, {isInQuotes: false}) {
2787 if (type is TypeVariableType) { 2789 if (type is TypeVariableType) {
2788 addTypeVariableReference(type); 2790 addTypeVariableReference(type);
2789 template.add(isInQuotes ? "' + # +'" : "#"); 2791 template.add(isInQuotes ? "' + # +'" : "#");
2790 } else if (type is InterfaceType) { 2792 } else if (type is InterfaceType) {
2791 bool isFirstVariable = true; 2793 bool isFirstVariable = true;
2792 InterfaceType interfaceType = type; 2794 InterfaceType interfaceType = type;
2793 bool hasTypeArguments = !interfaceType.arguments.isEmpty(); 2795 bool hasTypeArguments = !interfaceType.arguments.isEmpty();
2794 if (!isInQuotes) template.add("'"); 2796 if (!isInQuotes) template.add("'");
2795 template.add("${type.element.name.slowToString()}"); 2797 template.add(rti.getName(type.element));
2796 if (hasTypeArguments) { 2798 if (hasTypeArguments) {
2797 template.add("<"); 2799 template.add("<");
2798 for (DartType argument in interfaceType.arguments) { 2800 for (DartType argument in interfaceType.arguments) {
2799 if (!isFirstVariable) { 2801 if (!isFirstVariable) {
2800 template.add(", "); 2802 template.add(", ");
2801 } else { 2803 } else {
2802 isFirstVariable = false; 2804 isFirstVariable = false;
2803 } 2805 }
2804 buildTypeString(argument, isInQuotes: true); 2806 buildTypeString(argument, isInQuotes: true);
2805 } 2807 }
2806 template.add(">"); 2808 template.add(">");
2807 } 2809 }
2808 if (!isInQuotes) template.add("'"); 2810 if (!isInQuotes) template.add("'");
2809 } else { 2811 } else {
2810 assert(type is TypedefType); 2812 assert(type is TypedefType);
2811 if (!isInQuotes) template.add("'"); 2813 if (!isInQuotes) template.add("'");
2812 template.add(argument.toString()); 2814 template.add(rti.getName(argument.element));
2813 if (!isInQuotes) template.add("'"); 2815 if (!isInQuotes) template.add("'");
2814 } 2816 }
2815 } 2817 }
2816 2818
2817 buildTypeString(argument, isInQuotes: false); 2819 buildTypeString(argument, isInQuotes: false);
2818 HInstruction result = 2820 HInstruction result =
2819 new HForeign(new LiteralDartString("$template"), 2821 new HForeign(new LiteralDartString("$template"),
2820 new LiteralDartString('String'), 2822 new LiteralDartString('String'),
2821 inputs); 2823 inputs);
2822 add(result); 2824 add(result);
(...skipping 24 matching lines...) Expand all
2847 return new HForeign(new LiteralDartString(template), 2849 return new HForeign(new LiteralDartString(template),
2848 new LiteralDartString(type), 2850 new LiteralDartString(type),
2849 arguments); 2851 arguments);
2850 } 2852 }
2851 2853
2852 // Construct the runtime type information. 2854 // Construct the runtime type information.
2853 StringBuffer runtimeCode = new StringBuffer(); 2855 StringBuffer runtimeCode = new StringBuffer();
2854 List<HInstruction> runtimeCodeInputs = <HInstruction>[]; 2856 List<HInstruction> runtimeCodeInputs = <HInstruction>[];
2855 if (runtimeTypeIsUsed) { 2857 if (runtimeTypeIsUsed) {
2856 String runtimeTypeString = 2858 String runtimeTypeString =
2857 RuntimeTypeInformation.generateRuntimeTypeString(element, 2859 rti.generateRuntimeTypeString(element, rtiInputs.length);
2858 rtiInputs.length);
2859 HInstruction runtimeType = createForeign(runtimeTypeString, rtiInputs); 2860 HInstruction runtimeType = createForeign(runtimeTypeString, rtiInputs);
2860 add(runtimeType); 2861 add(runtimeType);
2861 runtimeCodeInputs.add(runtimeType); 2862 runtimeCodeInputs.add(runtimeType);
2862 runtimeCode.add('runtimeType: #'); 2863 runtimeCode.add('runtimeType: #');
2863 } 2864 }
2864 if (needsRti) { 2865 if (needsRti) {
2865 if (runtimeTypeIsUsed) runtimeCode.add(', '); 2866 if (runtimeTypeIsUsed) runtimeCode.add(', ');
2866 String typeVariablesString = 2867 String typeVariablesString =
2867 RuntimeTypeInformation.generateTypeVariableString(element, 2868 RuntimeTypeInformation.generateTypeVariableString(element,
2868 rtiInputs.length); 2869 rtiInputs.length);
(...skipping 1585 matching lines...) Expand 10 before | Expand all | Expand 10 after
4454 new HSubGraphBlockInformation(elseBranch.graph)); 4455 new HSubGraphBlockInformation(elseBranch.graph));
4455 4456
4456 HBasicBlock conditionStartBlock = conditionBranch.block; 4457 HBasicBlock conditionStartBlock = conditionBranch.block;
4457 conditionStartBlock.setBlockFlow(info, joinBlock); 4458 conditionStartBlock.setBlockFlow(info, joinBlock);
4458 SubGraph conditionGraph = conditionBranch.graph; 4459 SubGraph conditionGraph = conditionBranch.graph;
4459 HIf branch = conditionGraph.end.last; 4460 HIf branch = conditionGraph.end.last;
4460 assert(branch is HIf); 4461 assert(branch is HIf);
4461 branch.blockInformation = conditionStartBlock.blockFlow; 4462 branch.blockInformation = conditionStartBlock.blockFlow;
4462 } 4463 }
4463 } 4464 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698