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

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

Issue 22301009: Retain fewer names for reflection. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: 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 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 part of js_backend; 5 part of js_backend;
6 6
7 /** 7 /**
8 * A function element that represents a closure call. The signature is copied 8 * A function element that represents a closure call. The signature is copied
9 * from the given element. 9 * from the given element.
10 */ 10 */
(...skipping 1270 matching lines...) Expand 10 before | Expand all | Expand 10 after
1281 if (!parameters.optionalParameters.isEmpty) { 1281 if (!parameters.optionalParameters.isEmpty) {
1282 addParameterStubs(member, builder.addProperty); 1282 addParameterStubs(member, builder.addProperty);
1283 } 1283 }
1284 } else if (!member.isField()) { 1284 } else if (!member.isField()) {
1285 compiler.internalError('unexpected kind: "${member.kind}"', 1285 compiler.internalError('unexpected kind: "${member.kind}"',
1286 element: member); 1286 element: member);
1287 } 1287 }
1288 emitExtraAccessors(member, builder); 1288 emitExtraAccessors(member, builder);
1289 } 1289 }
1290 1290
1291 String getReflectionName(elementOrSelector, String mangledName) { 1291 String getReflectionName(elementOrSelector, String mangledName) {
Johnni Winther 2013/08/07 10:47:34 Add documentation to this method.
ahe 2013/08/07 14:03:17 Done.
1292 if (!backend.retainName(elementOrSelector.name)) return null; 1292 SourceString name = elementOrSelector.name;
1293 if (!backend.retainName(name)) {
1294 if (name == const SourceString('') && elementOrSelector is Element) {
1295 // Make sure to retain names of unnamed constructors.
1296 if (!backend.isNeededForReflection(elementOrSelector)) return null;
1297 } else {
1298 return null;
1299 }
1300 }
1293 // TODO(ahe): Enable the next line when I can tell the difference between 1301 // TODO(ahe): Enable the next line when I can tell the difference between
1294 // an instance method and a global. They may have the same mangled name. 1302 // an instance method and a global. They may have the same mangled name.
1295 // if (recordedMangledNames.contains(mangledName)) return null; 1303 // if (recordedMangledNames.contains(mangledName)) return null;
1296 recordedMangledNames.add(mangledName); 1304 recordedMangledNames.add(mangledName);
1297 return getReflectionNameInternal(elementOrSelector, mangledName); 1305 return getReflectionNameInternal(elementOrSelector, mangledName);
1298 } 1306 }
1299 1307
1300 String getReflectionNameInternal(elementOrSelector, String mangledName) { 1308 String getReflectionNameInternal(elementOrSelector, String mangledName) {
1301 String name = elementOrSelector.name.slowToString(); 1309 String name = elementOrSelector.name.slowToString();
1302 if (elementOrSelector.isGetter()) return name; 1310 if (elementOrSelector.isGetter()) return name;
(...skipping 651 matching lines...) Expand 10 before | Expand all | Expand 10 after
1954 } 1962 }
1955 1963
1956 // TODO(ahe): This method (generateClass) should return a jsAst.Expression. 1964 // TODO(ahe): This method (generateClass) should return a jsAst.Expression.
1957 if (!buffer.isEmpty) { 1965 if (!buffer.isEmpty) {
1958 buffer.write(',$n$n'); 1966 buffer.write(',$n$n');
1959 } 1967 }
1960 buffer.write('$className:$_'); 1968 buffer.write('$className:$_');
1961 buffer.write(jsAst.prettyPrint(builder.toObjectInitializer(), compiler)); 1969 buffer.write(jsAst.prettyPrint(builder.toObjectInitializer(), compiler));
1962 if (backend.retainName(classElement.name)) { 1970 if (backend.retainName(classElement.name)) {
1963 buffer.write(',$n$n"+${classElement.name.slowToString()}": 0'); 1971 buffer.write(',$n$n"+${classElement.name.slowToString()}": 0');
1972 recordedMangledNames.add(className);
1964 } 1973 }
1965 } 1974 }
1966 1975
1967 bool get getterAndSetterCanBeImplementedByFieldSpec => true; 1976 bool get getterAndSetterCanBeImplementedByFieldSpec => true;
1968 1977
1969 /// If this is true then we can generate the noSuchMethod handlers at startup 1978 /// If this is true then we can generate the noSuchMethod handlers at startup
1970 /// time, instead of them being emitted as part of the Object class. 1979 /// time, instead of them being emitted as part of the Object class.
1971 bool get generateTrivialNsmHandlers => true; 1980 bool get generateTrivialNsmHandlers => true;
1972 1981
1973 int _selectorRank(Selector selector) { 1982 int _selectorRank(Selector selector) {
(...skipping 2069 matching lines...) Expand 10 before | Expand all | Expand 10 after
4043 4052
4044 const String HOOKS_API_USAGE = """ 4053 const String HOOKS_API_USAGE = """
4045 // The code supports the following hooks: 4054 // The code supports the following hooks:
4046 // dartPrint(message) - if this function is defined it is called 4055 // dartPrint(message) - if this function is defined it is called
4047 // instead of the Dart [print] method. 4056 // instead of the Dart [print] method.
4048 // dartMainRunner(main) - if this function is defined, the Dart [main] 4057 // dartMainRunner(main) - if this function is defined, the Dart [main]
4049 // method will not be invoked directly. 4058 // method will not be invoked directly.
4050 // Instead, a closure that will invoke [main] is 4059 // Instead, a closure that will invoke [main] is
4051 // passed to [dartMainRunner]. 4060 // passed to [dartMainRunner].
4052 """; 4061 """;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698