src/share/vm/memory/genCollectedHeap.hpp

Fri, 29 Apr 2016 00:06:10 +0800

author
aoqi
date
Fri, 29 Apr 2016 00:06:10 +0800
changeset 1
2d8a650513c2
parent 0
f90c822e73f8
child 6876
710a3c8b516e
permissions
-rw-r--r--

Added MIPS 64-bit port.

aoqi@0 1 /*
aoqi@0 2 * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
aoqi@0 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
aoqi@0 4 *
aoqi@0 5 * This code is free software; you can redistribute it and/or modify it
aoqi@0 6 * under the terms of the GNU General Public License version 2 only, as
aoqi@0 7 * published by the Free Software Foundation.
aoqi@0 8 *
aoqi@0 9 * This code is distributed in the hope that it will be useful, but WITHOUT
aoqi@0 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
aoqi@0 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
aoqi@0 12 * version 2 for more details (a copy is included in the LICENSE file that
aoqi@0 13 * accompanied this code).
aoqi@0 14 *
aoqi@0 15 * You should have received a copy of the GNU General Public License version
aoqi@0 16 * 2 along with this work; if not, write to the Free Software Foundation,
aoqi@0 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
aoqi@0 18 *
aoqi@0 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
aoqi@0 20 * or visit www.oracle.com if you need additional information or have any
aoqi@0 21 * questions.
aoqi@0 22 *
aoqi@0 23 */
aoqi@0 24
aoqi@0 25 #ifndef SHARE_VM_MEMORY_GENCOLLECTEDHEAP_HPP
aoqi@0 26 #define SHARE_VM_MEMORY_GENCOLLECTEDHEAP_HPP
aoqi@0 27
aoqi@0 28 #include "gc_implementation/shared/adaptiveSizePolicy.hpp"
aoqi@0 29 #include "memory/collectorPolicy.hpp"
aoqi@0 30 #include "memory/generation.hpp"
aoqi@0 31 #include "memory/sharedHeap.hpp"
aoqi@0 32
aoqi@0 33 class SubTasksDone;
aoqi@0 34
aoqi@0 35 // A "GenCollectedHeap" is a SharedHeap that uses generational
aoqi@0 36 // collection. It is represented with a sequence of Generation's.
aoqi@0 37 class GenCollectedHeap : public SharedHeap {
aoqi@0 38 friend class GenCollectorPolicy;
aoqi@0 39 friend class Generation;
aoqi@0 40 friend class DefNewGeneration;
aoqi@0 41 friend class TenuredGeneration;
aoqi@0 42 friend class ConcurrentMarkSweepGeneration;
aoqi@0 43 friend class CMSCollector;
aoqi@0 44 friend class GenMarkSweep;
aoqi@0 45 friend class VM_GenCollectForAllocation;
aoqi@0 46 friend class VM_GenCollectFull;
aoqi@0 47 friend class VM_GenCollectFullConcurrent;
aoqi@0 48 friend class VM_GC_HeapInspection;
aoqi@0 49 friend class VM_HeapDumper;
aoqi@0 50 friend class HeapInspection;
aoqi@0 51 friend class GCCauseSetter;
aoqi@0 52 friend class VMStructs;
aoqi@0 53 public:
aoqi@0 54 enum SomeConstants {
aoqi@0 55 max_gens = 10
aoqi@0 56 };
aoqi@0 57
aoqi@0 58 friend class VM_PopulateDumpSharedSpace;
aoqi@0 59
aoqi@0 60 protected:
aoqi@0 61 // Fields:
aoqi@0 62 static GenCollectedHeap* _gch;
aoqi@0 63
aoqi@0 64 private:
aoqi@0 65 int _n_gens;
aoqi@0 66 Generation* _gens[max_gens];
aoqi@0 67 GenerationSpec** _gen_specs;
aoqi@0 68
aoqi@0 69 // The generational collector policy.
aoqi@0 70 GenCollectorPolicy* _gen_policy;
aoqi@0 71
aoqi@0 72 // Indicates that the most recent previous incremental collection failed.
aoqi@0 73 // The flag is cleared when an action is taken that might clear the
aoqi@0 74 // condition that caused that incremental collection to fail.
aoqi@0 75 bool _incremental_collection_failed;
aoqi@0 76
aoqi@0 77 // In support of ExplicitGCInvokesConcurrent functionality
aoqi@0 78 unsigned int _full_collections_completed;
aoqi@0 79
aoqi@0 80 // Data structure for claiming the (potentially) parallel tasks in
aoqi@0 81 // (gen-specific) strong roots processing.
aoqi@0 82 SubTasksDone* _gen_process_strong_tasks;
aoqi@0 83 SubTasksDone* gen_process_strong_tasks() { return _gen_process_strong_tasks; }
aoqi@0 84
aoqi@0 85 // In block contents verification, the number of header words to skip
aoqi@0 86 NOT_PRODUCT(static size_t _skip_header_HeapWords;)
aoqi@0 87
aoqi@0 88 protected:
aoqi@0 89 // Helper functions for allocation
aoqi@0 90 HeapWord* attempt_allocation(size_t size,
aoqi@0 91 bool is_tlab,
aoqi@0 92 bool first_only);
aoqi@0 93
aoqi@0 94 // Helper function for two callbacks below.
aoqi@0 95 // Considers collection of the first max_level+1 generations.
aoqi@0 96 void do_collection(bool full,
aoqi@0 97 bool clear_all_soft_refs,
aoqi@0 98 size_t size,
aoqi@0 99 bool is_tlab,
aoqi@0 100 int max_level);
aoqi@0 101
aoqi@0 102 // Callback from VM_GenCollectForAllocation operation.
aoqi@0 103 // This function does everything necessary/possible to satisfy an
aoqi@0 104 // allocation request that failed in the youngest generation that should
aoqi@0 105 // have handled it (including collection, expansion, etc.)
aoqi@0 106 HeapWord* satisfy_failed_allocation(size_t size, bool is_tlab);
aoqi@0 107
aoqi@0 108 // Callback from VM_GenCollectFull operation.
aoqi@0 109 // Perform a full collection of the first max_level+1 generations.
aoqi@0 110 virtual void do_full_collection(bool clear_all_soft_refs);
aoqi@0 111 void do_full_collection(bool clear_all_soft_refs, int max_level);
aoqi@0 112
aoqi@0 113 // Does the "cause" of GC indicate that
aoqi@0 114 // we absolutely __must__ clear soft refs?
aoqi@0 115 bool must_clear_all_soft_refs();
aoqi@0 116
aoqi@0 117 public:
aoqi@0 118 GenCollectedHeap(GenCollectorPolicy *policy);
aoqi@0 119
aoqi@0 120 GCStats* gc_stats(int level) const;
aoqi@0 121
aoqi@0 122 // Returns JNI_OK on success
aoqi@0 123 virtual jint initialize();
aoqi@0 124 char* allocate(size_t alignment,
aoqi@0 125 size_t* _total_reserved, int* _n_covered_regions,
aoqi@0 126 ReservedSpace* heap_rs);
aoqi@0 127
aoqi@0 128 // Does operations required after initialization has been done.
aoqi@0 129 void post_initialize();
aoqi@0 130
aoqi@0 131 // Initialize ("weak") refs processing support
aoqi@0 132 virtual void ref_processing_init();
aoqi@0 133
aoqi@0 134 virtual CollectedHeap::Name kind() const {
aoqi@0 135 return CollectedHeap::GenCollectedHeap;
aoqi@0 136 }
aoqi@0 137
aoqi@0 138 // The generational collector policy.
aoqi@0 139 GenCollectorPolicy* gen_policy() const { return _gen_policy; }
aoqi@0 140 virtual CollectorPolicy* collector_policy() const { return (CollectorPolicy*) gen_policy(); }
aoqi@0 141
aoqi@0 142 // Adaptive size policy
aoqi@0 143 virtual AdaptiveSizePolicy* size_policy() {
aoqi@0 144 return gen_policy()->size_policy();
aoqi@0 145 }
aoqi@0 146
aoqi@0 147 // Return the (conservative) maximum heap alignment
aoqi@0 148 static size_t conservative_max_heap_alignment() {
aoqi@0 149 return Generation::GenGrain;
aoqi@0 150 }
aoqi@0 151
aoqi@0 152 size_t capacity() const;
aoqi@0 153 size_t used() const;
aoqi@0 154
aoqi@0 155 // Save the "used_region" for generations level and lower.
aoqi@0 156 void save_used_regions(int level);
aoqi@0 157
aoqi@0 158 size_t max_capacity() const;
aoqi@0 159
aoqi@0 160 HeapWord* mem_allocate(size_t size,
aoqi@0 161 bool* gc_overhead_limit_was_exceeded);
aoqi@0 162
aoqi@0 163 // We may support a shared contiguous allocation area, if the youngest
aoqi@0 164 // generation does.
aoqi@0 165 bool supports_inline_contig_alloc() const;
aoqi@0 166 HeapWord** top_addr() const;
aoqi@0 167 HeapWord** end_addr() const;
aoqi@0 168
aoqi@0 169 // Return an estimate of the maximum allocation that could be performed
aoqi@0 170 // without triggering any collection activity. In a generational
aoqi@0 171 // collector, for example, this is probably the largest allocation that
aoqi@0 172 // could be supported in the youngest generation. It is "unsafe" because
aoqi@0 173 // no locks are taken; the result should be treated as an approximation,
aoqi@0 174 // not a guarantee.
aoqi@0 175 size_t unsafe_max_alloc();
aoqi@0 176
aoqi@0 177 // Does this heap support heap inspection? (+PrintClassHistogram)
aoqi@0 178 virtual bool supports_heap_inspection() const { return true; }
aoqi@0 179
aoqi@0 180 // Perform a full collection of the heap; intended for use in implementing
aoqi@0 181 // "System.gc". This implies as full a collection as the CollectedHeap
aoqi@0 182 // supports. Caller does not hold the Heap_lock on entry.
aoqi@0 183 void collect(GCCause::Cause cause);
aoqi@0 184
aoqi@0 185 // The same as above but assume that the caller holds the Heap_lock.
aoqi@0 186 void collect_locked(GCCause::Cause cause);
aoqi@0 187
aoqi@0 188 // Perform a full collection of the first max_level+1 generations.
aoqi@0 189 // Mostly used for testing purposes. Caller does not hold the Heap_lock on entry.
aoqi@0 190 void collect(GCCause::Cause cause, int max_level);
aoqi@0 191
aoqi@0 192 // Returns "TRUE" iff "p" points into the committed areas of the heap.
aoqi@0 193 // The methods is_in(), is_in_closed_subset() and is_in_youngest() may
aoqi@0 194 // be expensive to compute in general, so, to prevent
aoqi@0 195 // their inadvertent use in product jvm's, we restrict their use to
aoqi@0 196 // assertion checking or verification only.
aoqi@0 197 bool is_in(const void* p) const;
aoqi@0 198
aoqi@0 199 // override
aoqi@0 200 bool is_in_closed_subset(const void* p) const {
aoqi@0 201 if (UseConcMarkSweepGC) {
aoqi@0 202 return is_in_reserved(p);
aoqi@0 203 } else {
aoqi@0 204 return is_in(p);
aoqi@0 205 }
aoqi@0 206 }
aoqi@0 207
aoqi@0 208 // Returns true if the reference is to an object in the reserved space
aoqi@0 209 // for the young generation.
aoqi@0 210 // Assumes the the young gen address range is less than that of the old gen.
aoqi@0 211 bool is_in_young(oop p);
aoqi@0 212
aoqi@0 213 #ifdef ASSERT
aoqi@0 214 virtual bool is_in_partial_collection(const void* p);
aoqi@0 215 #endif
aoqi@0 216
aoqi@0 217 virtual bool is_scavengable(const void* addr) {
aoqi@0 218 return is_in_young((oop)addr);
aoqi@0 219 }
aoqi@0 220
aoqi@0 221 // Iteration functions.
aoqi@0 222 void oop_iterate(ExtendedOopClosure* cl);
aoqi@0 223 void oop_iterate(MemRegion mr, ExtendedOopClosure* cl);
aoqi@0 224 void object_iterate(ObjectClosure* cl);
aoqi@0 225 void safe_object_iterate(ObjectClosure* cl);
aoqi@0 226 Space* space_containing(const void* addr) const;
aoqi@0 227
aoqi@0 228 // A CollectedHeap is divided into a dense sequence of "blocks"; that is,
aoqi@0 229 // each address in the (reserved) heap is a member of exactly
aoqi@0 230 // one block. The defining characteristic of a block is that it is
aoqi@0 231 // possible to find its size, and thus to progress forward to the next
aoqi@0 232 // block. (Blocks may be of different sizes.) Thus, blocks may
aoqi@0 233 // represent Java objects, or they might be free blocks in a
aoqi@0 234 // free-list-based heap (or subheap), as long as the two kinds are
aoqi@0 235 // distinguishable and the size of each is determinable.
aoqi@0 236
aoqi@0 237 // Returns the address of the start of the "block" that contains the
aoqi@0 238 // address "addr". We say "blocks" instead of "object" since some heaps
aoqi@0 239 // may not pack objects densely; a chunk may either be an object or a
aoqi@0 240 // non-object.
aoqi@0 241 virtual HeapWord* block_start(const void* addr) const;
aoqi@0 242
aoqi@0 243 // Requires "addr" to be the start of a chunk, and returns its size.
aoqi@0 244 // "addr + size" is required to be the start of a new chunk, or the end
aoqi@0 245 // of the active area of the heap. Assumes (and verifies in non-product
aoqi@0 246 // builds) that addr is in the allocated part of the heap and is
aoqi@0 247 // the start of a chunk.
aoqi@0 248 virtual size_t block_size(const HeapWord* addr) const;
aoqi@0 249
aoqi@0 250 // Requires "addr" to be the start of a block, and returns "TRUE" iff
aoqi@0 251 // the block is an object. Assumes (and verifies in non-product
aoqi@0 252 // builds) that addr is in the allocated part of the heap and is
aoqi@0 253 // the start of a chunk.
aoqi@0 254 virtual bool block_is_obj(const HeapWord* addr) const;
aoqi@0 255
aoqi@0 256 // Section on TLAB's.
aoqi@0 257 virtual bool supports_tlab_allocation() const;
aoqi@0 258 virtual size_t tlab_capacity(Thread* thr) const;
aoqi@0 259 virtual size_t tlab_used(Thread* thr) const;
aoqi@0 260 virtual size_t unsafe_max_tlab_alloc(Thread* thr) const;
aoqi@0 261 virtual HeapWord* allocate_new_tlab(size_t size);
aoqi@0 262
aoqi@0 263 // Can a compiler initialize a new object without store barriers?
aoqi@0 264 // This permission only extends from the creation of a new object
aoqi@0 265 // via a TLAB up to the first subsequent safepoint.
aoqi@0 266 virtual bool can_elide_tlab_store_barriers() const {
aoqi@0 267 return true;
aoqi@0 268 }
aoqi@0 269
aoqi@0 270 virtual bool card_mark_must_follow_store() const {
aoqi@0 271 return UseConcMarkSweepGC;
aoqi@0 272 }
aoqi@0 273
aoqi@0 274 // We don't need barriers for stores to objects in the
aoqi@0 275 // young gen and, a fortiori, for initializing stores to
aoqi@0 276 // objects therein. This applies to {DefNew,ParNew}+{Tenured,CMS}
aoqi@0 277 // only and may need to be re-examined in case other
aoqi@0 278 // kinds of collectors are implemented in the future.
aoqi@0 279 virtual bool can_elide_initializing_store_barrier(oop new_obj) {
aoqi@0 280 // We wanted to assert that:-
aoqi@0 281 // assert(UseParNewGC || UseSerialGC || UseConcMarkSweepGC,
aoqi@0 282 // "Check can_elide_initializing_store_barrier() for this collector");
aoqi@0 283 // but unfortunately the flag UseSerialGC need not necessarily always
aoqi@0 284 // be set when DefNew+Tenured are being used.
aoqi@0 285 return is_in_young(new_obj);
aoqi@0 286 }
aoqi@0 287
aoqi@0 288 // The "requestor" generation is performing some garbage collection
aoqi@0 289 // action for which it would be useful to have scratch space. The
aoqi@0 290 // requestor promises to allocate no more than "max_alloc_words" in any
aoqi@0 291 // older generation (via promotion say.) Any blocks of space that can
aoqi@0 292 // be provided are returned as a list of ScratchBlocks, sorted by
aoqi@0 293 // decreasing size.
aoqi@0 294 ScratchBlock* gather_scratch(Generation* requestor, size_t max_alloc_words);
aoqi@0 295 // Allow each generation to reset any scratch space that it has
aoqi@0 296 // contributed as it needs.
aoqi@0 297 void release_scratch();
aoqi@0 298
aoqi@0 299 // Ensure parsability: override
aoqi@0 300 virtual void ensure_parsability(bool retire_tlabs);
aoqi@0 301
aoqi@0 302 // Time in ms since the longest time a collector ran in
aoqi@0 303 // in any generation.
aoqi@0 304 virtual jlong millis_since_last_gc();
aoqi@0 305
aoqi@0 306 // Total number of full collections completed.
aoqi@0 307 unsigned int total_full_collections_completed() {
aoqi@0 308 assert(_full_collections_completed <= _total_full_collections,
aoqi@0 309 "Can't complete more collections than were started");
aoqi@0 310 return _full_collections_completed;
aoqi@0 311 }
aoqi@0 312
aoqi@0 313 // Update above counter, as appropriate, at the end of a stop-world GC cycle
aoqi@0 314 unsigned int update_full_collections_completed();
aoqi@0 315 // Update above counter, as appropriate, at the end of a concurrent GC cycle
aoqi@0 316 unsigned int update_full_collections_completed(unsigned int count);
aoqi@0 317
aoqi@0 318 // Update "time of last gc" for all constituent generations
aoqi@0 319 // to "now".
aoqi@0 320 void update_time_of_last_gc(jlong now) {
aoqi@0 321 for (int i = 0; i < _n_gens; i++) {
aoqi@0 322 _gens[i]->update_time_of_last_gc(now);
aoqi@0 323 }
aoqi@0 324 }
aoqi@0 325
aoqi@0 326 // Update the gc statistics for each generation.
aoqi@0 327 // "level" is the level of the lastest collection
aoqi@0 328 void update_gc_stats(int current_level, bool full) {
aoqi@0 329 for (int i = 0; i < _n_gens; i++) {
aoqi@0 330 _gens[i]->update_gc_stats(current_level, full);
aoqi@0 331 }
aoqi@0 332 }
aoqi@0 333
aoqi@0 334 // Override.
aoqi@0 335 bool no_gc_in_progress() { return !is_gc_active(); }
aoqi@0 336
aoqi@0 337 // Override.
aoqi@0 338 void prepare_for_verify();
aoqi@0 339
aoqi@0 340 // Override.
aoqi@0 341 void verify(bool silent, VerifyOption option);
aoqi@0 342
aoqi@0 343 // Override.
aoqi@0 344 virtual void print_on(outputStream* st) const;
aoqi@0 345 virtual void print_gc_threads_on(outputStream* st) const;
aoqi@0 346 virtual void gc_threads_do(ThreadClosure* tc) const;
aoqi@0 347 virtual void print_tracing_info() const;
aoqi@0 348 virtual void print_on_error(outputStream* st) const;
aoqi@0 349
aoqi@0 350 // PrintGC, PrintGCDetails support
aoqi@0 351 void print_heap_change(size_t prev_used) const;
aoqi@0 352
aoqi@0 353 // The functions below are helper functions that a subclass of
aoqi@0 354 // "CollectedHeap" can use in the implementation of its virtual
aoqi@0 355 // functions.
aoqi@0 356
aoqi@0 357 class GenClosure : public StackObj {
aoqi@0 358 public:
aoqi@0 359 virtual void do_generation(Generation* gen) = 0;
aoqi@0 360 };
aoqi@0 361
aoqi@0 362 // Apply "cl.do_generation" to all generations in the heap
aoqi@0 363 // If "old_to_young" determines the order.
aoqi@0 364 void generation_iterate(GenClosure* cl, bool old_to_young);
aoqi@0 365
aoqi@0 366 void space_iterate(SpaceClosure* cl);
aoqi@0 367
aoqi@0 368 // Return "true" if all generations have reached the
aoqi@0 369 // maximal committed limit that they can reach, without a garbage
aoqi@0 370 // collection.
aoqi@0 371 virtual bool is_maximal_no_gc() const;
aoqi@0 372
aoqi@0 373 // Return the generation before "gen".
aoqi@0 374 Generation* prev_gen(Generation* gen) const {
aoqi@0 375 int l = gen->level();
aoqi@0 376 guarantee(l > 0, "Out of bounds");
aoqi@0 377 return _gens[l-1];
aoqi@0 378 }
aoqi@0 379
aoqi@0 380 // Return the generation after "gen".
aoqi@0 381 Generation* next_gen(Generation* gen) const {
aoqi@0 382 int l = gen->level() + 1;
aoqi@0 383 guarantee(l < _n_gens, "Out of bounds");
aoqi@0 384 return _gens[l];
aoqi@0 385 }
aoqi@0 386
aoqi@0 387 Generation* get_gen(int i) const {
aoqi@0 388 guarantee(i >= 0 && i < _n_gens, "Out of bounds");
aoqi@0 389 return _gens[i];
aoqi@0 390 }
aoqi@0 391
aoqi@0 392 int n_gens() const {
aoqi@0 393 assert(_n_gens == gen_policy()->number_of_generations(), "Sanity");
aoqi@0 394 return _n_gens;
aoqi@0 395 }
aoqi@0 396
aoqi@0 397 // Convenience function to be used in situations where the heap type can be
aoqi@0 398 // asserted to be this type.
aoqi@0 399 static GenCollectedHeap* heap();
aoqi@0 400
aoqi@0 401 void set_par_threads(uint t);
aoqi@0 402
aoqi@0 403 // Invoke the "do_oop" method of one of the closures "not_older_gens"
aoqi@0 404 // or "older_gens" on root locations for the generation at
aoqi@0 405 // "level". (The "older_gens" closure is used for scanning references
aoqi@0 406 // from older generations; "not_older_gens" is used everywhere else.)
aoqi@0 407 // If "younger_gens_as_roots" is false, younger generations are
aoqi@0 408 // not scanned as roots; in this case, the caller must be arranging to
aoqi@0 409 // scan the younger generations itself. (For example, a generation might
aoqi@0 410 // explicitly mark reachable objects in younger generations, to avoid
aoqi@0 411 // excess storage retention.)
aoqi@0 412 // The "so" argument determines which of the roots
aoqi@0 413 // the closure is applied to:
aoqi@0 414 // "SO_None" does none;
aoqi@0 415 // "SO_AllClasses" applies the closure to all entries in the SystemDictionary;
aoqi@0 416 // "SO_SystemClasses" to all the "system" classes and loaders;
aoqi@0 417 // "SO_Strings" applies the closure to all entries in the StringTable.
aoqi@0 418 void gen_process_strong_roots(int level,
aoqi@0 419 bool younger_gens_as_roots,
aoqi@0 420 // The remaining arguments are in an order
aoqi@0 421 // consistent with SharedHeap::process_strong_roots:
aoqi@0 422 bool activate_scope,
aoqi@0 423 bool is_scavenging,
aoqi@0 424 SharedHeap::ScanningOption so,
aoqi@0 425 OopsInGenClosure* not_older_gens,
aoqi@0 426 bool do_code_roots,
aoqi@0 427 OopsInGenClosure* older_gens,
aoqi@0 428 KlassClosure* klass_closure);
aoqi@0 429
aoqi@0 430 // Apply "blk" to all the weak roots of the system. These include
aoqi@0 431 // JNI weak roots, the code cache, system dictionary, symbol table,
aoqi@0 432 // string table, and referents of reachable weak refs.
aoqi@0 433 void gen_process_weak_roots(OopClosure* root_closure,
aoqi@0 434 CodeBlobClosure* code_roots);
aoqi@0 435
aoqi@0 436 // Set the saved marks of generations, if that makes sense.
aoqi@0 437 // In particular, if any generation might iterate over the oops
aoqi@0 438 // in other generations, it should call this method.
aoqi@0 439 void save_marks();
aoqi@0 440
aoqi@0 441 // Apply "cur->do_oop" or "older->do_oop" to all the oops in objects
aoqi@0 442 // allocated since the last call to save_marks in generations at or above
aoqi@0 443 // "level". The "cur" closure is
aoqi@0 444 // applied to references in the generation at "level", and the "older"
aoqi@0 445 // closure to older generations.
aoqi@0 446 #define GCH_SINCE_SAVE_MARKS_ITERATE_DECL(OopClosureType, nv_suffix) \
aoqi@0 447 void oop_since_save_marks_iterate(int level, \
aoqi@0 448 OopClosureType* cur, \
aoqi@0 449 OopClosureType* older);
aoqi@0 450
aoqi@0 451 ALL_SINCE_SAVE_MARKS_CLOSURES(GCH_SINCE_SAVE_MARKS_ITERATE_DECL)
aoqi@0 452
aoqi@0 453 #undef GCH_SINCE_SAVE_MARKS_ITERATE_DECL
aoqi@0 454
aoqi@0 455 // Returns "true" iff no allocations have occurred in any generation at
aoqi@0 456 // "level" or above since the last
aoqi@0 457 // call to "save_marks".
aoqi@0 458 bool no_allocs_since_save_marks(int level);
aoqi@0 459
aoqi@0 460 // Returns true if an incremental collection is likely to fail.
aoqi@0 461 // We optionally consult the young gen, if asked to do so;
aoqi@0 462 // otherwise we base our answer on whether the previous incremental
aoqi@0 463 // collection attempt failed with no corrective action as of yet.
aoqi@0 464 bool incremental_collection_will_fail(bool consult_young) {
aoqi@0 465 // Assumes a 2-generation system; the first disjunct remembers if an
aoqi@0 466 // incremental collection failed, even when we thought (second disjunct)
aoqi@0 467 // that it would not.
aoqi@0 468 assert(heap()->collector_policy()->is_two_generation_policy(),
aoqi@0 469 "the following definition may not be suitable for an n(>2)-generation system");
aoqi@0 470 return incremental_collection_failed() ||
aoqi@0 471 (consult_young && !get_gen(0)->collection_attempt_is_safe());
aoqi@0 472 }
aoqi@0 473
aoqi@0 474 // If a generation bails out of an incremental collection,
aoqi@0 475 // it sets this flag.
aoqi@0 476 bool incremental_collection_failed() const {
aoqi@0 477 return _incremental_collection_failed;
aoqi@0 478 }
aoqi@0 479 void set_incremental_collection_failed() {
aoqi@0 480 _incremental_collection_failed = true;
aoqi@0 481 }
aoqi@0 482 void clear_incremental_collection_failed() {
aoqi@0 483 _incremental_collection_failed = false;
aoqi@0 484 }
aoqi@0 485
aoqi@0 486 // Promotion of obj into gen failed. Try to promote obj to higher
aoqi@0 487 // gens in ascending order; return the new location of obj if successful.
aoqi@0 488 // Otherwise, try expand-and-allocate for obj in both the young and old
aoqi@0 489 // generation; return the new location of obj if successful. Otherwise, return NULL.
aoqi@0 490 oop handle_failed_promotion(Generation* old_gen,
aoqi@0 491 oop obj,
aoqi@0 492 size_t obj_size);
aoqi@0 493
aoqi@0 494 private:
aoqi@0 495 // Accessor for memory state verification support
aoqi@0 496 NOT_PRODUCT(
aoqi@0 497 static size_t skip_header_HeapWords() { return _skip_header_HeapWords; }
aoqi@0 498 )
aoqi@0 499
aoqi@0 500 // Override
aoqi@0 501 void check_for_non_bad_heap_word_value(HeapWord* addr,
aoqi@0 502 size_t size) PRODUCT_RETURN;
aoqi@0 503
aoqi@0 504 // For use by mark-sweep. As implemented, mark-sweep-compact is global
aoqi@0 505 // in an essential way: compaction is performed across generations, by
aoqi@0 506 // iterating over spaces.
aoqi@0 507 void prepare_for_compaction();
aoqi@0 508
aoqi@0 509 // Perform a full collection of the first max_level+1 generations.
aoqi@0 510 // This is the low level interface used by the public versions of
aoqi@0 511 // collect() and collect_locked(). Caller holds the Heap_lock on entry.
aoqi@0 512 void collect_locked(GCCause::Cause cause, int max_level);
aoqi@0 513
aoqi@0 514 // Returns success or failure.
aoqi@0 515 bool create_cms_collector();
aoqi@0 516
aoqi@0 517 // In support of ExplicitGCInvokesConcurrent functionality
aoqi@0 518 bool should_do_concurrent_full_gc(GCCause::Cause cause);
aoqi@0 519 void collect_mostly_concurrent(GCCause::Cause cause);
aoqi@0 520
aoqi@0 521 // Save the tops of the spaces in all generations
aoqi@0 522 void record_gen_tops_before_GC() PRODUCT_RETURN;
aoqi@0 523
aoqi@0 524 protected:
aoqi@0 525 virtual void gc_prologue(bool full);
aoqi@0 526 virtual void gc_epilogue(bool full);
aoqi@0 527 };
aoqi@0 528
aoqi@0 529 #endif // SHARE_VM_MEMORY_GENCOLLECTEDHEAP_HPP

mercurial