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

Side by Side Diff: pkg/compiler/lib/src/world.dart

Issue 2875313002: Access BackendUsage through ClosedWorld (Closed)
Patch Set: Created 3 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
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 library dart2js.world; 5 library dart2js.world;
6 6
7 import 'closure.dart' show ClosureClassElement, SynthesizedCallMethodElementX; 7 import 'closure.dart' show ClosureClassElement, SynthesizedCallMethodElementX;
8 import 'common.dart'; 8 import 'common.dart';
9 import 'constants/constant_system.dart'; 9 import 'constants/constant_system.dart';
10 import 'common_elements.dart' show CommonElements; 10 import 'common_elements.dart' show CommonElements;
(...skipping 24 matching lines...) Expand all
35 35
36 /// The [ClosedWorld] represents the information known about a program when 36 /// The [ClosedWorld] represents the information known about a program when
37 /// compiling with closed-world semantics. 37 /// compiling with closed-world semantics.
38 /// 38 ///
39 /// Given the entrypoint of an application, we can track what's reachable from 39 /// Given the entrypoint of an application, we can track what's reachable from
40 /// it, what functions are called, what classes are allocated, which native 40 /// it, what functions are called, what classes are allocated, which native
41 /// JavaScript types are touched, what language features are used, and so on. 41 /// JavaScript types are touched, what language features are used, and so on.
42 /// This precise knowledge about what's live in the program is later used in 42 /// This precise knowledge about what's live in the program is later used in
43 /// optimizations and other compiler decisions during code generation. 43 /// optimizations and other compiler decisions during code generation.
44 abstract class ClosedWorld implements World { 44 abstract class ClosedWorld implements World {
45 BackendUsage get backendUsage;
46
45 NativeData get nativeData; 47 NativeData get nativeData;
46 48
47 InterceptorData get interceptorData; 49 InterceptorData get interceptorData;
48 50
49 CommonElements get commonElements; 51 CommonElements get commonElements;
50 52
51 CommonMasks get commonMasks; 53 CommonMasks get commonMasks;
52 54
53 ConstantSystem get constantSystem; 55 ConstantSystem get constantSystem;
54 56
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 392
391 /// The class and all classes that implement or subclass it (transitively) 393 /// The class and all classes that implement or subclass it (transitively)
392 /// are included. 394 /// are included.
393 SUBTYPE, 395 SUBTYPE,
394 } 396 }
395 397
396 abstract class ClosedWorldBase implements ClosedWorld, ClosedWorldRefiner { 398 abstract class ClosedWorldBase implements ClosedWorld, ClosedWorldRefiner {
397 final ConstantSystem constantSystem; 399 final ConstantSystem constantSystem;
398 final NativeData nativeData; 400 final NativeData nativeData;
399 final InterceptorData interceptorData; 401 final InterceptorData interceptorData;
400 final BackendUsage _backendUsage; 402 final BackendUsage backendUsage;
401 403
402 final FunctionSet _allFunctions; 404 final FunctionSet _allFunctions;
403 405
404 final Iterable<TypedefElement> _allTypedefs; 406 final Iterable<TypedefElement> _allTypedefs;
405 407
406 final Map<ClassEntity, Set<ClassEntity>> _mixinUses; 408 final Map<ClassEntity, Set<ClassEntity>> _mixinUses;
407 Map<ClassEntity, List<ClassEntity>> _liveMixinUses; 409 Map<ClassEntity, List<ClassEntity>> _liveMixinUses;
408 410
409 final Map<ClassEntity, Set<ClassEntity>> _typesImplementedBySubclasses; 411 final Map<ClassEntity, Set<ClassEntity>> _typesImplementedBySubclasses;
410 412
(...skipping 18 matching lines...) Expand all
429 431
430 final CommonElements commonElements; 432 final CommonElements commonElements;
431 433
432 final ResolutionWorldBuilder _resolverWorld; 434 final ResolutionWorldBuilder _resolverWorld;
433 435
434 ClosedWorldBase( 436 ClosedWorldBase(
435 {this.commonElements, 437 {this.commonElements,
436 this.constantSystem, 438 this.constantSystem,
437 this.nativeData, 439 this.nativeData,
438 this.interceptorData, 440 this.interceptorData,
439 BackendUsage backendUsage, 441 this.backendUsage,
440 ResolutionWorldBuilder resolutionWorldBuilder, 442 ResolutionWorldBuilder resolutionWorldBuilder,
441 FunctionSet functionSet, 443 FunctionSet functionSet,
442 Iterable<TypedefElement> allTypedefs, 444 Iterable<TypedefElement> allTypedefs,
443 Map<ClassEntity, Set<ClassEntity>> mixinUses, 445 Map<ClassEntity, Set<ClassEntity>> mixinUses,
444 Map<ClassEntity, Set<ClassEntity>> typesImplementedBySubclasses, 446 Map<ClassEntity, Set<ClassEntity>> typesImplementedBySubclasses,
445 Map<ClassEntity, ClassHierarchyNode> classHierarchyNodes, 447 Map<ClassEntity, ClassHierarchyNode> classHierarchyNodes,
446 Map<ClassEntity, ClassSet> classSets}) 448 Map<ClassEntity, ClassSet> classSets})
447 : this._backendUsage = backendUsage, 449 : this._resolverWorld = resolutionWorldBuilder,
448 this._resolverWorld = resolutionWorldBuilder,
449 this._allFunctions = functionSet, 450 this._allFunctions = functionSet,
450 this._allTypedefs = allTypedefs, 451 this._allTypedefs = allTypedefs,
451 this._mixinUses = mixinUses, 452 this._mixinUses = mixinUses,
452 this._typesImplementedBySubclasses = typesImplementedBySubclasses, 453 this._typesImplementedBySubclasses = typesImplementedBySubclasses,
453 this._classHierarchyNodes = classHierarchyNodes, 454 this._classHierarchyNodes = classHierarchyNodes,
454 this._classSets = classSets { 455 this._classSets = classSets {
455 _commonMasks = new CommonMasks(this); 456 _commonMasks = new CommonMasks(this);
456 } 457 }
457 458
458 @override 459 @override
(...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after
997 } 998 }
998 999
999 MemberEntity locateSingleElement(Selector selector, TypeMask mask) { 1000 MemberEntity locateSingleElement(Selector selector, TypeMask mask) {
1000 mask ??= commonMasks.dynamicType; 1001 mask ??= commonMasks.dynamicType;
1001 return mask.locateSingleElement(selector, this); 1002 return mask.locateSingleElement(selector, this);
1002 } 1003 }
1003 1004
1004 TypeMask extendMaskIfReachesAll(Selector selector, TypeMask mask) { 1005 TypeMask extendMaskIfReachesAll(Selector selector, TypeMask mask) {
1005 bool canReachAll = true; 1006 bool canReachAll = true;
1006 if (mask != null) { 1007 if (mask != null) {
1007 canReachAll = _backendUsage.isInvokeOnUsed && 1008 canReachAll = backendUsage.isInvokeOnUsed &&
1008 mask.needsNoSuchMethodHandling(selector, this); 1009 mask.needsNoSuchMethodHandling(selector, this);
1009 } 1010 }
1010 return canReachAll ? commonMasks.dynamicType : mask; 1011 return canReachAll ? commonMasks.dynamicType : mask;
1011 } 1012 }
1012 1013
1013 bool fieldNeverChanges(MemberEntity element) { 1014 bool fieldNeverChanges(MemberEntity element) {
1014 if (!element.isField) return false; 1015 if (!element.isField) return false;
1015 if (nativeData.isNativeMember(element)) { 1016 if (nativeData.isNativeMember(element)) {
1016 // Some native fields are views of data that may be changed by operations. 1017 // Some native fields are views of data that may be changed by operations.
1017 // E.g. node.firstChild depends on parentNode.removeBefore(n1, n2). 1018 // E.g. node.firstChild depends on parentNode.removeBefore(n1, n2).
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
1357 @override 1358 @override
1358 void registerClosureClass(ClassElement cls) { 1359 void registerClosureClass(ClassElement cls) {
1359 throw new UnimplementedError('KernelClosedWorld.registerClosureClass'); 1360 throw new UnimplementedError('KernelClosedWorld.registerClosureClass');
1360 } 1361 }
1361 1362
1362 @override 1363 @override
1363 bool hasElementIn(ClassEntity cls, Selector selector, Entity element) { 1364 bool hasElementIn(ClassEntity cls, Selector selector, Entity element) {
1364 throw new UnimplementedError('KernelClosedWorld.hasElementIn'); 1365 throw new UnimplementedError('KernelClosedWorld.hasElementIn');
1365 } 1366 }
1366 } 1367 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698