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

Unified Diff: lib/compiler/implementation/ssa/codegen.dart

Issue 10888003: Change how runtime type information is being set in the backend. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 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 side-by-side diff with in-line comments
Download patch
Index: lib/compiler/implementation/ssa/codegen.dart
===================================================================
--- lib/compiler/implementation/ssa/codegen.dart (revision 11430)
+++ lib/compiler/implementation/ssa/codegen.dart (working copy)
@@ -48,6 +48,7 @@
parameterNames.forEach((element, name) {
parameters.add(new js.Parameter(name));
});
+ addTypeVariables(work.element, parameters, parameterNames);
String parametersString = Strings.join(parameterNames.getValues(), ", ");
SsaOptimizedCodeGenerator codegen = new SsaOptimizedCodeGenerator(
backend, work, parameters, parameterNames);
@@ -77,6 +78,25 @@
return prettyPrint(fun, work.element);
});
}
+
+ void addTypeVariables(Element element,
kasperl 2012/08/28 09:14:15 Shouldn't this be something like addTypeParameters
ngeoffray 2012/08/28 10:39:45 Done.
+ List<js.Parameter> parameters,
+ Map<Element, String> parameterNames) {
+ if (element.isFactoryConstructor() || element.isGenerativeConstructor()) {
+ ClassElement cls = element.enclosingElement;
+ cls.typeVariables.forEach((TypeVariableType typeVariable) {
+ String name = typeVariable.element.name.slowToString();
+ String prefix = '';
+ // Avoid collisions with real parameters of the method.
+ do {
+ name = JsNames.getValid('$prefix$name');
+ prefix = '\$$prefix';
+ } while (parameterNames.containsValue(name));
+ parameterNames[typeVariable.element] = name;
+ parameters.add(new js.Parameter(name));
+ });
+ }
+ }
CodeBuffer generateBailoutMethod(WorkItem work, HGraph graph) {
return measure(() {
@@ -87,6 +107,8 @@
parameterNames.forEach((element, name) {
parameters.add(new js.Parameter(name));
});
+ addTypeVariables(work.element, parameters, parameterNames);
+
SsaUnoptimizedCodeGenerator codegen = new SsaUnoptimizedCodeGenerator(
backend, work, parameters, parameterNames);
codegen.visitGraph(graph);
@@ -2259,13 +2281,11 @@
checkType(input, element);
attachLocationToLast(node);
}
- if (compiler.codegenWorld.rti.hasTypeArguments(type)) {
+ if (node.hasTypeInfo()) {
InterfaceType interfaceType = type;
ClassElement cls = type.element;
Link<Type> arguments = interfaceType.arguments;
js.Expression result = pop();
- checkObject(node.typeInfoCall, '===');
- result = new js.Binary('&&', result, pop());
for (TypeVariableType typeVariable in cls.typeVariables) {
use(node.typeInfoCall);
// TODO(johnniwinther): Retrieve the type name properly and not through

Powered by Google App Engine
This is Rietveld 408576698