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

Side by Side Diff: pkg/compiler/lib/src/js_emitter/metadata_collector.dart

Issue 1803303002: Move all flags to CompilerOptions (first step to stop passing the compiler to (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 9 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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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.js_emitter; 5 part of dart2js.js_emitter;
6 6
7 /// Represents an entry's position in one of the global metadata arrays. 7 /// Represents an entry's position in one of the global metadata arrays.
8 /// 8 ///
9 /// [_rc] is used to count the number of references of the token in the 9 /// [_rc] is used to count the number of references of the token in the
10 /// ast for a program. 10 /// ast for a program.
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 Placeholder getMetadataPlaceholder([debug]) { 290 Placeholder getMetadataPlaceholder([debug]) {
291 return new _ForwardingMetadataEntry(debug); 291 return new _ForwardingMetadataEntry(debug);
292 } 292 }
293 293
294 _MetadataEntry _addGlobalMetadata(jsAst.Node node) { 294 _MetadataEntry _addGlobalMetadata(jsAst.Node node) {
295 String nameToKey(jsAst.Name name) => "${name.key}"; 295 String nameToKey(jsAst.Name name) => "${name.key}";
296 String printed = jsAst.prettyPrint( 296 String printed = jsAst.prettyPrint(
297 node, _compiler, renamerForNames: nameToKey); 297 node, _compiler, renamerForNames: nameToKey);
298 return _globalMetadataMap.putIfAbsent(printed, () { 298 return _globalMetadataMap.putIfAbsent(printed, () {
299 _BoundMetadataEntry result = new _BoundMetadataEntry(node); 299 _BoundMetadataEntry result = new _BoundMetadataEntry(node);
300 if (_compiler.hasIncrementalSupport) { 300 if (_compiler.options.hasIncrementalSupport) {
301 result.finalize(_globalMetadataCounter++); 301 result.finalize(_globalMetadataCounter++);
302 } 302 }
303 return result; 303 return result;
304 }); 304 });
305 } 305 }
306 306
307 jsAst.Expression _computeTypeRepresentation(DartType type, 307 jsAst.Expression _computeTypeRepresentation(DartType type,
308 {ignoreTypeVariables: false}) { 308 {ignoreTypeVariables: false}) {
309 jsAst.Expression representation = _backend.rtiEncoder.getTypeRepresentation( 309 jsAst.Expression representation = _backend.rtiEncoder.getTypeRepresentation(
310 type, 310 type,
(...skipping 19 matching lines...) Expand all
330 jsAst.Expression addTypeInOutputUnit(DartType type, 330 jsAst.Expression addTypeInOutputUnit(DartType type,
331 OutputUnit outputUnit, 331 OutputUnit outputUnit,
332 {ignoreTypeVariables: false}) { 332 {ignoreTypeVariables: false}) {
333 if (_typesMap[outputUnit] == null) { 333 if (_typesMap[outputUnit] == null) {
334 _typesMap[outputUnit] = new Map<DartType, _BoundMetadataEntry>(); 334 _typesMap[outputUnit] = new Map<DartType, _BoundMetadataEntry>();
335 } 335 }
336 return _typesMap[outputUnit].putIfAbsent(type, () { 336 return _typesMap[outputUnit].putIfAbsent(type, () {
337 _BoundMetadataEntry result = new _BoundMetadataEntry( 337 _BoundMetadataEntry result = new _BoundMetadataEntry(
338 _computeTypeRepresentation(type, 338 _computeTypeRepresentation(type,
339 ignoreTypeVariables: ignoreTypeVariables)); 339 ignoreTypeVariables: ignoreTypeVariables));
340 if (_compiler.hasIncrementalSupport) { 340 if (_compiler.options.hasIncrementalSupport) {
341 result.finalize(_globalTypesCounter++); 341 result.finalize(_globalTypesCounter++);
342 } 342 }
343 return result; 343 return result;
344 }); 344 });
345 } 345 }
346 346
347 List<jsAst.DeferredNumber> computeMetadata(FunctionElement element) { 347 List<jsAst.DeferredNumber> computeMetadata(FunctionElement element) {
348 return reporter.withCurrentElement(element, () { 348 return reporter.withCurrentElement(element, () {
349 if (!_mustEmitMetadataFor(element)) return const <jsAst.DeferredNumber>[]; 349 if (!_mustEmitMetadataFor(element)) return const <jsAst.DeferredNumber>[];
350 List<jsAst.DeferredNumber> metadata = <jsAst.DeferredNumber>[]; 350 List<jsAst.DeferredNumber> metadata = <jsAst.DeferredNumber>[];
(...skipping 18 matching lines...) Expand all
369 } 369 }
370 void countTokensInTypes(Iterable<_BoundMetadataEntry> entries) { 370 void countTokensInTypes(Iterable<_BoundMetadataEntry> entries) {
371 jsAst.TokenCounter counter = new jsAst.TokenCounter(); 371 jsAst.TokenCounter counter = new jsAst.TokenCounter();
372 entries.where((_BoundMetadataEntry e) => e._rc > 0) 372 entries.where((_BoundMetadataEntry e) => e._rc > 0)
373 .map((_BoundMetadataEntry e) => e.entry) 373 .map((_BoundMetadataEntry e) => e.entry)
374 .forEach(counter.countTokens); 374 .forEach(counter.countTokens);
375 } 375 }
376 376
377 jsAst.ArrayInitializer finalizeMap(Map<dynamic, _BoundMetadataEntry> map) { 377 jsAst.ArrayInitializer finalizeMap(Map<dynamic, _BoundMetadataEntry> map) {
378 // When in incremental mode, we allocate entries eagerly. 378 // When in incremental mode, we allocate entries eagerly.
379 if (_compiler.hasIncrementalSupport) { 379 if (_compiler.options.hasIncrementalSupport) {
380 return new jsAst.ArrayInitializer(map.values.toList()); 380 return new jsAst.ArrayInitializer(map.values.toList());
381 } 381 }
382 382
383 bool isUsed(_BoundMetadataEntry entry) => entry.isUsed; 383 bool isUsed(_BoundMetadataEntry entry) => entry.isUsed;
384 List<_BoundMetadataEntry> entries = map.values.where(isUsed).toList(); 384 List<_BoundMetadataEntry> entries = map.values.where(isUsed).toList();
385 entries.sort(); 385 entries.sort();
386 386
387 // TODO(herhut): Bucket entries by index length and use a stable 387 // TODO(herhut): Bucket entries by index length and use a stable
388 // distribution within buckets. 388 // distribution within buckets.
389 int count = 0; 389 int count = 0;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 if (token is _ForwardingMetadataEntry && !token.isBound) { 423 if (token is _ForwardingMetadataEntry && !token.isBound) {
424 _foundUnboundToken = true; 424 _foundUnboundToken = true;
425 } 425 }
426 } 426 }
427 427
428 bool findUnboundPlaceholders(jsAst.Node node) { 428 bool findUnboundPlaceholders(jsAst.Node node) {
429 node.accept(this); 429 node.accept(this);
430 return _foundUnboundToken; 430 return _foundUnboundToken;
431 } 431 }
432 } 432 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698