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; 627 // Class to set and reset the GC cause for a CollectedHeap. 628 629 class GCCauseSetter : StackObj { 630 CollectedHeap* _heap; 631 GCCause::Cause _previous_cause; 632 public: 633 GCCauseSetter(CollectedHeap* heap, GCCause::Cause cause) { 634 assert(SafepointSynchronize::is_at_safepoint(), 635 "This method manipulates heap state without locking"); 636 _heap = heap; 637 _previous_cause = _heap->gc_cause(); 638 _heap->set_gc_cause(cause); 639 } 640 641 ~GCCauseSetter() { 642 assert(SafepointSynchronize::is_at_safepoint(), 643 "This method manipulates heap state without locking"); 644 _heap->set_gc_cause(_previous_cause); 645 } 646 }; | 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; 637 // Class to set and reset the GC cause for a CollectedHeap. 638 639 class GCCauseSetter : StackObj { 640 CollectedHeap* _heap; 641 GCCause::Cause _previous_cause; 642 public: 643 GCCauseSetter(CollectedHeap* heap, GCCause::Cause cause) { 644 assert(SafepointSynchronize::is_at_safepoint(), 645 "This method manipulates heap state without locking"); 646 _heap = heap; 647 _previous_cause = _heap->gc_cause(); 648 _heap->set_gc_cause(cause); 649 } 650 651 ~GCCauseSetter() { 652 assert(SafepointSynchronize::is_at_safepoint(), 653 "This method manipulates heap state without locking"); 654 _heap->set_gc_cause(_previous_cause); 655 } 656 }; 657 658 #endif // SHARE_VM_GC_INTERFACE_COLLECTEDHEAP_HPP |