Sat, 01 Sep 2012 13:25:18 -0400
6964458: Reimplement class meta-data storage to use native memory
Summary: Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
Contributed-by: jmasa <jon.masamitsu@oracle.com>, stefank <stefan.karlsson@oracle.com>, mgerdin <mikael.gerdin@oracle.com>, never <tom.rodriguez@oracle.com>
coleenp@4037 | 1 | /* |
coleenp@4037 | 2 | * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. |
coleenp@4037 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
coleenp@4037 | 4 | * |
coleenp@4037 | 5 | * This code is free software; you can redistribute it and/or modify it |
coleenp@4037 | 6 | * under the terms of the GNU General Public License version 2 only, as |
coleenp@4037 | 7 | * published by the Free Software Foundation. |
coleenp@4037 | 8 | * |
coleenp@4037 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
coleenp@4037 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
coleenp@4037 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
coleenp@4037 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
coleenp@4037 | 13 | * accompanied this code). |
coleenp@4037 | 14 | * |
coleenp@4037 | 15 | * You should have received a copy of the GNU General Public License version |
coleenp@4037 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
coleenp@4037 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
coleenp@4037 | 18 | * |
coleenp@4037 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
coleenp@4037 | 20 | * or visit www.oracle.com if you need additional information or have any |
coleenp@4037 | 21 | * questions. |
coleenp@4037 | 22 | * |
coleenp@4037 | 23 | */ |
coleenp@4037 | 24 | #ifndef SHARE_VM_MEMORY_METASPACE_SHARED_HPP |
coleenp@4037 | 25 | #define SHARE_VM_MEMORY_METASPACE_SHARED_HPP |
coleenp@4037 | 26 | |
coleenp@4037 | 27 | #include "memory/allocation.hpp" |
coleenp@4037 | 28 | #include "memory/memRegion.hpp" |
coleenp@4037 | 29 | #include "runtime/virtualspace.hpp" |
coleenp@4037 | 30 | #include "utilities/exceptions.hpp" |
coleenp@4037 | 31 | #include "utilities/macros.hpp" |
coleenp@4037 | 32 | |
coleenp@4037 | 33 | class FileMapInfo; |
coleenp@4037 | 34 | |
coleenp@4037 | 35 | // Class Data Sharing Support |
coleenp@4037 | 36 | class MetaspaceShared : AllStatic { |
coleenp@4037 | 37 | |
coleenp@4037 | 38 | // CDS support |
coleenp@4037 | 39 | static ReservedSpace* _shared_rs; |
coleenp@4037 | 40 | static int _max_alignment; |
coleenp@4037 | 41 | |
coleenp@4037 | 42 | public: |
coleenp@4037 | 43 | enum { |
coleenp@4037 | 44 | vtbl_list_size = 17, // number of entries in the shared space vtable list. |
coleenp@4037 | 45 | num_virtuals = 200 // maximum number of virtual functions |
coleenp@4037 | 46 | // If virtual functions are added to Metadata, |
coleenp@4037 | 47 | // this number needs to be increased. Also, |
coleenp@4037 | 48 | // SharedMiscCodeSize will need to be increased. |
coleenp@4037 | 49 | }; |
coleenp@4037 | 50 | |
coleenp@4037 | 51 | enum { |
coleenp@4037 | 52 | ro = 0, // read-only shared space in the heap |
coleenp@4037 | 53 | rw = 1, // read-write shared space in the heap |
coleenp@4037 | 54 | md = 2, // miscellaneous data for initializing tables, etc. |
coleenp@4037 | 55 | mc = 3, // miscellaneous code - vtable replacement. |
coleenp@4037 | 56 | n_regions = 4 |
coleenp@4037 | 57 | }; |
coleenp@4037 | 58 | |
coleenp@4037 | 59 | static void set_max_alignment(int alignment) KERNEL_RETURN; |
coleenp@4037 | 60 | static int max_alignment() KERNEL_RETURN_(0); |
coleenp@4037 | 61 | |
coleenp@4037 | 62 | static void preload_and_dump(TRAPS) KERNEL_RETURN; |
coleenp@4037 | 63 | static ReservedSpace* shared_rs(); |
coleenp@4037 | 64 | static void set_shared_rs(ReservedSpace* rs) KERNEL_RETURN; |
coleenp@4037 | 65 | |
coleenp@4037 | 66 | static bool map_shared_spaces(FileMapInfo* mapinfo) KERNEL_RETURN_(false); |
coleenp@4037 | 67 | static void initialize_shared_spaces() KERNEL_RETURN; |
coleenp@4037 | 68 | |
coleenp@4037 | 69 | // Return true if given address is in the mapped shared space. |
coleenp@4037 | 70 | static bool is_in_shared_space(const void* p) KERNEL_RETURN_(false); |
coleenp@4037 | 71 | |
coleenp@4037 | 72 | static void generate_vtable_methods(void** vtbl_list, |
coleenp@4037 | 73 | void** vtable, |
coleenp@4037 | 74 | char** md_top, char* md_end, |
coleenp@4037 | 75 | char** mc_top, char* mc_end); |
coleenp@4037 | 76 | static void serialize(SerializeClosure* sc); |
coleenp@4037 | 77 | |
coleenp@4037 | 78 | // JVM/TI RedefineClasses() support: |
coleenp@4037 | 79 | // Remap the shared readonly space to shared readwrite, private if |
coleenp@4037 | 80 | // sharing is enabled. Simply returns true if sharing is not enabled |
coleenp@4037 | 81 | // or if the remapping has already been done by a prior call. |
coleenp@4037 | 82 | static bool remap_shared_readonly_as_readwrite() KERNEL_RETURN_(true); |
coleenp@4037 | 83 | |
coleenp@4037 | 84 | static void print_shared_spaces(); |
coleenp@4037 | 85 | }; |
coleenp@4037 | 86 | #endif // SHARE_VM_MEMORY_METASPACE_SHARED_HPP |