src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.hpp

Thu, 27 May 2010 19:08:38 -0700

author
trims
date
Thu, 27 May 2010 19:08:38 -0700
changeset 1907
c18cbe5936b8
parent 1822
0bfd3fb24150
child 2314
f95d63e2154a
permissions
-rw-r--r--

6941466: Oracle rebranding changes for Hotspot repositories
Summary: Change all the Sun copyrights to Oracle copyright
Reviewed-by: ohair

duke@435 1 /*
trims@1907 2 * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
duke@435 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@435 4 *
duke@435 5 * This code is free software; you can redistribute it and/or modify it
duke@435 6 * under the terms of the GNU General Public License version 2 only, as
duke@435 7 * published by the Free Software Foundation.
duke@435 8 *
duke@435 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@435 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@435 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@435 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@435 13 * accompanied this code).
duke@435 14 *
duke@435 15 * You should have received a copy of the GNU General Public License version
duke@435 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@435 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@435 18 *
trims@1907 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1907 20 * or visit www.oracle.com if you need additional information or have any
trims@1907 21 * questions.
duke@435 22 *
duke@435 23 */
duke@435 24
duke@435 25 class AdjoiningGenerations;
duke@435 26 class GCTaskManager;
duke@435 27 class PSAdaptiveSizePolicy;
jmasa@1822 28 class GenerationSizer;
jmasa@1822 29 class CollectorPolicy;
duke@435 30
duke@435 31 class ParallelScavengeHeap : public CollectedHeap {
duke@435 32 friend class VMStructs;
duke@435 33 private:
duke@435 34 static PSYoungGen* _young_gen;
duke@435 35 static PSOldGen* _old_gen;
duke@435 36 static PSPermGen* _perm_gen;
duke@435 37
duke@435 38 // Sizing policy for entire heap
duke@435 39 static PSAdaptiveSizePolicy* _size_policy;
duke@435 40 static PSGCAdaptivePolicyCounters* _gc_policy_counters;
duke@435 41
duke@435 42 static ParallelScavengeHeap* _psh;
duke@435 43
duke@435 44 size_t _perm_gen_alignment;
duke@435 45 size_t _young_gen_alignment;
duke@435 46 size_t _old_gen_alignment;
duke@435 47
jmasa@1822 48 GenerationSizer* _collector_policy;
jmasa@1822 49
duke@435 50 inline size_t set_alignment(size_t& var, size_t val);
duke@435 51
duke@435 52 // Collection of generations that are adjacent in the
duke@435 53 // space reserved for the heap.
duke@435 54 AdjoiningGenerations* _gens;
duke@435 55
duke@435 56 static GCTaskManager* _gc_task_manager; // The task manager.
duke@435 57
duke@435 58 protected:
duke@435 59 static inline size_t total_invocations();
duke@435 60 HeapWord* allocate_new_tlab(size_t size);
duke@435 61
duke@435 62 public:
duke@435 63 ParallelScavengeHeap() : CollectedHeap() {
jmasa@448 64 set_alignment(_perm_gen_alignment, intra_heap_alignment());
jmasa@448 65 set_alignment(_young_gen_alignment, intra_heap_alignment());
jmasa@448 66 set_alignment(_old_gen_alignment, intra_heap_alignment());
duke@435 67 }
duke@435 68
duke@435 69 // For use by VM operations
duke@435 70 enum CollectionType {
duke@435 71 Scavenge,
duke@435 72 MarkSweep
duke@435 73 };
duke@435 74
duke@435 75 ParallelScavengeHeap::Name kind() const {
duke@435 76 return CollectedHeap::ParallelScavengeHeap;
duke@435 77 }
duke@435 78
jmasa@1822 79 CollectorPolicy* collector_policy() const { return (CollectorPolicy*) _collector_policy; }
jmasa@1822 80 // GenerationSizer* collector_policy() const { return _collector_policy; }
jmasa@1822 81
duke@435 82 static PSYoungGen* young_gen() { return _young_gen; }
duke@435 83 static PSOldGen* old_gen() { return _old_gen; }
duke@435 84 static PSPermGen* perm_gen() { return _perm_gen; }
duke@435 85
duke@435 86 virtual PSAdaptiveSizePolicy* size_policy() { return _size_policy; }
duke@435 87
duke@435 88 static PSGCAdaptivePolicyCounters* gc_policy_counters() { return _gc_policy_counters; }
duke@435 89
duke@435 90 static ParallelScavengeHeap* heap();
duke@435 91
duke@435 92 static GCTaskManager* const gc_task_manager() { return _gc_task_manager; }
duke@435 93
duke@435 94 AdjoiningGenerations* gens() { return _gens; }
duke@435 95
duke@435 96 // Returns JNI_OK on success
duke@435 97 virtual jint initialize();
duke@435 98
duke@435 99 void post_initialize();
duke@435 100 void update_counters();
duke@435 101 // The alignment used for the various generations.
duke@435 102 size_t perm_gen_alignment() const { return _perm_gen_alignment; }
duke@435 103 size_t young_gen_alignment() const { return _young_gen_alignment; }
duke@435 104 size_t old_gen_alignment() const { return _old_gen_alignment; }
duke@435 105
jmasa@448 106 // The alignment used for eden and survivors within the young gen
jmasa@448 107 // and for boundary between young gen and old gen.
jmasa@448 108 size_t intra_heap_alignment() const { return 64 * K; }
duke@435 109
duke@435 110 size_t capacity() const;
duke@435 111 size_t used() const;
duke@435 112
duke@435 113 // Return "true" if all generations (but perm) have reached the
duke@435 114 // maximal committed limit that they can reach, without a garbage
duke@435 115 // collection.
duke@435 116 virtual bool is_maximal_no_gc() const;
duke@435 117
duke@435 118 // Does this heap support heap inspection? (+PrintClassHistogram)
duke@435 119 bool supports_heap_inspection() const { return true; }
duke@435 120
duke@435 121 size_t permanent_capacity() const;
duke@435 122 size_t permanent_used() const;
duke@435 123
duke@435 124 size_t max_capacity() const;
duke@435 125
duke@435 126 // Whether p is in the allocated part of the heap
duke@435 127 bool is_in(const void* p) const;
duke@435 128
duke@435 129 bool is_in_reserved(const void* p) const;
duke@435 130 bool is_in_permanent(const void *p) const { // reserved part
duke@435 131 return perm_gen()->reserved().contains(p);
duke@435 132 }
duke@435 133
duke@435 134 bool is_permanent(const void *p) const { // committed part
duke@435 135 return perm_gen()->is_in(p);
duke@435 136 }
duke@435 137
ysr@1462 138 inline bool is_in_young(oop p); // reserved part
ysr@1462 139 inline bool is_in_old_or_perm(oop p); // reserved part
duke@435 140
duke@435 141 // Memory allocation. "gc_time_limit_was_exceeded" will
duke@435 142 // be set to true if the adaptive size policy determine that
duke@435 143 // an excessive amount of time is being spent doing collections
duke@435 144 // and caused a NULL to be returned. If a NULL is not returned,
duke@435 145 // "gc_time_limit_was_exceeded" has an undefined meaning.
duke@435 146
duke@435 147 HeapWord* mem_allocate(size_t size,
duke@435 148 bool is_noref,
duke@435 149 bool is_tlab,
duke@435 150 bool* gc_overhead_limit_was_exceeded);
duke@435 151 HeapWord* failed_mem_allocate(size_t size, bool is_tlab);
duke@435 152
duke@435 153 HeapWord* permanent_mem_allocate(size_t size);
duke@435 154 HeapWord* failed_permanent_mem_allocate(size_t size);
duke@435 155
duke@435 156 // Support for System.gc()
duke@435 157 void collect(GCCause::Cause cause);
duke@435 158
duke@435 159 // This interface assumes that it's being called by the
duke@435 160 // vm thread. It collects the heap assuming that the
duke@435 161 // heap lock is already held and that we are executing in
duke@435 162 // the context of the vm thread.
duke@435 163 void collect_as_vm_thread(GCCause::Cause cause);
duke@435 164
duke@435 165 // These also should be called by the vm thread at a safepoint (e.g., from a
duke@435 166 // VM operation).
duke@435 167 //
duke@435 168 // The first collects the young generation only, unless the scavenge fails; it
duke@435 169 // will then attempt a full gc. The second collects the entire heap; if
duke@435 170 // maximum_compaction is true, it will compact everything and clear all soft
duke@435 171 // references.
duke@435 172 inline void invoke_scavenge();
duke@435 173 inline void invoke_full_gc(bool maximum_compaction);
duke@435 174
duke@435 175 size_t large_typearray_limit() { return FastAllocateSizeLimit; }
duke@435 176
duke@435 177 bool supports_inline_contig_alloc() const { return !UseNUMA; }
iveresov@576 178
iveresov@576 179 HeapWord** top_addr() const { return !UseNUMA ? young_gen()->top_addr() : (HeapWord**)-1; }
iveresov@576 180 HeapWord** end_addr() const { return !UseNUMA ? young_gen()->end_addr() : (HeapWord**)-1; }
duke@435 181
duke@435 182 void ensure_parsability(bool retire_tlabs);
duke@435 183 void accumulate_statistics_all_tlabs();
duke@435 184 void resize_all_tlabs();
duke@435 185
duke@435 186 size_t unsafe_max_alloc();
duke@435 187
duke@435 188 bool supports_tlab_allocation() const { return true; }
duke@435 189
duke@435 190 size_t tlab_capacity(Thread* thr) const;
duke@435 191 size_t unsafe_max_tlab_alloc(Thread* thr) const;
duke@435 192
ysr@777 193 // Can a compiler initialize a new object without store barriers?
ysr@777 194 // This permission only extends from the creation of a new object
ysr@777 195 // via a TLAB up to the first subsequent safepoint.
ysr@777 196 virtual bool can_elide_tlab_store_barriers() const {
ysr@777 197 return true;
ysr@777 198 }
ysr@777 199
ysr@1601 200 virtual bool card_mark_must_follow_store() const {
ysr@1601 201 return false;
ysr@1601 202 }
ysr@1601 203
ysr@1462 204 // Return true if we don't we need a store barrier for
ysr@1462 205 // initializing stores to an object at this address.
ysr@1462 206 virtual bool can_elide_initializing_store_barrier(oop new_obj);
ysr@1462 207
ysr@777 208 // Can a compiler elide a store barrier when it writes
ysr@777 209 // a permanent oop into the heap? Applies when the compiler
ysr@777 210 // is storing x to the heap, where x->is_perm() is true.
ysr@777 211 virtual bool can_elide_permanent_oop_store_barriers() const {
ysr@777 212 return true;
ysr@777 213 }
ysr@777 214
duke@435 215 void oop_iterate(OopClosure* cl);
duke@435 216 void object_iterate(ObjectClosure* cl);
jmasa@952 217 void safe_object_iterate(ObjectClosure* cl) { object_iterate(cl); }
duke@435 218 void permanent_oop_iterate(OopClosure* cl);
duke@435 219 void permanent_object_iterate(ObjectClosure* cl);
duke@435 220
duke@435 221 HeapWord* block_start(const void* addr) const;
duke@435 222 size_t block_size(const HeapWord* addr) const;
duke@435 223 bool block_is_obj(const HeapWord* addr) const;
duke@435 224
duke@435 225 jlong millis_since_last_gc();
duke@435 226
duke@435 227 void prepare_for_verify();
duke@435 228 void print() const;
duke@435 229 void print_on(outputStream* st) const;
duke@435 230 virtual void print_gc_threads_on(outputStream* st) const;
duke@435 231 virtual void gc_threads_do(ThreadClosure* tc) const;
duke@435 232 virtual void print_tracing_info() const;
duke@435 233
ysr@1280 234 void verify(bool allow_dirty, bool silent, bool /* option */);
duke@435 235
duke@435 236 void print_heap_change(size_t prev_used);
duke@435 237
duke@435 238 // Resize the young generation. The reserved space for the
duke@435 239 // generation may be expanded in preparation for the resize.
duke@435 240 void resize_young_gen(size_t eden_size, size_t survivor_size);
duke@435 241
duke@435 242 // Resize the old generation. The reserved space for the
duke@435 243 // generation may be expanded in preparation for the resize.
duke@435 244 void resize_old_gen(size_t desired_free_space);
jmasa@698 245
jmasa@698 246 // Save the tops of the spaces in all generations
jmasa@698 247 void record_gen_tops_before_GC() PRODUCT_RETURN;
jmasa@698 248
jmasa@698 249 // Mangle the unused parts of all spaces in the heap
jmasa@698 250 void gen_mangle_unused_area() PRODUCT_RETURN;
jrose@1424 251
jrose@1424 252 // Call these in sequential code around the processing of strong roots.
jrose@1424 253 class ParStrongRootsScope : public MarkingCodeBlobClosure::MarkScope {
jrose@1424 254 public:
jrose@1424 255 ParStrongRootsScope();
jrose@1424 256 ~ParStrongRootsScope();
jrose@1424 257 };
duke@435 258 };
duke@435 259
duke@435 260 inline size_t ParallelScavengeHeap::set_alignment(size_t& var, size_t val)
duke@435 261 {
duke@435 262 assert(is_power_of_2((intptr_t)val), "must be a power of 2");
jmasa@448 263 var = round_to(val, intra_heap_alignment());
duke@435 264 return var;
duke@435 265 }

mercurial