| OLD | NEW |
| 1 // Copyright 2006-2010 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2010 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 13 matching lines...) Expand all Loading... |
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | 27 |
| 28 #ifndef V8_HEAP_INL_H_ | 28 #ifndef V8_HEAP_INL_H_ |
| 29 #define V8_HEAP_INL_H_ | 29 #define V8_HEAP_INL_H_ |
| 30 | 30 |
| 31 #include "heap.h" | 31 #include "heap.h" |
| 32 #include "objects.h" | 32 #include "objects.h" |
| 33 #include "v8-counters.h" | 33 #include "v8-counters.h" |
| 34 #include "write-buffer.h" |
| 34 | 35 |
| 35 namespace v8 { | 36 namespace v8 { |
| 36 namespace internal { | 37 namespace internal { |
| 37 | 38 |
| 38 int Heap::MaxObjectSizeInPagedSpace() { | 39 int Heap::MaxObjectSizeInPagedSpace() { |
| 39 return Page::kMaxHeapObjectSize; | 40 return Page::kMaxHeapObjectSize; |
| 40 } | 41 } |
| 41 | 42 |
| 42 | 43 |
| 43 MaybeObject* Heap::AllocateSymbol(Vector<const char> str, | 44 MaybeObject* Heap::AllocateSymbol(Vector<const char> str, |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 bool Heap::ShouldBePromoted(Address old_address, int object_size) { | 186 bool Heap::ShouldBePromoted(Address old_address, int object_size) { |
| 186 // An object should be promoted if: | 187 // An object should be promoted if: |
| 187 // - the object has survived a scavenge operation or | 188 // - the object has survived a scavenge operation or |
| 188 // - to space is already 25% full. | 189 // - to space is already 25% full. |
| 189 return old_address < new_space_.age_mark() | 190 return old_address < new_space_.age_mark() |
| 190 || (new_space_.Size() + object_size) >= (new_space_.Capacity() >> 2); | 191 || (new_space_.Size() + object_size) >= (new_space_.Capacity() >> 2); |
| 191 } | 192 } |
| 192 | 193 |
| 193 | 194 |
| 194 void Heap::RecordWrite(Address address, int offset) { | 195 void Heap::RecordWrite(Address address, int offset) { |
| 195 #ifdef ENABLE_CARDMARKING_WRITE_BARRIER | 196 WriteBuffer::Mark(address + offset); |
| 196 if (new_space_.Contains(address)) return; | |
| 197 ASSERT(!new_space_.FromSpaceContains(address)); | |
| 198 SLOW_ASSERT(Contains(address + offset)); | |
| 199 Page::FromAddress(address)->MarkRegionDirty(address + offset); | |
| 200 #endif | |
| 201 } | 197 } |
| 202 | 198 |
| 203 | 199 |
| 204 void Heap::RecordWrites(Address address, int start, int len) { | 200 void Heap::RecordWrites(Address address, int start, int len) { |
| 205 #ifdef ENABLE_CARDMARKING_WRITE_BARRIER | 201 for (int i = 0; i < len; i++) { |
| 206 if (new_space_.Contains(address)) return; | 202 WriteBuffer::Mark(address + start + i); |
| 207 ASSERT(!new_space_.FromSpaceContains(address)); | 203 } |
| 208 Page* page = Page::FromAddress(address); | |
| 209 page->SetRegionMarks(page->GetRegionMarks() | | |
| 210 page->GetRegionMaskForSpan(address + start, len * kPointerSize)); | |
| 211 #endif | |
| 212 } | 204 } |
| 213 | 205 |
| 214 | 206 |
| 215 OldSpace* Heap::TargetSpace(HeapObject* object) { | 207 OldSpace* Heap::TargetSpace(HeapObject* object) { |
| 216 InstanceType type = object->map()->instance_type(); | 208 InstanceType type = object->map()->instance_type(); |
| 217 AllocationSpace space = TargetSpaceId(type); | 209 AllocationSpace space = TargetSpaceId(type); |
| 218 return (space == OLD_POINTER_SPACE) | 210 return (space == OLD_POINTER_SPACE) |
| 219 ? old_pointer_space_ | 211 ? old_pointer_space_ |
| 220 : old_data_space_; | 212 : old_data_space_; |
| 221 } | 213 } |
| (...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 512 | 504 |
| 513 | 505 |
| 514 void ExternalStringTable::ShrinkNewStrings(int position) { | 506 void ExternalStringTable::ShrinkNewStrings(int position) { |
| 515 new_space_strings_.Rewind(position); | 507 new_space_strings_.Rewind(position); |
| 516 Verify(); | 508 Verify(); |
| 517 } | 509 } |
| 518 | 510 |
| 519 } } // namespace v8::internal | 511 } } // namespace v8::internal |
| 520 | 512 |
| 521 #endif // V8_HEAP_INL_H_ | 513 #endif // V8_HEAP_INL_H_ |
| OLD | NEW |