@@ -58,15 +58,7 @@ Zone::~Zone() {
58
58
59
59
void * Zone::New (size_t size) {
60
60
// Round up the requested size to fit the alignment.
61
- size = RoundUp (size, kAlignment );
62
-
63
- // If the allocation size is divisible by 8 then we return an 8-byte aligned
64
- // address.
65
- if (kPointerSize == 4 && kAlignment == 4 ) {
66
- position_ += ((~size) & 4 ) & (reinterpret_cast <intptr_t >(position_) & 4 );
67
- } else {
68
- DCHECK (kAlignment >= kPointerSize );
69
- }
61
+ size = RoundUp (size, kAlignmentInBytes );
70
62
71
63
// Check if the requested size is available without expanding.
72
64
Address result = position_;
@@ -86,7 +78,7 @@ void* Zone::New(size_t size) {
86
78
ASAN_POISON_MEMORY_REGION (redzone_position, kASanRedzoneBytes );
87
79
88
80
// Check that the result has the proper alignment and return it.
89
- DCHECK (IsAddressAligned (result, kAlignment , 0 ));
81
+ DCHECK (IsAddressAligned (result, kAlignmentInBytes , 0 ));
90
82
allocation_size_ += size;
91
83
return reinterpret_cast <void *>(result);
92
84
}
@@ -121,7 +113,7 @@ void Zone::DeleteAll() {
121
113
// force a new segment to be allocated on demand.
122
114
if (keep) {
123
115
Address start = keep->start ();
124
- position_ = RoundUp (start, kAlignment );
116
+ position_ = RoundUp (start, kAlignmentInBytes );
125
117
limit_ = keep->end ();
126
118
// Un-poison so we can re-use the segment later.
127
119
ASAN_UNPOISON_MEMORY_REGION (start, keep->capacity ());
@@ -167,7 +159,7 @@ Segment* Zone::NewSegment(size_t size) {
167
159
Address Zone::NewExpand (size_t size) {
168
160
// Make sure the requested size is already properly aligned and that
169
161
// there isn't enough room in the Zone to satisfy the request.
170
- DCHECK_EQ (size, RoundDown (size, kAlignment ));
162
+ DCHECK_EQ (size, RoundDown (size, kAlignmentInBytes ));
171
163
DCHECK (limit_ < position_ ||
172
164
reinterpret_cast <uintptr_t >(limit_) -
173
165
reinterpret_cast <uintptr_t >(position_) <
@@ -179,7 +171,7 @@ Address Zone::NewExpand(size_t size) {
179
171
// is to avoid excessive malloc() and free() overhead.
180
172
Segment* head = segment_head_;
181
173
const size_t old_size = (head == nullptr ) ? 0 : head->size ();
182
- static const size_t kSegmentOverhead = sizeof (Segment) + kAlignment ;
174
+ static const size_t kSegmentOverhead = sizeof (Segment) + kAlignmentInBytes ;
183
175
const size_t new_size_no_overhead = size + (old_size << 1 );
184
176
size_t new_size = kSegmentOverhead + new_size_no_overhead;
185
177
const size_t min_new_size = kSegmentOverhead + size;
@@ -208,7 +200,7 @@ Address Zone::NewExpand(size_t size) {
208
200
}
209
201
210
202
// Recompute 'top' and 'limit' based on the new segment.
211
- Address result = RoundUp (segment->start (), kAlignment );
203
+ Address result = RoundUp (segment->start (), kAlignmentInBytes );
212
204
position_ = result + size;
213
205
// Check for address overflow.
214
206
// (Should not happen since the segment is guaranteed to accomodate
0 commit comments