coleenp@4037: /* coleenp@4037: * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. coleenp@4037: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. coleenp@4037: * coleenp@4037: * This code is free software; you can redistribute it and/or modify it coleenp@4037: * under the terms of the GNU General Public License version 2 only, as coleenp@4037: * published by the Free Software Foundation. coleenp@4037: * coleenp@4037: * This code is distributed in the hope that it will be useful, but WITHOUT coleenp@4037: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or coleenp@4037: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License coleenp@4037: * version 2 for more details (a copy is included in the LICENSE file that coleenp@4037: * accompanied this code). coleenp@4037: * coleenp@4037: * You should have received a copy of the GNU General Public License version coleenp@4037: * 2 along with this work; if not, write to the Free Software Foundation, coleenp@4037: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. coleenp@4037: * coleenp@4037: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA coleenp@4037: * or visit www.oracle.com if you need additional information or have any coleenp@4037: * questions. coleenp@4037: * coleenp@4037: */ coleenp@4037: #ifndef SHARE_VM_MEMORY_METASPACE_SHARED_HPP coleenp@4037: #define SHARE_VM_MEMORY_METASPACE_SHARED_HPP coleenp@4037: coleenp@4037: #include "memory/allocation.hpp" coleenp@4037: #include "memory/memRegion.hpp" coleenp@4037: #include "runtime/virtualspace.hpp" coleenp@4037: #include "utilities/exceptions.hpp" coleenp@4037: #include "utilities/macros.hpp" coleenp@4037: coleenp@4037: class FileMapInfo; coleenp@4037: coleenp@4037: // Class Data Sharing Support coleenp@4037: class MetaspaceShared : AllStatic { coleenp@4037: coleenp@4037: // CDS support coleenp@4037: static ReservedSpace* _shared_rs; coleenp@4037: static int _max_alignment; coleenp@4037: coleenp@4037: public: coleenp@4037: enum { coleenp@4037: vtbl_list_size = 17, // number of entries in the shared space vtable list. coleenp@4037: num_virtuals = 200 // maximum number of virtual functions coleenp@4037: // If virtual functions are added to Metadata, coleenp@4037: // this number needs to be increased. Also, coleenp@4037: // SharedMiscCodeSize will need to be increased. coleenp@4037: }; coleenp@4037: coleenp@4037: enum { coleenp@4037: ro = 0, // read-only shared space in the heap coleenp@4037: rw = 1, // read-write shared space in the heap coleenp@4037: md = 2, // miscellaneous data for initializing tables, etc. coleenp@4037: mc = 3, // miscellaneous code - vtable replacement. coleenp@4037: n_regions = 4 coleenp@4037: }; coleenp@4037: jprovino@4165: // Accessor functions to save shared space created for metadata, which has jprovino@4165: // extra space allocated at the end for miscellaneous data and code. jprovino@4165: static void set_max_alignment(int alignment) { jprovino@4165: CDS_ONLY(_max_alignment = alignment); jprovino@4165: } coleenp@4037: jprovino@4165: static int max_alignment() { jprovino@4165: CDS_ONLY(return _max_alignment); jprovino@4165: NOT_CDS(return 0); jprovino@4165: } coleenp@4037: jprovino@4165: static void preload_and_dump(TRAPS) NOT_CDS_RETURN; jprovino@4165: jprovino@4165: static ReservedSpace* shared_rs() { jprovino@4165: CDS_ONLY(return _shared_rs); jprovino@4165: NOT_CDS(return NULL); jprovino@4165: } jprovino@4165: jprovino@4165: static void set_shared_rs(ReservedSpace* rs) { jprovino@4165: CDS_ONLY(_shared_rs = rs;) jprovino@4165: } jprovino@4165: jprovino@4165: static bool map_shared_spaces(FileMapInfo* mapinfo) NOT_CDS_RETURN_(false); jprovino@4165: static void initialize_shared_spaces() NOT_CDS_RETURN; coleenp@4037: coleenp@4037: // Return true if given address is in the mapped shared space. jprovino@4165: static bool is_in_shared_space(const void* p) NOT_CDS_RETURN_(false); coleenp@4037: coleenp@4037: static void generate_vtable_methods(void** vtbl_list, coleenp@4037: void** vtable, coleenp@4037: char** md_top, char* md_end, coleenp@4037: char** mc_top, char* mc_end); coleenp@4037: static void serialize(SerializeClosure* sc); coleenp@4037: coleenp@4037: // JVM/TI RedefineClasses() support: coleenp@4037: // Remap the shared readonly space to shared readwrite, private if coleenp@4037: // sharing is enabled. Simply returns true if sharing is not enabled coleenp@4037: // or if the remapping has already been done by a prior call. jprovino@4165: static bool remap_shared_readonly_as_readwrite() NOT_CDS_RETURN_(true); coleenp@4037: coleenp@4037: static void print_shared_spaces(); coleenp@4037: }; coleenp@4037: #endif // SHARE_VM_MEMORY_METASPACE_SHARED_HPP