| 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/v8.h" | 5 #include "src/v8.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 1923 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1934 | 1934 |
| 1935 offset += 2; | 1935 offset += 2; |
| 1936 current_cell >>= 2; | 1936 current_cell >>= 2; |
| 1937 | 1937 |
| 1938 // TODO(hpayer): Refactor EvacuateObject and call this function instead. | 1938 // TODO(hpayer): Refactor EvacuateObject and call this function instead. |
| 1939 if (heap()->ShouldBePromoted(object->address(), size) && | 1939 if (heap()->ShouldBePromoted(object->address(), size) && |
| 1940 TryPromoteObject(object, size)) { | 1940 TryPromoteObject(object, size)) { |
| 1941 continue; | 1941 continue; |
| 1942 } | 1942 } |
| 1943 | 1943 |
| 1944 AllocationAlignment alignment = object->NeedsToEnsureDoubleAlignment() | 1944 AllocationAlignment alignment = object->RequiredAlignment(); |
| 1945 ? kDoubleAligned | |
| 1946 : kWordAligned; | |
| 1947 AllocationResult allocation = new_space->AllocateRaw(size, alignment); | 1945 AllocationResult allocation = new_space->AllocateRaw(size, alignment); |
| 1948 if (allocation.IsRetry()) { | 1946 if (allocation.IsRetry()) { |
| 1949 if (!new_space->AddFreshPage()) { | 1947 if (!new_space->AddFreshPage()) { |
| 1950 // Shouldn't happen. We are sweeping linearly, and to-space | 1948 // Shouldn't happen. We are sweeping linearly, and to-space |
| 1951 // has the same number of pages as from-space, so there is | 1949 // has the same number of pages as from-space, so there is |
| 1952 // always room. | 1950 // always room. |
| 1953 UNREACHABLE(); | 1951 UNREACHABLE(); |
| 1954 } | 1952 } |
| 1955 allocation = new_space->AllocateRaw(size, alignment); | 1953 allocation = new_space->AllocateRaw(size, alignment); |
| 1956 DCHECK(!allocation.IsRetry()); | 1954 DCHECK(!allocation.IsRetry()); |
| (...skipping 1141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3098 } | 3096 } |
| 3099 | 3097 |
| 3100 | 3098 |
| 3101 bool MarkCompactCollector::TryPromoteObject(HeapObject* object, | 3099 bool MarkCompactCollector::TryPromoteObject(HeapObject* object, |
| 3102 int object_size) { | 3100 int object_size) { |
| 3103 DCHECK(object_size <= Page::kMaxRegularHeapObjectSize); | 3101 DCHECK(object_size <= Page::kMaxRegularHeapObjectSize); |
| 3104 | 3102 |
| 3105 OldSpace* old_space = heap()->old_space(); | 3103 OldSpace* old_space = heap()->old_space(); |
| 3106 | 3104 |
| 3107 HeapObject* target; | 3105 HeapObject* target; |
| 3108 AllocationAlignment alignment = | 3106 AllocationAlignment alignment = object->RequiredAlignment(); |
| 3109 object->NeedsToEnsureDoubleAlignment() ? kDoubleAligned : kWordAligned; | |
| 3110 AllocationResult allocation = old_space->AllocateRaw(object_size, alignment); | 3107 AllocationResult allocation = old_space->AllocateRaw(object_size, alignment); |
| 3111 if (allocation.To(&target)) { | 3108 if (allocation.To(&target)) { |
| 3112 MigrateObject(target, object, object_size, old_space->identity()); | 3109 MigrateObject(target, object, object_size, old_space->identity()); |
| 3113 heap()->IncrementPromotedObjectsSize(object_size); | 3110 heap()->IncrementPromotedObjectsSize(object_size); |
| 3114 return true; | 3111 return true; |
| 3115 } | 3112 } |
| 3116 | 3113 |
| 3117 return false; | 3114 return false; |
| 3118 } | 3115 } |
| 3119 | 3116 |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3323 | 3320 |
| 3324 if (*cell == 0) continue; | 3321 if (*cell == 0) continue; |
| 3325 | 3322 |
| 3326 int live_objects = MarkWordToObjectStarts(*cell, offsets); | 3323 int live_objects = MarkWordToObjectStarts(*cell, offsets); |
| 3327 for (int i = 0; i < live_objects; i++) { | 3324 for (int i = 0; i < live_objects; i++) { |
| 3328 Address object_addr = cell_base + offsets[i] * kPointerSize; | 3325 Address object_addr = cell_base + offsets[i] * kPointerSize; |
| 3329 HeapObject* object = HeapObject::FromAddress(object_addr); | 3326 HeapObject* object = HeapObject::FromAddress(object_addr); |
| 3330 DCHECK(Marking::IsBlack(Marking::MarkBitFrom(object))); | 3327 DCHECK(Marking::IsBlack(Marking::MarkBitFrom(object))); |
| 3331 | 3328 |
| 3332 int size = object->Size(); | 3329 int size = object->Size(); |
| 3333 | 3330 AllocationAlignment alignment = object->RequiredAlignment(); |
| 3334 AllocationAlignment alignment = object->NeedsToEnsureDoubleAlignment() | |
| 3335 ? kDoubleAligned | |
| 3336 : kWordAligned; | |
| 3337 HeapObject* target_object; | 3331 HeapObject* target_object; |
| 3338 AllocationResult allocation = space->AllocateRaw(size, alignment); | 3332 AllocationResult allocation = space->AllocateRaw(size, alignment); |
| 3339 if (!allocation.To(&target_object)) { | 3333 if (!allocation.To(&target_object)) { |
| 3340 // If allocation failed, use emergency memory and re-try allocation. | 3334 // If allocation failed, use emergency memory and re-try allocation. |
| 3341 CHECK(space->HasEmergencyMemory()); | 3335 CHECK(space->HasEmergencyMemory()); |
| 3342 space->UseEmergencyMemory(); | 3336 space->UseEmergencyMemory(); |
| 3343 allocation = space->AllocateRaw(size, alignment); | 3337 allocation = space->AllocateRaw(size, alignment); |
| 3344 } | 3338 } |
| 3345 if (!allocation.To(&target_object)) { | 3339 if (!allocation.To(&target_object)) { |
| 3346 // OS refused to give us memory. | 3340 // OS refused to give us memory. |
| (...skipping 1417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4764 SlotsBuffer* buffer = *buffer_address; | 4758 SlotsBuffer* buffer = *buffer_address; |
| 4765 while (buffer != NULL) { | 4759 while (buffer != NULL) { |
| 4766 SlotsBuffer* next_buffer = buffer->next(); | 4760 SlotsBuffer* next_buffer = buffer->next(); |
| 4767 DeallocateBuffer(buffer); | 4761 DeallocateBuffer(buffer); |
| 4768 buffer = next_buffer; | 4762 buffer = next_buffer; |
| 4769 } | 4763 } |
| 4770 *buffer_address = NULL; | 4764 *buffer_address = NULL; |
| 4771 } | 4765 } |
| 4772 } | 4766 } |
| 4773 } // namespace v8::internal | 4767 } // namespace v8::internal |
| OLD | NEW |