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

Unified Diff: sdk/lib/_internal/compiler/implementation/js_backend/backend.dart

Issue 15299002: Reapply "Enable full type-checks in checked mode." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 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 side-by-side diff with in-line comments
Download patch
Index: sdk/lib/_internal/compiler/implementation/js_backend/backend.dart
diff --git a/sdk/lib/_internal/compiler/implementation/js_backend/backend.dart b/sdk/lib/_internal/compiler/implementation/js_backend/backend.dart
index c3052f44edd40502cd36be7be004cfadd33bb2ea..36bdbc2e74b25c6419370190100e00cbcbbf6d80 100644
--- a/sdk/lib/_internal/compiler/implementation/js_backend/backend.dart
+++ b/sdk/lib/_internal/compiler/implementation/js_backend/backend.dart
@@ -1229,19 +1229,26 @@ class JavaScriptBackend extends Backend {
void registerIsCheck(DartType type, Enqueuer world, TreeElements elements) {
world.registerInstantiatedClass(compiler.boolClass, elements);
bool isTypeVariable = type.kind == TypeKind.TYPE_VARIABLE;
+ bool inCheckedMode = compiler.enableTypeAssertions;
if (!type.isRaw || isTypeVariable) {
enqueueInResolution(getSetRuntimeTypeInfo(), elements);
enqueueInResolution(getGetRuntimeTypeInfo(), elements);
enqueueInResolution(getGetRuntimeTypeArgument(), elements);
+ if (inCheckedMode) {
+ enqueueInResolution(getAssertSubtype(), elements);
+ }
enqueueInResolution(getCheckSubtype(), elements);
if (isTypeVariable) {
- enqueueInResolution(getGetObjectIsSubtype(), elements);
+ enqueueInResolution(getCheckSubtypeOfRuntimeType(), elements);
+ if (inCheckedMode) {
+ enqueueInResolution(getAssertSubtypeOfRuntimeType(), elements);
+ }
}
world.registerInstantiatedClass(compiler.listClass, elements);
}
// [registerIsCheck] is also called for checked mode checks, so we
// need to register checked mode helpers.
- if (compiler.enableTypeAssertions) {
+ if (inCheckedMode) {
Element e = getCheckedModeHelper(type, typeCast: false);
if (e != null) world.addToWorkList(e);
// We also need the native variant of the check (for DOM types).
@@ -1327,8 +1334,8 @@ class JavaScriptBackend extends Backend {
}
bool needsRti(ClassElement cls) {
- return rti.classesNeedingRti.contains(cls.declaration)
- || compiler.enabledRuntimeType;
+ return rti.classesNeedingRti.contains(cls.declaration) ||
+ compiler.enabledRuntimeType;
}
bool isDefaultNoSuchMethodImplementation(Element element) {
@@ -1593,8 +1600,9 @@ class JavaScriptBackend extends Backend {
* backend with implementation types (JSInt, JSString, ...).
*/
Element getCheckedModeHelper(DartType type, {bool typeCast}) {
- return compiler.findHelper(getCheckedModeHelperName(
- type, typeCast: typeCast, nativeCheckOnly: false));
+ SourceString name = getCheckedModeHelperName(
+ type, typeCast: typeCast, nativeCheckOnly: false);
+ return compiler.findHelper(name);
}
/**
@@ -1693,13 +1701,22 @@ class JavaScriptBackend extends Backend {
}
} else {
if (nativeCheck) {
+ // TODO(karlklose): can we get rid of this branch when we use
+ // interceptors?
return typeCast
? const SourceString("interceptedTypeCast")
: const SourceString('interceptedTypeCheck');
} else {
- return typeCast
- ? const SourceString("propertyTypeCast")
- : const SourceString('propertyTypeCheck');
+ if (typeCast) {
+ return const SourceString("propertyTypeCast");
+ }
+ if (type.kind == TypeKind.INTERFACE && !type.isRaw) {
+ return const SourceString('assertSubtype');
+ } else if (type.kind == TypeKind.TYPE_VARIABLE) {
+ return const SourceString('assertSubtypeOfRuntimeType');
+ } else {
+ return const SourceString('propertyTypeCheck');
+ }
}
}
}
@@ -1782,8 +1799,17 @@ class JavaScriptBackend extends Backend {
return compiler.findHelper(const SourceString('checkSubtype'));
}
- Element getGetObjectIsSubtype() {
- return compiler.findHelper(const SourceString('objectIsSubtype'));
+ Element getAssertSubtype() {
+ return compiler.findHelper(const SourceString('assertSubtype'));
+ }
+
+ Element getCheckSubtypeOfRuntimeType() {
+ return compiler.findHelper(const SourceString('checkSubtypeOfRuntimeType'));
+ }
+
+ Element getAssertSubtypeOfRuntimeType() {
+ return compiler.findHelper(
+ const SourceString('assertSubtypeOfRuntimeType'));
}
Element getThrowNoSuchMethod() {
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/dart_types.dart ('k') | sdk/lib/_internal/compiler/implementation/lib/js_rti.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698