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

Unified Diff: pkg/compiler/lib/src/universe/universe.dart

Issue 1424923004: Add StaticUse for more precise registration of statically known element use. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Updated cf. comments. Created 5 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/compiler/lib/src/ssa/ssa.dart ('k') | pkg/compiler/lib/src/universe/use.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/universe/universe.dart
diff --git a/pkg/compiler/lib/src/universe/universe.dart b/pkg/compiler/lib/src/universe/universe.dart
index e2f670b36518dc852559ab251b45486c8f20c864..79d3cd90f749c9242c66fe8db79b81cfbc665cde 100644
--- a/pkg/compiler/lib/src/universe/universe.dart
+++ b/pkg/compiler/lib/src/universe/universe.dart
@@ -18,7 +18,17 @@ import '../world.dart' show
import 'selector.dart' show
Selector;
+import 'use.dart' show
+ StaticUse,
+ StaticUseKind;
+
+enum DynamicUseKind {
+ INVOKE,
+ GET,
+ SET,
+}
+// TODO(johnniwinther): Rename to `DynamicUse` and move to 'use.dart'.
class UniverseSelector {
final Selector selector;
final ReceiverConstraint mask;
@@ -30,6 +40,16 @@ class UniverseSelector {
(mask == null || mask.canHit(element, selector, world));
}
+ DynamicUseKind get kind {
+ if (selector.isGetter) {
+ return DynamicUseKind.GET;
+ } else if (selector.isSetter) {
+ return DynamicUseKind.SET;
+ } else {
+ return DynamicUseKind.INVOKE;
+ }
+ }
+
int get hashCode => selector.hashCode * 13 + mask.hashCode * 17;
bool operator ==(other) {
@@ -323,16 +343,15 @@ class Universe {
return _hasMatchingSelector(_invokedSetters[member.name], member, world);
}
- bool registerInvocation(UniverseSelector selector) {
- return _registerNewSelector(selector, _invokedNames);
- }
-
- bool registerInvokedGetter(UniverseSelector selector) {
- return _registerNewSelector(selector, _invokedGetters);
- }
-
- bool registerInvokedSetter(UniverseSelector selector) {
- return _registerNewSelector(selector, _invokedSetters);
+ bool registerDynamicUse(UniverseSelector selector) {
+ switch (selector.kind) {
+ case DynamicUseKind.INVOKE:
+ return _registerNewSelector(selector, _invokedNames);
+ case DynamicUseKind.GET:
+ return _registerNewSelector(selector, _invokedGetters);
+ case DynamicUseKind.SET:
+ return _registerNewSelector(selector, _invokedSetters);
+ }
}
bool _registerNewSelector(
@@ -391,11 +410,27 @@ class Universe {
return type;
}
- void registerStaticFieldUse(FieldElement staticField) {
- assert(Elements.isStaticOrTopLevel(staticField) && staticField.isField);
- assert(staticField.isDeclaration);
-
- allReferencedStaticFields.add(staticField);
+ void registerStaticUse(StaticUse staticUse) {
+ Element element = staticUse.element;
+ if (Elements.isStaticOrTopLevel(element) && element.isField) {
+ allReferencedStaticFields.add(element);
+ }
+ switch (staticUse.kind) {
+ case StaticUseKind.STATIC_TEAR_OFF:
+ staticFunctionsNeedingGetter.add(element);
+ break;
+ case StaticUseKind.FIELD_GET:
+ fieldGetters.add(element);
+ break;
+ case StaticUseKind.FIELD_SET:
+ fieldSetters.add(element);
+ break;
+ case StaticUseKind.SUPER_TEAR_OFF:
+ methodsNeedingSuperGetter.add(element);
+ break;
+ case StaticUseKind.GENERAL:
+ break;
+ }
}
void forgetElement(Element element, Compiler compiler) {
« no previous file with comments | « pkg/compiler/lib/src/ssa/ssa.dart ('k') | pkg/compiler/lib/src/universe/use.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698