| 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 if (FLAG_new_gc) return; |
| 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); |
| 199 } | 200 } |
| 200 | 201 |
| 201 | 202 |
| 202 void Heap::RecordWrites(Address address, int start, int len) { | 203 void Heap::RecordWrites(Address address, int start, int len) { |
| 204 if (FLAG_new_gc) return; |
| 203 if (new_space_.Contains(address)) return; | 205 if (new_space_.Contains(address)) return; |
| 204 ASSERT(!new_space_.FromSpaceContains(address)); | 206 ASSERT(!new_space_.FromSpaceContains(address)); |
| 205 Page* page = Page::FromAddress(address); | 207 Page* page = Page::FromAddress(address); |
| 206 page->SetRegionMarks(page->GetRegionMarks() | | 208 page->SetRegionMarks(page->GetRegionMarks() | |
| 207 page->GetRegionMaskForSpan(address + start, len * kPointerSize)); | 209 page->GetRegionMaskForSpan(address + start, len * kPointerSize)); |
| 208 } | 210 } |
| 209 | 211 |
| 210 | 212 |
| 211 OldSpace* Heap::TargetSpace(HeapObject* object) { | 213 OldSpace* Heap::TargetSpace(HeapObject* object) { |
| 212 InstanceType type = object->map()->instance_type(); | 214 InstanceType type = object->map()->instance_type(); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 ASSERT(IsAligned(byte_size, kPointerSize)); | 248 ASSERT(IsAligned(byte_size, kPointerSize)); |
| 247 CopyWords(reinterpret_cast<Object**>(dst), | 249 CopyWords(reinterpret_cast<Object**>(dst), |
| 248 reinterpret_cast<Object**>(src), | 250 reinterpret_cast<Object**>(src), |
| 249 byte_size / kPointerSize); | 251 byte_size / kPointerSize); |
| 250 } | 252 } |
| 251 | 253 |
| 252 | 254 |
| 253 void Heap::CopyBlockToOldSpaceAndUpdateRegionMarks(Address dst, | 255 void Heap::CopyBlockToOldSpaceAndUpdateRegionMarks(Address dst, |
| 254 Address src, | 256 Address src, |
| 255 int byte_size) { | 257 int byte_size) { |
| 258 if (FLAG_new_gc) { |
| 259 CopyBlock(dst, src, byte_size); |
| 260 return; |
| 261 } |
| 262 |
| 256 ASSERT(IsAligned(byte_size, kPointerSize)); | 263 ASSERT(IsAligned(byte_size, kPointerSize)); |
| 257 | 264 |
| 258 Page* page = Page::FromAddress(dst); | 265 Page* page = Page::FromAddress(dst); |
| 259 uint32_t marks = page->GetRegionMarks(); | 266 uint32_t marks = page->GetRegionMarks(); |
| 260 | 267 |
| 261 for (int remaining = byte_size / kPointerSize; | 268 for (int remaining = byte_size / kPointerSize; |
| 262 remaining > 0; | 269 remaining > 0; |
| 263 remaining--) { | 270 remaining--) { |
| 264 Memory::Object_at(dst) = Memory::Object_at(src); | 271 Memory::Object_at(dst) = Memory::Object_at(src); |
| 265 | 272 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 } | 305 } |
| 299 | 306 |
| 300 | 307 |
| 301 void Heap::MoveBlockToOldSpaceAndUpdateRegionMarks(Address dst, | 308 void Heap::MoveBlockToOldSpaceAndUpdateRegionMarks(Address dst, |
| 302 Address src, | 309 Address src, |
| 303 int byte_size) { | 310 int byte_size) { |
| 304 ASSERT(IsAligned(byte_size, kPointerSize)); | 311 ASSERT(IsAligned(byte_size, kPointerSize)); |
| 305 ASSERT((dst >= (src + byte_size)) || | 312 ASSERT((dst >= (src + byte_size)) || |
| 306 ((OffsetFrom(src) - OffsetFrom(dst)) >= kPointerSize)); | 313 ((OffsetFrom(src) - OffsetFrom(dst)) >= kPointerSize)); |
| 307 | 314 |
| 308 CopyBlockToOldSpaceAndUpdateRegionMarks(dst, src, byte_size); | 315 if (FLAG_new_gc) { |
| 316 MoveBlock(dst, src, byte_size); |
| 317 } else { |
| 318 CopyBlockToOldSpaceAndUpdateRegionMarks(dst, src, byte_size); |
| 319 } |
| 309 } | 320 } |
| 310 | 321 |
| 311 | 322 |
| 312 void Heap::ScavengeObject(HeapObject** p, HeapObject* object) { | 323 void Heap::ScavengeObject(HeapObject** p, HeapObject* object) { |
| 313 ASSERT(InFromSpace(object)); | 324 ASSERT(InFromSpace(object)); |
| 314 | 325 |
| 315 // We use the first word (where the map pointer usually is) of a heap | 326 // 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 | 327 // 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 | 328 // point to an old space, the code space, or the to space of the new |
| 318 // generation. | 329 // generation. |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 500 | 511 |
| 501 | 512 |
| 502 void ExternalStringTable::ShrinkNewStrings(int position) { | 513 void ExternalStringTable::ShrinkNewStrings(int position) { |
| 503 new_space_strings_.Rewind(position); | 514 new_space_strings_.Rewind(position); |
| 504 Verify(); | 515 Verify(); |
| 505 } | 516 } |
| 506 | 517 |
| 507 } } // namespace v8::internal | 518 } } // namespace v8::internal |
| 508 | 519 |
| 509 #endif // V8_HEAP_INL_H_ | 520 #endif // V8_HEAP_INL_H_ |
| OLD | NEW |