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

Unified Diff: src/types.h

Issue 16361015: Migrate Compare ICs to new type rep (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Comments Created 7 years, 6 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 | « src/type-info.cc ('k') | src/types.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/types.h
diff --git a/src/types.h b/src/types.h
index 6db9bfbb6a4d8daaee77a06e0c723b6f0fa05bd7..883d8840e62cb28a42e62b336d0b007fa3800ce2 100644
--- a/src/types.h
+++ b/src/types.h
@@ -48,11 +48,15 @@ namespace internal {
// T <= Any
//
// Oddball = Boolean \/ Null \/ Undefined
-// Number = Smi \/ Double
+// Number = Integer32 \/ Double
+// Integer31 < Integer32
// Name = String \/ Symbol
// UniqueName = InternalizedString \/ Symbol
// InternalizedString < String
//
+// Allocated = Receiver \/ Number \/ Name
+// Detectable = Allocated - Undetectable
+// Undetectable < Object
// Receiver = Object \/ Proxy
// Array < Object
// Function < Object
@@ -70,8 +74,9 @@ namespace internal {
// T1->Is(T2) -- tests whether T1 is included in T2 (i.e., T1 <= T2)
// T1->Maybe(T2) -- tests whether T1 and T2 overlap (i.e., T1 /\ T2 =/= 0)
//
-// Typically, the latter should be used to check whether a specific case needs
-// handling (e.g., via T->Maybe(Number)).
+// Typically, the former is to be used to select representations (e.g., via
+// T->Is(Integer31())), and the to check whether a specific case needs handling
+// (e.g., via T->Maybe(Number())).
//
// There is no functionality to discover whether a type is a leaf in the
// lattice. That is intentional. It should always be possible to refine the
@@ -89,6 +94,8 @@ class Type : public Object {
public:
static Type* None() { return from_bitset(kNone); }
static Type* Any() { return from_bitset(kAny); }
+ static Type* Allocated() { return from_bitset(kAllocated); }
+ static Type* Detectable() { return from_bitset(kDetectable); }
static Type* Oddball() { return from_bitset(kOddball); }
static Type* Boolean() { return from_bitset(kBoolean); }
@@ -96,7 +103,8 @@ class Type : public Object {
static Type* Undefined() { return from_bitset(kUndefined); }
static Type* Number() { return from_bitset(kNumber); }
- static Type* Smi() { return from_bitset(kSmi); }
+ static Type* Integer31() { return from_bitset(kInteger31); }
+ static Type* Integer32() { return from_bitset(kInteger32); }
static Type* Double() { return from_bitset(kDouble); }
static Type* Name() { return from_bitset(kName); }
@@ -107,6 +115,7 @@ class Type : public Object {
static Type* Receiver() { return from_bitset(kReceiver); }
static Type* Object() { return from_bitset(kObject); }
+ static Type* Undetectable() { return from_bitset(kUndetectable); }
static Type* Array() { return from_bitset(kArray); }
static Type* Function() { return from_bitset(kFunction); }
static Type* Proxy() { return from_bitset(kProxy); }
@@ -122,10 +131,49 @@ class Type : public Object {
static Type* Union(Handle<Type> type1, Handle<Type> type2);
static Type* Optional(Handle<Type> type); // type \/ Undefined
- bool Is(Handle<Type> that);
- bool Maybe(Handle<Type> that);
+ bool Is(Type* that);
+ bool Is(Handle<Type> that) { return this->Is(*that); }
+ bool Maybe(Type* that);
+ bool Maybe(Handle<Type> that) { return this->Maybe(*that); }
- // TODO(rossberg): method to iterate unions?
+ bool IsClass() { return is_class(); }
+ bool IsConstant() { return is_constant(); }
+ Handle<Map> AsClass() { return as_class(); }
+ Handle<v8::internal::Object> AsConstant() { return as_constant(); }
+
+ int NumClasses();
+ int NumConstants();
+
+ template<class T>
+ class Iterator {
+ public:
+ bool Done() const { return index_ < 0; }
+ Handle<T> Current();
+ void Advance();
+
+ private:
+ friend class Type;
+
+ Iterator() : index_(-1) {}
+ explicit Iterator(Handle<Type> type) : type_(type), index_(-1) {
+ Advance();
+ }
+
+ inline bool matches(Handle<Type> type);
+ inline Handle<Type> get_type();
+
+ Handle<Type> type_;
+ int index_;
+ };
+
+ Iterator<Map> Classes() {
+ if (this->is_bitset()) return Iterator<Map>();
+ return Iterator<Map>(this->handle());
+ }
+ Iterator<v8::internal::Object> Constants() {
+ if (this->is_bitset()) return Iterator<v8::internal::Object>();
+ return Iterator<v8::internal::Object>(this->handle());
+ }
private:
// A union is a fixed array containing types. Invariants:
@@ -138,24 +186,29 @@ class Type : public Object {
kNull = 1 << 0,
kUndefined = 1 << 1,
kBoolean = 1 << 2,
- kSmi = 1 << 3,
- kDouble = 1 << 4,
- kSymbol = 1 << 5,
- kInternalizedString = 1 << 6,
- kOtherString = 1 << 7,
- kArray = 1 << 8,
- kFunction = 1 << 9,
- kOtherObject = 1 << 10,
- kProxy = 1 << 11,
+ kInteger31 = 1 << 3,
+ kOtherInteger = 1 << 4,
+ kDouble = 1 << 5,
+ kSymbol = 1 << 6,
+ kInternalizedString = 1 << 7,
+ kOtherString = 1 << 8,
+ kUndetectable = 1 << 9,
+ kArray = 1 << 10,
+ kFunction = 1 << 11,
+ kOtherObject = 1 << 12,
+ kProxy = 1 << 13,
kOddball = kBoolean | kNull | kUndefined,
- kNumber = kSmi | kDouble,
+ kInteger32 = kInteger31 | kOtherInteger,
+ kNumber = kInteger32 | kDouble,
kString = kInternalizedString | kOtherString,
kUniqueName = kSymbol | kInternalizedString,
kName = kSymbol | kString,
- kObject = kArray | kFunction | kOtherObject,
+ kObject = kUndetectable | kArray | kFunction | kOtherObject,
kReceiver = kObject | kProxy,
- kAny = kOddball | kNumber | kName | kReceiver,
+ kAllocated = kDouble | kName | kReceiver,
+ kAny = kOddball | kNumber | kAllocated,
+ kDetectable = kAllocated - kUndetectable,
kNone = 0
};
@@ -166,7 +219,10 @@ class Type : public Object {
int as_bitset() { return Smi::cast(this)->value(); }
Handle<Map> as_class() { return Handle<Map>::cast(handle()); }
- Handle<Box> as_constant() { return Handle<Box>::cast(handle()); }
+ Handle<v8::internal::Object> as_constant() {
+ Handle<Box> box = Handle<Box>::cast(handle());
+ return v8::internal::handle(box->value(), box->GetIsolate());
+ }
Handle<Unioned> as_union() { return Handle<Unioned>::cast(handle()); }
Handle<Type> handle() { return handle_via_isolate_of(this); }
« no previous file with comments | « src/type-info.cc ('k') | src/types.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698