1 /*
2 * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
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 *
55 #include "runtime/biasedLocking.hpp"
56 #include "runtime/flags/flagSetting.hpp"
57 #include "runtime/handles.inline.hpp"
58 #include "runtime/safepoint.hpp"
59 #include "runtime/vmThread.hpp"
60 #include "services/management.hpp"
61 #include "services/memoryService.hpp"
62 #include "utilities/align.hpp"
63 #include "utilities/events.hpp"
64 #include "utilities/stack.inline.hpp"
65
66 elapsedTimer PSMarkSweep::_accumulated_time;
67 jlong PSMarkSweep::_time_of_last_gc = 0;
68 CollectorCounters* PSMarkSweep::_counters = NULL;
69
70 SpanSubjectToDiscoveryClosure PSMarkSweep::_span_based_discoverer;
71
72 void PSMarkSweep::initialize() {
73 _span_based_discoverer.set_span(ParallelScavengeHeap::heap()->reserved_region());
74 set_ref_processor(new ReferenceProcessor(&_span_based_discoverer)); // a vanilla ref proc
75 _counters = new CollectorCounters("PSMarkSweep", 1);
76 MarkSweep::initialize();
77 }
78
79 // This method contains all heap specific policy for invoking mark sweep.
80 // PSMarkSweep::invoke_no_policy() will only attempt to mark-sweep-compact
81 // the heap. It will do nothing further. If we need to bail out for policy
82 // reasons, scavenge before full gc, or any other specialized behavior, it
83 // needs to be added here.
84 //
85 // Note that this method should only be called from the vm_thread while
86 // at a safepoint!
87 //
88 // Note that the all_soft_refs_clear flag in the collector policy
89 // may be true because this method can be called without intervening
90 // activity. For example when the heap space is tight and full measure
91 // are being taken to free space.
92
93 void PSMarkSweep::invoke(bool maximum_heap_compaction) {
94 assert(SafepointSynchronize::is_at_safepoint(), "should be at safepoint");
95 assert(Thread::current() == (Thread*)VMThread::vm_thread(), "should be in vm thread");
|
1 /*
2 * Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
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 *
55 #include "runtime/biasedLocking.hpp"
56 #include "runtime/flags/flagSetting.hpp"
57 #include "runtime/handles.inline.hpp"
58 #include "runtime/safepoint.hpp"
59 #include "runtime/vmThread.hpp"
60 #include "services/management.hpp"
61 #include "services/memoryService.hpp"
62 #include "utilities/align.hpp"
63 #include "utilities/events.hpp"
64 #include "utilities/stack.inline.hpp"
65
66 elapsedTimer PSMarkSweep::_accumulated_time;
67 jlong PSMarkSweep::_time_of_last_gc = 0;
68 CollectorCounters* PSMarkSweep::_counters = NULL;
69
70 SpanSubjectToDiscoveryClosure PSMarkSweep::_span_based_discoverer;
71
72 void PSMarkSweep::initialize() {
73 _span_based_discoverer.set_span(ParallelScavengeHeap::heap()->reserved_region());
74 set_ref_processor(new ReferenceProcessor(&_span_based_discoverer)); // a vanilla ref proc
75 _counters = new CollectorCounters("Serial full collection pauses", 1);
76 MarkSweep::initialize();
77 }
78
79 // This method contains all heap specific policy for invoking mark sweep.
80 // PSMarkSweep::invoke_no_policy() will only attempt to mark-sweep-compact
81 // the heap. It will do nothing further. If we need to bail out for policy
82 // reasons, scavenge before full gc, or any other specialized behavior, it
83 // needs to be added here.
84 //
85 // Note that this method should only be called from the vm_thread while
86 // at a safepoint!
87 //
88 // Note that the all_soft_refs_clear flag in the collector policy
89 // may be true because this method can be called without intervening
90 // activity. For example when the heap space is tight and full measure
91 // are being taken to free space.
92
93 void PSMarkSweep::invoke(bool maximum_heap_compaction) {
94 assert(SafepointSynchronize::is_at_safepoint(), "should be at safepoint");
95 assert(Thread::current() == (Thread*)VMThread::vm_thread(), "should be in vm thread");
|