3063N/A * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. 342N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 342N/A * This code is free software; you can redistribute it and/or modify it 342N/A * under the terms of the GNU General Public License version 2 only, as 342N/A * published by the Free Software Foundation. 342N/A * This code is distributed in the hope that it will be useful, but WITHOUT 342N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 342N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 342N/A * version 2 for more details (a copy is included in the LICENSE file that 342N/A * accompanied this code). 342N/A * You should have received a copy of the GNU General Public License version 342N/A * 2 along with this work; if not, write to the Free Software Foundation, 342N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1472N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 342N/A// A "G1CollectedHeap" is an implementation of a java heap for HotSpot. 342N/A// It uses the "Garbage First" heap organization and algorithm, which 342N/A// may combine concurrent marking with parallel, incremental compaction of 342N/A// heap subsets that will yield large amounts of garbage. 2589N/A // Currently we do not keep track of the used byte sum for the 2589N/A // young list and the survivors and it'd be quite a lot of work to 2589N/A // do so. When we'll eventually replace the young list with 2589N/A // instances of HeapRegionLinkedList we'll get that for free. So, 2589N/A // we'll report the more accurate information then. 342N/A // for development purposes 2815N/A// The G1 STW is alive closure. 2815N/A// An instance is embedded into the G1CH and used as the 2815N/A// (optional) _is_alive_non_header closure in the STW 2815N/A// reference processor. It is also extensively used during 4419N/A// reference processing during STW evacuation pauses. 342N/A // Closures used in implementation. 342N/A // Other related classes. 342N/A // The one and only G1CollectedHeap, so static functions can find it. 342N/A // Storage for the G1 heap (excludes the permanent generation). 342N/A // The part of _g1_storage that is currently committed. 2037N/A // The master free list. It will satisfy all new region allocations. 2037N/A // The secondary free list which contains regions that have been 2037N/A // freed up during the cleanup process. This will be appended to the 2037N/A // master free list when appropriate. 2910N/A // It keeps track of the old regions. 2037N/A // It keeps track of the humongous regions. 342N/A // The number of regions we could create by expansion. 342N/A // The block offset table for the G1 heap. 2910N/A // Tears down the region sets / lists so that they are empty and the 2910N/A // regions on the heap do not belong to a region set / list. The 2910N/A // only exception is the humongous set which we leave unaltered. If 2910N/A // free_list_only is true, it will only tear down the master free 2910N/A // list. It is called before a Full GC (free_list_only == false) or 2910N/A // before heap shrinking (free_list_only == true). 2910N/A // Rebuilds the region sets / lists so that they are repopulated to 2910N/A // reflect the contents of the heap. The only exception is the 2910N/A // humongous set which was not torn down in the first place. If 2910N/A // free_list_only is true, it will only rebuild the master free 2910N/A // list. It is called after a Full GC (free_list_only == false) or 2910N/A // after heap shrinking (free_list_only == true). 342N/A // The sequence of all heap regions in the heap. 2280N/A // Alloc region used to satisfy mutator allocation requests. 2655N/A // Alloc region used to satisfy allocation requests by the GC for 3945N/A // PLAB sizing policy for survivors. 2655N/A // Alloc region used to satisfy allocation requests by the GC for 3945N/A // PLAB sizing policy for tenured objects. 2655N/A // The last old region we allocated to during the last GC. 2655N/A // Typically, it is not full so we should re-use it during the next GC. 3061N/A // It specifies whether we should attempt to expand the heap after a 3061N/A // region allocation failure. If heap expansion fails we set this to 3061N/A // false so that we don't re-attempt the heap expansion (it's likely 3061N/A // that subsequent expansion attempts will also fail if one fails). 3061N/A // Currently, it is only consulted during GC and it's reset at the 2280N/A // It resets the mutator alloc region before new allocations can take place. 2280N/A // It releases the mutator alloc region. 2655N/A // It initializes the GC alloc regions at the start of a GC. 2655N/A // It releases the GC alloc regions at the end of a GC. 2655N/A // It does any cleanup that needs to be done on the GC alloc regions 2386N/A // Helper for monitoring and management support. 1391N/A // Determines PLAB size for a particular allocation purpose. 342N/A // Outside of GC pauses, the number of bytes used in all regions other 342N/A // than the current allocation region. 526N/A // This is used for a quick test on whether a reference points into 526N/A // the collection set or not. Basically, we have an array, with one 526N/A // byte per region, and that byte denotes whether the corresponding 526N/A // region is in the collection set or not. The entry corresponding 526N/A // the bottom of the heap, i.e., region 0, is pointed to by 526N/A // _in_cset_fast_test_base. The _in_cset_fast_test field has been 526N/A // biased so that it actually points to address 0 of the address 526N/A // space, to make the test as fast as possible (we can simply shift 526N/A // the address to address into it, instead of having to subtract the 526N/A // bottom of the heap from the address before shifting it; basically 526N/A // it works in the same way the card table works). 526N/A // The allocated array used for the fast test on whether a reference 526N/A // points into the collection set or not. This field is also used to 526N/A // The length of the _in_cset_fast_test_base array. 1576N/A // It decides whether an explicit GC should start a concurrent cycle 1576N/A // instead of doing a STW GC. Currently, a concurrent cycle is 1576N/A // (a) cause == _gc_locker and +GCLockerInvokesConcurrent, or 1576N/A // (b) cause == _java_lang_system_gc and +ExplicitGCInvokesConcurrent. 3112N/A // (c) cause == _g1_humongous_allocation 3787N/A // Keeps track of how many "old marking cycles" (i.e., Full GCs or 3787N/A // concurrent cycles) we have started. 3787N/A // Keeps track of how many "old marking cycles" (i.e., Full GCs or 3787N/A // concurrent cycles) we have completed. 2382N/A // This is a non-product method that is helpful for testing. It is 2382N/A // called at the end of a GC and artificially expands the heap by 2382N/A // allocating a number of dead regions. This way we can induce very 2382N/A // frequent marking cycles and stress the cleanup / concurrent 2382N/A // cleanup code more (as all the regions that will be allocated by 2382N/A // this method will be found dead by the marking cycle). 3920N/A // Clear RSets after a compaction. It also resets the GC time stamps. 3920N/A // If the HR printer is active, dump the state of the regions in the 3920N/A // heap after a compaction. 1880N/A // These are macros so that, if the assert fires, we get the correct 2037N/A err_msg(
"%s : Heap_lock locked: %s, at safepoint: %s, is VM thread: %s", \
1880N/A "should be at a safepoint")); \
1880N/A "should not be at a safepoint")); \
1880N/A "should not be at a safepoint")); \
342N/A // The current policy object for the collector. 2037N/A // This is the second level of trying to allocate a new region. If 2280N/A // new_region() didn't find a region on the free_list, this call will 2280N/A // check whether there's anything available on the 2280N/A // secondary_free_list and/or wait for more regions to appear on 2280N/A // that list, if _free_regions_coming is set. 2208N/A // Try to allocate a single non-humongous HeapRegion sufficient for 2208N/A // an allocation of the given word_size. If do_expand is true, 2208N/A // attempt to expand the heap if necessary to satisfy the allocation 2208N/A // Attempt to satisfy a humongous allocation request of the given 2208N/A // size by finding a contiguous set of free regions of num_regions 2208N/A // length and remove them from the master free list. Return the 2591N/A // index of the first region or G1_NULL_HRS_INDEX if the search 2208N/A // Initialize a contiguous set of free regions of length num_regions 2208N/A // and starting at index first so that they appear as a single 2208N/A // Attempt to allocate a humongous object of the given size. Return 1880N/A // The following two methods, allocate_new_tlab() and 1880N/A // mem_allocate(), are the two main entry points from the runtime 1880N/A // into the G1's allocation routines. They have the following 1880N/A // * They should both be called outside safepoints. 1880N/A // * They should both be called without holding the Heap_lock. 1880N/A // * All allocation requests for new TLABs should go to 2599N/A // * All non-TLAB allocation requests should go to mem_allocate(). 1880N/A // * If either call cannot satisfy the allocation request using the 1880N/A // current allocating region, they will try to get a new one. If 1880N/A // this fails, they will attempt to do an evacuation pause and 1880N/A // * If all allocation attempts fail, even after trying to schedule 1880N/A // an evacuation pause, allocate_new_tlab() will return NULL, 1880N/A // whereas mem_allocate() will attempt a heap expansion and/or 1880N/A // * We do not allow humongous-sized TLABs. So, allocate_new_tlab 1880N/A // should never be called with word_size being humongous. All 1880N/A // humongous allocation requests should go to mem_allocate() which 1880N/A // will satisfy them with a special path. 2280N/A // The following three methods take a gc_count_before_ret 2280N/A // parameter which is used to return the GC count if the method 2280N/A // returns NULL. Given that we are required to read the GC count 2280N/A // while holding the Heap_lock, and these paths will take the 2280N/A // Heap_lock at some point, it's easier to get them to read the GC 2280N/A // count while holding the Heap_lock before they return NULL instead 2280N/A // of the caller (namely: mem_allocate()) having to also take the 2280N/A // Heap_lock just to read the GC count. 2280N/A // First-level mutator allocation attempt: try to allocate out of 2280N/A // the mutator alloc region without taking the Heap_lock. This 2280N/A // should only be used for non-humongous allocations. 2280N/A // Second-level mutator allocation attempt: take the Heap_lock and 2280N/A // retry the allocation attempt, potentially scheduling a GC 2280N/A // pause. This should only be used for non-humongous allocations. 2280N/A // Takes the Heap_lock and attempts a humongous allocation. It can 2280N/A // potentially schedule a GC pause. 2280N/A // Allocation attempt that should be called during safepoints (e.g., 2280N/A // at the end of a successful GC). expect_null_mutator_alloc_region 2280N/A // specifies whether the mutator alloc region is expected to be NULL 1880N/A // It dirties the cards that cover the block so that so that the post 1880N/A // write barrier never queues anything when updating objects on this 1880N/A // block. It is assumed (and in fact we assert) that the block 1880N/A // belongs to a young region. 342N/A // Allocate blocks during garbage collection. Will ensure an 342N/A // allocation region, either by picking one or expanding the 342N/A // heap, and then allocate a block of the given size. The block 342N/A // may not be a humongous - it must fit into a single heap region. 342N/A // Ensure that no further allocations can happen in "r", bearing in mind 342N/A // that parallel threads might be attempting allocations. 2655N/A // Allocation attempt during GC for a survivor object / PLAB. 2655N/A // Allocation attempt during GC for an old object / PLAB. 2655N/A // These methods are the "callbacks" from the G1AllocRegion class. 2655N/A // For mutator alloc regions. 1576N/A // - if explicit_gc is true, the GC is for a System.gc() or a heap 1880N/A // inspection request and should collect the entire heap 1880N/A // - if clear_all_soft_refs is true, all soft references should be 1576N/A // - if explicit_gc is false, word_size describes the allocation that 1880N/A // the GC should attempt (at least) to satisfy 1880N/A // - it returns false if it is unable to do the collection due to the 1880N/A // GC locker being active, true otherwise 342N/A // Callback from VM_G1CollectFull operation. 342N/A // Perform a full collection. 342N/A // Resize the heap if necessary after a full collection. If this is 342N/A // after a collect-for allocation, "word_size" is the allocation size, 342N/A // and will be considered part of the used portion of the heap. 342N/A // Callback from VM_G1CollectForAllocation operation. 342N/A // failed allocation request (including collection, expansion, etc.) 342N/A // Attempting to expand the heap sufficiently 342N/A // to support an allocation of the given "word_size". If 342N/A // successful, perform the allocation and return the address of the 342N/A // allocated block, or else "NULL". 2815N/A // Process any reference objects discovered during 2815N/A // an incremental evacuation pause. 2815N/A // Enqueue any remaining discovered references 342N/A // Expand the garbage-first heap by at least the given size (in bytes!). 2069N/A // Returns true if the heap was expanded by the requested amount; 342N/A // (Rounds up to a HeapRegion boundary.) 342N/A // Do anything common to GC's. 526N/A // We register a region with the fast "in collection set" test. We 526N/A // simply set to true the array slot corresponding to this region. 526N/A // This is a fast test on whether a reference points into the 526N/A // collection set or not. It does not assume that the reference 526N/A // points into the heap; if it doesn't, it will return false. 526N/A // no need to subtract the bottom of the heap from obj, 526N/A // _in_cset_fast_test is biased 526N/A // let's make sure the result is consistent with what the slower 3787N/A // This is called at the start of either a concurrent cycle or a Full 3787N/A // GC to update the number of old marking cycles started. 1576N/A // This is called at the end of either a concurrent cycle or a Full 3787N/A // GC to update the number of old marking cycles completed. Those two 1576N/A // can happen in a nested fashion, i.e., we start a concurrent 1576N/A // cycle, a Full GC happens half-way through it which ends first, 1576N/A // and then the cycle notices that a Full GC happened and ends 1937N/A // too. The concurrent parameter is a boolean to help us do a bit 1937N/A // tighter consistency checking in the method. If concurrent is 1937N/A // false, the caller is the inner caller in the nesting (i.e., the 1937N/A // Full GC). If concurrent is true, the caller is the outer caller 1937N/A // in this nesting (i.e., the concurrent cycle). Further nesting is 3787N/A // not currently supported. The end of this call also notifies 1937N/A // the FullGCCount_lock in case a Java thread is waiting for a full 1937N/A // GC to happen (e.g., it called System.gc() with 1576N/A // +ExplicitGCInvokesConcurrent). 342N/A // Shrink the garbage-first heap by at most the given size (in bytes!). 342N/A // (Rounds down to a HeapRegion boundary.) 1880N/A // Schedule the VM operation that will do an evacuation pause to 1880N/A // satisfy an allocation request of word_size. *succeeded will 1880N/A // return whether the VM operation was successful (it did do an 1880N/A // evacuation pause) or not (another thread beat us to it or the GC 1880N/A // locker was active). Given that we should not be holding the 1880N/A // Heap_lock when we enter this method, we will pass the 1880N/A // gc_count_before (i.e., total_collections()) as a parameter since 1880N/A // it has to be read while holding the Heap_lock. Currently, both 1880N/A // methods that call do_collection_pause() release the Heap_lock 1880N/A // before the call, so it's easy to read gc_count_before just before. 342N/A // The guts of the incremental collection pause, executed by the vm 1880N/A // thread. It returns false if it is unable to do the collection due 1880N/A // to the GC locker being active, true otherwise 342N/A // Actually do the work of evacuating the collection set. 342N/A // The g1 remembered set of the heap. 342N/A // And it's mod ref barrier set, used to track updates for the above. 616N/A // A set of cards that cover the objects for which the Rsets should be updated 616N/A // concurrently after the collection. 342N/A // The Heap Region Rem Set Iterator. 342N/A // The closure used to refine a single card. 342N/A // A function to check the consistency of dirty card logs. 1625N/A // A DirtyCardQueueSet that is used to hold cards that contain 1625N/A // references into the current collection set. This is used to 1625N/A // update the remembered sets of the regions in the collection 1625N/A // set in the event of an evacuation failure. 342N/A // After a collection pause, make the regions in the CS into free 1394N/A // Abandon the current collection set without recording policy 1394N/A // statistics or updating free lists. 342N/A // Applies "scan_non_heap_roots" to roots outside the heap, 342N/A // "scan_rs" to roots inside the heap (having done "set_region" to 342N/A // indicate the region in which the root resides), and does "scan_perm" 342N/A // (setting the generation to the perm generation.) If "scan_rs" is 342N/A // NULL, then this step is skipped. The "worker_i" 342N/A // param is for use with parallel roots processing, and should be 342N/A // the "i" of the calling parallel worker thread's work(i) function. 342N/A // In the sequential case this param will be ignored. 342N/A // Apply "blk" to all the weak roots of the system. These include 342N/A // JNI weak roots, the code cache, system dictionary, symbol table, 342N/A // string table, and referents of reachable weak refs. 2208N/A // Frees a non-humongous region by initializing its contents and 2037N/A // adding it to the free list that's passed as a parameter (this is 2037N/A // usually a local list which will be appended to the master free 2037N/A // list later). The used bytes of freed regions are accumulated in 2037N/A // pre_used. If par is true, the region's RSet will not be freed 2037N/A // up. The assumption is that this will be done later. 2208N/A // Frees a humongous region by collapsing it into individual regions 2208N/A // and calling free_region() for each of them. The freed regions 2208N/A // will be added to the free list that's passed as a parameter (this 2208N/A // is usually a local list which will be appended to the master free 2208N/A // list later). The used bytes of freed regions are accumulated in 2208N/A // pre_used. If par is true, the region's RSet will not be freed 2208N/A // up. The assumption is that this will be done later. 2591N/A // Notifies all the necessary spaces that the committed space has 2591N/A // been updated (either expanded or shrunk). It should be called 2591N/A // after _g1_storage is updated. 342N/A // The concurrent marker (and the thread it runs in.) 342N/A // The concurrent refiner. 342N/A // The parallel task queues 342N/A // True iff a evacuation has failed in the current collection. 342N/A // Failed evacuations cause some logical from-space objects to have 342N/A // forwarding pointers to themselves. Reset them. 4199N/A // Together, these store an object with a preserved mark, and its mark value. 342N/A // Preserve the mark of "obj", if necessary, in preparation for its mark 342N/A // word being overwritten with a self-forwarding-pointer. 342N/A // The stack of evac-failure objects left to be scanned. 342N/A // The closure to apply to evac-failure objects. 342N/A // Set the field above. 342N/A // Push "obj" on the scan stack. 342N/A // Process scan stack entries until the stack is empty. 342N/A // True iff an invocation of "drain_scan_stack" is in progress; to 342N/A // prevent unnecessary recursion. 342N/A // Do any necessary initialization for evacuation-failure handling. 342N/A // "cl" is the closure that will be used to process evac-failure 342N/A // Do any necessary cleanup for evacuation-failure handling data 342N/A // An attempt to evacuate "obj" has failed; take necessary steps. 3979N/A // Support for forcing evacuation failures. Analogous to 3979N/A // PromotionFailureALot for the other collectors. 3979N/A // Records whether G1EvacuationFailureALot should be in effect 3979N/A // Used to record the GC number for interval checking when 3979N/A // determining whether G1EvaucationFailureALot is in effect 3979N/A // Count of the number of evacuations between failures. 3979N/A // Set whether G1EvacuationFailureALot should be in effect 3979N/A // for the current GC (based upon the type of GC and which 3979N/A // command line flags are set); 3979N/A // Return true if it's time to cause an evacuation failure. 3979N/A // Reset the G1EvacuationFailureALot counters. Should be called at 4419N/A // the end of an evacuation pause in which an evacuation failure occurred. 2815N/A // ("Weak") Reference processing support. 4419N/A // G1 has 2 instances of the reference processor class. One 2815N/A // (_ref_processor_cm) handles reference object discovery 2815N/A // and subsequent processing during concurrent marking cycles. 2815N/A // The other (_ref_processor_stw) handles reference object 2815N/A // discovery and processing during full GCs and incremental 2815N/A // During an incremental pause, reference discovery will be 2815N/A // temporarily disabled for _ref_processor_cm and will be 2815N/A // enabled for _ref_processor_stw. At the end of the evacuation 2815N/A // pause references discovered by _ref_processor_stw will be 2815N/A // processed and discovery will be disabled. The previous 2815N/A // setting for reference object discovery for _ref_processor_cm 2815N/A // At the start of marking: 2815N/A // * Discovery by the CM ref processor is verified to be inactive 2815N/A // and it's discovered lists are empty. 2815N/A // * Discovery by the CM ref processor is then enabled. 2815N/A // * Any references on the CM ref processor's discovered 2815N/A // lists are processed (possibly MT). 2815N/A // At the start of full GC we: 2815N/A // * Disable discovery by the CM ref processor and 2815N/A // empty CM ref processor's discovered lists 2815N/A // (without processing any entries). 2815N/A // * Verify that the STW ref processor is inactive and it's 2815N/A // discovered lists are empty. 2815N/A // * Temporarily set STW ref processor discovery as single threaded. 2815N/A // * Temporarily clear the STW ref processor's _is_alive_non_header 2815N/A // * Finally enable discovery by the STW ref processor. 2815N/A // The STW ref processor is used to record any discovered 2815N/A // references during the full GC. 2815N/A // At the end of a full GC we: 2815N/A // * Enqueue any reference objects discovered by the STW ref processor 2815N/A // that have non-live referents. This has the side-effect of 2815N/A // making the STW ref processor inactive by disabling discovery. 2815N/A // * Verify that the CM ref processor is still inactive 2815N/A // and no references have been placed on it's discovered 2815N/A // lists (also checked as a precondition during initial marking). 2815N/A // The (stw) reference processor... 2815N/A // During reference object discovery, the _is_alive_non_header 2815N/A // closure (if non-null) is applied to the referent object to 2815N/A // determine whether the referent is live. If so then the 2815N/A // reference object does not need to be 'discovered' and can 2815N/A // be treated as a regular oop. This has the benefit of reducing 2815N/A // the number of 'discovered' reference objects that need to 2815N/A // Instance of the is_alive closure for embedding into the 2815N/A // STW reference processor as the _is_alive_non_header field. 2815N/A // Supplying a value for the _is_alive_non_header field is 2815N/A // optional but doing so prevents unnecessary additions to 2815N/A // the discovered lists during reference discovery. 2815N/A // The (concurrent marking) reference processor... 1944N/A // Instance of the concurrent mark is_alive closure for embedding 2815N/A // into the Concurrent Marking reference processor as the 2815N/A // _is_alive_non_header field. Supplying a value for the 2815N/A // _is_alive_non_header field is optional but doing so prevents 2815N/A // unnecessary additions to the discovered lists during reference 2985N/A // Cache used by G1CollectedHeap::start_cset_region_for_worker(). 2985N/A // Time stamp to validate the regions recorded in the cache 2985N/A // used by G1CollectedHeap::start_cset_region_for_worker(). 2985N/A // The heap region entry for a given worker is valid iff 2985N/A // the associated time stamp value matches the current value 2985N/A // of G1CollectedHeap::_gc_time_stamp. 342N/A // Leave this one last. 616N/A // A set of cards where updates happened during the GC 1625N/A // A DirtyCardQueueSet that is used to hold cards that contain 1625N/A // references into the current collection set. This is used to 1625N/A // update the remembered sets of the regions in the collection 1625N/A // set in the event of an evacuation failure. 342N/A // Create a G1CollectedHeap with the specified policy. 342N/A // Must call the initialize method afterwards. 342N/A // May not return if something goes wrong. 342N/A // Initialize the G1CollectedHeap to have the initial and 342N/A // maximum sizes, permanent generation, and remembered and barrier sets 342N/A // specified by the policy object. 2815N/A // Initialize weak reference processing. 2941N/A // Done in SharedHeap but oddly there are 2941N/A // two _process_strong_tasks's in a G1CollectedHeap 2941N/A // Set _n_par_threads according to a policy TBD. 342N/A // The current policy object for the collector. 342N/A // Adaptive size policy. No such thing for g1. 342N/A // The rem set and barrier set. 342N/A // The rem set iterator. 2985N/A // Clear the cached CSet starting regions and time stamps. 2985N/A // Their validity is dependent on the GC timestamp. 3920N/A // Reset the given region's GC timestamp. If it's starts humongous, 3920N/A // also reset the GC timestamp of its corresponding 3920N/A // continues humongous regions too. 342N/A // The shared block offset table array. 2815N/A // Reference Processing accessors 2815N/A // The STW reference processor.... 4362N/A // The Concurrent Marking reference processor... 846N/A // This should be called when we're not holding the heap lock. The 846N/A // result might be a bit inaccurate. 342N/A // These virtual functions do the actual allocation. 342N/A // Some heaps may offer a contiguous region for shared non-blocking 342N/A // allocation, via inlined code (by exporting the address of the top and 342N/A // end fields defining the extent of the contiguous allocation region.) 342N/A // But G1CollectedHeap doesn't yet support this. 342N/A // Return an estimate of the maximum allocation that could be performed 342N/A // without triggering any collection or expansion activity. In a 342N/A // generational collector, for example, this is probably the largest 342N/A // allocation that could be supported (without expansion) in the youngest 342N/A // generation. It is "unsafe" because no locks are taken; the result 342N/A // should be treated as an approximation, not a guarantee, for use in 342N/A // heuristic resizing decisions. 342N/A // The total number of regions in the heap. 2591N/A // The max number of regions in the heap. 342N/A // The number of regions that are completely free. 342N/A // The number of regions that are not completely free. 342N/A // The number of regions available for "regular" expansion. 2591N/A // Factory method for HeapRegion instances. It will return NULL if 2037N/A // verify_region_sets() performs verification over the region 2037N/A // lists. It will be compiled in the product code to be used when 2037N/A // necessary (i.e., during heap verification). 2037N/A // verify_region_sets_optional() is planted in the code for 2037N/A // list verification in non-product builds (and it can be enabled in 4419N/A // product builds by defining HEAP_REGION_SET_FORCE_VERIFY to be 1). 2037N/A#
else // HEAP_REGION_SET_FORCE_VERIFY 2037N/A#
endif // HEAP_REGION_SET_FORCE_VERIFY 2037N/A // Wrapper for the region list operations that can be called from 2037N/A // methods outside this class. 2208N/A // If the secondary free list looks empty there's no reason to 2208N/A // take the lock and then try to append it. 3201N/A // Determine whether the given region is one that we are using as an 342N/A // Perform a collection of the heap; intended for use in implementing 342N/A // "System.gc". This probably implies as full a collection as the 342N/A // "CollectedHeap" supports. 342N/A // The same as above but assume that the caller holds the Heap_lock. 342N/A // This interface assumes that it's being called by the 342N/A // vm thread. It collects the heap assuming that the 342N/A // heap lock is already held and that we are executing in 342N/A // the context of the vm thread. 4419N/A // True iff an evacuation has failed in the most-recent collection. 2037N/A // It will free a region if it has allocated objects in it that are 2037N/A // all dead. It calls either free_region() or 2037N/A // free_humongous_region() depending on the type of the region that 2037N/A // It appends the free list to the master free list and updates the 2037N/A // master humongous list according to the contents of the proxy 2037N/A // list. It also adjusts the total used bytes according to pre_used 2037N/A // (if par is true, it will do so by taking the ParGCRareEvent_lock). 2984N/A // Returns "TRUE" iff "p" points into the committed areas of the heap. 342N/A // Return "TRUE" iff the given object address is within the collection 342N/A // Return "TRUE" iff the given object address is in the reserved 342N/A // region of g1 (excluding the permanent generation). 2282N/A // Returns a MemRegion that corresponds to the space that has been 2282N/A // Returns a MemRegion that corresponds to the space that has been 342N/A // committed in the heap 342N/A // This resets the card table to all zeros. It is used after 342N/A // a collection pause which used the card table to claim cards. 342N/A // Iteration functions. 342N/A // Iterate over all the ref-containing fields of all objects, calling 342N/A // "cl.do_oop" on each. 342N/A // Same as above, restricted to a memory region. 342N/A // Iterate over all objects, calling "cl.do_object" on each. 342N/A // Iterate over all objects allocated since the last collection, calling 342N/A // "cl.do_object" on each. The heap must have been initialized properly 342N/A // to support this function, or else this call will fail. 342N/A // Iterate over all spaces in use in the heap, in ascending address order. 342N/A // Iterate over heap regions, in address order, terminating the 342N/A // iteration early if the "doHeapRegion" method returns "true". 2591N/A // Return the region with the given index. It assumes the index is valid. 342N/A // Divide the heap region sequence into "chunks" of some size (the number 342N/A // of regions divided by the number of parallel threads times some 342N/A // overpartition factor, currently 4). Assumes that this will be called 342N/A // in parallel by ParallelGCThreads worker threads with discinct worker 342N/A // ids in the range [0..max(ParallelGCThreads-1, 1)], that all parallel 342N/A // calls will use the same "claim_value", and that that claim value is 342N/A // different from the claim_value of any heap region before the start of 342N/A // the iteration. Applies "blk->doHeapRegion" to each of the regions, by 342N/A // attempting to claim the first region in each chunk, and, if 342N/A // successful, applying the closure to each region in the chunk (and 342N/A // setting the claim value of the second and subsequent regions of the 342N/A // chunk.) For now requires that "doHeapRegion" always returns "false", 342N/A // i.e., that a closure never attempt to abort a traversal. 390N/A // It resets all the region claim values to the default. 3063N/A // Resets the claim values of regions in the current 3063N/A // collection set to the default. 2943N/A // Same as the routine above but only checks regions in the 2985N/A // Clear the cached cset start regions and (more importantly) 2985N/A // the time stamps. Called when we reset the GC time stamp. 2985N/A // Given the id of a worker, obtain or calculate a suitable 2985N/A // starting region for iterating over the current collection set. 3920N/A // This is a convenience method that is used by the 3920N/A // HeapRegionIterator classes to calculate the starting region for 3920N/A // each worker so that they do not all start from the same region. 342N/A // Iterate over the regions (if any) in the current collection set. 342N/A // As above but starting from region r 342N/A // Returns the first (lowest address) compactible space in the heap. 342N/A // A CollectedHeap will contain some number of spaces. This finds the 342N/A // space containing a given address, or else returns NULL. 342N/A // A G1CollectedHeap will contain some number of heap regions. This 342N/A // finds the region containing a given address, or else returns NULL. 342N/A // Like the above, but requires "addr" to be in the heap (to avoid a 342N/A // null-check), and unlike the above, may return an continuing humongous 342N/A // A CollectedHeap is divided into a dense sequence of "blocks"; that is, 342N/A // each address in the (reserved) heap is a member of exactly 342N/A // one block. The defining characteristic of a block is that it is 342N/A // possible to find its size, and thus to progress forward to the next 342N/A // block. (Blocks may be of different sizes.) Thus, blocks may 342N/A // represent Java objects, or they might be free blocks in a 342N/A // free-list-based heap (or subheap), as long as the two kinds are 342N/A // distinguishable and the size of each is determinable. 342N/A // Returns the address of the start of the "block" that contains the 342N/A // address "addr". We say "blocks" instead of "object" since some heaps 342N/A // may not pack objects densely; a chunk may either be an object or a 342N/A // Requires "addr" to be the start of a chunk, and returns its size. 342N/A // "addr + size" is required to be the start of a new chunk, or the end 342N/A // of the active area of the heap. 342N/A // Requires "addr" to be the start of a block, and returns "TRUE" iff 342N/A // the block is an object. 342N/A // Does this heap support heap inspection? (+PrintClassHistogram) 342N/A // Section on thread-local allocation buffers (TLABs) 342N/A // See CollectedHeap for semantics. 342N/A // Can a compiler initialize a new object without store barriers? 342N/A // This permission only extends from the creation of a new object 1027N/A // via a TLAB up to the first subsequent safepoint. If such permission 1027N/A // is granted for this heap type, the compiler promises to call 1027N/A // defer_store_barrier() below on any slow path allocation of 1027N/A // a new object for which such initializing store barriers will 1027N/A // have been elided. G1, like CMS, allows this, but should be 1027N/A // ready to provide a compensating write barrier as necessary 1027N/A // if that storage came out of a non-young region. The efficiency 1027N/A // of this implementation depends crucially on being able to 1027N/A // answer very efficiently in constant time whether a piece of 1027N/A // storage in the heap comes from a young region or not. 1027N/A // See ReduceInitialCardMarks. 1027N/A // We don't need barriers for initializing stores to objects 1027N/A // in the young gen: for the SATB pre-barrier, there is no 1027N/A // pre-value that needs to be remembered; for the remembered-set 1027N/A // update logging post-barrier, we don't maintain remembered set 2695N/A // information for young gen objects. 342N/A // Can a compiler elide a store barrier when it writes 342N/A // a permanent oop into the heap? Applies when the compiler 342N/A // is storing x to the heap, where x->is_perm() is true. 342N/A // At least until perm gen collection is also G1-ified, at 342N/A // which point this should return false. 342N/A // Returns "true" iff the given word_size is "very large". 1313N/A // Note this has to be strictly greater-than as the TLABs 1313N/A // are capped at the humongous thresold and we want to 1313N/A // ensure that we don't try to allocate a TLAB as 1313N/A // humongous and that we don't allocate a humongous 342N/A // Update mod union table with the set of dirty cards. 342N/A // Set the mod union bits corresponding to the given memRegion. Note 342N/A // that this is always a safe operation, since it doesn't clear any 342N/A // Records the fact that a marking phase is no longer in progress. 342N/A // Print the maximum heap capacity. 342N/A // Perform any cleanup actions necessary before allowing a verification. 342N/A // Perform verification. 2597N/A // vo == UsePrevMarking -> use "prev" marking information, 2597N/A // vo == UseNextMarking -> use "next" marking information 2597N/A // vo == UseMarkWord -> use the mark word in the object header 811N/A // NOTE: Only the "prev" marking information is guaranteed to be 811N/A // consistent most of the time, so most calls to this should use 2597N/A // Currently, there is only one case where this is called with 2597N/A // vo == UseNextMarking, which is to verify the "next" marking 2597N/A // information at the end of remark. 2597N/A // Currently there is only one place where this is called with 2597N/A // vo == UseMarkWord, which is to verify the marking during a 811N/A // Override; it uses the "prev" marking information 2602N/A // The following two methods are helpful for debugging RSet issues. 342N/A // Convenience function to be used in situations where the heap type can be 342N/A // asserted to be this type. 342N/A // add appropriate methods for any other surv rate groups 342N/A // *** Stuff related to concurrent marking. It's not clear to me that so 342N/A // many of these need to be public. 342N/A // The functions below are helper functions that a subclass of 342N/A // "CollectedHeap" can use in the implementation of its virtual 342N/A // This performs a concurrent marking of the live objects in a 342N/A // bitmap off to the side. 342N/A // Determine if an object is dead, given the object and also 342N/A // the region to which the object belongs. An object is dead 342N/A // iff a) it was not allocated since the last mark and b) it 342N/A // This function returns true when an object has been 342N/A // around since the previous marking and hasn't yet 342N/A // been marked during this marking. 342N/A // Determine if an object is dead, given only the object itself. 342N/A // This will find the region to which the object belongs and 342N/A // then call the region version of the same function. 342N/A // Added if it is in permanent gen it isn't dead. 342N/A // Added if it is NULL it isn't dead. 3920N/A // The methods below are here for convenience and dispatch the 3920N/A // appropriate method depending on value of the given VerifyOption 3920N/A // parameter. The options for that parameter are: 3920N/A // vo == UsePrevMarking -> use "prev" marking information, 3920N/A // vo == UseNextMarking -> use "next" marking information, 3920N/A // vo == UseMarkWord -> use mark word from object header 3920N/A return false;
// keep some compilers happy 3920N/A return false;
// keep some compilers happy 342N/A // The following is just to alert the verification code 342N/A // that a full collection has occurred and that the 342N/A // remembered sets are no longer up to date. 796N/A // The dirty cards region list is used to record a subset of regions 796N/A // whose cards need clearing. The list if populated during the 796N/A // remembered set scanning and drained during the card table 796N/A // phases must not overlap. For synchronization purposes the last 796N/A // element on the list points to itself. 845N/A // Map from young-age-index (0 == not young, 1 is youngest) to 845N/A // surviving words. base is what we get back from the malloc call 845N/A // this points into the array, as we use the first few entries for padding 845N/A // If the new value of the field points to the same region or 845N/A // is the to-space, we don't need to include it in the Rset updates. 845N/A // If the card hasn't been added to the buffer, do it. 845N/A "should contain whole object");
845N/A // We add on to hide entry 0 which accumulates surviving words for 845N/A // age -1 regions (i.e. non-young ones) 845N/A // Note: we can use "raw" versions of "region_containing" because 845N/A // "obj_to_scan" is definitely in the heap, and is not in a 1879N/A#
endif // SHARE_VM_GC_IMPLEMENTATION_G1_G1COLLECTEDHEAP_HPP