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

Unified Diff: sdk/lib/_internal/compiler/implementation/ssa/types.dart

Issue 13979009: Use native types for inlined native fields. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 8 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 | « sdk/lib/_internal/compiler/implementation/ssa/optimize.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/compiler/implementation/ssa/types.dart
diff --git a/sdk/lib/_internal/compiler/implementation/ssa/types.dart b/sdk/lib/_internal/compiler/implementation/ssa/types.dart
index 93dfcd89251567cbf9a719c68ccb08e131bfbcef..da6ad830dc0f323ed4bcec3ccac099423b75574d 100644
--- a/sdk/lib/_internal/compiler/implementation/ssa/types.dart
+++ b/sdk/lib/_internal/compiler/implementation/ssa/types.dart
@@ -121,36 +121,38 @@ abstract class HType {
compiler);
}
+ factory HType.fromNativeBehavior(native.NativeBehavior nativeBehavior,
+ Compiler compiler) {
+ if (nativeBehavior.typesReturned.isEmpty) return HType.UNKNOWN;
+
+ HType result = nativeBehavior.typesReturned
+ .map((type) => fromNativeType(type, compiler))
+ .reduce((t1, t2) => t1.union(t2, compiler));
+ assert(!result.isConflicting());
+ return result;
+ }
+
// [type] is either an instance of [DartType] or special objects
// like [native.SpecialType.JsObject], or [native.SpecialType.JsArray].
- factory HType.fromNativeType(type, Compiler compiler) {
+ static HType fromNativeType(type, Compiler compiler) {
if (type == native.SpecialType.JsObject) {
return new HType.nonNullExact(
compiler.objectClass.computeType(compiler), compiler);
} else if (type == native.SpecialType.JsArray) {
return HType.READABLE_ARRAY;
} else if (type.isVoid) {
- return HType.UNKNOWN; // Maybe use HType.NULL.
+ return HType.NULL;
} else if (type.element == compiler.nullClass) {
return HType.NULL;
- } else {
+ } else if (compiler.world.hasAnySubtype(type.element)) {
+ return new HType.nonNullSubtype(type, compiler);
+ } else if (compiler.world.hasAnySubclass(type.element)) {
return new HType.nonNullSubclass(type, compiler);
+ } else {
+ return new HType.nonNullExact(type, compiler);
}
}
- factory HType.fromNativeBehavior(native.NativeBehavior nativeBehavior,
- Compiler compiler) {
- if (nativeBehavior.typesReturned.isEmpty) return HType.UNKNOWN;
-
- HType ssaType = HType.CONFLICTING;
- for (final type in nativeBehavior.typesReturned) {
- ssaType = ssaType.union(
- new HType.fromNativeType(type, compiler), compiler);
- }
- assert(!ssaType.isConflicting());
- return ssaType;
- }
-
static const HType CONFLICTING = const HConflictingType();
static const HType UNKNOWN = const HUnknownType();
static const HType NON_NULL = const HNonNullType();
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/ssa/optimize.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698