Mercurial > hg > graal-compiler
comparison src/share/vm/gc_interface/collectedHeap.hpp @ 4970:33df1aeaebbf
Merge with http://hg.openjdk.java.net/hsx/hsx24/hotspot/
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Mon, 27 Feb 2012 13:10:13 +0100 |
parents | aa3d708d67c4 |
children | cc74fa5a91a9 |
comparison
equal
deleted
inserted
replaced
4703:2cfb7fb2dce7 | 4970:33df1aeaebbf |
---|---|
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 |
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; |
64 | 88 |
89 GCHeapLog* _gc_heap_log; | |
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: |
69 MemRegion _reserved; | 95 MemRegion _reserved; |
70 BarrierSet* _barrier_set; | 96 BarrierSet* _barrier_set; |
71 bool _is_gc_active; | 97 bool _is_gc_active; |
72 int _n_par_threads; | 98 uint _n_par_threads; |
73 | 99 |
74 unsigned int _total_collections; // ... started | 100 unsigned int _total_collections; // ... started |
75 unsigned int _total_full_collections; // ... started | 101 unsigned int _total_full_collections; // ... started |
76 NOT_PRODUCT(volatile size_t _promotion_failure_alot_count;) | 102 NOT_PRODUCT(volatile size_t _promotion_failure_alot_count;) |
77 NOT_PRODUCT(volatile size_t _promotion_failure_alot_gc_number;) | 103 NOT_PRODUCT(volatile size_t _promotion_failure_alot_gc_number;) |
215 | 241 |
216 bool is_in_reserved_or_null(const void* p) const { | 242 bool is_in_reserved_or_null(const void* p) const { |
217 return p == NULL || is_in_reserved(p); | 243 return p == NULL || is_in_reserved(p); |
218 } | 244 } |
219 | 245 |
220 // Returns "TRUE" if "p" points to the head of an allocated object in the | 246 // Returns "TRUE" iff "p" points into the committed areas of the heap. |
221 // heap. Since this method can be expensive in general, we restrict its | 247 // Since this method can be expensive in general, we restrict its |
222 // use to assertion checking only. | 248 // use to assertion checking only. |
223 virtual bool is_in(const void* p) const = 0; | 249 virtual bool is_in(const void* p) const = 0; |
224 | 250 |
225 bool is_in_or_null(const void* p) const { | 251 bool is_in_or_null(const void* p) const { |
226 return p == NULL || is_in(p); | 252 return p == NULL || is_in(p); |
307 _gc_cause = v; | 333 _gc_cause = v; |
308 } | 334 } |
309 GCCause::Cause gc_cause() { return _gc_cause; } | 335 GCCause::Cause gc_cause() { return _gc_cause; } |
310 | 336 |
311 // Number of threads currently working on GC tasks. | 337 // Number of threads currently working on GC tasks. |
312 int n_par_threads() { return _n_par_threads; } | 338 uint n_par_threads() { return _n_par_threads; } |
313 | 339 |
314 // May be overridden to set additional parallelism. | 340 // May be overridden to set additional parallelism. |
315 virtual void set_par_threads(int t) { _n_par_threads = t; }; | 341 virtual void set_par_threads(uint t) { _n_par_threads = t; }; |
316 | 342 |
317 // Preload classes into the shared portion of the heap, and then dump | 343 // Preload classes into the shared portion of the heap, and then dump |
318 // that data to a file so that it can be loaded directly by another | 344 // that data to a file so that it can be loaded directly by another |
319 // VM (then terminate). | 345 // VM (then terminate). |
320 virtual void preload_and_dump(TRAPS) { ShouldNotReachHere(); } | 346 virtual void preload_and_dump(TRAPS) { ShouldNotReachHere(); } |
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 |
646 // the actual number of GC worker threads is not pertinent but | 693 // the actual number of GC worker threads is not pertinent but |
647 // only whether there more than 0. Use of this method helps | 694 // only whether there more than 0. Use of this method helps |
648 // reduce the occurrence of ParallelGCThreads to uses where the | 695 // reduce the occurrence of ParallelGCThreads to uses where the |
649 // actual number may be germane. | 696 // actual number may be germane. |
650 static bool use_parallel_gc_threads() { return ParallelGCThreads > 0; } | 697 static bool use_parallel_gc_threads() { return ParallelGCThreads > 0; } |
698 | |
699 /////////////// Unit tests /////////////// | |
700 | |
701 NOT_PRODUCT(static void test_is_in();) | |
651 }; | 702 }; |
652 | 703 |
653 // Class to set and reset the GC cause for a CollectedHeap. | 704 // Class to set and reset the GC cause for a CollectedHeap. |
654 | 705 |
655 class GCCauseSetter : StackObj { | 706 class GCCauseSetter : StackObj { |