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

Unified Diff: pkg/compiler/lib/src/js_backend/interceptor_data.dart

Issue 2732663002: Late creation of CodegenEnqueuer (Closed)
Patch Set: Updated cf. comment Created 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/compiler/lib/src/js_backend/backend.dart ('k') | pkg/compiler/lib/src/js_backend/mirrors_analysis.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/js_backend/interceptor_data.dart
diff --git a/pkg/compiler/lib/src/js_backend/interceptor_data.dart b/pkg/compiler/lib/src/js_backend/interceptor_data.dart
index bde0355960ed11778836f18c831ddeec34ee3a33..3632b0ade685550c1e72714402bb71810913b0af 100644
--- a/pkg/compiler/lib/src/js_backend/interceptor_data.dart
+++ b/pkg/compiler/lib/src/js_backend/interceptor_data.dart
@@ -8,6 +8,7 @@ import '../common/names.dart' show Identifiers;
import '../common_elements.dart' show CommonElements;
import '../elements/elements.dart';
import '../elements/entities.dart';
+import '../elements/types.dart';
import '../js/js.dart' as jsAst;
import '../types/types.dart' show TypeMask;
import '../universe/selector.dart';
@@ -33,6 +34,11 @@ abstract class InterceptorData {
///
/// Returns an empty set if there is no class. Do not modify the returned set.
Set<ClassEntity> getInterceptedClassesOn(String name);
+
+ /// Whether the compiler can use the native `instanceof` check to test for
+ /// instances of [type]. This is true for types that are not used as mixins or
+ /// interfaces.
+ bool mayGenerateInstanceofCheck(DartType type);
}
abstract class InterceptorDataBuilder {
@@ -196,6 +202,17 @@ class InterceptorDataImpl implements InterceptorData {
_classesMixedIntoInterceptedClasses.contains(element);
Iterable<ClassElement> get interceptedClasses => _interceptedClasses;
+
+ bool mayGenerateInstanceofCheck(DartType type) {
+ // We can use an instanceof check for raw types that have no subclass that
+ // is mixed-in or in an implements clause.
+
+ if (!type.treatAsRaw) return false;
+ InterfaceType interfaceType = type;
+ ClassEntity classElement = interfaceType.element;
+ if (isInterceptedClass(classElement)) return false;
+ return _closedWorld.hasOnlySubclasses(classElement);
+ }
}
class InterceptorDataBuilderImpl implements InterceptorDataBuilder {
« no previous file with comments | « pkg/compiler/lib/src/js_backend/backend.dart ('k') | pkg/compiler/lib/src/js_backend/mirrors_analysis.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698