24
25 #include "precompiled.hpp"
26 #include "aot/aotLoader.hpp"
27 #include "classfile/classLoader.hpp"
28 #include "classfile/classLoaderData.hpp"
29 #include "classfile/javaClasses.hpp"
30 #include "classfile/stringTable.hpp"
31 #include "classfile/systemDictionary.hpp"
32 #include "classfile/vmSymbols.hpp"
33 #include "code/codeCache.hpp"
34 #include "code/dependencies.hpp"
35 #include "gc/shared/cardTableModRefBS.hpp"
36 #include "gc/shared/collectedHeap.inline.hpp"
37 #include "gc/shared/gcLocker.inline.hpp"
38 #include "gc/shared/genCollectedHeap.hpp"
39 #include "gc/shared/generation.hpp"
40 #include "gc/shared/gcTraceTime.inline.hpp"
41 #include "gc/shared/space.hpp"
42 #include "interpreter/interpreter.hpp"
43 #include "logging/log.hpp"
44 #include "memory/filemap.hpp"
45 #include "memory/metadataFactory.hpp"
46 #include "memory/metaspaceShared.hpp"
47 #include "memory/oopFactory.hpp"
48 #include "memory/resourceArea.hpp"
49 #include "memory/universe.hpp"
50 #include "memory/universe.inline.hpp"
51 #include "oops/constantPool.hpp"
52 #include "oops/instanceClassLoaderKlass.hpp"
53 #include "oops/instanceKlass.hpp"
54 #include "oops/instanceMirrorKlass.hpp"
55 #include "oops/instanceRefKlass.hpp"
56 #include "oops/objArrayOop.inline.hpp"
57 #include "oops/oop.inline.hpp"
58 #include "oops/typeArrayKlass.hpp"
59 #include "prims/resolvedMethodTable.hpp"
60 #include "runtime/arguments.hpp"
61 #include "runtime/atomic.hpp"
62 #include "runtime/commandLineFlagConstraintList.hpp"
63 #include "runtime/deoptimization.hpp"
745
746 #ifdef _LP64
747 if (UseCompressedOops) {
748 // Subtract a page because something can get allocated at heap base.
749 // This also makes implicit null checking work, because the
750 // memory+1 page below heap_base needs to cause a signal.
751 // See needs_explicit_null_check.
752 // Only set the heap base for compressed oops because it indicates
753 // compressed oops for pstack code.
754 if ((uint64_t)Universe::heap()->reserved_region().end() > UnscaledOopHeapMax) {
755 // Didn't reserve heap below 4Gb. Must shift.
756 Universe::set_narrow_oop_shift(LogMinObjAlignmentInBytes);
757 }
758 if ((uint64_t)Universe::heap()->reserved_region().end() <= OopEncodingHeapMax) {
759 // Did reserve heap below 32Gb. Can use base == 0;
760 Universe::set_narrow_oop_base(0);
761 }
762
763 Universe::set_narrow_ptrs_base(Universe::narrow_oop_base());
764
765 if (log_is_enabled(Info, gc, heap, coops)) {
766 ResourceMark rm;
767 outputStream* logst = Log(gc, heap, coops)::info_stream();
768 Universe::print_compressed_oops_mode(logst);
769 }
770
771 // Tell tests in which mode we run.
772 Arguments::PropertyList_add(new SystemProperty("java.vm.compressedOopsMode",
773 narrow_oop_mode_to_string(narrow_oop_mode()),
774 false));
775 }
776 // Universe::narrow_oop_base() is one page below the heap.
777 assert((intptr_t)Universe::narrow_oop_base() <= (intptr_t)(Universe::heap()->base() -
778 os::vm_page_size()) ||
779 Universe::narrow_oop_base() == NULL, "invalid value");
780 assert(Universe::narrow_oop_shift() == LogMinObjAlignmentInBytes ||
781 Universe::narrow_oop_shift() == 0, "invalid value");
782 #endif
783
784 // We will never reach the CATCH below since Exceptions::_throw will cause
785 // the VM to exit if an exception is thrown during initialization
786
787 if (UseTLAB) {
788 assert(Universe::heap()->supports_tlab_allocation(),
1081
1082 void Universe::compute_base_vtable_size() {
1083 _base_vtable_size = ClassLoader::compute_Object_vtable();
1084 }
1085
1086 void Universe::print_on(outputStream* st) {
1087 GCMutexLocker hl(Heap_lock); // Heap_lock might be locked by caller thread.
1088 st->print_cr("Heap");
1089 heap()->print_on(st);
1090 }
1091
1092 void Universe::print_heap_at_SIGBREAK() {
1093 if (PrintHeapAtSIGBREAK) {
1094 print_on(tty);
1095 tty->cr();
1096 tty->flush();
1097 }
1098 }
1099
1100 void Universe::print_heap_before_gc() {
1101 Log(gc, heap) log;
1102 if (log.is_debug()) {
1103 log.debug("Heap before GC invocations=%u (full %u):", heap()->total_collections(), heap()->total_full_collections());
1104 ResourceMark rm;
1105 heap()->print_on(log.debug_stream());
1106 }
1107 }
1108
1109 void Universe::print_heap_after_gc() {
1110 Log(gc, heap) log;
1111 if (log.is_debug()) {
1112 log.debug("Heap after GC invocations=%u (full %u):", heap()->total_collections(), heap()->total_full_collections());
1113 ResourceMark rm;
1114 heap()->print_on(log.debug_stream());
1115 }
1116 }
1117
1118 void Universe::initialize_verify_flags() {
1119 verify_flags = 0;
1120 const char delimiter[] = " ,";
1121
1122 size_t length = strlen(VerifySubSet);
1123 char* subset_list = NEW_C_HEAP_ARRAY(char, length + 1, mtInternal);
1124 strncpy(subset_list, VerifySubSet, length + 1);
1125
1126 char* token = strtok(subset_list, delimiter);
1127 while (token != NULL) {
1128 if (strcmp(token, "threads") == 0) {
1129 verify_flags |= Verify_Threads;
1130 } else if (strcmp(token, "heap") == 0) {
1131 verify_flags |= Verify_Heap;
1132 } else if (strcmp(token, "symbol_table") == 0) {
1133 verify_flags |= Verify_SymbolTable;
1134 } else if (strcmp(token, "string_table") == 0) {
|
24
25 #include "precompiled.hpp"
26 #include "aot/aotLoader.hpp"
27 #include "classfile/classLoader.hpp"
28 #include "classfile/classLoaderData.hpp"
29 #include "classfile/javaClasses.hpp"
30 #include "classfile/stringTable.hpp"
31 #include "classfile/systemDictionary.hpp"
32 #include "classfile/vmSymbols.hpp"
33 #include "code/codeCache.hpp"
34 #include "code/dependencies.hpp"
35 #include "gc/shared/cardTableModRefBS.hpp"
36 #include "gc/shared/collectedHeap.inline.hpp"
37 #include "gc/shared/gcLocker.inline.hpp"
38 #include "gc/shared/genCollectedHeap.hpp"
39 #include "gc/shared/generation.hpp"
40 #include "gc/shared/gcTraceTime.inline.hpp"
41 #include "gc/shared/space.hpp"
42 #include "interpreter/interpreter.hpp"
43 #include "logging/log.hpp"
44 #include "logging/logStream.hpp"
45 #include "memory/filemap.hpp"
46 #include "memory/metadataFactory.hpp"
47 #include "memory/metaspaceShared.hpp"
48 #include "memory/oopFactory.hpp"
49 #include "memory/resourceArea.hpp"
50 #include "memory/universe.hpp"
51 #include "memory/universe.inline.hpp"
52 #include "oops/constantPool.hpp"
53 #include "oops/instanceClassLoaderKlass.hpp"
54 #include "oops/instanceKlass.hpp"
55 #include "oops/instanceMirrorKlass.hpp"
56 #include "oops/instanceRefKlass.hpp"
57 #include "oops/objArrayOop.inline.hpp"
58 #include "oops/oop.inline.hpp"
59 #include "oops/typeArrayKlass.hpp"
60 #include "prims/resolvedMethodTable.hpp"
61 #include "runtime/arguments.hpp"
62 #include "runtime/atomic.hpp"
63 #include "runtime/commandLineFlagConstraintList.hpp"
64 #include "runtime/deoptimization.hpp"
746
747 #ifdef _LP64
748 if (UseCompressedOops) {
749 // Subtract a page because something can get allocated at heap base.
750 // This also makes implicit null checking work, because the
751 // memory+1 page below heap_base needs to cause a signal.
752 // See needs_explicit_null_check.
753 // Only set the heap base for compressed oops because it indicates
754 // compressed oops for pstack code.
755 if ((uint64_t)Universe::heap()->reserved_region().end() > UnscaledOopHeapMax) {
756 // Didn't reserve heap below 4Gb. Must shift.
757 Universe::set_narrow_oop_shift(LogMinObjAlignmentInBytes);
758 }
759 if ((uint64_t)Universe::heap()->reserved_region().end() <= OopEncodingHeapMax) {
760 // Did reserve heap below 32Gb. Can use base == 0;
761 Universe::set_narrow_oop_base(0);
762 }
763
764 Universe::set_narrow_ptrs_base(Universe::narrow_oop_base());
765
766 LogTarget(Info, gc, heap, coops) lt;
767 if (lt.is_enabled()) {
768 ResourceMark rm;
769 LogStream ls(lt);
770 Universe::print_compressed_oops_mode(&ls);
771 }
772
773 // Tell tests in which mode we run.
774 Arguments::PropertyList_add(new SystemProperty("java.vm.compressedOopsMode",
775 narrow_oop_mode_to_string(narrow_oop_mode()),
776 false));
777 }
778 // Universe::narrow_oop_base() is one page below the heap.
779 assert((intptr_t)Universe::narrow_oop_base() <= (intptr_t)(Universe::heap()->base() -
780 os::vm_page_size()) ||
781 Universe::narrow_oop_base() == NULL, "invalid value");
782 assert(Universe::narrow_oop_shift() == LogMinObjAlignmentInBytes ||
783 Universe::narrow_oop_shift() == 0, "invalid value");
784 #endif
785
786 // We will never reach the CATCH below since Exceptions::_throw will cause
787 // the VM to exit if an exception is thrown during initialization
788
789 if (UseTLAB) {
790 assert(Universe::heap()->supports_tlab_allocation(),
1083
1084 void Universe::compute_base_vtable_size() {
1085 _base_vtable_size = ClassLoader::compute_Object_vtable();
1086 }
1087
1088 void Universe::print_on(outputStream* st) {
1089 GCMutexLocker hl(Heap_lock); // Heap_lock might be locked by caller thread.
1090 st->print_cr("Heap");
1091 heap()->print_on(st);
1092 }
1093
1094 void Universe::print_heap_at_SIGBREAK() {
1095 if (PrintHeapAtSIGBREAK) {
1096 print_on(tty);
1097 tty->cr();
1098 tty->flush();
1099 }
1100 }
1101
1102 void Universe::print_heap_before_gc() {
1103 LogTarget(Debug, gc, heap) lt;
1104 if (lt.is_enabled()) {
1105 LogStream ls(lt);
1106 ls.print("Heap before GC invocations=%u (full %u):", heap()->total_collections(), heap()->total_full_collections());
1107 ResourceMark rm;
1108 heap()->print_on(&ls);
1109 }
1110 }
1111
1112 void Universe::print_heap_after_gc() {
1113 LogTarget(Debug, gc, heap) lt;
1114 if (lt.is_enabled()) {
1115 LogStream ls(lt);
1116 ls.print("Heap after GC invocations=%u (full %u):", heap()->total_collections(), heap()->total_full_collections());
1117 ResourceMark rm;
1118 heap()->print_on(&ls);
1119 }
1120 }
1121
1122 void Universe::initialize_verify_flags() {
1123 verify_flags = 0;
1124 const char delimiter[] = " ,";
1125
1126 size_t length = strlen(VerifySubSet);
1127 char* subset_list = NEW_C_HEAP_ARRAY(char, length + 1, mtInternal);
1128 strncpy(subset_list, VerifySubSet, length + 1);
1129
1130 char* token = strtok(subset_list, delimiter);
1131 while (token != NULL) {
1132 if (strcmp(token, "threads") == 0) {
1133 verify_flags |= Verify_Threads;
1134 } else if (strcmp(token, "heap") == 0) {
1135 verify_flags |= Verify_Heap;
1136 } else if (strcmp(token, "symbol_table") == 0) {
1137 verify_flags |= Verify_SymbolTable;
1138 } else if (strcmp(token, "string_table") == 0) {
|