Revision: 17139
Author: [email protected]
Date: Thu Oct 10 12:30:06 2013 UTC
Log: More precise type lub for numbers
[email protected]
BUG=v8:2910
Review URL: https://codereview.chromium.org/25722002
http://code.google.com/p/v8/source/detail?r=17139
Modified:
/branches/bleeding_edge/src/types.cc
/branches/bleeding_edge/src/types.h
=======================================
--- /branches/bleeding_edge/src/types.cc Thu Jul 25 11:53:38 2013 UTC
+++ /branches/bleeding_edge/src/types.cc Thu Oct 10 12:30:06 2013 UTC
@@ -128,11 +128,19 @@
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?
+ UNREACHABLE();
}
}
switch (map->instance_type()) {
@@ -230,7 +238,7 @@
// Check this <= that.
-bool Type::IsSlowCase(Type* that) {
+bool Type::SlowIs(Type* that) {
// Fast path for bitsets.
if (that->is_bitset()) {
return (this->LubBitset() | that->as_bitset()) == that->as_bitset();
=======================================
--- /branches/bleeding_edge/src/types.h Fri Sep 20 07:21:30 2013 UTC
+++ /branches/bleeding_edge/src/types.h Thu Oct 10 12:30:06 2013 UTC
@@ -156,7 +156,7 @@
static Type* Intersect(Handle<Type> type1, Handle<Type> type2);
static Type* Optional(Handle<Type> type); // type \/ Undefined
- bool Is(Type* that) { return (this == that) ? true : IsSlowCase(that); }
+ bool Is(Type* that) { return (this == that) ? true : SlowIs(that); }
bool Is(Handle<Type> that) { return this->Is(*that); }
bool Maybe(Type* that);
bool Maybe(Handle<Type> that) { return this->Maybe(*that); }
@@ -231,7 +231,7 @@
bool is_constant() { return this->IsBox(); }
bool is_union() { return this->IsFixedArray(); }
- bool IsSlowCase(Type* that);
+ bool SlowIs(Type* that);
int as_bitset() { return Smi::cast(this)->value(); }
Handle<Map> as_class() { return Handle<Map>::cast(handle()); }
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.