1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/share/vm/memory/metaspaceShared.hpp Wed Apr 27 01:25:04 2016 +0800 1.3 @@ -0,0 +1,101 @@ 1.4 +/* 1.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. 1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.7 + * 1.8 + * This code is free software; you can redistribute it and/or modify it 1.9 + * under the terms of the GNU General Public License version 2 only, as 1.10 + * published by the Free Software Foundation. 1.11 + * 1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.15 + * version 2 for more details (a copy is included in the LICENSE file that 1.16 + * accompanied this code). 1.17 + * 1.18 + * You should have received a copy of the GNU General Public License version 1.19 + * 2 along with this work; if not, write to the Free Software Foundation, 1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.21 + * 1.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 1.23 + * or visit www.oracle.com if you need additional information or have any 1.24 + * questions. 1.25 + * 1.26 + */ 1.27 +#ifndef SHARE_VM_MEMORY_METASPACE_SHARED_HPP 1.28 +#define SHARE_VM_MEMORY_METASPACE_SHARED_HPP 1.29 + 1.30 +#include "memory/allocation.hpp" 1.31 +#include "memory/memRegion.hpp" 1.32 +#include "runtime/virtualspace.hpp" 1.33 +#include "utilities/exceptions.hpp" 1.34 +#include "utilities/macros.hpp" 1.35 + 1.36 +class FileMapInfo; 1.37 + 1.38 +// Class Data Sharing Support 1.39 +class MetaspaceShared : AllStatic { 1.40 + 1.41 + // CDS support 1.42 + static ReservedSpace* _shared_rs; 1.43 + static int _max_alignment; 1.44 + 1.45 + public: 1.46 + enum { 1.47 + vtbl_list_size = 17, // number of entries in the shared space vtable list. 1.48 + num_virtuals = 200 // maximum number of virtual functions 1.49 + // If virtual functions are added to Metadata, 1.50 + // this number needs to be increased. Also, 1.51 + // SharedMiscCodeSize will need to be increased. 1.52 + }; 1.53 + 1.54 + enum { 1.55 + ro = 0, // read-only shared space in the heap 1.56 + rw = 1, // read-write shared space in the heap 1.57 + md = 2, // miscellaneous data for initializing tables, etc. 1.58 + mc = 3, // miscellaneous code - vtable replacement. 1.59 + n_regions = 4 1.60 + }; 1.61 + 1.62 + // Accessor functions to save shared space created for metadata, which has 1.63 + // extra space allocated at the end for miscellaneous data and code. 1.64 + static void set_max_alignment(int alignment) { 1.65 + CDS_ONLY(_max_alignment = alignment); 1.66 + } 1.67 + 1.68 + static int max_alignment() { 1.69 + CDS_ONLY(return _max_alignment); 1.70 + NOT_CDS(return 0); 1.71 + } 1.72 + 1.73 + static void preload_and_dump(TRAPS) NOT_CDS_RETURN; 1.74 + 1.75 + static ReservedSpace* shared_rs() { 1.76 + CDS_ONLY(return _shared_rs); 1.77 + NOT_CDS(return NULL); 1.78 + } 1.79 + 1.80 + static void set_shared_rs(ReservedSpace* rs) { 1.81 + CDS_ONLY(_shared_rs = rs;) 1.82 + } 1.83 + 1.84 + static bool map_shared_spaces(FileMapInfo* mapinfo) NOT_CDS_RETURN_(false); 1.85 + static void initialize_shared_spaces() NOT_CDS_RETURN; 1.86 + 1.87 + // Return true if given address is in the mapped shared space. 1.88 + static bool is_in_shared_space(const void* p) NOT_CDS_RETURN_(false); 1.89 + 1.90 + static void generate_vtable_methods(void** vtbl_list, 1.91 + void** vtable, 1.92 + char** md_top, char* md_end, 1.93 + char** mc_top, char* mc_end); 1.94 + static void serialize(SerializeClosure* sc); 1.95 + 1.96 + // JVM/TI RedefineClasses() support: 1.97 + // Remap the shared readonly space to shared readwrite, private if 1.98 + // sharing is enabled. Simply returns true if sharing is not enabled 1.99 + // or if the remapping has already been done by a prior call. 1.100 + static bool remap_shared_readonly_as_readwrite() NOT_CDS_RETURN_(true); 1.101 + 1.102 + static void print_shared_spaces(); 1.103 +}; 1.104 +#endif // SHARE_VM_MEMORY_METASPACE_SHARED_HPP