compactingPermGenGen.cpp revision 1879
2581N/A * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 0N/A * published by the Free Software Foundation. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 0N/A// An ObjectClosure helper: Recursively adjust all pointers in an object 176N/A// and all objects by referenced it. Clear marks on objects in order to 647N/A// prevent visiting any object twice. This helper is used when the 0N/A// RedefineClasses() API has been called. 0N/A// An OopClosure helper: Recursively adjust all pointers in an object 0N/A// and all objects by referenced it. Clear marks on objects in order 0N/A// to prevent visiting any object twice. 0N/A // Special case: if a class has a read-only constant pool, 0N/A // then the read-write objects referenced by the pool must 0N/A // have their marks reset. 647N/A// We need to go through all placeholders in the system dictionary and 647N/A// try to resolve them into shared classes. Other threads might be in 647N/A// the process of loading a shared class and have strong roots on 0N/A// their stack to the class without having added the class to the 0N/A// dictionary yet. This means the class will be marked during phase 1 647N/A// but will not be unmarked during the application of the 0N/A// RecursiveAdjustSharedObjectClosure to the SystemDictionary. Note 0N/A// that we must not call find_shared_class with non-read-only symbols 0N/A// as doing so can cause hash codes to be computed, destroying 0N/A// forwarding pointers. 647N/A // Generation Counters - generation 2, 1 subspace 647N/A // Break virtual space into address ranges for all spaces. 647N/A // Verify shared and unshared spaces adjacent. 647N/A // Split reserved memory into pieces. 647N/A // Allocate the unshared (default) space. 647N/A " CompactingPermGen Space");
647N/A // Allocate shared spaces 647N/A // If mapping a shared file, the space is not committed, don't 647N/A // Commit the memory behind the shared spaces if dumping (not 2581N/A // Allocate the shared spaces. 647N/A // Restore mangling flag. 667N/A // Cover both shared spaces entirely with cards. 667N/A // Map in the regions in the shared file. 647N/A // check the alignment constraints 647N/A // Base addresses didn't match; skip sharing, but continue 647N/A // If -Xshare:on is specified, print out the error message and exit VM, 647N/A // otherwise, set UseSharedSpaces to false and continue. 647N/A // Note: freeing the block offset array objects does not 647N/A // currently free up the underlying storage. 653N/A // Reserved region includes shared spaces for oop.is_in_reserved(). 647N/A// Do a complete scan of the shared read write space to catch all 647N/A// objects which contain references to any younger generation. Forward 647N/A// the pointers. Avoid space_iterate, as actually visiting all the 647N/A// objects in the space will page in more objects than we need. 647N/A// Instead, use the system dictionary as strong roots into the read 647N/A// If a RedefineClasses() call has been made, then we have to iterate 647N/A// over the entire shared read-write space in order to find all the 647N/A// objects that need to be forwarded. For example, it is possible for 647N/A// an nmethod to be found and marked in GC phase-1 only for the nmethod 647N/A// to be freed by the time we reach GC phase-3. The underlying method 647N/A// is still marked, but we can't (easily) find it in GC phase-3 so we 647N/A// blow up in GC phase-4. With RedefineClasses() we want replaced code 653N/A// (EMCP or obsolete) to go away (i.e., be collectible) once it is no 653N/A// longer being executed by any thread so we keep minimal attachments 653N/A// to the replaced code. However, we can't guarantee when those EMCP 653N/A// or obsolete methods will be collected so they may still be out there 653N/A// even after we've severed our minimal attachments. 2922N/A // RedefineClasses() requires a brute force approach 2922N/A "Shared oop still marked?");
// Do not use in time-critical operations due to the possibility of paging // in otherwise untouched or previously unread portions of the perm gen, // for instance, the shared spaces. NOTE: Because CompactingPermGenGen // derives from OneContigSpaceCardGeneration which is supposed to have a // single space, and does not override its object_iterate() method, // object iteration via that interface does not look at the objects in // the shared spaces when using CDS. This should be fixed; see CR 6897798. // Making the rw_space walkable will page in the entire space, and // is to be avoided in the case of time-critical operations. // However, this is required for Verify and heap dump operations. // References from the perm gen to the younger generation objects may // occur in static fields in Java classes or in constant pool references // ro_space has no younger gen refs. // Shared spaces are addressed in pre_adjust_pointers. // Don't include shared spaces. // Don't include shared spaces. "If not used, the size of shared spaces should be 0");
// No young generation references, clear this generation's main space's // card table entries. Do NOT clear the card table entries for the // read-only space (always clear) or the read-write space (valuable // Objects in this generation's main space may have moved, invalidate // that space's cards. Do NOT invalidate the card table entries for the // read-only or read-write spaces, as those objects never move. // JVM/TI RedefineClasses() support: // remap the shared readonly space to shared readwrite, private