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

Unified Diff: lib/compiler/implementation/ssa/codegen.dart

Issue 10912147: Change our 'is int' check to use Math.floor instead of a smi check. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 3 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 | « lib/compiler/implementation/lib/js_helper.dart ('k') | pkg/intl/number_format.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/compiler/implementation/ssa/codegen.dart
===================================================================
--- lib/compiler/implementation/ssa/codegen.dart (revision 12017)
+++ lib/compiler/implementation/ssa/codegen.dart (working copy)
@@ -2148,6 +2148,16 @@
push(new js.Binary(cmp, left, or0));
}
+ void checkBigInt(HInstruction input, String cmp) {
+ use(input);
+ js.Expression left = pop();
+ use(input);
+ js.Expression right = pop();
+ // TODO(4984): Deal with infinity.
+ push(new js.LiteralExpression.withData('Math.floor(#) === #',
+ <js.Expression>[left, right]));
+ }
+
void checkTypeOf(HInstruction input, String cmp, String typeName) {
use(input);
js.Expression typeOf = new js.Prefix("typeof", pop());
@@ -2303,9 +2313,12 @@
checkFunction(input, type);
attachLocationToLast(node);
} else if (element == compiler.intClass) {
+ // The is check in the code tells us that it might not be an
+ // int. So we do a typeof first to avoid possible
+ // deoptimizations on the JS engine due to the Math.floor check.
checkNum(input, '===');
js.Expression numTest = pop();
- checkInt(input, '===');
+ checkBigInt(input, '===');
push(new js.Binary('&&', numTest, pop()), node);
} else if (Elements.isStringSupertype(element, compiler)) {
handleStringSupertypeCheck(input, type);
« no previous file with comments | « lib/compiler/implementation/lib/js_helper.dart ('k') | pkg/intl/number_format.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698