src/share/vm/gc_interface/collectedHeap.hpp

changeset 3499
aa3d708d67c4
parent 3357
441e946dc1af
child 3668
cc74fa5a91a9
     1.1 --- a/src/share/vm/gc_interface/collectedHeap.hpp	Wed Feb 01 10:36:58 2012 +0100
     1.2 +++ b/src/share/vm/gc_interface/collectedHeap.hpp	Wed Feb 01 07:59:01 2012 -0800
     1.3 @@ -1,5 +1,5 @@
     1.4  /*
     1.5 - * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
     1.6 + * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
     1.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.8   *
     1.9   * This code is free software; you can redistribute it and/or modify it
    1.10 @@ -31,6 +31,7 @@
    1.11  #include "runtime/handles.hpp"
    1.12  #include "runtime/perfData.hpp"
    1.13  #include "runtime/safepoint.hpp"
    1.14 +#include "utilities/events.hpp"
    1.15  
    1.16  // A "CollectedHeap" is an implementation of a java heap for HotSpot.  This
    1.17  // is an abstract class: there may be many different kinds of heaps.  This
    1.18 @@ -43,6 +44,29 @@
    1.19  class Thread;
    1.20  class CollectorPolicy;
    1.21  
    1.22 +class GCMessage : public FormatBuffer<1024> {
    1.23 + public:
    1.24 +  bool is_before;
    1.25 +
    1.26 + public:
    1.27 +  GCMessage() {}
    1.28 +};
    1.29 +
    1.30 +class GCHeapLog : public EventLogBase<GCMessage> {
    1.31 + private:
    1.32 +  void log_heap(bool before);
    1.33 +
    1.34 + public:
    1.35 +  GCHeapLog() : EventLogBase<GCMessage>("GC Heap History") {}
    1.36 +
    1.37 +  void log_heap_before() {
    1.38 +    log_heap(true);
    1.39 +  }
    1.40 +  void log_heap_after() {
    1.41 +    log_heap(false);
    1.42 +  }
    1.43 +};
    1.44 +
    1.45  //
    1.46  // CollectedHeap
    1.47  //   SharedHeap
    1.48 @@ -62,6 +86,8 @@
    1.49    // Used for filler objects (static, but initialized in ctor).
    1.50    static size_t _filler_array_max_size;
    1.51  
    1.52 +  GCHeapLog* _gc_heap_log;
    1.53 +
    1.54    // Used in support of ReduceInitialCardMarks; only consulted if COMPILER2 is being used
    1.55    bool _defer_initial_card_mark;
    1.56  
    1.57 @@ -618,6 +644,27 @@
    1.58    // Default implementation does nothing.
    1.59    virtual void print_tracing_info() const = 0;
    1.60  
    1.61 +  // If PrintHeapAtGC is set call the appropriate routi
    1.62 +  void print_heap_before_gc() {
    1.63 +    if (PrintHeapAtGC) {
    1.64 +      Universe::print_heap_before_gc();
    1.65 +    }
    1.66 +    if (_gc_heap_log != NULL) {
    1.67 +      _gc_heap_log->log_heap_before();
    1.68 +    }
    1.69 +  }
    1.70 +  void print_heap_after_gc() {
    1.71 +    if (PrintHeapAtGC) {
    1.72 +      Universe::print_heap_after_gc();
    1.73 +    }
    1.74 +    if (_gc_heap_log != NULL) {
    1.75 +      _gc_heap_log->log_heap_after();
    1.76 +    }
    1.77 +  }
    1.78 +
    1.79 +  // Allocate GCHeapLog during VM startup
    1.80 +  static void initialize_heap_log();
    1.81 +
    1.82    // Heap verification
    1.83    virtual void verify(bool allow_dirty, bool silent, VerifyOption option) = 0;
    1.84  

mercurial