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

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

Issue 12095034: dart2js: Don't emit static const fields since they are inlined where they are used (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 10 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 dart2js; 5 part of dart2js;
6 6
7 /** 7 /**
8 * The [ConstantHandler] keeps track of compile-time constants, 8 * The [ConstantHandler] keeps track of compile-time constants,
9 * initializations of global and static fields, and default values of 9 * initializations of global and static fields, and default values of
10 * optional parameters. 10 * optional parameters.
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 222
223 /** 223 /**
224 * Returns an [Iterable] of static non final fields that need to be 224 * Returns an [Iterable] of static non final fields that need to be
225 * initialized. The fields list must be evaluated in order since they might 225 * initialized. The fields list must be evaluated in order since they might
226 * depend on each other. 226 * depend on each other.
227 */ 227 */
228 Iterable<VariableElement> getStaticNonFinalFieldsForEmission() { 228 Iterable<VariableElement> getStaticNonFinalFieldsForEmission() {
229 return initialVariableValues.keys.where((element) { 229 return initialVariableValues.keys.where((element) {
230 return element.kind == ElementKind.FIELD 230 return element.kind == ElementKind.FIELD
231 && !element.isInstanceMember() 231 && !element.isInstanceMember()
232 && !element.modifiers.isFinal(); 232 && !element.modifiers.isFinal()
233 // The const fields are all either emitted elsewhere or inlined.
234 && !element.modifiers.isConst();
233 }); 235 });
234 } 236 }
235 237
236 /** 238 /**
237 * Returns an [Iterable] of static const fields that need to be initialized. 239 * Returns an [Iterable] of static const fields that need to be initialized.
238 * The fields must be evaluated in order since they might depend on each 240 * The fields must be evaluated in order since they might depend on each
239 * other. 241 * other.
240 */ 242 */
241 Iterable<VariableElement> getStaticFinalFieldsForEmission() { 243 Iterable<VariableElement> getStaticFinalFieldsForEmission() {
242 return initialVariableValues.keys.where((element) { 244 return initialVariableValues.keys.where((element) {
(...skipping 634 matching lines...) Expand 10 before | Expand all | Expand 10 after
877 // Use the default value. 879 // Use the default value.
878 fieldValue = handler.compileConstant(field); 880 fieldValue = handler.compileConstant(field);
879 } 881 }
880 jsNewArguments.add(fieldValue); 882 jsNewArguments.add(fieldValue);
881 }, 883 },
882 includeBackendMembers: true, 884 includeBackendMembers: true,
883 includeSuperMembers: true); 885 includeSuperMembers: true);
884 return jsNewArguments; 886 return jsNewArguments;
885 } 887 }
886 } 888 }
OLDNEW
« no previous file with comments | « no previous file | tests/compiler/dart2js/emit_const_fields_test.dart » ('j') | tests/compiler/dart2js/emit_const_fields_test.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698