| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 evacuation_candidates_.Add(p); | 237 evacuation_candidates_.Add(p); |
| 238 } | 238 } |
| 239 | 239 |
| 240 | 240 |
| 241 bool MarkCompactCollector::StartCompaction() { | 241 bool MarkCompactCollector::StartCompaction() { |
| 242 if (!compacting_) { | 242 if (!compacting_) { |
| 243 ASSERT(evacuation_candidates_.length() == 0); | 243 ASSERT(evacuation_candidates_.length() == 0); |
| 244 | 244 |
| 245 CollectEvacuationCandidates(heap()->old_pointer_space()); | 245 CollectEvacuationCandidates(heap()->old_pointer_space()); |
| 246 CollectEvacuationCandidates(heap()->old_data_space()); | 246 CollectEvacuationCandidates(heap()->old_data_space()); |
| 247 CollectEvacuationCandidates(heap()->code_space()); | 247 |
| 248 if (FLAG_compact_code_space) { |
| 249 CollectEvacuationCandidates(heap()->code_space()); |
| 250 } |
| 248 | 251 |
| 249 heap()->old_pointer_space()->EvictEvacuationCandidatesFromFreeLists(); | 252 heap()->old_pointer_space()->EvictEvacuationCandidatesFromFreeLists(); |
| 250 heap()->old_data_space()->EvictEvacuationCandidatesFromFreeLists(); | 253 heap()->old_data_space()->EvictEvacuationCandidatesFromFreeLists(); |
| 251 heap()->code_space()->EvictEvacuationCandidatesFromFreeLists(); | 254 heap()->code_space()->EvictEvacuationCandidatesFromFreeLists(); |
| 252 | 255 |
| 253 compacting_ = evacuation_candidates_.length() > 0; | 256 compacting_ = evacuation_candidates_.length() > 0; |
| 254 } | 257 } |
| 255 | 258 |
| 256 return compacting_; | 259 return compacting_; |
| 257 } | 260 } |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 473 collect_maps_ = FLAG_collect_maps && !was_marked_incrementally_; | 476 collect_maps_ = FLAG_collect_maps && !was_marked_incrementally_; |
| 474 | 477 |
| 475 // Rather than passing the tracer around we stash it in a static member | 478 // Rather than passing the tracer around we stash it in a static member |
| 476 // variable. | 479 // variable. |
| 477 tracer_ = tracer; | 480 tracer_ = tracer; |
| 478 | 481 |
| 479 #ifdef DEBUG | 482 #ifdef DEBUG |
| 480 ASSERT(state_ == IDLE); | 483 ASSERT(state_ == IDLE); |
| 481 state_ = PREPARE_GC; | 484 state_ = PREPARE_GC; |
| 482 #endif | 485 #endif |
| 483 ASSERT(!FLAG_always_compact || !FLAG_never_compact); | 486 if (FLAG_never_compact) FLAG_always_compact = false; |
| 484 | 487 |
| 485 if (collect_maps_) CreateBackPointers(); | 488 if (collect_maps_) CreateBackPointers(); |
| 486 #ifdef ENABLE_GDB_JIT_INTERFACE | 489 #ifdef ENABLE_GDB_JIT_INTERFACE |
| 487 if (FLAG_gdbjit) { | 490 if (FLAG_gdbjit) { |
| 488 // If GDBJIT interface is active disable compaction. | 491 // If GDBJIT interface is active disable compaction. |
| 489 compacting_collection_ = false; | 492 compacting_collection_ = false; |
| 490 } | 493 } |
| 491 #endif | 494 #endif |
| 492 | 495 |
| 493 // Clear marking bits for precise sweeping to collect all garbage. | 496 // Clear marking bits for precise sweeping to collect all garbage. |
| (...skipping 1950 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2444 VisitPointer(&target); | 2447 VisitPointer(&target); |
| 2445 rinfo->set_call_address(Code::cast(target)->instruction_start()); | 2448 rinfo->set_call_address(Code::cast(target)->instruction_start()); |
| 2446 } | 2449 } |
| 2447 | 2450 |
| 2448 private: | 2451 private: |
| 2449 inline void UpdatePointer(Object** p) { | 2452 inline void UpdatePointer(Object** p) { |
| 2450 if (!(*p)->IsHeapObject()) return; | 2453 if (!(*p)->IsHeapObject()) return; |
| 2451 | 2454 |
| 2452 HeapObject* obj = HeapObject::cast(*p); | 2455 HeapObject* obj = HeapObject::cast(*p); |
| 2453 | 2456 |
| 2454 if (heap_->InNewSpace(obj) || | 2457 MapWord map_word = obj->map_word(); |
| 2455 MarkCompactCollector::IsOnEvacuationCandidate(obj)) { | 2458 if (map_word.IsForwardingAddress()) { |
| 2456 ASSERT(obj->map_word().IsForwardingAddress()); | 2459 ASSERT(heap_->InFromSpace(obj) || |
| 2460 MarkCompactCollector::IsOnEvacuationCandidate(obj)); |
| 2457 *p = obj->map_word().ToForwardingAddress(); | 2461 *p = obj->map_word().ToForwardingAddress(); |
| 2458 ASSERT(!MarkCompactCollector::IsOnEvacuationCandidate(*p)); | 2462 ASSERT(!heap_->InFromSpace(*p) && |
| 2463 !MarkCompactCollector::IsOnEvacuationCandidate(*p)); |
| 2459 } | 2464 } |
| 2460 } | 2465 } |
| 2461 | 2466 |
| 2462 Heap* heap_; | 2467 Heap* heap_; |
| 2463 }; | 2468 }; |
| 2464 | 2469 |
| 2465 | 2470 |
| 2466 static void UpdatePointer(HeapObject** p, HeapObject* object) { | 2471 static void UpdatePointer(HeapObject** p, HeapObject* object) { |
| 2467 ASSERT(*p == object); | 2472 ASSERT(*p == object); |
| 2468 | 2473 |
| (...skipping 1359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3828 while (buffer != NULL) { | 3833 while (buffer != NULL) { |
| 3829 SlotsBuffer* next_buffer = buffer->next(); | 3834 SlotsBuffer* next_buffer = buffer->next(); |
| 3830 DeallocateBuffer(buffer); | 3835 DeallocateBuffer(buffer); |
| 3831 buffer = next_buffer; | 3836 buffer = next_buffer; |
| 3832 } | 3837 } |
| 3833 *buffer_address = NULL; | 3838 *buffer_address = NULL; |
| 3834 } | 3839 } |
| 3835 | 3840 |
| 3836 | 3841 |
| 3837 } } // namespace v8::internal | 3842 } } // namespace v8::internal |
| OLD | NEW |