compactingPermGenGen.cpp revision 2062
1879N/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. 1472N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 47N/A// An ObjectClosure helper: Recursively adjust all pointers in an object 47N/A// and all objects by referenced it. Clear marks on objects in order to 47N/A// prevent visiting any object twice. This helper is used when the 47N/A// RedefineClasses() API has been called. 47N/A// An OopClosure helper: Recursively adjust all pointers in an object 47N/A// and all objects by referenced it. Clear marks on objects in order 47N/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. 0N/A// We need to go through all placeholders in the system dictionary and 0N/A// try to resolve them into shared classes. Other threads might be in 0N/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 0N/A// but will not be unmarked during the application of the 2062N/A// RecursiveAdjustSharedObjectClosure to the SystemDictionary. 0N/A // Generation Counters - generation 2, 1 subspace 0N/A // Break virtual space into address ranges for all spaces. 0N/A // Verify shared and unshared spaces adjacent. 0N/A // Split reserved memory into pieces. 0N/A // Allocate the unshared (default) space. 0N/A " CompactingPermGen Space");
0N/A // Allocate shared spaces 0N/A // If mapping a shared file, the space is not committed, don't 0N/A // Commit the memory behind the shared spaces if dumping (not 0N/A // Allocate the shared spaces. 0N/A // Restore mangling flag. 0N/A // Cover both shared spaces entirely with cards. 0N/A // Map in the regions in the shared file. 0N/A // check the alignment constraints 0N/A // Base addresses didn't match; skip sharing, but continue 0N/A // If -Xshare:on is specified, print out the error message and exit VM, 0N/A // otherwise, set UseSharedSpaces to false and continue. 0N/A // Note: freeing the block offset array objects does not 0N/A // currently free up the underlying storage. 0N/A // Reserved region includes shared spaces for oop.is_in_reserved(). 0N/A// Do a complete scan of the shared read write space to catch all 0N/A// objects which contain references to any younger generation. Forward 0N/A// the pointers. Avoid space_iterate, as actually visiting all the 0N/A// objects in the space will page in more objects than we need. 0N/A// Instead, use the system dictionary as strong roots into the read 47N/A// If a RedefineClasses() call has been made, then we have to iterate 47N/A// over the entire shared read-write space in order to find all the 47N/A// objects that need to be forwarded. For example, it is possible for 47N/A// an nmethod to be found and marked in GC phase-1 only for the nmethod 47N/A// to be freed by the time we reach GC phase-3. The underlying method 47N/A// is still marked, but we can't (easily) find it in GC phase-3 so we 47N/A// blow up in GC phase-4. With RedefineClasses() we want replaced code 47N/A// (EMCP or obsolete) to go away (i.e., be collectible) once it is no 47N/A// longer being executed by any thread so we keep minimal attachments 47N/A// to the replaced code. However, we can't guarantee when those EMCP 47N/A// or obsolete methods will be collected so they may still be out there 47N/A// even after we've severed our minimal attachments. 47N/A // RedefineClasses() requires a brute force approach 0N/A "Shared oop still marked?");
1051N/A// Do not use in time-critical operations due to the possibility of paging 1051N/A// in otherwise untouched or previously unread portions of the perm gen, 1051N/A// for instance, the shared spaces. NOTE: Because CompactingPermGenGen 1051N/A// derives from OneContigSpaceCardGeneration which is supposed to have a 1051N/A// single space, and does not override its object_iterate() method, 1051N/A// object iteration via that interface does not look at the objects in 1051N/A// the shared spaces when using CDS. This should be fixed; see CR 6897798. 0N/A // Making the rw_space walkable will page in the entire space, and 1051N/A // is to be avoided in the case of time-critical operations. 1051N/A // However, this is required for Verify and heap dump operations. 0N/A// References from the perm gen to the younger generation objects may 0N/A// occur in static fields in Java classes or in constant pool references 0N/A// to String objects. 0N/A // ro_space has no younger gen refs. 0N/A// Shared spaces are addressed in pre_adjust_pointers. 0N/A // Don't include shared spaces. 0N/A // Don't include shared spaces. 0N/A "If not used, the size of shared spaces should be 0");
0N/A// No young generation references, clear this generation's main space's 0N/A// card table entries. Do NOT clear the card table entries for the 0N/A// read-only space (always clear) or the read-write space (valuable 0N/A// Objects in this generation's main space may have moved, invalidate 0N/A// that space's cards. Do NOT invalidate the card table entries for the 0N/A// read-only or read-write spaces, as those objects never move. 0N/A // remap the shared readonly space to shared readwrite, private