| OLD | NEW |
| 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 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 bool Heap::ShouldBePromoted(Address old_address, int object_size) { | 185 bool Heap::ShouldBePromoted(Address old_address, int object_size) { |
| 186 // An object should be promoted if: | 186 // An object should be promoted if: |
| 187 // - the object has survived a scavenge operation or | 187 // - the object has survived a scavenge operation or |
| 188 // - to space is already 25% full. | 188 // - to space is already 25% full. |
| 189 return old_address < new_space_.age_mark() | 189 return old_address < new_space_.age_mark() |
| 190 || (new_space_.Size() + object_size) >= (new_space_.Capacity() >> 2); | 190 || (new_space_.Size() + object_size) >= (new_space_.Capacity() >> 2); |
| 191 } | 191 } |
| 192 | 192 |
| 193 | 193 |
| 194 void Heap::RecordWrite(Address address, int offset) { | 194 void Heap::RecordWrite(Address address, int offset) { |
| 195 #ifndef BASELINE_GC |
| 195 if (new_space_.Contains(address)) return; | 196 if (new_space_.Contains(address)) return; |
| 196 ASSERT(!new_space_.FromSpaceContains(address)); | 197 ASSERT(!new_space_.FromSpaceContains(address)); |
| 197 SLOW_ASSERT(Contains(address + offset)); | 198 SLOW_ASSERT(Contains(address + offset)); |
| 198 Page::FromAddress(address)->MarkRegionDirty(address + offset); | 199 Page::FromAddress(address)->MarkRegionDirty(address + offset); |
| 200 #endif |
| 199 } | 201 } |
| 200 | 202 |
| 201 | 203 |
| 202 void Heap::RecordWrites(Address address, int start, int len) { | 204 void Heap::RecordWrites(Address address, int start, int len) { |
| 205 #ifndef BASELINE_GC |
| 203 if (new_space_.Contains(address)) return; | 206 if (new_space_.Contains(address)) return; |
| 204 ASSERT(!new_space_.FromSpaceContains(address)); | 207 ASSERT(!new_space_.FromSpaceContains(address)); |
| 205 Page* page = Page::FromAddress(address); | 208 Page* page = Page::FromAddress(address); |
| 206 page->SetRegionMarks(page->GetRegionMarks() | | 209 page->SetRegionMarks(page->GetRegionMarks() | |
| 207 page->GetRegionMaskForSpan(address + start, len * kPointerSize)); | 210 page->GetRegionMaskForSpan(address + start, len * kPointerSize)); |
| 211 #endif |
| 208 } | 212 } |
| 209 | 213 |
| 210 | 214 |
| 211 OldSpace* Heap::TargetSpace(HeapObject* object) { | 215 OldSpace* Heap::TargetSpace(HeapObject* object) { |
| 212 InstanceType type = object->map()->instance_type(); | 216 InstanceType type = object->map()->instance_type(); |
| 213 AllocationSpace space = TargetSpaceId(type); | 217 AllocationSpace space = TargetSpaceId(type); |
| 214 return (space == OLD_POINTER_SPACE) | 218 return (space == OLD_POINTER_SPACE) |
| 215 ? old_pointer_space_ | 219 ? old_pointer_space_ |
| 216 : old_data_space_; | 220 : old_data_space_; |
| 217 } | 221 } |
| (...skipping 28 matching lines...) Expand all Loading... |
| 246 ASSERT(IsAligned(byte_size, kPointerSize)); | 250 ASSERT(IsAligned(byte_size, kPointerSize)); |
| 247 CopyWords(reinterpret_cast<Object**>(dst), | 251 CopyWords(reinterpret_cast<Object**>(dst), |
| 248 reinterpret_cast<Object**>(src), | 252 reinterpret_cast<Object**>(src), |
| 249 byte_size / kPointerSize); | 253 byte_size / kPointerSize); |
| 250 } | 254 } |
| 251 | 255 |
| 252 | 256 |
| 253 void Heap::CopyBlockToOldSpaceAndUpdateRegionMarks(Address dst, | 257 void Heap::CopyBlockToOldSpaceAndUpdateRegionMarks(Address dst, |
| 254 Address src, | 258 Address src, |
| 255 int byte_size) { | 259 int byte_size) { |
| 260 #ifndef BASELINE_GC |
| 256 ASSERT(IsAligned(byte_size, kPointerSize)); | 261 ASSERT(IsAligned(byte_size, kPointerSize)); |
| 257 | 262 |
| 258 Page* page = Page::FromAddress(dst); | 263 Page* page = Page::FromAddress(dst); |
| 259 uint32_t marks = page->GetRegionMarks(); | 264 uint32_t marks = page->GetRegionMarks(); |
| 260 | 265 |
| 261 for (int remaining = byte_size / kPointerSize; | 266 for (int remaining = byte_size / kPointerSize; |
| 262 remaining > 0; | 267 remaining > 0; |
| 263 remaining--) { | 268 remaining--) { |
| 264 Memory::Object_at(dst) = Memory::Object_at(src); | 269 Memory::Object_at(dst) = Memory::Object_at(src); |
| 265 | 270 |
| 266 if (Heap::InNewSpace(Memory::Object_at(dst))) { | 271 if (Heap::InNewSpace(Memory::Object_at(dst))) { |
| 267 marks |= page->GetRegionMaskForAddress(dst); | 272 marks |= page->GetRegionMaskForAddress(dst); |
| 268 } | 273 } |
| 269 | 274 |
| 270 dst += kPointerSize; | 275 dst += kPointerSize; |
| 271 src += kPointerSize; | 276 src += kPointerSize; |
| 272 } | 277 } |
| 273 | 278 |
| 274 page->SetRegionMarks(marks); | 279 page->SetRegionMarks(marks); |
| 280 #else |
| 281 CopyBlock(dst, src, byte_size); |
| 282 #endif |
| 275 } | 283 } |
| 276 | 284 |
| 277 | 285 |
| 278 void Heap::MoveBlock(Address dst, Address src, int byte_size) { | 286 void Heap::MoveBlock(Address dst, Address src, int byte_size) { |
| 279 ASSERT(IsAligned(byte_size, kPointerSize)); | 287 ASSERT(IsAligned(byte_size, kPointerSize)); |
| 280 | 288 |
| 281 int size_in_words = byte_size / kPointerSize; | 289 int size_in_words = byte_size / kPointerSize; |
| 282 | 290 |
| 283 if ((dst < src) || (dst >= (src + size_in_words))) { | 291 if ((dst < src) || (dst >= (src + size_in_words))) { |
| 284 ASSERT((dst >= (src + size_in_words)) || | 292 ASSERT((dst >= (src + size_in_words)) || |
| (...skipping 13 matching lines...) Expand all Loading... |
| 298 } | 306 } |
| 299 | 307 |
| 300 | 308 |
| 301 void Heap::MoveBlockToOldSpaceAndUpdateRegionMarks(Address dst, | 309 void Heap::MoveBlockToOldSpaceAndUpdateRegionMarks(Address dst, |
| 302 Address src, | 310 Address src, |
| 303 int byte_size) { | 311 int byte_size) { |
| 304 ASSERT(IsAligned(byte_size, kPointerSize)); | 312 ASSERT(IsAligned(byte_size, kPointerSize)); |
| 305 ASSERT((dst >= (src + byte_size)) || | 313 ASSERT((dst >= (src + byte_size)) || |
| 306 ((OffsetFrom(src) - OffsetFrom(dst)) >= kPointerSize)); | 314 ((OffsetFrom(src) - OffsetFrom(dst)) >= kPointerSize)); |
| 307 | 315 |
| 316 #ifndef BASELINE_GC |
| 308 CopyBlockToOldSpaceAndUpdateRegionMarks(dst, src, byte_size); | 317 CopyBlockToOldSpaceAndUpdateRegionMarks(dst, src, byte_size); |
| 318 #else |
| 319 MoveBlock(dst, src, byte_size); |
| 320 #endif |
| 309 } | 321 } |
| 310 | 322 |
| 311 | 323 |
| 312 void Heap::ScavengeObject(HeapObject** p, HeapObject* object) { | 324 void Heap::ScavengeObject(HeapObject** p, HeapObject* object) { |
| 313 ASSERT(InFromSpace(object)); | 325 ASSERT(InFromSpace(object)); |
| 314 | 326 |
| 315 // We use the first word (where the map pointer usually is) of a heap | 327 // We use the first word (where the map pointer usually is) of a heap |
| 316 // object to record the forwarding pointer. A forwarding pointer can | 328 // object to record the forwarding pointer. A forwarding pointer can |
| 317 // point to an old space, the code space, or the to space of the new | 329 // point to an old space, the code space, or the to space of the new |
| 318 // generation. | 330 // generation. |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 500 | 512 |
| 501 | 513 |
| 502 void ExternalStringTable::ShrinkNewStrings(int position) { | 514 void ExternalStringTable::ShrinkNewStrings(int position) { |
| 503 new_space_strings_.Rewind(position); | 515 new_space_strings_.Rewind(position); |
| 504 Verify(); | 516 Verify(); |
| 505 } | 517 } |
| 506 | 518 |
| 507 } } // namespace v8::internal | 519 } } // namespace v8::internal |
| 508 | 520 |
| 509 #endif // V8_HEAP_INL_H_ | 521 #endif // V8_HEAP_INL_H_ |
| OLD | NEW |