Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 79 } | 79 } |
| 80 | 80 |
| 81 | 81 |
| 82 void MarkCompactCollector::RecordSlot(Object** anchor_slot, | 82 void MarkCompactCollector::RecordSlot(Object** anchor_slot, |
| 83 Object** slot, | 83 Object** slot, |
| 84 Object* object, | 84 Object* object, |
| 85 SlotsBuffer::AdditionMode mode) { | 85 SlotsBuffer::AdditionMode mode) { |
| 86 Page* object_page = Page::FromAddress(reinterpret_cast<Address>(object)); | 86 Page* object_page = Page::FromAddress(reinterpret_cast<Address>(object)); |
| 87 if (object_page->IsEvacuationCandidate() && | 87 if (object_page->IsEvacuationCandidate() && |
| 88 !ShouldSkipEvacuationSlotRecording(anchor_slot)) { | 88 !ShouldSkipEvacuationSlotRecording(anchor_slot)) { |
| 89 if (!SlotsBuffer::AddTo(&slots_buffer_allocator_, | 89 if (!SlotsBuffer::AddTo(heap_, |
| 90 &slots_buffer_allocator_, | |
| 90 object_page->slots_buffer_address(), | 91 object_page->slots_buffer_address(), |
| 91 slot, | 92 slot, |
| 92 mode)) { | 93 mode)) { |
| 93 EvictEvacuationCandidate(object_page); | 94 EvictEvacuationCandidate(object_page); |
| 94 } | 95 } |
| 95 } | 96 } |
| 96 } | 97 } |
| 97 | 98 |
| 98 | 99 |
| 100 bool SlotsBuffer::AddTo(Heap* heap, | |
| 101 SlotsBufferAllocator* allocator, | |
| 102 SlotsBuffer** buffer_address, | |
| 103 ObjectSlot slot, | |
| 104 AdditionMode mode) { | |
| 105 ASSERT(!heap->mark_compact_collector()->IsInsideEvacuationScope() || | |
| 106 mode == IGNORE_OVERFLOW); | |
| 107 ASSERT(heap->mark_compact_collector()->IsInsideEvacuationScope() || | |
| 108 mode == FAIL_ON_OVERFLOW); | |
|
Michael Starzinger
2014/03/06 10:47:25
This invariant can be expressed in one expression
| |
| 109 SlotsBuffer* buffer = *buffer_address; | |
| 110 if (buffer == NULL || buffer->IsFull()) { | |
| 111 if (mode == FAIL_ON_OVERFLOW && ChainLengthThresholdReached(buffer)) { | |
| 112 allocator->DeallocateChain(buffer_address); | |
| 113 return false; | |
| 114 } | |
| 115 buffer = allocator->AllocateBuffer(heap, buffer); | |
| 116 *buffer_address = buffer; | |
| 117 } | |
| 118 buffer->Add(slot); | |
| 119 return true; | |
| 120 } | |
| 121 | |
| 122 | |
| 123 bool SlotsBuffer::AddTo(Heap* heap, | |
| 124 SlotsBufferAllocator* allocator, | |
| 125 SlotsBuffer** buffer_address, | |
| 126 SlotType type, | |
| 127 Address addr, | |
| 128 AdditionMode mode) { | |
| 129 ASSERT(!heap->mark_compact_collector()->IsInsideEvacuationScope() || | |
| 130 mode == IGNORE_OVERFLOW); | |
| 131 ASSERT(heap->mark_compact_collector()->IsInsideEvacuationScope() || | |
| 132 mode == FAIL_ON_OVERFLOW); | |
|
Michael Starzinger
2014/03/06 10:47:25
Likewise.
| |
| 133 SlotsBuffer* buffer = *buffer_address; | |
| 134 if (buffer == NULL || !buffer->HasSpaceForTypedSlot()) { | |
| 135 if (mode == FAIL_ON_OVERFLOW && ChainLengthThresholdReached(buffer)) { | |
| 136 allocator->DeallocateChain(buffer_address); | |
| 137 return false; | |
| 138 } | |
| 139 buffer = allocator->AllocateBuffer(heap, buffer); | |
| 140 *buffer_address = buffer; | |
| 141 } | |
| 142 ASSERT(buffer->HasSpaceForTypedSlot()); | |
| 143 buffer->Add(reinterpret_cast<ObjectSlot>(type)); | |
| 144 buffer->Add(reinterpret_cast<ObjectSlot>(addr)); | |
| 145 return true; | |
| 146 } | |
| 147 | |
| 148 | |
| 99 } } // namespace v8::internal | 149 } } // namespace v8::internal |
| 100 | 150 |
| 101 #endif // V8_MARK_COMPACT_INL_H_ | 151 #endif // V8_MARK_COMPACT_INL_H_ |
| OLD | NEW |