Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(251)

Side by Side Diff: src/heap-inl.h

Issue 2144006: Cardmarking writebarrier. (Closed)
Patch Set: change NewSpace and SemiSpace Contains to match HasHeapObjectTag Created 10 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 // - to space is already 25% full. 177 // - to space is already 25% full.
178 return old_address < new_space_.age_mark() 178 return old_address < new_space_.age_mark()
179 || (new_space_.Size() + object_size) >= (new_space_.Capacity() >> 2); 179 || (new_space_.Size() + object_size) >= (new_space_.Capacity() >> 2);
180 } 180 }
181 181
182 182
183 void Heap::RecordWrite(Address address, int offset) { 183 void Heap::RecordWrite(Address address, int offset) {
184 if (new_space_.Contains(address)) return; 184 if (new_space_.Contains(address)) return;
185 ASSERT(!new_space_.FromSpaceContains(address)); 185 ASSERT(!new_space_.FromSpaceContains(address));
186 SLOW_ASSERT(Contains(address + offset)); 186 SLOW_ASSERT(Contains(address + offset));
187 Page::SetRSet(address, offset); 187 Page::FromAddress(address)->MarkRegionDirty(address + offset);
188 } 188 }
189 189
190 190
191 void Heap::RecordWrites(Address address, int start, int len) { 191 void Heap::RecordWrites(Address address, int start, int len) {
192 if (new_space_.Contains(address)) return; 192 if (new_space_.Contains(address)) return;
193 ASSERT(!new_space_.FromSpaceContains(address)); 193 ASSERT(!new_space_.FromSpaceContains(address));
194 for (int offset = start; 194 for (int offset = start;
195 offset < start + len * kPointerSize; 195 offset < start + len * kPointerSize;
196 offset += kPointerSize) { 196 offset += kPointerSize) {
197 SLOW_ASSERT(Contains(address + offset)); 197 SLOW_ASSERT(Contains(address + offset));
198 Page::SetRSet(address, offset); 198 Page::FromAddress(address)->MarkRegionDirty(address + offset);
199 } 199 }
200 } 200 }
201 201
202 202
203 OldSpace* Heap::TargetSpace(HeapObject* object) { 203 OldSpace* Heap::TargetSpace(HeapObject* object) {
204 InstanceType type = object->map()->instance_type(); 204 InstanceType type = object->map()->instance_type();
205 AllocationSpace space = TargetSpaceId(type); 205 AllocationSpace space = TargetSpaceId(type);
206 return (space == OLD_POINTER_SPACE) 206 return (space == OLD_POINTER_SPACE)
207 ? old_pointer_space_ 207 ? old_pointer_space_
208 : old_data_space_; 208 : old_data_space_;
(...skipping 18 matching lines...) Expand all
227 // non-map-word pointers to heap objects. 227 // non-map-word pointers to heap objects.
228 return ((type & kStringRepresentationMask) == kConsStringTag) 228 return ((type & kStringRepresentationMask) == kConsStringTag)
229 ? OLD_POINTER_SPACE 229 ? OLD_POINTER_SPACE
230 : OLD_DATA_SPACE; 230 : OLD_DATA_SPACE;
231 } else { 231 } else {
232 return (type <= LAST_DATA_TYPE) ? OLD_DATA_SPACE : OLD_POINTER_SPACE; 232 return (type <= LAST_DATA_TYPE) ? OLD_DATA_SPACE : OLD_POINTER_SPACE;
233 } 233 }
234 } 234 }
235 235
236 236
237 void Heap::CopyBlock(Object** dst, Object** src, int byte_size) { 237 void Heap::CopyBlock(Address dst, Address src, int byte_size) {
238 ASSERT(IsAligned(byte_size, kPointerSize)); 238 ASSERT(IsAligned(byte_size, kPointerSize));
239 CopyWords(dst, src, byte_size / kPointerSize); 239 CopyWords(reinterpret_cast<Object**>(dst),
240 reinterpret_cast<Object**>(src),
241 byte_size / kPointerSize);
240 } 242 }
241 243
242 244
243 void Heap::MoveBlock(Object** dst, Object** src, int byte_size) { 245 void Heap::CopyBlockToOldSpaceAndUpdateRegionMarks(Address dst,
246 Address src,
247 int byte_size) {
248 ASSERT(IsAligned(byte_size, kPointerSize));
249
250 Page* page = Page::FromAddress(dst);
251 uint32_t marks = page->GetRegionMarks();
252
253 for (int remaining = byte_size / kPointerSize;
254 remaining > 0;
255 remaining--) {
256 Memory::Object_at(dst) = Memory::Object_at(src);
257
258 if (Heap::InNewSpace(Memory::Object_at(dst))) {
259 marks |= page->GetRegionMaskForAddress(dst);
260 }
261
262 dst += kPointerSize;
263 src += kPointerSize;
264 }
265
266 page->SetRegionMarks(marks);
267 }
268
269
270 void Heap::MoveBlock(Address dst, Address src, int byte_size) {
244 ASSERT(IsAligned(byte_size, kPointerSize)); 271 ASSERT(IsAligned(byte_size, kPointerSize));
245 272
246 int size_in_words = byte_size / kPointerSize; 273 int size_in_words = byte_size / kPointerSize;
247 274
248 if ((dst < src) || (dst >= (src + size_in_words))) { 275 if ((dst < src) || (dst >= (src + size_in_words))) {
249 ASSERT((dst >= (src + size_in_words)) || 276 ASSERT((dst >= (src + size_in_words)) ||
250 ((OffsetFrom(reinterpret_cast<Address>(src)) - 277 ((OffsetFrom(reinterpret_cast<Address>(src)) -
251 OffsetFrom(reinterpret_cast<Address>(dst))) >= kPointerSize)); 278 OffsetFrom(reinterpret_cast<Address>(dst))) >= kPointerSize));
252 279
253 Object** end = src + size_in_words; 280 Object** src_slot = reinterpret_cast<Object**>(src);
281 Object** dst_slot = reinterpret_cast<Object**>(dst);
282 Object** end_slot = src_slot + size_in_words;
254 283
255 while (src != end) { 284 while (src_slot != end_slot) {
256 *dst++ = *src++; 285 *dst_slot++ = *src_slot++;
257 } 286 }
258 } else { 287 } else {
259 memmove(dst, src, byte_size); 288 memmove(dst, src, byte_size);
260 } 289 }
261 } 290 }
262 291
263 292
293 void Heap::MoveBlockToOldSpaceAndUpdateRegionMarks(Address dst,
294 Address src,
295 int byte_size) {
296 ASSERT(IsAligned(byte_size, kPointerSize));
297 ASSERT((dst >= (src + byte_size)) ||
298 ((OffsetFrom(src) - OffsetFrom(dst)) >= kPointerSize));
299
300 CopyBlockToOldSpaceAndUpdateRegionMarks(dst, src, byte_size);
301 }
302
303
264 void Heap::ScavengeObject(HeapObject** p, HeapObject* object) { 304 void Heap::ScavengeObject(HeapObject** p, HeapObject* object) {
265 ASSERT(InFromSpace(object)); 305 ASSERT(InFromSpace(object));
266 306
267 // We use the first word (where the map pointer usually is) of a heap 307 // We use the first word (where the map pointer usually is) of a heap
268 // object to record the forwarding pointer. A forwarding pointer can 308 // object to record the forwarding pointer. A forwarding pointer can
269 // point to an old space, the code space, or the to space of the new 309 // point to an old space, the code space, or the to space of the new
270 // generation. 310 // generation.
271 MapWord first_word = object->map_word(); 311 MapWord first_word = object->map_word();
272 312
273 // If the first word is a forwarding address, the object has already been 313 // If the first word is a forwarding address, the object has already been
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 482
443 483
444 void ExternalStringTable::ShrinkNewStrings(int position) { 484 void ExternalStringTable::ShrinkNewStrings(int position) {
445 new_space_strings_.Rewind(position); 485 new_space_strings_.Rewind(position);
446 Verify(); 486 Verify();
447 } 487 }
448 488
449 } } // namespace v8::internal 489 } } // namespace v8::internal
450 490
451 #endif // V8_HEAP_INL_H_ 491 #endif // V8_HEAP_INL_H_
OLDNEW
« no previous file with comments | « src/heap.cc ('k') | src/ia32/builtins-ia32.cc » ('j') | src/spaces.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698