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

Unified Diff: src/runtime.cc

Issue 660084: Optimize 3 Number2Integer functions in runtime.cc: remove the check that was ... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 10 years, 10 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/runtime.cc
===================================================================
--- src/runtime.cc (revision 3939)
+++ src/runtime.cc (working copy)
@@ -4152,10 +4152,13 @@
NoHandleAllocation ha;
ASSERT(args.length() == 1);
- Object* obj = args[0];
- if (obj->IsSmi()) return obj;
- CONVERT_DOUBLE_CHECKED(number, obj);
- return Heap::NumberFromDouble(DoubleToInteger(number));
+ CONVERT_DOUBLE_CHECKED(number, args[0]);
+
+ // We do not include 0 so that we didn't have to treat +0 / -0 cases.
Mads Ager (chromium) 2010/02/25 15:11:03 didn't -> don't
Oleg Eterevsky 2010/02/25 15:30:43 Done.
+ if (number > 0 && number <= Smi::kMaxValue)
Mads Ager (chromium) 2010/02/25 15:11:03 Please use braces around both the if and the else
Oleg Eterevsky 2010/02/25 15:30:43 Done.
+ return Smi::FromInt(static_cast<int>(number));
+ else
+ return Heap::NumberFromDouble(DoubleToInteger(number));
}
@@ -4164,7 +4167,6 @@
ASSERT(args.length() == 1);
Object* obj = args[0];
Mads Ager (chromium) 2010/02/25 15:11:03 Just use args[0] in the CONVERT_NUMBER_CHECKED bel
Oleg Eterevsky 2010/02/25 15:30:43 Done.
- if (obj->IsSmi() && Smi::cast(obj)->value() >= 0) return obj;
CONVERT_NUMBER_CHECKED(int32_t, number, Uint32, obj);
return Heap::NumberFromUint32(number);
}
@@ -4174,10 +4176,11 @@
NoHandleAllocation ha;
ASSERT(args.length() == 1);
- Object* obj = args[0];
- if (obj->IsSmi()) return obj;
- CONVERT_DOUBLE_CHECKED(number, obj);
- return Heap::NumberFromInt32(DoubleToInt32(number));
+ CONVERT_DOUBLE_CHECKED(number, args[0]);
+ if (number > 0 && number <= Smi::kMaxValue)
Mads Ager (chromium) 2010/02/25 15:11:03 Please use braces here as well. Repeat the commen
Oleg Eterevsky 2010/02/25 15:30:43 Done.
+ return Smi::FromInt(static_cast<int>(number));
+ else
+ return Heap::NumberFromInt32(DoubleToInt32(number));
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698