Changeset 68:34040d3abeb0 in rrlib_util


Ignore:
Timestamp:
21.10.2012 15:14:38 (7 years ago)
Author:
Max Reichardt <mreichardt@…>
Branch:
default
Phase:
public
Message:

Tagged pointers can now have 32 bit tags on 32 bit platforms.

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • tTaggedPointer.h

    r67 r68  
    6767 * \tparam Pointer type (without *) 
    6868 * \tparam ALIGNED_POINTERS Are the T pointers used with this class 8-byte aligned? (Typically the case for any object T created with 'new') 
    69  * \tparam TAG_BIT_WIDTH Bit width of tag. For maximum portability, this is limited to 19 bits (values 0-524287) for aligned pointers 
     69 * \tparam TAG_BIT_WIDTH Bit width of tag. 19 bits is supported on all platforms (values 0-524287) for aligned pointers 
    7070 *                       and 16 bits (values 0-65535) for non-aligned pointers. 
    7171 *                       A value of <= 3 (values 0-7) requires only a 32 bit integer for aligned pointers on 32 bit platforms. 
     72 *                       Maximum bit width on 32 bit platforms is 32. 
    7273 * 
    7374 * Assertions make sure that only valid pointers and stamps are used. 
     
    7879  typedef tagged_pointer::tTaggedPointerImplementation<TAG_BIT_WIDTH, ALIGNED_POINTERS> tImplementation; 
    7980 
    80   static_assert(TAG_BIT_WIDTH >= 1 && (TAG_BIT_WIDTH <= 16 || (ALIGNED_POINTERS && TAG_BIT_WIDTH <= 19)), "Invalid TAG_BIT_WIDTH"); 
     81  static_assert(TAG_BIT_WIDTH >= 1 && ((sizeof(void*) == 4 && TAG_BIT_WIDTH <= 32) || (TAG_BIT_WIDTH <= 16 || (ALIGNED_POINTERS && TAG_BIT_WIDTH <= 19))), "Invalid TAG_BIT_WIDTH"); 
    8182 
    8283//---------------------------------------------------------------------- 
     
    99100    implementation.SetRaw(raw_tagged_pointer); 
    100101  } 
    101   tTaggedPointer(T* pointer, int stamp) 
     102  tTaggedPointer(T* pointer, uint stamp) 
    102103  { 
    103104    Set(pointer, stamp); 
     
    115116   * \return Stamp stored in this object 
    116117   */ 
    117   int GetStamp() const 
     118  uint GetStamp() const 
    118119  { 
    119120    return implementation.GetStamp(); 
     
    124125   * \param stamp New stamp 
    125126   */ 
    126   void Set(T* pointer, int stamp) 
     127  void Set(T* pointer, uint stamp) 
    127128  { 
    128129    assert((stamp & cSTAMP_MASK) == stamp && "Stamp is out of bounds"); 
     
    143144   * \param stamp New stamp 
    144145   */ 
    145   void SetStamp(int stamp) 
     146  void SetStamp(uint stamp) 
    146147  { 
    147148    assert((stamp & cSTAMP_MASK) == stamp && "Stamp is out of bounds"); 
  • tagged_pointer/tTaggedPointerImplementation.h

    r67 r68  
    127127  } 
    128128 
    129   int GetStamp() const 
     129  uint GetStamp() const 
    130130  { 
    131131    return static_cast<int>(storage >> 48); 
    132132  } 
    133133 
    134   void Set(void* pointer, int stamp) 
     134  void Set(void* pointer, uint stamp) 
    135135  { 
    136136    uint64_t pointer_int = reinterpret_cast<uint64_t>(pointer); 
     
    148148  } 
    149149 
    150   void SetStamp(int stamp) 
     150  void SetStamp(uint stamp) 
    151151  { 
    152152    uint64_t old_pointer = storage & POINTER16_MASK; 
     
    166166  } 
    167167 
    168   int GetStamp() const 
    169   { 
    170     return static_cast<int>(storage >> 45); 
    171   } 
    172  
    173   void Set(void* pointer, int stamp) 
     168  uint GetStamp() const 
     169  { 
     170    return static_cast<uint>(storage >> 45); 
     171  } 
     172 
     173  void Set(void* pointer, uint stamp) 
    174174  { 
    175175    uint64_t pointer_int = reinterpret_cast<uint64_t>(pointer); 
     
    187187  } 
    188188 
    189   void SetStamp(int stamp) 
     189  void SetStamp(uint stamp) 
    190190  { 
    191191    uint64_t old_pointer = storage & POINTER19_MASK; 
     
    213213  } 
    214214 
    215   int GetStamp() const 
    216   { 
    217     return static_cast<int>(storage & STAMP3_MASK); 
    218   } 
    219  
    220   void Set(void* pointer, int stamp) 
     215  uint GetStamp() const 
     216  { 
     217    return static_cast<uint>(storage & STAMP3_MASK); 
     218  } 
     219 
     220  void Set(void* pointer, uint stamp) 
    221221  { 
    222222    uint pointer_int = reinterpret_cast<uint>(pointer); 
     
    229229  } 
    230230 
    231   void SetStamp(int stamp) 
     231  void SetStamp(uint stamp) 
    232232  { 
    233233    uint old_pointer = storage & POINTER3_MASK; 
     
    249249  } 
    250250 
    251   int GetStamp() const 
    252   { 
    253     return static_cast<int>(ints[1]); 
     251  uint GetStamp() const 
     252  { 
     253    return static_cast<uint>(ints[1]); 
    254254  } 
    255255 
     
    264264  } 
    265265 
    266   void Set(void* pointer, int stamp) 
     266  void Set(void* pointer, uint stamp) 
    267267  { 
    268268    SetPointer(pointer); 
     
    280280  } 
    281281 
    282   void SetStamp(int stamp) 
     282  void SetStamp(uint stamp) 
    283283  { 
    284284    ints[1] = stamp; 
Note: See TracChangeset for help on using the changeset viewer.