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

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

Issue 13019003: Enable full type-checks in checked mode. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix a bug. 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
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 a2cffcf2f09c84d36757f28e83471cb10a9e35a2..b0b27f5849cd62b1f8e9c5b6b4b3c4f5a77259be 100644
--- a/sdk/lib/_internal/compiler/implementation/js_backend/backend.dart
+++ b/sdk/lib/_internal/compiler/implementation/js_backend/backend.dart
@@ -1176,19 +1176,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 isCheckedMode = compiler.enableTypeAssertions;
if (!type.isRaw || isTypeVariable) {
enqueueInResolution(getSetRuntimeTypeInfo(), elements);
enqueueInResolution(getGetRuntimeTypeInfo(), elements);
enqueueInResolution(getGetRuntimeTypeArgument(), elements);
+ if (isCheckedMode) {
+ enqueueInResolution(getAssertSubtype(), elements);
+ }
enqueueInResolution(getCheckSubtype(), elements);
if (isTypeVariable) {
- enqueueInResolution(getGetObjectIsSubtype(), elements);
+ enqueueInResolution(getObjectIsSubtype(), elements);
+ if (isCheckedMode) {
+ enqueueInResolution(getAssertObjectIsSubtype(), 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 (isCheckedMode) {
Element e = getCheckedModeHelper(type, typeCast: false);
if (e != null) world.addToWorkList(e);
// We also need the native variant of the check (for DOM types).
@@ -1274,8 +1281,9 @@ class JavaScriptBackend extends Backend {
}
bool needsRti(ClassElement cls) {
- return rti.classesNeedingRti.contains(cls.declaration)
- || compiler.enabledRuntimeType;
+ return rti.classesNeedingRti.contains(cls.declaration) ||
+ compiler.enabledRuntimeType ||
+ (compiler.enableTypeAssertions && !cls.typeVariables.isEmpty);
ngeoffray 2013/04/15 10:59:14 Is that because we never know if there will be a t
}
bool isDefaultNoSuchMethodImplementation(Element element) {
@@ -1708,10 +1716,18 @@ class JavaScriptBackend extends Backend {
return compiler.findHelper(const SourceString('checkSubtype'));
}
- Element getGetObjectIsSubtype() {
+ Element getAssertSubtype() {
+ return compiler.findHelper(const SourceString('assertSubtype'));
+ }
+
+ Element getObjectIsSubtype() {
return compiler.findHelper(const SourceString('objectIsSubtype'));
}
+ Element getAssertObjectIsSubtype() {
+ return compiler.findHelper(const SourceString('assertObjectIsSubtype'));
+ }
+
Element getThrowNoSuchMethod() {
return compiler.findHelper(const SourceString('throwNoSuchMethod'));
}

Powered by Google App Engine
This is Rietveld 408576698