@@ -30,19 +30,16 @@ struct object {};
3030// The three low bits make up a primary tag, used to differentiate gc_obj
3131// from immediate objects. All even tags map to SmallInt, which is
3232// optimized by checking only the lowest bit for parity.
33- enum {
34- kSmallIntTagBits = 1 ,
35- kPrimaryTagBits = 3 ,
36- kImmediateTagBits = 5 ,
37- kWordSize = sizeof (word ),
38- kBitsPerByte = 8 ,
39- kBitsPerPointer = kBitsPerByte * kWordSize ,
40- };
33+ static const uword kSmallIntTagBits = 1 ;
34+ static const uword kPrimaryTagBits = 3 ;
35+ static const uword kImmediateTagBits = 5 ;
4136static const uword kSmallIntTagMask = (1 << kSmallIntTagBits ) - 1 ;
4237static const uword kPrimaryTagMask = (1 << kPrimaryTagBits ) - 1 ;
4338static const uword kImmediateTagMask = (1 << kImmediateTagBits ) - 1 ;
4439
45- static const word kMaxSmallStringLength = kWordSize - 1 ;
40+ static const uword kWordSize = sizeof (word );
41+ static const uword kMaxSmallStringLength = kWordSize - 1 ;
42+ static const uword kBitsPerByte = 8 ;
4643
4744static const uword kSmallIntTag = 0 ; // 0b****0
4845static const uword kHeapObjectTag = 1 ; // 0b**001
@@ -74,7 +71,6 @@ static ALWAYS_INLINE uword small_string_length(struct object* obj) {
7471}
7572static ALWAYS_INLINE struct object * mksmallstring (const char * data ,
7673 uword length ) {
77- assert (length >= 0 );
7874 assert (length <= kMaxSmallStringLength );
7975 uword result = 0 ;
8076 for (word i = length - 1 ; i >= 0 ; i -- ) {
@@ -90,7 +86,6 @@ static ALWAYS_INLINE struct object* mksmallstring(const char* data,
9086}
9187static ALWAYS_INLINE char small_string_at (struct object * obj , uword index ) {
9288 assert (is_small_string (obj ));
93- assert (index >= 0 );
9489 assert (index < small_string_length (obj ));
9590 // +1 for (length | tag) byte
9691 return ((uword )obj >> ((index + 1 ) * kBitsPerByte )) & 0xFF ;
@@ -346,9 +341,8 @@ size_t trace_heap_object(struct gc_obj* obj, struct gc_heap* heap,
346341 return heap_object_size (obj );
347342}
348343
349- enum {
350- kSmallIntBits = kBitsPerPointer - kSmallIntTagBits ,
351- };
344+ static const uword kBitsPerPointer = kBitsPerByte * kWordSize ;
345+ static const word kSmallIntBits = kBitsPerPointer - kSmallIntTagBits ;
352346static const word kSmallIntMinValue = - (((word )1 ) << (kSmallIntBits - 1 ));
353347static const word kSmallIntMaxValue = (((word )1 ) << (kSmallIntBits - 1 )) - 1 ;
354348
0 commit comments