OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/heap/mark-compact.h" | 5 #include "src/heap/mark-compact.h" |
6 | 6 |
7 #include "src/base/atomicops.h" | 7 #include "src/base/atomicops.h" |
8 #include "src/base/bits.h" | 8 #include "src/base/bits.h" |
9 #include "src/code-stubs.h" | 9 #include "src/code-stubs.h" |
10 #include "src/compilation-cache.h" | 10 #include "src/compilation-cache.h" |
(...skipping 2923 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2934 return String::cast(*p); | 2934 return String::cast(*p); |
2935 } | 2935 } |
2936 | 2936 |
2937 | 2937 |
2938 bool MarkCompactCollector::TryPromoteObject(HeapObject* object, | 2938 bool MarkCompactCollector::TryPromoteObject(HeapObject* object, |
2939 int object_size) { | 2939 int object_size) { |
2940 DCHECK(object_size <= Page::kMaxRegularHeapObjectSize); | 2940 DCHECK(object_size <= Page::kMaxRegularHeapObjectSize); |
2941 | 2941 |
2942 OldSpace* old_space = heap()->old_space(); | 2942 OldSpace* old_space = heap()->old_space(); |
2943 | 2943 |
2944 HeapObject* target; | 2944 HeapObject* target = nullptr; |
2945 AllocationAlignment alignment = object->RequiredAlignment(); | 2945 AllocationAlignment alignment = object->RequiredAlignment(); |
2946 AllocationResult allocation = old_space->AllocateRaw(object_size, alignment); | 2946 AllocationResult allocation = old_space->AllocateRaw(object_size, alignment); |
2947 if (allocation.To(&target)) { | 2947 if (allocation.To(&target)) { |
2948 MigrateObject(target, object, object_size, old_space->identity()); | 2948 MigrateObject(target, object, object_size, old_space->identity()); |
2949 // If we end up needing more special cases, we should factor this out. | 2949 // If we end up needing more special cases, we should factor this out. |
2950 if (V8_UNLIKELY(target->IsJSArrayBuffer())) { | 2950 if (V8_UNLIKELY(target->IsJSArrayBuffer())) { |
2951 heap()->PromoteArrayBuffer(target); | 2951 heap()->PromoteArrayBuffer(target); |
2952 } | 2952 } |
2953 heap()->IncrementPromotedObjectsSize(object_size); | 2953 heap()->IncrementPromotedObjectsSize(object_size); |
2954 return true; | 2954 return true; |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3186 if (*cell == 0) continue; | 3186 if (*cell == 0) continue; |
3187 | 3187 |
3188 int live_objects = MarkWordToObjectStarts(*cell, offsets); | 3188 int live_objects = MarkWordToObjectStarts(*cell, offsets); |
3189 for (int i = 0; i < live_objects; i++) { | 3189 for (int i = 0; i < live_objects; i++) { |
3190 Address object_addr = cell_base + offsets[i] * kPointerSize; | 3190 Address object_addr = cell_base + offsets[i] * kPointerSize; |
3191 HeapObject* object = HeapObject::FromAddress(object_addr); | 3191 HeapObject* object = HeapObject::FromAddress(object_addr); |
3192 DCHECK(Marking::IsBlack(Marking::MarkBitFrom(object))); | 3192 DCHECK(Marking::IsBlack(Marking::MarkBitFrom(object))); |
3193 | 3193 |
3194 int size = object->Size(); | 3194 int size = object->Size(); |
3195 AllocationAlignment alignment = object->RequiredAlignment(); | 3195 AllocationAlignment alignment = object->RequiredAlignment(); |
3196 HeapObject* target_object; | 3196 HeapObject* target_object = nullptr; |
3197 AllocationResult allocation = space->AllocateRaw(size, alignment); | 3197 AllocationResult allocation = space->AllocateRaw(size, alignment); |
3198 if (!allocation.To(&target_object)) { | 3198 if (!allocation.To(&target_object)) { |
3199 // If allocation failed, use emergency memory and re-try allocation. | 3199 // If allocation failed, use emergency memory and re-try allocation. |
3200 CHECK(space->HasEmergencyMemory()); | 3200 CHECK(space->HasEmergencyMemory()); |
3201 space->UseEmergencyMemory(); | 3201 space->UseEmergencyMemory(); |
3202 allocation = space->AllocateRaw(size, alignment); | 3202 allocation = space->AllocateRaw(size, alignment); |
3203 } | 3203 } |
3204 if (!allocation.To(&target_object)) { | 3204 if (!allocation.To(&target_object)) { |
3205 // OS refused to give us memory. | 3205 // OS refused to give us memory. |
3206 V8::FatalProcessOutOfMemory("Evacuation"); | 3206 V8::FatalProcessOutOfMemory("Evacuation"); |
(...skipping 1459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4666 SlotsBuffer* buffer = *buffer_address; | 4666 SlotsBuffer* buffer = *buffer_address; |
4667 while (buffer != NULL) { | 4667 while (buffer != NULL) { |
4668 SlotsBuffer* next_buffer = buffer->next(); | 4668 SlotsBuffer* next_buffer = buffer->next(); |
4669 DeallocateBuffer(buffer); | 4669 DeallocateBuffer(buffer); |
4670 buffer = next_buffer; | 4670 buffer = next_buffer; |
4671 } | 4671 } |
4672 *buffer_address = NULL; | 4672 *buffer_address = NULL; |
4673 } | 4673 } |
4674 } // namespace internal | 4674 } // namespace internal |
4675 } // namespace v8 | 4675 } // namespace v8 |
OLD | NEW |