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 *
23 */
24
25 #ifndef SHARE_VM_GC_INTERFACE_COLLECTEDHEAP_HPP
26 #define SHARE_VM_GC_INTERFACE_COLLECTEDHEAP_HPP
27
28 #include "gc_interface/gcCause.hpp"
29 #include "gc_implementation/shared/gcWhen.hpp"
30 #include "memory/allocation.hpp"
31 #include "runtime/handles.hpp"
32 #include "runtime/perfData.hpp"
33 #include "runtime/safepoint.hpp"
34 #include "utilities/events.hpp"
35
36 // A "CollectedHeap" is an implementation of a java heap for HotSpot. This
37 // is an abstract class: there may be many different kinds of heaps. This
38 // class defines the functions that a heap must implement, and contains
39 // infrastructure common to all heaps.
40
41 class AdaptiveSizePolicy;
42 class BarrierSet;
43 class CollectorPolicy;
44 class GCHeapSummary;
45 class GCTimer;
46 class GCTracer;
47 class MetaspaceSummary;
48 class Thread;
49 class ThreadClosure;
619
620 class GCCauseSetter : StackObj {
621 CollectedHeap* _heap;
622 GCCause::Cause _previous_cause;
623 public:
624 GCCauseSetter(CollectedHeap* heap, GCCause::Cause cause) {
625 assert(SafepointSynchronize::is_at_safepoint(),
626 "This method manipulates heap state without locking");
627 _heap = heap;
628 _previous_cause = _heap->gc_cause();
629 _heap->set_gc_cause(cause);
630 }
631
632 ~GCCauseSetter() {
633 assert(SafepointSynchronize::is_at_safepoint(),
634 "This method manipulates heap state without locking");
635 _heap->set_gc_cause(_previous_cause);
636 }
637 };
638
639 #endif // SHARE_VM_GC_INTERFACE_COLLECTEDHEAP_HPP
|
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 *
23 */
24
25 #ifndef SHARE_VM_GC_SHARED_COLLECTEDHEAP_HPP
26 #define SHARE_VM_GC_SHARED_COLLECTEDHEAP_HPP
27
28 #include "gc/shared/gcCause.hpp"
29 #include "gc/shared/gcWhen.hpp"
30 #include "memory/allocation.hpp"
31 #include "runtime/handles.hpp"
32 #include "runtime/perfData.hpp"
33 #include "runtime/safepoint.hpp"
34 #include "utilities/events.hpp"
35
36 // A "CollectedHeap" is an implementation of a java heap for HotSpot. This
37 // is an abstract class: there may be many different kinds of heaps. This
38 // class defines the functions that a heap must implement, and contains
39 // infrastructure common to all heaps.
40
41 class AdaptiveSizePolicy;
42 class BarrierSet;
43 class CollectorPolicy;
44 class GCHeapSummary;
45 class GCTimer;
46 class GCTracer;
47 class MetaspaceSummary;
48 class Thread;
49 class ThreadClosure;
619
620 class GCCauseSetter : StackObj {
621 CollectedHeap* _heap;
622 GCCause::Cause _previous_cause;
623 public:
624 GCCauseSetter(CollectedHeap* heap, GCCause::Cause cause) {
625 assert(SafepointSynchronize::is_at_safepoint(),
626 "This method manipulates heap state without locking");
627 _heap = heap;
628 _previous_cause = _heap->gc_cause();
629 _heap->set_gc_cause(cause);
630 }
631
632 ~GCCauseSetter() {
633 assert(SafepointSynchronize::is_at_safepoint(),
634 "This method manipulates heap state without locking");
635 _heap->set_gc_cause(_previous_cause);
636 }
637 };
638
639 #endif // SHARE_VM_GC_SHARED_COLLECTEDHEAP_HPP
|