File tree Expand file tree Collapse file tree 2 files changed +5
-12
lines changed Expand file tree Collapse file tree 2 files changed +5
-12
lines changed Original file line number Diff line number Diff line change @@ -1102,17 +1102,9 @@ inline BucketId GetBucketForSize(size_t bytes)
1102
1102
return BucketId::LargeObjectList;
1103
1103
}
1104
1104
1105
- BucketId bucket = (BucketId) (log2 (bytes) - 7 );
1106
-
1107
- // < 8 => 0
1108
- // 8 => 1
1109
- // 9 => 2 ...
1105
+ BucketId bucket = (BucketId) (log2 (bytes / Page::sizePerBit));
1110
1106
Assert (bucket < BucketId::LargeObjectList);
1111
-
1112
- if (bucket < BucketId::SmallObjectList)
1113
- {
1114
- bucket = BucketId::SmallObjectList;
1115
- }
1107
+ Assert (bucket >= BucketId::SmallObjectList);
1116
1108
1117
1109
return bucket;
1118
1110
}
Original file line number Diff line number Diff line change @@ -57,7 +57,7 @@ struct Page
57
57
58
58
bool CanAllocate (BucketId targetBucket)
59
59
{
60
- return freeBitVector.FirstStringOfOnes (targetBucket + 1 ) != BVInvalidIndex;
60
+ return freeBitVector.FirstStringOfOnes (1 << targetBucket ) != BVInvalidIndex;
61
61
}
62
62
63
63
Page (__in char * address, void * segment, BucketId bucket):
@@ -72,8 +72,9 @@ struct Page
72
72
73
73
// Each bit in the bit vector corresponds to 128 bytes of memory
74
74
// This implies that 128 bytes is the smallest allocation possible
75
- static const uint Alignment = 128 ;
76
75
static const uint MaxAllocationSize = 4096 ;
76
+ static const uint sizePerBit = MaxAllocationSize / 32 ; // pagesize / freeBitVector bit count
77
+ static const uint Alignment = sizePerBit; // 128
77
78
};
78
79
79
80
struct Allocation
You can’t perform that action at this time.
0 commit comments