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

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

Issue 10949003: Revert r12491 (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 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
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 1224 matching lines...) Expand 10 before | Expand all | Expand 10 after
1235 includeBackendMembers: true, 1235 includeBackendMembers: true,
1236 includeSuperMembers: true, 1236 includeSuperMembers: true,
1237 f: (ClassElement enclosingClass, Element member) { 1237 f: (ClassElement enclosingClass, Element member) {
1238 constructorArguments.add( 1238 constructorArguments.add(
1239 potentiallyCheckType(fieldValues[member], member)); 1239 potentiallyCheckType(fieldValues[member], member));
1240 }); 1240 });
1241 1241
1242 HForeignNew newObject = new HForeignNew(classElement, constructorArguments); 1242 HForeignNew newObject = new HForeignNew(classElement, constructorArguments);
1243 add(newObject); 1243 add(newObject);
1244 1244
1245 // Create the runtime type information, if needed. 1245 // If the class has type variables, create the runtime type
1246 // information with the type parameters provided.
1246 InterfaceType type = classElement.computeType(compiler); 1247 InterfaceType type = classElement.computeType(compiler);
1247 List<HInstruction> inputs = <HInstruction>[]; 1248 if (compiler.world.needsRti(type.element)) {
1248 if (compiler.world.needsRti(classElement)) { 1249 List<HInstruction> rtiInputs = <HInstruction>[];
1249 classElement.typeVariables.forEach((TypeVariableType typeVariable) { 1250 classElement.typeVariables.forEach((TypeVariableType typeVariable) {
1250 inputs.add(localsHandler.directLocals[typeVariable.element]); 1251 rtiInputs.add(localsHandler.directLocals[typeVariable.element]);
1251 }); 1252 });
1252 callSetRuntimeTypeInfo(classElement, inputs, newObject); 1253 callSetRuntimeTypeInfo(classElement, rtiInputs, newObject);
1253 } 1254 }
1254 1255
1255 // Generate calls to the constructor bodies. 1256 // Generate calls to the constructor bodies.
1256 for (int index = constructors.length - 1; index >= 0; index--) { 1257 for (int index = constructors.length - 1; index >= 0; index--) {
1257 FunctionElement constructor = constructors[index]; 1258 FunctionElement constructor = constructors[index];
1258 ConstructorBodyElement body = getConstructorBody(constructor); 1259 ConstructorBodyElement body = getConstructorBody(constructor);
1259 if (body === null) continue; 1260 if (body === null) continue;
1260 List bodyCallInputs = <HInstruction>[]; 1261 List bodyCallInputs = <HInstruction>[];
1261 bodyCallInputs.add(newObject); 1262 bodyCallInputs.add(newObject);
1262 int arity = body.functionSignature.parameterCount; 1263 int arity = body.functionSignature.parameterCount;
(...skipping 1380 matching lines...) Expand 10 before | Expand all | Expand 10 after
2643 } else { 2644 } else {
2644 // The type variable is a type (e.g. int). 2645 // The type variable is a type (e.g. int).
2645 return graph.addConstantString( 2646 return graph.addConstantString(
2646 new LiteralDartString('$argument'), currentNode, constantSystem); 2647 new LiteralDartString('$argument'), currentNode, constantSystem);
2647 } 2648 }
2648 } 2649 }
2649 2650
2650 void handleListConstructor(InterfaceType type, 2651 void handleListConstructor(InterfaceType type,
2651 Node currentNode, 2652 Node currentNode,
2652 HInstruction newObject) { 2653 HInstruction newObject) {
2653 if (!compiler.world.needsRti(type.element)) return; 2654 if (type.arguments.isEmpty()) return;
2654 List<HInstruction> inputs = <HInstruction>[]; 2655 List<HInstruction> inputs = <HInstruction>[];
2655 type.arguments.forEach((DartType argument) { 2656 type.arguments.forEach((DartType argument) {
2656 inputs.add(analyzeTypeArgument(argument, currentNode)); 2657 inputs.add(analyzeTypeArgument(argument, currentNode));
2657 }); 2658 });
2658 callSetRuntimeTypeInfo(type.element, inputs, newObject); 2659 callSetRuntimeTypeInfo(type.element, inputs, newObject);
2659 } 2660 }
2660 2661
2661 void callSetRuntimeTypeInfo(ClassElement element, 2662 void callSetRuntimeTypeInfo(ClassElement element,
2662 List<HInstruction> rtiInputs, 2663 List<HInstruction> inputs,
2663 HInstruction newObject) { 2664 HInstruction newObject) {
2664 bool needsRti = compiler.world.needsRti(element); 2665 List<String> typeVariables = <String>[];
2665 bool runtimeTypeIsUsed = compiler.enabledRuntimeType; 2666 element.typeVariables.forEach((TypeVariableType typeVariable) {
2667 typeVariables.add("'$typeVariable': #");
2668 });
2666 2669
2667 HInstruction createForeign(String template, 2670 String jsCode = '{ ${Strings.join(typeVariables, ', ')} }';
2668 List<HInstruction> arguments, 2671 HInstruction typeInfo = new HForeign(new LiteralDartString(jsCode),
2669 [String type = 'String']) { 2672 new LiteralDartString('Object'),
2670 return new HForeign(new LiteralDartString(template), 2673 inputs);
2671 new LiteralDartString(type), 2674 add(typeInfo);
2672 arguments);
2673 }
2674
2675 // Construct the runtime type information.
2676 StringBuffer runtimeCode = new StringBuffer();
2677 List<HInstruction> runtimeCodeInputs = <HInstruction>[];
2678 if (runtimeTypeIsUsed) {
2679 String runtimeTypeString =
2680 RuntimeTypeInformation.generateRuntimeTypeString(element,
2681 rtiInputs.length);
2682 HInstruction runtimeType = createForeign(runtimeTypeString, rtiInputs);
2683 add(runtimeType);
2684 runtimeCodeInputs.add(runtimeType);
2685 runtimeCode.add('runtimeType: #');
2686 }
2687 if (needsRti) {
2688 if (runtimeTypeIsUsed) runtimeCode.add(', ');
2689 String typeVariablesString =
2690 RuntimeTypeInformation.generateTypeVariableString(element,
2691 rtiInputs.length);
2692 HInstruction typeInfo = createForeign(typeVariablesString, rtiInputs);
2693 add(typeInfo);
2694 runtimeCodeInputs.add(typeInfo);
2695 runtimeCode.add('#');
2696 }
2697 HInstruction runtimeInfo =
2698 createForeign("{$runtimeCode}", runtimeCodeInputs, 'Object');
2699 add(runtimeInfo);
2700
2701 // Set the runtime type information on the object.
2702 Element typeInfoSetterElement = interceptors.getSetRuntimeTypeInfo(); 2675 Element typeInfoSetterElement = interceptors.getSetRuntimeTypeInfo();
2703 HInstruction typeInfoSetter = new HStatic(typeInfoSetterElement); 2676 HInstruction typeInfoSetter = new HStatic(typeInfoSetterElement);
2704 add(typeInfoSetter); 2677 add(typeInfoSetter);
2705 add(new HInvokeStatic( 2678 add(new HInvokeStatic(<HInstruction>[typeInfoSetter, newObject, typeInfo]));
2706 <HInstruction>[typeInfoSetter, newObject, runtimeInfo]));
2707 } 2679 }
2708 2680
2709 visitNewSend(Send node) { 2681 visitNewSend(Send node) {
2710 bool isListConstructor = false; 2682 bool isListConstructor = false;
2711 computeType(element) { 2683 computeType(element) {
2712 Element originalElement = elements[node]; 2684 Element originalElement = elements[node];
2713 if (originalElement.getEnclosingClass() === compiler.listClass) { 2685 if (originalElement.getEnclosingClass() === compiler.listClass) {
2714 isListConstructor = true; 2686 isListConstructor = true;
2715 if (node.arguments.isEmpty()) { 2687 if (node.arguments.isEmpty()) {
2716 return HType.EXTENDABLE_ARRAY; 2688 return HType.EXTENDABLE_ARRAY;
(...skipping 1514 matching lines...) Expand 10 before | Expand all | Expand 10 after
4231 new HSubGraphBlockInformation(elseBranch.graph)); 4203 new HSubGraphBlockInformation(elseBranch.graph));
4232 4204
4233 HBasicBlock conditionStartBlock = conditionBranch.block; 4205 HBasicBlock conditionStartBlock = conditionBranch.block;
4234 conditionStartBlock.setBlockFlow(info, joinBlock); 4206 conditionStartBlock.setBlockFlow(info, joinBlock);
4235 SubGraph conditionGraph = conditionBranch.graph; 4207 SubGraph conditionGraph = conditionBranch.graph;
4236 HIf branch = conditionGraph.end.last; 4208 HIf branch = conditionGraph.end.last;
4237 assert(branch is HIf); 4209 assert(branch is HIf);
4238 branch.blockInformation = conditionStartBlock.blockFlow; 4210 branch.blockInformation = conditionStartBlock.blockFlow;
4239 } 4211 }
4240 } 4212 }
OLDNEW
« no previous file with comments | « lib/compiler/implementation/lib/js_helper.dart ('k') | lib/compiler/implementation/ssa/ssa.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698