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

Unified Diff: dart/sdk/lib/_internal/compiler/implementation/js_emitter/class_emitter.dart

Issue 57773002: Repro for OOM bug in test.dart (applies to r29345). (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 1 month 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
Index: dart/sdk/lib/_internal/compiler/implementation/js_emitter/class_emitter.dart
diff --git a/dart/sdk/lib/_internal/compiler/implementation/js_emitter/class_emitter.dart b/dart/sdk/lib/_internal/compiler/implementation/js_emitter/class_emitter.dart
index 53285fd7cd97b9cf0f03e28ebc2a9063c19b34d4..dbf20b8167c6f0121b3637b232aba146dbade109 100644
--- a/dart/sdk/lib/_internal/compiler/implementation/js_emitter/class_emitter.dart
+++ b/dart/sdk/lib/_internal/compiler/implementation/js_emitter/class_emitter.dart
@@ -42,6 +42,8 @@ class ClassEmitter extends CodeEmitterHelper {
emitInstanceMembers(classElement, builder, onlyForRti: onlyForRti);
task.typeTestEmitter.emitIsTests(classElement, builder);
+ emitTypeVariableReaders(classElement, builder);
+
emitClassBuilderWithReflectionData(
className, classElement, builder, buffer);
}
@@ -601,4 +603,45 @@ class ClassEmitter extends CodeEmitterHelper {
builder.addProperty('+$reflectionName', reflectable);
}
}
+
+ void emitTypeVariableReaders(ClassElement cls, ClassBuilder builder) {
+ List typeVariables = [];
+ ClassElement superclass = cls;
+ while (superclass != null) {
+ GenericType type = superclass.thisType;
+ for (TypeVariableType parameter in type.typeArguments) {
+ if (task.readTypeVariables.contains(parameter.element)) {
+ emitTypeVariableReader(cls, builder, parameter.element);
+ }
+ }
+ superclass = superclass.superclass;
+ }
+ }
+
+ void emitTypeVariableReader(ClassElement cls,
+ ClassBuilder builder,
+ TypeVariableElement element) {
+ String name = namer.readTypeVariableName(element);
+ jsAst.Expression index =
+ js.toExpression(RuntimeTypes.getTypeVariableIndex(element));
+ jsAst.Expression computeTypeVariable;
+
+ if (!backend.rti.isTrivialSubstitution(cls, element.enclosingElement)) {
+ Substitution substitution =
+ backend.rti.computeSubstitution(
+ cls, element.enclosingElement, alwaysGenerateFunction: true);
+ jsAst.Expression typeArguments =
+ substitution.getCode(backend.rti, true)['apply'](
+ ['null', r'this.$builtinTypeInfo']);
+ computeTypeVariable = typeArguments[index];
+ } else {
+ computeTypeVariable =
+ js(r'this.$builtinTypeInfo && this.$builtinTypeInfo[#]', index);
+ }
+ jsAst.Expression convertRtiToRuntimeType =
+ namer.elementAccess(compiler.findHelper('convertRtiToRuntimeType'));
+ builder.addProperty(
+ name, js.fun(
+ [], [js.return_(convertRtiToRuntimeType(computeTypeVariable))]));
+ }
}

Powered by Google App Engine
This is Rietveld 408576698