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

Unified 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/compiler/implementation/ssa/builder.dart
===================================================================
--- lib/compiler/implementation/ssa/builder.dart (revision 12499)
+++ lib/compiler/implementation/ssa/builder.dart (working copy)
@@ -1242,14 +1242,15 @@
HForeignNew newObject = new HForeignNew(classElement, constructorArguments);
add(newObject);
- // Create the runtime type information, if needed.
+ // If the class has type variables, create the runtime type
+ // information with the type parameters provided.
InterfaceType type = classElement.computeType(compiler);
- List<HInstruction> inputs = <HInstruction>[];
- if (compiler.world.needsRti(classElement)) {
+ if (compiler.world.needsRti(type.element)) {
+ List<HInstruction> rtiInputs = <HInstruction>[];
classElement.typeVariables.forEach((TypeVariableType typeVariable) {
- inputs.add(localsHandler.directLocals[typeVariable.element]);
+ rtiInputs.add(localsHandler.directLocals[typeVariable.element]);
});
- callSetRuntimeTypeInfo(classElement, inputs, newObject);
+ callSetRuntimeTypeInfo(classElement, rtiInputs, newObject);
}
// Generate calls to the constructor bodies.
@@ -2650,7 +2651,7 @@
void handleListConstructor(InterfaceType type,
Node currentNode,
HInstruction newObject) {
- if (!compiler.world.needsRti(type.element)) return;
+ if (type.arguments.isEmpty()) return;
List<HInstruction> inputs = <HInstruction>[];
type.arguments.forEach((DartType argument) {
inputs.add(analyzeTypeArgument(argument, currentNode));
@@ -2659,51 +2660,22 @@
}
void callSetRuntimeTypeInfo(ClassElement element,
- List<HInstruction> rtiInputs,
+ List<HInstruction> inputs,
HInstruction newObject) {
- bool needsRti = compiler.world.needsRti(element);
- bool runtimeTypeIsUsed = compiler.enabledRuntimeType;
+ List<String> typeVariables = <String>[];
+ element.typeVariables.forEach((TypeVariableType typeVariable) {
+ typeVariables.add("'$typeVariable': #");
+ });
- HInstruction createForeign(String template,
- List<HInstruction> arguments,
- [String type = 'String']) {
- return new HForeign(new LiteralDartString(template),
- new LiteralDartString(type),
- arguments);
- }
-
- // Construct the runtime type information.
- StringBuffer runtimeCode = new StringBuffer();
- List<HInstruction> runtimeCodeInputs = <HInstruction>[];
- if (runtimeTypeIsUsed) {
- String runtimeTypeString =
- RuntimeTypeInformation.generateRuntimeTypeString(element,
- rtiInputs.length);
- HInstruction runtimeType = createForeign(runtimeTypeString, rtiInputs);
- add(runtimeType);
- runtimeCodeInputs.add(runtimeType);
- runtimeCode.add('runtimeType: #');
- }
- if (needsRti) {
- if (runtimeTypeIsUsed) runtimeCode.add(', ');
- String typeVariablesString =
- RuntimeTypeInformation.generateTypeVariableString(element,
- rtiInputs.length);
- HInstruction typeInfo = createForeign(typeVariablesString, rtiInputs);
- add(typeInfo);
- runtimeCodeInputs.add(typeInfo);
- runtimeCode.add('#');
- }
- HInstruction runtimeInfo =
- createForeign("{$runtimeCode}", runtimeCodeInputs, 'Object');
- add(runtimeInfo);
-
- // Set the runtime type information on the object.
+ String jsCode = '{ ${Strings.join(typeVariables, ', ')} }';
+ HInstruction typeInfo = new HForeign(new LiteralDartString(jsCode),
+ new LiteralDartString('Object'),
+ inputs);
+ add(typeInfo);
Element typeInfoSetterElement = interceptors.getSetRuntimeTypeInfo();
HInstruction typeInfoSetter = new HStatic(typeInfoSetterElement);
add(typeInfoSetter);
- add(new HInvokeStatic(
- <HInstruction>[typeInfoSetter, newObject, runtimeInfo]));
+ add(new HInvokeStatic(<HInstruction>[typeInfoSetter, newObject, typeInfo]));
}
visitNewSend(Send node) {
« 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