1 /*
2 * Copyright (c) 2001, 2015, 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 *
81 // activity. For example when the heap space is tight and full measure
82 // are being taken to free space.
83
84 void PSMarkSweep::invoke(bool maximum_heap_compaction) {
85 assert(SafepointSynchronize::is_at_safepoint(), "should be at safepoint");
86 assert(Thread::current() == (Thread*)VMThread::vm_thread(), "should be in vm thread");
87 assert(!ParallelScavengeHeap::heap()->is_gc_active(), "not reentrant");
88
89 ParallelScavengeHeap* heap = ParallelScavengeHeap::heap();
90 GCCause::Cause gc_cause = heap->gc_cause();
91 PSAdaptiveSizePolicy* policy = heap->size_policy();
92 IsGCActiveMark mark;
93
94 if (ScavengeBeforeFullGC) {
95 PSScavenge::invoke_no_policy();
96 }
97
98 const bool clear_all_soft_refs =
99 heap->collector_policy()->should_clear_all_soft_refs();
100
101 uint count = maximum_heap_compaction ? 1 : MarkSweepAlwaysCompactCount;
102 UIntXFlagSetting flag_setting(MarkSweepAlwaysCompactCount, count);
103 PSMarkSweep::invoke_no_policy(clear_all_soft_refs || maximum_heap_compaction);
104 }
105
106 // This method contains no policy. You should probably
107 // be calling invoke() instead.
108 bool PSMarkSweep::invoke_no_policy(bool clear_all_softrefs) {
109 assert(SafepointSynchronize::is_at_safepoint(), "must be at a safepoint");
110 assert(ref_processor() != NULL, "Sanity");
111
112 if (GCLocker::check_active_before_gc()) {
113 return false;
114 }
115
116 ParallelScavengeHeap* heap = ParallelScavengeHeap::heap();
117 GCCause::Cause gc_cause = heap->gc_cause();
118
119 GCIdMark gc_id_mark;
120 _gc_timer->register_gc_start();
121 _gc_tracer->report_gc_start(gc_cause, _gc_timer->gc_start());
|
1 /*
2 * Copyright (c) 2001, 2016, 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 *
81 // activity. For example when the heap space is tight and full measure
82 // are being taken to free space.
83
84 void PSMarkSweep::invoke(bool maximum_heap_compaction) {
85 assert(SafepointSynchronize::is_at_safepoint(), "should be at safepoint");
86 assert(Thread::current() == (Thread*)VMThread::vm_thread(), "should be in vm thread");
87 assert(!ParallelScavengeHeap::heap()->is_gc_active(), "not reentrant");
88
89 ParallelScavengeHeap* heap = ParallelScavengeHeap::heap();
90 GCCause::Cause gc_cause = heap->gc_cause();
91 PSAdaptiveSizePolicy* policy = heap->size_policy();
92 IsGCActiveMark mark;
93
94 if (ScavengeBeforeFullGC) {
95 PSScavenge::invoke_no_policy();
96 }
97
98 const bool clear_all_soft_refs =
99 heap->collector_policy()->should_clear_all_soft_refs();
100
101 uintx count = maximum_heap_compaction ? 1 : MarkSweepAlwaysCompactCount;
102 UIntXFlagSetting flag_setting(MarkSweepAlwaysCompactCount, count);
103 PSMarkSweep::invoke_no_policy(clear_all_soft_refs || maximum_heap_compaction);
104 }
105
106 // This method contains no policy. You should probably
107 // be calling invoke() instead.
108 bool PSMarkSweep::invoke_no_policy(bool clear_all_softrefs) {
109 assert(SafepointSynchronize::is_at_safepoint(), "must be at a safepoint");
110 assert(ref_processor() != NULL, "Sanity");
111
112 if (GCLocker::check_active_before_gc()) {
113 return false;
114 }
115
116 ParallelScavengeHeap* heap = ParallelScavengeHeap::heap();
117 GCCause::Cause gc_cause = heap->gc_cause();
118
119 GCIdMark gc_id_mark;
120 _gc_timer->register_gc_start();
121 _gc_tracer->report_gc_start(gc_cause, _gc_timer->gc_start());
|