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

Side by Side Diff: pkg/compiler/lib/src/native/enqueue.dart

Issue 2595493002: Merge CoreTypes and CoreClasses into CommonElements. (Closed)
Patch Set: Updated cf. comment Created 3 years, 12 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
« no previous file with comments | « pkg/compiler/lib/src/native/behavior.dart ('k') | pkg/compiler/lib/src/patch_parser.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 import 'dart:collection' show Queue; 5 import 'dart:collection' show Queue;
6 6
7 import '../common.dart'; 7 import '../common.dart';
8 import '../common/backend_api.dart' show ForeignResolver; 8 import '../common/backend_api.dart' show ForeignResolver;
9 import '../common/resolution.dart' show Resolution; 9 import '../common/resolution.dart' show Resolution;
10 import '../compiler.dart' show Compiler; 10 import '../compiler.dart' show Compiler;
11 import '../constants/values.dart'; 11 import '../constants/values.dart';
12 import '../core_types.dart' show CoreTypes; 12 import '../core_types.dart' show CommonElements;
13 import '../dart_types.dart'; 13 import '../dart_types.dart';
14 import '../elements/elements.dart'; 14 import '../elements/elements.dart';
15 import '../elements/modelx.dart' show FunctionElementX; 15 import '../elements/modelx.dart' show FunctionElementX;
16 import '../js_backend/backend_helpers.dart' show BackendHelpers; 16 import '../js_backend/backend_helpers.dart' show BackendHelpers;
17 import '../js_backend/js_backend.dart'; 17 import '../js_backend/js_backend.dart';
18 import '../js_emitter/js_emitter.dart' show CodeEmitterTask, NativeEmitter; 18 import '../js_emitter/js_emitter.dart' show CodeEmitterTask, NativeEmitter;
19 import '../tokens/token.dart' show BeginGroupToken, Token; 19 import '../tokens/token.dart' show BeginGroupToken, Token;
20 import '../tokens/token_constants.dart' as Tokens show EOF_TOKEN; 20 import '../tokens/token_constants.dart' as Tokens show EOF_TOKEN;
21 import '../tree/tree.dart'; 21 import '../tree/tree.dart';
22 import '../universe/use.dart' show StaticUse, TypeUse; 22 import '../universe/use.dart' show StaticUse, TypeUse;
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 /// Subclasses of [NativeEnqueuerBase] are constructed by the backend. 90 /// Subclasses of [NativeEnqueuerBase] are constructed by the backend.
91 NativeEnqueuerBase(Compiler compiler, this.enableLiveTypeAnalysis) 91 NativeEnqueuerBase(Compiler compiler, this.enableLiveTypeAnalysis)
92 : this.compiler = compiler, 92 : this.compiler = compiler,
93 processedLibraries = compiler.cacheStrategy.newSet(); 93 processedLibraries = compiler.cacheStrategy.newSet();
94 94
95 JavaScriptBackend get backend => compiler.backend; 95 JavaScriptBackend get backend => compiler.backend;
96 BackendHelpers get helpers => backend.helpers; 96 BackendHelpers get helpers => backend.helpers;
97 Resolution get resolution => compiler.resolution; 97 Resolution get resolution => compiler.resolution;
98 98
99 DiagnosticReporter get reporter => compiler.reporter; 99 DiagnosticReporter get reporter => compiler.reporter;
100 CoreTypes get coreTypes => compiler.coreTypes; 100 CommonElements get commonElements => compiler.commonElements;
101 101
102 void onInstantiatedType(InterfaceType type) { 102 void onInstantiatedType(InterfaceType type) {
103 if (_unusedClasses.remove(type.element)) { 103 if (_unusedClasses.remove(type.element)) {
104 _registeredClasses.add(type.element); 104 _registeredClasses.add(type.element);
105 } 105 }
106 } 106 }
107 107
108 WorldImpact processNativeClasses(Iterable<LibraryElement> libraries) { 108 WorldImpact processNativeClasses(Iterable<LibraryElement> libraries) {
109 WorldImpactBuilderImpl impactBuilder = new WorldImpactBuilderImpl(); 109 WorldImpactBuilderImpl impactBuilder = new WorldImpactBuilderImpl();
110 _processNativeClasses(impactBuilder, libraries); 110 _processNativeClasses(impactBuilder, libraries);
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 WorldImpactBuilder impactBuilder, NativeBehavior behavior, cause) { 432 WorldImpactBuilder impactBuilder, NativeBehavior behavior, cause) {
433 void registerInstantiation(InterfaceType type) { 433 void registerInstantiation(InterfaceType type) {
434 impactBuilder.registerTypeUse(new TypeUse.nativeInstantiation(type)); 434 impactBuilder.registerTypeUse(new TypeUse.nativeInstantiation(type));
435 } 435 }
436 436
437 int unusedBefore = _unusedClasses.length; 437 int unusedBefore = _unusedClasses.length;
438 Set<ClassElement> matchingClasses = new Set<ClassElement>(); 438 Set<ClassElement> matchingClasses = new Set<ClassElement>();
439 for (var type in behavior.typesInstantiated) { 439 for (var type in behavior.typesInstantiated) {
440 if (type is SpecialType) { 440 if (type is SpecialType) {
441 if (type == SpecialType.JsObject) { 441 if (type == SpecialType.JsObject) {
442 registerInstantiation(compiler.coreTypes.objectType); 442 registerInstantiation(compiler.commonElements.objectType);
443 } 443 }
444 continue; 444 continue;
445 } 445 }
446 if (type is InterfaceType) { 446 if (type is InterfaceType) {
447 if (type == coreTypes.intType) { 447 if (type == commonElements.intType) {
448 registerInstantiation(type); 448 registerInstantiation(type);
449 } else if (type == coreTypes.doubleType) { 449 } else if (type == commonElements.doubleType) {
450 registerInstantiation(type); 450 registerInstantiation(type);
451 } else if (type == coreTypes.numType) { 451 } else if (type == commonElements.numType) {
452 registerInstantiation(coreTypes.doubleType); 452 registerInstantiation(commonElements.doubleType);
453 registerInstantiation(coreTypes.intType); 453 registerInstantiation(commonElements.intType);
454 } else if (type == coreTypes.stringType) { 454 } else if (type == commonElements.stringType) {
455 registerInstantiation(type); 455 registerInstantiation(type);
456 } else if (type == coreTypes.nullType) { 456 } else if (type == commonElements.nullType) {
457 registerInstantiation(type); 457 registerInstantiation(type);
458 } else if (type == coreTypes.boolType) { 458 } else if (type == commonElements.boolType) {
459 registerInstantiation(type); 459 registerInstantiation(type);
460 } else if (compiler.types.isSubtype( 460 } else if (compiler.types.isSubtype(
461 type, backend.backendClasses.listImplementation.rawType)) { 461 type, backend.backendClasses.listImplementation.rawType)) {
462 registerInstantiation(type); 462 registerInstantiation(type);
463 } 463 }
464 // TODO(johnniwinther): Improve spec string precision to handle type 464 // TODO(johnniwinther): Improve spec string precision to handle type
465 // arguments and implements relations that preserve generics. Currently 465 // arguments and implements relations that preserve generics. Currently
466 // we cannot distinguish between `List`, `List<dynamic>`, and 466 // we cannot distinguish between `List`, `List<dynamic>`, and
467 // `List<int>` and take all to mean `List<E>`; in effect not including 467 // `List<int>` and take all to mean `List<E>`; in effect not including
468 // any native subclasses of generic classes. 468 // any native subclasses of generic classes.
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 /** 557 /**
558 * Handles JS-calls, which can be an instantiation point for types. 558 * Handles JS-calls, which can be an instantiation point for types.
559 * 559 *
560 * For example, the following code instantiates and returns native classes 560 * For example, the following code instantiates and returns native classes
561 * that are `_DOMWindowImpl` or a subtype. 561 * that are `_DOMWindowImpl` or a subtype.
562 * 562 *
563 * JS('_DOMWindowImpl', 'window') 563 * JS('_DOMWindowImpl', 'window')
564 * 564 *
565 */ 565 */
566 NativeBehavior resolveJsCall(Send node, ForeignResolver resolver) { 566 NativeBehavior resolveJsCall(Send node, ForeignResolver resolver) {
567 return NativeBehavior.ofJsCallSend( 567 return NativeBehavior.ofJsCallSend(node, reporter, compiler.parsingContext,
568 node, reporter, compiler.parsingContext, compiler.coreTypes, resolver); 568 compiler.commonElements, resolver);
569 } 569 }
570 570
571 /** 571 /**
572 * Handles JS-embedded global calls, which can be an instantiation point for 572 * Handles JS-embedded global calls, which can be an instantiation point for
573 * types. 573 * types.
574 * 574 *
575 * For example, the following code instantiates and returns a String class 575 * For example, the following code instantiates and returns a String class
576 * 576 *
577 * JS_EMBEDDED_GLOBAL('String', 'foo') 577 * JS_EMBEDDED_GLOBAL('String', 'foo')
578 * 578 *
579 */ 579 */
580 NativeBehavior resolveJsEmbeddedGlobalCall( 580 NativeBehavior resolveJsEmbeddedGlobalCall(
581 Send node, ForeignResolver resolver) { 581 Send node, ForeignResolver resolver) {
582 return NativeBehavior.ofJsEmbeddedGlobalCallSend( 582 return NativeBehavior.ofJsEmbeddedGlobalCallSend(
583 node, reporter, compiler.coreTypes, resolver); 583 node, reporter, compiler.commonElements, resolver);
584 } 584 }
585 585
586 /** 586 /**
587 * Handles JS-compiler builtin calls, which can be an instantiation point for 587 * Handles JS-compiler builtin calls, which can be an instantiation point for
588 * types. 588 * types.
589 * 589 *
590 * For example, the following code instantiates and returns a String class 590 * For example, the following code instantiates and returns a String class
591 * 591 *
592 * JS_BUILTIN('String', 'int2string', 0) 592 * JS_BUILTIN('String', 'int2string', 0)
593 * 593 *
594 */ 594 */
595 NativeBehavior resolveJsBuiltinCall(Send node, ForeignResolver resolver) { 595 NativeBehavior resolveJsBuiltinCall(Send node, ForeignResolver resolver) {
596 return NativeBehavior.ofJsBuiltinCallSend( 596 return NativeBehavior.ofJsBuiltinCallSend(
597 node, reporter, compiler.coreTypes, resolver); 597 node, reporter, compiler.commonElements, resolver);
598 } 598 }
599 } 599 }
600 600
601 class NativeCodegenEnqueuer extends NativeEnqueuerBase { 601 class NativeCodegenEnqueuer extends NativeEnqueuerBase {
602 final CodeEmitterTask emitter; 602 final CodeEmitterTask emitter;
603 603
604 final Set<ClassElement> doneAddSubtypes = new Set<ClassElement>(); 604 final Set<ClassElement> doneAddSubtypes = new Set<ClassElement>();
605 605
606 NativeCodegenEnqueuer(Compiler compiler, this.emitter) 606 NativeCodegenEnqueuer(Compiler compiler, this.emitter)
607 : super(compiler, compiler.options.enableNativeLiveTypeAnalysis); 607 : super(compiler, compiler.options.enableNativeLiveTypeAnalysis);
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
662 List<Element> directSubtypes = 662 List<Element> directSubtypes =
663 emitter.directSubtypes.putIfAbsent(superclass, () => <ClassElement>[]); 663 emitter.directSubtypes.putIfAbsent(superclass, () => <ClassElement>[]);
664 directSubtypes.add(cls); 664 directSubtypes.add(cls);
665 } 665 }
666 666
667 void logSummary(log(message)) { 667 void logSummary(log(message)) {
668 log('Compiled ${_registeredClasses.length} native classes, ' 668 log('Compiled ${_registeredClasses.length} native classes, '
669 '${_unusedClasses.length} native classes omitted.'); 669 '${_unusedClasses.length} native classes omitted.');
670 } 670 }
671 } 671 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/native/behavior.dart ('k') | pkg/compiler/lib/src/patch_parser.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698