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 // A "CollectedHeap" is an implementation of a java heap for HotSpot. This 26 // is an abstract class: there may be many different kinds of heaps. This 27 // class defines the functions that a heap must implement, and contains 28 // infrastructure common to all heaps. 29 30 class BarrierSet; 31 class ThreadClosure; 32 class AdaptiveSizePolicy; 33 class Thread; 34 class CollectorPolicy; 35 36 // 37 // CollectedHeap 38 // SharedHeap 39 // GenCollectedHeap 40 // G1CollectedHeap 41 // ParallelScavengeHeap 42 // 43 class CollectedHeap : public CHeapObj { 44 friend class VMStructs; 611 // Class to set and reset the GC cause for a CollectedHeap. 612 613 class GCCauseSetter : StackObj { 614 CollectedHeap* _heap; 615 GCCause::Cause _previous_cause; 616 public: 617 GCCauseSetter(CollectedHeap* heap, GCCause::Cause cause) { 618 assert(SafepointSynchronize::is_at_safepoint(), 619 "This method manipulates heap state without locking"); 620 _heap = heap; 621 _previous_cause = _heap->gc_cause(); 622 _heap->set_gc_cause(cause); 623 } 624 625 ~GCCauseSetter() { 626 assert(SafepointSynchronize::is_at_safepoint(), 627 "This method manipulates heap state without locking"); 628 _heap->set_gc_cause(_previous_cause); 629 } 630 }; | 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 "memory/allocation.hpp" 30 #include "memory/barrierSet.hpp" 31 #include "runtime/handles.hpp" 32 #include "runtime/perfData.hpp" 33 #include "runtime/safepoint.hpp" 34 35 // A "CollectedHeap" is an implementation of a java heap for HotSpot. This 36 // is an abstract class: there may be many different kinds of heaps. This 37 // class defines the functions that a heap must implement, and contains 38 // infrastructure common to all heaps. 39 40 class BarrierSet; 41 class ThreadClosure; 42 class AdaptiveSizePolicy; 43 class Thread; 44 class CollectorPolicy; 45 46 // 47 // CollectedHeap 48 // SharedHeap 49 // GenCollectedHeap 50 // G1CollectedHeap 51 // ParallelScavengeHeap 52 // 53 class CollectedHeap : public CHeapObj { 54 friend class VMStructs; 621 // Class to set and reset the GC cause for a CollectedHeap. 622 623 class GCCauseSetter : StackObj { 624 CollectedHeap* _heap; 625 GCCause::Cause _previous_cause; 626 public: 627 GCCauseSetter(CollectedHeap* heap, GCCause::Cause cause) { 628 assert(SafepointSynchronize::is_at_safepoint(), 629 "This method manipulates heap state without locking"); 630 _heap = heap; 631 _previous_cause = _heap->gc_cause(); 632 _heap->set_gc_cause(cause); 633 } 634 635 ~GCCauseSetter() { 636 assert(SafepointSynchronize::is_at_safepoint(), 637 "This method manipulates heap state without locking"); 638 _heap->set_gc_cause(_previous_cause); 639 } 640 }; 641 642 #endif // SHARE_VM_GC_INTERFACE_COLLECTEDHEAP_HPP |