comparison src/share/vm/gc_interface/collectedHeap.hpp @ 4872:aa3d708d67c4

7141200: log some interesting information in ring buffers for crashes Reviewed-by: kvn, jrose, kevinw, brutisso, twisti, jmasa
author never
date Wed, 01 Feb 2012 07:59:01 -0800
parents 441e946dc1af
children cc74fa5a91a9
comparison
equal deleted inserted replaced
4871:f067b4e0e04b 4872:aa3d708d67c4
1 /* 1 /*
2 * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 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 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
29 #include "memory/allocation.hpp" 29 #include "memory/allocation.hpp"
30 #include "memory/barrierSet.hpp" 30 #include "memory/barrierSet.hpp"
31 #include "runtime/handles.hpp" 31 #include "runtime/handles.hpp"
32 #include "runtime/perfData.hpp" 32 #include "runtime/perfData.hpp"
33 #include "runtime/safepoint.hpp" 33 #include "runtime/safepoint.hpp"
34 #include "utilities/events.hpp"
34 35
35 // A "CollectedHeap" is an implementation of a java heap for HotSpot. This 36 // 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 // 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 // class defines the functions that a heap must implement, and contains
38 // infrastructure common to all heaps. 39 // infrastructure common to all heaps.
40 class BarrierSet; 41 class BarrierSet;
41 class ThreadClosure; 42 class ThreadClosure;
42 class AdaptiveSizePolicy; 43 class AdaptiveSizePolicy;
43 class Thread; 44 class Thread;
44 class CollectorPolicy; 45 class CollectorPolicy;
46
47 class GCMessage : public FormatBuffer<1024> {
48 public:
49 bool is_before;
50
51 public:
52 GCMessage() {}
53 };
54
55 class GCHeapLog : public EventLogBase<GCMessage> {
56 private:
57 void log_heap(bool before);
58
59 public:
60 GCHeapLog() : EventLogBase<GCMessage>("GC Heap History") {}
61
62 void log_heap_before() {
63 log_heap(true);
64 }
65 void log_heap_after() {
66 log_heap(false);
67 }
68 };
45 69
46 // 70 //
47 // CollectedHeap 71 // CollectedHeap
48 // SharedHeap 72 // SharedHeap
49 // GenCollectedHeap 73 // GenCollectedHeap
59 static int _fire_out_of_memory_count; 83 static int _fire_out_of_memory_count;
60 #endif 84 #endif
61 85
62 // Used for filler objects (static, but initialized in ctor). 86 // Used for filler objects (static, but initialized in ctor).
63 static size_t _filler_array_max_size; 87 static size_t _filler_array_max_size;
88
89 GCHeapLog* _gc_heap_log;
64 90
65 // Used in support of ReduceInitialCardMarks; only consulted if COMPILER2 is being used 91 // Used in support of ReduceInitialCardMarks; only consulted if COMPILER2 is being used
66 bool _defer_initial_card_mark; 92 bool _defer_initial_card_mark;
67 93
68 protected: 94 protected:
616 642
617 // Print any relevant tracing info that flags imply. 643 // Print any relevant tracing info that flags imply.
618 // Default implementation does nothing. 644 // Default implementation does nothing.
619 virtual void print_tracing_info() const = 0; 645 virtual void print_tracing_info() const = 0;
620 646
647 // If PrintHeapAtGC is set call the appropriate routi
648 void print_heap_before_gc() {
649 if (PrintHeapAtGC) {
650 Universe::print_heap_before_gc();
651 }
652 if (_gc_heap_log != NULL) {
653 _gc_heap_log->log_heap_before();
654 }
655 }
656 void print_heap_after_gc() {
657 if (PrintHeapAtGC) {
658 Universe::print_heap_after_gc();
659 }
660 if (_gc_heap_log != NULL) {
661 _gc_heap_log->log_heap_after();
662 }
663 }
664
665 // Allocate GCHeapLog during VM startup
666 static void initialize_heap_log();
667
621 // Heap verification 668 // Heap verification
622 virtual void verify(bool allow_dirty, bool silent, VerifyOption option) = 0; 669 virtual void verify(bool allow_dirty, bool silent, VerifyOption option) = 0;
623 670
624 // Non product verification and debugging. 671 // Non product verification and debugging.
625 #ifndef PRODUCT 672 #ifndef PRODUCT