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;
2632 bool ret_succeeded = op.prologue_succeeded() && op.pause_succeeded();
2633 assert(result == NULL || ret_succeeded,
2634 "the result should be NULL if the VM did not succeed");
2635 *succeeded = ret_succeeded;
2636
2637 assert_heap_not_locked();
2638 return result;
2639 }
2640
2641 void
2642 G1CollectedHeap::doConcurrentMark() {
2643 MutexLockerEx x(CGC_lock, Mutex::_no_safepoint_check_flag);
2644 if (!_cmThread->in_progress()) {
2645 _cmThread->set_started();
2646 CGC_lock->notify();
2647 }
2648 }
2649
2650 size_t G1CollectedHeap::pending_card_num() {
2651 size_t extra_cards = 0;
2652 JavaThread *curr = Threads::first();
2653 while (curr != NULL) {
2654 DirtyCardQueue& dcq = curr->dirty_card_queue();
2655 extra_cards += dcq.size();
2656 curr = curr->next();
2657 }
2658 DirtyCardQueueSet& dcqs = JavaThread::dirty_card_queue_set();
2659 size_t buffer_size = dcqs.buffer_size();
2660 size_t buffer_num = dcqs.completed_buffers_num();
2661
2662 return buffer_size * buffer_num + extra_cards;
2663 }
2664
2665 class RegisterHumongousWithInCSetFastTestClosure : public HeapRegionClosure {
2666 private:
2667 size_t _total_humongous;
2668 size_t _candidate_humongous;
2669
2670 DirtyCardQueue _dcq;
2671
2672 // We don't nominate objects with many remembered set entries, on
2673 // the assumption that such objects are likely still live.
2674 bool is_remset_small(HeapRegion* region) const {
2675 HeapRegionRemSet* const rset = region->rem_set();
2676 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;
2633 bool ret_succeeded = op.prologue_succeeded() && op.pause_succeeded();
2634 assert(result == NULL || ret_succeeded,
2635 "the result should be NULL if the VM did not succeed");
2636 *succeeded = ret_succeeded;
2637
2638 assert_heap_not_locked();
2639 return result;
2640 }
2641
2642 void
2643 G1CollectedHeap::doConcurrentMark() {
2644 MutexLockerEx x(CGC_lock, Mutex::_no_safepoint_check_flag);
2645 if (!_cmThread->in_progress()) {
2646 _cmThread->set_started();
2647 CGC_lock->notify();
2648 }
2649 }
2650
2651 size_t G1CollectedHeap::pending_card_num() {
2652 size_t extra_cards = 0;
2653 for (JavaThreadIteratorWithHandle jtiwh; JavaThread *curr = jtiwh.next(); ) {
2654 DirtyCardQueue& dcq = curr->dirty_card_queue();
2655 extra_cards += dcq.size();
2656 }
2657 DirtyCardQueueSet& dcqs = JavaThread::dirty_card_queue_set();
2658 size_t buffer_size = dcqs.buffer_size();
2659 size_t buffer_num = dcqs.completed_buffers_num();
2660
2661 return buffer_size * buffer_num + extra_cards;
2662 }
2663
2664 class RegisterHumongousWithInCSetFastTestClosure : public HeapRegionClosure {
2665 private:
2666 size_t _total_humongous;
2667 size_t _candidate_humongous;
2668
2669 DirtyCardQueue _dcq;
2670
2671 // We don't nominate objects with many remembered set entries, on
2672 // the assumption that such objects are likely still live.
2673 bool is_remset_small(HeapRegion* region) const {
2674 HeapRegionRemSet* const rset = region->rem_set();
2675 return G1EagerReclaimHumongousObjectsWithStaleRefs
|