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 "v8.h" | 5 #include "v8.h" |
6 | 6 |
7 #include "code-stubs.h" | 7 #include "code-stubs.h" |
8 #include "compilation-cache.h" | 8 #include "compilation-cache.h" |
9 #include "cpu-profiler.h" | 9 #include "cpu-profiler.h" |
10 #include "deoptimizer.h" | 10 #include "deoptimizer.h" |
11 #include "execution.h" | 11 #include "execution.h" |
12 #include "gdb-jit.h" | 12 #include "gdb-jit.h" |
13 #include "global-handles.h" | 13 #include "global-handles.h" |
14 #include "heap-profiler.h" | 14 #include "heap-profiler.h" |
15 #include "ic-inl.h" | 15 #include "ic-inl.h" |
16 #include "incremental-marking.h" | 16 #include "incremental-marking.h" |
17 #include "mark-compact.h" | 17 #include "mark-compact.h" |
18 #include "objects-visiting.h" | 18 #include "objects-visiting.h" |
19 #include "objects-visiting-inl.h" | 19 #include "objects-visiting-inl.h" |
20 #include "stub-cache.h" | 20 #include "stub-cache.h" |
21 #include "spaces-inl.h" | |
Hannes Payer (out of office)
2014/04/30 07:07:07
order:
#include "spaces-inl.h"
#include "stub-cach
| |
21 #include "sweeper-thread.h" | 22 #include "sweeper-thread.h" |
22 | 23 |
23 namespace v8 { | 24 namespace v8 { |
24 namespace internal { | 25 namespace internal { |
25 | 26 |
26 | 27 |
27 const char* Marking::kWhiteBitPattern = "00"; | 28 const char* Marking::kWhiteBitPattern = "00"; |
28 const char* Marking::kBlackBitPattern = "10"; | 29 const char* Marking::kBlackBitPattern = "10"; |
29 const char* Marking::kGreyBitPattern = "11"; | 30 const char* Marking::kGreyBitPattern = "11"; |
30 const char* Marking::kImpossibleBitPattern = "01"; | 31 const char* Marking::kImpossibleBitPattern = "01"; |
(...skipping 2005 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2036 Heap::UpdateAllocationSiteFeedback(object, Heap::RECORD_SCRATCHPAD_SLOT); | 2037 Heap::UpdateAllocationSiteFeedback(object, Heap::RECORD_SCRATCHPAD_SLOT); |
2037 | 2038 |
2038 offset++; | 2039 offset++; |
2039 current_cell >>= 1; | 2040 current_cell >>= 1; |
2040 // Aggressively promote young survivors to the old space. | 2041 // Aggressively promote young survivors to the old space. |
2041 if (TryPromoteObject(object, size)) { | 2042 if (TryPromoteObject(object, size)) { |
2042 continue; | 2043 continue; |
2043 } | 2044 } |
2044 | 2045 |
2045 // Promotion failed. Just migrate object to another semispace. | 2046 // Promotion failed. Just migrate object to another semispace. |
2046 MaybeObject* allocation = new_space->AllocateRaw(size); | 2047 AllocationResult allocation = new_space->AllocateRaw(size); |
2047 if (allocation->IsFailure()) { | 2048 if (allocation.IsRetry()) { |
2048 if (!new_space->AddFreshPage()) { | 2049 if (!new_space->AddFreshPage()) { |
2049 // Shouldn't happen. We are sweeping linearly, and to-space | 2050 // Shouldn't happen. We are sweeping linearly, and to-space |
2050 // has the same number of pages as from-space, so there is | 2051 // has the same number of pages as from-space, so there is |
2051 // always room. | 2052 // always room. |
2052 UNREACHABLE(); | 2053 UNREACHABLE(); |
2053 } | 2054 } |
2054 allocation = new_space->AllocateRaw(size); | 2055 allocation = new_space->AllocateRaw(size); |
2055 ASSERT(!allocation->IsFailure()); | 2056 ASSERT(!allocation.IsRetry()); |
2056 } | 2057 } |
2057 Object* target = allocation->ToObjectUnchecked(); | 2058 Object* target = allocation.ToObjectChecked(); |
2058 | 2059 |
2059 MigrateObject(HeapObject::cast(target), | 2060 MigrateObject(HeapObject::cast(target), |
2060 object, | 2061 object, |
2061 size, | 2062 size, |
2062 NEW_SPACE); | 2063 NEW_SPACE); |
2063 } | 2064 } |
2064 *cells = 0; | 2065 *cells = 0; |
2065 } | 2066 } |
2066 return survivors_size; | 2067 return survivors_size; |
2067 } | 2068 } |
(...skipping 983 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3051 | 3052 |
3052 | 3053 |
3053 bool MarkCompactCollector::TryPromoteObject(HeapObject* object, | 3054 bool MarkCompactCollector::TryPromoteObject(HeapObject* object, |
3054 int object_size) { | 3055 int object_size) { |
3055 ASSERT(object_size <= Page::kMaxRegularHeapObjectSize); | 3056 ASSERT(object_size <= Page::kMaxRegularHeapObjectSize); |
3056 | 3057 |
3057 OldSpace* target_space = heap()->TargetSpace(object); | 3058 OldSpace* target_space = heap()->TargetSpace(object); |
3058 | 3059 |
3059 ASSERT(target_space == heap()->old_pointer_space() || | 3060 ASSERT(target_space == heap()->old_pointer_space() || |
3060 target_space == heap()->old_data_space()); | 3061 target_space == heap()->old_data_space()); |
3061 Object* result; | 3062 HeapObject* target; |
3062 MaybeObject* maybe_result = target_space->AllocateRaw(object_size); | 3063 AllocationResult allocation = target_space->AllocateRaw(object_size); |
3063 if (maybe_result->ToObject(&result)) { | 3064 if (allocation.To(&target)) { |
3064 HeapObject* target = HeapObject::cast(result); | |
3065 MigrateObject(target, | 3065 MigrateObject(target, |
3066 object, | 3066 object, |
3067 object_size, | 3067 object_size, |
3068 target_space->identity()); | 3068 target_space->identity()); |
3069 heap()->mark_compact_collector()->tracer()-> | 3069 heap()->mark_compact_collector()->tracer()-> |
3070 increment_promoted_objects_size(object_size); | 3070 increment_promoted_objects_size(object_size); |
3071 return true; | 3071 return true; |
3072 } | 3072 } |
3073 | 3073 |
3074 return false; | 3074 return false; |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3125 if (*cell == 0) continue; | 3125 if (*cell == 0) continue; |
3126 | 3126 |
3127 int live_objects = MarkWordToObjectStarts(*cell, offsets); | 3127 int live_objects = MarkWordToObjectStarts(*cell, offsets); |
3128 for (int i = 0; i < live_objects; i++) { | 3128 for (int i = 0; i < live_objects; i++) { |
3129 Address object_addr = cell_base + offsets[i] * kPointerSize; | 3129 Address object_addr = cell_base + offsets[i] * kPointerSize; |
3130 HeapObject* object = HeapObject::FromAddress(object_addr); | 3130 HeapObject* object = HeapObject::FromAddress(object_addr); |
3131 ASSERT(Marking::IsBlack(Marking::MarkBitFrom(object))); | 3131 ASSERT(Marking::IsBlack(Marking::MarkBitFrom(object))); |
3132 | 3132 |
3133 int size = object->Size(); | 3133 int size = object->Size(); |
3134 | 3134 |
3135 MaybeObject* target = space->AllocateRaw(size); | 3135 HeapObject* target_object; |
3136 if (target->IsFailure()) { | 3136 AllocationResult allocation = space->AllocateRaw(size); |
3137 if (!allocation.To(&target_object)) { | |
3137 // OS refused to give us memory. | 3138 // OS refused to give us memory. |
3138 V8::FatalProcessOutOfMemory("Evacuation"); | 3139 V8::FatalProcessOutOfMemory("Evacuation"); |
3139 return; | 3140 return; |
3140 } | 3141 } |
3141 | 3142 |
3142 Object* target_object = target->ToObjectUnchecked(); | 3143 MigrateObject(target_object, object, size, space->identity()); |
3143 | |
3144 MigrateObject(HeapObject::cast(target_object), | |
3145 object, | |
3146 size, | |
3147 space->identity()); | |
3148 ASSERT(object->map_word().IsForwardingAddress()); | 3144 ASSERT(object->map_word().IsForwardingAddress()); |
3149 } | 3145 } |
3150 | 3146 |
3151 // Clear marking bits for current cell. | 3147 // Clear marking bits for current cell. |
3152 *cell = 0; | 3148 *cell = 0; |
3153 } | 3149 } |
3154 p->ResetLiveBytes(); | 3150 p->ResetLiveBytes(); |
3155 } | 3151 } |
3156 | 3152 |
3157 | 3153 |
(...skipping 1364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4522 while (buffer != NULL) { | 4518 while (buffer != NULL) { |
4523 SlotsBuffer* next_buffer = buffer->next(); | 4519 SlotsBuffer* next_buffer = buffer->next(); |
4524 DeallocateBuffer(buffer); | 4520 DeallocateBuffer(buffer); |
4525 buffer = next_buffer; | 4521 buffer = next_buffer; |
4526 } | 4522 } |
4527 *buffer_address = NULL; | 4523 *buffer_address = NULL; |
4528 } | 4524 } |
4529 | 4525 |
4530 | 4526 |
4531 } } // namespace v8::internal | 4527 } } // namespace v8::internal |
OLD | NEW |