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

Unified Diff: src/types.cc

Issue 25722002: More precise type lub for numbers (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Comments Created 7 years, 2 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/types.cc
diff --git a/src/types.cc b/src/types.cc
index 70ddccd6a74eeebf9f3ee0c3b3ceb941f2c80ca8..0086313eee83970539e77644ad930ab5b6eaef1c 100644
--- a/src/types.cc
+++ b/src/types.cc
@@ -128,11 +128,18 @@ int Type::LubBitset() {
Handle<v8::internal::Object> value = this->as_constant();
if (value->IsSmi()) return kSmi;
map = HeapObject::cast(*value)->map();
+ if (map->instance_type() == HEAP_NUMBER_TYPE) {
+ int32_t i;
+ uint32_t u;
+ if (value->ToInt32(&i)) return Smi::IsValid(i) ? kSmi : kOtherSigned32;
+ if (value->ToUint32(&u)) return kUnsigned32;
+ return kDouble;
+ }
if (map->instance_type() == ODDBALL_TYPE) {
if (value->IsUndefined()) return kUndefined;
if (value->IsNull()) return kNull;
if (value->IsTrue() || value->IsFalse()) return kBoolean;
- if (value->IsTheHole()) return kAny;
+ if (value->IsTheHole()) return kAny; // TODO(rossberg): kNone?
}
}
switch (map->instance_type()) {
@@ -162,9 +169,8 @@ int Type::LubBitset() {
case SYMBOL_TYPE:
return kSymbol;
case ODDBALL_TYPE:
- return kOddball;
case HEAP_NUMBER_TYPE:
- return kDouble;
+ UNREACHABLE();
case JS_VALUE_TYPE:
case JS_DATE_TYPE:
case JS_OBJECT_TYPE:
« 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