Bug Summary

File:jdk/src/hotspot/share/runtime/deoptimization.cpp
Warning:line 2464, column 5
Value stored to 'len' 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 deoptimization.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/runtime/deoptimization.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 "jvm.h"
27#include "classfile/javaClasses.inline.hpp"
28#include "classfile/symbolTable.hpp"
29#include "classfile/systemDictionary.hpp"
30#include "classfile/vmClasses.hpp"
31#include "code/codeCache.hpp"
32#include "code/debugInfoRec.hpp"
33#include "code/nmethod.hpp"
34#include "code/pcDesc.hpp"
35#include "code/scopeDesc.hpp"
36#include "compiler/compilationPolicy.hpp"
37#include "gc/shared/collectedHeap.hpp"
38#include "interpreter/bytecode.hpp"
39#include "interpreter/interpreter.hpp"
40#include "interpreter/oopMapCache.hpp"
41#include "memory/allocation.inline.hpp"
42#include "memory/oopFactory.hpp"
43#include "memory/resourceArea.hpp"
44#include "memory/universe.hpp"
45#include "oops/constantPool.hpp"
46#include "oops/method.hpp"
47#include "oops/objArrayKlass.hpp"
48#include "oops/objArrayOop.inline.hpp"
49#include "oops/oop.inline.hpp"
50#include "oops/fieldStreams.inline.hpp"
51#include "oops/typeArrayOop.inline.hpp"
52#include "oops/verifyOopClosure.hpp"
53#include "prims/jvmtiDeferredUpdates.hpp"
54#include "prims/jvmtiExport.hpp"
55#include "prims/jvmtiThreadState.hpp"
56#include "prims/vectorSupport.hpp"
57#include "prims/methodHandles.hpp"
58#include "runtime/atomic.hpp"
59#include "runtime/deoptimization.hpp"
60#include "runtime/escapeBarrier.hpp"
61#include "runtime/fieldDescriptor.hpp"
62#include "runtime/fieldDescriptor.inline.hpp"
63#include "runtime/frame.inline.hpp"
64#include "runtime/handles.inline.hpp"
65#include "runtime/interfaceSupport.inline.hpp"
66#include "runtime/jniHandles.inline.hpp"
67#include "runtime/keepStackGCProcessed.hpp"
68#include "runtime/objectMonitor.inline.hpp"
69#include "runtime/osThread.hpp"
70#include "runtime/safepointVerifiers.hpp"
71#include "runtime/sharedRuntime.hpp"
72#include "runtime/signature.hpp"
73#include "runtime/stackFrameStream.inline.hpp"
74#include "runtime/stackWatermarkSet.hpp"
75#include "runtime/stubRoutines.hpp"
76#include "runtime/thread.hpp"
77#include "runtime/threadSMR.hpp"
78#include "runtime/threadWXSetters.inline.hpp"
79#include "runtime/vframe.hpp"
80#include "runtime/vframeArray.hpp"
81#include "runtime/vframe_hp.hpp"
82#include "runtime/vmOperations.hpp"
83#include "utilities/events.hpp"
84#include "utilities/macros.hpp"
85#include "utilities/preserveException.hpp"
86#include "utilities/xmlstream.hpp"
87#if INCLUDE_JFR1
88#include "jfr/jfrEvents.hpp"
89#include "jfr/metadata/jfrSerializer.hpp"
90#endif
91
92bool DeoptimizationMarker::_is_active = false;
93
94Deoptimization::UnrollBlock::UnrollBlock(int size_of_deoptimized_frame,
95 int caller_adjustment,
96 int caller_actual_parameters,
97 int number_of_frames,
98 intptr_t* frame_sizes,
99 address* frame_pcs,
100 BasicType return_type,
101 int exec_mode) {
102 _size_of_deoptimized_frame = size_of_deoptimized_frame;
103 _caller_adjustment = caller_adjustment;
104 _caller_actual_parameters = caller_actual_parameters;
105 _number_of_frames = number_of_frames;
106 _frame_sizes = frame_sizes;
107 _frame_pcs = frame_pcs;
108 _register_block = NEW_C_HEAP_ARRAY(intptr_t, RegisterMap::reg_count * 2, mtCompiler)(intptr_t*) (AllocateHeap((RegisterMap::reg_count * 2) * sizeof
(intptr_t), mtCompiler))
;
109 _return_type = return_type;
110 _initial_info = 0;
111 // PD (x86 only)
112 _counter_temp = 0;
113 _unpack_kind = exec_mode;
114 _sender_sp_temp = 0;
115
116 _total_frame_sizes = size_of_frames();
117 assert(exec_mode >= 0 && exec_mode < Unpack_LIMIT, "Unexpected exec_mode")do { if (!(exec_mode >= 0 && exec_mode < Unpack_LIMIT
)) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/runtime/deoptimization.cpp"
, 117, "assert(" "exec_mode >= 0 && exec_mode < Unpack_LIMIT"
") failed", "Unexpected exec_mode"); ::breakpoint(); } } while
(0)
;
118}
119
120
121Deoptimization::UnrollBlock::~UnrollBlock() {
122 FREE_C_HEAP_ARRAY(intptr_t, _frame_sizes)FreeHeap((char*)(_frame_sizes));
123 FREE_C_HEAP_ARRAY(intptr_t, _frame_pcs)FreeHeap((char*)(_frame_pcs));
124 FREE_C_HEAP_ARRAY(intptr_t, _register_block)FreeHeap((char*)(_register_block));
125}
126
127
128intptr_t* Deoptimization::UnrollBlock::value_addr_at(int register_number) const {
129 assert(register_number < RegisterMap::reg_count, "checking register number")do { if (!(register_number < RegisterMap::reg_count)) { (*
g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/runtime/deoptimization.cpp"
, 129, "assert(" "register_number < RegisterMap::reg_count"
") failed", "checking register number"); ::breakpoint(); } }
while (0)
;
130 return &_register_block[register_number * 2];
131}
132
133
134
135int Deoptimization::UnrollBlock::size_of_frames() const {
136 // Acount first for the adjustment of the initial frame
137 int result = _caller_adjustment;
138 for (int index = 0; index < number_of_frames(); index++) {
139 result += frame_sizes()[index];
140 }
141 return result;
142}
143
144
145void Deoptimization::UnrollBlock::print() {
146 ResourceMark rm;
147 stringStream st;
148 st.print_cr("UnrollBlock");
149 st.print_cr(" size_of_deoptimized_frame = %d", _size_of_deoptimized_frame);
150 st.print( " frame_sizes: ");
151 for (int index = 0; index < number_of_frames(); index++) {
152 st.print(INTX_FORMAT"%" "l" "d" " ", frame_sizes()[index]);
153 }
154 st.cr();
155 tty->print_raw(st.as_string());
156}
157
158
159// In order to make fetch_unroll_info work properly with escape
160// analysis, the method was changed from JRT_LEAF to JRT_BLOCK_ENTRY.
161// The actual reallocation of previously eliminated objects occurs in realloc_objects,
162// which is called from the method fetch_unroll_info_helper below.
163JRT_BLOCK_ENTRY(Deoptimization::UnrollBlock*, Deoptimization::fetch_unroll_info(JavaThread* current, int exec_mode))Deoptimization::UnrollBlock* Deoptimization::fetch_unroll_info
(JavaThread* current, int exec_mode) { do { if (!(current == JavaThread
::current())) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/runtime/deoptimization.cpp"
, 163, "assert(" "current == JavaThread::current()" ") failed"
, "Must be"); ::breakpoint(); } } while (0); ; HandleMarkCleaner
__hm(current);
164 // fetch_unroll_info() is called at the beginning of the deoptimization
165 // handler. Note this fact before we start generating temporary frames
166 // that can confuse an asynchronous stack walker. This counter is
167 // decremented at the end of unpack_frames().
168 if (TraceDeoptimization) {
169 tty->print_cr("Deoptimizing thread " INTPTR_FORMAT"0x%016" "l" "x", p2i(current));
170 }
171 current->inc_in_deopt_handler();
172
173 if (exec_mode == Unpack_exception) {
174 // When we get here, a callee has thrown an exception into a deoptimized
175 // frame. That throw might have deferred stack watermark checking until
176 // after unwinding. So we deal with such deferred requests here.
177 StackWatermarkSet::after_unwind(current);
178 }
179
180 return fetch_unroll_info_helper(current, exec_mode);
181JRT_END}
182
183#if COMPILER2_OR_JVMCI1
184#ifndef PRODUCT
185// print information about reallocated objects
186static void print_objects(JavaThread* deoptee_thread,
187 GrowableArray<ScopeValue*>* objects, bool realloc_failures) {
188 ResourceMark rm;
189 stringStream st; // change to logStream with logging
190 st.print_cr("REALLOC OBJECTS in thread " INTPTR_FORMAT"0x%016" "l" "x", p2i(deoptee_thread));
191 fieldDescriptor fd;
192
193 for (int i = 0; i < objects->length(); i++) {
194 ObjectValue* sv = (ObjectValue*) objects->at(i);
195 Klass* k = java_lang_Class::as_Klass(sv->klass()->as_ConstantOopReadValue()->value()());
196 Handle obj = sv->value();
197
198 st.print(" object <" INTPTR_FORMAT"0x%016" "l" "x" "> of type ", p2i(sv->value()()));
199 k->print_value_on(&st);
200 assert(obj.not_null() || realloc_failures, "reallocation was missed")do { if (!(obj.not_null() || realloc_failures)) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/runtime/deoptimization.cpp"
, 200, "assert(" "obj.not_null() || realloc_failures" ") failed"
, "reallocation was missed"); ::breakpoint(); } } while (0)
;
201 if (obj.is_null()) {
202 st.print(" allocation failed");
203 } else {
204 st.print(" allocated (" SIZE_FORMAT"%" "l" "u" " bytes)", obj->size() * HeapWordSize);
205 }
206 st.cr();
207
208 if (Verbose && !obj.is_null()) {
209 k->oop_print_on(obj(), &st);
210 }
211 }
212 tty->print_raw(st.as_string());
213}
214#endif
215
216static bool rematerialize_objects(JavaThread* thread, int exec_mode, CompiledMethod* compiled_method,
217 frame& deoptee, RegisterMap& map, GrowableArray<compiledVFrame*>* chunk,
218 bool& deoptimized_objects) {
219 bool realloc_failures = false;
220 assert (chunk->at(0)->scope() != NULL,"expect only compiled java frames")do { if (!(chunk->at(0)->scope() != __null)) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/runtime/deoptimization.cpp"
, 220, "assert(" "chunk->at(0)->scope() != __null" ") failed"
, "expect only compiled java frames"); ::breakpoint(); } } while
(0)
;
221
222 JavaThread* deoptee_thread = chunk->at(0)->thread();
223 assert(exec_mode == Deoptimization::Unpack_none || (deoptee_thread == thread),do { if (!(exec_mode == Deoptimization::Unpack_none || (deoptee_thread
== thread))) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/runtime/deoptimization.cpp"
, 224, "assert(" "exec_mode == Deoptimization::Unpack_none || (deoptee_thread == thread)"
") failed", "a frame can only be deoptimized by the owner thread"
); ::breakpoint(); } } while (0)
224 "a frame can only be deoptimized by the owner thread")do { if (!(exec_mode == Deoptimization::Unpack_none || (deoptee_thread
== thread))) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/runtime/deoptimization.cpp"
, 224, "assert(" "exec_mode == Deoptimization::Unpack_none || (deoptee_thread == thread)"
") failed", "a frame can only be deoptimized by the owner thread"
); ::breakpoint(); } } while (0)
;
225
226 GrowableArray<ScopeValue*>* objects = chunk->at(0)->scope()->objects();
227
228 // The flag return_oop() indicates call sites which return oop
229 // in compiled code. Such sites include java method calls,
230 // runtime calls (for example, used to allocate new objects/arrays
231 // on slow code path) and any other calls generated in compiled code.
232 // It is not guaranteed that we can get such information here only
233 // by analyzing bytecode in deoptimized frames. This is why this flag
234 // is set during method compilation (see Compile::Process_OopMap_Node()).
235 // If the previous frame was popped or if we are dispatching an exception,
236 // we don't have an oop result.
237 bool save_oop_result = chunk->at(0)->scope()->return_oop() && !thread->popframe_forcing_deopt_reexecution() && (exec_mode == Deoptimization::Unpack_deopt);
238 Handle return_value;
239 if (save_oop_result) {
240 // Reallocation may trigger GC. If deoptimization happened on return from
241 // call which returns oop we need to save it since it is not in oopmap.
242 oop result = deoptee.saved_oop_result(&map);
243 assert(oopDesc::is_oop_or_null(result), "must be oop")do { if (!(oopDesc::is_oop_or_null(result))) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/runtime/deoptimization.cpp"
, 243, "assert(" "oopDesc::is_oop_or_null(result)" ") failed"
, "must be oop"); ::breakpoint(); } } while (0)
;
244 return_value = Handle(thread, result);
245 assert(Universe::heap()->is_in_or_null(result), "must be heap pointer")do { if (!(Universe::heap()->is_in_or_null(result))) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/runtime/deoptimization.cpp"
, 245, "assert(" "Universe::heap()->is_in_or_null(result)"
") failed", "must be heap pointer"); ::breakpoint(); } } while
(0)
;
246 if (TraceDeoptimization) {
247 tty->print_cr("SAVED OOP RESULT " INTPTR_FORMAT"0x%016" "l" "x" " in thread " INTPTR_FORMAT"0x%016" "l" "x", p2i(result), p2i(thread));
248 }
249 }
250 if (objects != NULL__null) {
251 if (exec_mode == Deoptimization::Unpack_none) {
252 assert(thread->thread_state() == _thread_in_vm, "assumption")do { if (!(thread->thread_state() == _thread_in_vm)) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/runtime/deoptimization.cpp"
, 252, "assert(" "thread->thread_state() == _thread_in_vm"
") failed", "assumption"); ::breakpoint(); } } while (0)
;
253 JavaThread* THREAD__the_thread__ = thread; // For exception macros.
254 // Clear pending OOM if reallocation fails and return true indicating allocation failure
255 realloc_failures = Deoptimization::realloc_objects(thread, &deoptee, &map, objects, CHECK_AND_CLEAR_(true)__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception
())) { (((ThreadShadow*)__the_thread__)->clear_pending_exception
()); return true; } (void)(0
);
256 deoptimized_objects = true;
257 } else {
258 JavaThread* current = thread; // For JRT_BLOCK
259 JRT_BLOCK{ do { if (!(current == JavaThread::current())) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/runtime/deoptimization.cpp"
, 259, "assert(" "current == JavaThread::current()" ") failed"
, "Must be"); ::breakpoint(); } } while (0); ThreadInVMfromJava
__tiv(current); JavaThread* __the_thread__ = current; VMEntryWrapper
__vew;
260 realloc_failures = Deoptimization::realloc_objects(thread, &deoptee, &map, objects, THREAD__the_thread__);
261 JRT_END}
262 }
263 bool skip_internal = (compiled_method != NULL__null) && !compiled_method->is_compiled_by_jvmci();
264 Deoptimization::reassign_fields(&deoptee, &map, objects, realloc_failures, skip_internal);
265#ifndef PRODUCT
266 if (TraceDeoptimization) {
267 print_objects(deoptee_thread, objects, realloc_failures);
268 }
269#endif
270 }
271 if (save_oop_result) {
272 // Restore result.
273 deoptee.set_saved_oop_result(&map, return_value());
274 }
275 return realloc_failures;
276}
277
278static void restore_eliminated_locks(JavaThread* thread, GrowableArray<compiledVFrame*>* chunk, bool realloc_failures,
279 frame& deoptee, int exec_mode, bool& deoptimized_objects) {
280 JavaThread* deoptee_thread = chunk->at(0)->thread();
281 assert(!EscapeBarrier::objs_are_deoptimized(deoptee_thread, deoptee.id()), "must relock just once")do { if (!(!EscapeBarrier::objs_are_deoptimized(deoptee_thread
, deoptee.id()))) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/runtime/deoptimization.cpp"
, 281, "assert(" "!EscapeBarrier::objs_are_deoptimized(deoptee_thread, deoptee.id())"
") failed", "must relock just once"); ::breakpoint(); } } while
(0)
;
282 assert(thread == Thread::current(), "should be")do { if (!(thread == Thread::current())) { (*g_assert_poison)
= 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/runtime/deoptimization.cpp"
, 282, "assert(" "thread == Thread::current()" ") failed", "should be"
); ::breakpoint(); } } while (0)
;
283 HandleMark hm(thread);
284#ifndef PRODUCT
285 bool first = true;
286#endif
287 for (int i = 0; i < chunk->length(); i++) {
288 compiledVFrame* cvf = chunk->at(i);
289 assert (cvf->scope() != NULL,"expect only compiled java frames")do { if (!(cvf->scope() != __null)) { (*g_assert_poison) =
'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/runtime/deoptimization.cpp"
, 289, "assert(" "cvf->scope() != __null" ") failed", "expect only compiled java frames"
); ::breakpoint(); } } while (0)
;
290 GrowableArray<MonitorInfo*>* monitors = cvf->monitors();
291 if (monitors->is_nonempty()) {
292 bool relocked = Deoptimization::relock_objects(thread, monitors, deoptee_thread, deoptee,
293 exec_mode, realloc_failures);
294 deoptimized_objects = deoptimized_objects || relocked;
295#ifndef PRODUCT
296 if (PrintDeoptimizationDetails) {
297 ResourceMark rm;
298 stringStream st;
299 for (int j = 0; j < monitors->length(); j++) {
300 MonitorInfo* mi = monitors->at(j);
301 if (mi->eliminated()) {
302 if (first) {
303 first = false;
304 st.print_cr("RELOCK OBJECTS in thread " INTPTR_FORMAT"0x%016" "l" "x", p2i(thread));
305 }
306 if (exec_mode == Deoptimization::Unpack_none) {
307 ObjectMonitor* monitor = deoptee_thread->current_waiting_monitor();
308 if (monitor != NULL__null && monitor->object() == mi->owner()) {
309 st.print_cr(" object <" INTPTR_FORMAT"0x%016" "l" "x" "> DEFERRED relocking after wait", p2i(mi->owner()));
310 continue;
311 }
312 }
313 if (mi->owner_is_scalar_replaced()) {
314 Klass* k = java_lang_Class::as_Klass(mi->owner_klass());
315 st.print_cr(" failed reallocation for klass %s", k->external_name());
316 } else {
317 st.print_cr(" object <" INTPTR_FORMAT"0x%016" "l" "x" "> locked", p2i(mi->owner()));
318 }
319 }
320 }
321 tty->print_raw(st.as_string());
322 }
323#endif // !PRODUCT
324 }
325 }
326}
327
328// Deoptimize objects, that is reallocate and relock them, just before they escape through JVMTI.
329// The given vframes cover one physical frame.
330bool Deoptimization::deoptimize_objects_internal(JavaThread* thread, GrowableArray<compiledVFrame*>* chunk,
331 bool& realloc_failures) {
332 frame deoptee = chunk->at(0)->fr();
333 JavaThread* deoptee_thread = chunk->at(0)->thread();
334 CompiledMethod* cm = deoptee.cb()->as_compiled_method_or_null();
335 RegisterMap map(chunk->at(0)->register_map());
336 bool deoptimized_objects = false;
337
338 bool const jvmci_enabled = JVMCI_ONLY(UseJVMCICompiler)UseJVMCICompiler NOT_JVMCI(false);
339
340 // Reallocate the non-escaping objects and restore their fields.
341 if (jvmci_enabled COMPILER2_PRESENT(|| (DoEscapeAnalysis && EliminateAllocations)|| (DoEscapeAnalysis && EliminateAllocations) || EliminateAutoBox
|| EnableVectorAggressiveReboxing
342 || EliminateAutoBox || EnableVectorAggressiveReboxing)|| (DoEscapeAnalysis && EliminateAllocations) || EliminateAutoBox
|| EnableVectorAggressiveReboxing
) {
343 realloc_failures = rematerialize_objects(thread, Unpack_none, cm, deoptee, map, chunk, deoptimized_objects);
344 }
345
346 // MonitorInfo structures used in eliminate_locks are not GC safe.
347 NoSafepointVerifier no_safepoint;
348
349 // Now relock objects if synchronization on them was eliminated.
350 if (jvmci_enabled COMPILER2_PRESENT(|| ((DoEscapeAnalysis || EliminateNestedLocks) && EliminateLocks))|| ((DoEscapeAnalysis || EliminateNestedLocks) && EliminateLocks
)
) {
351 restore_eliminated_locks(thread, chunk, realloc_failures, deoptee, Unpack_none, deoptimized_objects);
352 }
353 return deoptimized_objects;
354}
355#endif // COMPILER2_OR_JVMCI
356
357// This is factored, since it is both called from a JRT_LEAF (deoptimization) and a JRT_ENTRY (uncommon_trap)
358Deoptimization::UnrollBlock* Deoptimization::fetch_unroll_info_helper(JavaThread* current, int exec_mode) {
359 // When we get here we are about to unwind the deoptee frame. In order to
360 // catch not yet safe to use frames, the following stack watermark barrier
361 // poll will make such frames safe to use.
362 StackWatermarkSet::before_unwind(current);
363
364 // Note: there is a safepoint safety issue here. No matter whether we enter
365 // via vanilla deopt or uncommon trap we MUST NOT stop at a safepoint once
366 // the vframeArray is created.
367 //
368
369 // Allocate our special deoptimization ResourceMark
370 DeoptResourceMark* dmark = new DeoptResourceMark(current);
371 assert(current->deopt_mark() == NULL, "Pending deopt!")do { if (!(current->deopt_mark() == __null)) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/runtime/deoptimization.cpp"
, 371, "assert(" "current->deopt_mark() == __null" ") failed"
, "Pending deopt!"); ::breakpoint(); } } while (0)
;
372 current->set_deopt_mark(dmark);
373
374 frame stub_frame = current->last_frame(); // Makes stack walkable as side effect
375 RegisterMap map(current, true);
376 RegisterMap dummy_map(current, false);
377 // Now get the deoptee with a valid map
378 frame deoptee = stub_frame.sender(&map);
379 // Set the deoptee nmethod
380 assert(current->deopt_compiled_method() == NULL, "Pending deopt!")do { if (!(current->deopt_compiled_method() == __null)) { (
*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/runtime/deoptimization.cpp"
, 380, "assert(" "current->deopt_compiled_method() == __null"
") failed", "Pending deopt!"); ::breakpoint(); } } while (0)
;
381 CompiledMethod* cm = deoptee.cb()->as_compiled_method_or_null();
382 current->set_deopt_compiled_method(cm);
383
384 if (VerifyStack) {
385 current->validate_frame_layout();
386 }
387
388 // Create a growable array of VFrames where each VFrame represents an inlined
389 // Java frame. This storage is allocated with the usual system arena.
390 assert(deoptee.is_compiled_frame(), "Wrong frame type")do { if (!(deoptee.is_compiled_frame())) { (*g_assert_poison)
= 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/runtime/deoptimization.cpp"
, 390, "assert(" "deoptee.is_compiled_frame()" ") failed", "Wrong frame type"
); ::breakpoint(); } } while (0)
;
391 GrowableArray<compiledVFrame*>* chunk = new GrowableArray<compiledVFrame*>(10);
392 vframe* vf = vframe::new_vframe(&deoptee, &map, current);
393 while (!vf->is_top()) {
394 assert(vf->is_compiled_frame(), "Wrong frame type")do { if (!(vf->is_compiled_frame())) { (*g_assert_poison) =
'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/runtime/deoptimization.cpp"
, 394, "assert(" "vf->is_compiled_frame()" ") failed", "Wrong frame type"
); ::breakpoint(); } } while (0)
;
395 chunk->push(compiledVFrame::cast(vf));
396 vf = vf->sender();
397 }
398 assert(vf->is_compiled_frame(), "Wrong frame type")do { if (!(vf->is_compiled_frame())) { (*g_assert_poison) =
'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/runtime/deoptimization.cpp"
, 398, "assert(" "vf->is_compiled_frame()" ") failed", "Wrong frame type"
); ::breakpoint(); } } while (0)
;
399 chunk->push(compiledVFrame::cast(vf));
400
401 bool realloc_failures = false;
402
403#if COMPILER2_OR_JVMCI1
404 bool const jvmci_enabled = JVMCI_ONLY(EnableJVMCI)EnableJVMCI NOT_JVMCI(false);
405
406 // Reallocate the non-escaping objects and restore their fields. Then
407 // relock objects if synchronization on them was eliminated.
408 if (jvmci_enabled COMPILER2_PRESENT( || (DoEscapeAnalysis && EliminateAllocations)|| (DoEscapeAnalysis && EliminateAllocations) || EliminateAutoBox
|| EnableVectorAggressiveReboxing
409 || EliminateAutoBox || EnableVectorAggressiveReboxing )|| (DoEscapeAnalysis && EliminateAllocations) || EliminateAutoBox
|| EnableVectorAggressiveReboxing
) {
410 bool unused;
411 realloc_failures = rematerialize_objects(current, exec_mode, cm, deoptee, map, chunk, unused);
412 }
413#endif // COMPILER2_OR_JVMCI
414
415 // Ensure that no safepoint is taken after pointers have been stored
416 // in fields of rematerialized objects. If a safepoint occurs from here on
417 // out the java state residing in the vframeArray will be missed.
418 // Locks may be rebaised in a safepoint.
419 NoSafepointVerifier no_safepoint;
420
421#if COMPILER2_OR_JVMCI1
422 if ((jvmci_enabled COMPILER2_PRESENT( || ((DoEscapeAnalysis || EliminateNestedLocks) && EliminateLocks) )|| ((DoEscapeAnalysis || EliminateNestedLocks) && EliminateLocks
)
)
423 && !EscapeBarrier::objs_are_deoptimized(current, deoptee.id())) {
424 bool unused;
425 restore_eliminated_locks(current, chunk, realloc_failures, deoptee, exec_mode, unused);
426 }
427#endif // COMPILER2_OR_JVMCI
428
429 ScopeDesc* trap_scope = chunk->at(0)->scope();
430 Handle exceptionObject;
431 if (trap_scope->rethrow_exception()) {
432 if (PrintDeoptimizationDetails) {
433 tty->print_cr("Exception to be rethrown in the interpreter for method %s::%s at bci %d", trap_scope->method()->method_holder()->name()->as_C_string(), trap_scope->method()->name()->as_C_string(), trap_scope->bci());
434 }
435 GrowableArray<ScopeValue*>* expressions = trap_scope->expressions();
436 guarantee(expressions != NULL && expressions->length() > 0, "must have exception to throw")do { if (!(expressions != __null && expressions->length
() > 0)) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/runtime/deoptimization.cpp"
, 436, "guarantee(" "expressions != NULL && expressions->length() > 0"
") failed", "must have exception to throw"); ::breakpoint();
} } while (0)
;
437 ScopeValue* topOfStack = expressions->top();
438 exceptionObject = StackValue::create_stack_value(&deoptee, &map, topOfStack)->get_obj();
439 guarantee(exceptionObject() != NULL, "exception oop can not be null")do { if (!(exceptionObject() != __null)) { (*g_assert_poison)
= 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/runtime/deoptimization.cpp"
, 439, "guarantee(" "exceptionObject() != NULL" ") failed", "exception oop can not be null"
); ::breakpoint(); } } while (0)
;
440 }
441
442 vframeArray* array = create_vframeArray(current, deoptee, &map, chunk, realloc_failures);
443#if COMPILER2_OR_JVMCI1
444 if (realloc_failures) {
445 pop_frames_failed_reallocs(current, array);
446 }
447#endif
448
449 assert(current->vframe_array_head() == NULL, "Pending deopt!")do { if (!(current->vframe_array_head() == __null)) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/runtime/deoptimization.cpp"
, 449, "assert(" "current->vframe_array_head() == __null" ") failed"
, "Pending deopt!"); ::breakpoint(); } } while (0)
;
450 current->set_vframe_array_head(array);
451
452 // Now that the vframeArray has been created if we have any deferred local writes
453 // added by jvmti then we can free up that structure as the data is now in the
454 // vframeArray
455
456 JvmtiDeferredUpdates::delete_updates_for_frame(current, array->original().id());
457
458 // Compute the caller frame based on the sender sp of stub_frame and stored frame sizes info.
459 CodeBlob* cb = stub_frame.cb();
460 // Verify we have the right vframeArray
461 assert(cb->frame_size() >= 0, "Unexpected frame size")do { if (!(cb->frame_size() >= 0)) { (*g_assert_poison)
= 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/runtime/deoptimization.cpp"
, 461, "assert(" "cb->frame_size() >= 0" ") failed", "Unexpected frame size"
); ::breakpoint(); } } while (0)
;
462 intptr_t* unpack_sp = stub_frame.sp() + cb->frame_size();
463
464 // If the deopt call site is a MethodHandle invoke call site we have
465 // to adjust the unpack_sp.
466 nmethod* deoptee_nm = deoptee.cb()->as_nmethod_or_null();
467 if (deoptee_nm != NULL__null && deoptee_nm->is_method_handle_return(deoptee.pc()))
468 unpack_sp = deoptee.unextended_sp();
469
470#ifdef ASSERT1
471 assert(cb->is_deoptimization_stub() ||do { if (!(cb->is_deoptimization_stub() || cb->is_uncommon_trap_stub
() || strcmp("Stub<DeoptimizationStub.deoptimizationHandler>"
, cb->name()) == 0 || strcmp("Stub<UncommonTrapStub.uncommonTrapHandler>"
, cb->name()) == 0)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/runtime/deoptimization.cpp"
, 475, "assert(" "cb->is_deoptimization_stub() || cb->is_uncommon_trap_stub() || strcmp(\"Stub<DeoptimizationStub.deoptimizationHandler>\", cb->name()) == 0 || strcmp(\"Stub<UncommonTrapStub.uncommonTrapHandler>\", cb->name()) == 0"
") failed", "unexpected code blob: %s", cb->name()); ::breakpoint
(); } } while (0)
472 cb->is_uncommon_trap_stub() ||do { if (!(cb->is_deoptimization_stub() || cb->is_uncommon_trap_stub
() || strcmp("Stub<DeoptimizationStub.deoptimizationHandler>"
, cb->name()) == 0 || strcmp("Stub<UncommonTrapStub.uncommonTrapHandler>"
, cb->name()) == 0)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/runtime/deoptimization.cpp"
, 475, "assert(" "cb->is_deoptimization_stub() || cb->is_uncommon_trap_stub() || strcmp(\"Stub<DeoptimizationStub.deoptimizationHandler>\", cb->name()) == 0 || strcmp(\"Stub<UncommonTrapStub.uncommonTrapHandler>\", cb->name()) == 0"
") failed", "unexpected code blob: %s", cb->name()); ::breakpoint
(); } } while (0)
473 strcmp("Stub<DeoptimizationStub.deoptimizationHandler>", cb->name()) == 0 ||do { if (!(cb->is_deoptimization_stub() || cb->is_uncommon_trap_stub
() || strcmp("Stub<DeoptimizationStub.deoptimizationHandler>"
, cb->name()) == 0 || strcmp("Stub<UncommonTrapStub.uncommonTrapHandler>"
, cb->name()) == 0)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/runtime/deoptimization.cpp"
, 475, "assert(" "cb->is_deoptimization_stub() || cb->is_uncommon_trap_stub() || strcmp(\"Stub<DeoptimizationStub.deoptimizationHandler>\", cb->name()) == 0 || strcmp(\"Stub<UncommonTrapStub.uncommonTrapHandler>\", cb->name()) == 0"
") failed", "unexpected code blob: %s", cb->name()); ::breakpoint
(); } } while (0)
474 strcmp("Stub<UncommonTrapStub.uncommonTrapHandler>", cb->name()) == 0,do { if (!(cb->is_deoptimization_stub() || cb->is_uncommon_trap_stub
() || strcmp("Stub<DeoptimizationStub.deoptimizationHandler>"
, cb->name()) == 0 || strcmp("Stub<UncommonTrapStub.uncommonTrapHandler>"
, cb->name()) == 0)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/runtime/deoptimization.cpp"
, 475, "assert(" "cb->is_deoptimization_stub() || cb->is_uncommon_trap_stub() || strcmp(\"Stub<DeoptimizationStub.deoptimizationHandler>\", cb->name()) == 0 || strcmp(\"Stub<UncommonTrapStub.uncommonTrapHandler>\", cb->name()) == 0"
") failed", "unexpected code blob: %s", cb->name()); ::breakpoint
(); } } while (0)
475 "unexpected code blob: %s", cb->name())do { if (!(cb->is_deoptimization_stub() || cb->is_uncommon_trap_stub
() || strcmp("Stub<DeoptimizationStub.deoptimizationHandler>"
, cb->name()) == 0 || strcmp("Stub<UncommonTrapStub.uncommonTrapHandler>"
, cb->name()) == 0)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/runtime/deoptimization.cpp"
, 475, "assert(" "cb->is_deoptimization_stub() || cb->is_uncommon_trap_stub() || strcmp(\"Stub<DeoptimizationStub.deoptimizationHandler>\", cb->name()) == 0 || strcmp(\"Stub<UncommonTrapStub.uncommonTrapHandler>\", cb->name()) == 0"
") failed", "unexpected code blob: %s", cb->name()); ::breakpoint
(); } } while (0)
;
476#endif
477
478 // This is a guarantee instead of an assert because if vframe doesn't match
479 // we will unpack the wrong deoptimized frame and wind up in strange places
480 // where it will be very difficult to figure out what went wrong. Better
481 // to die an early death here than some very obscure death later when the
482 // trail is cold.
483 // Note: on ia64 this guarantee can be fooled by frames with no memory stack
484 // in that it will fail to detect a problem when there is one. This needs
485 // more work in tiger timeframe.
486 guarantee(array->unextended_sp() == unpack_sp, "vframe_array_head must contain the vframeArray to unpack")do { if (!(array->unextended_sp() == unpack_sp)) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/runtime/deoptimization.cpp"
, 486, "guarantee(" "array->unextended_sp() == unpack_sp" ") failed"
, "vframe_array_head must contain the vframeArray to unpack")
; ::breakpoint(); } } while (0)
;
487
488 int number_of_frames = array->frames();
489
490 // Compute the vframes' sizes. Note that frame_sizes[] entries are ordered from outermost to innermost
491 // virtual activation, which is the reverse of the elements in the vframes array.
492 intptr_t* frame_sizes = NEW_C_HEAP_ARRAY(intptr_t, number_of_frames, mtCompiler)(intptr_t*) (AllocateHeap((number_of_frames) * sizeof(intptr_t
), mtCompiler))
;
493 // +1 because we always have an interpreter return address for the final slot.
494 address* frame_pcs = NEW_C_HEAP_ARRAY(address, number_of_frames + 1, mtCompiler)(address*) (AllocateHeap((number_of_frames + 1) * sizeof(address
), mtCompiler))
;
495 int popframe_extra_args = 0;
496 // Create an interpreter return address for the stub to use as its return
497 // address so the skeletal frames are perfectly walkable
498 frame_pcs[number_of_frames] = Interpreter::deopt_entry(vtos, 0);
499
500 // PopFrame requires that the preserved incoming arguments from the recently-popped topmost
501 // activation be put back on the expression stack of the caller for reexecution
502 if (JvmtiExport::can_pop_frame() && current->popframe_forcing_deopt_reexecution()) {
503 popframe_extra_args = in_words(current->popframe_preserved_args_size_in_words());
504 }
505
506 // Find the current pc for sender of the deoptee. Since the sender may have been deoptimized
507 // itself since the deoptee vframeArray was created we must get a fresh value of the pc rather
508 // than simply use array->sender.pc(). This requires us to walk the current set of frames
509 //
510 frame deopt_sender = stub_frame.sender(&dummy_map); // First is the deoptee frame
511 deopt_sender = deopt_sender.sender(&dummy_map); // Now deoptee caller
512
513 // It's possible that the number of parameters at the call site is
514 // different than number of arguments in the callee when method
515 // handles are used. If the caller is interpreted get the real
516 // value so that the proper amount of space can be added to it's
517 // frame.
518 bool caller_was_method_handle = false;
519 if (deopt_sender.is_interpreted_frame()) {
520 methodHandle method(current, deopt_sender.interpreter_frame_method());
521 Bytecode_invoke cur = Bytecode_invoke_check(method, deopt_sender.interpreter_frame_bci());
522 if (cur.is_invokedynamic() || cur.is_invokehandle()) {
523 // Method handle invokes may involve fairly arbitrary chains of
524 // calls so it's impossible to know how much actual space the
525 // caller has for locals.
526 caller_was_method_handle = true;
527 }
528 }
529
530 //
531 // frame_sizes/frame_pcs[0] oldest frame (int or c2i)
532 // frame_sizes/frame_pcs[1] next oldest frame (int)
533 // frame_sizes/frame_pcs[n] youngest frame (int)
534 //
535 // Now a pc in frame_pcs is actually the return address to the frame's caller (a frame
536 // owns the space for the return address to it's caller). Confusing ain't it.
537 //
538 // The vframe array can address vframes with indices running from
539 // 0.._frames-1. Index 0 is the youngest frame and _frame - 1 is the oldest (root) frame.
540 // When we create the skeletal frames we need the oldest frame to be in the zero slot
541 // in the frame_sizes/frame_pcs so the assembly code can do a trivial walk.
542 // so things look a little strange in this loop.
543 //
544 int callee_parameters = 0;
545 int callee_locals = 0;
546 for (int index = 0; index < array->frames(); index++ ) {
547 // frame[number_of_frames - 1 ] = on_stack_size(youngest)
548 // frame[number_of_frames - 2 ] = on_stack_size(sender(youngest))
549 // frame[number_of_frames - 3 ] = on_stack_size(sender(sender(youngest)))
550 frame_sizes[number_of_frames - 1 - index] = BytesPerWord * array->element(index)->on_stack_size(callee_parameters,
551 callee_locals,
552 index == 0,
553 popframe_extra_args);
554 // This pc doesn't have to be perfect just good enough to identify the frame
555 // as interpreted so the skeleton frame will be walkable
556 // The correct pc will be set when the skeleton frame is completely filled out
557 // The final pc we store in the loop is wrong and will be overwritten below
558 frame_pcs[number_of_frames - 1 - index ] = Interpreter::deopt_entry(vtos, 0) - frame::pc_return_offset;
559
560 callee_parameters = array->element(index)->method()->size_of_parameters();
561 callee_locals = array->element(index)->method()->max_locals();
562 popframe_extra_args = 0;
563 }
564
565 // Compute whether the root vframe returns a float or double value.
566 BasicType return_type;
567 {
568 methodHandle method(current, array->element(0)->method());
569 Bytecode_invoke invoke = Bytecode_invoke_check(method, array->element(0)->bci());
570 return_type = invoke.is_valid() ? invoke.result_type() : T_ILLEGAL;
571 }
572
573 // Compute information for handling adapters and adjusting the frame size of the caller.
574 int caller_adjustment = 0;
575
576 // Compute the amount the oldest interpreter frame will have to adjust
577 // its caller's stack by. If the caller is a compiled frame then
578 // we pretend that the callee has no parameters so that the
579 // extension counts for the full amount of locals and not just
580 // locals-parms. This is because without a c2i adapter the parm
581 // area as created by the compiled frame will not be usable by
582 // the interpreter. (Depending on the calling convention there
583 // may not even be enough space).
584
585 // QQQ I'd rather see this pushed down into last_frame_adjust
586 // and have it take the sender (aka caller).
587
588 if (deopt_sender.is_compiled_caller() || caller_was_method_handle) {
589 caller_adjustment = last_frame_adjust(0, callee_locals);
590 } else if (callee_locals > callee_parameters) {
591 // The caller frame may need extending to accommodate
592 // non-parameter locals of the first unpacked interpreted frame.
593 // Compute that adjustment.
594 caller_adjustment = last_frame_adjust(callee_parameters, callee_locals);
595 }
596
597 // If the sender is deoptimized the we must retrieve the address of the handler
598 // since the frame will "magically" show the original pc before the deopt
599 // and we'd undo the deopt.
600
601 frame_pcs[0] = deopt_sender.raw_pc();
602
603 assert(CodeCache::find_blob_unsafe(frame_pcs[0]) != NULL, "bad pc")do { if (!(CodeCache::find_blob_unsafe(frame_pcs[0]) != __null
)) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/runtime/deoptimization.cpp"
, 603, "assert(" "CodeCache::find_blob_unsafe(frame_pcs[0]) != __null"
") failed", "bad pc"); ::breakpoint(); } } while (0)
;
604
605#if INCLUDE_JVMCI1
606 if (exceptionObject() != NULL__null) {
607 current->set_exception_oop(exceptionObject());
608 exec_mode = Unpack_exception;
609 }
610#endif
611
612 if (current->frames_to_pop_failed_realloc() > 0 && exec_mode != Unpack_uncommon_trap) {
613 assert(current->has_pending_exception(), "should have thrown OOME")do { if (!(current->has_pending_exception())) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/runtime/deoptimization.cpp"
, 613, "assert(" "current->has_pending_exception()" ") failed"
, "should have thrown OOME"); ::breakpoint(); } } while (0)
;
614 current->set_exception_oop(current->pending_exception());
615 current->clear_pending_exception();
616 exec_mode = Unpack_exception;
617 }
618
619#if INCLUDE_JVMCI1
620 if (current->frames_to_pop_failed_realloc() > 0) {
621 current->set_pending_monitorenter(false);
622 }
623#endif
624
625 UnrollBlock* info = new UnrollBlock(array->frame_size() * BytesPerWord,
626 caller_adjustment * BytesPerWord,
627 caller_was_method_handle ? 0 : callee_parameters,
628 number_of_frames,
629 frame_sizes,
630 frame_pcs,
631 return_type,
632 exec_mode);
633 // On some platforms, we need a way to pass some platform dependent
634 // information to the unpacking code so the skeletal frames come out
635 // correct (initial fp value, unextended sp, ...)
636 info->set_initial_info((intptr_t) array->sender().initial_deoptimization_info());
637
638 if (array->frames() > 1) {
639 if (VerifyStack && TraceDeoptimization) {
640 tty->print_cr("Deoptimizing method containing inlining");
641 }
642 }
643
644 array->set_unroll_block(info);
645 return info;
646}
647
648// Called to cleanup deoptimization data structures in normal case
649// after unpacking to stack and when stack overflow error occurs
650void Deoptimization::cleanup_deopt_info(JavaThread *thread,
651 vframeArray *array) {
652
653 // Get array if coming from exception
654 if (array == NULL__null) {
655 array = thread->vframe_array_head();
656 }
657 thread->set_vframe_array_head(NULL__null);
658
659 // Free the previous UnrollBlock
660 vframeArray* old_array = thread->vframe_array_last();
661 thread->set_vframe_array_last(array);
662
663 if (old_array != NULL__null) {
664 UnrollBlock* old_info = old_array->unroll_block();
665 old_array->set_unroll_block(NULL__null);
666 delete old_info;
667 delete old_array;
668 }
669
670 // Deallocate any resource creating in this routine and any ResourceObjs allocated
671 // inside the vframeArray (StackValueCollections)
672
673 delete thread->deopt_mark();
674 thread->set_deopt_mark(NULL__null);
675 thread->set_deopt_compiled_method(NULL__null);
676
677
678 if (JvmtiExport::can_pop_frame()) {
679 // Regardless of whether we entered this routine with the pending
680 // popframe condition bit set, we should always clear it now
681 thread->clear_popframe_condition();
682 }
683
684 // unpack_frames() is called at the end of the deoptimization handler
685 // and (in C2) at the end of the uncommon trap handler. Note this fact
686 // so that an asynchronous stack walker can work again. This counter is
687 // incremented at the beginning of fetch_unroll_info() and (in C2) at
688 // the beginning of uncommon_trap().
689 thread->dec_in_deopt_handler();
690}
691
692// Moved from cpu directories because none of the cpus has callee save values.
693// If a cpu implements callee save values, move this to deoptimization_<cpu>.cpp.
694void Deoptimization::unwind_callee_save_values(frame* f, vframeArray* vframe_array) {
695
696 // This code is sort of the equivalent of C2IAdapter::setup_stack_frame back in
697 // the days we had adapter frames. When we deoptimize a situation where a
698 // compiled caller calls a compiled caller will have registers it expects
699 // to survive the call to the callee. If we deoptimize the callee the only
700 // way we can restore these registers is to have the oldest interpreter
701 // frame that we create restore these values. That is what this routine
702 // will accomplish.
703
704 // At the moment we have modified c2 to not have any callee save registers
705 // so this problem does not exist and this routine is just a place holder.
706
707 assert(f->is_interpreted_frame(), "must be interpreted")do { if (!(f->is_interpreted_frame())) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/runtime/deoptimization.cpp"
, 707, "assert(" "f->is_interpreted_frame()" ") failed", "must be interpreted"
); ::breakpoint(); } } while (0)
;
708}
709
710// Return BasicType of value being returned
711JRT_LEAF(BasicType, Deoptimization::unpack_frames(JavaThread* thread, int exec_mode))BasicType Deoptimization::unpack_frames(JavaThread* thread, int
exec_mode) { NoHandleMark __hm; ; os::verify_stack_alignment
(); NoSafepointVerifier __nsv;
712
713 // We are already active in the special DeoptResourceMark any ResourceObj's we
714 // allocate will be freed at the end of the routine.
715
716 // JRT_LEAF methods don't normally allocate handles and there is a
717 // NoHandleMark to enforce that. It is actually safe to use Handles
718 // in a JRT_LEAF method, and sometimes desirable, but to do so we
719 // must use ResetNoHandleMark to bypass the NoHandleMark, and
720 // then use a HandleMark to ensure any Handles we do create are
721 // cleaned up in this scope.
722 ResetNoHandleMark rnhm;
723 HandleMark hm(thread);
724
725 frame stub_frame = thread->last_frame();
726
727 // Since the frame to unpack is the top frame of this thread, the vframe_array_head
728 // must point to the vframeArray for the unpack frame.
729 vframeArray* array = thread->vframe_array_head();
730
731#ifndef PRODUCT
732 if (TraceDeoptimization) {
733 tty->print_cr("DEOPT UNPACKING thread " INTPTR_FORMAT"0x%016" "l" "x" " vframeArray " INTPTR_FORMAT"0x%016" "l" "x" " mode %d",
734 p2i(thread), p2i(array), exec_mode);
735 }
736#endif
737 Events::log_deopt_message(thread, "DEOPT UNPACKING pc=" INTPTR_FORMAT"0x%016" "l" "x" " sp=" INTPTR_FORMAT"0x%016" "l" "x" " mode %d",
738 p2i(stub_frame.pc()), p2i(stub_frame.sp()), exec_mode);
739
740 UnrollBlock* info = array->unroll_block();
741
742 // We set the last_Java frame. But the stack isn't really parsable here. So we
743 // clear it to make sure JFR understands not to try and walk stacks from events
744 // in here.
745 intptr_t* sp = thread->frame_anchor()->last_Java_sp();
746 thread->frame_anchor()->set_last_Java_sp(NULL__null);
747
748 // Unpack the interpreter frames and any adapter frame (c2 only) we might create.
749 array->unpack_to_stack(stub_frame, exec_mode, info->caller_actual_parameters());
750
751 thread->frame_anchor()->set_last_Java_sp(sp);
752
753 BasicType bt = info->return_type();
754
755 // If we have an exception pending, claim that the return type is an oop
756 // so the deopt_blob does not overwrite the exception_oop.
757
758 if (exec_mode == Unpack_exception)
759 bt = T_OBJECT;
760
761 // Cleanup thread deopt data
762 cleanup_deopt_info(thread, array);
763
764#ifndef PRODUCT
765 if (VerifyStack) {
766 ResourceMark res_mark;
767 // Clear pending exception to not break verification code (restored afterwards)
768 PreserveExceptionMark pm(thread);
769
770 thread->validate_frame_layout();
771
772 // Verify that the just-unpacked frames match the interpreter's
773 // notions of expression stack and locals
774 vframeArray* cur_array = thread->vframe_array_last();
775 RegisterMap rm(thread, false);
776 rm.set_include_argument_oops(false);
777 bool is_top_frame = true;
778 int callee_size_of_parameters = 0;
779 int callee_max_locals = 0;
780 for (int i = 0; i < cur_array->frames(); i++) {
781 vframeArrayElement* el = cur_array->element(i);
782 frame* iframe = el->iframe();
783 guarantee(iframe->is_interpreted_frame(), "Wrong frame type")do { if (!(iframe->is_interpreted_frame())) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/runtime/deoptimization.cpp"
, 783, "guarantee(" "iframe->is_interpreted_frame()" ") failed"
, "Wrong frame type"); ::breakpoint(); } } while (0)
;
784
785 // Get the oop map for this bci
786 InterpreterOopMap mask;
787 int cur_invoke_parameter_size = 0;
788 bool try_next_mask = false;
789 int next_mask_expression_stack_size = -1;
790 int top_frame_expression_stack_adjustment = 0;
791 methodHandle mh(thread, iframe->interpreter_frame_method());
792 OopMapCache::compute_one_oop_map(mh, iframe->interpreter_frame_bci(), &mask);
793 BytecodeStream str(mh, iframe->interpreter_frame_bci());
794 int max_bci = mh->code_size();
795 // Get to the next bytecode if possible
796 assert(str.bci() < max_bci, "bci in interpreter frame out of bounds")do { if (!(str.bci() < max_bci)) { (*g_assert_poison) = 'X'
;; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/runtime/deoptimization.cpp"
, 796, "assert(" "str.bci() < max_bci" ") failed", "bci in interpreter frame out of bounds"
); ::breakpoint(); } } while (0)
;
797 // Check to see if we can grab the number of outgoing arguments
798 // at an uncommon trap for an invoke (where the compiler
799 // generates debug info before the invoke has executed)
800 Bytecodes::Code cur_code = str.next();
801 Bytecodes::Code next_code = Bytecodes::_shouldnotreachhere;
802 if (Bytecodes::is_invoke(cur_code)) {
803 Bytecode_invoke invoke(mh, iframe->interpreter_frame_bci());
804 cur_invoke_parameter_size = invoke.size_of_parameters();
805 if (i != 0 && !invoke.is_invokedynamic() && MethodHandles::has_member_arg(invoke.klass(), invoke.name())) {
806 callee_size_of_parameters++;
807 }
808 }
809 if (str.bci() < max_bci) {
810 next_code = str.next();
811 if (next_code >= 0) {
812 // The interpreter oop map generator reports results before
813 // the current bytecode has executed except in the case of
814 // calls. It seems to be hard to tell whether the compiler
815 // has emitted debug information matching the "state before"
816 // a given bytecode or the state after, so we try both
817 if (!Bytecodes::is_invoke(cur_code) && cur_code != Bytecodes::_athrow) {
818 // Get expression stack size for the next bytecode
819 InterpreterOopMap next_mask;
820 OopMapCache::compute_one_oop_map(mh, str.bci(), &next_mask);
821 next_mask_expression_stack_size = next_mask.expression_stack_size();
822 if (Bytecodes::is_invoke(next_code)) {
823 Bytecode_invoke invoke(mh, str.bci());
824 next_mask_expression_stack_size += invoke.size_of_parameters();
825 }
826 // Need to subtract off the size of the result type of
827 // the bytecode because this is not described in the
828 // debug info but returned to the interpreter in the TOS
829 // caching register
830 BasicType bytecode_result_type = Bytecodes::result_type(cur_code);
831 if (bytecode_result_type != T_ILLEGAL) {
832 top_frame_expression_stack_adjustment = type2size[bytecode_result_type];
833 }
834 assert(top_frame_expression_stack_adjustment >= 0, "stack adjustment must be positive")do { if (!(top_frame_expression_stack_adjustment >= 0)) { (
*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/runtime/deoptimization.cpp"
, 834, "assert(" "top_frame_expression_stack_adjustment >= 0"
") failed", "stack adjustment must be positive"); ::breakpoint
(); } } while (0)
;
835 try_next_mask = true;
836 }
837 }
838 }
839
840 // Verify stack depth and oops in frame
841 // This assertion may be dependent on the platform we're running on and may need modification (tested on x86 and sparc)
842 if (!(
843 /* SPARC */
844 (iframe->interpreter_frame_expression_stack_size() == mask.expression_stack_size() + callee_size_of_parameters) ||
845 /* x86 */
846 (iframe->interpreter_frame_expression_stack_size() == mask.expression_stack_size() + callee_max_locals) ||
847 (try_next_mask &&
848 (iframe->interpreter_frame_expression_stack_size() == (next_mask_expression_stack_size -
849 top_frame_expression_stack_adjustment))) ||
850 (is_top_frame && (exec_mode == Unpack_exception) && iframe->interpreter_frame_expression_stack_size() == 0) ||
851 (is_top_frame && (exec_mode == Unpack_uncommon_trap || exec_mode == Unpack_reexecute || el->should_reexecute()) &&
852 (iframe->interpreter_frame_expression_stack_size() == mask.expression_stack_size() + cur_invoke_parameter_size))
853 )) {
854 {
855 // Print out some information that will help us debug the problem
856 tty->print_cr("Wrong number of expression stack elements during deoptimization");
857 tty->print_cr(" Error occurred while verifying frame %d (0..%d, 0 is topmost)", i, cur_array->frames() - 1);
858 tty->print_cr(" Current code %s", Bytecodes::name(cur_code));
859 if (try_next_mask) {
860 tty->print_cr(" Next code %s", Bytecodes::name(next_code));
861 }
862 tty->print_cr(" Fabricated interpreter frame had %d expression stack elements",
863 iframe->interpreter_frame_expression_stack_size());
864 tty->print_cr(" Interpreter oop map had %d expression stack elements", mask.expression_stack_size());
865 tty->print_cr(" try_next_mask = %d", try_next_mask);
866 tty->print_cr(" next_mask_expression_stack_size = %d", next_mask_expression_stack_size);
867 tty->print_cr(" callee_size_of_parameters = %d", callee_size_of_parameters);
868 tty->print_cr(" callee_max_locals = %d", callee_max_locals);
869 tty->print_cr(" top_frame_expression_stack_adjustment = %d", top_frame_expression_stack_adjustment);
870 tty->print_cr(" exec_mode = %d", exec_mode);
871 tty->print_cr(" cur_invoke_parameter_size = %d", cur_invoke_parameter_size);
872 tty->print_cr(" Thread = " INTPTR_FORMAT"0x%016" "l" "x" ", thread ID = %d", p2i(thread), thread->osthread()->thread_id());
873 tty->print_cr(" Interpreted frames:");
874 for (int k = 0; k < cur_array->frames(); k++) {
875 vframeArrayElement* el = cur_array->element(k);
876 tty->print_cr(" %s (bci %d)", el->method()->name_and_sig_as_C_string(), el->bci());
877 }
878 cur_array->print_on_2(tty);
879 }
880 guarantee(false, "wrong number of expression stack elements during deopt")do { if (!(false)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/runtime/deoptimization.cpp"
, 880, "guarantee(" "false" ") failed", "wrong number of expression stack elements during deopt"
); ::breakpoint(); } } while (0)
;
881 }
882 VerifyOopClosure verify;
883 iframe->oops_interpreted_do(&verify, &rm, false);
884 callee_size_of_parameters = mh->size_of_parameters();
885 callee_max_locals = mh->max_locals();
886 is_top_frame = false;
887 }
888 }
889#endif /* !PRODUCT */
890
891 return bt;
892JRT_END}
893
894class DeoptimizeMarkedClosure : public HandshakeClosure {
895 public:
896 DeoptimizeMarkedClosure() : HandshakeClosure("Deoptimize") {}
897 void do_thread(Thread* thread) {
898 JavaThread* jt = JavaThread::cast(thread);
899 jt->deoptimize_marked_methods();
900 }
901};
902
903void Deoptimization::deoptimize_all_marked(nmethod* nmethod_only) {
904 ResourceMark rm;
905 DeoptimizationMarker dm;
906
907 // Make the dependent methods not entrant
908 if (nmethod_only != NULL__null) {
909 nmethod_only->mark_for_deoptimization();
910 nmethod_only->make_not_entrant();
911 } else {
912 MutexLocker mu(SafepointSynchronize::is_at_safepoint() ? NULL__null : CodeCache_lock, Mutex::_no_safepoint_check_flag);
913 CodeCache::make_marked_nmethods_not_entrant();
914 }
915
916 DeoptimizeMarkedClosure deopt;
917 if (SafepointSynchronize::is_at_safepoint()) {
918 Threads::java_threads_do(&deopt);
919 } else {
920 Handshake::execute(&deopt);
921 }
922}
923
924Deoptimization::DeoptAction Deoptimization::_unloaded_action
925 = Deoptimization::Action_reinterpret;
926
927#if COMPILER2_OR_JVMCI1
928template<typename CacheType>
929class BoxCacheBase : public CHeapObj<mtCompiler> {
930protected:
931 static InstanceKlass* find_cache_klass(Symbol* klass_name) {
932 ResourceMark rm;
933 char* klass_name_str = klass_name->as_C_string();
934 InstanceKlass* ik = SystemDictionary::find_instance_klass(klass_name, Handle(), Handle());
935 guarantee(ik != NULL, "%s must be loaded", klass_name_str)do { if (!(ik != __null)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/runtime/deoptimization.cpp"
, 935, "guarantee(" "ik != NULL" ") failed", "%s must be loaded"
, klass_name_str); ::breakpoint(); } } while (0)
;
936 guarantee(ik->is_initialized(), "%s must be initialized", klass_name_str)do { if (!(ik->is_initialized())) { (*g_assert_poison) = 'X'
;; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/runtime/deoptimization.cpp"
, 936, "guarantee(" "ik->is_initialized()" ") failed", "%s must be initialized"
, klass_name_str); ::breakpoint(); } } while (0)
;
937 CacheType::compute_offsets(ik);
938 return ik;
939 }
940};
941
942template<typename PrimitiveType, typename CacheType, typename BoxType> class BoxCache : public BoxCacheBase<CacheType> {
943 PrimitiveType _low;
944 PrimitiveType _high;
945 jobject _cache;
946protected:
947 static BoxCache<PrimitiveType, CacheType, BoxType> *_singleton;
948 BoxCache(Thread* thread) {
949 InstanceKlass* ik = BoxCacheBase<CacheType>::find_cache_klass(CacheType::symbol());
950 objArrayOop cache = CacheType::cache(ik);
951 assert(cache->length() > 0, "Empty cache")do { if (!(cache->length() > 0)) { (*g_assert_poison) =
'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/runtime/deoptimization.cpp"
, 951, "assert(" "cache->length() > 0" ") failed", "Empty cache"
); ::breakpoint(); } } while (0)
;
952 _low = BoxType::value(cache->obj_at(0));
953 _high = _low + cache->length() - 1;
954 _cache = JNIHandles::make_global(Handle(thread, cache));
955 }
956 ~BoxCache() {
957 JNIHandles::destroy_global(_cache);
958 }
959public:
960 static BoxCache<PrimitiveType, CacheType, BoxType>* singleton(Thread* thread) {
961 if (_singleton == NULL__null) {
962 BoxCache<PrimitiveType, CacheType, BoxType>* s = new BoxCache<PrimitiveType, CacheType, BoxType>(thread);
963 if (!Atomic::replace_if_null(&_singleton, s)) {
964 delete s;
965 }
966 }
967 return _singleton;
968 }
969 oop lookup(PrimitiveType value) {
970 if (_low <= value && value <= _high) {
971 int offset = value - _low;
972 return objArrayOop(JNIHandles::resolve_non_null(_cache))->obj_at(offset);
973 }
974 return NULL__null;
975 }
976 oop lookup_raw(intptr_t raw_value) {
977 // Have to cast to avoid little/big-endian problems.
978 if (sizeof(PrimitiveType) > sizeof(jint)) {
979 jlong value = (jlong)raw_value;
980 return lookup(value);
981 }
982 PrimitiveType value = (PrimitiveType)*((jint*)&raw_value);
983 return lookup(value);
984 }
985};
986
987typedef BoxCache<jint, java_lang_Integer_IntegerCache, java_lang_Integer> IntegerBoxCache;
988typedef BoxCache<jlong, java_lang_Long_LongCache, java_lang_Long> LongBoxCache;
989typedef BoxCache<jchar, java_lang_Character_CharacterCache, java_lang_Character> CharacterBoxCache;
990typedef BoxCache<jshort, java_lang_Short_ShortCache, java_lang_Short> ShortBoxCache;
991typedef BoxCache<jbyte, java_lang_Byte_ByteCache, java_lang_Byte> ByteBoxCache;
992
993template<> BoxCache<jint, java_lang_Integer_IntegerCache, java_lang_Integer>* BoxCache<jint, java_lang_Integer_IntegerCache, java_lang_Integer>::_singleton = NULL__null;
994template<> BoxCache<jlong, java_lang_Long_LongCache, java_lang_Long>* BoxCache<jlong, java_lang_Long_LongCache, java_lang_Long>::_singleton = NULL__null;
995template<> BoxCache<jchar, java_lang_Character_CharacterCache, java_lang_Character>* BoxCache<jchar, java_lang_Character_CharacterCache, java_lang_Character>::_singleton = NULL__null;
996template<> BoxCache<jshort, java_lang_Short_ShortCache, java_lang_Short>* BoxCache<jshort, java_lang_Short_ShortCache, java_lang_Short>::_singleton = NULL__null;
997template<> BoxCache<jbyte, java_lang_Byte_ByteCache, java_lang_Byte>* BoxCache<jbyte, java_lang_Byte_ByteCache, java_lang_Byte>::_singleton = NULL__null;
998
999class BooleanBoxCache : public BoxCacheBase<java_lang_Boolean> {
1000 jobject _true_cache;
1001 jobject _false_cache;
1002protected:
1003 static BooleanBoxCache *_singleton;
1004 BooleanBoxCache(Thread *thread) {
1005 InstanceKlass* ik = find_cache_klass(java_lang_Boolean::symbol());
1006 _true_cache = JNIHandles::make_global(Handle(thread, java_lang_Boolean::get_TRUE(ik)));
1007 _false_cache = JNIHandles::make_global(Handle(thread, java_lang_Boolean::get_FALSE(ik)));
1008 }
1009 ~BooleanBoxCache() {
1010 JNIHandles::destroy_global(_true_cache);
1011 JNIHandles::destroy_global(_false_cache);
1012 }
1013public:
1014 static BooleanBoxCache* singleton(Thread* thread) {
1015 if (_singleton == NULL__null) {
1016 BooleanBoxCache* s = new BooleanBoxCache(thread);
1017 if (!Atomic::replace_if_null(&_singleton, s)) {
1018 delete s;
1019 }
1020 }
1021 return _singleton;
1022 }
1023 oop lookup_raw(intptr_t raw_value) {
1024 // Have to cast to avoid little/big-endian problems.
1025 jboolean value = (jboolean)*((jint*)&raw_value);
1026 return lookup(value);
1027 }
1028 oop lookup(jboolean value) {
1029 if (value != 0) {
1030 return JNIHandles::resolve_non_null(_true_cache);
1031 }
1032 return JNIHandles::resolve_non_null(_false_cache);
1033 }
1034};
1035
1036BooleanBoxCache* BooleanBoxCache::_singleton = NULL__null;
1037
1038oop Deoptimization::get_cached_box(AutoBoxObjectValue* bv, frame* fr, RegisterMap* reg_map, TRAPSJavaThread* __the_thread__) {
1039 Klass* k = java_lang_Class::as_Klass(bv->klass()->as_ConstantOopReadValue()->value()());
1040 BasicType box_type = vmClasses::box_klass_type(k);
1041 if (box_type != T_OBJECT) {
1042 StackValue* value = StackValue::create_stack_value(fr, reg_map, bv->field_at(box_type == T_LONG ? 1 : 0));
1043 switch(box_type) {
1044 case T_INT: return IntegerBoxCache::singleton(THREAD__the_thread__)->lookup_raw(value->get_int());
1045 case T_CHAR: return CharacterBoxCache::singleton(THREAD__the_thread__)->lookup_raw(value->get_int());
1046 case T_SHORT: return ShortBoxCache::singleton(THREAD__the_thread__)->lookup_raw(value->get_int());
1047 case T_BYTE: return ByteBoxCache::singleton(THREAD__the_thread__)->lookup_raw(value->get_int());
1048 case T_BOOLEAN: return BooleanBoxCache::singleton(THREAD__the_thread__)->lookup_raw(value->get_int());
1049 case T_LONG: return LongBoxCache::singleton(THREAD__the_thread__)->lookup_raw(value->get_int());
1050 default:;
1051 }
1052 }
1053 return NULL__null;
1054}
1055
1056bool Deoptimization::realloc_objects(JavaThread* thread, frame* fr, RegisterMap* reg_map, GrowableArray<ScopeValue*>* objects, TRAPSJavaThread* __the_thread__) {
1057 Handle pending_exception(THREAD__the_thread__, thread->pending_exception());
1058 const char* exception_file = thread->exception_file();
1059 int exception_line = thread->exception_line();
1060 thread->clear_pending_exception();
1061
1062 bool failures = false;
1063
1064 for (int i = 0; i < objects->length(); i++) {
1065 assert(objects->at(i)->is_object(), "invalid debug information")do { if (!(objects->at(i)->is_object())) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/runtime/deoptimization.cpp"
, 1065, "assert(" "objects->at(i)->is_object()" ") failed"
, "invalid debug information"); ::breakpoint(); } } while (0)
;
1066 ObjectValue* sv = (ObjectValue*) objects->at(i);
1067
1068 Klass* k = java_lang_Class::as_Klass(sv->klass()->as_ConstantOopReadValue()->value()());
1069 oop obj = NULL__null;
1070
1071 if (k->is_instance_klass()) {
1072 if (sv->is_auto_box()) {
1073 AutoBoxObjectValue* abv = (AutoBoxObjectValue*) sv;
1074 obj = get_cached_box(abv, fr, reg_map, THREAD__the_thread__);
1075 if (obj != NULL__null) {
1076 // Set the flag to indicate the box came from a cache, so that we can skip the field reassignment for it.
1077 abv->set_cached(true);
1078 }
1079 }
1080
1081 InstanceKlass* ik = InstanceKlass::cast(k);
1082 if (obj == NULL__null) {
1083#ifdef COMPILER21
1084 if (EnableVectorSupport && VectorSupport::is_vector(ik)) {
1085 obj = VectorSupport::allocate_vector(ik, fr, reg_map, sv, THREAD__the_thread__);
1086 } else {
1087 obj = ik->allocate_instance(THREAD__the_thread__);
1088 }
1089#else
1090 obj = ik->allocate_instance(THREAD__the_thread__);
1091#endif // COMPILER2
1092 }
1093 } else if (k->is_typeArray_klass()) {
1094 TypeArrayKlass* ak = TypeArrayKlass::cast(k);
1095 assert(sv->field_size() % type2size[ak->element_type()] == 0, "non-integral array length")do { if (!(sv->field_size() % type2size[ak->element_type
()] == 0)) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/runtime/deoptimization.cpp"
, 1095, "assert(" "sv->field_size() % type2size[ak->element_type()] == 0"
") failed", "non-integral array length"); ::breakpoint(); } }
while (0)
;
1096 int len = sv->field_size() / type2size[ak->element_type()];
1097 obj = ak->allocate(len, THREAD__the_thread__);
1098 } else if (k->is_objArray_klass()) {
1099 ObjArrayKlass* ak = ObjArrayKlass::cast(k);
1100 obj = ak->allocate(sv->field_size(), THREAD__the_thread__);
1101 }
1102
1103 if (obj == NULL__null) {
1104 failures = true;
1105 }
1106
1107 assert(sv->value().is_null(), "redundant reallocation")do { if (!(sv->value().is_null())) { (*g_assert_poison) = 'X'
;; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/runtime/deoptimization.cpp"
, 1107, "assert(" "sv->value().is_null()" ") failed", "redundant reallocation"
); ::breakpoint(); } } while (0)
;
1108 assert(obj != NULL || HAS_PENDING_EXCEPTION, "allocation should succeed or we should get an exception")do { if (!(obj != __null || (((ThreadShadow*)__the_thread__)->
has_pending_exception()))) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/runtime/deoptimization.cpp"
, 1108, "assert(" "obj != __null || (((ThreadShadow*)__the_thread__)->has_pending_exception())"
") failed", "allocation should succeed or we should get an exception"
); ::breakpoint(); } } while (0)
;
1109 CLEAR_PENDING_EXCEPTION(((ThreadShadow*)__the_thread__)->clear_pending_exception(
))
;
1110 sv->set_value(obj);
1111 }
1112
1113 if (failures) {
1114 THROW_OOP_(Universe::out_of_memory_error_realloc_objects(), failures){ Exceptions::_throw_oop(__the_thread__, "/home/daniel/Projects/java/jdk/src/hotspot/share/runtime/deoptimization.cpp"
, 1114, Universe::out_of_memory_error_realloc_objects()); return
failures; }
;
1115 } else if (pending_exception.not_null()) {
1116 thread->set_pending_exception(pending_exception(), exception_file, exception_line);
1117 }
1118
1119 return failures;
1120}
1121
1122#if INCLUDE_JVMCI1
1123/**
1124 * For primitive types whose kind gets "erased" at runtime (shorts become stack ints),
1125 * we need to somehow be able to recover the actual kind to be able to write the correct
1126 * amount of bytes.
1127 * For that purpose, this method assumes that, for an entry spanning n bytes at index i,
1128 * the entries at index n + 1 to n + i are 'markers'.
1129 * For example, if we were writing a short at index 4 of a byte array of size 8, the
1130 * expected form of the array would be:
1131 *
1132 * {b0, b1, b2, b3, INT, marker, b6, b7}
1133 *
1134 * Thus, in order to get back the size of the entry, we simply need to count the number
1135 * of marked entries
1136 *
1137 * @param virtualArray the virtualized byte array
1138 * @param i index of the virtual entry we are recovering
1139 * @return The number of bytes the entry spans
1140 */
1141static int count_number_of_bytes_for_entry(ObjectValue *virtualArray, int i) {
1142 int index = i;
1143 while (++index < virtualArray->field_size() &&
1144 virtualArray->field_at(index)->is_marker()) {}
1145 return index - i;
1146}
1147
1148/**
1149 * If there was a guarantee for byte array to always start aligned to a long, we could
1150 * do a simple check on the parity of the index. Unfortunately, that is not always the
1151 * case. Thus, we check alignment of the actual address we are writing to.
1152 * In the unlikely case index 0 is 5-aligned for example, it would then be possible to
1153 * write a long to index 3.
1154 */
1155static jbyte* check_alignment_get_addr(typeArrayOop obj, int index, int expected_alignment) {
1156 jbyte* res = obj->byte_at_addr(index);
1157 assert((((intptr_t) res) % expected_alignment) == 0, "Non-aligned write")do { if (!((((intptr_t) res) % expected_alignment) == 0)) { (
*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/runtime/deoptimization.cpp"
, 1157, "assert(" "(((intptr_t) res) % expected_alignment) == 0"
") failed", "Non-aligned write"); ::breakpoint(); } } while (
0)
;
1158 return res;
1159}
1160
1161static void byte_array_put(typeArrayOop obj, intptr_t val, int index, int byte_count) {
1162 switch (byte_count) {
1163 case 1:
1164 obj->byte_at_put(index, (jbyte) *((jint *) &val));
1165 break;
1166 case 2:
1167 *((jshort *) check_alignment_get_addr(obj, index, 2)) = (jshort) *((jint *) &val);
1168 break;
1169 case 4:
1170 *((jint *) check_alignment_get_addr(obj, index, 4)) = (jint) *((jint *) &val);
1171 break;
1172 case 8:
1173 *((jlong *) check_alignment_get_addr(obj, index, 8)) = (jlong) *((jlong *) &val);
1174 break;
1175 default:
1176 ShouldNotReachHere()do { (*g_assert_poison) = 'X';; report_should_not_reach_here(
"/home/daniel/Projects/java/jdk/src/hotspot/share/runtime/deoptimization.cpp"
, 1176); ::breakpoint(); } while (0)
;
1177 }
1178}
1179#endif // INCLUDE_JVMCI
1180
1181
1182// restore elements of an eliminated type array
1183void Deoptimization::reassign_type_array_elements(frame* fr, RegisterMap* reg_map, ObjectValue* sv, typeArrayOop obj, BasicType type) {
1184 int index = 0;
1185 intptr_t val;
1186
1187 for (int i = 0; i < sv->field_size(); i++) {
1188 StackValue* value = StackValue::create_stack_value(fr, reg_map, sv->field_at(i));
1189 switch(type) {
1190 case T_LONG: case T_DOUBLE: {
1191 assert(value->type() == T_INT, "Agreement.")do { if (!(value->type() == T_INT)) { (*g_assert_poison) =
'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/runtime/deoptimization.cpp"
, 1191, "assert(" "value->type() == T_INT" ") failed", "Agreement."
); ::breakpoint(); } } while (0)
;
1192 StackValue* low =
1193 StackValue::create_stack_value(fr, reg_map, sv->field_at(++i));
1194#ifdef _LP641
1195 jlong res = (jlong)low->get_int();
1196#else
1197 jlong res = jlong_from((jint)value->get_int(), (jint)low->get_int());
1198#endif
1199 obj->long_at_put(index, res);
1200 break;
1201 }
1202
1203 // Have to cast to INT (32 bits) pointer to avoid little/big-endian problem.
1204 case T_INT: case T_FLOAT: { // 4 bytes.
1205 assert(value->type() == T_INT, "Agreement.")do { if (!(value->type() == T_INT)) { (*g_assert_poison) =
'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/runtime/deoptimization.cpp"
, 1205, "assert(" "value->type() == T_INT" ") failed", "Agreement."
); ::breakpoint(); } } while (0)
;
1206 bool big_value = false;
1207 if (i + 1 < sv->field_size() && type == T_INT) {
1208 if (sv->field_at(i)->is_location()) {
1209 Location::Type type = ((LocationValue*) sv->field_at(i))->location().type();
1210 if (type == Location::dbl || type == Location::lng) {
1211 big_value = true;
1212 }
1213 } else if (sv->field_at(i)->is_constant_int()) {
1214 ScopeValue* next_scope_field = sv->field_at(i + 1);
1215 if (next_scope_field->is_constant_long() || next_scope_field->is_constant_double()) {
1216 big_value = true;
1217 }
1218 }
1219 }
1220
1221 if (big_value) {
1222 StackValue* low = StackValue::create_stack_value(fr, reg_map, sv->field_at(++i));
1223 #ifdef _LP641
1224 jlong res = (jlong)low->get_int();
1225 #else
1226 jlong res = jlong_from((jint)value->get_int(), (jint)low->get_int());
1227 #endif
1228 obj->int_at_put(index, (jint)*((jint*)&res));
1229 obj->int_at_put(++index, (jint)*(((jint*)&res) + 1));
1230 } else {
1231 val = value->get_int();
1232 obj->int_at_put(index, (jint)*((jint*)&val));
1233 }
1234 break;
1235 }
1236
1237 case T_SHORT:
1238 assert(value->type() == T_INT, "Agreement.")do { if (!(value->type() == T_INT)) { (*g_assert_poison) =
'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/runtime/deoptimization.cpp"
, 1238, "assert(" "value->type() == T_INT" ") failed", "Agreement."
); ::breakpoint(); } } while (0)
;
1239 val = value->get_int();
1240 obj->short_at_put(index, (jshort)*((jint*)&val));
1241 break;
1242
1243 case T_CHAR:
1244 assert(value->type() == T_INT, "Agreement.")do { if (!(value->type() == T_INT)) { (*g_assert_poison) =
'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/runtime/deoptimization.cpp"
, 1244, "assert(" "value->type() == T_INT" ") failed", "Agreement."
); ::breakpoint(); } } while (0)
;
1245 val = value->get_int();
1246 obj->char_at_put(index, (jchar)*((jint*)&val));
1247 break;
1248
1249 case T_BYTE: {
1250 assert(value->type() == T_INT, "Agreement.")do { if (!(value->type() == T_INT)) { (*g_assert_poison) =
'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/runtime/deoptimization.cpp"
, 1250, "assert(" "value->type() == T_INT" ") failed", "Agreement."
); ::breakpoint(); } } while (0)
;
1251 // The value we get is erased as a regular int. We will need to find its actual byte count 'by hand'.
1252 val = value->get_int();
1253#if INCLUDE_JVMCI1
1254 int byte_count = count_number_of_bytes_for_entry(sv, i);
1255 byte_array_put(obj, val, index, byte_count);
1256 // According to byte_count contract, the values from i + 1 to i + byte_count are illegal values. Skip.
1257 i += byte_count - 1; // Balance the loop counter.
1258 index += byte_count;
1259 // index has been updated so continue at top of loop
1260 continue;
1261#else
1262 obj->byte_at_put(index, (jbyte)*((jint*)&val));
1263 break;
1264#endif // INCLUDE_JVMCI
1265 }
1266
1267 case T_BOOLEAN: {
1268 assert(value->type() == T_INT, "Agreement.")do { if (!(value->type() == T_INT)) { (*g_assert_poison) =
'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/runtime/deoptimization.cpp"
, 1268, "assert(" "value->type() == T_INT" ") failed", "Agreement."
); ::breakpoint(); } } while (0)
;
1269 val = value->get_int();
1270 obj->bool_at_put(index, (jboolean)*((jint*)&val));
1271 break;
1272 }
1273
1274 default:
1275 ShouldNotReachHere()do { (*g_assert_poison) = 'X';; report_should_not_reach_here(
"/home/daniel/Projects/java/jdk/src/hotspot/share/runtime/deoptimization.cpp"
, 1275); ::breakpoint(); } while (0)
;
1276 }
1277 index++;
1278 }
1279}
1280
1281// restore fields of an eliminated object array
1282void Deoptimization::reassign_object_array_elements(frame* fr, RegisterMap* reg_map, ObjectValue* sv, objArrayOop obj) {
1283 for (int i = 0; i < sv->field_size(); i++) {
1284 StackValue* value = StackValue::create_stack_value(fr, reg_map, sv->field_at(i));
1285 assert(value->type() == T_OBJECT, "object element expected")do { if (!(value->type() == T_OBJECT)) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/runtime/deoptimization.cpp"
, 1285, "assert(" "value->type() == T_OBJECT" ") failed", "object element expected"
); ::breakpoint(); } } while (0)
;
1286 obj->obj_at_put(i, value->get_obj()());
1287 }
1288}
1289
1290class ReassignedField {
1291public:
1292 int _offset;
1293 BasicType _type;
1294public:
1295 ReassignedField() {
1296 _offset = 0;
1297 _type = T_ILLEGAL;
1298 }
1299};
1300
1301int compare(ReassignedField* left, ReassignedField* right) {
1302 return left->_offset - right->_offset;
1303}
1304
1305// Restore fields of an eliminated instance object using the same field order
1306// returned by HotSpotResolvedObjectTypeImpl.getInstanceFields(true)
1307static int reassign_fields_by_klass(InstanceKlass* klass, frame* fr, RegisterMap* reg_map, ObjectValue* sv, int svIndex, oop obj, bool skip_internal) {
1308 GrowableArray<ReassignedField>* fields = new GrowableArray<ReassignedField>();
1309 InstanceKlass* ik = klass;
1310 while (ik != NULL__null) {
1311 for (AllFieldStream fs(ik); !fs.done(); fs.next()) {
1312 if (!fs.access_flags().is_static() && (!skip_internal || !fs.access_flags().is_internal())) {
1313 ReassignedField field;
1314 field._offset = fs.offset();
1315 field._type = Signature::basic_type(fs.signature());
1316 fields->append(field);
1317 }
1318 }
1319 ik = ik->superklass();
1320 }
1321 fields->sort(compare);
1322 for (int i = 0; i < fields->length(); i++) {
1323 intptr_t val;
1324 ScopeValue* scope_field = sv->field_at(svIndex);
1325 StackValue* value = StackValue::create_stack_value(fr, reg_map, scope_field);
1326 int offset = fields->at(i)._offset;
1327 BasicType type = fields->at(i)._type;
1328 switch (type) {
1329 case T_OBJECT: case T_ARRAY:
1330 assert(value->type() == T_OBJECT, "Agreement.")do { if (!(value->type() == T_OBJECT)) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/runtime/deoptimization.cpp"
, 1330, "assert(" "value->type() == T_OBJECT" ") failed", "Agreement."
); ::breakpoint(); } } while (0)
;
1331 obj->obj_field_put(offset, value->get_obj()());
1332 break;
1333
1334 // Have to cast to INT (32 bits) pointer to avoid little/big-endian problem.
1335 case T_INT: case T_FLOAT: { // 4 bytes.
1336 assert(value->type() == T_INT, "Agreement.")do { if (!(value->type() == T_INT)) { (*g_assert_poison) =
'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/runtime/deoptimization.cpp"
, 1336, "assert(" "value->type() == T_INT" ") failed", "Agreement."
); ::breakpoint(); } } while (0)
;
1337 bool big_value = false;
1338 if (i+1 < fields->length() && fields->at(i+1)._type == T_INT) {
1339 if (scope_field->is_location()) {
1340 Location::Type type = ((LocationValue*) scope_field)->location().type();
1341 if (type == Location::dbl || type == Location::lng) {
1342 big_value = true;
1343 }
1344 }
1345 if (scope_field->is_constant_int()) {
1346 ScopeValue* next_scope_field = sv->field_at(svIndex + 1);
1347 if (next_scope_field->is_constant_long() || next_scope_field->is_constant_double()) {
1348 big_value = true;
1349 }
1350 }
1351 }
1352
1353 if (big_value) {
1354 i++;
1355 assert(i < fields->length(), "second T_INT field needed")do { if (!(i < fields->length())) { (*g_assert_poison) =
'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/runtime/deoptimization.cpp"
, 1355, "assert(" "i < fields->length()" ") failed", "second T_INT field needed"
); ::breakpoint(); } } while (0)
;
1356 assert(fields->at(i)._type == T_INT, "T_INT field needed")do { if (!(fields->at(i)._type == T_INT)) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/runtime/deoptimization.cpp"
, 1356, "assert(" "fields->at(i)._type == T_INT" ") failed"
, "T_INT field needed"); ::breakpoint(); } } while (0)
;
1357 } else {
1358 val = value->get_int();
1359 obj->int_field_put(offset, (jint)*((jint*)&val));
1360 break;
1361 }
1362 }
1363 /* no break */
1364
1365 case T_LONG: case T_DOUBLE: {
1366 assert(value->type() == T_INT, "Agreement.")do { if (!(value->type() == T_INT)) { (*g_assert_poison) =
'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/runtime/deoptimization.cpp"
, 1366, "assert(" "value->type() == T_INT" ") failed", "Agreement."
); ::breakpoint(); } } while (0)
;
1367 StackValue* low = StackValue::create_stack_value(fr, reg_map, sv->field_at(++svIndex));
1368#ifdef _LP641
1369 jlong res = (jlong)low->get_int();
1370#else
1371 jlong res = jlong_from((jint)value->get_int(), (jint)low->get_int());
1372#endif
1373 obj->long_field_put(offset, res);
1374 break;
1375 }
1376
1377 case T_SHORT:
1378 assert(value->type() == T_INT, "Agreement.")do { if (!(value->type() == T_INT)) { (*g_assert_poison) =
'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/runtime/deoptimization.cpp"
, 1378, "assert(" "value->type() == T_INT" ") failed", "Agreement."
); ::breakpoint(); } } while (0)
;
1379 val = value->get_int();
1380 obj->short_field_put(offset, (jshort)*((jint*)&val));
1381 break;
1382
1383 case T_CHAR:
1384 assert(value->type() == T_INT, "Agreement.")do { if (!(value->type() == T_INT)) { (*g_assert_poison) =
'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/runtime/deoptimization.cpp"
, 1384, "assert(" "value->type() == T_INT" ") failed", "Agreement."
); ::breakpoint(); } } while (0)
;
1385 val = value->get_int();
1386 obj->char_field_put(offset, (jchar)*((jint*)&val));
1387 break;
1388
1389 case T_BYTE:
1390 assert(value->type() == T_INT, "Agreement.")do { if (!(value->type() == T_INT)) { (*g_assert_poison) =
'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/runtime/deoptimization.cpp"
, 1390, "assert(" "value->type() == T_INT" ") failed", "Agreement."
); ::breakpoint(); } } while (0)
;
1391 val = value->get_int();
1392 obj->byte_field_put(offset, (jbyte)*((jint*)&val));
1393 break;
1394
1395 case T_BOOLEAN:
1396 assert(value->type() == T_INT, "Agreement.")do { if (!(value->type() == T_INT)) { (*g_assert_poison) =
'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/runtime/deoptimization.cpp"
, 1396, "assert(" "value->type() == T_INT" ") failed", "Agreement."
); ::breakpoint(); } } while (0)
;
1397 val = value->get_int();
1398 obj->bool_field_put(offset, (jboolean)*((jint*)&val));
1399 break;
1400
1401 default:
1402 ShouldNotReachHere()do { (*g_assert_poison) = 'X';; report_should_not_reach_here(
"/home/daniel/Projects/java/jdk/src/hotspot/share/runtime/deoptimization.cpp"
, 1402); ::breakpoint(); } while (0)
;
1403 }
1404 svIndex++;
1405 }
1406 return svIndex;
1407}
1408
1409// restore fields of all eliminated objects and arrays
1410void Deoptimization::reassign_fields(frame* fr, RegisterMap* reg_map, GrowableArray<ScopeValue*>* objects, bool realloc_failures, bool skip_internal) {
1411 for (int i = 0; i < objects->length(); i++) {
1412 ObjectValue* sv = (ObjectValue*) objects->at(i);
1413 Klass* k = java_lang_Class::as_Klass(sv->klass()->as_ConstantOopReadValue()->value()());
1414 Handle obj = sv->value();
1415 assert(obj.not_null() || realloc_failures, "reallocation was missed")do { if (!(obj.not_null() || realloc_failures)) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/runtime/deoptimization.cpp"
, 1415, "assert(" "obj.not_null() || realloc_failures" ") failed"
, "reallocation was missed"); ::breakpoint(); } } while (0)
;
1416 if (PrintDeoptimizationDetails) {
1417 tty->print_cr("reassign fields for object of type %s!", k->name()->as_C_string());
1418 }
1419 if (obj.is_null()) {
1420 continue;
1421 }
1422
1423 // Don't reassign fields of boxes that came from a cache. Caches may be in CDS.
1424 if (sv->is_auto_box() && ((AutoBoxObjectValue*) sv)->is_cached()) {
1425 continue;
1426 }
1427#ifdef COMPILER21
1428 if (EnableVectorSupport && VectorSupport::is_vector(k)) {
1429 assert(sv->field_size() == 1, "%s not a vector", k->name()->as_C_string())do { if (!(sv->field_size() == 1)) { (*g_assert_poison) = 'X'
;; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/runtime/deoptimization.cpp"
, 1429, "assert(" "sv->field_size() == 1" ") failed", "%s not a vector"
, k->name()->as_C_string()); ::breakpoint(); } } while (
0)
;
1430 ScopeValue* payload = sv->field_at(0);
1431 if (payload->is_location() &&
1432 payload->as_LocationValue()->location().type() == Location::vector) {
1433 if (PrintDeoptimizationDetails) {
1434 tty->print_cr("skip field reassignment for this vector - it should be assigned already");
1435 if (Verbose) {
1436 Handle obj = sv->value();
1437 k->oop_print_on(obj(), tty);
1438 }
1439 }
1440 continue; // Such vector's value was already restored in VectorSupport::allocate_vector().
1441 }
1442 // Else fall-through to do assignment for scalar-replaced boxed vector representation
1443 // which could be restored after vector object allocation.
1444 }
1445#endif
1446 if (k->is_instance_klass()) {
1447 InstanceKlass* ik = InstanceKlass::cast(k);
1448 reassign_fields_by_klass(ik, fr, reg_map, sv, 0, obj(), skip_internal);
1449 } else if (k->is_typeArray_klass()) {
1450 TypeArrayKlass* ak = TypeArrayKlass::cast(k);
1451 reassign_type_array_elements(fr, reg_map, sv, (typeArrayOop) obj(), ak->element_type());
1452 } else if (k->is_objArray_klass()) {
1453 reassign_object_array_elements(fr, reg_map, sv, (objArrayOop) obj());
1454 }
1455 }
1456}
1457
1458
1459// relock objects for which synchronization was eliminated
1460bool Deoptimization::relock_objects(JavaThread* thread, GrowableArray<MonitorInfo*>* monitors,
1461 JavaThread* deoptee_thread, frame& fr, int exec_mode, bool realloc_failures) {
1462 bool relocked_objects = false;
1463 for (int i = 0; i < monitors->length(); i++) {
1464 MonitorInfo* mon_info = monitors->at(i);
1465 if (mon_info->eliminated()) {
1466 assert(!mon_info->owner_is_scalar_replaced() || realloc_failures, "reallocation was missed")do { if (!(!mon_info->owner_is_scalar_replaced() || realloc_failures
)) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/runtime/deoptimization.cpp"
, 1466, "assert(" "!mon_info->owner_is_scalar_replaced() || realloc_failures"
") failed", "reallocation was missed"); ::breakpoint(); } } while
(0)
;
1467 relocked_objects = true;
1468 if (!mon_info->owner_is_scalar_replaced()) {
1469 Handle obj(thread, mon_info->owner());
1470 markWord mark = obj->mark();
1471 if (exec_mode == Unpack_none) {
1472 if (mark.has_locker() && fr.sp() > (intptr_t*)mark.locker()) {
1473 // With exec_mode == Unpack_none obj may be thread local and locked in
1474 // a callee frame. Make the lock in the callee a recursive lock and restore the displaced header.
1475 markWord dmw = mark.displaced_mark_helper();
1476 mark.locker()->set_displaced_header(markWord::encode((BasicLock*) NULL__null));
1477 obj->set_mark(dmw);
1478 }
1479 if (mark.has_monitor()) {
1480 // defer relocking if the deoptee thread is currently waiting for obj
1481 ObjectMonitor* waiting_monitor = deoptee_thread->current_waiting_monitor();
1482 if (waiting_monitor != NULL__null && waiting_monitor->object() == obj()) {
1483 assert(fr.is_deoptimized_frame(), "frame must be scheduled for deoptimization")do { if (!(fr.is_deoptimized_frame())) { (*g_assert_poison) =
'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/runtime/deoptimization.cpp"
, 1483, "assert(" "fr.is_deoptimized_frame()" ") failed", "frame must be scheduled for deoptimization"
); ::breakpoint(); } } while (0)
;
1484 mon_info->lock()->set_displaced_header(markWord::unused_mark());
1485 JvmtiDeferredUpdates::inc_relock_count_after_wait(deoptee_thread);
1486 continue;
1487 }
1488 }
1489 }
1490 BasicLock* lock = mon_info->lock();
1491 ObjectSynchronizer::enter(obj, lock, deoptee_thread);
1492 assert(mon_info->owner()->is_locked(), "object must be locked now")do { if (!(mon_info->owner()->is_locked())) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/runtime/deoptimization.cpp"
, 1492, "assert(" "mon_info->owner()->is_locked()" ") failed"
, "object must be locked now"); ::breakpoint(); } } while (0)
;
1493 }
1494 }
1495 }
1496 return relocked_objects;
1497}
1498#endif // COMPILER2_OR_JVMCI
1499
1500vframeArray* Deoptimization::create_vframeArray(JavaThread* thread, frame fr, RegisterMap *reg_map, GrowableArray<compiledVFrame*>* chunk, bool realloc_failures) {
1501 Events::log_deopt_message(thread, "DEOPT PACKING pc=" INTPTR_FORMAT"0x%016" "l" "x" " sp=" INTPTR_FORMAT"0x%016" "l" "x", p2i(fr.pc()), p2i(fr.sp()));
1502
1503#ifndef PRODUCT
1504 if (PrintDeoptimizationDetails) {
1505 ResourceMark rm;
1506 stringStream st;
1507 st.print("DEOPT PACKING thread " INTPTR_FORMAT"0x%016" "l" "x" " ", p2i(thread));
1508 fr.print_on(&st);
1509 st.print_cr(" Virtual frames (innermost first):");
1510 for (int index = 0; index < chunk->length(); index++) {
1511 compiledVFrame* vf = chunk->at(index);
1512 st.print(" %2d - ", index);
1513 vf->print_value_on(&st);
1514 int bci = chunk->at(index)->raw_bci();
1515 const char* code_name;
1516 if (bci == SynchronizationEntryBCI) {
1517 code_name = "sync entry";
1518 } else {
1519 Bytecodes::Code code = vf->method()->code_at(bci);
1520 code_name = Bytecodes::name(code);
1521 }
1522 st.print(" - %s", code_name);
1523 st.print_cr(" @ bci %d ", bci);
1524 if (Verbose) {
1525 vf->print_on(&st);
1526 st.cr();
1527 }
1528 }
1529 tty->print_raw(st.as_string());
1530 }
1531#endif
1532
1533 // Register map for next frame (used for stack crawl). We capture
1534 // the state of the deopt'ing frame's caller. Thus if we need to
1535 // stuff a C2I adapter we can properly fill in the callee-save
1536 // register locations.
1537 frame caller = fr.sender(reg_map);
1538 int frame_size = caller.sp() - fr.sp();
1539
1540 frame sender = caller;
1541
1542 // Since the Java thread being deoptimized will eventually adjust it's own stack,
1543 // the vframeArray containing the unpacking information is allocated in the C heap.
1544 // For Compiler1, the caller of the deoptimized frame is saved for use by unpack_frames().
1545 vframeArray* array = vframeArray::allocate(thread, frame_size, chunk, reg_map, sender, caller, fr, realloc_failures);
1546
1547 // Compare the vframeArray to the collected vframes
1548 assert(array->structural_compare(thread, chunk), "just checking")do { if (!(array->structural_compare(thread, chunk))) { (*
g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/runtime/deoptimization.cpp"
, 1548, "assert(" "array->structural_compare(thread, chunk)"
") failed", "just checking"); ::breakpoint(); } } while (0)
;
1549
1550#ifndef PRODUCT
1551 if (PrintDeoptimizationDetails) {
1552 tty->print_cr(" Created vframeArray " INTPTR_FORMAT"0x%016" "l" "x", p2i(array));
1553 }
1554#endif // PRODUCT
1555
1556 return array;
1557}
1558
1559#if COMPILER2_OR_JVMCI1
1560void Deoptimization::pop_frames_failed_reallocs(JavaThread* thread, vframeArray* array) {
1561 // Reallocation of some scalar replaced objects failed. Record
1562 // that we need to pop all the interpreter frames for the
1563 // deoptimized compiled frame.
1564 assert(thread->frames_to_pop_failed_realloc() == 0, "missed frames to pop?")do { if (!(thread->frames_to_pop_failed_realloc() == 0)) {
(*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/runtime/deoptimization.cpp"
, 1564, "assert(" "thread->frames_to_pop_failed_realloc() == 0"
") failed", "missed frames to pop?"); ::breakpoint(); } } while
(0)
;
1565 thread->set_frames_to_pop_failed_realloc(array->frames());
1566 // Unlock all monitors here otherwise the interpreter will see a
1567 // mix of locked and unlocked monitors (because of failed
1568 // reallocations of synchronized objects) and be confused.
1569 for (int i = 0; i < array->frames(); i++) {
1570 MonitorChunk* monitors = array->element(i)->monitors();
1571 if (monitors != NULL__null) {
1572 for (int j = 0; j < monitors->number_of_monitors(); j++) {
1573 BasicObjectLock* src = monitors->at(j);
1574 if (src->obj() != NULL__null) {
1575 ObjectSynchronizer::exit(src->obj(), src->lock(), thread);
1576 }
1577 }
1578 array->element(i)->free_monitors(thread);
1579#ifdef ASSERT1
1580 array->element(i)->set_removed_monitors();
1581#endif
1582 }
1583 }
1584}
1585#endif
1586
1587void Deoptimization::deoptimize_single_frame(JavaThread* thread, frame fr, Deoptimization::DeoptReason reason) {
1588 assert(fr.can_be_deoptimized(), "checking frame type")do { if (!(fr.can_be_deoptimized())) { (*g_assert_poison) = 'X'
;; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/runtime/deoptimization.cpp"
, 1588, "assert(" "fr.can_be_deoptimized()" ") failed", "checking frame type"
); ::breakpoint(); } } while (0)
;
1589
1590 gather_statistics(reason, Action_none, Bytecodes::_illegal);
1591
1592 if (LogCompilation && xtty != NULL__null) {
1593 CompiledMethod* cm = fr.cb()->as_compiled_method_or_null();
1594 assert(cm != NULL, "only compiled methods can deopt")do { if (!(cm != __null)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/runtime/deoptimization.cpp"
, 1594, "assert(" "cm != __null" ") failed", "only compiled methods can deopt"
); ::breakpoint(); } } while (0)
;
1595
1596 ttyLocker ttyl;
1597 xtty->begin_head("deoptimized thread='" UINTX_FORMAT"%" "l" "u" "' reason='%s' pc='" INTPTR_FORMAT"0x%016" "l" "x" "'",(uintx)thread->osthread()->thread_id(), trap_reason_name(reason), p2i(fr.pc()));
1598 cm->log_identity(xtty);
1599 xtty->end_head();
1600 for (ScopeDesc* sd = cm->scope_desc_at(fr.pc()); ; sd = sd->sender()) {
1601 xtty->begin_elem("jvms bci='%d'", sd->bci());
1602 xtty->method(sd->method());
1603 xtty->end_elem();
1604 if (sd->is_top()) break;
1605 }
1606 xtty->tail("deoptimized");
1607 }
1608
1609 // Patch the compiled method so that when execution returns to it we will
1610 // deopt the execution state and return to the interpreter.
1611 fr.deoptimize(thread);
1612}
1613
1614void Deoptimization::deoptimize(JavaThread* thread, frame fr, DeoptReason reason) {
1615 // Deoptimize only if the frame comes from compile code.
1616 // Do not deoptimize the frame which is already patched
1617 // during the execution of the loops below.
1618 if (!fr.is_compiled_frame() || fr.is_deoptimized_frame()) {
1619 return;
1620 }
1621 ResourceMark rm;
1622 DeoptimizationMarker dm;
1623 deoptimize_single_frame(thread, fr, reason);
1624}
1625
1626#if INCLUDE_JVMCI1
1627address Deoptimization::deoptimize_for_missing_exception_handler(CompiledMethod* cm) {
1628 // there is no exception handler for this pc => deoptimize
1629 cm->make_not_entrant();
1630
1631 // Use Deoptimization::deoptimize for all of its side-effects:
1632 // gathering traps statistics, logging...
1633 // it also patches the return pc but we do not care about that
1634 // since we return a continuation to the deopt_blob below.
1635 JavaThread* thread = JavaThread::current();
1636 RegisterMap reg_map(thread, false);
1637 frame runtime_frame = thread->last_frame();
1638 frame caller_frame = runtime_frame.sender(&reg_map);
1639 assert(caller_frame.cb()->as_compiled_method_or_null() == cm, "expect top frame compiled method")do { if (!(caller_frame.cb()->as_compiled_method_or_null()
== cm)) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/runtime/deoptimization.cpp"
, 1639, "assert(" "caller_frame.cb()->as_compiled_method_or_null() == cm"
") failed", "expect top frame compiled method"); ::breakpoint
(); } } while (0)
;
1640 vframe* vf = vframe::new_vframe(&caller_frame, &reg_map, thread);
1641 compiledVFrame* cvf = compiledVFrame::cast(vf);
1642 ScopeDesc* imm_scope = cvf->scope();
1643 MethodData* imm_mdo = get_method_data(thread, methodHandle(thread, imm_scope->method()), true);
1644 if (imm_mdo != NULL__null) {
1645 ProfileData* pdata = imm_mdo->allocate_bci_to_data(imm_scope->bci(), NULL__null);
1646 if (pdata != NULL__null && pdata->is_BitData()) {
1647 BitData* bit_data = (BitData*) pdata;
1648 bit_data->set_exception_seen();
1649 }
1650 }
1651
1652 Deoptimization::deoptimize(thread, caller_frame, Deoptimization::Reason_not_compiled_exception_handler);
1653
1654 MethodData* trap_mdo = get_method_data(thread, methodHandle(thread, cm->method()), true);
1655 if (trap_mdo != NULL__null) {
1656 trap_mdo->inc_trap_count(Deoptimization::Reason_not_compiled_exception_handler);
1657 }
1658
1659 return SharedRuntime::deopt_blob()->unpack_with_exception_in_tls();
1660}
1661#endif
1662
1663void Deoptimization::deoptimize_frame_internal(JavaThread* thread, intptr_t* id, DeoptReason reason) {
1664 assert(thread == Thread::current() ||do { if (!(thread == Thread::current() || thread->is_handshake_safe_for
(Thread::current()) || SafepointSynchronize::is_at_safepoint(
))) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/runtime/deoptimization.cpp"
, 1667, "assert(" "thread == Thread::current() || thread->is_handshake_safe_for(Thread::current()) || SafepointSynchronize::is_at_safepoint()"
") failed", "can only deoptimize other thread at a safepoint/handshake"
); ::breakpoint(); } } while (0)
1665 thread->is_handshake_safe_for(Thread::current()) ||do { if (!(thread == Thread::current() || thread->is_handshake_safe_for
(Thread::current()) || SafepointSynchronize::is_at_safepoint(
))) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/runtime/deoptimization.cpp"
, 1667, "assert(" "thread == Thread::current() || thread->is_handshake_safe_for(Thread::current()) || SafepointSynchronize::is_at_safepoint()"
") failed", "can only deoptimize other thread at a safepoint/handshake"
); ::breakpoint(); } } while (0)
1666 SafepointSynchronize::is_at_safepoint(),do { if (!(thread == Thread::current() || thread->is_handshake_safe_for
(Thread::current()) || SafepointSynchronize::is_at_safepoint(
))) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/runtime/deoptimization.cpp"
, 1667, "assert(" "thread == Thread::current() || thread->is_handshake_safe_for(Thread::current()) || SafepointSynchronize::is_at_safepoint()"
") failed", "can only deoptimize other thread at a safepoint/handshake"
); ::breakpoint(); } } while (0)
1667 "can only deoptimize other thread at a safepoint/handshake")do { if (!(thread == Thread::current() || thread->is_handshake_safe_for
(Thread::current()) || SafepointSynchronize::is_at_safepoint(
))) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/runtime/deoptimization.cpp"
, 1667, "assert(" "thread == Thread::current() || thread->is_handshake_safe_for(Thread::current()) || SafepointSynchronize::is_at_safepoint()"
") failed", "can only deoptimize other thread at a safepoint/handshake"
); ::breakpoint(); } } while (0)
;
1668 // Compute frame and register map based on thread and sp.
1669 RegisterMap reg_map(thread, false);
1670 frame fr = thread->last_frame();
1671 while (fr.id() != id) {
1672 fr = fr.sender(&reg_map);
1673 }
1674 deoptimize(thread, fr, reason);
1675}
1676
1677
1678void Deoptimization::deoptimize_frame(JavaThread* thread, intptr_t* id, DeoptReason reason) {
1679 Thread* current = Thread::current();
1680 if (thread == current || thread->is_handshake_safe_for(current)) {
1681 Deoptimization::deoptimize_frame_internal(thread, id, reason);
1682 } else {
1683 VM_DeoptimizeFrame deopt(thread, id, reason);
1684 VMThread::execute(&deopt);
1685 }
1686}
1687
1688void Deoptimization::deoptimize_frame(JavaThread* thread, intptr_t* id) {
1689 deoptimize_frame(thread, id, Reason_constraint);
1690}
1691
1692// JVMTI PopFrame support
1693JRT_LEAF(void, Deoptimization::popframe_preserve_args(JavaThread* thread, int bytes_to_save, void* start_address))void Deoptimization::popframe_preserve_args(JavaThread* thread
, int bytes_to_save, void* start_address) { NoHandleMark __hm
; ; os::verify_stack_alignment(); NoSafepointVerifier __nsv;
1694{
1695 thread->popframe_preserve_args(in_ByteSize(bytes_to_save), start_address);
1696}
1697JRT_END}
1698
1699MethodData*
1700Deoptimization::get_method_data(JavaThread* thread, const methodHandle& m,
1701 bool create_if_missing) {
1702 JavaThread* THREAD__the_thread__ = thread; // For exception macros.
1703 MethodData* mdo = m()->method_data();
1704 if (mdo == NULL__null && create_if_missing && !HAS_PENDING_EXCEPTION(((ThreadShadow*)__the_thread__)->has_pending_exception())) {
1705 // Build an MDO. Ignore errors like OutOfMemory;
1706 // that simply means we won't have an MDO to update.
1707 Method::build_interpreter_method_data(m, THREAD__the_thread__);
1708 if (HAS_PENDING_EXCEPTION(((ThreadShadow*)__the_thread__)->has_pending_exception())) {
1709 // Only metaspace OOM is expected. No Java code executed.
1710 assert((PENDING_EXCEPTION->is_a(vmClasses::OutOfMemoryError_klass())), "we expect only an OOM error here")do { if (!(((((ThreadShadow*)__the_thread__)->pending_exception
())->is_a(vmClasses::OutOfMemoryError_klass())))) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/runtime/deoptimization.cpp"
, 1710, "assert(" "((((ThreadShadow*)__the_thread__)->pending_exception())->is_a(vmClasses::OutOfMemoryError_klass()))"
") failed", "we expect only an OOM error here"); ::breakpoint
(); } } while (0)
;
1711 CLEAR_PENDING_EXCEPTION(((ThreadShadow*)__the_thread__)->clear_pending_exception(
))
;
1712 }
1713 mdo = m()->method_data();
1714 }
1715 return mdo;
1716}
1717
1718#if COMPILER2_OR_JVMCI1
1719void Deoptimization::load_class_by_index(const constantPoolHandle& constant_pool, int index, TRAPSJavaThread* __the_thread__) {
1720 // In case of an unresolved klass entry, load the class.
1721 // This path is exercised from case _ldc in Parse::do_one_bytecode,
1722 // and probably nowhere else.
1723 // Even that case would benefit from simply re-interpreting the
1724 // bytecode, without paying special attention to the class index.
1725 // So this whole "class index" feature should probably be removed.
1726
1727 if (constant_pool->tag_at(index).is_unresolved_klass()) {
1728 Klass* tk = constant_pool->klass_at(index, THREAD__the_thread__);
1729 if (HAS_PENDING_EXCEPTION(((ThreadShadow*)__the_thread__)->has_pending_exception())) {
1730 // Exception happened during classloading. We ignore the exception here, since it
1731 // is going to be rethrown since the current activation is going to be deoptimized and
1732 // the interpreter will re-execute the bytecode.
1733 // Do not clear probable Async Exceptions.
1734 CLEAR_PENDING_NONASYNC_EXCEPTION(((ThreadShadow*)__the_thread__)->clear_pending_nonasync_exception
())
;
1735 // Class loading called java code which may have caused a stack
1736 // overflow. If the exception was thrown right before the return
1737 // to the runtime the stack is no longer guarded. Reguard the
1738 // stack otherwise if we return to the uncommon trap blob and the
1739 // stack bang causes a stack overflow we crash.
1740 JavaThread* jt = THREAD__the_thread__;
1741 bool guard_pages_enabled = jt->stack_overflow_state()->reguard_stack_if_needed();
1742 assert(guard_pages_enabled, "stack banging in uncommon trap blob may cause crash")do { if (!(guard_pages_enabled)) { (*g_assert_poison) = 'X';;
report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/runtime/deoptimization.cpp"
, 1742, "assert(" "guard_pages_enabled" ") failed", "stack banging in uncommon trap blob may cause crash"
); ::breakpoint(); } } while (0)
;
1743 }
1744 return;
1745 }
1746
1747 assert(!constant_pool->tag_at(index).is_symbol(),do { if (!(!constant_pool->tag_at(index).is_symbol())) { (
*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/runtime/deoptimization.cpp"
, 1748, "assert(" "!constant_pool->tag_at(index).is_symbol()"
") failed", "no symbolic names here, please"); ::breakpoint(
); } } while (0)
1748 "no symbolic names here, please")do { if (!(!constant_pool->tag_at(index).is_symbol())) { (
*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/runtime/deoptimization.cpp"
, 1748, "assert(" "!constant_pool->tag_at(index).is_symbol()"
") failed", "no symbolic names here, please"); ::breakpoint(
); } } while (0)
;
1749}
1750
1751#if INCLUDE_JFR1
1752
1753class DeoptReasonSerializer : public JfrSerializer {
1754 public:
1755 void serialize(JfrCheckpointWriter& writer) {
1756 writer.write_count((u4)(Deoptimization::Reason_LIMIT + 1)); // + Reason::many (-1)
1757 for (int i = -1; i < Deoptimization::Reason_LIMIT; ++i) {
1758 writer.write_key((u8)i);
1759 writer.write(Deoptimization::trap_reason_name(i));
1760 }
1761 }
1762};
1763
1764class DeoptActionSerializer : public JfrSerializer {
1765 public:
1766 void serialize(JfrCheckpointWriter& writer) {
1767 static const u4 nof_actions = Deoptimization::Action_LIMIT;
1768 writer.write_count(nof_actions);
1769 for (u4 i = 0; i < Deoptimization::Action_LIMIT; ++i) {
1770 writer.write_key(i);
1771 writer.write(Deoptimization::trap_action_name((int)i));
1772 }
1773 }
1774};
1775
1776static void register_serializers() {
1777 static int critical_section = 0;
1778 if (1 == critical_section || Atomic::cmpxchg(&critical_section, 0, 1) == 1) {
1779 return;
1780 }
1781 JfrSerializer::register_serializer(TYPE_DEOPTIMIZATIONREASON, true, new DeoptReasonSerializer());
1782 JfrSerializer::register_serializer(TYPE_DEOPTIMIZATIONACTION, true, new DeoptActionSerializer());
1783}
1784
1785static void post_deoptimization_event(CompiledMethod* nm,
1786 const Method* method,
1787 int trap_bci,
1788 int instruction,
1789 Deoptimization::DeoptReason reason,
1790 Deoptimization::DeoptAction action) {
1791 assert(nm != NULL, "invariant")do { if (!(nm != __null)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/runtime/deoptimization.cpp"
, 1791, "assert(" "nm != __null" ") failed", "invariant"); ::
breakpoint(); } } while (0)
;
1792 assert(method != NULL, "invariant")do { if (!(method != __null)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/runtime/deoptimization.cpp"
, 1792, "assert(" "method != __null" ") failed", "invariant")
; ::breakpoint(); } } while (0)
;
1793 if (EventDeoptimization::is_enabled()) {
1794 static bool serializers_registered = false;
1795 if (!serializers_registered) {
1796 register_serializers();
1797 serializers_registered = true;
1798 }
1799 EventDeoptimization event;
1800 event.set_compileId(nm->compile_id());
1801 event.set_compiler(nm->compiler_type());
1802 event.set_method(method);
1803 event.set_lineNumber(method->line_number_from_bci(trap_bci));
1804 event.set_bci(trap_bci);
1805 event.set_instruction(instruction);
1806 event.set_reason(reason);
1807 event.set_action(action);
1808 event.commit();
1809 }
1810}
1811
1812#endif // INCLUDE_JFR
1813
1814JRT_ENTRY(void, Deoptimization::uncommon_trap_inner(JavaThread* current, jint trap_request))void Deoptimization::uncommon_trap_inner(JavaThread* current,
jint trap_request) { do { if (!(current == JavaThread::current
())) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/runtime/deoptimization.cpp"
, 1814, "assert(" "current == JavaThread::current()" ") failed"
, "Must be"); ::breakpoint(); } } while (0); ; ThreadInVMfromJava
__tiv(current); HandleMarkCleaner __hm(current); JavaThread*
__the_thread__ = current; os::verify_stack_alignment(); VMEntryWrapper
__vew;
{
1815 HandleMark hm(current);
1816
1817 // uncommon_trap() is called at the beginning of the uncommon trap
1818 // handler. Note this fact before we start generating temporary frames
1819 // that can confuse an asynchronous stack walker. This counter is
1820 // decremented at the end of unpack_frames().
1821 current->inc_in_deopt_handler();
1822
1823#if INCLUDE_JVMCI1
1824 // JVMCI might need to get an exception from the stack, which in turn requires the register map to be valid
1825 RegisterMap reg_map(current, true);
1826#else
1827 RegisterMap reg_map(current, false);
1828#endif
1829 frame stub_frame = current->last_frame();
1830 frame fr = stub_frame.sender(&reg_map);
1831 // Make sure the calling nmethod is not getting deoptimized and removed
1832 // before we are done with it.
1833 nmethodLocker nl(fr.pc());
1834
1835 // Log a message
1836 Events::log_deopt_message(current, "Uncommon trap: trap_request=" PTR32_FORMAT"0x%08" "x" " fr.pc=" INTPTR_FORMAT"0x%016" "l" "x" " relative=" INTPTR_FORMAT"0x%016" "l" "x",
1837 trap_request, p2i(fr.pc()), fr.pc() - fr.cb()->code_begin());
1838
1839 {
1840 ResourceMark rm;
1841
1842 DeoptReason reason = trap_request_reason(trap_request);
1843 DeoptAction action = trap_request_action(trap_request);
1844#if INCLUDE_JVMCI1
1845 int debug_id = trap_request_debug_id(trap_request);
1846#endif
1847 jint unloaded_class_index = trap_request_index(trap_request); // CP idx or -1
1848
1849 vframe* vf = vframe::new_vframe(&fr, &reg_map, current);
1850 compiledVFrame* cvf = compiledVFrame::cast(vf);
1851
1852 CompiledMethod* nm = cvf->code();
1853
1854 ScopeDesc* trap_scope = cvf->scope();
1855
1856 bool is_receiver_constraint_failure = COMPILER2_PRESENT(VerifyReceiverTypes &&)VerifyReceiverTypes && (reason == Deoptimization::Reason_receiver_constraint);
1857
1858 if (TraceDeoptimization || is_receiver_constraint_failure) {
1859 tty->print_cr(" bci=%d pc=" INTPTR_FORMAT"0x%016" "l" "x" ", relative_pc=" INTPTR_FORMAT"0x%016" "l" "x" ", method=%s" JVMCI_ONLY(", debug_id=%d")", debug_id=%d", trap_scope->bci(), p2i(fr.pc()), fr.pc() - nm->code_begin(), trap_scope->method()->name_and_sig_as_C_string()
1860#if INCLUDE_JVMCI1
1861 , debug_id
1862#endif
1863 );
1864 }
1865
1866 methodHandle trap_method(current, trap_scope->method());
1867 int trap_bci = trap_scope->bci();
1868#if INCLUDE_JVMCI1
1869 jlong speculation = current->pending_failed_speculation();
1870 if (nm->is_compiled_by_jvmci()) {
1871 nm->as_nmethod()->update_speculation(current);
1872 } else {
1873 assert(speculation == 0, "There should not be a speculation for methods compiled by non-JVMCI compilers")do { if (!(speculation == 0)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/runtime/deoptimization.cpp"
, 1873, "assert(" "speculation == 0" ") failed", "There should not be a speculation for methods compiled by non-JVMCI compilers"
); ::breakpoint(); } } while (0)
;
1874 }
1875
1876 if (trap_bci == SynchronizationEntryBCI) {
1877 trap_bci = 0;
1878 current->set_pending_monitorenter(true);
1879 }
1880
1881 if (reason == Deoptimization::Reason_transfer_to_interpreter) {
1882 current->set_pending_transfer_to_interpreter(true);
1883 }
1884#endif
1885
1886 Bytecodes::Code trap_bc = trap_method->java_code_at(trap_bci);
1887 // Record this event in the histogram.
1888 gather_statistics(reason, action, trap_bc);
1889
1890 // Ensure that we can record deopt. history:
1891 // Need MDO to record RTM code generation state.
1892 bool create_if_missing = ProfileTraps || UseCodeAging RTM_OPT_ONLY( || UseRTMLocking )|| UseRTMLocking;
1893
1894 methodHandle profiled_method;
1895#if INCLUDE_JVMCI1
1896 if (nm->is_compiled_by_jvmci()) {
1897 profiled_method = methodHandle(current, nm->method());
1898 } else {
1899 profiled_method = trap_method;
1900 }
1901#else
1902 profiled_method = trap_method;
1903#endif
1904
1905 MethodData* trap_mdo =
1906 get_method_data(current, profiled_method, create_if_missing);
1907
1908 JFR_ONLY(post_deoptimization_event(nm, trap_method(), trap_bci, trap_bc, reason, action);)post_deoptimization_event(nm, trap_method(), trap_bci, trap_bc
, reason, action);
1909
1910 // Log a message
1911 Events::log_deopt_message(current, "Uncommon trap: reason=%s action=%s pc=" INTPTR_FORMAT"0x%016" "l" "x" " method=%s @ %d %s",
1912 trap_reason_name(reason), trap_action_name(action), p2i(fr.pc()),
1913 trap_method->name_and_sig_as_C_string(), trap_bci, nm->compiler_name());
1914
1915 // Print a bunch of diagnostics, if requested.
1916 if (TraceDeoptimization || LogCompilation || is_receiver_constraint_failure) {
1917 ResourceMark rm;
1918 ttyLocker ttyl;
1919 char buf[100];
1920 if (xtty != NULL__null) {
1921 xtty->begin_head("uncommon_trap thread='" UINTX_FORMAT"%" "l" "u" "' %s",
1922 os::current_thread_id(),
1923 format_trap_request(buf, sizeof(buf), trap_request));
1924#if INCLUDE_JVMCI1
1925 if (speculation != 0) {
1926 xtty->print(" speculation='" JLONG_FORMAT"%" "l" "d" "'", speculation);
1927 }
1928#endif
1929 nm->log_identity(xtty);
1930 }
1931 Symbol* class_name = NULL__null;
1932 bool unresolved = false;
1933 if (unloaded_class_index >= 0) {
1934 constantPoolHandle constants (current, trap_method->constants());
1935 if (constants->tag_at(unloaded_class_index).is_unresolved_klass()) {
1936 class_name = constants->klass_name_at(unloaded_class_index);
1937 unresolved = true;
1938 if (xtty != NULL__null)
1939 xtty->print(" unresolved='1'");
1940 } else if (constants->tag_at(unloaded_class_index).is_symbol()) {
1941 class_name = constants->symbol_at(unloaded_class_index);
1942 }
1943 if (xtty != NULL__null)
1944 xtty->name(class_name);
1945 }
1946 if (xtty != NULL__null && trap_mdo != NULL__null && (int)reason < (int)MethodData::_trap_hist_limit) {
1947 // Dump the relevant MDO state.
1948 // This is the deopt count for the current reason, any previous
1949 // reasons or recompiles seen at this point.
1950 int dcnt = trap_mdo->trap_count(reason);
1951 if (dcnt != 0)
1952 xtty->print(" count='%d'", dcnt);
1953 ProfileData* pdata = trap_mdo->bci_to_data(trap_bci);
1954 int dos = (pdata == NULL__null)? 0: pdata->trap_state();
1955 if (dos != 0) {
1956 xtty->print(" state='%s'", format_trap_state(buf, sizeof(buf), dos));
1957 if (trap_state_is_recompiled(dos)) {
1958 int recnt2 = trap_mdo->overflow_recompile_count();
1959 if (recnt2 != 0)
1960 xtty->print(" recompiles2='%d'", recnt2);
1961 }
1962 }
1963 }
1964 if (xtty != NULL__null) {
1965 xtty->stamp();
1966 xtty->end_head();
1967 }
1968 if (TraceDeoptimization) { // make noise on the tty
1969 tty->print("Uncommon trap occurred in");
1970 nm->method()->print_short_name(tty);
1971 tty->print(" compiler=%s compile_id=%d", nm->compiler_name(), nm->compile_id());
1972#if INCLUDE_JVMCI1
1973 if (nm->is_nmethod()) {
1974 const char* installed_code_name = nm->as_nmethod()->jvmci_name();
1975 if (installed_code_name != NULL__null) {
1976 tty->print(" (JVMCI: installed code name=%s) ", installed_code_name);
1977 }
1978 }
1979#endif
1980 tty->print(" (@" INTPTR_FORMAT"0x%016" "l" "x" ") thread=" UINTX_FORMAT"%" "l" "u" " reason=%s action=%s unloaded_class_index=%d" JVMCI_ONLY(" debug_id=%d")" debug_id=%d",
1981 p2i(fr.pc()),
1982 os::current_thread_id(),
1983 trap_reason_name(reason),
1984 trap_action_name(action),
1985 unloaded_class_index
1986#if INCLUDE_JVMCI1
1987 , debug_id
1988#endif
1989 );
1990 if (class_name != NULL__null) {
1991 tty->print(unresolved ? " unresolved class: " : " symbol: ");
1992 class_name->print_symbol_on(tty);
1993 }
1994 tty->cr();
1995 }
1996 if (xtty != NULL__null) {
1997 // Log the precise location of the trap.
1998 for (ScopeDesc* sd = trap_scope; ; sd = sd->sender()) {
1999 xtty->begin_elem("jvms bci='%d'", sd->bci());
2000 xtty->method(sd->method());
2001 xtty->end_elem();
2002 if (sd->is_top()) break;
2003 }
2004 xtty->tail("uncommon_trap");
2005 }
2006 }
2007 // (End diagnostic printout.)
2008
2009 if (is_receiver_constraint_failure) {
2010 fatal("missing receiver type check")do { (*g_assert_poison) = 'X';; report_fatal(INTERNAL_ERROR, "/home/daniel/Projects/java/jdk/src/hotspot/share/runtime/deoptimization.cpp"
, 2010, "missing receiver type check"); ::breakpoint(); } while
(0)
;
2011 }
2012
2013 // Load class if necessary
2014 if (unloaded_class_index >= 0) {
2015 constantPoolHandle constants(current, trap_method->constants());
2016 load_class_by_index(constants, unloaded_class_index, THREAD__the_thread__);
2017 }
2018
2019 // Flush the nmethod if necessary and desirable.
2020 //
2021 // We need to avoid situations where we are re-flushing the nmethod
2022 // because of a hot deoptimization site. Repeated flushes at the same
2023 // point need to be detected by the compiler and avoided. If the compiler
2024 // cannot avoid them (or has a bug and "refuses" to avoid them), this
2025 // module must take measures to avoid an infinite cycle of recompilation
2026 // and deoptimization. There are several such measures:
2027 //
2028 // 1. If a recompilation is ordered a second time at some site X
2029 // and for the same reason R, the action is adjusted to 'reinterpret',
2030 // to give the interpreter time to exercise the method more thoroughly.
2031 // If this happens, the method's overflow_recompile_count is incremented.
2032 //
2033 // 2. If the compiler fails to reduce the deoptimization rate, then
2034 // the method's overflow_recompile_count will begin to exceed the set
2035 // limit PerBytecodeRecompilationCutoff. If this happens, the action
2036 // is adjusted to 'make_not_compilable', and the method is abandoned
2037 // to the interpreter. This is a performance hit for hot methods,
2038 // but is better than a disastrous infinite cycle of recompilations.
2039 // (Actually, only the method containing the site X is abandoned.)
2040 //
2041 // 3. In parallel with the previous measures, if the total number of
2042 // recompilations of a method exceeds the much larger set limit
2043 // PerMethodRecompilationCutoff, the method is abandoned.
2044 // This should only happen if the method is very large and has
2045 // many "lukewarm" deoptimizations. The code which enforces this
2046 // limit is elsewhere (class nmethod, class Method).
2047 //
2048 // Note that the per-BCI 'is_recompiled' bit gives the compiler one chance
2049 // to recompile at each bytecode independently of the per-BCI cutoff.
2050 //
2051 // The decision to update code is up to the compiler, and is encoded
2052 // in the Action_xxx code. If the compiler requests Action_none
2053 // no trap state is changed, no compiled code is changed, and the
2054 // computation suffers along in the interpreter.
2055 //
2056 // The other action codes specify various tactics for decompilation
2057 // and recompilation. Action_maybe_recompile is the loosest, and
2058 // allows the compiled code to stay around until enough traps are seen,
2059 // and until the compiler gets around to recompiling the trapping method.
2060 //
2061 // The other actions cause immediate removal of the present code.
2062
2063 // Traps caused by injected profile shouldn't pollute trap counts.
2064 bool injected_profile_trap = trap_method->has_injected_profile() &&
2065 (reason == Reason_intrinsic || reason == Reason_unreached);
2066
2067 bool update_trap_state = (reason != Reason_tenured) && !injected_profile_trap;
2068 bool make_not_entrant = false;
2069 bool make_not_compilable = false;
2070 bool reprofile = false;
2071 switch (action) {
2072 case Action_none:
2073 // Keep the old code.
2074 update_trap_state = false;
2075 break;
2076 case Action_maybe_recompile:
2077 // Do not need to invalidate the present code, but we can
2078 // initiate another
2079 // Start compiler without (necessarily) invalidating the nmethod.
2080 // The system will tolerate the old code, but new code should be
2081 // generated when possible.
2082 break;
2083 case Action_reinterpret:
2084 // Go back into the interpreter for a while, and then consider
2085 // recompiling form scratch.
2086 make_not_entrant = true;
2087 // Reset invocation counter for outer most method.
2088 // This will allow the interpreter to exercise the bytecodes
2089 // for a while before recompiling.
2090 // By contrast, Action_make_not_entrant is immediate.
2091 //
2092 // Note that the compiler will track null_check, null_assert,
2093 // range_check, and class_check events and log them as if they
2094 // had been traps taken from compiled code. This will update
2095 // the MDO trap history so that the next compilation will
2096 // properly detect hot trap sites.
2097 reprofile = true;
2098 break;
2099 case Action_make_not_entrant:
2100 // Request immediate recompilation, and get rid of the old code.
2101 // Make them not entrant, so next time they are called they get
2102 // recompiled. Unloaded classes are loaded now so recompile before next
2103 // time they are called. Same for uninitialized. The interpreter will
2104 // link the missing class, if any.
2105 make_not_entrant = true;
2106 break;
2107 case Action_make_not_compilable:
2108 // Give up on compiling this method at all.
2109 make_not_entrant = true;
2110 make_not_compilable = true;
2111 break;
2112 default:
2113 ShouldNotReachHere()do { (*g_assert_poison) = 'X';; report_should_not_reach_here(
"/home/daniel/Projects/java/jdk/src/hotspot/share/runtime/deoptimization.cpp"
, 2113); ::breakpoint(); } while (0)
;
2114 }
2115
2116 // Setting +ProfileTraps fixes the following, on all platforms:
2117 // 4852688: ProfileInterpreter is off by default for ia64. The result is
2118 // infinite heroic-opt-uncommon-trap/deopt/recompile cycles, since the
2119 // recompile relies on a MethodData* to record heroic opt failures.
2120
2121 // Whether the interpreter is producing MDO data or not, we also need
2122 // to use the MDO to detect hot deoptimization points and control
2123 // aggressive optimization.
2124 bool inc_recompile_count = false;
2125 ProfileData* pdata = NULL__null;
2126 if (ProfileTraps && CompilerConfig::is_c2_or_jvmci_compiler_enabled() && update_trap_state && trap_mdo != NULL__null) {
2127 assert(trap_mdo == get_method_data(current, profiled_method, false), "sanity")do { if (!(trap_mdo == get_method_data(current, profiled_method
, false))) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/runtime/deoptimization.cpp"
, 2127, "assert(" "trap_mdo == get_method_data(current, profiled_method, false)"
") failed", "sanity"); ::breakpoint(); } } while (0)
;
2128 uint this_trap_count = 0;
2129 bool maybe_prior_trap = false;
2130 bool maybe_prior_recompile = false;
2131 pdata = query_update_method_data(trap_mdo, trap_bci, reason, true,
2132#if INCLUDE_JVMCI1
2133 nm->is_compiled_by_jvmci() && nm->is_osr_method(),
2134#endif
2135 nm->method(),
2136 //outputs:
2137 this_trap_count,
2138 maybe_prior_trap,
2139 maybe_prior_recompile);
2140 // Because the interpreter also counts null, div0, range, and class
2141 // checks, these traps from compiled code are double-counted.
2142 // This is harmless; it just means that the PerXTrapLimit values
2143 // are in effect a little smaller than they look.
2144
2145 DeoptReason per_bc_reason = reason_recorded_per_bytecode_if_any(reason);
2146 if (per_bc_reason != Reason_none) {
2147 // Now take action based on the partially known per-BCI history.
2148 if (maybe_prior_trap
2149 && this_trap_count >= (uint)PerBytecodeTrapLimit) {
2150 // If there are too many traps at this BCI, force a recompile.
2151 // This will allow the compiler to see the limit overflow, and
2152 // take corrective action, if possible. The compiler generally
2153 // does not use the exact PerBytecodeTrapLimit value, but instead
2154 // changes its tactics if it sees any traps at all. This provides
2155 // a little hysteresis, delaying a recompile until a trap happens
2156 // several times.
2157 //
2158 // Actually, since there is only one bit of counter per BCI,
2159 // the possible per-BCI counts are {0,1,(per-method count)}.
2160 // This produces accurate results if in fact there is only
2161 // one hot trap site, but begins to get fuzzy if there are
2162 // many sites. For example, if there are ten sites each
2163 // trapping two or more times, they each get the blame for
2164 // all of their traps.
2165 make_not_entrant = true;
2166 }
2167
2168 // Detect repeated recompilation at the same BCI, and enforce a limit.
2169 if (make_not_entrant && maybe_prior_recompile) {
2170 // More than one recompile at this point.
2171 inc_recompile_count = maybe_prior_trap;
2172 }
2173 } else {
2174 // For reasons which are not recorded per-bytecode, we simply
2175 // force recompiles unconditionally.
2176 // (Note that PerMethodRecompilationCutoff is enforced elsewhere.)
2177 make_not_entrant = true;
2178 }
2179
2180 // Go back to the compiler if there are too many traps in this method.
2181 if (this_trap_count >= per_method_trap_limit(reason)) {
2182 // If there are too many traps in this method, force a recompile.
2183 // This will allow the compiler to see the limit overflow, and
2184 // take corrective action, if possible.
2185 // (This condition is an unlikely backstop only, because the
2186 // PerBytecodeTrapLimit is more likely to take effect first,
2187 // if it is applicable.)
2188 make_not_entrant = true;
2189 }
2190
2191 // Here's more hysteresis: If there has been a recompile at
2192 // this trap point already, run the method in the interpreter
2193 // for a while to exercise it more thoroughly.
2194 if (make_not_entrant && maybe_prior_recompile && maybe_prior_trap) {
2195 reprofile = true;
2196 }
2197 }
2198
2199 // Take requested actions on the method:
2200
2201 // Recompile
2202 if (make_not_entrant) {
2203 if (!nm->make_not_entrant()) {
2204 return; // the call did not change nmethod's state
2205 }
2206
2207 if (pdata != NULL__null) {
2208 // Record the recompilation event, if any.
2209 int tstate0 = pdata->trap_state();
2210 int tstate1 = trap_state_set_recompiled(tstate0, true);
2211 if (tstate1 != tstate0)
2212 pdata->set_trap_state(tstate1);
2213 }
2214
2215#if INCLUDE_RTM_OPT1
2216 // Restart collecting RTM locking abort statistic if the method
2217 // is recompiled for a reason other than RTM state change.
2218 // Assume that in new recompiled code the statistic could be different,
2219 // for example, due to different inlining.
2220 if ((reason != Reason_rtm_state_change) && (trap_mdo != NULL__null) &&
2221 UseRTMDeopt && (nm->as_nmethod()->rtm_state() != ProfileRTM)) {
2222 trap_mdo->atomic_set_rtm_state(ProfileRTM);
2223 }
2224#endif
2225 // For code aging we count traps separately here, using make_not_entrant()
2226 // as a guard against simultaneous deopts in multiple threads.
2227 if (reason == Reason_tenured && trap_mdo != NULL__null) {
2228 trap_mdo->inc_tenure_traps();
2229 }
2230 }
2231
2232 if (inc_recompile_count) {
2233 trap_mdo->inc_overflow_recompile_count();
2234 if ((uint)trap_mdo->overflow_recompile_count() >
2235 (uint)PerBytecodeRecompilationCutoff) {
2236 // Give up on the method containing the bad BCI.
2237 if (trap_method() == nm->method()) {
2238 make_not_compilable = true;
2239 } else {
2240 trap_method->set_not_compilable("overflow_recompile_count > PerBytecodeRecompilationCutoff", CompLevel_full_optimization);
2241 // But give grace to the enclosing nm->method().
2242 }
2243 }
2244 }
2245
2246 // Reprofile
2247 if (reprofile) {
2248 CompilationPolicy::reprofile(trap_scope, nm->is_osr_method());
2249 }
2250
2251 // Give up compiling
2252 if (make_not_compilable && !nm->method()->is_not_compilable(CompLevel_full_optimization)) {
2253 assert(make_not_entrant, "consistent")do { if (!(make_not_entrant)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/runtime/deoptimization.cpp"
, 2253, "assert(" "make_not_entrant" ") failed", "consistent"
); ::breakpoint(); } } while (0)
;
2254 nm->method()->set_not_compilable("give up compiling", CompLevel_full_optimization);
2255 }
2256
2257 } // Free marked resources
2258
2259}
2260JRT_END}
2261
2262ProfileData*
2263Deoptimization::query_update_method_data(MethodData* trap_mdo,
2264 int trap_bci,
2265 Deoptimization::DeoptReason reason,
2266 bool update_total_trap_count,
2267#if INCLUDE_JVMCI1
2268 bool is_osr,
2269#endif
2270 Method* compiled_method,
2271 //outputs:
2272 uint& ret_this_trap_count,
2273 bool& ret_maybe_prior_trap,
2274 bool& ret_maybe_prior_recompile) {
2275 bool maybe_prior_trap = false;
2276 bool maybe_prior_recompile = false;
2277 uint this_trap_count = 0;
2278 if (update_total_trap_count) {
2279 uint idx = reason;
2280#if INCLUDE_JVMCI1
2281 if (is_osr) {
2282 idx += Reason_LIMIT;
2283 }
2284#endif
2285 uint prior_trap_count = trap_mdo->trap_count(idx);
2286 this_trap_count = trap_mdo->inc_trap_count(idx);
2287
2288 // If the runtime cannot find a place to store trap history,
2289 // it is estimated based on the general condition of the method.
2290 // If the method has ever been recompiled, or has ever incurred
2291 // a trap with the present reason , then this BCI is assumed
2292 // (pessimistically) to be the culprit.
2293 maybe_prior_trap = (prior_trap_count != 0);
2294 maybe_prior_recompile = (trap_mdo->decompile_count() != 0);
2295 }
2296 ProfileData* pdata = NULL__null;
2297
2298
2299 // For reasons which are recorded per bytecode, we check per-BCI data.
2300 DeoptReason per_bc_reason = reason_recorded_per_bytecode_if_any(reason);
2301 assert(per_bc_reason != Reason_none || update_total_trap_count, "must be")do { if (!(per_bc_reason != Reason_none || update_total_trap_count
)) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/runtime/deoptimization.cpp"
, 2301, "assert(" "per_bc_reason != Reason_none || update_total_trap_count"
") failed", "must be"); ::breakpoint(); } } while (0)
;
2302 if (per_bc_reason != Reason_none) {
2303 // Find the profile data for this BCI. If there isn't one,
2304 // try to allocate one from the MDO's set of spares.
2305 // This will let us detect a repeated trap at this point.
2306 pdata = trap_mdo->allocate_bci_to_data(trap_bci, reason_is_speculate(reason) ? compiled_method : NULL__null);
2307
2308 if (pdata != NULL__null) {
2309 if (reason_is_speculate(reason) && !pdata->is_SpeculativeTrapData()) {
2310 if (LogCompilation && xtty != NULL__null) {
2311 ttyLocker ttyl;
2312 // no more room for speculative traps in this MDO
2313 xtty->elem("speculative_traps_oom");
2314 }
2315 }
2316 // Query the trap state of this profile datum.
2317 int tstate0 = pdata->trap_state();
2318 if (!trap_state_has_reason(tstate0, per_bc_reason))
2319 maybe_prior_trap = false;
2320 if (!trap_state_is_recompiled(tstate0))
2321 maybe_prior_recompile = false;
2322
2323 // Update the trap state of this profile datum.
2324 int tstate1 = tstate0;
2325 // Record the reason.
2326 tstate1 = trap_state_add_reason(tstate1, per_bc_reason);
2327 // Store the updated state on the MDO, for next time.
2328 if (tstate1 != tstate0)
2329 pdata->set_trap_state(tstate1);
2330 } else {
2331 if (LogCompilation && xtty != NULL__null) {
2332 ttyLocker ttyl;
2333 // Missing MDP? Leave a small complaint in the log.
2334 xtty->elem("missing_mdp bci='%d'", trap_bci);
2335 }
2336 }
2337 }
2338
2339 // Return results:
2340 ret_this_trap_count = this_trap_count;
2341 ret_maybe_prior_trap = maybe_prior_trap;
2342 ret_maybe_prior_recompile = maybe_prior_recompile;
2343 return pdata;
2344}
2345
2346void
2347Deoptimization::update_method_data_from_interpreter(MethodData* trap_mdo, int trap_bci, int reason) {
2348 ResourceMark rm;
2349 // Ignored outputs:
2350 uint ignore_this_trap_count;
2351 bool ignore_maybe_prior_trap;
2352 bool ignore_maybe_prior_recompile;
2353 assert(!reason_is_speculate(reason), "reason speculate only used by compiler")do { if (!(!reason_is_speculate(reason))) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/runtime/deoptimization.cpp"
, 2353, "assert(" "!reason_is_speculate(reason)" ") failed", "reason speculate only used by compiler"
); ::breakpoint(); } } while (0)
;
2354 // JVMCI uses the total counts to determine if deoptimizations are happening too frequently -> do not adjust total counts
2355 bool update_total_counts = true JVMCI_ONLY( && !UseJVMCICompiler)&& !UseJVMCICompiler;
2356 query_update_method_data(trap_mdo, trap_bci,
2357 (DeoptReason)reason,
2358 update_total_counts,
2359#if INCLUDE_JVMCI1
2360 false,
2361#endif
2362 NULL__null,
2363 ignore_this_trap_count,
2364 ignore_maybe_prior_trap,
2365 ignore_maybe_prior_recompile);
2366}
2367
2368Deoptimization::UnrollBlock* Deoptimization::uncommon_trap(JavaThread* current, jint trap_request, jint exec_mode) {
2369 // Enable WXWrite: current function is called from methods compiled by C2 directly
2370 MACOS_AARCH64_ONLY(ThreadWXEnable wx(WXWrite, current));
2371
2372 if (TraceDeoptimization) {
2373 tty->print("Uncommon trap ");
2374 }
2375 // Still in Java no safepoints
2376 {
2377 // This enters VM and may safepoint
2378 uncommon_trap_inner(current, trap_request);
2379 }
2380 HandleMark hm(current);
2381 return fetch_unroll_info_helper(current, exec_mode);
2382}
2383
2384// Local derived constants.
2385// Further breakdown of DataLayout::trap_state, as promised by DataLayout.
2386const int DS_REASON_MASK = ((uint)DataLayout::trap_mask) >> 1;
2387const int DS_RECOMPILE_BIT = DataLayout::trap_mask - DS_REASON_MASK;
2388
2389//---------------------------trap_state_reason---------------------------------
2390Deoptimization::DeoptReason
2391Deoptimization::trap_state_reason(int trap_state) {
2392 // This assert provides the link between the width of DataLayout::trap_bits
2393 // and the encoding of "recorded" reasons. It ensures there are enough
2394 // bits to store all needed reasons in the per-BCI MDO profile.
2395 assert(DS_REASON_MASK >= Reason_RECORDED_LIMIT, "enough bits")do { if (!(DS_REASON_MASK >= Reason_RECORDED_LIMIT)) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/runtime/deoptimization.cpp"
, 2395, "assert(" "DS_REASON_MASK >= Reason_RECORDED_LIMIT"
") failed", "enough bits"); ::breakpoint(); } } while (0)
;
2396 int recompile_bit = (trap_state & DS_RECOMPILE_BIT);
2397 trap_state -= recompile_bit;
2398 if (trap_state == DS_REASON_MASK) {
2399 return Reason_many;
2400 } else {
2401 assert((int)Reason_none == 0, "state=0 => Reason_none")do { if (!((int)Reason_none == 0)) { (*g_assert_poison) = 'X'
;; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/runtime/deoptimization.cpp"
, 2401, "assert(" "(int)Reason_none == 0" ") failed", "state=0 => Reason_none"
); ::breakpoint(); } } while (0)
;
2402 return (DeoptReason)trap_state;
2403 }
2404}
2405//-------------------------trap_state_has_reason-------------------------------
2406int Deoptimization::trap_state_has_reason(int trap_state, int reason) {
2407 assert(reason_is_recorded_per_bytecode((DeoptReason)reason), "valid reason")do { if (!(reason_is_recorded_per_bytecode((DeoptReason)reason
))) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/runtime/deoptimization.cpp"
, 2407, "assert(" "reason_is_recorded_per_bytecode((DeoptReason)reason)"
") failed", "valid reason"); ::breakpoint(); } } while (0)
;
2408 assert(DS_REASON_MASK >= Reason_RECORDED_LIMIT, "enough bits")do { if (!(DS_REASON_MASK >= Reason_RECORDED_LIMIT)) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/runtime/deoptimization.cpp"
, 2408, "assert(" "DS_REASON_MASK >= Reason_RECORDED_LIMIT"
") failed", "enough bits"); ::breakpoint(); } } while (0)
;
2409 int recompile_bit = (trap_state & DS_RECOMPILE_BIT);
2410 trap_state -= recompile_bit;
2411 if (trap_state == DS_REASON_MASK) {
2412 return -1; // true, unspecifically (bottom of state lattice)
2413 } else if (trap_state == reason) {
2414 return 1; // true, definitely
2415 } else if (trap_state == 0) {
2416 return 0; // false, definitely (top of state lattice)
2417 } else {
2418 return 0; // false, definitely
2419 }
2420}
2421//-------------------------trap_state_add_reason-------------------------------
2422int Deoptimization::trap_state_add_reason(int trap_state, int reason) {
2423 assert(reason_is_recorded_per_bytecode((DeoptReason)reason) || reason == Reason_many, "valid reason")do { if (!(reason_is_recorded_per_bytecode((DeoptReason)reason
) || reason == Reason_many)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/runtime/deoptimization.cpp"
, 2423, "assert(" "reason_is_recorded_per_bytecode((DeoptReason)reason) || reason == Reason_many"
") failed", "valid reason"); ::breakpoint(); } } while (0)
;
2424 int recompile_bit = (trap_state & DS_RECOMPILE_BIT);
2425 trap_state -= recompile_bit;
2426 if (trap_state == DS_REASON_MASK) {
2427 return trap_state + recompile_bit; // already at state lattice bottom
2428 } else if (trap_state == reason) {
2429 return trap_state + recompile_bit; // the condition is already true
2430 } else if (trap_state == 0) {
2431 return reason + recompile_bit; // no condition has yet been true
2432 } else {
2433 return DS_REASON_MASK + recompile_bit; // fall to state lattice bottom
2434 }
2435}
2436//-----------------------trap_state_is_recompiled------------------------------
2437bool Deoptimization::trap_state_is_recompiled(int trap_state) {
2438 return (trap_state & DS_RECOMPILE_BIT) != 0;
2439}
2440//-----------------------trap_state_set_recompiled-----------------------------
2441int Deoptimization::trap_state_set_recompiled(int trap_state, bool z) {
2442 if (z) return trap_state | DS_RECOMPILE_BIT;
2443 else return trap_state & ~DS_RECOMPILE_BIT;
2444}
2445//---------------------------format_trap_state---------------------------------
2446// This is used for debugging and diagnostics, including LogFile output.
2447const char* Deoptimization::format_trap_state(char* buf, size_t buflen,
2448 int trap_state) {
2449 assert(buflen > 0, "sanity")do { if (!(buflen > 0)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/runtime/deoptimization.cpp"
, 2449, "assert(" "buflen > 0" ") failed", "sanity"); ::breakpoint
(); } } while (0)
;
2450 DeoptReason reason = trap_state_reason(trap_state);
2451 bool recomp_flag = trap_state_is_recompiled(trap_state);
2452 // Re-encode the state from its decoded components.
2453 int decoded_state = 0;
2454 if (reason_is_recorded_per_bytecode(reason) || reason == Reason_many)
2455 decoded_state = trap_state_add_reason(decoded_state, reason);
2456 if (recomp_flag)
2457 decoded_state = trap_state_set_recompiled(decoded_state, recomp_flag);
2458 // If the state re-encodes properly, format it symbolically.
2459 // Because this routine is used for debugging and diagnostics,
2460 // be robust even if the state is a strange value.
2461 size_t len;
2462 if (decoded_state != trap_state) {
2463 // Random buggy state that doesn't decode??
2464 len = jio_snprintf(buf, buflen, "#%d", trap_state);
Value stored to 'len' is never read
2465 } else {
2466 len = jio_snprintf(buf, buflen, "%s%s",
2467 trap_reason_name(reason),
2468 recomp_flag ? " recompiled" : "");
2469 }
2470 return buf;
2471}
2472
2473
2474//--------------------------------statics--------------------------------------
2475const char* Deoptimization::_trap_reason_name[] = {
2476 // Note: Keep this in sync. with enum DeoptReason.
2477 "none",
2478 "null_check",
2479 "null_assert" JVMCI_ONLY("_or_unreached0")"_or_unreached0",
2480 "range_check",
2481 "class_check",
2482 "array_check",
2483 "intrinsic" JVMCI_ONLY("_or_type_checked_inlining")"_or_type_checked_inlining",
2484 "bimorphic" JVMCI_ONLY("_or_optimized_type_check")"_or_optimized_type_check",
2485 "profile_predicate",
2486 "unloaded",
2487 "uninitialized",
2488 "initialized",
2489 "unreached",
2490 "unhandled",
2491 "constraint",
2492 "div0_check",
2493 "age",
2494 "predicate",
2495 "loop_limit_check",
2496 "speculate_class_check",
2497 "speculate_null_check",
2498 "speculate_null_assert",
2499 "rtm_state_change",
2500 "unstable_if",
2501 "unstable_fused_if",
2502 "receiver_constraint",
2503#if INCLUDE_JVMCI1
2504 "aliasing",
2505 "transfer_to_interpreter",
2506 "not_compiled_exception_handler",
2507 "unresolved",
2508 "jsr_mismatch",
2509#endif
2510 "tenured"
2511};
2512const char* Deoptimization::_trap_action_name[] = {
2513 // Note: Keep this in sync. with enum DeoptAction.
2514 "none",
2515 "maybe_recompile",
2516 "reinterpret",
2517 "make_not_entrant",
2518 "make_not_compilable"
2519};
2520
2521const char* Deoptimization::trap_reason_name(int reason) {
2522 // Check that every reason has a name
2523 STATIC_ASSERT(sizeof(_trap_reason_name)/sizeof(const char*) == Reason_LIMIT)static_assert((sizeof(_trap_reason_name)/sizeof(const char*) ==
Reason_LIMIT), "sizeof(_trap_reason_name)/sizeof(const char*) == Reason_LIMIT"
)
;
2524
2525 if (reason == Reason_many) return "many";
2526 if ((uint)reason < Reason_LIMIT)
2527 return _trap_reason_name[reason];
2528 static char buf[20];
2529 sprintf(buf, "reason%d", reason);
2530 return buf;
2531}
2532const char* Deoptimization::trap_action_name(int action) {
2533 // Check that every action has a name
2534 STATIC_ASSERT(sizeof(_trap_action_name)/sizeof(const char*) == Action_LIMIT)static_assert((sizeof(_trap_action_name)/sizeof(const char*) ==
Action_LIMIT), "sizeof(_trap_action_name)/sizeof(const char*) == Action_LIMIT"
)
;
2535
2536 if ((uint)action < Action_LIMIT)
2537 return _trap_action_name[action];
2538 static char buf[20];
2539 sprintf(buf, "action%d", action);
2540 return buf;
2541}
2542
2543// This is used for debugging and diagnostics, including LogFile output.
2544const char* Deoptimization::format_trap_request(char* buf, size_t buflen,
2545 int trap_request) {
2546 jint unloaded_class_index = trap_request_index(trap_request);
2547 const char* reason = trap_reason_name(trap_request_reason(trap_request));
2548 const char* action = trap_action_name(trap_request_action(trap_request));
2549#if INCLUDE_JVMCI1
2550 int debug_id = trap_request_debug_id(trap_request);
2551#endif
2552 size_t len;
2553 if (unloaded_class_index < 0) {
2554 len = jio_snprintf(buf, buflen, "reason='%s' action='%s'" JVMCI_ONLY(" debug_id='%d'")" debug_id='%d'",
2555 reason, action
2556#if INCLUDE_JVMCI1
2557 ,debug_id
2558#endif
2559 );
2560 } else {
2561 len = jio_snprintf(buf, buflen, "reason='%s' action='%s' index='%d'" JVMCI_ONLY(" debug_id='%d'")" debug_id='%d'",
2562 reason, action, unloaded_class_index
2563#if INCLUDE_JVMCI1
2564 ,debug_id
2565#endif
2566 );
2567 }
2568 return buf;
2569}
2570
2571juint Deoptimization::_deoptimization_hist
2572 [Deoptimization::Reason_LIMIT]
2573 [1 + Deoptimization::Action_LIMIT]
2574 [Deoptimization::BC_CASE_LIMIT]
2575 = {0};
2576
2577enum {
2578 LSB_BITS = 8,
2579 LSB_MASK = right_n_bits(LSB_BITS)((((LSB_BITS) >= BitsPerWord) ? 0 : (OneBit << (LSB_BITS
))) - 1)
2580};
2581
2582void Deoptimization::gather_statistics(DeoptReason reason, DeoptAction action,
2583 Bytecodes::Code bc) {
2584 assert(reason >= 0 && reason < Reason_LIMIT, "oob")do { if (!(reason >= 0 && reason < Reason_LIMIT
)) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/runtime/deoptimization.cpp"
, 2584, "assert(" "reason >= 0 && reason < Reason_LIMIT"
") failed", "oob"); ::breakpoint(); } } while (0)
;
2585 assert(action >= 0 && action < Action_LIMIT, "oob")do { if (!(action >= 0 && action < Action_LIMIT
)) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/runtime/deoptimization.cpp"
, 2585, "assert(" "action >= 0 && action < Action_LIMIT"
") failed", "oob"); ::breakpoint(); } } while (0)
;
2586 _deoptimization_hist[Reason_none][0][0] += 1; // total
2587 _deoptimization_hist[reason][0][0] += 1; // per-reason total
2588 juint* cases = _deoptimization_hist[reason][1+action];
2589 juint* bc_counter_addr = NULL__null;
2590 juint bc_counter = 0;
2591 // Look for an unused counter, or an exact match to this BC.
2592 if (bc != Bytecodes::_illegal) {
2593 for (int bc_case = 0; bc_case < BC_CASE_LIMIT; bc_case++) {
2594 juint* counter_addr = &cases[bc_case];
2595 juint counter = *counter_addr;
2596 if ((counter == 0 && bc_counter_addr == NULL__null)
2597 || (Bytecodes::Code)(counter & LSB_MASK) == bc) {
2598 // this counter is either free or is already devoted to this BC
2599 bc_counter_addr = counter_addr;
2600 bc_counter = counter | bc;
2601 }
2602 }
2603 }
2604 if (bc_counter_addr == NULL__null) {
2605 // Overflow, or no given bytecode.
2606 bc_counter_addr = &cases[BC_CASE_LIMIT-1];
2607 bc_counter = (*bc_counter_addr & ~LSB_MASK); // clear LSB
2608 }
2609 *bc_counter_addr = bc_counter + (1 << LSB_BITS);
2610}
2611
2612jint Deoptimization::total_deoptimization_count() {
2613 return _deoptimization_hist[Reason_none][0][0];
2614}
2615
2616// Get the deopt count for a specific reason and a specific action. If either
2617// one of 'reason' or 'action' is null, the method returns the sum of all
2618// deoptimizations with the specific 'action' or 'reason' respectively.
2619// If both arguments are null, the method returns the total deopt count.
2620jint Deoptimization::deoptimization_count(const char *reason_str, const char *action_str) {
2621 if (reason_str == NULL__null && action_str == NULL__null) {
2622 return total_deoptimization_count();
2623 }
2624 juint counter = 0;
2625 for (int reason = 0; reason < Reason_LIMIT; reason++) {
2626 if (reason_str == NULL__null || !strcmp(reason_str, trap_reason_name(reason))) {
2627 for (int action = 0; action < Action_LIMIT; action++) {
2628 if (action_str == NULL__null || !strcmp(action_str, trap_action_name(action))) {
2629 juint* cases = _deoptimization_hist[reason][1+action];
2630 for (int bc_case = 0; bc_case < BC_CASE_LIMIT; bc_case++) {
2631 counter += cases[bc_case] >> LSB_BITS;
2632 }
2633 }
2634 }
2635 }
2636 }
2637 return counter;
2638}
2639
2640void Deoptimization::print_statistics() {
2641 juint total = total_deoptimization_count();
2642 juint account = total;
2643 if (total != 0) {
2644 ttyLocker ttyl;
2645 if (xtty != NULL__null) xtty->head("statistics type='deoptimization'");
2646 tty->print_cr("Deoptimization traps recorded:");
2647 #define PRINT_STAT_LINE(name, r) \
2648 tty->print_cr(" %4d (%4.1f%%) %s", (int)(r), ((r) * 100.0) / total, name);
2649 PRINT_STAT_LINE("total", total);
2650 // For each non-zero entry in the histogram, print the reason,
2651 // the action, and (if specifically known) the type of bytecode.
2652 for (int reason = 0; reason < Reason_LIMIT; reason++) {
2653 for (int action = 0; action < Action_LIMIT; action++) {
2654 juint* cases = _deoptimization_hist[reason][1+action];
2655 for (int bc_case = 0; bc_case < BC_CASE_LIMIT; bc_case++) {
2656 juint counter = cases[bc_case];
2657 if (counter != 0) {
2658 char name[1*K];
2659 Bytecodes::Code bc = (Bytecodes::Code)(counter & LSB_MASK);
2660 if (bc_case == BC_CASE_LIMIT && (int)bc == 0)
2661 bc = Bytecodes::_illegal;
2662 sprintf(name, "%s/%s/%s",
2663 trap_reason_name(reason),
2664 trap_action_name(action),
2665 Bytecodes::is_defined(bc)? Bytecodes::name(bc): "other");
2666 juint r = counter >> LSB_BITS;
2667 tty->print_cr(" %40s: " UINT32_FORMAT"%" "u" " (%.1f%%)", name, r, (r * 100.0) / total);
2668 account -= r;
2669 }
2670 }
2671 }
2672 }
2673 if (account != 0) {
2674 PRINT_STAT_LINE("unaccounted", account);
2675 }
2676 #undef PRINT_STAT_LINE
2677 if (xtty != NULL__null) xtty->tail("statistics");
2678 }
2679}
2680
2681#else // COMPILER2_OR_JVMCI
2682
2683
2684// Stubs for C1 only system.
2685bool Deoptimization::trap_state_is_recompiled(int trap_state) {
2686 return false;
2687}
2688
2689const char* Deoptimization::trap_reason_name(int reason) {
2690 return "unknown";
2691}
2692
2693jint Deoptimization::total_deoptimization_count() {
2694 return 0;
2695}
2696
2697jint Deoptimization::deoptimization_count(const char *reason_str, const char *action_str) {
2698 return 0;
2699}
2700
2701void Deoptimization::print_statistics() {
2702 // no output
2703}
2704
2705void
2706Deoptimization::update_method_data_from_interpreter(MethodData* trap_mdo, int trap_bci, int reason) {
2707 // no udpate
2708}
2709
2710int Deoptimization::trap_state_has_reason(int trap_state, int reason) {
2711 return 0;
2712}
2713
2714void Deoptimization::gather_statistics(DeoptReason reason, DeoptAction action,
2715 Bytecodes::Code bc) {
2716 // no update
2717}
2718
2719const char* Deoptimization::format_trap_state(char* buf, size_t buflen,
2720 int trap_state) {
2721 jio_snprintf(buf, buflen, "#%d", trap_state);
2722 return buf;
2723}
2724
2725#endif // COMPILER2_OR_JVMCI