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

Unified Diff: dart/sdk/lib/_internal/compiler/implementation/js_backend/emitter.dart

Issue 23226002: Implement ClassMirror.superinterfaces. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Long lines and caching Created 7 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
« no previous file with comments | « no previous file | dart/sdk/lib/_internal/lib/js_mirrors.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dart/sdk/lib/_internal/compiler/implementation/js_backend/emitter.dart
diff --git a/dart/sdk/lib/_internal/compiler/implementation/js_backend/emitter.dart b/dart/sdk/lib/_internal/compiler/implementation/js_backend/emitter.dart
index 32d3ab8e05ae37f41f8813b6101e0916f4cbd6be..1c990e02eabacc8c3de16179febf17de76c76075 100644
--- a/dart/sdk/lib/_internal/compiler/implementation/js_backend/emitter.dart
+++ b/dart/sdk/lib/_internal/compiler/implementation/js_backend/emitter.dart
@@ -1296,6 +1296,8 @@ class CodeEmitterTask extends CompilerTask {
/// O is the named arguments.
/// The reflection name of a constructor is similar to a regular method but
/// starts with 'new '.
+ /// The reflection name of class 'C' is 'C'.
+ /// An anonymous mixin application has no reflection name.
/// This is used by js_mirrors.dart.
String getReflectionName(elementOrSelector, String mangledName) {
SourceString name = elementOrSelector.name;
@@ -1982,7 +1984,11 @@ class CodeEmitterTask extends CompilerTask {
buffer.write(jsAst.prettyPrint(builder.toObjectInitializer(), compiler));
if (backend.shouldRetainName(classElement.name)) {
String reflectionName = getReflectionName(classElement, className);
- buffer.write(',$n$n"+$reflectionName": 0');
+ List<int> interfaces = <int>[];
+ for (DartType interface in classElement.interfaces) {
+ interfaces.add(reifyType(interface));
+ }
+ buffer.write(',$n$n"+$reflectionName": $interfaces');
}
}
@@ -4013,10 +4019,17 @@ class CodeEmitterTask extends CompilerTask {
String metadataField = '"${namer.metadataField}"';
return '''
(function (reflectionData) {
+'''
+// [map] returns an object literal that V8 shouldn't try to optimize with a
+// hidden class. This prevents a potential performance problem where V8 tries
+// to build a hidden class for an object used as a hashMap.
+'''
+ function map(x){x={x:x};delete x.x;return x}
if (!init.libraries) init.libraries = [];
- if (!init.mangledNames) init.mangledNames = {};
- if (!init.mangledGlobalNames) init.mangledGlobalNames = {};
- if (!init.statics) init.statics = {};
+ if (!init.mangledNames) init.mangledNames = map();
+ if (!init.mangledGlobalNames) init.mangledGlobalNames = map();
+ if (!init.statics) init.statics = map();
+ if (!init.interfaces) init.interfaces = map();
var libraries = init.libraries;
var mangledNames = init.mangledNames;
var mangledGlobalNames = init.mangledGlobalNames;
@@ -4052,6 +4065,8 @@ class CodeEmitterTask extends CompilerTask {
var previousProperty;
if (firstChar === "+") {
mangledGlobalNames[previousProperty] = property.substring(1);
+ if (element && element.length) '''
ngeoffray 2013/08/15 06:52:33 This ''' quote here is confusing. My guess is that
ahe 2013/08/15 09:58:24 Done.
+'''init.interfaces[previousProperty] = element;
} else if (firstChar === "@") {
property = property.substring(1);
${namer.CURRENT_ISOLATE}[property][$metadataField] = element;
« no previous file with comments | « no previous file | dart/sdk/lib/_internal/lib/js_mirrors.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698