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

Side by Side Diff: pkg/compiler/lib/src/js_backend/lookup_map_analysis.dart

Issue 2684783003: Refactor ConstantSystem (Closed)
Patch Set: Updated cf. comments. Created 3 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
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 /// Analysis to determine how to generate code for `LookupMap`s. 5 /// Analysis to determine how to generate code for `LookupMap`s.
6 library compiler.src.js_backend.lookup_map_analysis; 6 library compiler.src.js_backend.lookup_map_analysis;
7 7
8 import 'package:pub_semver/pub_semver.dart'; 8 import 'package:pub_semver/pub_semver.dart';
9 9
10 import '../common.dart'; 10 import '../common.dart';
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 return false; 226 return false;
227 } 227 }
228 228
229 /// Whether we need to preserve [key]. This is true for keys that are not 229 /// Whether we need to preserve [key]. This is true for keys that are not
230 /// candidates for tree-shaking in the first place (primitives and non-type 230 /// candidates for tree-shaking in the first place (primitives and non-type
231 /// const values overriding equals) and keys that we have seen in the program. 231 /// const values overriding equals) and keys that we have seen in the program.
232 bool _shouldKeep(ConstantValue key) => 232 bool _shouldKeep(ConstantValue key) =>
233 key.isPrimitive || _inUse.contains(key) || _overridesEquals(key); 233 key.isPrimitive || _inUse.contains(key) || _overridesEquals(key);
234 234
235 void _addClassUse(ClassElement cls) { 235 void _addClassUse(ClassElement cls) {
236 ConstantValue key = _typeConstants.putIfAbsent(cls, 236 ConstantValue key = _typeConstants.putIfAbsent(
237 () => backend.constantSystem.createType(backend.compiler, cls.rawType)); 237 cls,
238 () => backend.constantSystem.createType(
239 backend.commonElements, backend.backendClasses, cls.rawType));
238 _addUse(key); 240 _addUse(key);
239 } 241 }
240 242
241 /// Record that [key] is used and update every lookup map that contains it. 243 /// Record that [key] is used and update every lookup map that contains it.
242 void _addUse(ConstantValue key) { 244 void _addUse(ConstantValue key) {
243 if (_inUse.add(key)) { 245 if (_inUse.add(key)) {
244 _pending[key]?.forEach((info) => info._markUsed(key)); 246 _pending[key]?.forEach((info) => info._markUsed(key));
245 _pending.remove(key); 247 _pending.remove(key);
246 } 248 }
247 } 249 }
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 original.fields[analysis.valueField] = keyValuePairs[1]; 448 original.fields[analysis.valueField] = keyValuePairs[1];
447 } 449 }
448 } else { 450 } else {
449 original.fields[analysis.entriesField] = 451 original.fields[analysis.entriesField] =
450 new ListConstantValue(listType, keyValuePairs); 452 new ListConstantValue(listType, keyValuePairs);
451 } 453 }
452 } 454 }
453 } 455 }
454 456
455 final _validLookupMapVersionConstraint = new VersionConstraint.parse('^0.0.1'); 457 final _validLookupMapVersionConstraint = new VersionConstraint.parse('^0.0.1');
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/js_backend/custom_elements_analysis.dart ('k') | pkg/compiler/lib/src/ssa/kernel_ast_adapter.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698