Revision: 4250
Author: [email protected]
Date: Wed Mar 24 05:34:27 2010
Log: Add primitive type and string type to the number info.

This change adds two new type attributes to  the lattice
defined in the class NumberInfo. Currently the new types
are not used yet.

I plan to rename NumberInfo into TypeInfo as a separate change.

Review URL: http://codereview.chromium.org/1249002
http://code.google.com/p/v8/source/detail?r=4250

Modified:
 /branches/bleeding_edge/src/frame-element.h
 /branches/bleeding_edge/src/number-info.h
 /branches/bleeding_edge/src/register-allocator.h

=======================================
--- /branches/bleeding_edge/src/frame-element.h Tue Mar 16 09:07:19 2010
+++ /branches/bleeding_edge/src/frame-element.h Wed Mar 24 05:34:27 2010
@@ -262,12 +262,13 @@
   // Encode type, copied, synced and data in one 32 bit integer.
   uint32_t value_;

+  // Declare BitFields with template parameters <type, start, size>.
   class TypeField: public BitField<Type, 0, 3> {};
   class CopiedField: public BitField<bool, 3, 1> {};
   class SyncedField: public BitField<bool, 4, 1> {};
   class UntaggedInt32Field: public BitField<bool, 5, 1> {};
-  class NumberInfoField: public BitField<int, 6, 4> {};
-  class DataField: public BitField<uint32_t, 10, 32 - 10> {};
+  class NumberInfoField: public BitField<int, 6, 6> {};
+  class DataField: public BitField<uint32_t, 12, 32 - 12> {};

   friend class VirtualFrame;
 };
=======================================
--- /branches/bleeding_edge/src/number-info.h   Fri Mar  5 15:54:13 2010
+++ /branches/bleeding_edge/src/number-info.h   Wed Mar 24 05:34:27 2010
@@ -33,19 +33,23 @@

 //        Unknown
 //           |
-//         Number
-//         /    |
-//  HeapNumber Integer32
-//        |      |
-//        |     Smi
-//        |     /
-//      Uninitialized.
+//      PrimitiveType
+//           |   \--------|
+//         Number      String
+//         /    |         |
+//  HeapNumber Integer32  |
+//        |      |       /
+//        |     Smi     /
+//        |     /      /
+//        Uninitialized.

 class NumberInfo {
  public:
   NumberInfo() { }

   static inline NumberInfo Unknown();
+  // We know it's a primitive type.
+  static inline NumberInfo Primitive();
   // We know it's a number of some sort.
   static inline NumberInfo Number();
   // We know it's signed or unsigned 32 bit integer.
@@ -54,13 +58,18 @@
   static inline NumberInfo Smi();
   // We know it's a heap number.
   static inline NumberInfo HeapNumber();
+  // We know it's a string.
+  static inline NumberInfo String();
   // We haven't started collecting info yet.
   static inline NumberInfo Uninitialized();

   // Return compact representation.  Very sensitive to enum values below!
+  // Compacting drops information about primtive types and strings types.
+ // We use the compact representation when we only care about number types.
   int ThreeBitRepresentation() {
     ASSERT(type_ != kUninitializedType);
-    int answer = type_ > 6 ? type_ -2 : type_;
+    int answer = type_ & 0xf;
+    answer = answer > 6 ? answer - 2 : answer;
     ASSERT(answer >= 0);
     ASSERT(answer <= 7);
     return answer;
@@ -71,6 +80,7 @@
     Type t = static_cast<Type>(three_bit_representation >= 6 ?
                                three_bit_representation + 2 :
                                three_bit_representation);
+    t = (t == kUnknownType) ? t : static_cast<Type>(t | kPrimitiveType);
     ASSERT(t == kUnknownType ||
            t == kNumberType ||
            t == kInteger32Type ||
@@ -86,10 +96,12 @@
   static NumberInfo FromInt(int bit_representation) {
     Type t = static_cast<Type>(bit_representation);
     ASSERT(t == kUnknownType ||
+           t == kPrimitiveType ||
            t == kNumberType ||
            t == kInteger32Type ||
            t == kSmiType ||
-           t == kHeapNumberType);
+           t == kHeapNumberType ||
+           t == kStringType);
     return NumberInfo(t);
   }

@@ -129,10 +141,12 @@
   const char* ToString() {
     switch (type_) {
       case kUnknownType: return "UnknownType";
+      case kPrimitiveType: return "PrimitiveType";
       case kNumberType: return "NumberType";
+      case kInteger32Type: return "Integer32Type";
       case kSmiType: return "SmiType";
       case kHeapNumberType: return "HeapNumberType";
-      case kInteger32Type: return "Integer32Type";
+      case kStringType: return "StringType";
       case kUninitializedType:
         UNREACHABLE();
         return "UninitializedType";
@@ -142,13 +156,16 @@
   }

  private:
+  // We use 6 bits to represent the types.
   enum Type {
-    kUnknownType = 0,
-    kNumberType = 1,
-    kInteger32Type = 3,
-    kSmiType = 7,
-    kHeapNumberType = 9,
-    kUninitializedType = 15
+    kUnknownType = 0,          // 000000
+    kPrimitiveType = 0x10,     // 010000
+    kNumberType = 0x11,        // 010001
+    kInteger32Type = 0x13,     // 010011
+    kSmiType = 0x17,           // 010111
+    kHeapNumberType = 0x19,    // 011001
+    kStringType = 0x30,        // 110000
+    kUninitializedType = 0x3f  // 111111
   };
   explicit inline NumberInfo(Type t) : type_(t) { }

@@ -159,6 +176,11 @@
 NumberInfo NumberInfo::Unknown() {
   return NumberInfo(kUnknownType);
 }
+
+
+NumberInfo NumberInfo::Primitive() {
+  return NumberInfo(kPrimitiveType);
+}


 NumberInfo NumberInfo::Number() {
@@ -179,6 +201,11 @@
 NumberInfo NumberInfo::HeapNumber() {
   return NumberInfo(kHeapNumberType);
 }
+
+
+NumberInfo NumberInfo::String() {
+  return NumberInfo(kStringType);
+}


 NumberInfo NumberInfo::Uninitialized() {
=======================================
--- /branches/bleeding_edge/src/register-allocator.h Tue Mar 16 09:07:19 2010 +++ /branches/bleeding_edge/src/register-allocator.h Wed Mar 24 05:34:27 2010
@@ -152,10 +152,11 @@
  private:
   uint32_t value_;

+  // Declare BitFields with template parameters <type, start, size>.
   class TypeField: public BitField<Type, 0, 2> {};
-  class NumberInfoField : public BitField<int, 2, 4> {};
-  class IsUntaggedInt32Field : public BitField<bool, 6, 1> {};
-  class DataField: public BitField<uint32_t, 7, 32 - 7> {};
+  class NumberInfoField : public BitField<int, 2, 6> {};
+  class IsUntaggedInt32Field : public BitField<bool, 8, 1> {};
+  class DataField: public BitField<uint32_t, 9, 32 - 9> {};

   inline void CopyTo(Result* destination) const;

--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

To unsubscribe from this group, send email to v8-dev+unsubscribegooglegroups.com or reply 
to this email with the words "REMOVE ME" as the subject.

Reply via email to