64 #include "gc/shared/gcLocker.inline.hpp"
65 #include "gc/shared/gcTimer.hpp"
66 #include "gc/shared/gcTrace.hpp"
67 #include "gc/shared/gcTraceTime.inline.hpp"
68 #include "gc/shared/generationSpec.hpp"
69 #include "gc/shared/isGCActiveMark.hpp"
70 #include "gc/shared/preservedMarks.inline.hpp"
71 #include "gc/shared/suspendibleThreadSet.hpp"
72 #include "gc/shared/referenceProcessor.inline.hpp"
73 #include "gc/shared/taskqueue.inline.hpp"
74 #include "gc/shared/weakProcessor.hpp"
75 #include "logging/log.hpp"
76 #include "memory/allocation.hpp"
77 #include "memory/iterator.hpp"
78 #include "memory/resourceArea.hpp"
79 #include "oops/oop.inline.hpp"
80 #include "prims/resolvedMethodTable.hpp"
81 #include "runtime/atomic.hpp"
82 #include "runtime/init.hpp"
83 #include "runtime/orderAccess.inline.hpp"
84 #include "runtime/vmThread.hpp"
85 #include "utilities/align.hpp"
86 #include "utilities/globalDefinitions.hpp"
87 #include "utilities/stack.inline.hpp"
88
89 size_t G1CollectedHeap::_humongous_object_threshold_in_words = 0;
90
91 // INVARIANTS/NOTES
92 //
93 // All allocation activity covered by the G1CollectedHeap interface is
94 // serialized by acquiring the HeapLock. This happens in mem_allocate
95 // and allocate_new_tlab, which are the "entry" points to the
96 // allocation code from the rest of the JVM. (Note that this does not
97 // apply to TLAB allocation, which is not part of this interface: it
98 // is done by clients of this interface.)
99
100 class RedirtyLoggedCardTableEntryClosure : public CardTableEntryClosure {
101 private:
102 size_t _num_dirtied;
103 G1CollectedHeap* _g1h;
2636 bool ret_succeeded = op.prologue_succeeded() && op.pause_succeeded();
2637 assert(result == NULL || ret_succeeded,
2638 "the result should be NULL if the VM did not succeed");
2639 *succeeded = ret_succeeded;
2640
2641 assert_heap_not_locked();
2642 return result;
2643 }
2644
2645 void
2646 G1CollectedHeap::doConcurrentMark() {
2647 MutexLockerEx x(CGC_lock, Mutex::_no_safepoint_check_flag);
2648 if (!_cmThread->in_progress()) {
2649 _cmThread->set_started();
2650 CGC_lock->notify();
2651 }
2652 }
2653
2654 size_t G1CollectedHeap::pending_card_num() {
2655 size_t extra_cards = 0;
2656 JavaThread *curr = Threads::first();
2657 while (curr != NULL) {
2658 DirtyCardQueue& dcq = curr->dirty_card_queue();
2659 extra_cards += dcq.size();
2660 curr = curr->next();
2661 }
2662 DirtyCardQueueSet& dcqs = JavaThread::dirty_card_queue_set();
2663 size_t buffer_size = dcqs.buffer_size();
2664 size_t buffer_num = dcqs.completed_buffers_num();
2665
2666 return buffer_size * buffer_num + extra_cards;
2667 }
2668
2669 class RegisterHumongousWithInCSetFastTestClosure : public HeapRegionClosure {
2670 private:
2671 size_t _total_humongous;
2672 size_t _candidate_humongous;
2673
2674 DirtyCardQueue _dcq;
2675
2676 // We don't nominate objects with many remembered set entries, on
2677 // the assumption that such objects are likely still live.
2678 bool is_remset_small(HeapRegion* region) const {
2679 HeapRegionRemSet* const rset = region->rem_set();
2680 return G1EagerReclaimHumongousObjectsWithStaleRefs
|
64 #include "gc/shared/gcLocker.inline.hpp"
65 #include "gc/shared/gcTimer.hpp"
66 #include "gc/shared/gcTrace.hpp"
67 #include "gc/shared/gcTraceTime.inline.hpp"
68 #include "gc/shared/generationSpec.hpp"
69 #include "gc/shared/isGCActiveMark.hpp"
70 #include "gc/shared/preservedMarks.inline.hpp"
71 #include "gc/shared/suspendibleThreadSet.hpp"
72 #include "gc/shared/referenceProcessor.inline.hpp"
73 #include "gc/shared/taskqueue.inline.hpp"
74 #include "gc/shared/weakProcessor.hpp"
75 #include "logging/log.hpp"
76 #include "memory/allocation.hpp"
77 #include "memory/iterator.hpp"
78 #include "memory/resourceArea.hpp"
79 #include "oops/oop.inline.hpp"
80 #include "prims/resolvedMethodTable.hpp"
81 #include "runtime/atomic.hpp"
82 #include "runtime/init.hpp"
83 #include "runtime/orderAccess.inline.hpp"
84 #include "runtime/threadSMR.hpp"
85 #include "runtime/vmThread.hpp"
86 #include "utilities/align.hpp"
87 #include "utilities/globalDefinitions.hpp"
88 #include "utilities/stack.inline.hpp"
89
90 size_t G1CollectedHeap::_humongous_object_threshold_in_words = 0;
91
92 // INVARIANTS/NOTES
93 //
94 // All allocation activity covered by the G1CollectedHeap interface is
95 // serialized by acquiring the HeapLock. This happens in mem_allocate
96 // and allocate_new_tlab, which are the "entry" points to the
97 // allocation code from the rest of the JVM. (Note that this does not
98 // apply to TLAB allocation, which is not part of this interface: it
99 // is done by clients of this interface.)
100
101 class RedirtyLoggedCardTableEntryClosure : public CardTableEntryClosure {
102 private:
103 size_t _num_dirtied;
104 G1CollectedHeap* _g1h;
2637 bool ret_succeeded = op.prologue_succeeded() && op.pause_succeeded();
2638 assert(result == NULL || ret_succeeded,
2639 "the result should be NULL if the VM did not succeed");
2640 *succeeded = ret_succeeded;
2641
2642 assert_heap_not_locked();
2643 return result;
2644 }
2645
2646 void
2647 G1CollectedHeap::doConcurrentMark() {
2648 MutexLockerEx x(CGC_lock, Mutex::_no_safepoint_check_flag);
2649 if (!_cmThread->in_progress()) {
2650 _cmThread->set_started();
2651 CGC_lock->notify();
2652 }
2653 }
2654
2655 size_t G1CollectedHeap::pending_card_num() {
2656 size_t extra_cards = 0;
2657 for (JavaThreadIteratorWithHandle jtiwh; JavaThread *curr = jtiwh.next(); ) {
2658 DirtyCardQueue& dcq = curr->dirty_card_queue();
2659 extra_cards += dcq.size();
2660 }
2661 DirtyCardQueueSet& dcqs = JavaThread::dirty_card_queue_set();
2662 size_t buffer_size = dcqs.buffer_size();
2663 size_t buffer_num = dcqs.completed_buffers_num();
2664
2665 return buffer_size * buffer_num + extra_cards;
2666 }
2667
2668 class RegisterHumongousWithInCSetFastTestClosure : public HeapRegionClosure {
2669 private:
2670 size_t _total_humongous;
2671 size_t _candidate_humongous;
2672
2673 DirtyCardQueue _dcq;
2674
2675 // We don't nominate objects with many remembered set entries, on
2676 // the assumption that such objects are likely still live.
2677 bool is_remset_small(HeapRegion* region) const {
2678 HeapRegionRemSet* const rset = region->rem_set();
2679 return G1EagerReclaimHumongousObjectsWithStaleRefs
|