7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "classfile/metadataOnStackMark.hpp"
27 #include "classfile/symbolTable.hpp"
28 #include "code/codeCache.hpp"
29 #include "gc/g1/g1BarrierSet.hpp"
30 #include "gc/g1/g1CollectedHeap.inline.hpp"
31 #include "gc/g1/g1CollectorState.hpp"
32 #include "gc/g1/g1ConcurrentMark.inline.hpp"
33 #include "gc/g1/g1ConcurrentMarkThread.inline.hpp"
34 #include "gc/g1/g1HeapVerifier.hpp"
35 #include "gc/g1/g1OopClosures.inline.hpp"
36 #include "gc/g1/g1Policy.hpp"
37 #include "gc/g1/g1RegionMarkStatsCache.inline.hpp"
38 #include "gc/g1/g1StringDedup.hpp"
39 #include "gc/g1/g1ThreadLocalData.hpp"
40 #include "gc/g1/heapRegion.inline.hpp"
41 #include "gc/g1/heapRegionRemSet.hpp"
42 #include "gc/g1/heapRegionSet.inline.hpp"
43 #include "gc/shared/adaptiveSizePolicy.hpp"
44 #include "gc/shared/gcId.hpp"
45 #include "gc/shared/gcTimer.hpp"
46 #include "gc/shared/gcTrace.hpp"
47 #include "gc/shared/gcTraceTime.inline.hpp"
1562 "Ergonomically chosen workers(%u) should be less than or equal to active workers(%u)",
1563 ergo_workers, _workers->active_workers());
1564
1565 G1CMRefProcTaskProxy proc_task_proxy(proc_task, _g1h, _cm);
1566
1567 // We need to reset the concurrency level before each
1568 // proxy task execution, so that the termination protocol
1569 // and overflow handling in G1CMTask::do_marking_step() knows
1570 // how many workers to wait for.
1571 _cm->set_concurrency(ergo_workers);
1572 _workers->run_task(&proc_task_proxy, ergo_workers);
1573 }
1574
1575 void G1ConcurrentMark::weak_refs_work(bool clear_all_soft_refs) {
1576 ResourceMark rm;
1577 HandleMark hm;
1578
1579 // Is alive closure.
1580 G1CMIsAliveClosure g1_is_alive(_g1h);
1581
1582 // Inner scope to exclude the cleaning of the string and symbol
1583 // tables from the displayed time.
1584 {
1585 GCTraceTime(Debug, gc, phases) debug("Reference Processing", _gc_timer_cm);
1586
1587 ReferenceProcessor* rp = _g1h->ref_processor_cm();
1588
1589 // See the comment in G1CollectedHeap::ref_processing_init()
1590 // about how reference processing currently works in G1.
1591
1592 // Set the soft reference policy
1593 rp->setup_policy(clear_all_soft_refs);
1594 assert(_global_mark_stack.is_empty(), "mark stack should be empty");
1595
1596 // Instances of the 'Keep Alive' and 'Complete GC' closures used
1597 // in serial reference processing. Note these closures are also
1598 // used for serially processing (by the the current thread) the
1599 // JNI references during parallel reference processing.
1600 //
1601 // These closures do not need to synchronize with the worker
1602 // threads involved in parallel reference processing as these
1603 // instances are executed serially by the current thread (e.g.
1657 rp->verify_no_references_recorded();
1658 assert(!rp->discovery_enabled(), "Post condition");
1659 }
1660
1661 if (has_overflown()) {
1662 // We can not trust g1_is_alive and the contents of the heap if the marking stack
1663 // overflowed while processing references. Exit the VM.
1664 fatal("Overflow during reference processing, can not continue. Please "
1665 "increase MarkStackSizeMax (current value: " SIZE_FORMAT ") and "
1666 "restart.", MarkStackSizeMax);
1667 return;
1668 }
1669
1670 assert(_global_mark_stack.is_empty(), "Marking should have completed");
1671
1672 {
1673 GCTraceTime(Debug, gc, phases) debug("Weak Processing", _gc_timer_cm);
1674 WeakProcessor::weak_oops_do(&g1_is_alive, &do_nothing_cl);
1675 }
1676
1677 // Unload Klasses, String, Symbols, Code Cache, etc.
1678 if (ClassUnloadingWithConcurrentMark) {
1679 GCTraceTime(Debug, gc, phases) debug("Class Unloading", _gc_timer_cm);
1680 bool purged_classes = SystemDictionary::do_unloading(_gc_timer_cm, false /* Defer cleaning */);
1681 _g1h->complete_cleaning(&g1_is_alive, purged_classes);
1682 } else {
1683 GCTraceTime(Debug, gc, phases) debug("Cleanup", _gc_timer_cm);
1684 // No need to clean string table and symbol table as they are treated as strong roots when
1685 // class unloading is disabled.
1686 _g1h->partial_cleaning(&g1_is_alive, false, false, G1StringDedup::is_enabled());
1687 }
1688 }
1689
1690 class G1PrecleanYieldClosure : public YieldClosure {
1691 G1ConcurrentMark* _cm;
1692
1693 public:
1694 G1PrecleanYieldClosure(G1ConcurrentMark* cm) : _cm(cm) { }
1695
1696 virtual bool should_return() {
1697 return _cm->has_aborted();
1698 }
1699
1700 virtual bool should_return_fine_grain() {
1701 _cm->do_yield_check();
1702 return _cm->has_aborted();
1703 }
1704 };
1705
1706 void G1ConcurrentMark::preclean() {
|
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "classfile/metadataOnStackMark.hpp"
27 #include "code/codeCache.hpp"
28 #include "gc/g1/g1BarrierSet.hpp"
29 #include "gc/g1/g1CollectedHeap.inline.hpp"
30 #include "gc/g1/g1CollectorState.hpp"
31 #include "gc/g1/g1ConcurrentMark.inline.hpp"
32 #include "gc/g1/g1ConcurrentMarkThread.inline.hpp"
33 #include "gc/g1/g1HeapVerifier.hpp"
34 #include "gc/g1/g1OopClosures.inline.hpp"
35 #include "gc/g1/g1Policy.hpp"
36 #include "gc/g1/g1RegionMarkStatsCache.inline.hpp"
37 #include "gc/g1/g1StringDedup.hpp"
38 #include "gc/g1/g1ThreadLocalData.hpp"
39 #include "gc/g1/heapRegion.inline.hpp"
40 #include "gc/g1/heapRegionRemSet.hpp"
41 #include "gc/g1/heapRegionSet.inline.hpp"
42 #include "gc/shared/adaptiveSizePolicy.hpp"
43 #include "gc/shared/gcId.hpp"
44 #include "gc/shared/gcTimer.hpp"
45 #include "gc/shared/gcTrace.hpp"
46 #include "gc/shared/gcTraceTime.inline.hpp"
1561 "Ergonomically chosen workers(%u) should be less than or equal to active workers(%u)",
1562 ergo_workers, _workers->active_workers());
1563
1564 G1CMRefProcTaskProxy proc_task_proxy(proc_task, _g1h, _cm);
1565
1566 // We need to reset the concurrency level before each
1567 // proxy task execution, so that the termination protocol
1568 // and overflow handling in G1CMTask::do_marking_step() knows
1569 // how many workers to wait for.
1570 _cm->set_concurrency(ergo_workers);
1571 _workers->run_task(&proc_task_proxy, ergo_workers);
1572 }
1573
1574 void G1ConcurrentMark::weak_refs_work(bool clear_all_soft_refs) {
1575 ResourceMark rm;
1576 HandleMark hm;
1577
1578 // Is alive closure.
1579 G1CMIsAliveClosure g1_is_alive(_g1h);
1580
1581 // Inner scope to exclude the cleaning of the string table
1582 // from the displayed time.
1583 {
1584 GCTraceTime(Debug, gc, phases) debug("Reference Processing", _gc_timer_cm);
1585
1586 ReferenceProcessor* rp = _g1h->ref_processor_cm();
1587
1588 // See the comment in G1CollectedHeap::ref_processing_init()
1589 // about how reference processing currently works in G1.
1590
1591 // Set the soft reference policy
1592 rp->setup_policy(clear_all_soft_refs);
1593 assert(_global_mark_stack.is_empty(), "mark stack should be empty");
1594
1595 // Instances of the 'Keep Alive' and 'Complete GC' closures used
1596 // in serial reference processing. Note these closures are also
1597 // used for serially processing (by the the current thread) the
1598 // JNI references during parallel reference processing.
1599 //
1600 // These closures do not need to synchronize with the worker
1601 // threads involved in parallel reference processing as these
1602 // instances are executed serially by the current thread (e.g.
1656 rp->verify_no_references_recorded();
1657 assert(!rp->discovery_enabled(), "Post condition");
1658 }
1659
1660 if (has_overflown()) {
1661 // We can not trust g1_is_alive and the contents of the heap if the marking stack
1662 // overflowed while processing references. Exit the VM.
1663 fatal("Overflow during reference processing, can not continue. Please "
1664 "increase MarkStackSizeMax (current value: " SIZE_FORMAT ") and "
1665 "restart.", MarkStackSizeMax);
1666 return;
1667 }
1668
1669 assert(_global_mark_stack.is_empty(), "Marking should have completed");
1670
1671 {
1672 GCTraceTime(Debug, gc, phases) debug("Weak Processing", _gc_timer_cm);
1673 WeakProcessor::weak_oops_do(&g1_is_alive, &do_nothing_cl);
1674 }
1675
1676 // Unload Klasses, String, Code Cache, etc.
1677 if (ClassUnloadingWithConcurrentMark) {
1678 GCTraceTime(Debug, gc, phases) debug("Class Unloading", _gc_timer_cm);
1679 bool purged_classes = SystemDictionary::do_unloading(_gc_timer_cm, false /* Defer cleaning */);
1680 _g1h->complete_cleaning(&g1_is_alive, purged_classes);
1681 } else {
1682 GCTraceTime(Debug, gc, phases) debug("Cleanup", _gc_timer_cm);
1683 // No need to clean string table as it is treated as strong roots when
1684 // class unloading is disabled.
1685 _g1h->partial_cleaning(&g1_is_alive, false, G1StringDedup::is_enabled());
1686 }
1687 }
1688
1689 class G1PrecleanYieldClosure : public YieldClosure {
1690 G1ConcurrentMark* _cm;
1691
1692 public:
1693 G1PrecleanYieldClosure(G1ConcurrentMark* cm) : _cm(cm) { }
1694
1695 virtual bool should_return() {
1696 return _cm->has_aborted();
1697 }
1698
1699 virtual bool should_return_fine_grain() {
1700 _cm->do_yield_check();
1701 return _cm->has_aborted();
1702 }
1703 };
1704
1705 void G1ConcurrentMark::preclean() {
|