comparison src/share/vm/gc_interface/collectedHeap.hpp @ 10405:f2110083203d

8005849: JEP 167: Event-Based JVM Tracing Reviewed-by: acorn, coleenp, sla Contributed-by: Karen Kinnear <karen.kinnear@oracle.com>, Bengt Rutisson <bengt.rutisson@oracle.com>, Calvin Cheung <calvin.cheung@oracle.com>, Erik Gahlin <erik.gahlin@oracle.com>, Erik Helin <erik.helin@oracle.com>, Jesper Wilhelmsson <jesper.wilhelmsson@oracle.com>, Keith McGuigan <keith.mcguigan@oracle.com>, Mattias Tobiasson <mattias.tobiasson@oracle.com>, Markus Gronlund <markus.gronlund@oracle.com>, Mikael Auno <mikael.auno@oracle.com>, Nils Eliasson <nils.eliasson@oracle.com>, Nils Loodin <nils.loodin@oracle.com>, Rickard Backman <rickard.backman@oracle.com>, Staffan Larsen <staffan.larsen@oracle.com>, Stefan Karlsson <stefan.karlsson@oracle.com>, Yekaterina Kantserova <yekaterina.kantserova@oracle.com>
author sla
date Mon, 10 Jun 2013 11:30:51 +0200
parents 7b835924c31c
children 836a62f43af9 5888334c9c24
comparison
equal deleted inserted replaced
10404:d0add7016434 10405:f2110083203d
1 /* 1 /*
2 * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 2001, 2013, 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.
24 24
25 #ifndef SHARE_VM_GC_INTERFACE_COLLECTEDHEAP_HPP 25 #ifndef SHARE_VM_GC_INTERFACE_COLLECTEDHEAP_HPP
26 #define SHARE_VM_GC_INTERFACE_COLLECTEDHEAP_HPP 26 #define SHARE_VM_GC_INTERFACE_COLLECTEDHEAP_HPP
27 27
28 #include "gc_interface/gcCause.hpp" 28 #include "gc_interface/gcCause.hpp"
29 #include "gc_implementation/shared/gcWhen.hpp"
29 #include "memory/allocation.hpp" 30 #include "memory/allocation.hpp"
30 #include "memory/barrierSet.hpp" 31 #include "memory/barrierSet.hpp"
31 #include "runtime/handles.hpp" 32 #include "runtime/handles.hpp"
32 #include "runtime/perfData.hpp" 33 #include "runtime/perfData.hpp"
33 #include "runtime/safepoint.hpp" 34 #include "runtime/safepoint.hpp"
36 // A "CollectedHeap" is an implementation of a java heap for HotSpot. This 37 // 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 // 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 // class defines the functions that a heap must implement, and contains
39 // infrastructure common to all heaps. 40 // infrastructure common to all heaps.
40 41
42 class AdaptiveSizePolicy;
41 class BarrierSet; 43 class BarrierSet;
44 class CollectorPolicy;
45 class GCHeapSummary;
46 class GCTimer;
47 class GCTracer;
48 class MetaspaceSummary;
49 class Thread;
42 class ThreadClosure; 50 class ThreadClosure;
43 class AdaptiveSizePolicy; 51 class VirtualSpaceSummary;
44 class Thread;
45 class CollectorPolicy;
46 52
47 class GCMessage : public FormatBuffer<1024> { 53 class GCMessage : public FormatBuffer<1024> {
48 public: 54 public:
49 bool is_before; 55 bool is_before;
50 56
126 132
127 // Reinitialize tlabs before resuming mutators. 133 // Reinitialize tlabs before resuming mutators.
128 virtual void resize_all_tlabs(); 134 virtual void resize_all_tlabs();
129 135
130 // Allocate from the current thread's TLAB, with broken-out slow path. 136 // Allocate from the current thread's TLAB, with broken-out slow path.
131 inline static HeapWord* allocate_from_tlab(Thread* thread, size_t size); 137 inline static HeapWord* allocate_from_tlab(KlassHandle klass, Thread* thread, size_t size);
132 static HeapWord* allocate_from_tlab_slow(Thread* thread, size_t size); 138 static HeapWord* allocate_from_tlab_slow(KlassHandle klass, Thread* thread, size_t size);
133 139
134 // Allocate an uninitialized block of the given size, or returns NULL if 140 // Allocate an uninitialized block of the given size, or returns NULL if
135 // this is impossible. 141 // this is impossible.
136 inline static HeapWord* common_mem_allocate_noinit(size_t size, TRAPS); 142 inline static HeapWord* common_mem_allocate_noinit(KlassHandle klass, size_t size, TRAPS);
137 143
138 // Like allocate_init, but the block returned by a successful allocation 144 // Like allocate_init, but the block returned by a successful allocation
139 // is guaranteed initialized to zeros. 145 // is guaranteed initialized to zeros.
140 inline static HeapWord* common_mem_allocate_init(size_t size, TRAPS); 146 inline static HeapWord* common_mem_allocate_init(KlassHandle klass, size_t size, TRAPS);
141 147
142 // Helper functions for (VM) allocation. 148 // Helper functions for (VM) allocation.
143 inline static void post_allocation_setup_common(KlassHandle klass, HeapWord* obj); 149 inline static void post_allocation_setup_common(KlassHandle klass, HeapWord* obj);
144 inline static void post_allocation_setup_no_klass_install(KlassHandle klass, 150 inline static void post_allocation_setup_no_klass_install(KlassHandle klass,
145 HeapWord* objPtr); 151 HeapWord* objPtr);
163 // words <= filler_array_max_size(). 169 // words <= filler_array_max_size().
164 static inline void fill_with_array(HeapWord* start, size_t words, bool zap = true); 170 static inline void fill_with_array(HeapWord* start, size_t words, bool zap = true);
165 171
166 // Fill with a single object (either an int array or a java.lang.Object). 172 // Fill with a single object (either an int array or a java.lang.Object).
167 static inline void fill_with_object_impl(HeapWord* start, size_t words, bool zap = true); 173 static inline void fill_with_object_impl(HeapWord* start, size_t words, bool zap = true);
174
175 virtual void trace_heap(GCWhen::Type when, GCTracer* tracer);
168 176
169 // Verification functions 177 // Verification functions
170 virtual void check_for_bad_heap_word_value(HeapWord* addr, size_t size) 178 virtual void check_for_bad_heap_word_value(HeapWord* addr, size_t size)
171 PRODUCT_RETURN; 179 PRODUCT_RETURN;
172 virtual void check_for_non_bad_heap_word_value(HeapWord* addr, size_t size) 180 virtual void check_for_non_bad_heap_word_value(HeapWord* addr, size_t size)
200 virtual void post_initialize() = 0; 208 virtual void post_initialize() = 0;
201 209
202 MemRegion reserved_region() const { return _reserved; } 210 MemRegion reserved_region() const { return _reserved; }
203 address base() const { return (address)reserved_region().start(); } 211 address base() const { return (address)reserved_region().start(); }
204 212
205 // Future cleanup here. The following functions should specify bytes or
206 // heapwords as part of their signature.
207 virtual size_t capacity() const = 0; 213 virtual size_t capacity() const = 0;
208 virtual size_t used() const = 0; 214 virtual size_t used() const = 0;
209 215
210 // Return "true" if the part of the heap that allocates Java 216 // Return "true" if the part of the heap that allocates Java
211 // objects has reached the maximal committed limit that it can 217 // objects has reached the maximal committed limit that it can
548 554
549 // Perform any cleanup actions necessary before allowing a verification. 555 // Perform any cleanup actions necessary before allowing a verification.
550 virtual void prepare_for_verify() = 0; 556 virtual void prepare_for_verify() = 0;
551 557
552 // Generate any dumps preceding or following a full gc 558 // Generate any dumps preceding or following a full gc
553 void pre_full_gc_dump(); 559 void pre_full_gc_dump(GCTimer* timer);
554 void post_full_gc_dump(); 560 void post_full_gc_dump(GCTimer* timer);
561
562 VirtualSpaceSummary create_heap_space_summary();
563 GCHeapSummary create_heap_summary();
564
565 MetaspaceSummary create_metaspace_summary();
555 566
556 // Print heap information on the given outputStream. 567 // Print heap information on the given outputStream.
557 virtual void print_on(outputStream* st) const = 0; 568 virtual void print_on(outputStream* st) const = 0;
558 // The default behavior is to call print_on() on tty. 569 // The default behavior is to call print_on() on tty.
559 virtual void print() const { 570 virtual void print() const {
560 print_on(tty); 571 print_on(tty);
561 } 572 }
562 // Print more detailed heap information on the given 573 // Print more detailed heap information on the given
563 // outputStream. The default behaviour is to call print_on(). It is 574 // outputStream. The default behavior is to call print_on(). It is
564 // up to each subclass to override it and add any additional output 575 // up to each subclass to override it and add any additional output
565 // it needs. 576 // it needs.
566 virtual void print_extended_on(outputStream* st) const { 577 virtual void print_extended_on(outputStream* st) const {
567 print_on(st); 578 print_on(st);
568 } 579 }
587 598
588 // Print any relevant tracing info that flags imply. 599 // Print any relevant tracing info that flags imply.
589 // Default implementation does nothing. 600 // Default implementation does nothing.
590 virtual void print_tracing_info() const = 0; 601 virtual void print_tracing_info() const = 0;
591 602
592 // If PrintHeapAtGC is set call the appropriate routi 603 void print_heap_before_gc();
593 void print_heap_before_gc() { 604 void print_heap_after_gc();
594 if (PrintHeapAtGC) { 605
595 Universe::print_heap_before_gc(); 606 void trace_heap_before_gc(GCTracer* gc_tracer);
596 } 607 void trace_heap_after_gc(GCTracer* gc_tracer);
597 if (_gc_heap_log != NULL) {
598 _gc_heap_log->log_heap_before();
599 }
600 }
601 void print_heap_after_gc() {
602 if (PrintHeapAtGC) {
603 Universe::print_heap_after_gc();
604 }
605 if (_gc_heap_log != NULL) {
606 _gc_heap_log->log_heap_after();
607 }
608 }
609 608
610 // Heap verification 609 // Heap verification
611 virtual void verify(bool silent, VerifyOption option) = 0; 610 virtual void verify(bool silent, VerifyOption option) = 0;
612 611
613 // Non product verification and debugging. 612 // Non product verification and debugging.
617 // this->_promotion_failure_alot_count as the counter. 616 // this->_promotion_failure_alot_count as the counter.
618 inline bool promotion_should_fail(volatile size_t* count); 617 inline bool promotion_should_fail(volatile size_t* count);
619 inline bool promotion_should_fail(); 618 inline bool promotion_should_fail();
620 619
621 // Reset the PromotionFailureALot counters. Should be called at the end of a 620 // Reset the PromotionFailureALot counters. Should be called at the end of a
622 // GC in which promotion failure ocurred. 621 // GC in which promotion failure occurred.
623 inline void reset_promotion_should_fail(volatile size_t* count); 622 inline void reset_promotion_should_fail(volatile size_t* count);
624 inline void reset_promotion_should_fail(); 623 inline void reset_promotion_should_fail();
625 #endif // #ifndef PRODUCT 624 #endif // #ifndef PRODUCT
626 625
627 #ifdef ASSERT 626 #ifdef ASSERT