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

Unified Diff: lib/runtime/_operations.js

Issue 1291623005: Skip type checks on native JavaScriptObjects (Closed) Base URL: https://github.com/dart-lang/dev_compiler.git@master
Patch Set: Skip type checks on JSOs Created 5 years, 4 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 | « no previous file | lib/runtime/_rtti.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/runtime/_operations.js
diff --git a/lib/runtime/_operations.js b/lib/runtime/_operations.js
index b50b8ba9089f6299062e25e59ccf9e1fba1b5149..1dfae7521d77167646681dad5585e86007e3ba3b 100644
--- a/lib/runtime/_operations.js
+++ b/lib/runtime/_operations.js
@@ -192,7 +192,8 @@ dart_library.library('dart_runtime/_operations', null, /* Imports */[
}
function strongInstanceOf(obj, type) {
- return types.isSubtype(rtti.realRuntimeType(obj), type);
+ let actual = rtti.realRuntimeType(obj);
+ return types.isSubtype(actual, type) || actual == types.jsobject;
}
exports.strongInstanceOf = strongInstanceOf;
@@ -203,7 +204,7 @@ dart_library.library('dart_runtime/_operations', null, /* Imports */[
function instanceOf(obj, type) {
if (strongInstanceOf(obj, type)) return true;
- // TODO(vsm): This is perhaps too eager to throw a StrongModeError?
+ // TODO(#296): This is perhaps too eager to throw a StrongModeError?
// It will throw on <int>[] is List<String>.
// TODO(vsm): We can statically detect many cases where this
// check is unnecessary.
@@ -216,20 +217,14 @@ dart_library.library('dart_runtime/_operations', null, /* Imports */[
exports.instanceOf = instanceOf;
function cast(obj, type) {
+ // TODO(#296): This is perhaps too eager to throw a StrongModeError?
// TODO(vsm): handle non-nullable types
if (instanceOfOrNull(obj, type)) return obj;
let actual = rtti.realRuntimeType(obj);
- if (_ignoreTypeFailure(actual, type)) {
- // TODO(vsm): track why this is happening in our async / await tests.
- if (types.isGroundType(type)) {
- console.error('Should not ignore cast failure from ' +
- types.typeName(actual) + ' to ' + types.typeName(type));
- }
- return obj;
- }
- if (types.isGroundType(type)) {
- errors.throwCastError(actual, type);
- }
+ if (types.isGroundType(type)) errors.throwCastError(actual, type);
+
+ if (_ignoreTypeFailure(actual, type)) return obj;
+
dart_utils.throwStrongModeError('Strong mode cast failure from ' +
types.typeName(actual) + ' to ' + types.typeName(type));
}
« no previous file with comments | « no previous file | lib/runtime/_rtti.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698