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 3023 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3034 int object_size) { | 3034 int object_size) { |
3035 DCHECK(object_size <= Page::kMaxRegularHeapObjectSize); | 3035 DCHECK(object_size <= Page::kMaxRegularHeapObjectSize); |
3036 | 3036 |
3037 OldSpace* old_space = heap()->old_space(); | 3037 OldSpace* old_space = heap()->old_space(); |
3038 | 3038 |
3039 HeapObject* target; | 3039 HeapObject* target; |
3040 AllocationAlignment alignment = object->RequiredAlignment(); | 3040 AllocationAlignment alignment = object->RequiredAlignment(); |
3041 AllocationResult allocation = old_space->AllocateRaw(object_size, alignment); | 3041 AllocationResult allocation = old_space->AllocateRaw(object_size, alignment); |
3042 if (allocation.To(&target)) { | 3042 if (allocation.To(&target)) { |
3043 MigrateObject(target, object, object_size, old_space->identity()); | 3043 MigrateObject(target, object, object_size, old_space->identity()); |
| 3044 // If we end up needing more special cases, we should factor this out. |
| 3045 if (V8_UNLIKELY(target->IsJSArrayBuffer())) { |
| 3046 heap()->PromoteArrayBuffer(target); |
| 3047 } |
3044 heap()->IncrementPromotedObjectsSize(object_size); | 3048 heap()->IncrementPromotedObjectsSize(object_size); |
3045 return true; | 3049 return true; |
3046 } | 3050 } |
3047 | 3051 |
3048 return false; | 3052 return false; |
3049 } | 3053 } |
3050 | 3054 |
3051 | 3055 |
3052 bool MarkCompactCollector::IsSlotInBlackObject(Page* p, Address slot, | 3056 bool MarkCompactCollector::IsSlotInBlackObject(Page* p, Address slot, |
3053 HeapObject** out_object) { | 3057 HeapObject** out_object) { |
(...skipping 1306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4360 void MarkCompactCollector::SweepSpaces() { | 4364 void MarkCompactCollector::SweepSpaces() { |
4361 GCTracer::Scope gc_scope(heap()->tracer(), GCTracer::Scope::MC_SWEEP); | 4365 GCTracer::Scope gc_scope(heap()->tracer(), GCTracer::Scope::MC_SWEEP); |
4362 double start_time = 0.0; | 4366 double start_time = 0.0; |
4363 if (FLAG_print_cumulative_gc_stat) { | 4367 if (FLAG_print_cumulative_gc_stat) { |
4364 start_time = base::OS::TimeCurrentMillis(); | 4368 start_time = base::OS::TimeCurrentMillis(); |
4365 } | 4369 } |
4366 | 4370 |
4367 #ifdef DEBUG | 4371 #ifdef DEBUG |
4368 state_ = SWEEP_SPACES; | 4372 state_ = SWEEP_SPACES; |
4369 #endif | 4373 #endif |
4370 heap()->FreeDeadArrayBuffers(); | |
4371 | 4374 |
4372 MoveEvacuationCandidatesToEndOfPagesList(); | 4375 MoveEvacuationCandidatesToEndOfPagesList(); |
4373 | 4376 |
4374 // Noncompacting collections simply sweep the spaces to clear the mark | 4377 // Noncompacting collections simply sweep the spaces to clear the mark |
4375 // bits and free the nonlive blocks (for old and map spaces). We sweep | 4378 // bits and free the nonlive blocks (for old and map spaces). We sweep |
4376 // the map space last because freeing non-live maps overwrites them and | 4379 // the map space last because freeing non-live maps overwrites them and |
4377 // the other spaces rely on possibly non-live maps to get the sizes for | 4380 // the other spaces rely on possibly non-live maps to get the sizes for |
4378 // non-live objects. | 4381 // non-live objects. |
4379 { | 4382 { |
4380 GCTracer::Scope sweep_scope(heap()->tracer(), | 4383 GCTracer::Scope sweep_scope(heap()->tracer(), |
4381 GCTracer::Scope::MC_SWEEP_OLDSPACE); | 4384 GCTracer::Scope::MC_SWEEP_OLDSPACE); |
4382 { SweepSpace(heap()->old_space(), CONCURRENT_SWEEPING); } | 4385 { SweepSpace(heap()->old_space(), CONCURRENT_SWEEPING); } |
4383 sweeping_in_progress_ = true; | 4386 sweeping_in_progress_ = true; |
4384 if (heap()->concurrent_sweeping_enabled()) { | 4387 if (heap()->concurrent_sweeping_enabled()) { |
4385 StartSweeperThreads(); | 4388 StartSweeperThreads(); |
4386 } | 4389 } |
4387 } | 4390 } |
4388 RemoveDeadInvalidatedCode(); | 4391 RemoveDeadInvalidatedCode(); |
4389 | 4392 |
4390 { | 4393 { |
4391 GCTracer::Scope sweep_scope(heap()->tracer(), | 4394 GCTracer::Scope sweep_scope(heap()->tracer(), |
4392 GCTracer::Scope::MC_SWEEP_CODE); | 4395 GCTracer::Scope::MC_SWEEP_CODE); |
4393 SweepSpace(heap()->code_space(), SEQUENTIAL_SWEEPING); | 4396 SweepSpace(heap()->code_space(), SEQUENTIAL_SWEEPING); |
4394 } | 4397 } |
4395 | 4398 |
4396 EvacuateNewSpaceAndCandidates(); | 4399 EvacuateNewSpaceAndCandidates(); |
4397 | 4400 |
| 4401 heap()->FreeDeadArrayBuffers(false); |
| 4402 |
4398 // ClearNonLiveReferences depends on precise sweeping of map space to | 4403 // ClearNonLiveReferences depends on precise sweeping of map space to |
4399 // detect whether unmarked map became dead in this collection or in one | 4404 // detect whether unmarked map became dead in this collection or in one |
4400 // of the previous ones. | 4405 // of the previous ones. |
4401 { | 4406 { |
4402 GCTracer::Scope sweep_scope(heap()->tracer(), | 4407 GCTracer::Scope sweep_scope(heap()->tracer(), |
4403 GCTracer::Scope::MC_SWEEP_MAP); | 4408 GCTracer::Scope::MC_SWEEP_MAP); |
4404 SweepSpace(heap()->map_space(), SEQUENTIAL_SWEEPING); | 4409 SweepSpace(heap()->map_space(), SEQUENTIAL_SWEEPING); |
4405 } | 4410 } |
4406 | 4411 |
4407 // Deallocate unmarked objects and clear marked bits for marked objects. | 4412 // Deallocate unmarked objects and clear marked bits for marked objects. |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4723 SlotsBuffer* buffer = *buffer_address; | 4728 SlotsBuffer* buffer = *buffer_address; |
4724 while (buffer != NULL) { | 4729 while (buffer != NULL) { |
4725 SlotsBuffer* next_buffer = buffer->next(); | 4730 SlotsBuffer* next_buffer = buffer->next(); |
4726 DeallocateBuffer(buffer); | 4731 DeallocateBuffer(buffer); |
4727 buffer = next_buffer; | 4732 buffer = next_buffer; |
4728 } | 4733 } |
4729 *buffer_address = NULL; | 4734 *buffer_address = NULL; |
4730 } | 4735 } |
4731 } // namespace internal | 4736 } // namespace internal |
4732 } // namespace v8 | 4737 } // namespace v8 |
OLD | NEW |