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

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

Issue 256453004: Avoid inlining constants that are used via a deferred import. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebase Created 6 years, 7 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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 * Assigns JavaScript identifiers to Dart variables, class-names and members. 8 * Assigns JavaScript identifiers to Dart variables, class-names and members.
9 */ 9 */
10 class Namer implements ClosureNamer { 10 class Namer implements ClosureNamer {
(...skipping 1145 matching lines...) Expand 10 before | Expand all | Expand 10 after
1156 } 1156 }
1157 1157
1158 visitInterceptor(InterceptorConstant constant) { 1158 visitInterceptor(InterceptorConstant constant) {
1159 addRoot(constant.dispatchedType.element.name); 1159 addRoot(constant.dispatchedType.element.name);
1160 add('methods'); 1160 add('methods');
1161 } 1161 }
1162 1162
1163 visitDummy(DummyConstant constant) { 1163 visitDummy(DummyConstant constant) {
1164 add('dummy_receiver'); 1164 add('dummy_receiver');
1165 } 1165 }
1166
1167 visitDeferred(DeferredConstant constant) {
1168 addRoot('Deferred');
1169 }
1166 } 1170 }
1167 1171
1168 /** 1172 /**
1169 * Generates canonical hash values for [Constant]s. 1173 * Generates canonical hash values for [Constant]s.
1170 * 1174 *
1171 * Unfortunately, [Constant.hashCode] is not stable under minor perturbations, 1175 * Unfortunately, [Constant.hashCode] is not stable under minor perturbations,
1172 * so it can't be used for generating names. This hasher keeps consistency 1176 * so it can't be used for generating names. This hasher keeps consistency
1173 * between runs by basing hash values of the names of elements, rather than 1177 * between runs by basing hash values of the names of elements, rather than
1174 * their hashCodes. 1178 * their hashCodes.
1175 */ 1179 */
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
1238 visitInterceptor(InterceptorConstant constant) { 1242 visitInterceptor(InterceptorConstant constant) {
1239 String typeName = constant.dispatchedType.element.name; 1243 String typeName = constant.dispatchedType.element.name;
1240 return _hashString(5, typeName); 1244 return _hashString(5, typeName);
1241 } 1245 }
1242 1246
1243 visitDummy(DummyConstant constant) { 1247 visitDummy(DummyConstant constant) {
1244 compiler.internalError(NO_LOCATION_SPANNABLE, 1248 compiler.internalError(NO_LOCATION_SPANNABLE,
1245 'DummyReceiverConstant should never be named and never be subconstant'); 1249 'DummyReceiverConstant should never be named and never be subconstant');
1246 } 1250 }
1247 1251
1252 visitDeferred(DeferredConstant constant) {
1253 int hash = constant.prefix.hashCode;
1254 return _combine(hash, constant.referenced.accept(this));
1255 }
1256
1248 int _hashString(int hash, String s) { 1257 int _hashString(int hash, String s) {
1249 int length = s.length; 1258 int length = s.length;
1250 hash = _combine(hash, length); 1259 hash = _combine(hash, length);
1251 // Increasing stride is O(log N) on large strings which are unlikely to have 1260 // Increasing stride is O(log N) on large strings which are unlikely to have
1252 // many collisions. 1261 // many collisions.
1253 for (int i = 0; i < length; i += 1 + (i >> 2)) { 1262 for (int i = 0; i < length; i += 1 + (i >> 2)) {
1254 hash = _combine(hash, s.codeUnitAt(i)); 1263 hash = _combine(hash, s.codeUnitAt(i));
1255 } 1264 }
1256 return hash; 1265 return hash;
1257 } 1266 }
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
1369 if (!first) { 1378 if (!first) {
1370 sb.write('_'); 1379 sb.write('_');
1371 } 1380 }
1372 sb.write('_'); 1381 sb.write('_');
1373 visit(link.head); 1382 visit(link.head);
1374 first = true; 1383 first = true;
1375 } 1384 }
1376 } 1385 }
1377 } 1386 }
1378 } 1387 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698