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

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

Issue 1301363002: dart2js cps: Generate fast checks for 'is String' and 'is bool'. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: 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 | pkg/compiler/lib/src/js_backend/codegen/glue.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/codegen/codegen.dart
diff --git a/pkg/compiler/lib/src/js_backend/codegen/codegen.dart b/pkg/compiler/lib/src/js_backend/codegen/codegen.dart
index 831db16e27bf98e3fe4845846d609fb69204f418..878145dafe31bbaa0338675b72218dcdf8a3a529 100644
--- a/pkg/compiler/lib/src/js_backend/codegen/codegen.dart
+++ b/pkg/compiler/lib/src/js_backend/codegen/codegen.dart
@@ -358,12 +358,28 @@ class CodeGenerator extends tree_ir.StatementVisitor
// Handle some special checks against classes that exist only in
// the compile-time class hierarchy, not at runtime.
+ // TODO(sra): Is this correct? The field tests are only valid with the
+ // precondition that [value] is an Array. They will crash on `null`.
if (clazz == glue.jsExtendableArrayClass) {
+ assert(node.isTypeTest);
return js.js(r'!#.fixed$length', <js.Expression>[value]);
} else if (clazz == glue.jsMutableArrayClass) {
+ assert(node.isTypeTest);
return js.js(r'!#.immutable$list', <js.Expression>[value]);
}
+ if (glue.isStringClass(clazz)) {
+ if (node.isTypeTest) {
+ return js.js(r'typeof # === "string"', <js.Expression>[value]);
+ }
+ // TODO(sra): Implement fast cast via calling 'stringTypeCast'.
+ } else if (glue.isBoolClass(clazz)) {
+ if (node.isTypeTest) {
+ return js.js(r'typeof # === "boolean"', <js.Expression>[value]);
+ }
+ // TODO(sra): Implement fast cast via calling 'boolTypeCast'.
+ }
+
// The helper we use needs the JSArray class to exist, but for some
// reason the helper does not cause this dependency to be registered.
// TODO(asgerf): Most programs need List anyway, but we should fix this.
« no previous file with comments | « no previous file | pkg/compiler/lib/src/js_backend/codegen/glue.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698