Mon, 12 Aug 2019 18:30:40 +0300
8223147: JFR Backport
8199712: Flight Recorder
8203346: JFR: Inconsistent signature of jfr_add_string_constant
8195817: JFR.stop should require name of recording
8195818: JFR.start should increase autogenerated name by one
8195819: Remove recording=x from jcmd JFR.check output
8203921: JFR thread sampling is missing fixes from JDK-8194552
8203929: Limit amount of data for JFR.dump
8203664: JFR start failure after AppCDS archive created with JFR StartFlightRecording
8003209: JFR events for network utilization
8207392: [PPC64] Implement JFR profiling
8202835: jfr/event/os/TestSystemProcess.java fails on missing events
Summary: Backport JFR from JDK11. Initial integration
Reviewed-by: neugens
coleenp@4037 | 1 | /* |
jiangli@8509 | 2 | * Copyright (c) 2012, 2016, 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 | |
ccheung@7103 | 33 | #define LargeSharedArchiveSize (300*M) |
ccheung@7103 | 34 | #define HugeSharedArchiveSize (800*M) |
iklam@7322 | 35 | #define ReadOnlyRegionPercentage 0.39 |
iklam@7322 | 36 | #define ReadWriteRegionPercentage 0.50 |
iklam@7322 | 37 | #define MiscDataRegionPercentage 0.09 |
ccheung@7103 | 38 | #define MiscCodeRegionPercentage 0.02 |
ccheung@7103 | 39 | #define LargeThresholdClassCount 5000 |
ccheung@7103 | 40 | #define HugeThresholdClassCount 40000 |
ccheung@7103 | 41 | |
ccheung@7103 | 42 | #define SET_ESTIMATED_SIZE(type, region) \ |
ccheung@7103 | 43 | Shared ##region## Size = FLAG_IS_DEFAULT(Shared ##region## Size) ? \ |
ccheung@7104 | 44 | (uintx)(type ## SharedArchiveSize * region ## RegionPercentage) : Shared ## region ## Size |
ccheung@7103 | 45 | |
coleenp@4037 | 46 | class FileMapInfo; |
coleenp@4037 | 47 | |
coleenp@4037 | 48 | // Class Data Sharing Support |
coleenp@4037 | 49 | class MetaspaceShared : AllStatic { |
coleenp@4037 | 50 | |
coleenp@4037 | 51 | // CDS support |
coleenp@4037 | 52 | static ReservedSpace* _shared_rs; |
coleenp@4037 | 53 | static int _max_alignment; |
iklam@7089 | 54 | static bool _link_classes_made_progress; |
iklam@7089 | 55 | static bool _check_classes_made_progress; |
iklam@7089 | 56 | static bool _has_error_classes; |
iklam@7089 | 57 | static bool _archive_loading_failed; |
jiangli@8509 | 58 | static bool _remapped_readwrite; |
coleenp@4037 | 59 | public: |
coleenp@4037 | 60 | enum { |
ccheung@7300 | 61 | vtbl_list_size = 17, // number of entries in the shared space vtable list. |
ccheung@7300 | 62 | num_virtuals = 200, // maximum number of virtual functions |
ccheung@7300 | 63 | // If virtual functions are added to Metadata, |
ccheung@7300 | 64 | // this number needs to be increased. Also, |
ccheung@7300 | 65 | // SharedMiscCodeSize will need to be increased. |
ccheung@7300 | 66 | // The following 2 sizes were based on |
ccheung@7300 | 67 | // MetaspaceShared::generate_vtable_methods() |
ccheung@7300 | 68 | vtbl_method_size = 16, // conservative size of the mov1 and jmp instructions |
ccheung@7300 | 69 | // for the x64 platform |
ccheung@7300 | 70 | vtbl_common_code_size = (1*K) // conservative size of the "common_code" for the x64 platform |
coleenp@4037 | 71 | }; |
coleenp@4037 | 72 | |
coleenp@4037 | 73 | enum { |
coleenp@4037 | 74 | ro = 0, // read-only shared space in the heap |
coleenp@4037 | 75 | rw = 1, // read-write shared space in the heap |
coleenp@4037 | 76 | md = 2, // miscellaneous data for initializing tables, etc. |
coleenp@4037 | 77 | mc = 3, // miscellaneous code - vtable replacement. |
coleenp@4037 | 78 | n_regions = 4 |
coleenp@4037 | 79 | }; |
coleenp@4037 | 80 | |
jprovino@4165 | 81 | // Accessor functions to save shared space created for metadata, which has |
jprovino@4165 | 82 | // extra space allocated at the end for miscellaneous data and code. |
jprovino@4165 | 83 | static void set_max_alignment(int alignment) { |
jprovino@4165 | 84 | CDS_ONLY(_max_alignment = alignment); |
jprovino@4165 | 85 | } |
coleenp@4037 | 86 | |
jprovino@4165 | 87 | static int max_alignment() { |
jprovino@4165 | 88 | CDS_ONLY(return _max_alignment); |
jprovino@4165 | 89 | NOT_CDS(return 0); |
jprovino@4165 | 90 | } |
coleenp@4037 | 91 | |
iklam@7089 | 92 | static void prepare_for_dumping() NOT_CDS_RETURN; |
jprovino@4165 | 93 | static void preload_and_dump(TRAPS) NOT_CDS_RETURN; |
iklam@7089 | 94 | static int preload_and_dump(const char * class_list_path, |
iklam@7089 | 95 | GrowableArray<Klass*>* class_promote_order, |
iklam@7089 | 96 | TRAPS) NOT_CDS_RETURN; |
jprovino@4165 | 97 | |
jprovino@4165 | 98 | static ReservedSpace* shared_rs() { |
jprovino@4165 | 99 | CDS_ONLY(return _shared_rs); |
jprovino@4165 | 100 | NOT_CDS(return NULL); |
jprovino@4165 | 101 | } |
jprovino@4165 | 102 | |
jprovino@4165 | 103 | static void set_shared_rs(ReservedSpace* rs) { |
jprovino@4165 | 104 | CDS_ONLY(_shared_rs = rs;) |
jprovino@4165 | 105 | } |
jprovino@4165 | 106 | |
iklam@7089 | 107 | static void set_archive_loading_failed() { |
iklam@7089 | 108 | _archive_loading_failed = true; |
iklam@7089 | 109 | } |
jprovino@4165 | 110 | static bool map_shared_spaces(FileMapInfo* mapinfo) NOT_CDS_RETURN_(false); |
jprovino@4165 | 111 | static void initialize_shared_spaces() NOT_CDS_RETURN; |
coleenp@4037 | 112 | |
coleenp@4037 | 113 | // Return true if given address is in the mapped shared space. |
jprovino@4165 | 114 | static bool is_in_shared_space(const void* p) NOT_CDS_RETURN_(false); |
coleenp@4037 | 115 | |
coleenp@4037 | 116 | static void generate_vtable_methods(void** vtbl_list, |
coleenp@4037 | 117 | void** vtable, |
coleenp@4037 | 118 | char** md_top, char* md_end, |
coleenp@4037 | 119 | char** mc_top, char* mc_end); |
coleenp@4037 | 120 | static void serialize(SerializeClosure* sc); |
coleenp@4037 | 121 | |
coleenp@4037 | 122 | // JVM/TI RedefineClasses() support: |
coleenp@4037 | 123 | // Remap the shared readonly space to shared readwrite, private if |
coleenp@4037 | 124 | // sharing is enabled. Simply returns true if sharing is not enabled |
coleenp@4037 | 125 | // or if the remapping has already been done by a prior call. |
jprovino@4165 | 126 | static bool remap_shared_readonly_as_readwrite() NOT_CDS_RETURN_(true); |
jiangli@8509 | 127 | static bool remapped_readwrite() { |
jiangli@8509 | 128 | CDS_ONLY(return _remapped_readwrite); |
jiangli@8509 | 129 | NOT_CDS(return false); |
jiangli@8509 | 130 | } |
coleenp@4037 | 131 | |
coleenp@4037 | 132 | static void print_shared_spaces(); |
iklam@7089 | 133 | |
iklam@7089 | 134 | static bool try_link_class(InstanceKlass* ik, TRAPS); |
iklam@7089 | 135 | static void link_one_shared_class(Klass* obj, TRAPS); |
iklam@7089 | 136 | static void check_one_shared_class(Klass* obj); |
iklam@7089 | 137 | static void link_and_cleanup_shared_classes(TRAPS); |
ccheung@7103 | 138 | |
ccheung@7103 | 139 | static int count_class(const char* classlist_file); |
ccheung@7103 | 140 | static void estimate_regions_size() NOT_CDS_RETURN; |
coleenp@4037 | 141 | }; |
coleenp@4037 | 142 | #endif // SHARE_VM_MEMORY_METASPACE_SHARED_HPP |