Mercurial > hg > truffle
annotate src/share/vm/runtime/deoptimization.cpp @ 7090:05ce1defa4f9
Common out some parts of UnsafeLoad/Store in UnsafeAccess
author | Gilles Duboscq <duboscq@ssw.jku.at> |
---|---|
date | Thu, 29 Nov 2012 13:24:08 +0100 |
parents | 9ba90252ce08 |
children | a818db37b7be |
rev | line source |
---|---|
0 | 1 /* |
4872
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
4777
diff
changeset
|
2 * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. |
0 | 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 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1255
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1255
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1255
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
1972 | 25 #include "precompiled.hpp" |
26 #include "classfile/systemDictionary.hpp" | |
27 #include "code/debugInfoRec.hpp" | |
28 #include "code/nmethod.hpp" | |
29 #include "code/pcDesc.hpp" | |
30 #include "code/scopeDesc.hpp" | |
31 #include "interpreter/bytecode.hpp" | |
32 #include "interpreter/interpreter.hpp" | |
33 #include "interpreter/oopMapCache.hpp" | |
34 #include "memory/allocation.inline.hpp" | |
35 #include "memory/oopFactory.hpp" | |
36 #include "memory/resourceArea.hpp" | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
37 #include "oops/method.hpp" |
1972 | 38 #include "oops/oop.inline.hpp" |
6948
e522a00b91aa
Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/ after NPG - C++ build works
Doug Simon <doug.simon@oracle.com>
diff
changeset
|
39 #ifdef GRAAL |
e522a00b91aa
Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/ after NPG - C++ build works
Doug Simon <doug.simon@oracle.com>
diff
changeset
|
40 #include "oops/fieldStreams.hpp" |
e522a00b91aa
Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/ after NPG - C++ build works
Doug Simon <doug.simon@oracle.com>
diff
changeset
|
41 #endif |
1972 | 42 #include "prims/jvmtiThreadState.hpp" |
43 #include "runtime/biasedLocking.hpp" | |
44 #include "runtime/compilationPolicy.hpp" | |
45 #include "runtime/deoptimization.hpp" | |
46 #include "runtime/interfaceSupport.hpp" | |
47 #include "runtime/sharedRuntime.hpp" | |
48 #include "runtime/signature.hpp" | |
49 #include "runtime/stubRoutines.hpp" | |
50 #include "runtime/thread.hpp" | |
51 #include "runtime/vframe.hpp" | |
52 #include "runtime/vframeArray.hpp" | |
53 #include "runtime/vframe_hp.hpp" | |
54 #include "utilities/events.hpp" | |
55 #include "utilities/xmlstream.hpp" | |
56 #ifdef TARGET_ARCH_x86 | |
57 # include "vmreg_x86.inline.hpp" | |
58 #endif | |
59 #ifdef TARGET_ARCH_sparc | |
60 # include "vmreg_sparc.inline.hpp" | |
61 #endif | |
62 #ifdef TARGET_ARCH_zero | |
63 # include "vmreg_zero.inline.hpp" | |
64 #endif | |
2192
b92c45f2bc75
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
2177
diff
changeset
|
65 #ifdef TARGET_ARCH_arm |
b92c45f2bc75
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
2177
diff
changeset
|
66 # include "vmreg_arm.inline.hpp" |
b92c45f2bc75
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
2177
diff
changeset
|
67 #endif |
b92c45f2bc75
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
2177
diff
changeset
|
68 #ifdef TARGET_ARCH_ppc |
b92c45f2bc75
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
2177
diff
changeset
|
69 # include "vmreg_ppc.inline.hpp" |
b92c45f2bc75
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
2177
diff
changeset
|
70 #endif |
1972 | 71 #ifdef COMPILER2 |
72 #ifdef TARGET_ARCH_MODEL_x86_32 | |
73 # include "adfiles/ad_x86_32.hpp" | |
74 #endif | |
75 #ifdef TARGET_ARCH_MODEL_x86_64 | |
76 # include "adfiles/ad_x86_64.hpp" | |
77 #endif | |
78 #ifdef TARGET_ARCH_MODEL_sparc | |
79 # include "adfiles/ad_sparc.hpp" | |
80 #endif | |
81 #ifdef TARGET_ARCH_MODEL_zero | |
82 # include "adfiles/ad_zero.hpp" | |
83 #endif | |
2192
b92c45f2bc75
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
2177
diff
changeset
|
84 #ifdef TARGET_ARCH_MODEL_arm |
b92c45f2bc75
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
2177
diff
changeset
|
85 # include "adfiles/ad_arm.hpp" |
b92c45f2bc75
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
2177
diff
changeset
|
86 #endif |
b92c45f2bc75
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
2177
diff
changeset
|
87 #ifdef TARGET_ARCH_MODEL_ppc |
b92c45f2bc75
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
2177
diff
changeset
|
88 # include "adfiles/ad_ppc.hpp" |
b92c45f2bc75
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
2177
diff
changeset
|
89 #endif |
1972 | 90 #endif |
0 | 91 |
5129
51111665eda6
Support for recording a leaf graph id for each deoptimization point in the debug info.
Lukas Stadler <lukas.stadler@jku.at>
parents:
5038
diff
changeset
|
92 #ifdef GRAAL |
51111665eda6
Support for recording a leaf graph id for each deoptimization point in the debug info.
Lukas Stadler <lukas.stadler@jku.at>
parents:
5038
diff
changeset
|
93 #include "graal/graalCompiler.hpp" |
51111665eda6
Support for recording a leaf graph id for each deoptimization point in the debug info.
Lukas Stadler <lukas.stadler@jku.at>
parents:
5038
diff
changeset
|
94 #endif |
51111665eda6
Support for recording a leaf graph id for each deoptimization point in the debug info.
Lukas Stadler <lukas.stadler@jku.at>
parents:
5038
diff
changeset
|
95 |
51111665eda6
Support for recording a leaf graph id for each deoptimization point in the debug info.
Lukas Stadler <lukas.stadler@jku.at>
parents:
5038
diff
changeset
|
96 |
0 | 97 bool DeoptimizationMarker::_is_active = false; |
98 | |
99 Deoptimization::UnrollBlock::UnrollBlock(int size_of_deoptimized_frame, | |
100 int caller_adjustment, | |
3369
3d2ab563047a
7043461: VM crashes in void LinkResolver::runtime_resolve_virtual_method
never
parents:
3346
diff
changeset
|
101 int caller_actual_parameters, |
0 | 102 int number_of_frames, |
103 intptr_t* frame_sizes, | |
104 address* frame_pcs, | |
105 BasicType return_type) { | |
106 _size_of_deoptimized_frame = size_of_deoptimized_frame; | |
107 _caller_adjustment = caller_adjustment; | |
3369
3d2ab563047a
7043461: VM crashes in void LinkResolver::runtime_resolve_virtual_method
never
parents:
3346
diff
changeset
|
108 _caller_actual_parameters = caller_actual_parameters; |
0 | 109 _number_of_frames = number_of_frames; |
110 _frame_sizes = frame_sizes; | |
111 _frame_pcs = frame_pcs; | |
6197 | 112 _register_block = NEW_C_HEAP_ARRAY(intptr_t, RegisterMap::reg_count * 2, mtCompiler); |
0 | 113 _return_type = return_type; |
3931
5432047c7db7
7087445: Improve platform independence of JSR292 shared code
bdelsart
parents:
3369
diff
changeset
|
114 _initial_info = 0; |
0 | 115 // PD (x86 only) |
116 _counter_temp = 0; | |
117 _unpack_kind = 0; | |
118 _sender_sp_temp = 0; | |
119 | |
120 _total_frame_sizes = size_of_frames(); | |
121 } | |
122 | |
123 | |
124 Deoptimization::UnrollBlock::~UnrollBlock() { | |
6197 | 125 FREE_C_HEAP_ARRAY(intptr_t, _frame_sizes, mtCompiler); |
126 FREE_C_HEAP_ARRAY(intptr_t, _frame_pcs, mtCompiler); | |
127 FREE_C_HEAP_ARRAY(intptr_t, _register_block, mtCompiler); | |
0 | 128 } |
129 | |
130 | |
131 intptr_t* Deoptimization::UnrollBlock::value_addr_at(int register_number) const { | |
132 assert(register_number < RegisterMap::reg_count, "checking register number"); | |
133 return &_register_block[register_number * 2]; | |
134 } | |
135 | |
136 | |
137 | |
138 int Deoptimization::UnrollBlock::size_of_frames() const { | |
139 // Acount first for the adjustment of the initial frame | |
140 int result = _caller_adjustment; | |
141 for (int index = 0; index < number_of_frames(); index++) { | |
142 result += frame_sizes()[index]; | |
143 } | |
144 return result; | |
145 } | |
146 | |
147 | |
148 void Deoptimization::UnrollBlock::print() { | |
149 ttyLocker ttyl; | |
150 tty->print_cr("UnrollBlock"); | |
151 tty->print_cr(" size_of_deoptimized_frame = %d", _size_of_deoptimized_frame); | |
152 tty->print( " frame_sizes: "); | |
153 for (int index = 0; index < number_of_frames(); index++) { | |
154 tty->print("%d ", frame_sizes()[index]); | |
155 } | |
156 tty->cr(); | |
157 } | |
158 | |
159 | |
160 // In order to make fetch_unroll_info work properly with escape | |
161 // analysis, The method was changed from JRT_LEAF to JRT_BLOCK_ENTRY and | |
162 // ResetNoHandleMark and HandleMark were removed from it. The actual reallocation | |
163 // of previously eliminated objects occurs in realloc_objects, which is | |
164 // called from the method fetch_unroll_info_helper below. | |
165 JRT_BLOCK_ENTRY(Deoptimization::UnrollBlock*, Deoptimization::fetch_unroll_info(JavaThread* thread)) | |
166 // It is actually ok to allocate handles in a leaf method. It causes no safepoints, | |
167 // but makes the entry a little slower. There is however a little dance we have to | |
168 // do in debug mode to get around the NoHandleMark code in the JRT_LEAF macro | |
169 | |
170 // fetch_unroll_info() is called at the beginning of the deoptimization | |
171 // handler. Note this fact before we start generating temporary frames | |
172 // that can confuse an asynchronous stack walker. This counter is | |
173 // decremented at the end of unpack_frames(). | |
4674
e1c053324210
changed TraceDeoptimization output
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4668
diff
changeset
|
174 if (TraceDeoptimization) { |
5038
1b907994bf2d
fixed deoptimization output
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4978
diff
changeset
|
175 tty->print_cr("Deoptimizing thread " INTPTR_FORMAT, thread); |
4674
e1c053324210
changed TraceDeoptimization output
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4668
diff
changeset
|
176 } |
0 | 177 thread->inc_in_deopt_handler(); |
178 | |
179 return fetch_unroll_info_helper(thread); | |
180 JRT_END | |
181 | |
182 | |
183 // This is factored, since it is both called from a JRT_LEAF (deoptimization) and a JRT_ENTRY (uncommon_trap) | |
184 Deoptimization::UnrollBlock* Deoptimization::fetch_unroll_info_helper(JavaThread* thread) { | |
185 | |
186 // Note: there is a safepoint safety issue here. No matter whether we enter | |
187 // via vanilla deopt or uncommon trap we MUST NOT stop at a safepoint once | |
188 // the vframeArray is created. | |
189 // | |
190 | |
191 // Allocate our special deoptimization ResourceMark | |
192 DeoptResourceMark* dmark = new DeoptResourceMark(thread); | |
193 assert(thread->deopt_mark() == NULL, "Pending deopt!"); | |
194 thread->set_deopt_mark(dmark); | |
195 | |
196 frame stub_frame = thread->last_frame(); // Makes stack walkable as side effect | |
197 RegisterMap map(thread, true); | |
198 RegisterMap dummy_map(thread, false); | |
199 // Now get the deoptee with a valid map | |
200 frame deoptee = stub_frame.sender(&map); | |
1814
fd5d4527cdf5
6986270: guarantee(*bcp != Bytecodes::_monitorenter || exec_mode != Deoptimization::Unpack_exception) fails
iveresov
parents:
1783
diff
changeset
|
201 // Set the deoptee nmethod |
fd5d4527cdf5
6986270: guarantee(*bcp != Bytecodes::_monitorenter || exec_mode != Deoptimization::Unpack_exception) fails
iveresov
parents:
1783
diff
changeset
|
202 assert(thread->deopt_nmethod() == NULL, "Pending deopt!"); |
fd5d4527cdf5
6986270: guarantee(*bcp != Bytecodes::_monitorenter || exec_mode != Deoptimization::Unpack_exception) fails
iveresov
parents:
1783
diff
changeset
|
203 thread->set_deopt_nmethod(deoptee.cb()->as_nmethod_or_null()); |
0 | 204 |
3336
2e038ad0c1d0
7009361: JSR 292 Invalid value on stack on solaris-sparc with -Xcomp
never
parents:
2338
diff
changeset
|
205 if (VerifyStack) { |
2e038ad0c1d0
7009361: JSR 292 Invalid value on stack on solaris-sparc with -Xcomp
never
parents:
2338
diff
changeset
|
206 thread->validate_frame_layout(); |
2e038ad0c1d0
7009361: JSR 292 Invalid value on stack on solaris-sparc with -Xcomp
never
parents:
2338
diff
changeset
|
207 } |
2e038ad0c1d0
7009361: JSR 292 Invalid value on stack on solaris-sparc with -Xcomp
never
parents:
2338
diff
changeset
|
208 |
0 | 209 // Create a growable array of VFrames where each VFrame represents an inlined |
210 // Java frame. This storage is allocated with the usual system arena. | |
211 assert(deoptee.is_compiled_frame(), "Wrong frame type"); | |
5129
51111665eda6
Support for recording a leaf graph id for each deoptimization point in the debug info.
Lukas Stadler <lukas.stadler@jku.at>
parents:
5038
diff
changeset
|
212 |
51111665eda6
Support for recording a leaf graph id for each deoptimization point in the debug info.
Lukas Stadler <lukas.stadler@jku.at>
parents:
5038
diff
changeset
|
213 #ifdef GRAAL |
51111665eda6
Support for recording a leaf graph id for each deoptimization point in the debug info.
Lukas Stadler <lukas.stadler@jku.at>
parents:
5038
diff
changeset
|
214 PcDesc* pc_desc = ((nmethod*) deoptee.cb())->pc_desc_at(deoptee.pc()); |
51111665eda6
Support for recording a leaf graph id for each deoptimization point in the debug info.
Lukas Stadler <lukas.stadler@jku.at>
parents:
5038
diff
changeset
|
215 if (pc_desc != NULL && pc_desc->leaf_graph_id() != -1) { |
51111665eda6
Support for recording a leaf graph id for each deoptimization point in the debug info.
Lukas Stadler <lukas.stadler@jku.at>
parents:
5038
diff
changeset
|
216 GraalCompiler* compiler = (GraalCompiler*) ((nmethod*) deoptee.cb())->compiler(); |
51111665eda6
Support for recording a leaf graph id for each deoptimization point in the debug info.
Lukas Stadler <lukas.stadler@jku.at>
parents:
5038
diff
changeset
|
217 if (PrintDeoptimizationDetails) { |
51111665eda6
Support for recording a leaf graph id for each deoptimization point in the debug info.
Lukas Stadler <lukas.stadler@jku.at>
parents:
5038
diff
changeset
|
218 tty->print_cr("leaf graph id: %d", pc_desc->leaf_graph_id()); |
51111665eda6
Support for recording a leaf graph id for each deoptimization point in the debug info.
Lukas Stadler <lukas.stadler@jku.at>
parents:
5038
diff
changeset
|
219 } |
51111665eda6
Support for recording a leaf graph id for each deoptimization point in the debug info.
Lukas Stadler <lukas.stadler@jku.at>
parents:
5038
diff
changeset
|
220 compiler->deopt_leaf_graph(pc_desc->leaf_graph_id()); |
51111665eda6
Support for recording a leaf graph id for each deoptimization point in the debug info.
Lukas Stadler <lukas.stadler@jku.at>
parents:
5038
diff
changeset
|
221 } |
51111665eda6
Support for recording a leaf graph id for each deoptimization point in the debug info.
Lukas Stadler <lukas.stadler@jku.at>
parents:
5038
diff
changeset
|
222 #endif |
51111665eda6
Support for recording a leaf graph id for each deoptimization point in the debug info.
Lukas Stadler <lukas.stadler@jku.at>
parents:
5038
diff
changeset
|
223 |
0 | 224 GrowableArray<compiledVFrame*>* chunk = new GrowableArray<compiledVFrame*>(10); |
225 vframe* vf = vframe::new_vframe(&deoptee, &map, thread); | |
226 while (!vf->is_top()) { | |
227 assert(vf->is_compiled_frame(), "Wrong frame type"); | |
228 chunk->push(compiledVFrame::cast(vf)); | |
229 vf = vf->sender(); | |
230 } | |
231 assert(vf->is_compiled_frame(), "Wrong frame type"); | |
232 chunk->push(compiledVFrame::cast(vf)); | |
233 | |
4674
e1c053324210
changed TraceDeoptimization output
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4668
diff
changeset
|
234 #if defined(COMPILER2) || defined(GRAAL) |
0 | 235 // Reallocate the non-escaping objects and restore their fields. Then |
236 // relock objects if synchronization on them was eliminated. | |
4674
e1c053324210
changed TraceDeoptimization output
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4668
diff
changeset
|
237 #ifdef COMPILER2 |
4777 | 238 if (DoEscapeAnalysis || EliminateNestedLocks) { |
44
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
239 if (EliminateAllocations) { |
4674
e1c053324210
changed TraceDeoptimization output
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4668
diff
changeset
|
240 #endif // COMPILER2 |
83
d3cd40645d0d
6681646: Relocking of a scalar replaced object during deoptimization is broken
kvn
parents:
44
diff
changeset
|
241 assert (chunk->at(0)->scope() != NULL,"expect only compiled java frames"); |
44
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
242 GrowableArray<ScopeValue*>* objects = chunk->at(0)->scope()->objects(); |
1253
f70b0d9ab095
6910618: C2: Error: assert(d->is_oop(),"JVM_ArrayCopy: dst not an oop")
kvn
parents:
1206
diff
changeset
|
243 |
f70b0d9ab095
6910618: C2: Error: assert(d->is_oop(),"JVM_ArrayCopy: dst not an oop")
kvn
parents:
1206
diff
changeset
|
244 // The flag return_oop() indicates call sites which return oop |
f70b0d9ab095
6910618: C2: Error: assert(d->is_oop(),"JVM_ArrayCopy: dst not an oop")
kvn
parents:
1206
diff
changeset
|
245 // in compiled code. Such sites include java method calls, |
f70b0d9ab095
6910618: C2: Error: assert(d->is_oop(),"JVM_ArrayCopy: dst not an oop")
kvn
parents:
1206
diff
changeset
|
246 // runtime calls (for example, used to allocate new objects/arrays |
f70b0d9ab095
6910618: C2: Error: assert(d->is_oop(),"JVM_ArrayCopy: dst not an oop")
kvn
parents:
1206
diff
changeset
|
247 // on slow code path) and any other calls generated in compiled code. |
f70b0d9ab095
6910618: C2: Error: assert(d->is_oop(),"JVM_ArrayCopy: dst not an oop")
kvn
parents:
1206
diff
changeset
|
248 // It is not guaranteed that we can get such information here only |
f70b0d9ab095
6910618: C2: Error: assert(d->is_oop(),"JVM_ArrayCopy: dst not an oop")
kvn
parents:
1206
diff
changeset
|
249 // by analyzing bytecode in deoptimized frames. This is why this flag |
f70b0d9ab095
6910618: C2: Error: assert(d->is_oop(),"JVM_ArrayCopy: dst not an oop")
kvn
parents:
1206
diff
changeset
|
250 // is set during method compilation (see Compile::Process_OopMap_Node()). |
f70b0d9ab095
6910618: C2: Error: assert(d->is_oop(),"JVM_ArrayCopy: dst not an oop")
kvn
parents:
1206
diff
changeset
|
251 bool save_oop_result = chunk->at(0)->scope()->return_oop(); |
f70b0d9ab095
6910618: C2: Error: assert(d->is_oop(),"JVM_ArrayCopy: dst not an oop")
kvn
parents:
1206
diff
changeset
|
252 Handle return_value; |
f70b0d9ab095
6910618: C2: Error: assert(d->is_oop(),"JVM_ArrayCopy: dst not an oop")
kvn
parents:
1206
diff
changeset
|
253 if (save_oop_result) { |
f70b0d9ab095
6910618: C2: Error: assert(d->is_oop(),"JVM_ArrayCopy: dst not an oop")
kvn
parents:
1206
diff
changeset
|
254 // Reallocation may trigger GC. If deoptimization happened on return from |
f70b0d9ab095
6910618: C2: Error: assert(d->is_oop(),"JVM_ArrayCopy: dst not an oop")
kvn
parents:
1206
diff
changeset
|
255 // call which returns oop we need to save it since it is not in oopmap. |
f70b0d9ab095
6910618: C2: Error: assert(d->is_oop(),"JVM_ArrayCopy: dst not an oop")
kvn
parents:
1206
diff
changeset
|
256 oop result = deoptee.saved_oop_result(&map); |
f70b0d9ab095
6910618: C2: Error: assert(d->is_oop(),"JVM_ArrayCopy: dst not an oop")
kvn
parents:
1206
diff
changeset
|
257 assert(result == NULL || result->is_oop(), "must be oop"); |
f70b0d9ab095
6910618: C2: Error: assert(d->is_oop(),"JVM_ArrayCopy: dst not an oop")
kvn
parents:
1206
diff
changeset
|
258 return_value = Handle(thread, result); |
f70b0d9ab095
6910618: C2: Error: assert(d->is_oop(),"JVM_ArrayCopy: dst not an oop")
kvn
parents:
1206
diff
changeset
|
259 assert(Universe::heap()->is_in_or_null(result), "must be heap pointer"); |
f70b0d9ab095
6910618: C2: Error: assert(d->is_oop(),"JVM_ArrayCopy: dst not an oop")
kvn
parents:
1206
diff
changeset
|
260 if (TraceDeoptimization) { |
6843 | 261 ttyLocker ttyl; |
1253
f70b0d9ab095
6910618: C2: Error: assert(d->is_oop(),"JVM_ArrayCopy: dst not an oop")
kvn
parents:
1206
diff
changeset
|
262 tty->print_cr("SAVED OOP RESULT " INTPTR_FORMAT " in thread " INTPTR_FORMAT, result, thread); |
f70b0d9ab095
6910618: C2: Error: assert(d->is_oop(),"JVM_ArrayCopy: dst not an oop")
kvn
parents:
1206
diff
changeset
|
263 } |
f70b0d9ab095
6910618: C2: Error: assert(d->is_oop(),"JVM_ArrayCopy: dst not an oop")
kvn
parents:
1206
diff
changeset
|
264 } |
44
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
265 bool reallocated = false; |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
266 if (objects != NULL) { |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
267 JRT_BLOCK |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
268 reallocated = realloc_objects(thread, &deoptee, objects, THREAD); |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
269 JRT_END |
0 | 270 } |
44
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
271 if (reallocated) { |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
272 reassign_fields(&deoptee, &map, objects); |
0 | 273 #ifndef PRODUCT |
274 if (TraceDeoptimization) { | |
275 ttyLocker ttyl; | |
44
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
276 tty->print_cr("REALLOC OBJECTS in thread " INTPTR_FORMAT, thread); |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
277 print_objects(objects); |
1253
f70b0d9ab095
6910618: C2: Error: assert(d->is_oop(),"JVM_ArrayCopy: dst not an oop")
kvn
parents:
1206
diff
changeset
|
278 } |
f70b0d9ab095
6910618: C2: Error: assert(d->is_oop(),"JVM_ArrayCopy: dst not an oop")
kvn
parents:
1206
diff
changeset
|
279 #endif |
44
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
280 } |
1253
f70b0d9ab095
6910618: C2: Error: assert(d->is_oop(),"JVM_ArrayCopy: dst not an oop")
kvn
parents:
1206
diff
changeset
|
281 if (save_oop_result) { |
f70b0d9ab095
6910618: C2: Error: assert(d->is_oop(),"JVM_ArrayCopy: dst not an oop")
kvn
parents:
1206
diff
changeset
|
282 // Restore result. |
f70b0d9ab095
6910618: C2: Error: assert(d->is_oop(),"JVM_ArrayCopy: dst not an oop")
kvn
parents:
1206
diff
changeset
|
283 deoptee.set_saved_oop_result(&map, return_value()); |
44
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
284 } |
4674
e1c053324210
changed TraceDeoptimization output
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4668
diff
changeset
|
285 #ifdef COMPILER2 |
44
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
286 } |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
287 if (EliminateLocks) { |
4674
e1c053324210
changed TraceDeoptimization output
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4668
diff
changeset
|
288 #endif // COMPILER2 |
83
d3cd40645d0d
6681646: Relocking of a scalar replaced object during deoptimization is broken
kvn
parents:
44
diff
changeset
|
289 #ifndef PRODUCT |
d3cd40645d0d
6681646: Relocking of a scalar replaced object during deoptimization is broken
kvn
parents:
44
diff
changeset
|
290 bool first = true; |
d3cd40645d0d
6681646: Relocking of a scalar replaced object during deoptimization is broken
kvn
parents:
44
diff
changeset
|
291 #endif |
44
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
292 for (int i = 0; i < chunk->length(); i++) { |
83
d3cd40645d0d
6681646: Relocking of a scalar replaced object during deoptimization is broken
kvn
parents:
44
diff
changeset
|
293 compiledVFrame* cvf = chunk->at(i); |
d3cd40645d0d
6681646: Relocking of a scalar replaced object during deoptimization is broken
kvn
parents:
44
diff
changeset
|
294 assert (cvf->scope() != NULL,"expect only compiled java frames"); |
d3cd40645d0d
6681646: Relocking of a scalar replaced object during deoptimization is broken
kvn
parents:
44
diff
changeset
|
295 GrowableArray<MonitorInfo*>* monitors = cvf->monitors(); |
d3cd40645d0d
6681646: Relocking of a scalar replaced object during deoptimization is broken
kvn
parents:
44
diff
changeset
|
296 if (monitors->is_nonempty()) { |
d3cd40645d0d
6681646: Relocking of a scalar replaced object during deoptimization is broken
kvn
parents:
44
diff
changeset
|
297 relock_objects(monitors, thread); |
44
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
298 #ifndef PRODUCT |
4668
3dbcd1013cc8
added flag PrintDeoptimizationDetails
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4661
diff
changeset
|
299 if (PrintDeoptimizationDetails) { |
44
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
300 ttyLocker ttyl; |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
301 for (int j = 0; j < monitors->length(); j++) { |
83
d3cd40645d0d
6681646: Relocking of a scalar replaced object during deoptimization is broken
kvn
parents:
44
diff
changeset
|
302 MonitorInfo* mi = monitors->at(j); |
d3cd40645d0d
6681646: Relocking of a scalar replaced object during deoptimization is broken
kvn
parents:
44
diff
changeset
|
303 if (mi->eliminated()) { |
d3cd40645d0d
6681646: Relocking of a scalar replaced object during deoptimization is broken
kvn
parents:
44
diff
changeset
|
304 if (first) { |
d3cd40645d0d
6681646: Relocking of a scalar replaced object during deoptimization is broken
kvn
parents:
44
diff
changeset
|
305 first = false; |
d3cd40645d0d
6681646: Relocking of a scalar replaced object during deoptimization is broken
kvn
parents:
44
diff
changeset
|
306 tty->print_cr("RELOCK OBJECTS in thread " INTPTR_FORMAT, thread); |
d3cd40645d0d
6681646: Relocking of a scalar replaced object during deoptimization is broken
kvn
parents:
44
diff
changeset
|
307 } |
d3cd40645d0d
6681646: Relocking of a scalar replaced object during deoptimization is broken
kvn
parents:
44
diff
changeset
|
308 tty->print_cr(" object <" INTPTR_FORMAT "> locked", mi->owner()); |
44
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
309 } |
0 | 310 } |
311 } | |
4674
e1c053324210
changed TraceDeoptimization output
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4668
diff
changeset
|
312 #endif // !PRODUCT |
0 | 313 } |
314 } | |
4674
e1c053324210
changed TraceDeoptimization output
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4668
diff
changeset
|
315 #ifdef COMPILER2 |
0 | 316 } |
317 } | |
318 #endif // COMPILER2 | |
4674
e1c053324210
changed TraceDeoptimization output
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4668
diff
changeset
|
319 #endif // COMPILER2 || GRAAL |
e1c053324210
changed TraceDeoptimization output
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4668
diff
changeset
|
320 |
0 | 321 // Ensure that no safepoint is taken after pointers have been stored |
322 // in fields of rematerialized objects. If a safepoint occurs from here on | |
323 // out the java state residing in the vframeArray will be missed. | |
324 No_Safepoint_Verifier no_safepoint; | |
325 | |
326 vframeArray* array = create_vframeArray(thread, deoptee, &map, chunk); | |
327 | |
328 assert(thread->vframe_array_head() == NULL, "Pending deopt!");; | |
329 thread->set_vframe_array_head(array); | |
330 | |
331 // Now that the vframeArray has been created if we have any deferred local writes | |
332 // added by jvmti then we can free up that structure as the data is now in the | |
333 // vframeArray | |
334 | |
335 if (thread->deferred_locals() != NULL) { | |
336 GrowableArray<jvmtiDeferredLocalVariableSet*>* list = thread->deferred_locals(); | |
337 int i = 0; | |
338 do { | |
339 // Because of inlining we could have multiple vframes for a single frame | |
340 // and several of the vframes could have deferred writes. Find them all. | |
341 if (list->at(i)->id() == array->original().id()) { | |
342 jvmtiDeferredLocalVariableSet* dlv = list->at(i); | |
343 list->remove_at(i); | |
344 // individual jvmtiDeferredLocalVariableSet are CHeapObj's | |
345 delete dlv; | |
346 } else { | |
347 i++; | |
348 } | |
349 } while ( i < list->length() ); | |
350 if (list->length() == 0) { | |
351 thread->set_deferred_locals(NULL); | |
352 // free the list and elements back to C heap. | |
353 delete list; | |
354 } | |
355 | |
356 } | |
357 | |
1692 | 358 #ifndef SHARK |
0 | 359 // Compute the caller frame based on the sender sp of stub_frame and stored frame sizes info. |
360 CodeBlob* cb = stub_frame.cb(); | |
361 // Verify we have the right vframeArray | |
362 assert(cb->frame_size() >= 0, "Unexpected frame size"); | |
363 intptr_t* unpack_sp = stub_frame.sp() + cb->frame_size(); | |
364 | |
1204 | 365 // If the deopt call site is a MethodHandle invoke call site we have |
366 // to adjust the unpack_sp. | |
367 nmethod* deoptee_nm = deoptee.cb()->as_nmethod_or_null(); | |
368 if (deoptee_nm != NULL && deoptee_nm->is_method_handle_return(deoptee.pc())) | |
369 unpack_sp = deoptee.unextended_sp(); | |
370 | |
0 | 371 #ifdef ASSERT |
372 assert(cb->is_deoptimization_stub() || cb->is_uncommon_trap_stub(), "just checking"); | |
373 #endif | |
1692 | 374 #else |
375 intptr_t* unpack_sp = stub_frame.sender(&dummy_map).unextended_sp(); | |
376 #endif // !SHARK | |
377 | |
0 | 378 // This is a guarantee instead of an assert because if vframe doesn't match |
379 // we will unpack the wrong deoptimized frame and wind up in strange places | |
380 // where it will be very difficult to figure out what went wrong. Better | |
381 // to die an early death here than some very obscure death later when the | |
382 // trail is cold. | |
383 // Note: on ia64 this guarantee can be fooled by frames with no memory stack | |
384 // in that it will fail to detect a problem when there is one. This needs | |
385 // more work in tiger timeframe. | |
386 guarantee(array->unextended_sp() == unpack_sp, "vframe_array_head must contain the vframeArray to unpack"); | |
387 | |
388 int number_of_frames = array->frames(); | |
389 | |
390 // Compute the vframes' sizes. Note that frame_sizes[] entries are ordered from outermost to innermost | |
391 // virtual activation, which is the reverse of the elements in the vframes array. | |
6197 | 392 intptr_t* frame_sizes = NEW_C_HEAP_ARRAY(intptr_t, number_of_frames, mtCompiler); |
0 | 393 // +1 because we always have an interpreter return address for the final slot. |
6197 | 394 address* frame_pcs = NEW_C_HEAP_ARRAY(address, number_of_frames + 1, mtCompiler); |
0 | 395 int popframe_extra_args = 0; |
396 // Create an interpreter return address for the stub to use as its return | |
397 // address so the skeletal frames are perfectly walkable | |
398 frame_pcs[number_of_frames] = Interpreter::deopt_entry(vtos, 0); | |
399 | |
400 // PopFrame requires that the preserved incoming arguments from the recently-popped topmost | |
401 // activation be put back on the expression stack of the caller for reexecution | |
402 if (JvmtiExport::can_pop_frame() && thread->popframe_forcing_deopt_reexecution()) { | |
403 popframe_extra_args = in_words(thread->popframe_preserved_args_size_in_words()); | |
404 } | |
405 | |
3369
3d2ab563047a
7043461: VM crashes in void LinkResolver::runtime_resolve_virtual_method
never
parents:
3346
diff
changeset
|
406 // Find the current pc for sender of the deoptee. Since the sender may have been deoptimized |
3d2ab563047a
7043461: VM crashes in void LinkResolver::runtime_resolve_virtual_method
never
parents:
3346
diff
changeset
|
407 // itself since the deoptee vframeArray was created we must get a fresh value of the pc rather |
3d2ab563047a
7043461: VM crashes in void LinkResolver::runtime_resolve_virtual_method
never
parents:
3346
diff
changeset
|
408 // than simply use array->sender.pc(). This requires us to walk the current set of frames |
3d2ab563047a
7043461: VM crashes in void LinkResolver::runtime_resolve_virtual_method
never
parents:
3346
diff
changeset
|
409 // |
3d2ab563047a
7043461: VM crashes in void LinkResolver::runtime_resolve_virtual_method
never
parents:
3346
diff
changeset
|
410 frame deopt_sender = stub_frame.sender(&dummy_map); // First is the deoptee frame |
3d2ab563047a
7043461: VM crashes in void LinkResolver::runtime_resolve_virtual_method
never
parents:
3346
diff
changeset
|
411 deopt_sender = deopt_sender.sender(&dummy_map); // Now deoptee caller |
3d2ab563047a
7043461: VM crashes in void LinkResolver::runtime_resolve_virtual_method
never
parents:
3346
diff
changeset
|
412 |
3d2ab563047a
7043461: VM crashes in void LinkResolver::runtime_resolve_virtual_method
never
parents:
3346
diff
changeset
|
413 // It's possible that the number of paramters at the call site is |
3d2ab563047a
7043461: VM crashes in void LinkResolver::runtime_resolve_virtual_method
never
parents:
3346
diff
changeset
|
414 // different than number of arguments in the callee when method |
3d2ab563047a
7043461: VM crashes in void LinkResolver::runtime_resolve_virtual_method
never
parents:
3346
diff
changeset
|
415 // handles are used. If the caller is interpreted get the real |
3d2ab563047a
7043461: VM crashes in void LinkResolver::runtime_resolve_virtual_method
never
parents:
3346
diff
changeset
|
416 // value so that the proper amount of space can be added to it's |
3d2ab563047a
7043461: VM crashes in void LinkResolver::runtime_resolve_virtual_method
never
parents:
3346
diff
changeset
|
417 // frame. |
4042
b20d64f83668
7090904: JSR 292: JRuby junit test crashes in PSScavengeRootsClosure::do_oop
twisti
parents:
3931
diff
changeset
|
418 bool caller_was_method_handle = false; |
3369
3d2ab563047a
7043461: VM crashes in void LinkResolver::runtime_resolve_virtual_method
never
parents:
3346
diff
changeset
|
419 if (deopt_sender.is_interpreted_frame()) { |
3d2ab563047a
7043461: VM crashes in void LinkResolver::runtime_resolve_virtual_method
never
parents:
3346
diff
changeset
|
420 methodHandle method = deopt_sender.interpreter_frame_method(); |
4055
e342a5110bed
7106774: JSR 292: nightly test inlineMHTarget fails with wrong result
twisti
parents:
4042
diff
changeset
|
421 Bytecode_invoke cur = Bytecode_invoke_check(method, deopt_sender.interpreter_frame_bci()); |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6197
diff
changeset
|
422 if (cur.is_invokedynamic() || cur.is_invokehandle()) { |
4042
b20d64f83668
7090904: JSR 292: JRuby junit test crashes in PSScavengeRootsClosure::do_oop
twisti
parents:
3931
diff
changeset
|
423 // Method handle invokes may involve fairly arbitrary chains of |
b20d64f83668
7090904: JSR 292: JRuby junit test crashes in PSScavengeRootsClosure::do_oop
twisti
parents:
3931
diff
changeset
|
424 // calls so it's impossible to know how much actual space the |
b20d64f83668
7090904: JSR 292: JRuby junit test crashes in PSScavengeRootsClosure::do_oop
twisti
parents:
3931
diff
changeset
|
425 // caller has for locals. |
b20d64f83668
7090904: JSR 292: JRuby junit test crashes in PSScavengeRootsClosure::do_oop
twisti
parents:
3931
diff
changeset
|
426 caller_was_method_handle = true; |
b20d64f83668
7090904: JSR 292: JRuby junit test crashes in PSScavengeRootsClosure::do_oop
twisti
parents:
3931
diff
changeset
|
427 } |
3369
3d2ab563047a
7043461: VM crashes in void LinkResolver::runtime_resolve_virtual_method
never
parents:
3346
diff
changeset
|
428 } |
3d2ab563047a
7043461: VM crashes in void LinkResolver::runtime_resolve_virtual_method
never
parents:
3346
diff
changeset
|
429 |
0 | 430 // |
431 // frame_sizes/frame_pcs[0] oldest frame (int or c2i) | |
432 // frame_sizes/frame_pcs[1] next oldest frame (int) | |
433 // frame_sizes/frame_pcs[n] youngest frame (int) | |
434 // | |
435 // Now a pc in frame_pcs is actually the return address to the frame's caller (a frame | |
436 // owns the space for the return address to it's caller). Confusing ain't it. | |
437 // | |
438 // The vframe array can address vframes with indices running from | |
439 // 0.._frames-1. Index 0 is the youngest frame and _frame - 1 is the oldest (root) frame. | |
440 // When we create the skeletal frames we need the oldest frame to be in the zero slot | |
441 // in the frame_sizes/frame_pcs so the assembly code can do a trivial walk. | |
442 // so things look a little strange in this loop. | |
443 // | |
4042
b20d64f83668
7090904: JSR 292: JRuby junit test crashes in PSScavengeRootsClosure::do_oop
twisti
parents:
3931
diff
changeset
|
444 int callee_parameters = 0; |
b20d64f83668
7090904: JSR 292: JRuby junit test crashes in PSScavengeRootsClosure::do_oop
twisti
parents:
3931
diff
changeset
|
445 int callee_locals = 0; |
0 | 446 for (int index = 0; index < array->frames(); index++ ) { |
447 // frame[number_of_frames - 1 ] = on_stack_size(youngest) | |
448 // frame[number_of_frames - 2 ] = on_stack_size(sender(youngest)) | |
449 // frame[number_of_frames - 3 ] = on_stack_size(sender(sender(youngest))) | |
3369
3d2ab563047a
7043461: VM crashes in void LinkResolver::runtime_resolve_virtual_method
never
parents:
3346
diff
changeset
|
450 int caller_parms = callee_parameters; |
4042
b20d64f83668
7090904: JSR 292: JRuby junit test crashes in PSScavengeRootsClosure::do_oop
twisti
parents:
3931
diff
changeset
|
451 if ((index == array->frames() - 1) && caller_was_method_handle) { |
b20d64f83668
7090904: JSR 292: JRuby junit test crashes in PSScavengeRootsClosure::do_oop
twisti
parents:
3931
diff
changeset
|
452 caller_parms = 0; |
3369
3d2ab563047a
7043461: VM crashes in void LinkResolver::runtime_resolve_virtual_method
never
parents:
3346
diff
changeset
|
453 } |
3d2ab563047a
7043461: VM crashes in void LinkResolver::runtime_resolve_virtual_method
never
parents:
3346
diff
changeset
|
454 frame_sizes[number_of_frames - 1 - index] = BytesPerWord * array->element(index)->on_stack_size(caller_parms, |
3d2ab563047a
7043461: VM crashes in void LinkResolver::runtime_resolve_virtual_method
never
parents:
3346
diff
changeset
|
455 callee_parameters, |
0 | 456 callee_locals, |
457 index == 0, | |
458 popframe_extra_args); | |
459 // This pc doesn't have to be perfect just good enough to identify the frame | |
460 // as interpreted so the skeleton frame will be walkable | |
461 // The correct pc will be set when the skeleton frame is completely filled out | |
462 // The final pc we store in the loop is wrong and will be overwritten below | |
463 frame_pcs[number_of_frames - 1 - index ] = Interpreter::deopt_entry(vtos, 0) - frame::pc_return_offset; | |
464 | |
465 callee_parameters = array->element(index)->method()->size_of_parameters(); | |
466 callee_locals = array->element(index)->method()->max_locals(); | |
467 popframe_extra_args = 0; | |
468 } | |
469 | |
470 // Compute whether the root vframe returns a float or double value. | |
471 BasicType return_type; | |
472 { | |
473 HandleMark hm; | |
474 methodHandle method(thread, array->element(0)->method()); | |
2142 | 475 Bytecode_invoke invoke = Bytecode_invoke_check(method, array->element(0)->bci()); |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2142
diff
changeset
|
476 return_type = invoke.is_valid() ? invoke.result_type() : T_ILLEGAL; |
0 | 477 } |
478 | |
479 // Compute information for handling adapters and adjusting the frame size of the caller. | |
480 int caller_adjustment = 0; | |
481 | |
482 // Compute the amount the oldest interpreter frame will have to adjust | |
483 // its caller's stack by. If the caller is a compiled frame then | |
484 // we pretend that the callee has no parameters so that the | |
485 // extension counts for the full amount of locals and not just | |
486 // locals-parms. This is because without a c2i adapter the parm | |
487 // area as created by the compiled frame will not be usable by | |
488 // the interpreter. (Depending on the calling convention there | |
489 // may not even be enough space). | |
490 | |
491 // QQQ I'd rather see this pushed down into last_frame_adjust | |
492 // and have it take the sender (aka caller). | |
493 | |
4042
b20d64f83668
7090904: JSR 292: JRuby junit test crashes in PSScavengeRootsClosure::do_oop
twisti
parents:
3931
diff
changeset
|
494 if (deopt_sender.is_compiled_frame() || caller_was_method_handle) { |
0 | 495 caller_adjustment = last_frame_adjust(0, callee_locals); |
4042
b20d64f83668
7090904: JSR 292: JRuby junit test crashes in PSScavengeRootsClosure::do_oop
twisti
parents:
3931
diff
changeset
|
496 } else if (callee_locals > callee_parameters) { |
0 | 497 // The caller frame may need extending to accommodate |
498 // non-parameter locals of the first unpacked interpreted frame. | |
499 // Compute that adjustment. | |
4042
b20d64f83668
7090904: JSR 292: JRuby junit test crashes in PSScavengeRootsClosure::do_oop
twisti
parents:
3931
diff
changeset
|
500 caller_adjustment = last_frame_adjust(callee_parameters, callee_locals); |
0 | 501 } |
502 | |
503 // If the sender is deoptimized the we must retrieve the address of the handler | |
504 // since the frame will "magically" show the original pc before the deopt | |
505 // and we'd undo the deopt. | |
506 | |
507 frame_pcs[0] = deopt_sender.raw_pc(); | |
508 | |
1692 | 509 #ifndef SHARK |
0 | 510 assert(CodeCache::find_blob_unsafe(frame_pcs[0]) != NULL, "bad pc"); |
1692 | 511 #endif // SHARK |
0 | 512 |
513 UnrollBlock* info = new UnrollBlock(array->frame_size() * BytesPerWord, | |
514 caller_adjustment * BytesPerWord, | |
4042
b20d64f83668
7090904: JSR 292: JRuby junit test crashes in PSScavengeRootsClosure::do_oop
twisti
parents:
3931
diff
changeset
|
515 caller_was_method_handle ? 0 : callee_parameters, |
0 | 516 number_of_frames, |
517 frame_sizes, | |
518 frame_pcs, | |
519 return_type); | |
3931
5432047c7db7
7087445: Improve platform independence of JSR292 shared code
bdelsart
parents:
3369
diff
changeset
|
520 // On some platforms, we need a way to pass some platform dependent |
5432047c7db7
7087445: Improve platform independence of JSR292 shared code
bdelsart
parents:
3369
diff
changeset
|
521 // information to the unpacking code so the skeletal frames come out |
5432047c7db7
7087445: Improve platform independence of JSR292 shared code
bdelsart
parents:
3369
diff
changeset
|
522 // correct (initial fp value, unextended sp, ...) |
5432047c7db7
7087445: Improve platform independence of JSR292 shared code
bdelsart
parents:
3369
diff
changeset
|
523 info->set_initial_info((intptr_t) array->sender().initial_deoptimization_info()); |
0 | 524 |
525 if (array->frames() > 1) { | |
526 if (VerifyStack && TraceDeoptimization) { | |
6843 | 527 ttyLocker ttyl; |
0 | 528 tty->print_cr("Deoptimizing method containing inlining"); |
529 } | |
530 } | |
531 | |
532 array->set_unroll_block(info); | |
533 return info; | |
534 } | |
535 | |
536 // Called to cleanup deoptimization data structures in normal case | |
537 // after unpacking to stack and when stack overflow error occurs | |
538 void Deoptimization::cleanup_deopt_info(JavaThread *thread, | |
539 vframeArray *array) { | |
540 | |
541 // Get array if coming from exception | |
542 if (array == NULL) { | |
543 array = thread->vframe_array_head(); | |
544 } | |
545 thread->set_vframe_array_head(NULL); | |
546 | |
547 // Free the previous UnrollBlock | |
548 vframeArray* old_array = thread->vframe_array_last(); | |
549 thread->set_vframe_array_last(array); | |
550 | |
551 if (old_array != NULL) { | |
552 UnrollBlock* old_info = old_array->unroll_block(); | |
553 old_array->set_unroll_block(NULL); | |
554 delete old_info; | |
555 delete old_array; | |
556 } | |
557 | |
558 // Deallocate any resource creating in this routine and any ResourceObjs allocated | |
559 // inside the vframeArray (StackValueCollections) | |
560 | |
561 delete thread->deopt_mark(); | |
562 thread->set_deopt_mark(NULL); | |
1814
fd5d4527cdf5
6986270: guarantee(*bcp != Bytecodes::_monitorenter || exec_mode != Deoptimization::Unpack_exception) fails
iveresov
parents:
1783
diff
changeset
|
563 thread->set_deopt_nmethod(NULL); |
0 | 564 |
565 | |
566 if (JvmtiExport::can_pop_frame()) { | |
567 #ifndef CC_INTERP | |
568 // Regardless of whether we entered this routine with the pending | |
569 // popframe condition bit set, we should always clear it now | |
570 thread->clear_popframe_condition(); | |
571 #else | |
572 // C++ interpeter will clear has_pending_popframe when it enters | |
573 // with method_resume. For deopt_resume2 we clear it now. | |
574 if (thread->popframe_forcing_deopt_reexecution()) | |
575 thread->clear_popframe_condition(); | |
576 #endif /* CC_INTERP */ | |
577 } | |
578 | |
579 // unpack_frames() is called at the end of the deoptimization handler | |
580 // and (in C2) at the end of the uncommon trap handler. Note this fact | |
581 // so that an asynchronous stack walker can work again. This counter is | |
582 // incremented at the beginning of fetch_unroll_info() and (in C2) at | |
583 // the beginning of uncommon_trap(). | |
584 thread->dec_in_deopt_handler(); | |
585 } | |
586 | |
587 | |
588 // Return BasicType of value being returned | |
589 JRT_LEAF(BasicType, Deoptimization::unpack_frames(JavaThread* thread, int exec_mode)) | |
590 | |
591 // We are already active int he special DeoptResourceMark any ResourceObj's we | |
592 // allocate will be freed at the end of the routine. | |
593 | |
594 // It is actually ok to allocate handles in a leaf method. It causes no safepoints, | |
595 // but makes the entry a little slower. There is however a little dance we have to | |
596 // do in debug mode to get around the NoHandleMark code in the JRT_LEAF macro | |
597 ResetNoHandleMark rnhm; // No-op in release/product versions | |
598 HandleMark hm; | |
599 | |
600 frame stub_frame = thread->last_frame(); | |
601 | |
602 // Since the frame to unpack is the top frame of this thread, the vframe_array_head | |
603 // must point to the vframeArray for the unpack frame. | |
604 vframeArray* array = thread->vframe_array_head(); | |
605 | |
606 #ifndef PRODUCT | |
607 if (TraceDeoptimization) { | |
6843 | 608 ttyLocker ttyl; |
0 | 609 tty->print_cr("DEOPT UNPACKING thread " INTPTR_FORMAT " vframeArray " INTPTR_FORMAT " mode %d", thread, array, exec_mode); |
610 } | |
611 #endif | |
4872
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
4777
diff
changeset
|
612 Events::log(thread, "DEOPT UNPACKING pc=" INTPTR_FORMAT " sp=" INTPTR_FORMAT " mode %d", |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
4777
diff
changeset
|
613 stub_frame.pc(), stub_frame.sp(), exec_mode); |
0 | 614 |
615 UnrollBlock* info = array->unroll_block(); | |
616 | |
617 // Unpack the interpreter frames and any adapter frame (c2 only) we might create. | |
3369
3d2ab563047a
7043461: VM crashes in void LinkResolver::runtime_resolve_virtual_method
never
parents:
3346
diff
changeset
|
618 array->unpack_to_stack(stub_frame, exec_mode, info->caller_actual_parameters()); |
0 | 619 |
620 BasicType bt = info->return_type(); | |
621 | |
622 // If we have an exception pending, claim that the return type is an oop | |
623 // so the deopt_blob does not overwrite the exception_oop. | |
624 | |
625 if (exec_mode == Unpack_exception) | |
626 bt = T_OBJECT; | |
627 | |
628 // Cleanup thread deopt data | |
629 cleanup_deopt_info(thread, array); | |
630 | |
631 #ifndef PRODUCT | |
632 if (VerifyStack) { | |
633 ResourceMark res_mark; | |
634 | |
3336
2e038ad0c1d0
7009361: JSR 292 Invalid value on stack on solaris-sparc with -Xcomp
never
parents:
2338
diff
changeset
|
635 thread->validate_frame_layout(); |
2e038ad0c1d0
7009361: JSR 292 Invalid value on stack on solaris-sparc with -Xcomp
never
parents:
2338
diff
changeset
|
636 |
0 | 637 // Verify that the just-unpacked frames match the interpreter's |
638 // notions of expression stack and locals | |
639 vframeArray* cur_array = thread->vframe_array_last(); | |
640 RegisterMap rm(thread, false); | |
641 rm.set_include_argument_oops(false); | |
642 bool is_top_frame = true; | |
643 int callee_size_of_parameters = 0; | |
644 int callee_max_locals = 0; | |
645 for (int i = 0; i < cur_array->frames(); i++) { | |
646 vframeArrayElement* el = cur_array->element(i); | |
647 frame* iframe = el->iframe(); | |
648 guarantee(iframe->is_interpreted_frame(), "Wrong frame type"); | |
649 | |
650 // Get the oop map for this bci | |
651 InterpreterOopMap mask; | |
652 int cur_invoke_parameter_size = 0; | |
653 bool try_next_mask = false; | |
654 int next_mask_expression_stack_size = -1; | |
655 int top_frame_expression_stack_adjustment = 0; | |
656 methodHandle mh(thread, iframe->interpreter_frame_method()); | |
657 OopMapCache::compute_one_oop_map(mh, iframe->interpreter_frame_bci(), &mask); | |
658 BytecodeStream str(mh); | |
659 str.set_start(iframe->interpreter_frame_bci()); | |
660 int max_bci = mh->code_size(); | |
661 // Get to the next bytecode if possible | |
662 assert(str.bci() < max_bci, "bci in interpreter frame out of bounds"); | |
663 // Check to see if we can grab the number of outgoing arguments | |
664 // at an uncommon trap for an invoke (where the compiler | |
665 // generates debug info before the invoke has executed) | |
666 Bytecodes::Code cur_code = str.next(); | |
667 if (cur_code == Bytecodes::_invokevirtual || | |
668 cur_code == Bytecodes::_invokespecial || | |
669 cur_code == Bytecodes::_invokestatic || | |
670 cur_code == Bytecodes::_invokeinterface) { | |
2142 | 671 Bytecode_invoke invoke(mh, iframe->interpreter_frame_bci()); |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2142
diff
changeset
|
672 Symbol* signature = invoke.signature(); |
0 | 673 ArgumentSizeComputer asc(signature); |
674 cur_invoke_parameter_size = asc.size(); | |
675 if (cur_code != Bytecodes::_invokestatic) { | |
676 // Add in receiver | |
677 ++cur_invoke_parameter_size; | |
678 } | |
679 } | |
680 if (str.bci() < max_bci) { | |
681 Bytecodes::Code bc = str.next(); | |
682 if (bc >= 0) { | |
683 // The interpreter oop map generator reports results before | |
684 // the current bytecode has executed except in the case of | |
685 // calls. It seems to be hard to tell whether the compiler | |
686 // has emitted debug information matching the "state before" | |
687 // a given bytecode or the state after, so we try both | |
688 switch (cur_code) { | |
689 case Bytecodes::_invokevirtual: | |
690 case Bytecodes::_invokespecial: | |
691 case Bytecodes::_invokestatic: | |
692 case Bytecodes::_invokeinterface: | |
693 case Bytecodes::_athrow: | |
694 break; | |
695 default: { | |
696 InterpreterOopMap next_mask; | |
697 OopMapCache::compute_one_oop_map(mh, str.bci(), &next_mask); | |
698 next_mask_expression_stack_size = next_mask.expression_stack_size(); | |
699 // Need to subtract off the size of the result type of | |
700 // the bytecode because this is not described in the | |
701 // debug info but returned to the interpreter in the TOS | |
702 // caching register | |
703 BasicType bytecode_result_type = Bytecodes::result_type(cur_code); | |
704 if (bytecode_result_type != T_ILLEGAL) { | |
705 top_frame_expression_stack_adjustment = type2size[bytecode_result_type]; | |
706 } | |
707 assert(top_frame_expression_stack_adjustment >= 0, ""); | |
708 try_next_mask = true; | |
709 break; | |
710 } | |
711 } | |
712 } | |
713 } | |
714 | |
715 // Verify stack depth and oops in frame | |
716 // This assertion may be dependent on the platform we're running on and may need modification (tested on x86 and sparc) | |
717 if (!( | |
718 /* SPARC */ | |
719 (iframe->interpreter_frame_expression_stack_size() == mask.expression_stack_size() + callee_size_of_parameters) || | |
720 /* x86 */ | |
721 (iframe->interpreter_frame_expression_stack_size() == mask.expression_stack_size() + callee_max_locals) || | |
722 (try_next_mask && | |
723 (iframe->interpreter_frame_expression_stack_size() == (next_mask_expression_stack_size - | |
724 top_frame_expression_stack_adjustment))) || | |
725 (is_top_frame && (exec_mode == Unpack_exception) && iframe->interpreter_frame_expression_stack_size() == 0) || | |
726 (is_top_frame && (exec_mode == Unpack_uncommon_trap || exec_mode == Unpack_reexecute) && | |
727 (iframe->interpreter_frame_expression_stack_size() == mask.expression_stack_size() + cur_invoke_parameter_size)) | |
728 )) { | |
729 ttyLocker ttyl; | |
730 | |
731 // Print out some information that will help us debug the problem | |
732 tty->print_cr("Wrong number of expression stack elements during deoptimization"); | |
733 tty->print_cr(" Error occurred while verifying frame %d (0..%d, 0 is topmost)", i, cur_array->frames() - 1); | |
734 tty->print_cr(" Fabricated interpreter frame had %d expression stack elements", | |
735 iframe->interpreter_frame_expression_stack_size()); | |
736 tty->print_cr(" Interpreter oop map had %d expression stack elements", mask.expression_stack_size()); | |
737 tty->print_cr(" try_next_mask = %d", try_next_mask); | |
738 tty->print_cr(" next_mask_expression_stack_size = %d", next_mask_expression_stack_size); | |
739 tty->print_cr(" callee_size_of_parameters = %d", callee_size_of_parameters); | |
740 tty->print_cr(" callee_max_locals = %d", callee_max_locals); | |
741 tty->print_cr(" top_frame_expression_stack_adjustment = %d", top_frame_expression_stack_adjustment); | |
742 tty->print_cr(" exec_mode = %d", exec_mode); | |
743 tty->print_cr(" cur_invoke_parameter_size = %d", cur_invoke_parameter_size); | |
744 tty->print_cr(" Thread = " INTPTR_FORMAT ", thread ID = " UINTX_FORMAT, thread, thread->osthread()->thread_id()); | |
745 tty->print_cr(" Interpreted frames:"); | |
746 for (int k = 0; k < cur_array->frames(); k++) { | |
747 vframeArrayElement* el = cur_array->element(k); | |
748 tty->print_cr(" %s (bci %d)", el->method()->name_and_sig_as_C_string(), el->bci()); | |
749 } | |
750 cur_array->print_on_2(tty); | |
751 guarantee(false, "wrong number of expression stack elements during deopt"); | |
752 } | |
753 VerifyOopClosure verify; | |
754 iframe->oops_interpreted_do(&verify, &rm, false); | |
755 callee_size_of_parameters = mh->size_of_parameters(); | |
756 callee_max_locals = mh->max_locals(); | |
757 is_top_frame = false; | |
758 } | |
759 } | |
760 #endif /* !PRODUCT */ | |
761 | |
762 | |
763 return bt; | |
764 JRT_END | |
765 | |
766 | |
767 int Deoptimization::deoptimize_dependents() { | |
768 Threads::deoptimized_wrt_marked_nmethods(); | |
769 return 0; | |
770 } | |
771 | |
772 | |
4978
99d3d8a72252
More ifdef GRAAL usage.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4970
diff
changeset
|
773 #if defined(COMPILER2) || defined(GRAAL) |
0 | 774 bool Deoptimization::realloc_objects(JavaThread* thread, frame* fr, GrowableArray<ScopeValue*>* objects, TRAPS) { |
775 Handle pending_exception(thread->pending_exception()); | |
776 const char* exception_file = thread->exception_file(); | |
777 int exception_line = thread->exception_line(); | |
778 thread->clear_pending_exception(); | |
779 | |
780 for (int i = 0; i < objects->length(); i++) { | |
781 assert(objects->at(i)->is_object(), "invalid debug information"); | |
782 ObjectValue* sv = (ObjectValue*) objects->at(i); | |
783 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
784 KlassHandle k(java_lang_Class::as_Klass(sv->klass()->as_ConstantOopReadValue()->value()())); |
0 | 785 oop obj = NULL; |
786 | |
787 if (k->oop_is_instance()) { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
788 InstanceKlass* ik = InstanceKlass::cast(k()); |
0 | 789 obj = ik->allocate_instance(CHECK_(false)); |
790 } else if (k->oop_is_typeArray()) { | |
6831
d8ce2825b193
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
6725
diff
changeset
|
791 TypeArrayKlass* ak = TypeArrayKlass::cast(k()); |
0 | 792 assert(sv->field_size() % type2size[ak->element_type()] == 0, "non-integral array length"); |
793 int len = sv->field_size() / type2size[ak->element_type()]; | |
794 obj = ak->allocate(len, CHECK_(false)); | |
795 } else if (k->oop_is_objArray()) { | |
6831
d8ce2825b193
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
6725
diff
changeset
|
796 ObjArrayKlass* ak = ObjArrayKlass::cast(k()); |
0 | 797 obj = ak->allocate(sv->field_size(), CHECK_(false)); |
798 } | |
799 | |
800 assert(obj != NULL, "allocation failed"); | |
801 assert(sv->value().is_null(), "redundant reallocation"); | |
802 sv->set_value(obj); | |
803 } | |
804 | |
805 if (pending_exception.not_null()) { | |
806 thread->set_pending_exception(pending_exception(), exception_file, exception_line); | |
807 } | |
808 | |
809 return true; | |
810 } | |
811 | |
812 // This assumes that the fields are stored in ObjectValue in the same order | |
813 // they are yielded by do_nonstatic_fields. | |
814 class FieldReassigner: public FieldClosure { | |
815 frame* _fr; | |
816 RegisterMap* _reg_map; | |
817 ObjectValue* _sv; | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
818 InstanceKlass* _ik; |
0 | 819 oop _obj; |
820 | |
821 int _i; | |
822 public: | |
823 FieldReassigner(frame* fr, RegisterMap* reg_map, ObjectValue* sv, oop obj) : | |
824 _fr(fr), _reg_map(reg_map), _sv(sv), _obj(obj), _i(0) {} | |
825 | |
826 int i() const { return _i; } | |
827 | |
828 | |
829 void do_field(fieldDescriptor* fd) { | |
44
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
830 intptr_t val; |
0 | 831 StackValue* value = |
832 StackValue::create_stack_value(_fr, _reg_map, _sv->field_at(i())); | |
833 int offset = fd->offset(); | |
834 switch (fd->field_type()) { | |
835 case T_OBJECT: case T_ARRAY: | |
836 assert(value->type() == T_OBJECT, "Agreement."); | |
837 _obj->obj_field_put(offset, value->get_obj()()); | |
838 break; | |
839 | |
840 case T_LONG: case T_DOUBLE: { | |
841 assert(value->type() == T_INT, "Agreement."); | |
842 StackValue* low = | |
843 StackValue::create_stack_value(_fr, _reg_map, _sv->field_at(++_i)); | |
44
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
844 #ifdef _LP64 |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
845 jlong res = (jlong)low->get_int(); |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
846 #else |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
847 #ifdef SPARC |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
848 // For SPARC we have to swap high and low words. |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
849 jlong res = jlong_from((jint)low->get_int(), (jint)value->get_int()); |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
850 #else |
0 | 851 jlong res = jlong_from((jint)value->get_int(), (jint)low->get_int()); |
44
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
852 #endif //SPARC |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
853 #endif |
0 | 854 _obj->long_field_put(offset, res); |
855 break; | |
856 } | |
44
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
857 // Have to cast to INT (32 bits) pointer to avoid little/big-endian problem. |
0 | 858 case T_INT: case T_FLOAT: // 4 bytes. |
859 assert(value->type() == T_INT, "Agreement."); | |
44
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
860 val = value->get_int(); |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
861 _obj->int_field_put(offset, (jint)*((jint*)&val)); |
0 | 862 break; |
863 | |
864 case T_SHORT: case T_CHAR: // 2 bytes | |
865 assert(value->type() == T_INT, "Agreement."); | |
44
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
866 val = value->get_int(); |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
867 _obj->short_field_put(offset, (jshort)*((jint*)&val)); |
0 | 868 break; |
869 | |
44
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
870 case T_BOOLEAN: case T_BYTE: // 1 byte |
0 | 871 assert(value->type() == T_INT, "Agreement."); |
44
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
872 val = value->get_int(); |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
873 _obj->bool_field_put(offset, (jboolean)*((jint*)&val)); |
0 | 874 break; |
875 | |
876 default: | |
877 ShouldNotReachHere(); | |
878 } | |
879 _i++; | |
880 } | |
881 }; | |
882 | |
883 // restore elements of an eliminated type array | |
884 void Deoptimization::reassign_type_array_elements(frame* fr, RegisterMap* reg_map, ObjectValue* sv, typeArrayOop obj, BasicType type) { | |
885 int index = 0; | |
44
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
886 intptr_t val; |
0 | 887 |
888 for (int i = 0; i < sv->field_size(); i++) { | |
889 StackValue* value = StackValue::create_stack_value(fr, reg_map, sv->field_at(i)); | |
890 switch(type) { | |
44
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
891 case T_LONG: case T_DOUBLE: { |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
892 assert(value->type() == T_INT, "Agreement."); |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
893 StackValue* low = |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
894 StackValue::create_stack_value(fr, reg_map, sv->field_at(++i)); |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
895 #ifdef _LP64 |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
896 jlong res = (jlong)low->get_int(); |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
897 #else |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
898 #ifdef SPARC |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
899 // For SPARC we have to swap high and low words. |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
900 jlong res = jlong_from((jint)low->get_int(), (jint)value->get_int()); |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
901 #else |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
902 jlong res = jlong_from((jint)value->get_int(), (jint)low->get_int()); |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
903 #endif //SPARC |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
904 #endif |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
905 obj->long_at_put(index, res); |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
906 break; |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
907 } |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
908 |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
909 // Have to cast to INT (32 bits) pointer to avoid little/big-endian problem. |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
910 case T_INT: case T_FLOAT: // 4 bytes. |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
911 assert(value->type() == T_INT, "Agreement."); |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
912 val = value->get_int(); |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
913 obj->int_at_put(index, (jint)*((jint*)&val)); |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
914 break; |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
915 |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
916 case T_SHORT: case T_CHAR: // 2 bytes |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
917 assert(value->type() == T_INT, "Agreement."); |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
918 val = value->get_int(); |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
919 obj->short_at_put(index, (jshort)*((jint*)&val)); |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
920 break; |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
921 |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
922 case T_BOOLEAN: case T_BYTE: // 1 byte |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
923 assert(value->type() == T_INT, "Agreement."); |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
924 val = value->get_int(); |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
925 obj->bool_at_put(index, (jboolean)*((jint*)&val)); |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
926 break; |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
927 |
0 | 928 default: |
929 ShouldNotReachHere(); | |
930 } | |
931 index++; | |
932 } | |
933 } | |
934 | |
935 | |
936 // restore fields of an eliminated object array | |
937 void Deoptimization::reassign_object_array_elements(frame* fr, RegisterMap* reg_map, ObjectValue* sv, objArrayOop obj) { | |
938 for (int i = 0; i < sv->field_size(); i++) { | |
939 StackValue* value = StackValue::create_stack_value(fr, reg_map, sv->field_at(i)); | |
940 assert(value->type() == T_OBJECT, "object element expected"); | |
941 obj->obj_at_put(i, value->get_obj()()); | |
942 } | |
943 } | |
944 | |
6948
e522a00b91aa
Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/ after NPG - C++ build works
Doug Simon <doug.simon@oracle.com>
diff
changeset
|
945 #ifdef GRAAL |
e522a00b91aa
Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/ after NPG - C++ build works
Doug Simon <doug.simon@oracle.com>
diff
changeset
|
946 // Restore fields of an eliminated instance object using the same field order |
7084
9ba90252ce08
HotSpotResolvedJavaType is now the HotSpot implementation of ResolvedJavaType,
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
6948
diff
changeset
|
947 // returned by HotSpotResolvedObjectType.getInstanceFields(true) |
6948
e522a00b91aa
Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/ after NPG - C++ build works
Doug Simon <doug.simon@oracle.com>
diff
changeset
|
948 static int reassign_fields_by_klass(InstanceKlass* klass, frame* fr, RegisterMap* reg_map, ObjectValue* sv, int svIndex, oop obj) { |
e522a00b91aa
Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/ after NPG - C++ build works
Doug Simon <doug.simon@oracle.com>
diff
changeset
|
949 if (klass->superklass() != NULL) { |
e522a00b91aa
Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/ after NPG - C++ build works
Doug Simon <doug.simon@oracle.com>
diff
changeset
|
950 svIndex = reassign_fields_by_klass(klass->superklass(), fr, reg_map, sv, svIndex, obj); |
e522a00b91aa
Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/ after NPG - C++ build works
Doug Simon <doug.simon@oracle.com>
diff
changeset
|
951 } |
e522a00b91aa
Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/ after NPG - C++ build works
Doug Simon <doug.simon@oracle.com>
diff
changeset
|
952 |
e522a00b91aa
Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/ after NPG - C++ build works
Doug Simon <doug.simon@oracle.com>
diff
changeset
|
953 for (AllFieldStream fs(klass); !fs.done(); fs.next()) { |
e522a00b91aa
Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/ after NPG - C++ build works
Doug Simon <doug.simon@oracle.com>
diff
changeset
|
954 if (fs.access_flags().is_static()) { |
e522a00b91aa
Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/ after NPG - C++ build works
Doug Simon <doug.simon@oracle.com>
diff
changeset
|
955 continue; |
e522a00b91aa
Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/ after NPG - C++ build works
Doug Simon <doug.simon@oracle.com>
diff
changeset
|
956 } |
e522a00b91aa
Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/ after NPG - C++ build works
Doug Simon <doug.simon@oracle.com>
diff
changeset
|
957 intptr_t val; |
e522a00b91aa
Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/ after NPG - C++ build works
Doug Simon <doug.simon@oracle.com>
diff
changeset
|
958 StackValue* value = StackValue::create_stack_value(fr, reg_map, sv->field_at(svIndex)); |
e522a00b91aa
Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/ after NPG - C++ build works
Doug Simon <doug.simon@oracle.com>
diff
changeset
|
959 int offset = fs.offset(); |
e522a00b91aa
Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/ after NPG - C++ build works
Doug Simon <doug.simon@oracle.com>
diff
changeset
|
960 BasicType type = FieldType::basic_type(fs.signature()); |
e522a00b91aa
Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/ after NPG - C++ build works
Doug Simon <doug.simon@oracle.com>
diff
changeset
|
961 switch (type) { |
e522a00b91aa
Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/ after NPG - C++ build works
Doug Simon <doug.simon@oracle.com>
diff
changeset
|
962 case T_OBJECT: case T_ARRAY: |
e522a00b91aa
Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/ after NPG - C++ build works
Doug Simon <doug.simon@oracle.com>
diff
changeset
|
963 assert(value->type() == T_OBJECT, "Agreement."); |
e522a00b91aa
Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/ after NPG - C++ build works
Doug Simon <doug.simon@oracle.com>
diff
changeset
|
964 obj->obj_field_put(offset, value->get_obj()()); |
e522a00b91aa
Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/ after NPG - C++ build works
Doug Simon <doug.simon@oracle.com>
diff
changeset
|
965 break; |
e522a00b91aa
Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/ after NPG - C++ build works
Doug Simon <doug.simon@oracle.com>
diff
changeset
|
966 |
e522a00b91aa
Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/ after NPG - C++ build works
Doug Simon <doug.simon@oracle.com>
diff
changeset
|
967 case T_LONG: case T_DOUBLE: { |
e522a00b91aa
Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/ after NPG - C++ build works
Doug Simon <doug.simon@oracle.com>
diff
changeset
|
968 assert(value->type() == T_INT, "Agreement."); |
e522a00b91aa
Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/ after NPG - C++ build works
Doug Simon <doug.simon@oracle.com>
diff
changeset
|
969 StackValue* low = StackValue::create_stack_value(fr, reg_map, sv->field_at(++svIndex)); |
e522a00b91aa
Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/ after NPG - C++ build works
Doug Simon <doug.simon@oracle.com>
diff
changeset
|
970 #ifdef _LP64 |
e522a00b91aa
Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/ after NPG - C++ build works
Doug Simon <doug.simon@oracle.com>
diff
changeset
|
971 jlong res = (jlong)low->get_int(); |
e522a00b91aa
Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/ after NPG - C++ build works
Doug Simon <doug.simon@oracle.com>
diff
changeset
|
972 #else |
e522a00b91aa
Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/ after NPG - C++ build works
Doug Simon <doug.simon@oracle.com>
diff
changeset
|
973 #ifdef SPARC |
e522a00b91aa
Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/ after NPG - C++ build works
Doug Simon <doug.simon@oracle.com>
diff
changeset
|
974 // For SPARC we have to swap high and low words. |
e522a00b91aa
Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/ after NPG - C++ build works
Doug Simon <doug.simon@oracle.com>
diff
changeset
|
975 jlong res = jlong_from((jint)low->get_int(), (jint)value->get_int()); |
e522a00b91aa
Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/ after NPG - C++ build works
Doug Simon <doug.simon@oracle.com>
diff
changeset
|
976 #else |
e522a00b91aa
Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/ after NPG - C++ build works
Doug Simon <doug.simon@oracle.com>
diff
changeset
|
977 jlong res = jlong_from((jint)value->get_int(), (jint)low->get_int()); |
e522a00b91aa
Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/ after NPG - C++ build works
Doug Simon <doug.simon@oracle.com>
diff
changeset
|
978 #endif //SPARC |
e522a00b91aa
Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/ after NPG - C++ build works
Doug Simon <doug.simon@oracle.com>
diff
changeset
|
979 #endif |
e522a00b91aa
Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/ after NPG - C++ build works
Doug Simon <doug.simon@oracle.com>
diff
changeset
|
980 obj->long_field_put(offset, res); |
e522a00b91aa
Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/ after NPG - C++ build works
Doug Simon <doug.simon@oracle.com>
diff
changeset
|
981 break; |
e522a00b91aa
Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/ after NPG - C++ build works
Doug Simon <doug.simon@oracle.com>
diff
changeset
|
982 } |
e522a00b91aa
Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/ after NPG - C++ build works
Doug Simon <doug.simon@oracle.com>
diff
changeset
|
983 // Have to cast to INT (32 bits) pointer to avoid little/big-endian problem. |
e522a00b91aa
Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/ after NPG - C++ build works
Doug Simon <doug.simon@oracle.com>
diff
changeset
|
984 case T_INT: case T_FLOAT: // 4 bytes. |
e522a00b91aa
Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/ after NPG - C++ build works
Doug Simon <doug.simon@oracle.com>
diff
changeset
|
985 assert(value->type() == T_INT, "Agreement."); |
e522a00b91aa
Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/ after NPG - C++ build works
Doug Simon <doug.simon@oracle.com>
diff
changeset
|
986 val = value->get_int(); |
e522a00b91aa
Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/ after NPG - C++ build works
Doug Simon <doug.simon@oracle.com>
diff
changeset
|
987 obj->int_field_put(offset, (jint)*((jint*)&val)); |
e522a00b91aa
Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/ after NPG - C++ build works
Doug Simon <doug.simon@oracle.com>
diff
changeset
|
988 break; |
e522a00b91aa
Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/ after NPG - C++ build works
Doug Simon <doug.simon@oracle.com>
diff
changeset
|
989 |
e522a00b91aa
Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/ after NPG - C++ build works
Doug Simon <doug.simon@oracle.com>
diff
changeset
|
990 case T_SHORT: case T_CHAR: // 2 bytes |
e522a00b91aa
Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/ after NPG - C++ build works
Doug Simon <doug.simon@oracle.com>
diff
changeset
|
991 assert(value->type() == T_INT, "Agreement."); |
e522a00b91aa
Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/ after NPG - C++ build works
Doug Simon <doug.simon@oracle.com>
diff
changeset
|
992 val = value->get_int(); |
e522a00b91aa
Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/ after NPG - C++ build works
Doug Simon <doug.simon@oracle.com>
diff
changeset
|
993 obj->short_field_put(offset, (jshort)*((jint*)&val)); |
e522a00b91aa
Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/ after NPG - C++ build works
Doug Simon <doug.simon@oracle.com>
diff
changeset
|
994 break; |
e522a00b91aa
Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/ after NPG - C++ build works
Doug Simon <doug.simon@oracle.com>
diff
changeset
|
995 |
e522a00b91aa
Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/ after NPG - C++ build works
Doug Simon <doug.simon@oracle.com>
diff
changeset
|
996 case T_BOOLEAN: case T_BYTE: // 1 byte |
e522a00b91aa
Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/ after NPG - C++ build works
Doug Simon <doug.simon@oracle.com>
diff
changeset
|
997 assert(value->type() == T_INT, "Agreement."); |
e522a00b91aa
Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/ after NPG - C++ build works
Doug Simon <doug.simon@oracle.com>
diff
changeset
|
998 val = value->get_int(); |
e522a00b91aa
Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/ after NPG - C++ build works
Doug Simon <doug.simon@oracle.com>
diff
changeset
|
999 obj->bool_field_put(offset, (jboolean)*((jint*)&val)); |
e522a00b91aa
Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/ after NPG - C++ build works
Doug Simon <doug.simon@oracle.com>
diff
changeset
|
1000 break; |
e522a00b91aa
Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/ after NPG - C++ build works
Doug Simon <doug.simon@oracle.com>
diff
changeset
|
1001 |
e522a00b91aa
Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/ after NPG - C++ build works
Doug Simon <doug.simon@oracle.com>
diff
changeset
|
1002 default: |
e522a00b91aa
Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/ after NPG - C++ build works
Doug Simon <doug.simon@oracle.com>
diff
changeset
|
1003 ShouldNotReachHere(); |
e522a00b91aa
Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/ after NPG - C++ build works
Doug Simon <doug.simon@oracle.com>
diff
changeset
|
1004 } |
e522a00b91aa
Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/ after NPG - C++ build works
Doug Simon <doug.simon@oracle.com>
diff
changeset
|
1005 svIndex++; |
e522a00b91aa
Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/ after NPG - C++ build works
Doug Simon <doug.simon@oracle.com>
diff
changeset
|
1006 } |
e522a00b91aa
Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/ after NPG - C++ build works
Doug Simon <doug.simon@oracle.com>
diff
changeset
|
1007 return svIndex; |
e522a00b91aa
Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/ after NPG - C++ build works
Doug Simon <doug.simon@oracle.com>
diff
changeset
|
1008 } |
e522a00b91aa
Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/ after NPG - C++ build works
Doug Simon <doug.simon@oracle.com>
diff
changeset
|
1009 #endif |
e522a00b91aa
Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/ after NPG - C++ build works
Doug Simon <doug.simon@oracle.com>
diff
changeset
|
1010 |
0 | 1011 |
1012 // restore fields of all eliminated objects and arrays | |
1013 void Deoptimization::reassign_fields(frame* fr, RegisterMap* reg_map, GrowableArray<ScopeValue*>* objects) { | |
1014 for (int i = 0; i < objects->length(); i++) { | |
1015 ObjectValue* sv = (ObjectValue*) objects->at(i); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
1016 KlassHandle k(java_lang_Class::as_Klass(sv->klass()->as_ConstantOopReadValue()->value()())); |
0 | 1017 Handle obj = sv->value(); |
1018 assert(obj.not_null(), "reallocation was missed"); | |
4668
3dbcd1013cc8
added flag PrintDeoptimizationDetails
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4661
diff
changeset
|
1019 if (PrintDeoptimizationDetails) { |
3134
4b63eb1197ca
Various fixes around escape analysis.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
3090
diff
changeset
|
1020 tty->print_cr("reassign fields for object of type %s!", k->name()->as_C_string()); |
4b63eb1197ca
Various fixes around escape analysis.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
3090
diff
changeset
|
1021 } |
0 | 1022 |
1023 if (k->oop_is_instance()) { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
1024 InstanceKlass* ik = InstanceKlass::cast(k()); |
6948
e522a00b91aa
Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/ after NPG - C++ build works
Doug Simon <doug.simon@oracle.com>
diff
changeset
|
1025 #ifndef GRAAL |
0 | 1026 FieldReassigner reassign(fr, reg_map, sv, obj()); |
1027 ik->do_nonstatic_fields(&reassign); | |
6948
e522a00b91aa
Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/ after NPG - C++ build works
Doug Simon <doug.simon@oracle.com>
diff
changeset
|
1028 #else |
e522a00b91aa
Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/ after NPG - C++ build works
Doug Simon <doug.simon@oracle.com>
diff
changeset
|
1029 reassign_fields_by_klass(ik, fr, reg_map, sv, 0, obj()); |
e522a00b91aa
Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/ after NPG - C++ build works
Doug Simon <doug.simon@oracle.com>
diff
changeset
|
1030 #endif |
0 | 1031 } else if (k->oop_is_typeArray()) { |
6831
d8ce2825b193
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
6725
diff
changeset
|
1032 TypeArrayKlass* ak = TypeArrayKlass::cast(k()); |
0 | 1033 reassign_type_array_elements(fr, reg_map, sv, (typeArrayOop) obj(), ak->element_type()); |
1034 } else if (k->oop_is_objArray()) { | |
1035 reassign_object_array_elements(fr, reg_map, sv, (objArrayOop) obj()); | |
1036 } | |
1037 } | |
1038 } | |
1039 | |
1040 | |
1041 // relock objects for which synchronization was eliminated | |
83
d3cd40645d0d
6681646: Relocking of a scalar replaced object during deoptimization is broken
kvn
parents:
44
diff
changeset
|
1042 void Deoptimization::relock_objects(GrowableArray<MonitorInfo*>* monitors, JavaThread* thread) { |
0 | 1043 for (int i = 0; i < monitors->length(); i++) { |
83
d3cd40645d0d
6681646: Relocking of a scalar replaced object during deoptimization is broken
kvn
parents:
44
diff
changeset
|
1044 MonitorInfo* mon_info = monitors->at(i); |
d3cd40645d0d
6681646: Relocking of a scalar replaced object during deoptimization is broken
kvn
parents:
44
diff
changeset
|
1045 if (mon_info->eliminated()) { |
d3cd40645d0d
6681646: Relocking of a scalar replaced object during deoptimization is broken
kvn
parents:
44
diff
changeset
|
1046 assert(mon_info->owner() != NULL, "reallocation was missed"); |
d3cd40645d0d
6681646: Relocking of a scalar replaced object during deoptimization is broken
kvn
parents:
44
diff
changeset
|
1047 Handle obj = Handle(mon_info->owner()); |
d3cd40645d0d
6681646: Relocking of a scalar replaced object during deoptimization is broken
kvn
parents:
44
diff
changeset
|
1048 markOop mark = obj->mark(); |
d3cd40645d0d
6681646: Relocking of a scalar replaced object during deoptimization is broken
kvn
parents:
44
diff
changeset
|
1049 if (UseBiasedLocking && mark->has_bias_pattern()) { |
d3cd40645d0d
6681646: Relocking of a scalar replaced object during deoptimization is broken
kvn
parents:
44
diff
changeset
|
1050 // New allocated objects may have the mark set to anonymously biased. |
d3cd40645d0d
6681646: Relocking of a scalar replaced object during deoptimization is broken
kvn
parents:
44
diff
changeset
|
1051 // Also the deoptimized method may called methods with synchronization |
d3cd40645d0d
6681646: Relocking of a scalar replaced object during deoptimization is broken
kvn
parents:
44
diff
changeset
|
1052 // where the thread-local object is bias locked to the current thread. |
d3cd40645d0d
6681646: Relocking of a scalar replaced object during deoptimization is broken
kvn
parents:
44
diff
changeset
|
1053 assert(mark->is_biased_anonymously() || |
d3cd40645d0d
6681646: Relocking of a scalar replaced object during deoptimization is broken
kvn
parents:
44
diff
changeset
|
1054 mark->biased_locker() == thread, "should be locked to current thread"); |
d3cd40645d0d
6681646: Relocking of a scalar replaced object during deoptimization is broken
kvn
parents:
44
diff
changeset
|
1055 // Reset mark word to unbiased prototype. |
d3cd40645d0d
6681646: Relocking of a scalar replaced object during deoptimization is broken
kvn
parents:
44
diff
changeset
|
1056 markOop unbiased_prototype = markOopDesc::prototype()->set_age(mark->age()); |
d3cd40645d0d
6681646: Relocking of a scalar replaced object during deoptimization is broken
kvn
parents:
44
diff
changeset
|
1057 obj->set_mark(unbiased_prototype); |
d3cd40645d0d
6681646: Relocking of a scalar replaced object during deoptimization is broken
kvn
parents:
44
diff
changeset
|
1058 } |
d3cd40645d0d
6681646: Relocking of a scalar replaced object during deoptimization is broken
kvn
parents:
44
diff
changeset
|
1059 BasicLock* lock = mon_info->lock(); |
d3cd40645d0d
6681646: Relocking of a scalar replaced object during deoptimization is broken
kvn
parents:
44
diff
changeset
|
1060 ObjectSynchronizer::slow_enter(obj, lock, thread); |
0 | 1061 } |
83
d3cd40645d0d
6681646: Relocking of a scalar replaced object during deoptimization is broken
kvn
parents:
44
diff
changeset
|
1062 assert(mon_info->owner()->is_locked(), "object must be locked now"); |
0 | 1063 } |
1064 } | |
1065 | |
1066 | |
1067 #ifndef PRODUCT | |
1068 // print information about reallocated objects | |
1069 void Deoptimization::print_objects(GrowableArray<ScopeValue*>* objects) { | |
1070 fieldDescriptor fd; | |
1071 | |
1072 for (int i = 0; i < objects->length(); i++) { | |
1073 ObjectValue* sv = (ObjectValue*) objects->at(i); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
1074 KlassHandle k(java_lang_Class::as_Klass(sv->klass()->as_ConstantOopReadValue()->value()())); |
0 | 1075 Handle obj = sv->value(); |
1076 | |
1077 tty->print(" object <" INTPTR_FORMAT "> of type ", sv->value()()); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
1078 k->print_value(); |
0 | 1079 tty->print(" allocated (%d bytes)", obj->size() * HeapWordSize); |
1080 tty->cr(); | |
1081 | |
1082 if (Verbose) { | |
1083 k->oop_print_on(obj(), tty); | |
1084 } | |
1085 } | |
1086 } | |
1087 #endif | |
4978
99d3d8a72252
More ifdef GRAAL usage.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4970
diff
changeset
|
1088 #endif // COMPILER2 || GRAAL |
0 | 1089 |
1090 vframeArray* Deoptimization::create_vframeArray(JavaThread* thread, frame fr, RegisterMap *reg_map, GrowableArray<compiledVFrame*>* chunk) { | |
4872
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
4777
diff
changeset
|
1091 Events::log(thread, "DEOPT PACKING pc=" INTPTR_FORMAT " sp=" INTPTR_FORMAT, fr.pc(), fr.sp()); |
0 | 1092 |
1093 #ifndef PRODUCT | |
4668
3dbcd1013cc8
added flag PrintDeoptimizationDetails
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4661
diff
changeset
|
1094 if (PrintDeoptimizationDetails) { |
0 | 1095 ttyLocker ttyl; |
1096 tty->print("DEOPT PACKING thread " INTPTR_FORMAT " ", thread); | |
1097 fr.print_on(tty); | |
1098 tty->print_cr(" Virtual frames (innermost first):"); | |
1099 for (int index = 0; index < chunk->length(); index++) { | |
1100 compiledVFrame* vf = chunk->at(index); | |
1101 tty->print(" %2d - ", index); | |
1102 vf->print_value(); | |
1103 int bci = chunk->at(index)->raw_bci(); | |
1104 const char* code_name; | |
1105 if (bci == SynchronizationEntryBCI) { | |
1106 code_name = "sync entry"; | |
1107 } else { | |
2142 | 1108 Bytecodes::Code code = vf->method()->code_at(bci); |
0 | 1109 code_name = Bytecodes::name(code); |
1110 } | |
1111 tty->print(" - %s", code_name); | |
1112 tty->print_cr(" @ bci %d ", bci); | |
1113 if (Verbose) { | |
1114 vf->print(); | |
1115 tty->cr(); | |
1116 } | |
1117 } | |
1118 } | |
1119 #endif | |
1120 | |
1121 // Register map for next frame (used for stack crawl). We capture | |
1122 // the state of the deopt'ing frame's caller. Thus if we need to | |
1123 // stuff a C2I adapter we can properly fill in the callee-save | |
1124 // register locations. | |
1125 frame caller = fr.sender(reg_map); | |
1126 int frame_size = caller.sp() - fr.sp(); | |
1127 | |
1128 frame sender = caller; | |
1129 | |
1130 // Since the Java thread being deoptimized will eventually adjust it's own stack, | |
1131 // the vframeArray containing the unpacking information is allocated in the C heap. | |
1132 // For Compiler1, the caller of the deoptimized frame is saved for use by unpack_frames(). | |
1133 vframeArray* array = vframeArray::allocate(thread, frame_size, chunk, reg_map, sender, caller, fr); | |
1134 | |
1135 // Compare the vframeArray to the collected vframes | |
1136 assert(array->structural_compare(thread, chunk), "just checking"); | |
1137 | |
1138 #ifndef PRODUCT | |
4668
3dbcd1013cc8
added flag PrintDeoptimizationDetails
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4661
diff
changeset
|
1139 if (PrintDeoptimizationDetails) { |
0 | 1140 ttyLocker ttyl; |
1141 tty->print_cr(" Created vframeArray " INTPTR_FORMAT, array); | |
1142 } | |
1143 #endif // PRODUCT | |
1144 | |
1145 return array; | |
1146 } | |
1147 | |
1148 | |
1149 static void collect_monitors(compiledVFrame* cvf, GrowableArray<Handle>* objects_to_revoke) { | |
1150 GrowableArray<MonitorInfo*>* monitors = cvf->monitors(); | |
1151 for (int i = 0; i < monitors->length(); i++) { | |
1152 MonitorInfo* mon_info = monitors->at(i); | |
818
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
196
diff
changeset
|
1153 if (!mon_info->eliminated() && mon_info->owner() != NULL) { |
0 | 1154 objects_to_revoke->append(Handle(mon_info->owner())); |
1155 } | |
1156 } | |
1157 } | |
1158 | |
1159 | |
1160 void Deoptimization::revoke_biases_of_monitors(JavaThread* thread, frame fr, RegisterMap* map) { | |
1161 if (!UseBiasedLocking) { | |
1162 return; | |
1163 } | |
1164 | |
1165 GrowableArray<Handle>* objects_to_revoke = new GrowableArray<Handle>(); | |
1166 | |
1167 // Unfortunately we don't have a RegisterMap available in most of | |
1168 // the places we want to call this routine so we need to walk the | |
1169 // stack again to update the register map. | |
1170 if (map == NULL || !map->update_map()) { | |
1171 StackFrameStream sfs(thread, true); | |
1172 bool found = false; | |
1173 while (!found && !sfs.is_done()) { | |
1174 frame* cur = sfs.current(); | |
1175 sfs.next(); | |
1176 found = cur->id() == fr.id(); | |
1177 } | |
1178 assert(found, "frame to be deoptimized not found on target thread's stack"); | |
1179 map = sfs.register_map(); | |
1180 } | |
1181 | |
1182 vframe* vf = vframe::new_vframe(&fr, map, thread); | |
1183 compiledVFrame* cvf = compiledVFrame::cast(vf); | |
1184 // Revoke monitors' biases in all scopes | |
1185 while (!cvf->is_top()) { | |
1186 collect_monitors(cvf, objects_to_revoke); | |
1187 cvf = compiledVFrame::cast(cvf->sender()); | |
1188 } | |
1189 collect_monitors(cvf, objects_to_revoke); | |
1190 | |
1191 if (SafepointSynchronize::is_at_safepoint()) { | |
1192 BiasedLocking::revoke_at_safepoint(objects_to_revoke); | |
1193 } else { | |
1194 BiasedLocking::revoke(objects_to_revoke); | |
1195 } | |
1196 } | |
1197 | |
1198 | |
1199 void Deoptimization::revoke_biases_of_monitors(CodeBlob* cb) { | |
1200 if (!UseBiasedLocking) { | |
1201 return; | |
1202 } | |
1203 | |
1204 assert(SafepointSynchronize::is_at_safepoint(), "must only be called from safepoint"); | |
1205 GrowableArray<Handle>* objects_to_revoke = new GrowableArray<Handle>(); | |
1206 for (JavaThread* jt = Threads::first(); jt != NULL ; jt = jt->next()) { | |
1207 if (jt->has_last_Java_frame()) { | |
1208 StackFrameStream sfs(jt, true); | |
1209 while (!sfs.is_done()) { | |
1210 frame* cur = sfs.current(); | |
1211 if (cb->contains(cur->pc())) { | |
1212 vframe* vf = vframe::new_vframe(cur, sfs.register_map(), jt); | |
1213 compiledVFrame* cvf = compiledVFrame::cast(vf); | |
1214 // Revoke monitors' biases in all scopes | |
1215 while (!cvf->is_top()) { | |
1216 collect_monitors(cvf, objects_to_revoke); | |
1217 cvf = compiledVFrame::cast(cvf->sender()); | |
1218 } | |
1219 collect_monitors(cvf, objects_to_revoke); | |
1220 } | |
1221 sfs.next(); | |
1222 } | |
1223 } | |
1224 } | |
1225 BiasedLocking::revoke_at_safepoint(objects_to_revoke); | |
1226 } | |
1227 | |
1228 | |
5110
0ebca2e35ca5
more preparations for disabling runtime feedback selectively based on deoptimization history
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5038
diff
changeset
|
1229 void Deoptimization::deoptimize_single_frame(JavaThread* thread, frame fr, Deoptimization::DeoptReason reason) { |
0 | 1230 assert(fr.can_be_deoptimized(), "checking frame type"); |
1231 | |
5110
0ebca2e35ca5
more preparations for disabling runtime feedback selectively based on deoptimization history
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5038
diff
changeset
|
1232 gather_statistics(reason, Action_none, Bytecodes::_illegal); |
0 | 1233 |
1234 // Patch the nmethod so that when execution returns to it we will | |
1235 // deopt the execution state and return to the interpreter. | |
1236 fr.deoptimize(thread); | |
1237 } | |
1238 | |
5110
0ebca2e35ca5
more preparations for disabling runtime feedback selectively based on deoptimization history
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5038
diff
changeset
|
1239 void Deoptimization::deoptimize(JavaThread* thread, frame fr, RegisterMap *map, DeoptReason reason) { |
0 | 1240 // Deoptimize only if the frame comes from compile code. |
1241 // Do not deoptimize the frame which is already patched | |
1242 // during the execution of the loops below. | |
1243 if (!fr.is_compiled_frame() || fr.is_deoptimized_frame()) { | |
1244 return; | |
1245 } | |
1246 ResourceMark rm; | |
1247 DeoptimizationMarker dm; | |
1248 if (UseBiasedLocking) { | |
1249 revoke_biases_of_monitors(thread, fr, map); | |
1250 } | |
5110
0ebca2e35ca5
more preparations for disabling runtime feedback selectively based on deoptimization history
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5038
diff
changeset
|
1251 deoptimize_single_frame(thread, fr, reason); |
0 | 1252 |
1253 } | |
1254 | |
1255 | |
5110
0ebca2e35ca5
more preparations for disabling runtime feedback selectively based on deoptimization history
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5038
diff
changeset
|
1256 void Deoptimization::deoptimize_frame_internal(JavaThread* thread, intptr_t* id, DeoptReason reason) { |
1905
ce6848d0666d
6968367: can_post_on_exceptions is still using VM_DeoptimizeFrame in some places
never
parents:
1814
diff
changeset
|
1257 assert(thread == Thread::current() || SafepointSynchronize::is_at_safepoint(), |
ce6848d0666d
6968367: can_post_on_exceptions is still using VM_DeoptimizeFrame in some places
never
parents:
1814
diff
changeset
|
1258 "can only deoptimize other thread at a safepoint"); |
0 | 1259 // Compute frame and register map based on thread and sp. |
1260 RegisterMap reg_map(thread, UseBiasedLocking); | |
1261 frame fr = thread->last_frame(); | |
1262 while (fr.id() != id) { | |
1263 fr = fr.sender(®_map); | |
1264 } | |
5110
0ebca2e35ca5
more preparations for disabling runtime feedback selectively based on deoptimization history
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5038
diff
changeset
|
1265 deoptimize(thread, fr, ®_map, reason); |
0 | 1266 } |
1267 | |
1268 | |
5110
0ebca2e35ca5
more preparations for disabling runtime feedback selectively based on deoptimization history
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5038
diff
changeset
|
1269 void Deoptimization::deoptimize_frame(JavaThread* thread, intptr_t* id, DeoptReason reason) { |
1905
ce6848d0666d
6968367: can_post_on_exceptions is still using VM_DeoptimizeFrame in some places
never
parents:
1814
diff
changeset
|
1270 if (thread == Thread::current()) { |
5110
0ebca2e35ca5
more preparations for disabling runtime feedback selectively based on deoptimization history
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5038
diff
changeset
|
1271 Deoptimization::deoptimize_frame_internal(thread, id, reason); |
1905
ce6848d0666d
6968367: can_post_on_exceptions is still using VM_DeoptimizeFrame in some places
never
parents:
1814
diff
changeset
|
1272 } else { |
5110
0ebca2e35ca5
more preparations for disabling runtime feedback selectively based on deoptimization history
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5038
diff
changeset
|
1273 VM_DeoptimizeFrame deopt(thread, id, reason); |
1905
ce6848d0666d
6968367: can_post_on_exceptions is still using VM_DeoptimizeFrame in some places
never
parents:
1814
diff
changeset
|
1274 VMThread::execute(&deopt); |
ce6848d0666d
6968367: can_post_on_exceptions is still using VM_DeoptimizeFrame in some places
never
parents:
1814
diff
changeset
|
1275 } |
ce6848d0666d
6968367: can_post_on_exceptions is still using VM_DeoptimizeFrame in some places
never
parents:
1814
diff
changeset
|
1276 } |
ce6848d0666d
6968367: can_post_on_exceptions is still using VM_DeoptimizeFrame in some places
never
parents:
1814
diff
changeset
|
1277 |
ce6848d0666d
6968367: can_post_on_exceptions is still using VM_DeoptimizeFrame in some places
never
parents:
1814
diff
changeset
|
1278 |
0 | 1279 // JVMTI PopFrame support |
1280 JRT_LEAF(void, Deoptimization::popframe_preserve_args(JavaThread* thread, int bytes_to_save, void* start_address)) | |
1281 { | |
1282 thread->popframe_preserve_args(in_ByteSize(bytes_to_save), start_address); | |
1283 } | |
1284 JRT_END | |
1285 | |
1286 | |
4978
99d3d8a72252
More ifdef GRAAL usage.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4970
diff
changeset
|
1287 #if defined(COMPILER2) || defined(SHARK) || defined(GRAAL) |
0 | 1288 void Deoptimization::load_class_by_index(constantPoolHandle constant_pool, int index, TRAPS) { |
1289 // in case of an unresolved klass entry, load the class. | |
1290 if (constant_pool->tag_at(index).is_unresolved_klass()) { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
1291 Klass* tk = constant_pool->klass_at(index, CHECK); |
0 | 1292 return; |
1293 } | |
1294 | |
1295 if (!constant_pool->tag_at(index).is_symbol()) return; | |
1296 | |
6940
18fb7da42534
8000725: NPG: method_holder() and pool_holder() and pool_holder field should be InstanceKlass
coleenp
parents:
6853
diff
changeset
|
1297 Handle class_loader (THREAD, constant_pool->pool_holder()->class_loader()); |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2142
diff
changeset
|
1298 Symbol* symbol = constant_pool->symbol_at(index); |
0 | 1299 |
1300 // class name? | |
1301 if (symbol->byte_at(0) != '(') { | |
6940
18fb7da42534
8000725: NPG: method_holder() and pool_holder() and pool_holder field should be InstanceKlass
coleenp
parents:
6853
diff
changeset
|
1302 Handle protection_domain (THREAD, constant_pool->pool_holder()->protection_domain()); |
0 | 1303 SystemDictionary::resolve_or_null(symbol, class_loader, protection_domain, CHECK); |
1304 return; | |
1305 } | |
1306 | |
1307 // then it must be a signature! | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2142
diff
changeset
|
1308 ResourceMark rm(THREAD); |
0 | 1309 for (SignatureStream ss(symbol); !ss.is_done(); ss.next()) { |
1310 if (ss.is_object()) { | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2142
diff
changeset
|
1311 Symbol* class_name = ss.as_symbol(CHECK); |
6940
18fb7da42534
8000725: NPG: method_holder() and pool_holder() and pool_holder field should be InstanceKlass
coleenp
parents:
6853
diff
changeset
|
1312 Handle protection_domain (THREAD, constant_pool->pool_holder()->protection_domain()); |
0 | 1313 SystemDictionary::resolve_or_null(class_name, class_loader, protection_domain, CHECK); |
1314 } | |
1315 } | |
1316 } | |
1317 | |
1318 | |
1319 void Deoptimization::load_class_by_index(constantPoolHandle constant_pool, int index) { | |
1320 EXCEPTION_MARK; | |
1321 load_class_by_index(constant_pool, index, THREAD); | |
1322 if (HAS_PENDING_EXCEPTION) { | |
1323 // Exception happened during classloading. We ignore the exception here, since it | |
1324 // is going to be rethrown since the current activation is going to be deoptimzied and | |
1325 // the interpreter will re-execute the bytecode. | |
1326 CLEAR_PENDING_EXCEPTION; | |
1327 } | |
1328 } | |
1329 | |
1330 JRT_ENTRY(void, Deoptimization::uncommon_trap_inner(JavaThread* thread, jint trap_request)) { | |
1331 HandleMark hm; | |
1332 | |
1333 // uncommon_trap() is called at the beginning of the uncommon trap | |
1334 // handler. Note this fact before we start generating temporary frames | |
1335 // that can confuse an asynchronous stack walker. This counter is | |
1336 // decremented at the end of unpack_frames(). | |
1337 thread->inc_in_deopt_handler(); | |
1338 | |
1339 // We need to update the map if we have biased locking. | |
6428
6278ac5829ce
fix for deopt issue with -XX:-UseBiasedLocking (plus a cosmetic fix in graalCodeInstaller.cpp)
Lukas Stadler <lukas.stadler@jku.at>
parents:
6275
diff
changeset
|
1340 #ifdef GRAAL |
6278ac5829ce
fix for deopt issue with -XX:-UseBiasedLocking (plus a cosmetic fix in graalCodeInstaller.cpp)
Lukas Stadler <lukas.stadler@jku.at>
parents:
6275
diff
changeset
|
1341 // (lstadler) Graal might need to get an exception from the stack, which in turn requires the register map to be valid |
6278ac5829ce
fix for deopt issue with -XX:-UseBiasedLocking (plus a cosmetic fix in graalCodeInstaller.cpp)
Lukas Stadler <lukas.stadler@jku.at>
parents:
6275
diff
changeset
|
1342 RegisterMap reg_map(thread, true); |
6278ac5829ce
fix for deopt issue with -XX:-UseBiasedLocking (plus a cosmetic fix in graalCodeInstaller.cpp)
Lukas Stadler <lukas.stadler@jku.at>
parents:
6275
diff
changeset
|
1343 #else |
0 | 1344 RegisterMap reg_map(thread, UseBiasedLocking); |
6428
6278ac5829ce
fix for deopt issue with -XX:-UseBiasedLocking (plus a cosmetic fix in graalCodeInstaller.cpp)
Lukas Stadler <lukas.stadler@jku.at>
parents:
6275
diff
changeset
|
1345 #endif |
0 | 1346 frame stub_frame = thread->last_frame(); |
1347 frame fr = stub_frame.sender(®_map); | |
1348 // Make sure the calling nmethod is not getting deoptimized and removed | |
1349 // before we are done with it. | |
1350 nmethodLocker nl(fr.pc()); | |
1351 | |
4872
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
4777
diff
changeset
|
1352 // Log a message |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
4777
diff
changeset
|
1353 Events::log_deopt_message(thread, "Uncommon trap %d fr.pc " INTPTR_FORMAT, |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
4777
diff
changeset
|
1354 trap_request, fr.pc()); |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
4777
diff
changeset
|
1355 |
0 | 1356 { |
1357 ResourceMark rm; | |
1358 | |
1359 // Revoke biases of any monitors in the frame to ensure we can migrate them | |
1360 revoke_biases_of_monitors(thread, fr, ®_map); | |
1361 | |
1362 DeoptReason reason = trap_request_reason(trap_request); | |
1363 DeoptAction action = trap_request_action(trap_request); | |
1364 jint unloaded_class_index = trap_request_index(trap_request); // CP idx or -1 | |
1365 | |
1366 vframe* vf = vframe::new_vframe(&fr, ®_map, thread); | |
1367 compiledVFrame* cvf = compiledVFrame::cast(vf); | |
1368 | |
1369 nmethod* nm = cvf->code(); | |
1370 | |
1371 ScopeDesc* trap_scope = cvf->scope(); | |
3017
b4ba003eb11d
Fixed unnecessary node in the graph builder.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2938
diff
changeset
|
1372 |
b4ba003eb11d
Fixed unnecessary node in the graph builder.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2938
diff
changeset
|
1373 if (TraceDeoptimization) { |
4674
e1c053324210
changed TraceDeoptimization output
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4668
diff
changeset
|
1374 tty->print_cr(" bci=%d pc=%d, relative_pc=%d, method=%s", trap_scope->bci(), fr.pc(), fr.pc() - nm->code_begin(), trap_scope->method()->name()->as_C_string()); |
5749 | 1375 #ifdef GRAAL |
3558
bc95d122df79
added runtime call to supply info upon deoptimization
Lukas Stadler <lukas.stadler@jku.at>
parents:
3464
diff
changeset
|
1376 if (thread->graal_deopt_info() != NULL) { |
bc95d122df79
added runtime call to supply info upon deoptimization
Lukas Stadler <lukas.stadler@jku.at>
parents:
3464
diff
changeset
|
1377 oop deopt_info = thread->graal_deopt_info(); |
bc95d122df79
added runtime call to supply info upon deoptimization
Lukas Stadler <lukas.stadler@jku.at>
parents:
3464
diff
changeset
|
1378 if (java_lang_String::is_instance(deopt_info)) { |
bc95d122df79
added runtime call to supply info upon deoptimization
Lukas Stadler <lukas.stadler@jku.at>
parents:
3464
diff
changeset
|
1379 char buf[1024]; |
bc95d122df79
added runtime call to supply info upon deoptimization
Lukas Stadler <lukas.stadler@jku.at>
parents:
3464
diff
changeset
|
1380 java_lang_String::as_utf8_string(deopt_info, buf, 1024); |
bc95d122df79
added runtime call to supply info upon deoptimization
Lukas Stadler <lukas.stadler@jku.at>
parents:
3464
diff
changeset
|
1381 tty->print_cr("deopt info: %s", buf); |
bc95d122df79
added runtime call to supply info upon deoptimization
Lukas Stadler <lukas.stadler@jku.at>
parents:
3464
diff
changeset
|
1382 } else { |
bc95d122df79
added runtime call to supply info upon deoptimization
Lukas Stadler <lukas.stadler@jku.at>
parents:
3464
diff
changeset
|
1383 tty->print_cr("deopt info:"); |
bc95d122df79
added runtime call to supply info upon deoptimization
Lukas Stadler <lukas.stadler@jku.at>
parents:
3464
diff
changeset
|
1384 deopt_info->print(); |
bc95d122df79
added runtime call to supply info upon deoptimization
Lukas Stadler <lukas.stadler@jku.at>
parents:
3464
diff
changeset
|
1385 } |
bc95d122df79
added runtime call to supply info upon deoptimization
Lukas Stadler <lukas.stadler@jku.at>
parents:
3464
diff
changeset
|
1386 thread->set_graal_deopt_info(NULL); |
bc95d122df79
added runtime call to supply info upon deoptimization
Lukas Stadler <lukas.stadler@jku.at>
parents:
3464
diff
changeset
|
1387 } |
5749 | 1388 #endif |
3017
b4ba003eb11d
Fixed unnecessary node in the graph builder.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2938
diff
changeset
|
1389 } |
0 | 1390 |
1391 methodHandle trap_method = trap_scope->method(); | |
1392 int trap_bci = trap_scope->bci(); | |
2142 | 1393 Bytecodes::Code trap_bc = trap_method->java_code_at(trap_bci); |
0 | 1394 |
3018
5857923e563c
Fixed an issue with frame states in exception dispatch chains (now we are correctly rethrowing the exception immediately at entering the interpreter).
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
3017
diff
changeset
|
1395 if (trap_scope->rethrow_exception()) { |
4668
3dbcd1013cc8
added flag PrintDeoptimizationDetails
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4661
diff
changeset
|
1396 if (PrintDeoptimizationDetails) { |
6948
e522a00b91aa
Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/ after NPG - C++ build works
Doug Simon <doug.simon@oracle.com>
diff
changeset
|
1397 tty->print_cr("Exception to be rethrown in the interpreter for method %s::%s at bci %d", trap_method->method_holder()->name()->as_C_string(), trap_method->name()->as_C_string(), trap_bci); |
3019
77bb196828cb
Fixed an issue with accessing non-initialized static fields.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
3018
diff
changeset
|
1398 } |
3018
5857923e563c
Fixed an issue with frame states in exception dispatch chains (now we are correctly rethrowing the exception immediately at entering the interpreter).
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
3017
diff
changeset
|
1399 GrowableArray<ScopeValue*>* expressions = trap_scope->expressions(); |
3167
132aa6f2bbc0
Fixed rethrow exception frame state (again.. and this time added some useful assertions).
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
3153
diff
changeset
|
1400 guarantee(expressions != NULL, "must have exception to throw"); |
3018
5857923e563c
Fixed an issue with frame states in exception dispatch chains (now we are correctly rethrowing the exception immediately at entering the interpreter).
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
3017
diff
changeset
|
1401 ScopeValue* topOfStack = expressions->top(); |
5857923e563c
Fixed an issue with frame states in exception dispatch chains (now we are correctly rethrowing the exception immediately at entering the interpreter).
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
3017
diff
changeset
|
1402 Handle topOfStackObj = cvf->create_stack_value(topOfStack)->get_obj(); |
5857923e563c
Fixed an issue with frame states in exception dispatch chains (now we are correctly rethrowing the exception immediately at entering the interpreter).
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
3017
diff
changeset
|
1403 THREAD->set_pending_exception(topOfStackObj(), NULL, 0); |
5857923e563c
Fixed an issue with frame states in exception dispatch chains (now we are correctly rethrowing the exception immediately at entering the interpreter).
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
3017
diff
changeset
|
1404 } |
5857923e563c
Fixed an issue with frame states in exception dispatch chains (now we are correctly rethrowing the exception immediately at entering the interpreter).
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
3017
diff
changeset
|
1405 |
0 | 1406 // Record this event in the histogram. |
1407 gather_statistics(reason, action, trap_bc); | |
1408 | |
1409 // Ensure that we can record deopt. history: | |
1410 bool create_if_missing = ProfileTraps; | |
1411 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
1412 MethodData* trap_mdo = |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
1413 get_method_data(thread, trap_method, create_if_missing); |
0 | 1414 |
1415 // Print a bunch of diagnostics, if requested. | |
1416 if (TraceDeoptimization || LogCompilation) { | |
1417 ResourceMark rm; | |
1418 ttyLocker ttyl; | |
1419 char buf[100]; | |
1420 if (xtty != NULL) { | |
1421 xtty->begin_head("uncommon_trap thread='" UINTX_FORMAT"' %s", | |
1422 os::current_thread_id(), | |
1423 format_trap_request(buf, sizeof(buf), trap_request)); | |
1424 nm->log_identity(xtty); | |
1425 } | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2142
diff
changeset
|
1426 Symbol* class_name = NULL; |
0 | 1427 bool unresolved = false; |
1428 if (unloaded_class_index >= 0) { | |
1429 constantPoolHandle constants (THREAD, trap_method->constants()); | |
1430 if (constants->tag_at(unloaded_class_index).is_unresolved_klass()) { | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2142
diff
changeset
|
1431 class_name = constants->klass_name_at(unloaded_class_index); |
0 | 1432 unresolved = true; |
1433 if (xtty != NULL) | |
1434 xtty->print(" unresolved='1'"); | |
1435 } else if (constants->tag_at(unloaded_class_index).is_symbol()) { | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2142
diff
changeset
|
1436 class_name = constants->symbol_at(unloaded_class_index); |
0 | 1437 } |
1438 if (xtty != NULL) | |
1439 xtty->name(class_name); | |
1440 } | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
1441 if (xtty != NULL && trap_mdo != NULL) { |
0 | 1442 // Dump the relevant MDO state. |
1443 // This is the deopt count for the current reason, any previous | |
1444 // reasons or recompiles seen at this point. | |
1445 int dcnt = trap_mdo->trap_count(reason); | |
1446 if (dcnt != 0) | |
1447 xtty->print(" count='%d'", dcnt); | |
1448 ProfileData* pdata = trap_mdo->bci_to_data(trap_bci); | |
1449 int dos = (pdata == NULL)? 0: pdata->trap_state(); | |
1450 if (dos != 0) { | |
1451 xtty->print(" state='%s'", format_trap_state(buf, sizeof(buf), dos)); | |
1452 if (trap_state_is_recompiled(dos)) { | |
1453 int recnt2 = trap_mdo->overflow_recompile_count(); | |
1454 if (recnt2 != 0) | |
1455 xtty->print(" recompiles2='%d'", recnt2); | |
1456 } | |
1457 } | |
1458 } | |
1459 if (xtty != NULL) { | |
1460 xtty->stamp(); | |
1461 xtty->end_head(); | |
1462 } | |
1463 if (TraceDeoptimization) { // make noise on the tty | |
1464 tty->print("Uncommon trap occurred in"); | |
1465 nm->method()->print_short_name(tty); | |
6843 | 1466 tty->print(" (@" INTPTR_FORMAT ") thread=" UINTX_FORMAT " reason=%s action=%s unloaded_class_index=%d", |
0 | 1467 fr.pc(), |
6843 | 1468 os::current_thread_id(), |
0 | 1469 trap_reason_name(reason), |
1470 trap_action_name(action), | |
1471 unloaded_class_index); | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2142
diff
changeset
|
1472 if (class_name != NULL) { |
0 | 1473 tty->print(unresolved ? " unresolved class: " : " symbol: "); |
1474 class_name->print_symbol_on(tty); | |
1475 } | |
1476 tty->cr(); | |
1477 } | |
1478 if (xtty != NULL) { | |
1479 // Log the precise location of the trap. | |
1480 for (ScopeDesc* sd = trap_scope; ; sd = sd->sender()) { | |
1481 xtty->begin_elem("jvms bci='%d'", sd->bci()); | |
1482 xtty->method(sd->method()); | |
1483 xtty->end_elem(); | |
1484 if (sd->is_top()) break; | |
1485 } | |
1486 xtty->tail("uncommon_trap"); | |
1487 } | |
1488 } | |
1489 // (End diagnostic printout.) | |
1490 | |
1491 // Load class if necessary | |
1492 if (unloaded_class_index >= 0) { | |
1493 constantPoolHandle constants(THREAD, trap_method->constants()); | |
1494 load_class_by_index(constants, unloaded_class_index); | |
1495 } | |
1496 | |
1497 // Flush the nmethod if necessary and desirable. | |
1498 // | |
1499 // We need to avoid situations where we are re-flushing the nmethod | |
1500 // because of a hot deoptimization site. Repeated flushes at the same | |
1501 // point need to be detected by the compiler and avoided. If the compiler | |
1502 // cannot avoid them (or has a bug and "refuses" to avoid them), this | |
1503 // module must take measures to avoid an infinite cycle of recompilation | |
1504 // and deoptimization. There are several such measures: | |
1505 // | |
1506 // 1. If a recompilation is ordered a second time at some site X | |
1507 // and for the same reason R, the action is adjusted to 'reinterpret', | |
1508 // to give the interpreter time to exercise the method more thoroughly. | |
1509 // If this happens, the method's overflow_recompile_count is incremented. | |
1510 // | |
1511 // 2. If the compiler fails to reduce the deoptimization rate, then | |
1512 // the method's overflow_recompile_count will begin to exceed the set | |
1513 // limit PerBytecodeRecompilationCutoff. If this happens, the action | |
1514 // is adjusted to 'make_not_compilable', and the method is abandoned | |
1515 // to the interpreter. This is a performance hit for hot methods, | |
1516 // but is better than a disastrous infinite cycle of recompilations. | |
1517 // (Actually, only the method containing the site X is abandoned.) | |
1518 // | |
1519 // 3. In parallel with the previous measures, if the total number of | |
1520 // recompilations of a method exceeds the much larger set limit | |
1521 // PerMethodRecompilationCutoff, the method is abandoned. | |
1522 // This should only happen if the method is very large and has | |
1523 // many "lukewarm" deoptimizations. The code which enforces this | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
1524 // limit is elsewhere (class nmethod, class Method). |
0 | 1525 // |
1526 // Note that the per-BCI 'is_recompiled' bit gives the compiler one chance | |
1527 // to recompile at each bytecode independently of the per-BCI cutoff. | |
1528 // | |
1529 // The decision to update code is up to the compiler, and is encoded | |
1530 // in the Action_xxx code. If the compiler requests Action_none | |
1531 // no trap state is changed, no compiled code is changed, and the | |
1532 // computation suffers along in the interpreter. | |
1533 // | |
1534 // The other action codes specify various tactics for decompilation | |
1535 // and recompilation. Action_maybe_recompile is the loosest, and | |
1536 // allows the compiled code to stay around until enough traps are seen, | |
1537 // and until the compiler gets around to recompiling the trapping method. | |
1538 // | |
1539 // The other actions cause immediate removal of the present code. | |
1540 | |
1541 bool update_trap_state = true; | |
1542 bool make_not_entrant = false; | |
1543 bool make_not_compilable = false; | |
1783 | 1544 bool reprofile = false; |
0 | 1545 switch (action) { |
1546 case Action_none: | |
1547 // Keep the old code. | |
1548 update_trap_state = false; | |
1549 break; | |
1550 case Action_maybe_recompile: | |
1551 // Do not need to invalidate the present code, but we can | |
1552 // initiate another | |
1553 // Start compiler without (necessarily) invalidating the nmethod. | |
1554 // The system will tolerate the old code, but new code should be | |
1555 // generated when possible. | |
1556 break; | |
1557 case Action_reinterpret: | |
1558 // Go back into the interpreter for a while, and then consider | |
1559 // recompiling form scratch. | |
1560 make_not_entrant = true; | |
1561 // Reset invocation counter for outer most method. | |
1562 // This will allow the interpreter to exercise the bytecodes | |
1563 // for a while before recompiling. | |
1564 // By contrast, Action_make_not_entrant is immediate. | |
1565 // | |
1566 // Note that the compiler will track null_check, null_assert, | |
1567 // range_check, and class_check events and log them as if they | |
1568 // had been traps taken from compiled code. This will update | |
1569 // the MDO trap history so that the next compilation will | |
1570 // properly detect hot trap sites. | |
1783 | 1571 reprofile = true; |
0 | 1572 break; |
1573 case Action_make_not_entrant: | |
1574 // Request immediate recompilation, and get rid of the old code. | |
1575 // Make them not entrant, so next time they are called they get | |
1576 // recompiled. Unloaded classes are loaded now so recompile before next | |
1577 // time they are called. Same for uninitialized. The interpreter will | |
1578 // link the missing class, if any. | |
1579 make_not_entrant = true; | |
1580 break; | |
1581 case Action_make_not_compilable: | |
1582 // Give up on compiling this method at all. | |
1583 make_not_entrant = true; | |
1584 make_not_compilable = true; | |
1585 break; | |
1586 default: | |
1587 ShouldNotReachHere(); | |
1588 } | |
1589 | |
1590 // Setting +ProfileTraps fixes the following, on all platforms: | |
1591 // 4852688: ProfileInterpreter is off by default for ia64. The result is | |
1592 // infinite heroic-opt-uncommon-trap/deopt/recompile cycles, since the | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
1593 // recompile relies on a MethodData* to record heroic opt failures. |
0 | 1594 |
1595 // Whether the interpreter is producing MDO data or not, we also need | |
1596 // to use the MDO to detect hot deoptimization points and control | |
1597 // aggressive optimization. | |
1206
87684f1a88b5
6614597: Performance variability in jvm2008 xml.validation
kvn
parents:
1204
diff
changeset
|
1598 bool inc_recompile_count = false; |
87684f1a88b5
6614597: Performance variability in jvm2008 xml.validation
kvn
parents:
1204
diff
changeset
|
1599 ProfileData* pdata = NULL; |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
1600 if (ProfileTraps && update_trap_state && trap_mdo != NULL) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
1601 assert(trap_mdo == get_method_data(thread, trap_method, false), "sanity"); |
0 | 1602 uint this_trap_count = 0; |
1603 bool maybe_prior_trap = false; | |
1604 bool maybe_prior_recompile = false; | |
5114
dad1ac9dba7d
finished first implementation of disabling runtime feedback selectively based on deoptimization history
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5110
diff
changeset
|
1605 pdata = query_update_method_data(trap_mdo, trap_bci, reason, true, |
0 | 1606 //outputs: |
1607 this_trap_count, | |
1608 maybe_prior_trap, | |
1609 maybe_prior_recompile); | |
1610 // Because the interpreter also counts null, div0, range, and class | |
1611 // checks, these traps from compiled code are double-counted. | |
1612 // This is harmless; it just means that the PerXTrapLimit values | |
1613 // are in effect a little smaller than they look. | |
1614 | |
1615 DeoptReason per_bc_reason = reason_recorded_per_bytecode_if_any(reason); | |
1616 if (per_bc_reason != Reason_none) { | |
1617 // Now take action based on the partially known per-BCI history. | |
1618 if (maybe_prior_trap | |
1619 && this_trap_count >= (uint)PerBytecodeTrapLimit) { | |
1620 // If there are too many traps at this BCI, force a recompile. | |
1621 // This will allow the compiler to see the limit overflow, and | |
1622 // take corrective action, if possible. The compiler generally | |
1623 // does not use the exact PerBytecodeTrapLimit value, but instead | |
1624 // changes its tactics if it sees any traps at all. This provides | |
1625 // a little hysteresis, delaying a recompile until a trap happens | |
1626 // several times. | |
1627 // | |
1628 // Actually, since there is only one bit of counter per BCI, | |
1629 // the possible per-BCI counts are {0,1,(per-method count)}. | |
1630 // This produces accurate results if in fact there is only | |
1631 // one hot trap site, but begins to get fuzzy if there are | |
1632 // many sites. For example, if there are ten sites each | |
1633 // trapping two or more times, they each get the blame for | |
1634 // all of their traps. | |
1635 make_not_entrant = true; | |
1636 } | |
1637 | |
1638 // Detect repeated recompilation at the same BCI, and enforce a limit. | |
1639 if (make_not_entrant && maybe_prior_recompile) { | |
1640 // More than one recompile at this point. | |
1206
87684f1a88b5
6614597: Performance variability in jvm2008 xml.validation
kvn
parents:
1204
diff
changeset
|
1641 inc_recompile_count = maybe_prior_trap; |
0 | 1642 } |
1643 } else { | |
1644 // For reasons which are not recorded per-bytecode, we simply | |
1645 // force recompiles unconditionally. | |
1646 // (Note that PerMethodRecompilationCutoff is enforced elsewhere.) | |
1647 make_not_entrant = true; | |
1648 } | |
1649 | |
1650 // Go back to the compiler if there are too many traps in this method. | |
1651 if (this_trap_count >= (uint)PerMethodTrapLimit) { | |
1652 // If there are too many traps in this method, force a recompile. | |
1653 // This will allow the compiler to see the limit overflow, and | |
1654 // take corrective action, if possible. | |
1655 // (This condition is an unlikely backstop only, because the | |
1656 // PerBytecodeTrapLimit is more likely to take effect first, | |
1657 // if it is applicable.) | |
1658 make_not_entrant = true; | |
1659 } | |
1660 | |
1661 // Here's more hysteresis: If there has been a recompile at | |
1662 // this trap point already, run the method in the interpreter | |
1663 // for a while to exercise it more thoroughly. | |
1664 if (make_not_entrant && maybe_prior_recompile && maybe_prior_trap) { | |
1783 | 1665 reprofile = true; |
0 | 1666 } |
1667 | |
1206
87684f1a88b5
6614597: Performance variability in jvm2008 xml.validation
kvn
parents:
1204
diff
changeset
|
1668 } |
87684f1a88b5
6614597: Performance variability in jvm2008 xml.validation
kvn
parents:
1204
diff
changeset
|
1669 |
87684f1a88b5
6614597: Performance variability in jvm2008 xml.validation
kvn
parents:
1204
diff
changeset
|
1670 // Take requested actions on the method: |
87684f1a88b5
6614597: Performance variability in jvm2008 xml.validation
kvn
parents:
1204
diff
changeset
|
1671 |
87684f1a88b5
6614597: Performance variability in jvm2008 xml.validation
kvn
parents:
1204
diff
changeset
|
1672 // Recompile |
87684f1a88b5
6614597: Performance variability in jvm2008 xml.validation
kvn
parents:
1204
diff
changeset
|
1673 if (make_not_entrant) { |
87684f1a88b5
6614597: Performance variability in jvm2008 xml.validation
kvn
parents:
1204
diff
changeset
|
1674 if (!nm->make_not_entrant()) { |
87684f1a88b5
6614597: Performance variability in jvm2008 xml.validation
kvn
parents:
1204
diff
changeset
|
1675 return; // the call did not change nmethod's state |
87684f1a88b5
6614597: Performance variability in jvm2008 xml.validation
kvn
parents:
1204
diff
changeset
|
1676 } |
87684f1a88b5
6614597: Performance variability in jvm2008 xml.validation
kvn
parents:
1204
diff
changeset
|
1677 |
87684f1a88b5
6614597: Performance variability in jvm2008 xml.validation
kvn
parents:
1204
diff
changeset
|
1678 if (pdata != NULL) { |
0 | 1679 // Record the recompilation event, if any. |
1680 int tstate0 = pdata->trap_state(); | |
1681 int tstate1 = trap_state_set_recompiled(tstate0, true); | |
1682 if (tstate1 != tstate0) | |
1683 pdata->set_trap_state(tstate1); | |
1684 } | |
1685 } | |
1686 | |
1206
87684f1a88b5
6614597: Performance variability in jvm2008 xml.validation
kvn
parents:
1204
diff
changeset
|
1687 if (inc_recompile_count) { |
87684f1a88b5
6614597: Performance variability in jvm2008 xml.validation
kvn
parents:
1204
diff
changeset
|
1688 trap_mdo->inc_overflow_recompile_count(); |
87684f1a88b5
6614597: Performance variability in jvm2008 xml.validation
kvn
parents:
1204
diff
changeset
|
1689 if ((uint)trap_mdo->overflow_recompile_count() > |
87684f1a88b5
6614597: Performance variability in jvm2008 xml.validation
kvn
parents:
1204
diff
changeset
|
1690 (uint)PerBytecodeRecompilationCutoff) { |
87684f1a88b5
6614597: Performance variability in jvm2008 xml.validation
kvn
parents:
1204
diff
changeset
|
1691 // Give up on the method containing the bad BCI. |
87684f1a88b5
6614597: Performance variability in jvm2008 xml.validation
kvn
parents:
1204
diff
changeset
|
1692 if (trap_method() == nm->method()) { |
87684f1a88b5
6614597: Performance variability in jvm2008 xml.validation
kvn
parents:
1204
diff
changeset
|
1693 make_not_compilable = true; |
87684f1a88b5
6614597: Performance variability in jvm2008 xml.validation
kvn
parents:
1204
diff
changeset
|
1694 } else { |
1783 | 1695 trap_method->set_not_compilable(CompLevel_full_optimization); |
1206
87684f1a88b5
6614597: Performance variability in jvm2008 xml.validation
kvn
parents:
1204
diff
changeset
|
1696 // But give grace to the enclosing nm->method(). |
87684f1a88b5
6614597: Performance variability in jvm2008 xml.validation
kvn
parents:
1204
diff
changeset
|
1697 } |
87684f1a88b5
6614597: Performance variability in jvm2008 xml.validation
kvn
parents:
1204
diff
changeset
|
1698 } |
87684f1a88b5
6614597: Performance variability in jvm2008 xml.validation
kvn
parents:
1204
diff
changeset
|
1699 } |
0 | 1700 |
1783 | 1701 // Reprofile |
1702 if (reprofile) { | |
1703 CompilationPolicy::policy()->reprofile(trap_scope, nm->is_osr_method()); | |
0 | 1704 } |
1705 | |
1706 // Give up compiling | |
1783 | 1707 if (make_not_compilable && !nm->method()->is_not_compilable(CompLevel_full_optimization)) { |
0 | 1708 assert(make_not_entrant, "consistent"); |
1783 | 1709 nm->method()->set_not_compilable(CompLevel_full_optimization); |
0 | 1710 } |
1711 | |
1712 } // Free marked resources | |
1713 | |
1714 } | |
1715 JRT_END | |
1716 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
1717 MethodData* |
0 | 1718 Deoptimization::get_method_data(JavaThread* thread, methodHandle m, |
1719 bool create_if_missing) { | |
1720 Thread* THREAD = thread; | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
1721 MethodData* mdo = m()->method_data(); |
0 | 1722 if (mdo == NULL && create_if_missing && !HAS_PENDING_EXCEPTION) { |
1723 // Build an MDO. Ignore errors like OutOfMemory; | |
1724 // that simply means we won't have an MDO to update. | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
1725 Method::build_interpreter_method_data(m, THREAD); |
0 | 1726 if (HAS_PENDING_EXCEPTION) { |
1727 assert((PENDING_EXCEPTION->is_a(SystemDictionary::OutOfMemoryError_klass())), "we expect only an OOM error here"); | |
1728 CLEAR_PENDING_EXCEPTION; | |
1729 } | |
1730 mdo = m()->method_data(); | |
1731 } | |
1732 return mdo; | |
1733 } | |
1734 | |
1735 ProfileData* | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
1736 Deoptimization::query_update_method_data(MethodData* trap_mdo, |
0 | 1737 int trap_bci, |
1738 Deoptimization::DeoptReason reason, | |
5114
dad1ac9dba7d
finished first implementation of disabling runtime feedback selectively based on deoptimization history
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5110
diff
changeset
|
1739 bool update_total_trap_count, |
0 | 1740 //outputs: |
1741 uint& ret_this_trap_count, | |
1742 bool& ret_maybe_prior_trap, | |
1743 bool& ret_maybe_prior_recompile) { | |
5114
dad1ac9dba7d
finished first implementation of disabling runtime feedback selectively based on deoptimization history
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5110
diff
changeset
|
1744 bool maybe_prior_trap = false; |
dad1ac9dba7d
finished first implementation of disabling runtime feedback selectively based on deoptimization history
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5110
diff
changeset
|
1745 bool maybe_prior_recompile = false; |
dad1ac9dba7d
finished first implementation of disabling runtime feedback selectively based on deoptimization history
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5110
diff
changeset
|
1746 uint this_trap_count = 0; |
dad1ac9dba7d
finished first implementation of disabling runtime feedback selectively based on deoptimization history
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5110
diff
changeset
|
1747 if (update_total_trap_count) { |
dad1ac9dba7d
finished first implementation of disabling runtime feedback selectively based on deoptimization history
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5110
diff
changeset
|
1748 uint prior_trap_count = trap_mdo->trap_count(reason); |
dad1ac9dba7d
finished first implementation of disabling runtime feedback selectively based on deoptimization history
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5110
diff
changeset
|
1749 this_trap_count = trap_mdo->inc_trap_count(reason); |
0 | 1750 |
5114
dad1ac9dba7d
finished first implementation of disabling runtime feedback selectively based on deoptimization history
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5110
diff
changeset
|
1751 // If the runtime cannot find a place to store trap history, |
dad1ac9dba7d
finished first implementation of disabling runtime feedback selectively based on deoptimization history
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5110
diff
changeset
|
1752 // it is estimated based on the general condition of the method. |
dad1ac9dba7d
finished first implementation of disabling runtime feedback selectively based on deoptimization history
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5110
diff
changeset
|
1753 // If the method has ever been recompiled, or has ever incurred |
dad1ac9dba7d
finished first implementation of disabling runtime feedback selectively based on deoptimization history
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5110
diff
changeset
|
1754 // a trap with the present reason , then this BCI is assumed |
dad1ac9dba7d
finished first implementation of disabling runtime feedback selectively based on deoptimization history
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5110
diff
changeset
|
1755 // (pessimistically) to be the culprit. |
dad1ac9dba7d
finished first implementation of disabling runtime feedback selectively based on deoptimization history
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5110
diff
changeset
|
1756 maybe_prior_trap = (prior_trap_count != 0); |
dad1ac9dba7d
finished first implementation of disabling runtime feedback selectively based on deoptimization history
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5110
diff
changeset
|
1757 maybe_prior_recompile = (trap_mdo->decompile_count() != 0); |
dad1ac9dba7d
finished first implementation of disabling runtime feedback selectively based on deoptimization history
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5110
diff
changeset
|
1758 } |
0 | 1759 |
1760 // For reasons which are recorded per bytecode, we check per-BCI data. | |
5114
dad1ac9dba7d
finished first implementation of disabling runtime feedback selectively based on deoptimization history
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5110
diff
changeset
|
1761 ProfileData* pdata = NULL; |
0 | 1762 DeoptReason per_bc_reason = reason_recorded_per_bytecode_if_any(reason); |
5121
34518fd74518
fixed fastdebug C++ issue
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5114
diff
changeset
|
1763 assert(per_bc_reason != Reason_none || update_total_trap_count, "must be"); |
0 | 1764 if (per_bc_reason != Reason_none) { |
1765 // Find the profile data for this BCI. If there isn't one, | |
1766 // try to allocate one from the MDO's set of spares. | |
1767 // This will let us detect a repeated trap at this point. | |
1768 pdata = trap_mdo->allocate_bci_to_data(trap_bci); | |
1769 | |
1770 if (pdata != NULL) { | |
1771 // Query the trap state of this profile datum. | |
1772 int tstate0 = pdata->trap_state(); | |
1773 if (!trap_state_has_reason(tstate0, per_bc_reason)) | |
1774 maybe_prior_trap = false; | |
1775 if (!trap_state_is_recompiled(tstate0)) | |
1776 maybe_prior_recompile = false; | |
1777 | |
1778 // Update the trap state of this profile datum. | |
1779 int tstate1 = tstate0; | |
1780 // Record the reason. | |
1781 tstate1 = trap_state_add_reason(tstate1, per_bc_reason); | |
1782 // Store the updated state on the MDO, for next time. | |
1783 if (tstate1 != tstate0) | |
1784 pdata->set_trap_state(tstate1); | |
1785 } else { | |
1206
87684f1a88b5
6614597: Performance variability in jvm2008 xml.validation
kvn
parents:
1204
diff
changeset
|
1786 if (LogCompilation && xtty != NULL) { |
87684f1a88b5
6614597: Performance variability in jvm2008 xml.validation
kvn
parents:
1204
diff
changeset
|
1787 ttyLocker ttyl; |
0 | 1788 // Missing MDP? Leave a small complaint in the log. |
1789 xtty->elem("missing_mdp bci='%d'", trap_bci); | |
1206
87684f1a88b5
6614597: Performance variability in jvm2008 xml.validation
kvn
parents:
1204
diff
changeset
|
1790 } |
0 | 1791 } |
1792 } | |
1793 | |
1794 // Return results: | |
1795 ret_this_trap_count = this_trap_count; | |
1796 ret_maybe_prior_trap = maybe_prior_trap; | |
1797 ret_maybe_prior_recompile = maybe_prior_recompile; | |
1798 return pdata; | |
1799 } | |
1800 | |
1801 void | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
1802 Deoptimization::update_method_data_from_interpreter(MethodData* trap_mdo, int trap_bci, int reason) { |
0 | 1803 ResourceMark rm; |
1804 // Ignored outputs: | |
1805 uint ignore_this_trap_count; | |
1806 bool ignore_maybe_prior_trap; | |
1807 bool ignore_maybe_prior_recompile; | |
5114
dad1ac9dba7d
finished first implementation of disabling runtime feedback selectively based on deoptimization history
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5110
diff
changeset
|
1808 // Graal uses the total counts to determine if deoptimizations are happening too frequently -> do not adjust total counts |
5130 | 1809 bool update_total_counts = GRAAL_ONLY(false) NOT_GRAAL(true); |
0 | 1810 query_update_method_data(trap_mdo, trap_bci, |
1811 (DeoptReason)reason, | |
5114
dad1ac9dba7d
finished first implementation of disabling runtime feedback selectively based on deoptimization history
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5110
diff
changeset
|
1812 update_total_counts, |
0 | 1813 ignore_this_trap_count, |
1814 ignore_maybe_prior_trap, | |
1815 ignore_maybe_prior_recompile); | |
1816 } | |
1817 | |
1818 Deoptimization::UnrollBlock* Deoptimization::uncommon_trap(JavaThread* thread, jint trap_request) { | |
4674
e1c053324210
changed TraceDeoptimization output
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4668
diff
changeset
|
1819 if (TraceDeoptimization) { |
e1c053324210
changed TraceDeoptimization output
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4668
diff
changeset
|
1820 tty->print("Uncommon trap "); |
e1c053324210
changed TraceDeoptimization output
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4668
diff
changeset
|
1821 } |
0 | 1822 // Still in Java no safepoints |
1823 { | |
1824 // This enters VM and may safepoint | |
1825 uncommon_trap_inner(thread, trap_request); | |
1826 } | |
1827 return fetch_unroll_info_helper(thread); | |
1828 } | |
1829 | |
1830 // Local derived constants. | |
1831 // Further breakdown of DataLayout::trap_state, as promised by DataLayout. | |
1832 const int DS_REASON_MASK = DataLayout::trap_mask >> 1; | |
1833 const int DS_RECOMPILE_BIT = DataLayout::trap_mask - DS_REASON_MASK; | |
1834 | |
1835 //---------------------------trap_state_reason--------------------------------- | |
1836 Deoptimization::DeoptReason | |
1837 Deoptimization::trap_state_reason(int trap_state) { | |
1838 // This assert provides the link between the width of DataLayout::trap_bits | |
1839 // and the encoding of "recorded" reasons. It ensures there are enough | |
1840 // bits to store all needed reasons in the per-BCI MDO profile. | |
1841 assert(DS_REASON_MASK >= Reason_RECORDED_LIMIT, "enough bits"); | |
1842 int recompile_bit = (trap_state & DS_RECOMPILE_BIT); | |
1843 trap_state -= recompile_bit; | |
1844 if (trap_state == DS_REASON_MASK) { | |
1845 return Reason_many; | |
1846 } else { | |
1847 assert((int)Reason_none == 0, "state=0 => Reason_none"); | |
1848 return (DeoptReason)trap_state; | |
1849 } | |
1850 } | |
1851 //-------------------------trap_state_has_reason------------------------------- | |
1852 int Deoptimization::trap_state_has_reason(int trap_state, int reason) { | |
1853 assert(reason_is_recorded_per_bytecode((DeoptReason)reason), "valid reason"); | |
1854 assert(DS_REASON_MASK >= Reason_RECORDED_LIMIT, "enough bits"); | |
1855 int recompile_bit = (trap_state & DS_RECOMPILE_BIT); | |
1856 trap_state -= recompile_bit; | |
1857 if (trap_state == DS_REASON_MASK) { | |
1858 return -1; // true, unspecifically (bottom of state lattice) | |
1859 } else if (trap_state == reason) { | |
1860 return 1; // true, definitely | |
1861 } else if (trap_state == 0) { | |
1862 return 0; // false, definitely (top of state lattice) | |
1863 } else { | |
1864 return 0; // false, definitely | |
1865 } | |
1866 } | |
1867 //-------------------------trap_state_add_reason------------------------------- | |
1868 int Deoptimization::trap_state_add_reason(int trap_state, int reason) { | |
1869 assert(reason_is_recorded_per_bytecode((DeoptReason)reason) || reason == Reason_many, "valid reason"); | |
1870 int recompile_bit = (trap_state & DS_RECOMPILE_BIT); | |
1871 trap_state -= recompile_bit; | |
1872 if (trap_state == DS_REASON_MASK) { | |
1873 return trap_state + recompile_bit; // already at state lattice bottom | |
1874 } else if (trap_state == reason) { | |
1875 return trap_state + recompile_bit; // the condition is already true | |
1876 } else if (trap_state == 0) { | |
1877 return reason + recompile_bit; // no condition has yet been true | |
1878 } else { | |
1879 return DS_REASON_MASK + recompile_bit; // fall to state lattice bottom | |
1880 } | |
1881 } | |
1882 //-----------------------trap_state_is_recompiled------------------------------ | |
1883 bool Deoptimization::trap_state_is_recompiled(int trap_state) { | |
1884 return (trap_state & DS_RECOMPILE_BIT) != 0; | |
1885 } | |
1886 //-----------------------trap_state_set_recompiled----------------------------- | |
1887 int Deoptimization::trap_state_set_recompiled(int trap_state, bool z) { | |
1888 if (z) return trap_state | DS_RECOMPILE_BIT; | |
1889 else return trap_state & ~DS_RECOMPILE_BIT; | |
1890 } | |
1891 //---------------------------format_trap_state--------------------------------- | |
1892 // This is used for debugging and diagnostics, including hotspot.log output. | |
1893 const char* Deoptimization::format_trap_state(char* buf, size_t buflen, | |
1894 int trap_state) { | |
1895 DeoptReason reason = trap_state_reason(trap_state); | |
1896 bool recomp_flag = trap_state_is_recompiled(trap_state); | |
1897 // Re-encode the state from its decoded components. | |
1898 int decoded_state = 0; | |
1899 if (reason_is_recorded_per_bytecode(reason) || reason == Reason_many) | |
1900 decoded_state = trap_state_add_reason(decoded_state, reason); | |
1901 if (recomp_flag) | |
1902 decoded_state = trap_state_set_recompiled(decoded_state, recomp_flag); | |
1903 // If the state re-encodes properly, format it symbolically. | |
1904 // Because this routine is used for debugging and diagnostics, | |
1905 // be robust even if the state is a strange value. | |
1906 size_t len; | |
1907 if (decoded_state != trap_state) { | |
1908 // Random buggy state that doesn't decode?? | |
1909 len = jio_snprintf(buf, buflen, "#%d", trap_state); | |
1910 } else { | |
1911 len = jio_snprintf(buf, buflen, "%s%s", | |
1912 trap_reason_name(reason), | |
1913 recomp_flag ? " recompiled" : ""); | |
1914 } | |
1915 if (len >= buflen) | |
1916 buf[buflen-1] = '\0'; | |
1917 return buf; | |
1918 } | |
1919 | |
1920 | |
1921 //--------------------------------statics-------------------------------------- | |
1922 Deoptimization::DeoptAction Deoptimization::_unloaded_action | |
1923 = Deoptimization::Action_reinterpret; | |
1924 const char* Deoptimization::_trap_reason_name[Reason_LIMIT] = { | |
5110
0ebca2e35ca5
more preparations for disabling runtime feedback selectively based on deoptimization history
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5038
diff
changeset
|
1925 #ifdef GRAAL |
0ebca2e35ca5
more preparations for disabling runtime feedback selectively based on deoptimization history
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5038
diff
changeset
|
1926 "none", |
0ebca2e35ca5
more preparations for disabling runtime feedback selectively based on deoptimization history
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5038
diff
changeset
|
1927 "null_check", |
0ebca2e35ca5
more preparations for disabling runtime feedback selectively based on deoptimization history
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5038
diff
changeset
|
1928 "range_check", |
0ebca2e35ca5
more preparations for disabling runtime feedback selectively based on deoptimization history
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5038
diff
changeset
|
1929 "class_check", |
0ebca2e35ca5
more preparations for disabling runtime feedback selectively based on deoptimization history
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5038
diff
changeset
|
1930 "array_check", |
0ebca2e35ca5
more preparations for disabling runtime feedback selectively based on deoptimization history
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5038
diff
changeset
|
1931 "unreached", |
0ebca2e35ca5
more preparations for disabling runtime feedback selectively based on deoptimization history
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5038
diff
changeset
|
1932 "type_checked_inlining", |
0ebca2e35ca5
more preparations for disabling runtime feedback selectively based on deoptimization history
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5038
diff
changeset
|
1933 "optimized_type_check", |
0ebca2e35ca5
more preparations for disabling runtime feedback selectively based on deoptimization history
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5038
diff
changeset
|
1934 "not_compiled_exception_handler", |
0ebca2e35ca5
more preparations for disabling runtime feedback selectively based on deoptimization history
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5038
diff
changeset
|
1935 "unresolved", |
0ebca2e35ca5
more preparations for disabling runtime feedback selectively based on deoptimization history
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5038
diff
changeset
|
1936 "jsr_mismatch", |
0ebca2e35ca5
more preparations for disabling runtime feedback selectively based on deoptimization history
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5038
diff
changeset
|
1937 "div0_check", |
0ebca2e35ca5
more preparations for disabling runtime feedback selectively based on deoptimization history
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5038
diff
changeset
|
1938 "constraint" |
0ebca2e35ca5
more preparations for disabling runtime feedback selectively based on deoptimization history
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5038
diff
changeset
|
1939 #else |
0 | 1940 // Note: Keep this in sync. with enum DeoptReason. |
1941 "none", | |
1942 "null_check", | |
1943 "null_assert", | |
1944 "range_check", | |
1945 "class_check", | |
1946 "array_check", | |
1947 "intrinsic", | |
1206
87684f1a88b5
6614597: Performance variability in jvm2008 xml.validation
kvn
parents:
1204
diff
changeset
|
1948 "bimorphic", |
0 | 1949 "unloaded", |
1950 "uninitialized", | |
1951 "unreached", | |
1952 "unhandled", | |
1953 "constraint", | |
1954 "div0_check", | |
1172 | 1955 "age", |
3345 | 1956 "predicate", |
1957 "loop_limit_check" | |
5110
0ebca2e35ca5
more preparations for disabling runtime feedback selectively based on deoptimization history
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5038
diff
changeset
|
1958 #endif |
0 | 1959 }; |
1960 const char* Deoptimization::_trap_action_name[Action_LIMIT] = { | |
1961 // Note: Keep this in sync. with enum DeoptAction. | |
1962 "none", | |
1963 "maybe_recompile", | |
1964 "reinterpret", | |
1965 "make_not_entrant", | |
1966 "make_not_compilable" | |
1967 }; | |
1968 | |
1969 const char* Deoptimization::trap_reason_name(int reason) { | |
1970 if (reason == Reason_many) return "many"; | |
1971 if ((uint)reason < Reason_LIMIT) | |
1972 return _trap_reason_name[reason]; | |
1973 static char buf[20]; | |
1974 sprintf(buf, "reason%d", reason); | |
1975 return buf; | |
1976 } | |
1977 const char* Deoptimization::trap_action_name(int action) { | |
1978 if ((uint)action < Action_LIMIT) | |
1979 return _trap_action_name[action]; | |
1980 static char buf[20]; | |
1981 sprintf(buf, "action%d", action); | |
1982 return buf; | |
1983 } | |
1984 | |
1985 // This is used for debugging and diagnostics, including hotspot.log output. | |
1986 const char* Deoptimization::format_trap_request(char* buf, size_t buflen, | |
1987 int trap_request) { | |
1988 jint unloaded_class_index = trap_request_index(trap_request); | |
1989 const char* reason = trap_reason_name(trap_request_reason(trap_request)); | |
1990 const char* action = trap_action_name(trap_request_action(trap_request)); | |
1991 size_t len; | |
1992 if (unloaded_class_index < 0) { | |
1993 len = jio_snprintf(buf, buflen, "reason='%s' action='%s'", | |
1994 reason, action); | |
1995 } else { | |
1996 len = jio_snprintf(buf, buflen, "reason='%s' action='%s' index='%d'", | |
1997 reason, action, unloaded_class_index); | |
1998 } | |
1999 if (len >= buflen) | |
2000 buf[buflen-1] = '\0'; | |
2001 return buf; | |
2002 } | |
2003 | |
2004 juint Deoptimization::_deoptimization_hist | |
2005 [Deoptimization::Reason_LIMIT] | |
2006 [1 + Deoptimization::Action_LIMIT] | |
2007 [Deoptimization::BC_CASE_LIMIT] | |
2008 = {0}; | |
2009 | |
2010 enum { | |
2011 LSB_BITS = 8, | |
2012 LSB_MASK = right_n_bits(LSB_BITS) | |
2013 }; | |
2014 | |
2015 void Deoptimization::gather_statistics(DeoptReason reason, DeoptAction action, | |
2016 Bytecodes::Code bc) { | |
2017 assert(reason >= 0 && reason < Reason_LIMIT, "oob"); | |
2018 assert(action >= 0 && action < Action_LIMIT, "oob"); | |
2019 _deoptimization_hist[Reason_none][0][0] += 1; // total | |
2020 _deoptimization_hist[reason][0][0] += 1; // per-reason total | |
2021 juint* cases = _deoptimization_hist[reason][1+action]; | |
2022 juint* bc_counter_addr = NULL; | |
2023 juint bc_counter = 0; | |
2024 // Look for an unused counter, or an exact match to this BC. | |
2025 if (bc != Bytecodes::_illegal) { | |
2026 for (int bc_case = 0; bc_case < BC_CASE_LIMIT; bc_case++) { | |
2027 juint* counter_addr = &cases[bc_case]; | |
2028 juint counter = *counter_addr; | |
2029 if ((counter == 0 && bc_counter_addr == NULL) | |
2030 || (Bytecodes::Code)(counter & LSB_MASK) == bc) { | |
2031 // this counter is either free or is already devoted to this BC | |
2032 bc_counter_addr = counter_addr; | |
2033 bc_counter = counter | bc; | |
2034 } | |
2035 } | |
2036 } | |
2037 if (bc_counter_addr == NULL) { | |
2038 // Overflow, or no given bytecode. | |
2039 bc_counter_addr = &cases[BC_CASE_LIMIT-1]; | |
2040 bc_counter = (*bc_counter_addr & ~LSB_MASK); // clear LSB | |
2041 } | |
2042 *bc_counter_addr = bc_counter + (1 << LSB_BITS); | |
2043 } | |
2044 | |
2045 jint Deoptimization::total_deoptimization_count() { | |
2046 return _deoptimization_hist[Reason_none][0][0]; | |
2047 } | |
2048 | |
2049 jint Deoptimization::deoptimization_count(DeoptReason reason) { | |
2050 assert(reason >= 0 && reason < Reason_LIMIT, "oob"); | |
2051 return _deoptimization_hist[reason][0][0]; | |
2052 } | |
2053 | |
2054 void Deoptimization::print_statistics() { | |
2055 juint total = total_deoptimization_count(); | |
2056 juint account = total; | |
2057 if (total != 0) { | |
2058 ttyLocker ttyl; | |
2059 if (xtty != NULL) xtty->head("statistics type='deoptimization'"); | |
2060 tty->print_cr("Deoptimization traps recorded:"); | |
2061 #define PRINT_STAT_LINE(name, r) \ | |
2062 tty->print_cr(" %4d (%4.1f%%) %s", (int)(r), ((r) * 100.0) / total, name); | |
2063 PRINT_STAT_LINE("total", total); | |
2064 // For each non-zero entry in the histogram, print the reason, | |
2065 // the action, and (if specifically known) the type of bytecode. | |
2066 for (int reason = 0; reason < Reason_LIMIT; reason++) { | |
2067 for (int action = 0; action < Action_LIMIT; action++) { | |
2068 juint* cases = _deoptimization_hist[reason][1+action]; | |
2069 for (int bc_case = 0; bc_case < BC_CASE_LIMIT; bc_case++) { | |
2070 juint counter = cases[bc_case]; | |
2071 if (counter != 0) { | |
2072 char name[1*K]; | |
2073 Bytecodes::Code bc = (Bytecodes::Code)(counter & LSB_MASK); | |
2074 if (bc_case == BC_CASE_LIMIT && (int)bc == 0) | |
2075 bc = Bytecodes::_illegal; | |
2076 sprintf(name, "%s/%s/%s", | |
2077 trap_reason_name(reason), | |
2078 trap_action_name(action), | |
2079 Bytecodes::is_defined(bc)? Bytecodes::name(bc): "other"); | |
2080 juint r = counter >> LSB_BITS; | |
2081 tty->print_cr(" %40s: " UINT32_FORMAT " (%.1f%%)", name, r, (r * 100.0) / total); | |
2082 account -= r; | |
2083 } | |
2084 } | |
2085 } | |
2086 } | |
2087 if (account != 0) { | |
2088 PRINT_STAT_LINE("unaccounted", account); | |
2089 } | |
2090 #undef PRINT_STAT_LINE | |
2091 if (xtty != NULL) xtty->tail("statistics"); | |
2092 } | |
2093 } | |
4978
99d3d8a72252
More ifdef GRAAL usage.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4970
diff
changeset
|
2094 #else // COMPILER2 || SHARK || GRAAL |
0 | 2095 |
2096 | |
2097 // Stubs for C1 only system. | |
2098 bool Deoptimization::trap_state_is_recompiled(int trap_state) { | |
2099 return false; | |
2100 } | |
2101 | |
2102 const char* Deoptimization::trap_reason_name(int reason) { | |
2103 return "unknown"; | |
2104 } | |
2105 | |
2106 void Deoptimization::print_statistics() { | |
2107 // no output | |
2108 } | |
2109 | |
2110 void | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
2111 Deoptimization::update_method_data_from_interpreter(MethodData* trap_mdo, int trap_bci, int reason) { |
0 | 2112 // no udpate |
2113 } | |
2114 | |
2115 int Deoptimization::trap_state_has_reason(int trap_state, int reason) { | |
2116 return 0; | |
2117 } | |
2118 | |
2119 void Deoptimization::gather_statistics(DeoptReason reason, DeoptAction action, | |
2120 Bytecodes::Code bc) { | |
2121 // no update | |
2122 } | |
2123 | |
2124 const char* Deoptimization::format_trap_state(char* buf, size_t buflen, | |
2125 int trap_state) { | |
2126 jio_snprintf(buf, buflen, "#%d", trap_state); | |
2127 return buf; | |
2128 } | |
2129 | |
4978
99d3d8a72252
More ifdef GRAAL usage.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4970
diff
changeset
|
2130 #endif // COMPILER2 || SHARK || GRAAL |