Bug Summary

File:jdk/src/hotspot/share/cds/archiveUtils.cpp
Warning:line 57, column 10
Value stored to 'estimated_archive_size' during its initialization is never read

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 archiveUtils.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/cds/archiveUtils.cpp
1/*
2 * Copyright (c) 2019, 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/archiveBuilder.hpp"
27#include "cds/archiveUtils.hpp"
28#include "cds/classListParser.hpp"
29#include "cds/classListWriter.hpp"
30#include "cds/dynamicArchive.hpp"
31#include "cds/filemap.hpp"
32#include "cds/heapShared.inline.hpp"
33#include "cds/metaspaceShared.hpp"
34#include "classfile/systemDictionaryShared.hpp"
35#include "classfile/vmClasses.hpp"
36#include "interpreter/bootstrapInfo.hpp"
37#include "memory/metaspaceUtils.hpp"
38#include "memory/resourceArea.hpp"
39#include "oops/compressedOops.inline.hpp"
40#include "runtime/arguments.hpp"
41#include "utilities/bitMap.inline.hpp"
42#include "utilities/formatBuffer.hpp"
43
44CHeapBitMap* ArchivePtrMarker::_ptrmap = NULL__null;
45VirtualSpace* ArchivePtrMarker::_vs;
46
47bool ArchivePtrMarker::_compacted;
48
49void ArchivePtrMarker::initialize(CHeapBitMap* ptrmap, VirtualSpace* vs) {
50 assert(_ptrmap == NULL, "initialize only once")do { if (!(_ptrmap == __null)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/cds/archiveUtils.cpp"
, 50, "assert(" "_ptrmap == __null" ") failed", "initialize only once"
); ::breakpoint(); } } while (0)
;
51 _vs = vs;
52 _compacted = false;
53 _ptrmap = ptrmap;
54
55 // Use this as initial guesstimate. We should need less space in the
56 // archive, but if we're wrong the bitmap will be expanded automatically.
57 size_t estimated_archive_size = MetaspaceGC::capacity_until_GC();
Value stored to 'estimated_archive_size' during its initialization is never read
58 // But set it smaller in debug builds so we always test the expansion code.
59 // (Default archive is about 12MB).
60 DEBUG_ONLY(estimated_archive_size = 6 * M)estimated_archive_size = 6 * M;
61
62 // We need one bit per pointer in the archive.
63 _ptrmap->initialize(estimated_archive_size / sizeof(intptr_t));
64}
65
66void ArchivePtrMarker::mark_pointer(address* ptr_loc) {
67 assert(_ptrmap != NULL, "not initialized")do { if (!(_ptrmap != __null)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/cds/archiveUtils.cpp"
, 67, "assert(" "_ptrmap != __null" ") failed", "not initialized"
); ::breakpoint(); } } while (0)
;
68 assert(!_compacted, "cannot mark anymore")do { if (!(!_compacted)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/cds/archiveUtils.cpp"
, 68, "assert(" "!_compacted" ") failed", "cannot mark anymore"
); ::breakpoint(); } } while (0)
;
69
70 if (ptr_base() <= ptr_loc && ptr_loc < ptr_end()) {
71 address value = *ptr_loc;
72 // We don't want any pointer that points to very bottom of the archive, otherwise when
73 // MetaspaceShared::default_base_address()==0, we can't distinguish between a pointer
74 // to nothing (NULL) vs a pointer to an objects that happens to be at the very bottom
75 // of the archive.
76 assert(value != (address)ptr_base(), "don't point to the bottom of the archive")do { if (!(value != (address)ptr_base())) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/cds/archiveUtils.cpp"
, 76, "assert(" "value != (address)ptr_base()" ") failed", "don't point to the bottom of the archive"
); ::breakpoint(); } } while (0)
;
77
78 if (value != NULL__null) {
79 assert(uintx(ptr_loc) % sizeof(intptr_t) == 0, "pointers must be stored in aligned addresses")do { if (!(uintx(ptr_loc) % sizeof(intptr_t) == 0)) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/cds/archiveUtils.cpp"
, 79, "assert(" "uintx(ptr_loc) % sizeof(intptr_t) == 0" ") failed"
, "pointers must be stored in aligned addresses"); ::breakpoint
(); } } while (0)
;
80 size_t idx = ptr_loc - ptr_base();
81 if (_ptrmap->size() <= idx) {
82 _ptrmap->resize((idx + 1) * 2);
83 }
84 assert(idx < _ptrmap->size(), "must be")do { if (!(idx < _ptrmap->size())) { (*g_assert_poison)
= 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/cds/archiveUtils.cpp"
, 84, "assert(" "idx < _ptrmap->size()" ") failed", "must be"
); ::breakpoint(); } } while (0)
;
85 _ptrmap->set_bit(idx);
86 //tty->print_cr("Marking pointer [" PTR_FORMAT "] -> " PTR_FORMAT " @ " SIZE_FORMAT_W(5), p2i(ptr_loc), p2i(*ptr_loc), idx);
87 }
88 }
89}
90
91void ArchivePtrMarker::clear_pointer(address* ptr_loc) {
92 assert(_ptrmap != NULL, "not initialized")do { if (!(_ptrmap != __null)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/cds/archiveUtils.cpp"
, 92, "assert(" "_ptrmap != __null" ") failed", "not initialized"
); ::breakpoint(); } } while (0)
;
93 assert(!_compacted, "cannot clear anymore")do { if (!(!_compacted)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/cds/archiveUtils.cpp"
, 93, "assert(" "!_compacted" ") failed", "cannot clear anymore"
); ::breakpoint(); } } while (0)
;
94
95 assert(ptr_base() <= ptr_loc && ptr_loc < ptr_end(), "must be")do { if (!(ptr_base() <= ptr_loc && ptr_loc < ptr_end
())) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/cds/archiveUtils.cpp"
, 95, "assert(" "ptr_base() <= ptr_loc && ptr_loc < ptr_end()"
") failed", "must be"); ::breakpoint(); } } while (0)
;
96 assert(uintx(ptr_loc) % sizeof(intptr_t) == 0, "pointers must be stored in aligned addresses")do { if (!(uintx(ptr_loc) % sizeof(intptr_t) == 0)) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/cds/archiveUtils.cpp"
, 96, "assert(" "uintx(ptr_loc) % sizeof(intptr_t) == 0" ") failed"
, "pointers must be stored in aligned addresses"); ::breakpoint
(); } } while (0)
;
97 size_t idx = ptr_loc - ptr_base();
98 assert(idx < _ptrmap->size(), "cannot clear pointers that have not been marked")do { if (!(idx < _ptrmap->size())) { (*g_assert_poison)
= 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/cds/archiveUtils.cpp"
, 98, "assert(" "idx < _ptrmap->size()" ") failed", "cannot clear pointers that have not been marked"
); ::breakpoint(); } } while (0)
;
99 _ptrmap->clear_bit(idx);
100 //tty->print_cr("Clearing pointer [" PTR_FORMAT "] -> " PTR_FORMAT " @ " SIZE_FORMAT_W(5), p2i(ptr_loc), p2i(*ptr_loc), idx);
101}
102
103class ArchivePtrBitmapCleaner: public BitMapClosure {
104 CHeapBitMap* _ptrmap;
105 address* _ptr_base;
106 address _relocatable_base;
107 address _relocatable_end;
108 size_t _max_non_null_offset;
109
110public:
111 ArchivePtrBitmapCleaner(CHeapBitMap* ptrmap, address* ptr_base, address relocatable_base, address relocatable_end) :
112 _ptrmap(ptrmap), _ptr_base(ptr_base),
113 _relocatable_base(relocatable_base), _relocatable_end(relocatable_end), _max_non_null_offset(0) {}
114
115 bool do_bit(size_t offset) {
116 address* ptr_loc = _ptr_base + offset;
117 address ptr_value = *ptr_loc;
118 if (ptr_value != NULL__null) {
119 assert(_relocatable_base <= ptr_value && ptr_value < _relocatable_end, "do not point to arbitrary locations!")do { if (!(_relocatable_base <= ptr_value && ptr_value
< _relocatable_end)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/cds/archiveUtils.cpp"
, 119, "assert(" "_relocatable_base <= ptr_value && ptr_value < _relocatable_end"
") failed", "do not point to arbitrary locations!"); ::breakpoint
(); } } while (0)
;
120 if (_max_non_null_offset < offset) {
121 _max_non_null_offset = offset;
122 }
123 } else {
124 _ptrmap->clear_bit(offset);
125 DEBUG_ONLY(log_trace(cds, reloc)("Clearing pointer [" PTR_FORMAT "] -> NULL @ " SIZE_FORMAT_W(9), p2i(ptr_loc), offset))(!(LogImpl<(LogTag::_cds), (LogTag::_reloc), (LogTag::__NO_TAG
), (LogTag::__NO_TAG), (LogTag::__NO_TAG), (LogTag::__NO_TAG)
>::is_level(LogLevel::Trace))) ? (void)0 : LogImpl<(LogTag
::_cds), (LogTag::_reloc), (LogTag::__NO_TAG), (LogTag::__NO_TAG
), (LogTag::__NO_TAG), (LogTag::__NO_TAG)>::write<LogLevel
::Trace>("Clearing pointer [" "0x%016" "l" "x" "] -> NULL @ "
"%" "9" "l" "u", p2i(ptr_loc), offset)
;
126 }
127
128 return true;
129 }
130
131 size_t max_non_null_offset() const { return _max_non_null_offset; }
132};
133
134void ArchivePtrMarker::compact(address relocatable_base, address relocatable_end) {
135 assert(!_compacted, "cannot compact again")do { if (!(!_compacted)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/cds/archiveUtils.cpp"
, 135, "assert(" "!_compacted" ") failed", "cannot compact again"
); ::breakpoint(); } } while (0)
;
136 ArchivePtrBitmapCleaner cleaner(_ptrmap, ptr_base(), relocatable_base, relocatable_end);
137 _ptrmap->iterate(&cleaner);
138 compact(cleaner.max_non_null_offset());
139}
140
141void ArchivePtrMarker::compact(size_t max_non_null_offset) {
142 assert(!_compacted, "cannot compact again")do { if (!(!_compacted)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/cds/archiveUtils.cpp"
, 142, "assert(" "!_compacted" ") failed", "cannot compact again"
); ::breakpoint(); } } while (0)
;
143 _ptrmap->resize(max_non_null_offset + 1);
144 _compacted = true;
145}
146
147char* DumpRegion::expand_top_to(char* newtop) {
148 assert(is_allocatable(), "must be initialized and not packed")do { if (!(is_allocatable())) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/cds/archiveUtils.cpp"
, 148, "assert(" "is_allocatable()" ") failed", "must be initialized and not packed"
); ::breakpoint(); } } while (0)
;
149 assert(newtop >= _top, "must not grow backwards")do { if (!(newtop >= _top)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/cds/archiveUtils.cpp"
, 149, "assert(" "newtop >= _top" ") failed", "must not grow backwards"
); ::breakpoint(); } } while (0)
;
150 if (newtop > _end) {
151 ArchiveBuilder::current()->report_out_of_space(_name, newtop - _top);
152 ShouldNotReachHere()do { (*g_assert_poison) = 'X';; report_should_not_reach_here(
"/home/daniel/Projects/java/jdk/src/hotspot/share/cds/archiveUtils.cpp"
, 152); ::breakpoint(); } while (0)
;
153 }
154
155 commit_to(newtop);
156 _top = newtop;
157
158 if (_max_delta > 0) {
159 uintx delta = ArchiveBuilder::current()->buffer_to_offset((address)(newtop-1));
160 if (delta > _max_delta) {
161 // This is just a sanity check and should not appear in any real world usage. This
162 // happens only if you allocate more than 2GB of shared objects and would require
163 // millions of shared classes.
164 vm_exit_during_initialization("Out of memory in the CDS archive",
165 "Please reduce the number of shared classes.");
166 }
167 }
168
169 return _top;
170}
171
172void DumpRegion::commit_to(char* newtop) {
173 Arguments::assert_is_dumping_archive();
174 char* base = _rs->base();
175 size_t need_committed_size = newtop - base;
176 size_t has_committed_size = _vs->committed_size();
177 if (need_committed_size < has_committed_size) {
178 return;
179 }
180
181 size_t min_bytes = need_committed_size - has_committed_size;
182 size_t preferred_bytes = 1 * M;
183 size_t uncommitted = _vs->reserved_size() - has_committed_size;
184
185 size_t commit = MAX2(min_bytes, preferred_bytes);
186 commit = MIN2(commit, uncommitted);
187 assert(commit <= uncommitted, "sanity")do { if (!(commit <= uncommitted)) { (*g_assert_poison) = 'X'
;; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/cds/archiveUtils.cpp"
, 187, "assert(" "commit <= uncommitted" ") failed", "sanity"
); ::breakpoint(); } } while (0)
;
188
189 if (!_vs->expand_by(commit, false)) {
190 vm_exit_during_initialization(err_msg("Failed to expand shared space to " SIZE_FORMAT"%" "l" "u" " bytes",
191 need_committed_size));
192 }
193
194 const char* which;
195 if (_rs->base() == (char*)MetaspaceShared::symbol_rs_base()) {
196 which = "symbol";
197 } else {
198 which = "shared";
199 }
200 log_debug(cds)(!(LogImpl<(LogTag::_cds), (LogTag::__NO_TAG), (LogTag::__NO_TAG
), (LogTag::__NO_TAG), (LogTag::__NO_TAG), (LogTag::__NO_TAG)
>::is_level(LogLevel::Debug))) ? (void)0 : LogImpl<(LogTag
::_cds), (LogTag::__NO_TAG), (LogTag::__NO_TAG), (LogTag::__NO_TAG
), (LogTag::__NO_TAG), (LogTag::__NO_TAG)>::write<LogLevel
::Debug>
("Expanding %s spaces by " SIZE_FORMAT_W(7)"%" "7" "l" "u" " bytes [total " SIZE_FORMAT_W(9)"%" "9" "l" "u" " bytes ending at %p]",
201 which, commit, _vs->actual_committed_size(), _vs->high());
202}
203
204
205char* DumpRegion::allocate(size_t num_bytes) {
206 char* p = (char*)align_up(_top, (size_t)SharedSpaceObjectAlignment);
207 char* newtop = p + align_up(num_bytes, (size_t)SharedSpaceObjectAlignment);
208 expand_top_to(newtop);
209 memset(p, 0, newtop - p);
210 return p;
211}
212
213void DumpRegion::append_intptr_t(intptr_t n, bool need_to_mark) {
214 assert(is_aligned(_top, sizeof(intptr_t)), "bad alignment")do { if (!(is_aligned(_top, sizeof(intptr_t)))) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/cds/archiveUtils.cpp"
, 214, "assert(" "is_aligned(_top, sizeof(intptr_t))" ") failed"
, "bad alignment"); ::breakpoint(); } } while (0)
;
215 intptr_t *p = (intptr_t*)_top;
216 char* newtop = _top + sizeof(intptr_t);
217 expand_top_to(newtop);
218 *p = n;
219 if (need_to_mark) {
220 ArchivePtrMarker::mark_pointer(p);
221 }
222}
223
224void DumpRegion::print(size_t total_bytes) const {
225 log_debug(cds)(!(LogImpl<(LogTag::_cds), (LogTag::__NO_TAG), (LogTag::__NO_TAG
), (LogTag::__NO_TAG), (LogTag::__NO_TAG), (LogTag::__NO_TAG)
>::is_level(LogLevel::Debug))) ? (void)0 : LogImpl<(LogTag
::_cds), (LogTag::__NO_TAG), (LogTag::__NO_TAG), (LogTag::__NO_TAG
), (LogTag::__NO_TAG), (LogTag::__NO_TAG)>::write<LogLevel
::Debug>
("%-3s space: " SIZE_FORMAT_W(9)"%" "9" "l" "u" " [ %4.1f%% of total] out of " SIZE_FORMAT_W(9)"%" "9" "l" "u" " bytes [%5.1f%% used] at " INTPTR_FORMAT"0x%016" "l" "x",
226 _name, used(), percent_of(used(), total_bytes), reserved(), percent_of(used(), reserved()),
227 p2i(ArchiveBuilder::current()->to_requested(_base)));
228}
229
230void DumpRegion::print_out_of_space_msg(const char* failing_region, size_t needed_bytes) {
231 log_error(cds)(!(LogImpl<(LogTag::_cds), (LogTag::__NO_TAG), (LogTag::__NO_TAG
), (LogTag::__NO_TAG), (LogTag::__NO_TAG), (LogTag::__NO_TAG)
>::is_level(LogLevel::Error))) ? (void)0 : LogImpl<(LogTag
::_cds), (LogTag::__NO_TAG), (LogTag::__NO_TAG), (LogTag::__NO_TAG
), (LogTag::__NO_TAG), (LogTag::__NO_TAG)>::write<LogLevel
::Error>
("[%-8s] " PTR_FORMAT"0x%016" "l" "x" " - " PTR_FORMAT"0x%016" "l" "x" " capacity =%9d, allocated =%9d",
232 _name, p2i(_base), p2i(_top), int(_end - _base), int(_top - _base));
233 if (strcmp(_name, failing_region) == 0) {
234 log_error(cds)(!(LogImpl<(LogTag::_cds), (LogTag::__NO_TAG), (LogTag::__NO_TAG
), (LogTag::__NO_TAG), (LogTag::__NO_TAG), (LogTag::__NO_TAG)
>::is_level(LogLevel::Error))) ? (void)0 : LogImpl<(LogTag
::_cds), (LogTag::__NO_TAG), (LogTag::__NO_TAG), (LogTag::__NO_TAG
), (LogTag::__NO_TAG), (LogTag::__NO_TAG)>::write<LogLevel
::Error>
(" required = %d", int(needed_bytes));
235 }
236}
237
238void DumpRegion::init(ReservedSpace* rs, VirtualSpace* vs) {
239 _rs = rs;
240 _vs = vs;
241 // Start with 0 committed bytes. The memory will be committed as needed.
242 if (!_vs->initialize(*_rs, 0)) {
243 fatal("Unable to allocate memory for shared space")do { (*g_assert_poison) = 'X';; report_fatal(INTERNAL_ERROR, "/home/daniel/Projects/java/jdk/src/hotspot/share/cds/archiveUtils.cpp"
, 243, "Unable to allocate memory for shared space"); ::breakpoint
(); } while (0)
;
244 }
245 _base = _top = _rs->base();
246 _end = _rs->end();
247}
248
249void DumpRegion::pack(DumpRegion* next) {
250 assert(!is_packed(), "sanity")do { if (!(!is_packed())) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/cds/archiveUtils.cpp"
, 250, "assert(" "!is_packed()" ") failed", "sanity"); ::breakpoint
(); } } while (0)
;
251 _end = (char*)align_up(_top, MetaspaceShared::core_region_alignment());
252 _is_packed = true;
253 if (next != NULL__null) {
254 next->_rs = _rs;
255 next->_vs = _vs;
256 next->_base = next->_top = this->_end;
257 next->_end = _rs->end();
258 }
259}
260
261void WriteClosure::do_oop(oop* o) {
262 if (*o == NULL__null) {
263 _dump_region->append_intptr_t(0);
264 } else {
265 assert(HeapShared::can_write(), "sanity")do { if (!(HeapShared::can_write())) { (*g_assert_poison) = 'X'
;; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/cds/archiveUtils.cpp"
, 265, "assert(" "HeapShared::can_write()" ") failed", "sanity"
); ::breakpoint(); } } while (0)
;
266 _dump_region->append_intptr_t(
267 (intptr_t)CompressedOops::encode_not_null(*o));
268 }
269}
270
271void WriteClosure::do_region(u_char* start, size_t size) {
272 assert((intptr_t)start % sizeof(intptr_t) == 0, "bad alignment")do { if (!((intptr_t)start % sizeof(intptr_t) == 0)) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/cds/archiveUtils.cpp"
, 272, "assert(" "(intptr_t)start % sizeof(intptr_t) == 0" ") failed"
, "bad alignment"); ::breakpoint(); } } while (0)
;
273 assert(size % sizeof(intptr_t) == 0, "bad size")do { if (!(size % sizeof(intptr_t) == 0)) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/cds/archiveUtils.cpp"
, 273, "assert(" "size % sizeof(intptr_t) == 0" ") failed", "bad size"
); ::breakpoint(); } } while (0)
;
274 do_tag((int)size);
275 while (size > 0) {
276 _dump_region->append_intptr_t(*(intptr_t*)start, true);
277 start += sizeof(intptr_t);
278 size -= sizeof(intptr_t);
279 }
280}
281
282void ReadClosure::do_ptr(void** p) {
283 assert(*p == NULL, "initializing previous initialized pointer.")do { if (!(*p == __null)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/cds/archiveUtils.cpp"
, 283, "assert(" "*p == __null" ") failed", "initializing previous initialized pointer."
); ::breakpoint(); } } while (0)
;
284 intptr_t obj = nextPtr();
285 assert((intptr_t)obj >= 0 || (intptr_t)obj < -100,do { if (!((intptr_t)obj >= 0 || (intptr_t)obj < -100))
{ (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/cds/archiveUtils.cpp"
, 286, "assert(" "(intptr_t)obj >= 0 || (intptr_t)obj < -100"
") failed", "hit tag while initializing ptrs."); ::breakpoint
(); } } while (0)
286 "hit tag while initializing ptrs.")do { if (!((intptr_t)obj >= 0 || (intptr_t)obj < -100))
{ (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/cds/archiveUtils.cpp"
, 286, "assert(" "(intptr_t)obj >= 0 || (intptr_t)obj < -100"
") failed", "hit tag while initializing ptrs."); ::breakpoint
(); } } while (0)
;
287 *p = (void*)obj;
288}
289
290void ReadClosure::do_u4(u4* p) {
291 intptr_t obj = nextPtr();
292 *p = (u4)(uintx(obj));
293}
294
295void ReadClosure::do_bool(bool* p) {
296 intptr_t obj = nextPtr();
297 *p = (bool)(uintx(obj));
298}
299
300void ReadClosure::do_tag(int tag) {
301 int old_tag;
302 old_tag = (int)(intptr_t)nextPtr();
303 // do_int(&old_tag);
304 assert(tag == old_tag, "old tag doesn't match")do { if (!(tag == old_tag)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/cds/archiveUtils.cpp"
, 304, "assert(" "tag == old_tag" ") failed", "old tag doesn't match"
); ::breakpoint(); } } while (0)
;
305 FileMapInfo::assert_mark(tag == old_tag);
306}
307
308void ReadClosure::do_oop(oop *p) {
309 narrowOop o = CompressedOops::narrow_oop_cast(nextPtr());
310 if (CompressedOops::is_null(o) || !HeapShared::is_fully_available()) {
311 *p = NULL__null;
312 } else {
313 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/cds/archiveUtils.cpp"
, 313, "assert(" "HeapShared::can_use()" ") failed", "sanity"
); ::breakpoint(); } } while (0)
;
314 assert(HeapShared::is_fully_available(), "must be")do { if (!(HeapShared::is_fully_available())) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/cds/archiveUtils.cpp"
, 314, "assert(" "HeapShared::is_fully_available()" ") failed"
, "must be"); ::breakpoint(); } } while (0)
;
315 *p = HeapShared::decode_from_archive(o);
316 }
317}
318
319void ReadClosure::do_region(u_char* start, size_t size) {
320 assert((intptr_t)start % sizeof(intptr_t) == 0, "bad alignment")do { if (!((intptr_t)start % sizeof(intptr_t) == 0)) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/cds/archiveUtils.cpp"
, 320, "assert(" "(intptr_t)start % sizeof(intptr_t) == 0" ") failed"
, "bad alignment"); ::breakpoint(); } } while (0)
;
321 assert(size % sizeof(intptr_t) == 0, "bad size")do { if (!(size % sizeof(intptr_t) == 0)) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/cds/archiveUtils.cpp"
, 321, "assert(" "size % sizeof(intptr_t) == 0" ") failed", "bad size"
); ::breakpoint(); } } while (0)
;
322 do_tag((int)size);
323 while (size > 0) {
324 *(intptr_t*)start = nextPtr();
325 start += sizeof(intptr_t);
326 size -= sizeof(intptr_t);
327 }
328}
329
330void ArchiveUtils::log_to_classlist(BootstrapInfo* bootstrap_specifier, TRAPSJavaThread* __the_thread__) {
331 if (ClassListWriter::is_enabled()) {
332 if (SystemDictionaryShared::is_supported_invokedynamic(bootstrap_specifier)) {
333 const constantPoolHandle& pool = bootstrap_specifier->pool();
334 if (SystemDictionaryShared::is_builtin_loader(pool->pool_holder()->class_loader_data())) {
335 // Currently lambda proxy classes are supported only for the built-in loaders.
336 ResourceMark rm(THREAD__the_thread__);
337 int pool_index = bootstrap_specifier->bss_index();
338 ClassListWriter w;
339 w.stream()->print("%s %s", LAMBDA_PROXY_TAG"@lambda-proxy", pool->pool_holder()->name()->as_C_string());
340 CDSIndyInfo cii;
341 ClassListParser::populate_cds_indy_info(pool, pool_index, &cii, CHECK__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception
())) return ; (void)(0
);
342 GrowableArray<const char*>* indy_items = cii.items();
343 for (int i = 0; i < indy_items->length(); i++) {
344 w.stream()->print(" %s", indy_items->at(i));
345 }
346 w.stream()->cr();
347 }
348 }
349 }
350}