18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "jvm.h"
27 #include "classfile/classListParser.hpp"
28 #include "classfile/classLoaderExt.hpp"
29 #include "classfile/dictionary.hpp"
30 #include "classfile/loaderConstraints.hpp"
31 #include "classfile/placeholders.hpp"
32 #include "classfile/sharedClassUtil.hpp"
33 #include "classfile/symbolTable.hpp"
34 #include "classfile/stringTable.hpp"
35 #include "classfile/systemDictionary.hpp"
36 #include "classfile/systemDictionaryShared.hpp"
37 #include "code/codeCache.hpp"
38 #if INCLUDE_ALL_GCS
39 #include "gc/g1/g1Allocator.inline.hpp"
40 #include "gc/g1/g1CollectedHeap.hpp"
41 #endif
42 #include "gc/shared/gcLocker.hpp"
43 #include "interpreter/bytecodeStream.hpp"
44 #include "interpreter/bytecodes.hpp"
45 #include "logging/log.hpp"
46 #include "logging/logMessage.hpp"
47 #include "memory/filemap.hpp"
48 #include "memory/metaspace.hpp"
49 #include "memory/metaspaceClosure.hpp"
50 #include "memory/metaspaceShared.hpp"
51 #include "memory/resourceArea.hpp"
52 #include "oops/instanceClassLoaderKlass.hpp"
53 #include "oops/instanceMirrorKlass.hpp"
54 #include "oops/instanceRefKlass.hpp"
55 #include "oops/objArrayKlass.hpp"
56 #include "oops/objArrayOop.hpp"
57 #include "oops/oop.inline.hpp"
58 #include "oops/typeArrayKlass.hpp"
59 #include "prims/jvmtiRedefineClasses.hpp"
60 #include "runtime/handles.inline.hpp"
61 #include "runtime/os.hpp"
62 #include "runtime/signature.hpp"
63 #include "runtime/timerTrace.hpp"
64 #include "runtime/vmThread.hpp"
65 #include "runtime/vm_operations.hpp"
66 #include "utilities/align.hpp"
67 #include "utilities/defaultStream.hpp"
68 #include "utilities/hashtable.inline.hpp"
69
70 ReservedSpace MetaspaceShared::_shared_rs;
71 VirtualSpace MetaspaceShared::_shared_vs;
72 MetaspaceSharedStats MetaspaceShared::_stats;
73 bool MetaspaceShared::_has_error_classes;
74 bool MetaspaceShared::_archive_loading_failed = false;
75 bool MetaspaceShared::_remapped_readwrite = false;
76 bool MetaspaceShared::_open_archive_heap_region_mapped = false;
77 address MetaspaceShared::_cds_i2i_entry_code_buffers = NULL;
78 size_t MetaspaceShared::_cds_i2i_entry_code_buffers_size = 0;
79 size_t MetaspaceShared::_core_spaces_size = 0;
80
81 // The CDS archive is divided into the following regions:
82 // mc - misc code (the method entry trampolines)
83 // rw - read-write metadata
84 // ro - read-only metadata and read-only tables
85 // md - misc data (the c++ vtables)
86 // od - optional data (original class files)
87 //
88 // s0 - shared strings(closed archive heap space) #0
827 void do_ptr(void** p) {
828 _dump_region->append_intptr_t((intptr_t)*p);
829 }
830
831 void do_u4(u4* p) {
832 void* ptr = (void*)(uintx(*p));
833 do_ptr(&ptr);
834 }
835
836 void do_tag(int tag) {
837 _dump_region->append_intptr_t((intptr_t)tag);
838 }
839
840 void do_oop(oop* o) {
841 if (*o == NULL) {
842 _dump_region->append_intptr_t(0);
843 } else {
844 assert(MetaspaceShared::is_heap_object_archiving_allowed(),
845 "Archiving heap object is not allowed");
846 _dump_region->append_intptr_t(
847 (intptr_t)oopDesc::encode_heap_oop_not_null(*o));
848 }
849 }
850
851 void do_region(u_char* start, size_t size) {
852 assert((intptr_t)start % sizeof(intptr_t) == 0, "bad alignment");
853 assert(size % sizeof(intptr_t) == 0, "bad size");
854 do_tag((int)size);
855 while (size > 0) {
856 _dump_region->append_intptr_t(*(intptr_t*)start);
857 start += sizeof(intptr_t);
858 size -= sizeof(intptr_t);
859 }
860 }
861
862 bool reading() const { return false; }
863 };
864
865 // This is for dumping detailed statistics for the allocations
866 // in the shared spaces.
867 class DumpAllocStats : public ResourceObj {
1919 *p = (u4)(uintx(obj));
1920 }
1921
1922 void do_tag(int tag) {
1923 int old_tag;
1924 old_tag = (int)(intptr_t)nextPtr();
1925 // do_int(&old_tag);
1926 assert(tag == old_tag, "old tag doesn't match");
1927 FileMapInfo::assert_mark(tag == old_tag);
1928 }
1929
1930 void do_oop(oop *p) {
1931 narrowOop o = (narrowOop)nextPtr();
1932 if (o == 0 || !MetaspaceShared::open_archive_heap_region_mapped()) {
1933 p = NULL;
1934 } else {
1935 assert(MetaspaceShared::is_heap_object_archiving_allowed(),
1936 "Archived heap object is not allowed");
1937 assert(MetaspaceShared::open_archive_heap_region_mapped(),
1938 "Open archive heap region is not mapped");
1939 RootAccess<IN_ARCHIVE_ROOT>::oop_store(p, oopDesc::decode_heap_oop_not_null(o));
1940 }
1941 }
1942
1943 void do_region(u_char* start, size_t size) {
1944 assert((intptr_t)start % sizeof(intptr_t) == 0, "bad alignment");
1945 assert(size % sizeof(intptr_t) == 0, "bad size");
1946 do_tag((int)size);
1947 while (size > 0) {
1948 *(intptr_t*)start = nextPtr();
1949 start += sizeof(intptr_t);
1950 size -= sizeof(intptr_t);
1951 }
1952 }
1953
1954 bool reading() const { return true; }
1955 };
1956
1957 // Return true if given address is in the misc data region
1958 bool MetaspaceShared::is_in_shared_region(const void* p, int idx) {
1959 return UseSharedSpaces && FileMapInfo::current_info()->is_in_shared_region(p, idx);
|
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "jvm.h"
27 #include "classfile/classListParser.hpp"
28 #include "classfile/classLoaderExt.hpp"
29 #include "classfile/dictionary.hpp"
30 #include "classfile/loaderConstraints.hpp"
31 #include "classfile/placeholders.hpp"
32 #include "classfile/sharedClassUtil.hpp"
33 #include "classfile/symbolTable.hpp"
34 #include "classfile/stringTable.hpp"
35 #include "classfile/systemDictionary.hpp"
36 #include "classfile/systemDictionaryShared.hpp"
37 #include "code/codeCache.hpp"
38 #include "gc/shared/gcLocker.hpp"
39 #include "interpreter/bytecodeStream.hpp"
40 #include "interpreter/bytecodes.hpp"
41 #include "logging/log.hpp"
42 #include "logging/logMessage.hpp"
43 #include "memory/filemap.hpp"
44 #include "memory/metaspace.hpp"
45 #include "memory/metaspaceClosure.hpp"
46 #include "memory/metaspaceShared.hpp"
47 #include "memory/resourceArea.hpp"
48 #include "oops/compressedOops.inline.hpp"
49 #include "oops/instanceClassLoaderKlass.hpp"
50 #include "oops/instanceMirrorKlass.hpp"
51 #include "oops/instanceRefKlass.hpp"
52 #include "oops/objArrayKlass.hpp"
53 #include "oops/objArrayOop.hpp"
54 #include "oops/oop.inline.hpp"
55 #include "oops/typeArrayKlass.hpp"
56 #include "prims/jvmtiRedefineClasses.hpp"
57 #include "runtime/handles.inline.hpp"
58 #include "runtime/os.hpp"
59 #include "runtime/signature.hpp"
60 #include "runtime/timerTrace.hpp"
61 #include "runtime/vmThread.hpp"
62 #include "runtime/vm_operations.hpp"
63 #include "utilities/align.hpp"
64 #include "utilities/defaultStream.hpp"
65 #include "utilities/hashtable.inline.hpp"
66 #if INCLUDE_ALL_GCS
67 #include "gc/g1/g1Allocator.inline.hpp"
68 #include "gc/g1/g1CollectedHeap.hpp"
69 #endif
70
71 ReservedSpace MetaspaceShared::_shared_rs;
72 VirtualSpace MetaspaceShared::_shared_vs;
73 MetaspaceSharedStats MetaspaceShared::_stats;
74 bool MetaspaceShared::_has_error_classes;
75 bool MetaspaceShared::_archive_loading_failed = false;
76 bool MetaspaceShared::_remapped_readwrite = false;
77 bool MetaspaceShared::_open_archive_heap_region_mapped = false;
78 address MetaspaceShared::_cds_i2i_entry_code_buffers = NULL;
79 size_t MetaspaceShared::_cds_i2i_entry_code_buffers_size = 0;
80 size_t MetaspaceShared::_core_spaces_size = 0;
81
82 // The CDS archive is divided into the following regions:
83 // mc - misc code (the method entry trampolines)
84 // rw - read-write metadata
85 // ro - read-only metadata and read-only tables
86 // md - misc data (the c++ vtables)
87 // od - optional data (original class files)
88 //
89 // s0 - shared strings(closed archive heap space) #0
828 void do_ptr(void** p) {
829 _dump_region->append_intptr_t((intptr_t)*p);
830 }
831
832 void do_u4(u4* p) {
833 void* ptr = (void*)(uintx(*p));
834 do_ptr(&ptr);
835 }
836
837 void do_tag(int tag) {
838 _dump_region->append_intptr_t((intptr_t)tag);
839 }
840
841 void do_oop(oop* o) {
842 if (*o == NULL) {
843 _dump_region->append_intptr_t(0);
844 } else {
845 assert(MetaspaceShared::is_heap_object_archiving_allowed(),
846 "Archiving heap object is not allowed");
847 _dump_region->append_intptr_t(
848 (intptr_t)CompressedOops::encode_not_null(*o));
849 }
850 }
851
852 void do_region(u_char* start, size_t size) {
853 assert((intptr_t)start % sizeof(intptr_t) == 0, "bad alignment");
854 assert(size % sizeof(intptr_t) == 0, "bad size");
855 do_tag((int)size);
856 while (size > 0) {
857 _dump_region->append_intptr_t(*(intptr_t*)start);
858 start += sizeof(intptr_t);
859 size -= sizeof(intptr_t);
860 }
861 }
862
863 bool reading() const { return false; }
864 };
865
866 // This is for dumping detailed statistics for the allocations
867 // in the shared spaces.
868 class DumpAllocStats : public ResourceObj {
1920 *p = (u4)(uintx(obj));
1921 }
1922
1923 void do_tag(int tag) {
1924 int old_tag;
1925 old_tag = (int)(intptr_t)nextPtr();
1926 // do_int(&old_tag);
1927 assert(tag == old_tag, "old tag doesn't match");
1928 FileMapInfo::assert_mark(tag == old_tag);
1929 }
1930
1931 void do_oop(oop *p) {
1932 narrowOop o = (narrowOop)nextPtr();
1933 if (o == 0 || !MetaspaceShared::open_archive_heap_region_mapped()) {
1934 p = NULL;
1935 } else {
1936 assert(MetaspaceShared::is_heap_object_archiving_allowed(),
1937 "Archived heap object is not allowed");
1938 assert(MetaspaceShared::open_archive_heap_region_mapped(),
1939 "Open archive heap region is not mapped");
1940 RootAccess<IN_ARCHIVE_ROOT>::oop_store(p, CompressedOops::decode(o));
1941 }
1942 }
1943
1944 void do_region(u_char* start, size_t size) {
1945 assert((intptr_t)start % sizeof(intptr_t) == 0, "bad alignment");
1946 assert(size % sizeof(intptr_t) == 0, "bad size");
1947 do_tag((int)size);
1948 while (size > 0) {
1949 *(intptr_t*)start = nextPtr();
1950 start += sizeof(intptr_t);
1951 size -= sizeof(intptr_t);
1952 }
1953 }
1954
1955 bool reading() const { return true; }
1956 };
1957
1958 // Return true if given address is in the misc data region
1959 bool MetaspaceShared::is_in_shared_region(const void* p, int idx) {
1960 return UseSharedSpaces && FileMapInfo::current_info()->is_in_shared_region(p, idx);
|