Bug Summary

File:jdk/src/hotspot/share/memory/universe.cpp
Warning:line 1217, column 19
Called C++ object pointer is null

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -triple x86_64-pc-linux-gnu -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name universe.cpp -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -mthread-model posix -fno-delete-null-pointer-checks -mframe-pointer=all -relaxed-aliasing -fmath-errno -fno-rounding-math -masm-verbose -mconstructor-aliases -munwind-tables -target-cpu x86-64 -dwarf-column-info -fno-split-dwarf-inlining -debugger-tuning=gdb -resource-dir /usr/lib/llvm-10/lib/clang/10.0.0 -I /home/daniel/Projects/java/jdk/build/linux-x86_64-server-fastdebug/hotspot/variant-server/libjvm/objs/precompiled -D __STDC_FORMAT_MACROS -D __STDC_LIMIT_MACROS -D __STDC_CONSTANT_MACROS -D _GNU_SOURCE -D _REENTRANT -D LIBC=gnu -D LINUX -D VM_LITTLE_ENDIAN -D _LP64=1 -D ASSERT -D CHECK_UNHANDLED_OOPS -D TARGET_ARCH_x86 -D INCLUDE_SUFFIX_OS=_linux -D INCLUDE_SUFFIX_CPU=_x86 -D INCLUDE_SUFFIX_COMPILER=_gcc -D TARGET_COMPILER_gcc -D AMD64 -D HOTSPOT_LIB_ARCH="amd64" -D COMPILER1 -D COMPILER2 -I /home/daniel/Projects/java/jdk/build/linux-x86_64-server-fastdebug/hotspot/variant-server/gensrc/adfiles -I /home/daniel/Projects/java/jdk/src/hotspot/share -I /home/daniel/Projects/java/jdk/src/hotspot/os/linux -I /home/daniel/Projects/java/jdk/src/hotspot/os/posix -I /home/daniel/Projects/java/jdk/src/hotspot/cpu/x86 -I /home/daniel/Projects/java/jdk/src/hotspot/os_cpu/linux_x86 -I /home/daniel/Projects/java/jdk/build/linux-x86_64-server-fastdebug/hotspot/variant-server/gensrc -I /home/daniel/Projects/java/jdk/src/hotspot/share/precompiled -I /home/daniel/Projects/java/jdk/src/hotspot/share/include -I /home/daniel/Projects/java/jdk/src/hotspot/os/posix/include -I /home/daniel/Projects/java/jdk/build/linux-x86_64-server-fastdebug/support/modules_include/java.base -I /home/daniel/Projects/java/jdk/build/linux-x86_64-server-fastdebug/support/modules_include/java.base/linux -I /home/daniel/Projects/java/jdk/src/java.base/share/native/libjimage -I /home/daniel/Projects/java/jdk/build/linux-x86_64-server-fastdebug/hotspot/variant-server/gensrc/adfiles -I /home/daniel/Projects/java/jdk/src/hotspot/share -I /home/daniel/Projects/java/jdk/src/hotspot/os/linux -I /home/daniel/Projects/java/jdk/src/hotspot/os/posix -I /home/daniel/Projects/java/jdk/src/hotspot/cpu/x86 -I /home/daniel/Projects/java/jdk/src/hotspot/os_cpu/linux_x86 -I /home/daniel/Projects/java/jdk/build/linux-x86_64-server-fastdebug/hotspot/variant-server/gensrc -D _FORTIFY_SOURCE=2 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/c++/7.5.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/x86_64-linux-gnu/c++/7.5.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/x86_64-linux-gnu/c++/7.5.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/c++/7.5.0/backward -internal-isystem /usr/local/include -internal-isystem /usr/lib/llvm-10/lib/clang/10.0.0/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -O3 -Wno-format-zero-length -Wno-unused-parameter -Wno-unused -Wno-parentheses -Wno-comment -Wno-unknown-pragmas -Wno-address -Wno-delete-non-virtual-dtor -Wno-char-subscripts -Wno-array-bounds -Wno-int-in-bool-context -Wno-ignored-qualifiers -Wno-missing-field-initializers -Wno-implicit-fallthrough -Wno-empty-body -Wno-strict-overflow -Wno-sequence-point -Wno-maybe-uninitialized -Wno-misleading-indentation -Wno-cast-function-type -Wno-shift-negative-value -std=c++14 -fdeprecated-macro -fdebug-compilation-dir /home/daniel/Projects/java/jdk/make/hotspot -ferror-limit 19 -fmessage-length 0 -fvisibility hidden -stack-protector 1 -fno-rtti -fgnuc-version=4.2.1 -fobjc-runtime=gcc -fdiagnostics-show-option -vectorize-loops -vectorize-slp -analyzer-output=html -faddrsig -o /home/daniel/Projects/java/scan/2021-12-21-193737-8510-1 -x c++ /home/daniel/Projects/java/jdk/src/hotspot/share/memory/universe.cpp
1/*
2 * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
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 "cds/dynamicArchive.hpp"
27#include "cds/heapShared.hpp"
28#include "cds/metaspaceShared.hpp"
29#include "classfile/classLoader.hpp"
30#include "classfile/classLoaderDataGraph.hpp"
31#include "classfile/javaClasses.hpp"
32#include "classfile/stringTable.hpp"
33#include "classfile/symbolTable.hpp"
34#include "classfile/systemDictionary.hpp"
35#include "classfile/vmClasses.hpp"
36#include "classfile/vmSymbols.hpp"
37#include "code/codeBehaviours.hpp"
38#include "code/codeCache.hpp"
39#include "compiler/oopMap.hpp"
40#include "gc/shared/collectedHeap.inline.hpp"
41#include "gc/shared/gcArguments.hpp"
42#include "gc/shared/gcConfig.hpp"
43#include "gc/shared/gcLogPrecious.hpp"
44#include "gc/shared/gcTraceTime.inline.hpp"
45#include "gc/shared/oopStorageSet.hpp"
46#include "gc/shared/stringdedup/stringDedup.hpp"
47#include "gc/shared/tlab_globals.hpp"
48#include "logging/log.hpp"
49#include "logging/logStream.hpp"
50#include "memory/metadataFactory.hpp"
51#include "memory/metaspaceClosure.hpp"
52#include "memory/metaspaceCounters.hpp"
53#include "memory/metaspaceUtils.hpp"
54#include "memory/oopFactory.hpp"
55#include "memory/resourceArea.hpp"
56#include "memory/universe.hpp"
57#include "oops/compressedOops.hpp"
58#include "oops/instanceKlass.hpp"
59#include "oops/instanceMirrorKlass.hpp"
60#include "oops/klass.inline.hpp"
61#include "oops/objArrayOop.inline.hpp"
62#include "oops/oop.inline.hpp"
63#include "oops/oopHandle.inline.hpp"
64#include "oops/typeArrayKlass.hpp"
65#include "prims/resolvedMethodTable.hpp"
66#include "runtime/arguments.hpp"
67#include "runtime/atomic.hpp"
68#include "runtime/flags/jvmFlagLimit.hpp"
69#include "runtime/handles.inline.hpp"
70#include "runtime/init.hpp"
71#include "runtime/java.hpp"
72#include "runtime/jniHandles.hpp"
73#include "runtime/thread.inline.hpp"
74#include "runtime/timerTrace.hpp"
75#include "services/memoryService.hpp"
76#include "utilities/align.hpp"
77#include "utilities/autoRestore.hpp"
78#include "utilities/debug.hpp"
79#include "utilities/formatBuffer.hpp"
80#include "utilities/macros.hpp"
81#include "utilities/ostream.hpp"
82#include "utilities/preserveException.hpp"
83
84// Known objects
85Klass* Universe::_typeArrayKlassObjs[T_LONG+1] = { NULL__null /*, NULL...*/ };
86Klass* Universe::_objectArrayKlassObj = NULL__null;
87OopHandle Universe::_mirrors[T_VOID+1];
88
89OopHandle Universe::_main_thread_group;
90OopHandle Universe::_system_thread_group;
91OopHandle Universe::_the_empty_class_array;
92OopHandle Universe::_the_null_string;
93OopHandle Universe::_the_min_jint_string;
94
95OopHandle Universe::_the_null_sentinel;
96
97// _out_of_memory_errors is an objArray
98enum OutOfMemoryInstance { _oom_java_heap,
99 _oom_c_heap,
100 _oom_metaspace,
101 _oom_class_metaspace,
102 _oom_array_size,
103 _oom_gc_overhead_limit,
104 _oom_realloc_objects,
105 _oom_retry,
106 _oom_count };
107
108OopHandle Universe::_out_of_memory_errors;
109OopHandle Universe::_delayed_stack_overflow_error_message;
110OopHandle Universe::_preallocated_out_of_memory_error_array;
111volatile jint Universe::_preallocated_out_of_memory_error_avail_count = 0;
112
113OopHandle Universe::_null_ptr_exception_instance;
114OopHandle Universe::_arithmetic_exception_instance;
115OopHandle Universe::_virtual_machine_error_instance;
116
117OopHandle Universe::_reference_pending_list;
118
119Array<Klass*>* Universe::_the_array_interfaces_array = NULL__null;
120LatestMethodCache* Universe::_finalizer_register_cache = NULL__null;
121LatestMethodCache* Universe::_loader_addClass_cache = NULL__null;
122LatestMethodCache* Universe::_throw_illegal_access_error_cache = NULL__null;
123LatestMethodCache* Universe::_throw_no_such_method_error_cache = NULL__null;
124LatestMethodCache* Universe::_do_stack_walk_cache = NULL__null;
125
126long Universe::verify_flags = Universe::Verify_All;
127
128Array<int>* Universe::_the_empty_int_array = NULL__null;
129Array<u2>* Universe::_the_empty_short_array = NULL__null;
130Array<Klass*>* Universe::_the_empty_klass_array = NULL__null;
131Array<InstanceKlass*>* Universe::_the_empty_instance_klass_array = NULL__null;
132Array<Method*>* Universe::_the_empty_method_array = NULL__null;
133
134// These variables are guarded by FullGCALot_lock.
135debug_only(OopHandle Universe::_fullgc_alot_dummy_array;)OopHandle Universe::_fullgc_alot_dummy_array;
136debug_only(int Universe::_fullgc_alot_dummy_next = 0;)int Universe::_fullgc_alot_dummy_next = 0;
137
138// Heap
139int Universe::_verify_count = 0;
140
141// Oop verification (see MacroAssembler::verify_oop)
142uintptr_t Universe::_verify_oop_mask = 0;
143uintptr_t Universe::_verify_oop_bits = (uintptr_t) -1;
144
145int Universe::_base_vtable_size = 0;
146bool Universe::_bootstrapping = false;
147bool Universe::_module_initialized = false;
148bool Universe::_fully_initialized = false;
149
150OopStorage* Universe::_vm_weak = NULL__null;
151OopStorage* Universe::_vm_global = NULL__null;
152
153CollectedHeap* Universe::_collectedHeap = NULL__null;
154
155objArrayOop Universe::the_empty_class_array () {
156 return (objArrayOop)_the_empty_class_array.resolve();
157}
158
159oop Universe::main_thread_group() { return _main_thread_group.resolve(); }
160void Universe::set_main_thread_group(oop group) { _main_thread_group = OopHandle(vm_global(), group); }
161
162oop Universe::system_thread_group() { return _system_thread_group.resolve(); }
163void Universe::set_system_thread_group(oop group) { _system_thread_group = OopHandle(vm_global(), group); }
164
165oop Universe::the_null_string() { return _the_null_string.resolve(); }
166oop Universe::the_min_jint_string() { return _the_min_jint_string.resolve(); }
167
168oop Universe::null_ptr_exception_instance() { return _null_ptr_exception_instance.resolve(); }
169oop Universe::arithmetic_exception_instance() { return _arithmetic_exception_instance.resolve(); }
170oop Universe::virtual_machine_error_instance() { return _virtual_machine_error_instance.resolve(); }
171
172oop Universe::the_null_sentinel() { return _the_null_sentinel.resolve(); }
173
174oop Universe::int_mirror() { return check_mirror(_mirrors[T_INT].resolve()); }
175oop Universe::float_mirror() { return check_mirror(_mirrors[T_FLOAT].resolve()); }
176oop Universe::double_mirror() { return check_mirror(_mirrors[T_DOUBLE].resolve()); }
177oop Universe::byte_mirror() { return check_mirror(_mirrors[T_BYTE].resolve()); }
178oop Universe::bool_mirror() { return check_mirror(_mirrors[T_BOOLEAN].resolve()); }
179oop Universe::char_mirror() { return check_mirror(_mirrors[T_CHAR].resolve()); }
180oop Universe::long_mirror() { return check_mirror(_mirrors[T_LONG].resolve()); }
181oop Universe::short_mirror() { return check_mirror(_mirrors[T_SHORT].resolve()); }
182oop Universe::void_mirror() { return check_mirror(_mirrors[T_VOID].resolve()); }
183
184oop Universe::java_mirror(BasicType t) {
185 assert((uint)t < T_VOID+1, "range check")do { if (!((uint)t < T_VOID+1)) { (*g_assert_poison) = 'X'
;; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/memory/universe.cpp"
, 185, "assert(" "(uint)t < T_VOID+1" ") failed", "range check"
); ::breakpoint(); } } while (0)
;
186 return check_mirror(_mirrors[t].resolve());
187}
188
189// Used by CDS dumping
190void Universe::replace_mirror(BasicType t, oop new_mirror) {
191 Universe::_mirrors[t].replace(new_mirror);
192}
193
194void Universe::basic_type_classes_do(void f(Klass*)) {
195 for (int i = T_BOOLEAN; i < T_LONG+1; i++) {
196 f(_typeArrayKlassObjs[i]);
197 }
198}
199
200void Universe::basic_type_classes_do(KlassClosure *closure) {
201 for (int i = T_BOOLEAN; i < T_LONG+1; i++) {
202 closure->do_klass(_typeArrayKlassObjs[i]);
203 }
204}
205
206void LatestMethodCache::metaspace_pointers_do(MetaspaceClosure* it) {
207 it->push(&_klass);
208}
209
210void Universe::metaspace_pointers_do(MetaspaceClosure* it) {
211 for (int i = 0; i < T_LONG+1; i++) {
212 it->push(&_typeArrayKlassObjs[i]);
213 }
214 it->push(&_objectArrayKlassObj);
215
216 it->push(&_the_empty_int_array);
217 it->push(&_the_empty_short_array);
218 it->push(&_the_empty_klass_array);
219 it->push(&_the_empty_instance_klass_array);
220 it->push(&_the_empty_method_array);
221 it->push(&_the_array_interfaces_array);
222
223 _finalizer_register_cache->metaspace_pointers_do(it);
224 _loader_addClass_cache->metaspace_pointers_do(it);
225 _throw_illegal_access_error_cache->metaspace_pointers_do(it);
226 _throw_no_such_method_error_cache->metaspace_pointers_do(it);
227 _do_stack_walk_cache->metaspace_pointers_do(it);
228}
229
230// Serialize metadata and pointers to primitive type mirrors in and out of CDS archive
231void Universe::serialize(SerializeClosure* f) {
232
233#if INCLUDE_CDS_JAVA_HEAP1
234 {
235 oop mirror_oop;
236 for (int i = T_BOOLEAN; i < T_VOID+1; i++) {
237 if (f->reading()) {
238 f->do_oop(&mirror_oop); // read from archive
239 assert(oopDesc::is_oop_or_null(mirror_oop), "is oop")do { if (!(oopDesc::is_oop_or_null(mirror_oop))) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/memory/universe.cpp"
, 239, "assert(" "oopDesc::is_oop_or_null(mirror_oop)" ") failed"
, "is oop"); ::breakpoint(); } } while (0)
;
240 // Only create an OopHandle for non-null mirrors
241 if (mirror_oop != NULL__null) {
242 _mirrors[i] = OopHandle(vm_global(), mirror_oop);
243 }
244 } else {
245 if (HeapShared::can_write()) {
246 mirror_oop = _mirrors[i].resolve();
247 } else {
248 mirror_oop = NULL__null;
249 }
250 f->do_oop(&mirror_oop); // write to archive
251 }
252 if (mirror_oop != NULL__null) { // may be null if archived heap is disabled
253 java_lang_Class::update_archived_primitive_mirror_native_pointers(mirror_oop);
254 }
255 }
256 }
257#endif
258
259 for (int i = 0; i < T_LONG+1; i++) {
260 f->do_ptr((void**)&_typeArrayKlassObjs[i]);
261 }
262
263 f->do_ptr((void**)&_objectArrayKlassObj);
264 f->do_ptr((void**)&_the_array_interfaces_array);
265 f->do_ptr((void**)&_the_empty_int_array);
266 f->do_ptr((void**)&_the_empty_short_array);
267 f->do_ptr((void**)&_the_empty_method_array);
268 f->do_ptr((void**)&_the_empty_klass_array);
269 f->do_ptr((void**)&_the_empty_instance_klass_array);
270 _finalizer_register_cache->serialize(f);
271 _loader_addClass_cache->serialize(f);
272 _throw_illegal_access_error_cache->serialize(f);
273 _throw_no_such_method_error_cache->serialize(f);
274 _do_stack_walk_cache->serialize(f);
275}
276
277
278void Universe::check_alignment(uintx size, uintx alignment, const char* name) {
279 if (size < alignment || size % alignment != 0) {
280 vm_exit_during_initialization(
281 err_msg("Size of %s (" UINTX_FORMAT"%" "l" "u" " bytes) must be aligned to " UINTX_FORMAT"%" "l" "u" " bytes", name, size, alignment));
282 }
283}
284
285void initialize_basic_type_klass(Klass* k, TRAPSJavaThread* __the_thread__) {
286 Klass* ok = vmClasses::Object_klass();
287#if INCLUDE_CDS1
288 if (UseSharedSpaces) {
289 ClassLoaderData* loader_data = ClassLoaderData::the_null_class_loader_data();
290 assert(k->super() == ok, "u3")do { if (!(k->super() == ok)) { (*g_assert_poison) = 'X';;
report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/memory/universe.cpp"
, 290, "assert(" "k->super() == ok" ") failed", "u3"); ::breakpoint
(); } } while (0)
;
291 if (k->is_instance_klass()) {
292 InstanceKlass::cast(k)->restore_unshareable_info(loader_data, Handle(), NULL__null, CHECK__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception
())) return ; (void)(0
);
293 } else {
294 ArrayKlass::cast(k)->restore_unshareable_info(loader_data, Handle(), CHECK__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception
())) return ; (void)(0
);
295 }
296 } else
297#endif
298 {
299 k->initialize_supers(ok, NULL__null, CHECK__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception
())) return ; (void)(0
);
300 }
301 k->append_to_sibling_list();
302}
303
304void Universe::genesis(TRAPSJavaThread* __the_thread__) {
305 ResourceMark rm(THREAD__the_thread__);
306 HandleMark hm(THREAD__the_thread__);
307
308 { AutoModifyRestore<bool> temporarily(_bootstrapping, true);
309
310 { MutexLocker mc(THREAD__the_thread__, Compile_lock);
311
312 java_lang_Class::allocate_fixup_lists();
313
314 // determine base vtable size; without that we cannot create the array klasses
315 compute_base_vtable_size();
316
317 if (!UseSharedSpaces) {
318 for (int i = T_BOOLEAN; i < T_LONG+1; i++) {
319 _typeArrayKlassObjs[i] = TypeArrayKlass::create_klass((BasicType)i, CHECK__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception
())) return ; (void)(0
);
320 }
321
322 ClassLoaderData* null_cld = ClassLoaderData::the_null_class_loader_data();
323
324 _the_array_interfaces_array = MetadataFactory::new_array<Klass*>(null_cld, 2, NULL__null, CHECK__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception
())) return ; (void)(0
);
325 _the_empty_int_array = MetadataFactory::new_array<int>(null_cld, 0, CHECK__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception
())) return ; (void)(0
);
326 _the_empty_short_array = MetadataFactory::new_array<u2>(null_cld, 0, CHECK__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception
())) return ; (void)(0
);
327 _the_empty_method_array = MetadataFactory::new_array<Method*>(null_cld, 0, CHECK__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception
())) return ; (void)(0
);
328 _the_empty_klass_array = MetadataFactory::new_array<Klass*>(null_cld, 0, CHECK__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception
())) return ; (void)(0
);
329 _the_empty_instance_klass_array = MetadataFactory::new_array<InstanceKlass*>(null_cld, 0, CHECK__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception
())) return ; (void)(0
);
330 }
331 }
332
333 vmSymbols::initialize();
334
335 SystemDictionary::initialize(CHECK__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception
())) return ; (void)(0
);
336
337 // Create string constants
338 oop s = StringTable::intern("null", CHECK__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception
())) return ; (void)(0
);
339 _the_null_string = OopHandle(vm_global(), s);
340 s = StringTable::intern("-2147483648", CHECK__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception
())) return ; (void)(0
);
341 _the_min_jint_string = OopHandle(vm_global(), s);
342
343
344#if INCLUDE_CDS1
345 if (UseSharedSpaces) {
346 // Verify shared interfaces array.
347 assert(_the_array_interfaces_array->at(0) ==do { if (!(_the_array_interfaces_array->at(0) == vmClasses
::Cloneable_klass())) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/memory/universe.cpp"
, 348, "assert(" "_the_array_interfaces_array->at(0) == vmClasses::Cloneable_klass()"
") failed", "u3"); ::breakpoint(); } } while (0)
348 vmClasses::Cloneable_klass(), "u3")do { if (!(_the_array_interfaces_array->at(0) == vmClasses
::Cloneable_klass())) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/memory/universe.cpp"
, 348, "assert(" "_the_array_interfaces_array->at(0) == vmClasses::Cloneable_klass()"
") failed", "u3"); ::breakpoint(); } } while (0)
;
349 assert(_the_array_interfaces_array->at(1) ==do { if (!(_the_array_interfaces_array->at(1) == vmClasses
::Serializable_klass())) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/memory/universe.cpp"
, 350, "assert(" "_the_array_interfaces_array->at(1) == vmClasses::Serializable_klass()"
") failed", "u3"); ::breakpoint(); } } while (0)
350 vmClasses::Serializable_klass(), "u3")do { if (!(_the_array_interfaces_array->at(1) == vmClasses
::Serializable_klass())) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/memory/universe.cpp"
, 350, "assert(" "_the_array_interfaces_array->at(1) == vmClasses::Serializable_klass()"
") failed", "u3"); ::breakpoint(); } } while (0)
;
351 } else
352#endif
353 {
354 // Set up shared interfaces array. (Do this before supers are set up.)
355 _the_array_interfaces_array->at_put(0, vmClasses::Cloneable_klass());
356 _the_array_interfaces_array->at_put(1, vmClasses::Serializable_klass());
357 }
358
359 initialize_basic_type_klass(boolArrayKlassObj(), CHECK__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception
())) return ; (void)(0
);
360 initialize_basic_type_klass(charArrayKlassObj(), CHECK__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception
())) return ; (void)(0
);
361 initialize_basic_type_klass(floatArrayKlassObj(), CHECK__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception
())) return ; (void)(0
);
362 initialize_basic_type_klass(doubleArrayKlassObj(), CHECK__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception
())) return ; (void)(0
);
363 initialize_basic_type_klass(byteArrayKlassObj(), CHECK__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception
())) return ; (void)(0
);
364 initialize_basic_type_klass(shortArrayKlassObj(), CHECK__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception
())) return ; (void)(0
);
365 initialize_basic_type_klass(intArrayKlassObj(), CHECK__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception
())) return ; (void)(0
);
366 initialize_basic_type_klass(longArrayKlassObj(), CHECK__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception
())) return ; (void)(0
);
367 } // end of core bootstrapping
368
369 {
370 Handle tns = java_lang_String::create_from_str("<null_sentinel>", CHECK__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception
())) return ; (void)(0
);
371 _the_null_sentinel = OopHandle(vm_global(), tns());
372 }
373
374 // Create a handle for reference_pending_list
375 _reference_pending_list = OopHandle(vm_global(), NULL__null);
376
377 // Maybe this could be lifted up now that object array can be initialized
378 // during the bootstrapping.
379
380 // OLD
381 // Initialize _objectArrayKlass after core bootstraping to make
382 // sure the super class is set up properly for _objectArrayKlass.
383 // ---
384 // NEW
385 // Since some of the old system object arrays have been converted to
386 // ordinary object arrays, _objectArrayKlass will be loaded when
387 // SystemDictionary::initialize(CHECK); is run. See the extra check
388 // for Object_klass_loaded in objArrayKlassKlass::allocate_objArray_klass_impl.
389 _objectArrayKlassObj = InstanceKlass::
390 cast(vmClasses::Object_klass())->array_klass(1, CHECK__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception
())) return ; (void)(0
);
391 // OLD
392 // Add the class to the class hierarchy manually to make sure that
393 // its vtable is initialized after core bootstrapping is completed.
394 // ---
395 // New
396 // Have already been initialized.
397 _objectArrayKlassObj->append_to_sibling_list();
398
399 #ifdef ASSERT1
400 if (FullGCALot) {
401 // Allocate an array of dummy objects.
402 // We'd like these to be at the bottom of the old generation,
403 // so that when we free one and then collect,
404 // (almost) the whole heap moves
405 // and we find out if we actually update all the oops correctly.
406 // But we can't allocate directly in the old generation,
407 // so we allocate wherever, and hope that the first collection
408 // moves these objects to the bottom of the old generation.
409 int size = FullGCALotDummies * 2;
410
411 objArrayOop naked_array = oopFactory::new_objArray(vmClasses::Object_klass(), size, CHECK__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception
())) return ; (void)(0
);
412 objArrayHandle dummy_array(THREAD__the_thread__, naked_array);
413 int i = 0;
414 while (i < size) {
415 // Allocate dummy in old generation
416 oop dummy = vmClasses::Object_klass()->allocate_instance(CHECK__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception
())) return ; (void)(0
);
417 dummy_array->obj_at_put(i++, dummy);
418 }
419 {
420 // Only modify the global variable inside the mutex.
421 // If we had a race to here, the other dummy_array instances
422 // and their elements just get dropped on the floor, which is fine.
423 MutexLocker ml(THREAD__the_thread__, FullGCALot_lock);
424 if (_fullgc_alot_dummy_array.is_empty()) {
425 _fullgc_alot_dummy_array = OopHandle(vm_global(), dummy_array());
426 }
427 }
428 assert(i == ((objArrayOop)_fullgc_alot_dummy_array.resolve())->length(), "just checking")do { if (!(i == ((objArrayOop)_fullgc_alot_dummy_array.resolve
())->length())) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/memory/universe.cpp"
, 428, "assert(" "i == ((objArrayOop)_fullgc_alot_dummy_array.resolve())->length()"
") failed", "just checking"); ::breakpoint(); } } while (0)
;
429 }
430 #endif
431}
432
433void Universe::initialize_basic_type_mirrors(TRAPSJavaThread* __the_thread__) {
434#if INCLUDE_CDS_JAVA_HEAP1
435 if (UseSharedSpaces &&
436 HeapShared::are_archived_mirrors_available() &&
437 _mirrors[T_INT].resolve() != NULL__null) {
438 assert(HeapShared::can_use(), "Sanity")do { if (!(HeapShared::can_use())) { (*g_assert_poison) = 'X'
;; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/memory/universe.cpp"
, 438, "assert(" "HeapShared::can_use()" ") failed", "Sanity"
); ::breakpoint(); } } while (0)
;
439
440 // check that all mirrors are mapped also
441 for (int i = T_BOOLEAN; i < T_VOID+1; i++) {
442 if (!is_reference_type((BasicType)i)) {
443 oop m = _mirrors[i].resolve();
444 assert(m != NULL, "archived mirrors should not be NULL")do { if (!(m != __null)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/memory/universe.cpp"
, 444, "assert(" "m != __null" ") failed", "archived mirrors should not be NULL"
); ::breakpoint(); } } while (0)
;
445 }
446 }
447 } else
448 // _mirror[T_INT} could be NULL if archived heap is not mapped.
449#endif
450 {
451 for (int i = T_BOOLEAN; i < T_VOID+1; i++) {
452 BasicType bt = (BasicType)i;
453 if (!is_reference_type(bt)) {
454 oop m = java_lang_Class::create_basic_type_mirror(type2name(bt), bt, CHECK__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception
())) return ; (void)(0
);
455 _mirrors[i] = OopHandle(vm_global(), m);
456 }
457 }
458 }
459}
460
461void Universe::fixup_mirrors(TRAPSJavaThread* __the_thread__) {
462 // Bootstrap problem: all classes gets a mirror (java.lang.Class instance) assigned eagerly,
463 // but we cannot do that for classes created before java.lang.Class is loaded. Here we simply
464 // walk over permanent objects created so far (mostly classes) and fixup their mirrors. Note
465 // that the number of objects allocated at this point is very small.
466 assert(vmClasses::Class_klass_loaded(), "java.lang.Class should be loaded")do { if (!(vmClasses::Class_klass_loaded())) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/memory/universe.cpp"
, 466, "assert(" "vmClasses::Class_klass_loaded()" ") failed"
, "java.lang.Class should be loaded"); ::breakpoint(); } } while
(0)
;
467 HandleMark hm(THREAD__the_thread__);
468
469 if (!UseSharedSpaces) {
470 // Cache the start of the static fields
471 InstanceMirrorKlass::init_offset_of_static_fields();
472 }
473
474 GrowableArray <Klass*>* list = java_lang_Class::fixup_mirror_list();
475 int list_length = list->length();
476 for (int i = 0; i < list_length; i++) {
477 Klass* k = list->at(i);
478 assert(k->is_klass(), "List should only hold classes")do { if (!(k->is_klass())) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/memory/universe.cpp"
, 478, "assert(" "k->is_klass()" ") failed", "List should only hold classes"
); ::breakpoint(); } } while (0)
;
479 java_lang_Class::fixup_mirror(k, CATCH__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception
())) { oop ex = (((ThreadShadow*)__the_thread__)->pending_exception
()); (((ThreadShadow*)__the_thread__)->clear_pending_exception
()); ex->print(); do { if (!(false)) { (*g_assert_poison) =
'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/memory/universe.cpp"
, 479, "assert(" "false" ") failed", "CATCH"); ::breakpoint()
; } } while (0); } (void)(0
);
480 }
481 delete java_lang_Class::fixup_mirror_list();
482 java_lang_Class::set_fixup_mirror_list(NULL__null);
483}
484
485#define assert_pll_locked(test) \
486 assert(Heap_lock->test(), "Reference pending list access requires lock")do { if (!(Heap_lock->test())) { (*g_assert_poison) = 'X';
; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/memory/universe.cpp"
, 486, "assert(" "Heap_lock->test()" ") failed", "Reference pending list access requires lock"
); ::breakpoint(); } } while (0)
487
488#define assert_pll_ownership() assert_pll_locked(owned_by_self)
489
490oop Universe::reference_pending_list() {
491 if (Thread::current()->is_VM_thread()) {
492 assert_pll_locked(is_locked);
493 } else {
494 assert_pll_ownership();
495 }
496 return _reference_pending_list.resolve();
497}
498
499void Universe::clear_reference_pending_list() {
500 assert_pll_ownership();
501 _reference_pending_list.replace(NULL__null);
502}
503
504bool Universe::has_reference_pending_list() {
505 assert_pll_ownership();
506 return _reference_pending_list.peek() != NULL__null;
507}
508
509oop Universe::swap_reference_pending_list(oop list) {
510 assert_pll_locked(is_locked);
511 return _reference_pending_list.xchg(list);
512}
513
514#undef assert_pll_locked
515#undef assert_pll_ownership
516
517static void reinitialize_vtables() {
518 // The vtables are initialized by starting at java.lang.Object and
519 // initializing through the subclass links, so that the super
520 // classes are always initialized first.
521 for (ClassHierarchyIterator iter(vmClasses::Object_klass()); !iter.done(); iter.next()) {
522 Klass* sub = iter.klass();
523 sub->vtable().initialize_vtable();
524 }
525}
526
527static void reinitialize_itables() {
528
529 class ReinitTableClosure : public KlassClosure {
530 public:
531 void do_klass(Klass* k) {
532 if (k->is_instance_klass()) {
533 InstanceKlass::cast(k)->itable().initialize_itable();
534 }
535 }
536 };
537
538 MutexLocker mcld(ClassLoaderDataGraph_lock);
539 ReinitTableClosure cl;
540 ClassLoaderDataGraph::classes_do(&cl);
541}
542
543
544bool Universe::on_page_boundary(void* addr) {
545 return is_aligned(addr, os::vm_page_size());
546}
547
548// the array of preallocated errors with backtraces
549objArrayOop Universe::preallocated_out_of_memory_errors() {
550 return (objArrayOop)_preallocated_out_of_memory_error_array.resolve();
551}
552
553objArrayOop Universe::out_of_memory_errors() { return (objArrayOop)_out_of_memory_errors.resolve(); }
554
555oop Universe::out_of_memory_error_java_heap() {
556 return gen_out_of_memory_error(out_of_memory_errors()->obj_at(_oom_java_heap));
557}
558
559oop Universe::out_of_memory_error_c_heap() {
560 return gen_out_of_memory_error(out_of_memory_errors()->obj_at(_oom_c_heap));
561}
562
563oop Universe::out_of_memory_error_metaspace() {
564 return gen_out_of_memory_error(out_of_memory_errors()->obj_at(_oom_metaspace));
565}
566
567oop Universe::out_of_memory_error_class_metaspace() {
568 return gen_out_of_memory_error(out_of_memory_errors()->obj_at(_oom_class_metaspace));
569}
570
571oop Universe::out_of_memory_error_array_size() {
572 return gen_out_of_memory_error(out_of_memory_errors()->obj_at(_oom_array_size));
573}
574
575oop Universe::out_of_memory_error_gc_overhead_limit() {
576 return gen_out_of_memory_error(out_of_memory_errors()->obj_at(_oom_gc_overhead_limit));
577}
578
579oop Universe::out_of_memory_error_realloc_objects() {
580 return gen_out_of_memory_error(out_of_memory_errors()->obj_at(_oom_realloc_objects));
581}
582
583// Throw default _out_of_memory_error_retry object as it will never propagate out of the VM
584oop Universe::out_of_memory_error_retry() { return out_of_memory_errors()->obj_at(_oom_retry); }
585oop Universe::delayed_stack_overflow_error_message() { return _delayed_stack_overflow_error_message.resolve(); }
586
587
588bool Universe::should_fill_in_stack_trace(Handle throwable) {
589 // never attempt to fill in the stack trace of preallocated errors that do not have
590 // backtrace. These errors are kept alive forever and may be "re-used" when all
591 // preallocated errors with backtrace have been consumed. Also need to avoid
592 // a potential loop which could happen if an out of memory occurs when attempting
593 // to allocate the backtrace.
594 objArrayOop preallocated_oom = out_of_memory_errors();
595 for (int i = 0; i < _oom_count; i++) {
596 if (throwable() == preallocated_oom->obj_at(i)) {
597 return false;
598 }
599 }
600 return true;
601}
602
603
604oop Universe::gen_out_of_memory_error(oop default_err) {
605 // generate an out of memory error:
606 // - if there is a preallocated error and stack traces are available
607 // (j.l.Throwable is initialized), then return the preallocated
608 // error with a filled in stack trace, and with the message
609 // provided by the default error.
610 // - otherwise, return the default error, without a stack trace.
611 int next;
612 if ((_preallocated_out_of_memory_error_avail_count > 0) &&
613 vmClasses::Throwable_klass()->is_initialized()) {
614 next = (int)Atomic::add(&_preallocated_out_of_memory_error_avail_count, -1);
615 assert(next < (int)PreallocatedOutOfMemoryErrorCount, "avail count is corrupt")do { if (!(next < (int)PreallocatedOutOfMemoryErrorCount))
{ (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/memory/universe.cpp"
, 615, "assert(" "next < (int)PreallocatedOutOfMemoryErrorCount"
") failed", "avail count is corrupt"); ::breakpoint(); } } while
(0)
;
616 } else {
617 next = -1;
618 }
619 if (next < 0) {
620 // all preallocated errors have been used.
621 // return default
622 return default_err;
623 } else {
624 JavaThread* current = JavaThread::current();
625 Handle default_err_h(current, default_err);
626 // get the error object at the slot and set set it to NULL so that the
627 // array isn't keeping it alive anymore.
628 Handle exc(current, preallocated_out_of_memory_errors()->obj_at(next));
629 assert(exc() != NULL, "slot has been used already")do { if (!(exc() != __null)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/memory/universe.cpp"
, 629, "assert(" "exc() != __null" ") failed", "slot has been used already"
); ::breakpoint(); } } while (0)
;
630 preallocated_out_of_memory_errors()->obj_at_put(next, NULL__null);
631
632 // use the message from the default error
633 oop msg = java_lang_Throwable::message(default_err_h());
634 assert(msg != NULL, "no message")do { if (!(msg != __null)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/memory/universe.cpp"
, 634, "assert(" "msg != __null" ") failed", "no message"); ::
breakpoint(); } } while (0)
;
635 java_lang_Throwable::set_message(exc(), msg);
636
637 // populate the stack trace and return it.
638 java_lang_Throwable::fill_in_stack_trace_of_preallocated_backtrace(exc);
639 return exc();
640 }
641}
642
643// Setup preallocated OutOfMemoryError errors
644void Universe::create_preallocated_out_of_memory_errors(TRAPSJavaThread* __the_thread__) {
645 InstanceKlass* ik = vmClasses::OutOfMemoryError_klass();
646 objArrayOop oa = oopFactory::new_objArray(ik, _oom_count, CHECK__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception
())) return ; (void)(0
);
647 objArrayHandle oom_array(THREAD__the_thread__, oa);
648
649 for (int i = 0; i < _oom_count; i++) {
650 oop oom_obj = ik->allocate_instance(CHECK__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception
())) return ; (void)(0
);
651 oom_array->obj_at_put(i, oom_obj);
652 }
653 _out_of_memory_errors = OopHandle(vm_global(), oom_array());
654
655 Handle msg = java_lang_String::create_from_str("Java heap space", CHECK__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception
())) return ; (void)(0
);
656 java_lang_Throwable::set_message(oom_array->obj_at(_oom_java_heap), msg());
657
658 msg = java_lang_String::create_from_str("C heap space", CHECK__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception
())) return ; (void)(0
);
659 java_lang_Throwable::set_message(oom_array->obj_at(_oom_c_heap), msg());
660
661 msg = java_lang_String::create_from_str("Metaspace", CHECK__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception
())) return ; (void)(0
);
662 java_lang_Throwable::set_message(oom_array->obj_at(_oom_metaspace), msg());
663
664 msg = java_lang_String::create_from_str("Compressed class space", CHECK__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception
())) return ; (void)(0
);
665 java_lang_Throwable::set_message(oom_array->obj_at(_oom_class_metaspace), msg());
666
667 msg = java_lang_String::create_from_str("Requested array size exceeds VM limit", CHECK__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception
())) return ; (void)(0
);
668 java_lang_Throwable::set_message(oom_array->obj_at(_oom_array_size), msg());
669
670 msg = java_lang_String::create_from_str("GC overhead limit exceeded", CHECK__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception
())) return ; (void)(0
);
671 java_lang_Throwable::set_message(oom_array->obj_at(_oom_gc_overhead_limit), msg());
672
673 msg = java_lang_String::create_from_str("Java heap space: failed reallocation of scalar replaced objects", CHECK__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception
())) return ; (void)(0
);
674 java_lang_Throwable::set_message(oom_array->obj_at(_oom_realloc_objects), msg());
675
676 msg = java_lang_String::create_from_str("Java heap space: failed retryable allocation", CHECK__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception
())) return ; (void)(0
);
677 java_lang_Throwable::set_message(oom_array->obj_at(_oom_retry), msg());
678
679 // Setup the array of errors that have preallocated backtrace
680 int len = (StackTraceInThrowable) ? (int)PreallocatedOutOfMemoryErrorCount : 0;
681 objArrayOop instance = oopFactory::new_objArray(ik, len, CHECK__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception
())) return ; (void)(0
);
682 _preallocated_out_of_memory_error_array = OopHandle(vm_global(), instance);
683 objArrayHandle preallocated_oom_array(THREAD__the_thread__, instance);
684
685 for (int i=0; i<len; i++) {
686 oop err = ik->allocate_instance(CHECK__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception
())) return ; (void)(0
);
687 Handle err_h(THREAD__the_thread__, err);
688 java_lang_Throwable::allocate_backtrace(err_h, CHECK__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception
())) return ; (void)(0
);
689 preallocated_oom_array->obj_at_put(i, err_h());
690 }
691 _preallocated_out_of_memory_error_avail_count = (jint)len;
692}
693
694intptr_t Universe::_non_oop_bits = 0;
695
696void* Universe::non_oop_word() {
697 // Neither the high bits nor the low bits of this value is allowed
698 // to look like (respectively) the high or low bits of a real oop.
699 //
700 // High and low are CPU-specific notions, but low always includes
701 // the low-order bit. Since oops are always aligned at least mod 4,
702 // setting the low-order bit will ensure that the low half of the
703 // word will never look like that of a real oop.
704 //
705 // Using the OS-supplied non-memory-address word (usually 0 or -1)
706 // will take care of the high bits, however many there are.
707
708 if (_non_oop_bits == 0) {
709 _non_oop_bits = (intptr_t)os::non_memory_address_word() | 1;
710 }
711
712 return (void*)_non_oop_bits;
713}
714
715bool Universe::contains_non_oop_word(void* p) {
716 return *(void**)p == non_oop_word();
717}
718
719static void initialize_global_behaviours() {
720 CompiledICProtectionBehaviour::set_current(new DefaultICProtectionBehaviour());
721}
722
723jint universe_init() {
724 assert(!Universe::_fully_initialized, "called after initialize_vtables")do { if (!(!Universe::_fully_initialized)) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/memory/universe.cpp"
, 724, "assert(" "!Universe::_fully_initialized" ") failed", "called after initialize_vtables"
); ::breakpoint(); } } while (0)
;
725 guarantee(1 << LogHeapWordSize == sizeof(HeapWord),do { if (!(1 << LogHeapWordSize == sizeof(HeapWord))) {
(*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/memory/universe.cpp"
, 726, "guarantee(" "1 << LogHeapWordSize == sizeof(HeapWord)"
") failed", "LogHeapWordSize is incorrect."); ::breakpoint()
; } } while (0)
726 "LogHeapWordSize is incorrect.")do { if (!(1 << LogHeapWordSize == sizeof(HeapWord))) {
(*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/memory/universe.cpp"
, 726, "guarantee(" "1 << LogHeapWordSize == sizeof(HeapWord)"
") failed", "LogHeapWordSize is incorrect."); ::breakpoint()
; } } while (0)
;
727 guarantee(sizeof(oop) >= sizeof(HeapWord), "HeapWord larger than oop?")do { if (!(sizeof(oop) >= sizeof(HeapWord))) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/memory/universe.cpp"
, 727, "guarantee(" "sizeof(oop) >= sizeof(HeapWord)" ") failed"
, "HeapWord larger than oop?"); ::breakpoint(); } } while (0)
;
728 guarantee(sizeof(oop) % sizeof(HeapWord) == 0,do { if (!(sizeof(oop) % sizeof(HeapWord) == 0)) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/memory/universe.cpp"
, 729, "guarantee(" "sizeof(oop) % sizeof(HeapWord) == 0" ") failed"
, "oop size is not not a multiple of HeapWord size"); ::breakpoint
(); } } while (0)
729 "oop size is not not a multiple of HeapWord size")do { if (!(sizeof(oop) % sizeof(HeapWord) == 0)) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/memory/universe.cpp"
, 729, "guarantee(" "sizeof(oop) % sizeof(HeapWord) == 0" ") failed"
, "oop size is not not a multiple of HeapWord size"); ::breakpoint
(); } } while (0)
;
730
731 TraceTime timer("Genesis", TRACETIME_LOG(Info, startuptime)(LogImpl<(LogTag::_startuptime), (LogTag::__NO_TAG), (LogTag
::__NO_TAG), (LogTag::__NO_TAG), (LogTag::__NO_TAG), (LogTag::
__NO_TAG)>::is_level(LogLevel::Info)) ? static_cast<TraceTimerLogPrintFunc
>(&LogImpl<(LogTag::_startuptime), (LogTag::__NO_TAG
), (LogTag::__NO_TAG), (LogTag::__NO_TAG), (LogTag::__NO_TAG)
, (LogTag::__NO_TAG)>::write<LogLevel::Info>) : (TraceTimerLogPrintFunc
)__null
);
732
733 initialize_global_behaviours();
734
735 GCLogPrecious::initialize();
736
737 GCConfig::arguments()->initialize_heap_sizes();
738
739 jint status = Universe::initialize_heap();
740 if (status != JNI_OK0) {
741 return status;
742 }
743
744 Universe::initialize_tlab();
745
746 Metaspace::global_initialize();
747
748 // Initialize performance counters for metaspaces
749 MetaspaceCounters::initialize_performance_counters();
750
751 // Checks 'AfterMemoryInit' constraints.
752 if (!JVMFlagLimit::check_all_constraints(JVMFlagConstraintPhase::AfterMemoryInit)) {
753 return JNI_EINVAL(-6);
754 }
755
756 // Create memory for metadata. Must be after initializing heap for
757 // DumpSharedSpaces.
758 ClassLoaderData::init_null_class_loader_data();
759
760 // We have a heap so create the Method* caches before
761 // Metaspace::initialize_shared_spaces() tries to populate them.
762 Universe::_finalizer_register_cache = new LatestMethodCache();
763 Universe::_loader_addClass_cache = new LatestMethodCache();
764 Universe::_throw_illegal_access_error_cache = new LatestMethodCache();
765 Universe::_throw_no_such_method_error_cache = new LatestMethodCache();
766 Universe::_do_stack_walk_cache = new LatestMethodCache();
767
768#if INCLUDE_CDS1
769 DynamicArchive::check_for_dynamic_dump();
770 if (UseSharedSpaces) {
771 // Read the data structures supporting the shared spaces (shared
772 // system dictionary, symbol table, etc.). After that, access to
773 // the file (other than the mapped regions) is no longer needed, and
774 // the file is closed. Closing the file does not affect the
775 // currently mapped regions.
776 MetaspaceShared::initialize_shared_spaces();
777 StringTable::create_table();
778 if (HeapShared::is_loaded()) {
779 StringTable::transfer_shared_strings_to_local_table();
780 }
781 } else
782#endif
783 {
784 SymbolTable::create_table();
785 StringTable::create_table();
786 }
787
788#if INCLUDE_CDS1
789 if (Arguments::is_dumping_archive()) {
790 MetaspaceShared::prepare_for_dumping();
791 }
792#endif
793
794 if (strlen(VerifySubSet) > 0) {
795 Universe::initialize_verify_flags();
796 }
797
798 ResolvedMethodTable::create_table();
799
800 return JNI_OK0;
801}
802
803jint Universe::initialize_heap() {
804 assert(_collectedHeap == NULL, "Heap already created")do { if (!(_collectedHeap == __null)) { (*g_assert_poison) = 'X'
;; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/memory/universe.cpp"
, 804, "assert(" "_collectedHeap == __null" ") failed", "Heap already created"
); ::breakpoint(); } } while (0)
;
805 _collectedHeap = GCConfig::arguments()->create_heap();
806
807 log_info(gc)(!(LogImpl<(LogTag::_gc), (LogTag::__NO_TAG), (LogTag::__NO_TAG
), (LogTag::__NO_TAG), (LogTag::__NO_TAG), (LogTag::__NO_TAG)
>::is_level(LogLevel::Info))) ? (void)0 : LogImpl<(LogTag
::_gc), (LogTag::__NO_TAG), (LogTag::__NO_TAG), (LogTag::__NO_TAG
), (LogTag::__NO_TAG), (LogTag::__NO_TAG)>::write<LogLevel
::Info>
("Using %s", _collectedHeap->name());
808 return _collectedHeap->initialize();
809}
810
811void Universe::initialize_tlab() {
812 ThreadLocalAllocBuffer::set_max_size(Universe::heap()->max_tlab_size());
813 if (UseTLAB) {
814 ThreadLocalAllocBuffer::startup_initialization();
815 }
816}
817
818ReservedHeapSpace Universe::reserve_heap(size_t heap_size, size_t alignment) {
819
820 assert(alignment <= Arguments::conservative_max_heap_alignment(),do { if (!(alignment <= Arguments::conservative_max_heap_alignment
())) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/memory/universe.cpp"
, 822, "assert(" "alignment <= Arguments::conservative_max_heap_alignment()"
") failed", "actual alignment " "%" "l" "u" " must be within maximum heap alignment "
"%" "l" "u", alignment, Arguments::conservative_max_heap_alignment
()); ::breakpoint(); } } while (0)
821 "actual alignment " SIZE_FORMAT " must be within maximum heap alignment " SIZE_FORMAT,do { if (!(alignment <= Arguments::conservative_max_heap_alignment
())) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/memory/universe.cpp"
, 822, "assert(" "alignment <= Arguments::conservative_max_heap_alignment()"
") failed", "actual alignment " "%" "l" "u" " must be within maximum heap alignment "
"%" "l" "u", alignment, Arguments::conservative_max_heap_alignment
()); ::breakpoint(); } } while (0)
822 alignment, Arguments::conservative_max_heap_alignment())do { if (!(alignment <= Arguments::conservative_max_heap_alignment
())) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/memory/universe.cpp"
, 822, "assert(" "alignment <= Arguments::conservative_max_heap_alignment()"
") failed", "actual alignment " "%" "l" "u" " must be within maximum heap alignment "
"%" "l" "u", alignment, Arguments::conservative_max_heap_alignment
()); ::breakpoint(); } } while (0)
;
823
824 size_t total_reserved = align_up(heap_size, alignment);
825 assert(!UseCompressedOops || (total_reserved <= (OopEncodingHeapMax - os::vm_page_size())),do { if (!(!UseCompressedOops || (total_reserved <= (OopEncodingHeapMax
- os::vm_page_size())))) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/memory/universe.cpp"
, 826, "assert(" "!UseCompressedOops || (total_reserved <= (OopEncodingHeapMax - os::vm_page_size()))"
") failed", "heap size is too big for compressed oops"); ::breakpoint
(); } } while (0)
826 "heap size is too big for compressed oops")do { if (!(!UseCompressedOops || (total_reserved <= (OopEncodingHeapMax
- os::vm_page_size())))) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/memory/universe.cpp"
, 826, "assert(" "!UseCompressedOops || (total_reserved <= (OopEncodingHeapMax - os::vm_page_size()))"
") failed", "heap size is too big for compressed oops"); ::breakpoint
(); } } while (0)
;
827
828 size_t page_size = os::vm_page_size();
829 if (UseLargePages && is_aligned(alignment, os::large_page_size())) {
830 page_size = os::large_page_size();
831 } else {
832 // Parallel is the only collector that might opt out of using large pages
833 // for the heap.
834 assert(!UseLargePages || UseParallelGC , "Wrong alignment to use large pages")do { if (!(!UseLargePages || UseParallelGC)) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/memory/universe.cpp"
, 834, "assert(" "!UseLargePages || UseParallelGC" ") failed"
, "Wrong alignment to use large pages"); ::breakpoint(); } } while
(0)
;
835 }
836
837 // Now create the space.
838 ReservedHeapSpace total_rs(total_reserved, alignment, page_size, AllocateHeapAt);
839
840 if (total_rs.is_reserved()) {
841 assert((total_reserved == total_rs.size()) && ((uintptr_t)total_rs.base() % alignment == 0),do { if (!((total_reserved == total_rs.size()) && ((uintptr_t
)total_rs.base() % alignment == 0))) { (*g_assert_poison) = 'X'
;; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/memory/universe.cpp"
, 842, "assert(" "(total_reserved == total_rs.size()) && ((uintptr_t)total_rs.base() % alignment == 0)"
") failed", "must be exactly of required size and alignment"
); ::breakpoint(); } } while (0)
842 "must be exactly of required size and alignment")do { if (!((total_reserved == total_rs.size()) && ((uintptr_t
)total_rs.base() % alignment == 0))) { (*g_assert_poison) = 'X'
;; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/memory/universe.cpp"
, 842, "assert(" "(total_reserved == total_rs.size()) && ((uintptr_t)total_rs.base() % alignment == 0)"
") failed", "must be exactly of required size and alignment"
); ::breakpoint(); } } while (0)
;
843 // We are good.
844
845 if (AllocateHeapAt != NULL__null) {
846 log_info(gc,heap)(!(LogImpl<(LogTag::_gc), (LogTag::_heap), (LogTag::__NO_TAG
), (LogTag::__NO_TAG), (LogTag::__NO_TAG), (LogTag::__NO_TAG)
>::is_level(LogLevel::Info))) ? (void)0 : LogImpl<(LogTag
::_gc), (LogTag::_heap), (LogTag::__NO_TAG), (LogTag::__NO_TAG
), (LogTag::__NO_TAG), (LogTag::__NO_TAG)>::write<LogLevel
::Info>
("Successfully allocated Java heap at location %s", AllocateHeapAt);
847 }
848
849 if (UseCompressedOops) {
850 CompressedOops::initialize(total_rs);
851 }
852
853 Universe::calculate_verify_data((HeapWord*)total_rs.base(), (HeapWord*)total_rs.end());
854
855 return total_rs;
856 }
857
858 vm_exit_during_initialization(
859 err_msg("Could not reserve enough space for " SIZE_FORMAT"%" "l" "u" "KB object heap",
860 total_reserved/K));
861
862 // satisfy compiler
863 ShouldNotReachHere()do { (*g_assert_poison) = 'X';; report_should_not_reach_here(
"/home/daniel/Projects/java/jdk/src/hotspot/share/memory/universe.cpp"
, 863); ::breakpoint(); } while (0)
;
864 return ReservedHeapSpace(0, 0, os::vm_page_size());
865}
866
867OopStorage* Universe::vm_weak() {
868 return Universe::_vm_weak;
869}
870
871OopStorage* Universe::vm_global() {
872 return Universe::_vm_global;
873}
874
875void Universe::oopstorage_init() {
876 Universe::_vm_global = OopStorageSet::create_strong("VM Global", mtInternal);
877 Universe::_vm_weak = OopStorageSet::create_weak("VM Weak", mtInternal);
878}
879
880void universe_oopstorage_init() {
881 Universe::oopstorage_init();
882}
883
884void initialize_known_method(LatestMethodCache* method_cache,
885 InstanceKlass* ik,
886 const char* method,
887 Symbol* signature,
888 bool is_static, TRAPSJavaThread* __the_thread__)
889{
890 TempNewSymbol name = SymbolTable::new_symbol(method);
891 Method* m = NULL__null;
2
'm' initialized to a null pointer value
892 // The klass must be linked before looking up the method.
893 if (!ik->link_class_or_fail(THREAD__the_thread__) ||
3
Assuming the condition is true
894 ((m = ik->find_method(name, signature)) == NULL__null) ||
895 is_static != m->is_static()) {
896 ResourceMark rm(THREAD__the_thread__);
897 // NoSuchMethodException doesn't actually work because it tries to run the
898 // <init> function before java_lang_Class is linked. Print error and exit.
899 vm_exit_during_initialization(err_msg("Unable to link/verify %s.%s method",
900 ik->name()->as_C_string(), method));
901 }
902 method_cache->init(ik, m);
4
Passing null pointer value via 2nd parameter 'm'
5
Calling 'LatestMethodCache::init'
903}
904
905void Universe::initialize_known_methods(TRAPSJavaThread* __the_thread__) {
906 // Set up static method for registering finalizers
907 initialize_known_method(_finalizer_register_cache,
1
Calling 'initialize_known_method'
908 vmClasses::Finalizer_klass(),
909 "register",
910 vmSymbols::object_void_signature(), true, CHECK__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception
())) return ; (void)(0
);
911
912 initialize_known_method(_throw_illegal_access_error_cache,
913 vmClasses::internal_Unsafe_klass(),
914 "throwIllegalAccessError",
915 vmSymbols::void_method_signature(), true, CHECK__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception
())) return ; (void)(0
);
916
917 initialize_known_method(_throw_no_such_method_error_cache,
918 vmClasses::internal_Unsafe_klass(),
919 "throwNoSuchMethodError",
920 vmSymbols::void_method_signature(), true, CHECK__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception
())) return ; (void)(0
);
921
922 // Set up method for registering loaded classes in class loader vector
923 initialize_known_method(_loader_addClass_cache,
924 vmClasses::ClassLoader_klass(),
925 "addClass",
926 vmSymbols::class_void_signature(), false, CHECK__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception
())) return ; (void)(0
);
927
928 // Set up method for stack walking
929 initialize_known_method(_do_stack_walk_cache,
930 vmClasses::AbstractStackWalker_klass(),
931 "doStackWalk",
932 vmSymbols::doStackWalk_signature(), false, CHECK__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception
())) return ; (void)(0
);
933}
934
935void universe2_init() {
936 EXCEPTION_MARKExceptionMark __em; JavaThread* __the_thread__ = __em.thread(
);
;
937 Universe::genesis(CATCH__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception
())) { oop ex = (((ThreadShadow*)__the_thread__)->pending_exception
()); (((ThreadShadow*)__the_thread__)->clear_pending_exception
()); ex->print(); do { if (!(false)) { (*g_assert_poison) =
'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/memory/universe.cpp"
, 937, "assert(" "false" ") failed", "CATCH"); ::breakpoint()
; } } while (0); } (void)(0
);
938}
939
940// Set after initialization of the module runtime, call_initModuleRuntime
941void universe_post_module_init() {
942 Universe::_module_initialized = true;
943}
944
945bool universe_post_init() {
946 assert(!is_init_completed(), "Error: initialization not yet completed!")do { if (!(!is_init_completed())) { (*g_assert_poison) = 'X';
; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/memory/universe.cpp"
, 946, "assert(" "!is_init_completed()" ") failed", "Error: initialization not yet completed!"
); ::breakpoint(); } } while (0)
;
947 Universe::_fully_initialized = true;
948 EXCEPTION_MARKExceptionMark __em; JavaThread* __the_thread__ = __em.thread(
);
;
949 if (!UseSharedSpaces) {
950 reinitialize_vtables();
951 reinitialize_itables();
952 }
953
954 HandleMark hm(THREAD__the_thread__);
955 // Setup preallocated empty java.lang.Class array for Method reflection.
956
957 objArrayOop the_empty_class_array = oopFactory::new_objArray(vmClasses::Class_klass(), 0, CHECK_false__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception
())) return false; (void)(0
);
958 Universe::_the_empty_class_array = OopHandle(Universe::vm_global(), the_empty_class_array);
959
960 // Setup preallocated OutOfMemoryError errors
961 Universe::create_preallocated_out_of_memory_errors(CHECK_false__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception
())) return false; (void)(0
);
962
963 oop instance;
964 // Setup preallocated cause message for delayed StackOverflowError
965 if (StackReservedPages > 0) {
966 instance = java_lang_String::create_oop_from_str("Delayed StackOverflowError due to ReservedStackAccess annotated method", CHECK_false__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception
())) return false; (void)(0
);
967 Universe::_delayed_stack_overflow_error_message = OopHandle(Universe::vm_global(), instance);
968 }
969
970 // Setup preallocated NullPointerException
971 // (this is currently used for a cheap & dirty solution in compiler exception handling)
972 Klass* k = SystemDictionary::resolve_or_fail(vmSymbols::java_lang_NullPointerException(), true, CHECK_false__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception
())) return false; (void)(0
);
973 instance = InstanceKlass::cast(k)->allocate_instance(CHECK_false__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception
())) return false; (void)(0
);
974 Universe::_null_ptr_exception_instance = OopHandle(Universe::vm_global(), instance);
975
976 // Setup preallocated ArithmeticException
977 // (this is currently used for a cheap & dirty solution in compiler exception handling)
978 k = SystemDictionary::resolve_or_fail(vmSymbols::java_lang_ArithmeticException(), true, CHECK_false__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception
())) return false; (void)(0
);
979 instance = InstanceKlass::cast(k)->allocate_instance(CHECK_false__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception
())) return false; (void)(0
);
980 Universe::_arithmetic_exception_instance = OopHandle(Universe::vm_global(), instance);
981
982 // Virtual Machine Error for when we get into a situation we can't resolve
983 k = vmClasses::VirtualMachineError_klass();
984 bool linked = InstanceKlass::cast(k)->link_class_or_fail(CHECK_false__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception
())) return false; (void)(0
);
985 if (!linked) {
986 tty->print_cr("Unable to link/verify VirtualMachineError class");
987 return false; // initialization failed
988 }
989 instance = InstanceKlass::cast(k)->allocate_instance(CHECK_false__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception
())) return false; (void)(0
);
990 Universe::_virtual_machine_error_instance = OopHandle(Universe::vm_global(), instance);
991
992 Handle msg = java_lang_String::create_from_str("/ by zero", CHECK_false__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception
())) return false; (void)(0
);
993 java_lang_Throwable::set_message(Universe::arithmetic_exception_instance(), msg());
994
995 Universe::initialize_known_methods(CHECK_false__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception
())) return false; (void)(0
);
996
997 // This needs to be done before the first scavenge/gc, since
998 // it's an input to soft ref clearing policy.
999 {
1000 MutexLocker x(THREAD__the_thread__, Heap_lock);
1001 Universe::heap()->update_capacity_and_used_at_gc();
1002 }
1003
1004 // ("weak") refs processing infrastructure initialization
1005 Universe::heap()->post_initialize();
1006
1007 MemoryService::add_metaspace_memory_pools();
1008
1009 MemoryService::set_universe_heap(Universe::heap());
1010#if INCLUDE_CDS1
1011 MetaspaceShared::post_initialize(CHECK_false__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception
())) return false; (void)(0
);
1012#endif
1013 return true;
1014}
1015
1016
1017void Universe::compute_base_vtable_size() {
1018 _base_vtable_size = ClassLoader::compute_Object_vtable();
1019}
1020
1021void Universe::print_on(outputStream* st) {
1022 GCMutexLocker hl(Heap_lock); // Heap_lock might be locked by caller thread.
1023 st->print_cr("Heap");
1024 heap()->print_on(st);
1025}
1026
1027void Universe::print_heap_at_SIGBREAK() {
1028 if (PrintHeapAtSIGBREAK) {
1029 print_on(tty);
1030 tty->cr();
1031 tty->flush();
1032 }
1033}
1034
1035void Universe::initialize_verify_flags() {
1036 verify_flags = 0;
1037 const char delimiter[] = " ,";
1038
1039 size_t length = strlen(VerifySubSet);
1040 char* subset_list = NEW_C_HEAP_ARRAY(char, length + 1, mtInternal)(char*) (AllocateHeap((length + 1) * sizeof(char), mtInternal
))
;
1041 strncpy(subset_list, VerifySubSet, length + 1);
1042 char* save_ptr;
1043
1044 char* token = strtok_r(subset_list, delimiter, &save_ptr);
1045 while (token != NULL__null) {
1046 if (strcmp(token, "threads") == 0) {
1047 verify_flags |= Verify_Threads;
1048 } else if (strcmp(token, "heap") == 0) {
1049 verify_flags |= Verify_Heap;
1050 } else if (strcmp(token, "symbol_table") == 0) {
1051 verify_flags |= Verify_SymbolTable;
1052 } else if (strcmp(token, "string_table") == 0) {
1053 verify_flags |= Verify_StringTable;
1054 } else if (strcmp(token, "codecache") == 0) {
1055 verify_flags |= Verify_CodeCache;
1056 } else if (strcmp(token, "dictionary") == 0) {
1057 verify_flags |= Verify_SystemDictionary;
1058 } else if (strcmp(token, "classloader_data_graph") == 0) {
1059 verify_flags |= Verify_ClassLoaderDataGraph;
1060 } else if (strcmp(token, "metaspace") == 0) {
1061 verify_flags |= Verify_MetaspaceUtils;
1062 } else if (strcmp(token, "jni_handles") == 0) {
1063 verify_flags |= Verify_JNIHandles;
1064 } else if (strcmp(token, "codecache_oops") == 0) {
1065 verify_flags |= Verify_CodeCacheOops;
1066 } else if (strcmp(token, "resolved_method_table") == 0) {
1067 verify_flags |= Verify_ResolvedMethodTable;
1068 } else if (strcmp(token, "stringdedup") == 0) {
1069 verify_flags |= Verify_StringDedup;
1070 } else {
1071 vm_exit_during_initialization(err_msg("VerifySubSet: \'%s\' memory sub-system is unknown, please correct it", token));
1072 }
1073 token = strtok_r(NULL__null, delimiter, &save_ptr);
1074 }
1075 FREE_C_HEAP_ARRAY(char, subset_list)FreeHeap((char*)(subset_list));
1076}
1077
1078bool Universe::should_verify_subset(uint subset) {
1079 if (verify_flags & subset) {
1080 return true;
1081 }
1082 return false;
1083}
1084
1085void Universe::verify(VerifyOption option, const char* prefix) {
1086 COMPILER2_PRESENT(do { if (!(!DerivedPointerTable::is_active())) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/memory/universe.cpp"
, 1089, "assert(" "!DerivedPointerTable::is_active()" ") failed"
, "DPT should not be active during verification " "(of thread stacks below)"
); ::breakpoint(); } } while (0);
1087 assert(!DerivedPointerTable::is_active(),do { if (!(!DerivedPointerTable::is_active())) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/memory/universe.cpp"
, 1089, "assert(" "!DerivedPointerTable::is_active()" ") failed"
, "DPT should not be active during verification " "(of thread stacks below)"
); ::breakpoint(); } } while (0);
1088 "DPT should not be active during verification "do { if (!(!DerivedPointerTable::is_active())) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/memory/universe.cpp"
, 1089, "assert(" "!DerivedPointerTable::is_active()" ") failed"
, "DPT should not be active during verification " "(of thread stacks below)"
); ::breakpoint(); } } while (0);
1089 "(of thread stacks below)");do { if (!(!DerivedPointerTable::is_active())) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/memory/universe.cpp"
, 1089, "assert(" "!DerivedPointerTable::is_active()" ") failed"
, "DPT should not be active during verification " "(of thread stacks below)"
); ::breakpoint(); } } while (0);
1090 )do { if (!(!DerivedPointerTable::is_active())) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/memory/universe.cpp"
, 1089, "assert(" "!DerivedPointerTable::is_active()" ") failed"
, "DPT should not be active during verification " "(of thread stacks below)"
); ::breakpoint(); } } while (0);
1091
1092 Thread* thread = Thread::current();
1093 ResourceMark rm(thread);
1094 HandleMark hm(thread); // Handles created during verification can be zapped
1095 _verify_count++;
1096
1097 FormatBuffer<> title("Verifying %s", prefix);
1098 GCTraceTime(Info, gc, verify)GCTraceTimeWrapper<LogLevel::Info, (LogTag::_gc), (LogTag::
_verify), (LogTag::__NO_TAG), (LogTag::__NO_TAG), (LogTag::__NO_TAG
), (LogTag::__NO_TAG)>
tm(title.buffer());
1099 if (should_verify_subset(Verify_Threads)) {
1100 log_debug(gc, verify)(!(LogImpl<(LogTag::_gc), (LogTag::_verify), (LogTag::__NO_TAG
), (LogTag::__NO_TAG), (LogTag::__NO_TAG), (LogTag::__NO_TAG)
>::is_level(LogLevel::Debug))) ? (void)0 : LogImpl<(LogTag
::_gc), (LogTag::_verify), (LogTag::__NO_TAG), (LogTag::__NO_TAG
), (LogTag::__NO_TAG), (LogTag::__NO_TAG)>::write<LogLevel
::Debug>
("Threads");
1101 Threads::verify();
1102 }
1103 if (should_verify_subset(Verify_Heap)) {
1104 log_debug(gc, verify)(!(LogImpl<(LogTag::_gc), (LogTag::_verify), (LogTag::__NO_TAG
), (LogTag::__NO_TAG), (LogTag::__NO_TAG), (LogTag::__NO_TAG)
>::is_level(LogLevel::Debug))) ? (void)0 : LogImpl<(LogTag
::_gc), (LogTag::_verify), (LogTag::__NO_TAG), (LogTag::__NO_TAG
), (LogTag::__NO_TAG), (LogTag::__NO_TAG)>::write<LogLevel
::Debug>
("Heap");
1105 heap()->verify(option);
1106 }
1107 if (should_verify_subset(Verify_SymbolTable)) {
1108 log_debug(gc, verify)(!(LogImpl<(LogTag::_gc), (LogTag::_verify), (LogTag::__NO_TAG
), (LogTag::__NO_TAG), (LogTag::__NO_TAG), (LogTag::__NO_TAG)
>::is_level(LogLevel::Debug))) ? (void)0 : LogImpl<(LogTag
::_gc), (LogTag::_verify), (LogTag::__NO_TAG), (LogTag::__NO_TAG
), (LogTag::__NO_TAG), (LogTag::__NO_TAG)>::write<LogLevel
::Debug>
("SymbolTable");
1109 SymbolTable::verify();
1110 }
1111 if (should_verify_subset(Verify_StringTable)) {
1112 log_debug(gc, verify)(!(LogImpl<(LogTag::_gc), (LogTag::_verify), (LogTag::__NO_TAG
), (LogTag::__NO_TAG), (LogTag::__NO_TAG), (LogTag::__NO_TAG)
>::is_level(LogLevel::Debug))) ? (void)0 : LogImpl<(LogTag
::_gc), (LogTag::_verify), (LogTag::__NO_TAG), (LogTag::__NO_TAG
), (LogTag::__NO_TAG), (LogTag::__NO_TAG)>::write<LogLevel
::Debug>
("StringTable");
1113 StringTable::verify();
1114 }
1115 if (should_verify_subset(Verify_CodeCache)) {
1116 log_debug(gc, verify)(!(LogImpl<(LogTag::_gc), (LogTag::_verify), (LogTag::__NO_TAG
), (LogTag::__NO_TAG), (LogTag::__NO_TAG), (LogTag::__NO_TAG)
>::is_level(LogLevel::Debug))) ? (void)0 : LogImpl<(LogTag
::_gc), (LogTag::_verify), (LogTag::__NO_TAG), (LogTag::__NO_TAG
), (LogTag::__NO_TAG), (LogTag::__NO_TAG)>::write<LogLevel
::Debug>
("CodeCache");
1117 CodeCache::verify();
1118 }
1119 if (should_verify_subset(Verify_SystemDictionary)) {
1120 log_debug(gc, verify)(!(LogImpl<(LogTag::_gc), (LogTag::_verify), (LogTag::__NO_TAG
), (LogTag::__NO_TAG), (LogTag::__NO_TAG), (LogTag::__NO_TAG)
>::is_level(LogLevel::Debug))) ? (void)0 : LogImpl<(LogTag
::_gc), (LogTag::_verify), (LogTag::__NO_TAG), (LogTag::__NO_TAG
), (LogTag::__NO_TAG), (LogTag::__NO_TAG)>::write<LogLevel
::Debug>
("SystemDictionary");
1121 SystemDictionary::verify();
1122 }
1123 if (should_verify_subset(Verify_ClassLoaderDataGraph)) {
1124 log_debug(gc, verify)(!(LogImpl<(LogTag::_gc), (LogTag::_verify), (LogTag::__NO_TAG
), (LogTag::__NO_TAG), (LogTag::__NO_TAG), (LogTag::__NO_TAG)
>::is_level(LogLevel::Debug))) ? (void)0 : LogImpl<(LogTag
::_gc), (LogTag::_verify), (LogTag::__NO_TAG), (LogTag::__NO_TAG
), (LogTag::__NO_TAG), (LogTag::__NO_TAG)>::write<LogLevel
::Debug>
("ClassLoaderDataGraph");
1125 ClassLoaderDataGraph::verify();
1126 }
1127 if (should_verify_subset(Verify_MetaspaceUtils)) {
1128 log_debug(gc, verify)(!(LogImpl<(LogTag::_gc), (LogTag::_verify), (LogTag::__NO_TAG
), (LogTag::__NO_TAG), (LogTag::__NO_TAG), (LogTag::__NO_TAG)
>::is_level(LogLevel::Debug))) ? (void)0 : LogImpl<(LogTag
::_gc), (LogTag::_verify), (LogTag::__NO_TAG), (LogTag::__NO_TAG
), (LogTag::__NO_TAG), (LogTag::__NO_TAG)>::write<LogLevel
::Debug>
("MetaspaceUtils");
1129 DEBUG_ONLY(MetaspaceUtils::verify();)MetaspaceUtils::verify();
1130 }
1131 if (should_verify_subset(Verify_JNIHandles)) {
1132 log_debug(gc, verify)(!(LogImpl<(LogTag::_gc), (LogTag::_verify), (LogTag::__NO_TAG
), (LogTag::__NO_TAG), (LogTag::__NO_TAG), (LogTag::__NO_TAG)
>::is_level(LogLevel::Debug))) ? (void)0 : LogImpl<(LogTag
::_gc), (LogTag::_verify), (LogTag::__NO_TAG), (LogTag::__NO_TAG
), (LogTag::__NO_TAG), (LogTag::__NO_TAG)>::write<LogLevel
::Debug>
("JNIHandles");
1133 JNIHandles::verify();
1134 }
1135 if (should_verify_subset(Verify_CodeCacheOops)) {
1136 log_debug(gc, verify)(!(LogImpl<(LogTag::_gc), (LogTag::_verify), (LogTag::__NO_TAG
), (LogTag::__NO_TAG), (LogTag::__NO_TAG), (LogTag::__NO_TAG)
>::is_level(LogLevel::Debug))) ? (void)0 : LogImpl<(LogTag
::_gc), (LogTag::_verify), (LogTag::__NO_TAG), (LogTag::__NO_TAG
), (LogTag::__NO_TAG), (LogTag::__NO_TAG)>::write<LogLevel
::Debug>
("CodeCache Oops");
1137 CodeCache::verify_oops();
1138 }
1139 if (should_verify_subset(Verify_ResolvedMethodTable)) {
1140 log_debug(gc, verify)(!(LogImpl<(LogTag::_gc), (LogTag::_verify), (LogTag::__NO_TAG
), (LogTag::__NO_TAG), (LogTag::__NO_TAG), (LogTag::__NO_TAG)
>::is_level(LogLevel::Debug))) ? (void)0 : LogImpl<(LogTag
::_gc), (LogTag::_verify), (LogTag::__NO_TAG), (LogTag::__NO_TAG
), (LogTag::__NO_TAG), (LogTag::__NO_TAG)>::write<LogLevel
::Debug>
("ResolvedMethodTable Oops");
1141 ResolvedMethodTable::verify();
1142 }
1143 if (should_verify_subset(Verify_StringDedup)) {
1144 log_debug(gc, verify)(!(LogImpl<(LogTag::_gc), (LogTag::_verify), (LogTag::__NO_TAG
), (LogTag::__NO_TAG), (LogTag::__NO_TAG), (LogTag::__NO_TAG)
>::is_level(LogLevel::Debug))) ? (void)0 : LogImpl<(LogTag
::_gc), (LogTag::_verify), (LogTag::__NO_TAG), (LogTag::__NO_TAG
), (LogTag::__NO_TAG), (LogTag::__NO_TAG)>::write<LogLevel
::Debug>
("String Deduplication");
1145 StringDedup::verify();
1146 }
1147}
1148
1149
1150#ifndef PRODUCT
1151void Universe::calculate_verify_data(HeapWord* low_boundary, HeapWord* high_boundary) {
1152 assert(low_boundary < high_boundary, "bad interval")do { if (!(low_boundary < high_boundary)) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/memory/universe.cpp"
, 1152, "assert(" "low_boundary < high_boundary" ") failed"
, "bad interval"); ::breakpoint(); } } while (0)
;
1153
1154 // decide which low-order bits we require to be clear:
1155 size_t alignSize = MinObjAlignmentInBytes;
1156 size_t min_object_size = CollectedHeap::min_fill_size();
1157
1158 // make an inclusive limit:
1159 uintptr_t max = (uintptr_t)high_boundary - min_object_size*wordSize;
1160 uintptr_t min = (uintptr_t)low_boundary;
1161 assert(min < max, "bad interval")do { if (!(min < max)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/memory/universe.cpp"
, 1161, "assert(" "min < max" ") failed", "bad interval");
::breakpoint(); } } while (0)
;
1162 uintptr_t diff = max ^ min;
1163
1164 // throw away enough low-order bits to make the diff vanish
1165 uintptr_t mask = (uintptr_t)(-1);
1166 while ((mask & diff) != 0)
1167 mask <<= 1;
1168 uintptr_t bits = (min & mask);
1169 assert(bits == (max & mask), "correct mask")do { if (!(bits == (max & mask))) { (*g_assert_poison) = 'X'
;; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/memory/universe.cpp"
, 1169, "assert(" "bits == (max & mask)" ") failed", "correct mask"
); ::breakpoint(); } } while (0)
;
1170 // check an intermediate value between min and max, just to make sure:
1171 assert(bits == ((min + (max-min)/2) & mask), "correct mask")do { if (!(bits == ((min + (max-min)/2) & mask))) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/memory/universe.cpp"
, 1171, "assert(" "bits == ((min + (max-min)/2) & mask)" ") failed"
, "correct mask"); ::breakpoint(); } } while (0)
;
1172
1173 // require address alignment, too:
1174 mask |= (alignSize - 1);
1175
1176 if (!(_verify_oop_mask == 0 && _verify_oop_bits == (uintptr_t)-1)) {
1177 assert(_verify_oop_mask == mask && _verify_oop_bits == bits, "mask stability")do { if (!(_verify_oop_mask == mask && _verify_oop_bits
== bits)) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/memory/universe.cpp"
, 1177, "assert(" "_verify_oop_mask == mask && _verify_oop_bits == bits"
") failed", "mask stability"); ::breakpoint(); } } while (0)
;
1178 }
1179 _verify_oop_mask = mask;
1180 _verify_oop_bits = bits;
1181}
1182
1183// Oop verification (see MacroAssembler::verify_oop)
1184
1185uintptr_t Universe::verify_oop_mask() {
1186 return _verify_oop_mask;
1187}
1188
1189uintptr_t Universe::verify_oop_bits() {
1190 return _verify_oop_bits;
1191}
1192
1193uintptr_t Universe::verify_mark_mask() {
1194 return markWord::lock_mask_in_place;
1195}
1196
1197uintptr_t Universe::verify_mark_bits() {
1198 intptr_t mask = verify_mark_mask();
1199 intptr_t bits = (intptr_t)markWord::prototype().value();
1200 assert((bits & ~mask) == 0, "no stray header bits")do { if (!((bits & ~mask) == 0)) { (*g_assert_poison) = 'X'
;; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/memory/universe.cpp"
, 1200, "assert(" "(bits & ~mask) == 0" ") failed", "no stray header bits"
); ::breakpoint(); } } while (0)
;
1201 return bits;
1202}
1203#endif // PRODUCT
1204
1205
1206void LatestMethodCache::init(Klass* k, Method* m) {
1207 if (!UseSharedSpaces) {
6
Assuming 'UseSharedSpaces' is not equal to 0
7
Taking false branch
1208 _klass = k;
1209 }
1210#ifndef PRODUCT
1211 else {
1212 // sharing initilization should have already set up _klass
1213 assert(_klass != NULL, "just checking")do { if (!(_klass != __null)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/memory/universe.cpp"
, 1213, "assert(" "_klass != __null" ") failed", "just checking"
); ::breakpoint(); } } while (0)
;
8
Assuming the condition is true
9
Taking false branch
10
Loop condition is false. Exiting loop
1214 }
1215#endif
1216
1217 _method_idnum = m->method_idnum();
11
Called C++ object pointer is null
1218 assert(_method_idnum >= 0, "sanity check")do { if (!(_method_idnum >= 0)) { (*g_assert_poison) = 'X'
;; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/memory/universe.cpp"
, 1218, "assert(" "_method_idnum >= 0" ") failed", "sanity check"
); ::breakpoint(); } } while (0)
;
1219}
1220
1221
1222Method* LatestMethodCache::get_method() {
1223 if (klass() == NULL__null) return NULL__null;
1224 InstanceKlass* ik = InstanceKlass::cast(klass());
1225 Method* m = ik->method_with_idnum(method_idnum());
1226 assert(m != NULL, "sanity check")do { if (!(m != __null)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/memory/universe.cpp"
, 1226, "assert(" "m != __null" ") failed", "sanity check"); ::
breakpoint(); } } while (0)
;
1227 return m;
1228}
1229
1230#ifdef ASSERT1
1231// Release dummy object(s) at bottom of heap
1232bool Universe::release_fullgc_alot_dummy() {
1233 MutexLocker ml(FullGCALot_lock);
1234 objArrayOop fullgc_alot_dummy_array = (objArrayOop)_fullgc_alot_dummy_array.resolve();
1235 if (fullgc_alot_dummy_array != NULL__null) {
1236 if (_fullgc_alot_dummy_next >= fullgc_alot_dummy_array->length()) {
1237 // No more dummies to release, release entire array instead
1238 _fullgc_alot_dummy_array.release(Universe::vm_global());
1239 return false;
1240 }
1241
1242 // Release dummy at bottom of old generation
1243 fullgc_alot_dummy_array->obj_at_put(_fullgc_alot_dummy_next++, NULL__null);
1244 }
1245 return true;
1246}
1247
1248bool Universe::is_gc_active() {
1249 return heap()->is_gc_active();
1250}
1251
1252bool Universe::is_in_heap(const void* p) {
1253 return heap()->is_in(p);
1254}
1255
1256#endif // ASSERT