40 #include "memory/referencePolicy.hpp" |
40 #include "memory/referencePolicy.hpp" |
41 #include "memory/resourceArea.hpp" |
41 #include "memory/resourceArea.hpp" |
42 #include "oops/oop.inline.hpp" |
42 #include "oops/oop.inline.hpp" |
43 #include "runtime/handles.inline.hpp" |
43 #include "runtime/handles.inline.hpp" |
44 #include "runtime/java.hpp" |
44 #include "runtime/java.hpp" |
|
45 #include "services/memTracker.hpp" |
45 |
46 |
46 // Concurrent marking bit map wrapper |
47 // Concurrent marking bit map wrapper |
47 |
48 |
48 CMBitMapRO::CMBitMapRO(ReservedSpace rs, int shifter) : |
49 CMBitMapRO::CMBitMapRO(ReservedSpace rs, int shifter) : |
49 _bm((uintptr_t*)NULL,0), |
50 _bm((uintptr_t*)NULL,0), |
50 _shifter(shifter) { |
51 _shifter(shifter) { |
51 _bmStartWord = (HeapWord*)(rs.base()); |
52 _bmStartWord = (HeapWord*)(rs.base()); |
52 _bmWordSize = rs.size()/HeapWordSize; // rs.size() is in bytes |
53 _bmWordSize = rs.size()/HeapWordSize; // rs.size() is in bytes |
53 ReservedSpace brs(ReservedSpace::allocation_align_size_up( |
54 ReservedSpace brs(ReservedSpace::allocation_align_size_up( |
54 (_bmWordSize >> (_shifter + LogBitsPerByte)) + 1)); |
55 (_bmWordSize >> (_shifter + LogBitsPerByte)) + 1)); |
|
56 |
|
57 MemTracker::record_virtual_memory_type((address)brs.base(), mtGC); |
55 |
58 |
56 guarantee(brs.is_reserved(), "couldn't allocate concurrent marking bit map"); |
59 guarantee(brs.is_reserved(), "couldn't allocate concurrent marking bit map"); |
57 // For now we'll just commit all of the bit map up fromt. |
60 // For now we'll just commit all of the bit map up fromt. |
58 // Later on we'll try to be more parsimonious with swap. |
61 // Later on we'll try to be more parsimonious with swap. |
59 guarantee(_virtual_space.initialize(brs, brs.size()), |
62 guarantee(_virtual_space.initialize(brs, brs.size()), |
159 , _drain_in_progress_yields(false) |
162 , _drain_in_progress_yields(false) |
160 #endif |
163 #endif |
161 {} |
164 {} |
162 |
165 |
163 void CMMarkStack::allocate(size_t size) { |
166 void CMMarkStack::allocate(size_t size) { |
164 _base = NEW_C_HEAP_ARRAY(oop, size); |
167 _base = NEW_C_HEAP_ARRAY(oop, size, mtGC); |
165 if (_base == NULL) { |
168 if (_base == NULL) { |
166 vm_exit_during_initialization("Failed to allocate CM region mark stack"); |
169 vm_exit_during_initialization("Failed to allocate CM region mark stack"); |
167 } |
170 } |
168 _index = 0; |
171 _index = 0; |
169 _capacity = (jint) size; |
172 _capacity = (jint) size; |
478 SATBMarkQueueSet& satb_qs = JavaThread::satb_mark_queue_set(); |
481 SATBMarkQueueSet& satb_qs = JavaThread::satb_mark_queue_set(); |
479 satb_qs.set_buffer_size(G1SATBBufferSize); |
482 satb_qs.set_buffer_size(G1SATBBufferSize); |
480 |
483 |
481 _root_regions.init(_g1h, this); |
484 _root_regions.init(_g1h, this); |
482 |
485 |
483 _tasks = NEW_C_HEAP_ARRAY(CMTask*, _max_task_num); |
486 _tasks = NEW_C_HEAP_ARRAY(CMTask*, _max_task_num, mtGC); |
484 _accum_task_vtime = NEW_C_HEAP_ARRAY(double, _max_task_num); |
487 _accum_task_vtime = NEW_C_HEAP_ARRAY(double, _max_task_num, mtGC); |
485 |
488 |
486 _count_card_bitmaps = NEW_C_HEAP_ARRAY(BitMap, _max_task_num); |
489 _count_card_bitmaps = NEW_C_HEAP_ARRAY(BitMap, _max_task_num, mtGC); |
487 _count_marked_bytes = NEW_C_HEAP_ARRAY(size_t*, _max_task_num); |
490 _count_marked_bytes = NEW_C_HEAP_ARRAY(size_t*, _max_task_num, mtGC); |
488 |
491 |
489 BitMap::idx_t card_bm_size = _card_bm.size(); |
492 BitMap::idx_t card_bm_size = _card_bm.size(); |
490 |
493 |
491 // so that the assertion in MarkingTaskQueue::task_queue doesn't fail |
494 // so that the assertion in MarkingTaskQueue::task_queue doesn't fail |
492 _active_tasks = _max_task_num; |
495 _active_tasks = _max_task_num; |
494 CMTaskQueue* task_queue = new CMTaskQueue(); |
497 CMTaskQueue* task_queue = new CMTaskQueue(); |
495 task_queue->initialize(); |
498 task_queue->initialize(); |
496 _task_queues->register_queue(i, task_queue); |
499 _task_queues->register_queue(i, task_queue); |
497 |
500 |
498 _count_card_bitmaps[i] = BitMap(card_bm_size, false); |
501 _count_card_bitmaps[i] = BitMap(card_bm_size, false); |
499 _count_marked_bytes[i] = NEW_C_HEAP_ARRAY(size_t, (size_t) max_regions); |
502 _count_marked_bytes[i] = NEW_C_HEAP_ARRAY(size_t, (size_t) max_regions, mtGC); |
500 |
503 |
501 _tasks[i] = new CMTask(i, this, |
504 _tasks[i] = new CMTask(i, this, |
502 _count_marked_bytes[i], |
505 _count_marked_bytes[i], |
503 &_count_card_bitmaps[i], |
506 &_count_card_bitmaps[i], |
504 task_queue, _task_queues); |
507 task_queue, _task_queues); |