author | roland |
Tue, 25 Nov 2014 17:33:59 +0100 | |
changeset 28039 | bf5a8340bf8a |
parent 27420 | 04e6f914cce1 |
child 28196 | 6ba2bd76ea84 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
24424
2658d7834c6e
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
24322
diff
changeset
|
2 |
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. |
1 | 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 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5420
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5420
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5420
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#include "precompiled.hpp" |
26 |
#include "classfile/systemDictionary.hpp" |
|
27 |
#include "classfile/vmSymbols.hpp" |
|
28 |
#include "compiler/compileBroker.hpp" |
|
14626
0cf4eccf130f
8003240: x86: move MacroAssembler into separate file
twisti
parents:
14490
diff
changeset
|
29 |
#include "compiler/disassembler.hpp" |
7397 | 30 |
#include "gc_interface/collectedHeap.hpp" |
31 |
#include "interpreter/interpreter.hpp" |
|
32 |
#include "interpreter/interpreterRuntime.hpp" |
|
33 |
#include "interpreter/linkResolver.hpp" |
|
34 |
#include "interpreter/templateTable.hpp" |
|
35 |
#include "memory/oopFactory.hpp" |
|
36 |
#include "memory/universe.inline.hpp" |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
37 |
#include "oops/constantPool.hpp" |
7397 | 38 |
#include "oops/instanceKlass.hpp" |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
39 |
#include "oops/methodData.hpp" |
7397 | 40 |
#include "oops/objArrayKlass.hpp" |
41 |
#include "oops/oop.inline.hpp" |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7915
diff
changeset
|
42 |
#include "oops/symbol.hpp" |
7397 | 43 |
#include "prims/jvmtiExport.hpp" |
44 |
#include "prims/nativeLookup.hpp" |
|
25351
7c198a690050
8044775: Improve usage of umbrella header atomic.inline.hpp.
goetz
parents:
24678
diff
changeset
|
45 |
#include "runtime/atomic.inline.hpp" |
7397 | 46 |
#include "runtime/biasedLocking.hpp" |
47 |
#include "runtime/compilationPolicy.hpp" |
|
48 |
#include "runtime/deoptimization.hpp" |
|
49 |
#include "runtime/fieldDescriptor.hpp" |
|
50 |
#include "runtime/handles.inline.hpp" |
|
25715
d5a8dbdc5150
8049325: Introduce and clean up umbrella headers for the files in the cpu subdirectories.
goetz
parents:
25351
diff
changeset
|
51 |
#include "runtime/icache.hpp" |
7397 | 52 |
#include "runtime/interfaceSupport.hpp" |
53 |
#include "runtime/java.hpp" |
|
54 |
#include "runtime/jfieldIDWorkaround.hpp" |
|
55 |
#include "runtime/osThread.hpp" |
|
56 |
#include "runtime/sharedRuntime.hpp" |
|
57 |
#include "runtime/stubRoutines.hpp" |
|
58 |
#include "runtime/synchronizer.hpp" |
|
59 |
#include "runtime/threadCritical.hpp" |
|
60 |
#include "utilities/events.hpp" |
|
61 |
#ifdef COMPILER2 |
|
62 |
#include "opto/runtime.hpp" |
|
63 |
#endif |
|
1 | 64 |
|
24424
2658d7834c6e
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
24322
diff
changeset
|
65 |
PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC |
2658d7834c6e
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
24322
diff
changeset
|
66 |
|
1 | 67 |
class UnlockFlagSaver { |
68 |
private: |
|
69 |
JavaThread* _thread; |
|
70 |
bool _do_not_unlock; |
|
71 |
public: |
|
72 |
UnlockFlagSaver(JavaThread* t) { |
|
73 |
_thread = t; |
|
74 |
_do_not_unlock = t->do_not_unlock_if_synchronized(); |
|
75 |
t->set_do_not_unlock_if_synchronized(false); |
|
76 |
} |
|
77 |
~UnlockFlagSaver() { |
|
78 |
_thread->set_do_not_unlock_if_synchronized(_do_not_unlock); |
|
79 |
} |
|
80 |
}; |
|
81 |
||
82 |
//------------------------------------------------------------------------------------------------------------------------ |
|
83 |
// State accessors |
|
84 |
||
85 |
void InterpreterRuntime::set_bcp_and_mdp(address bcp, JavaThread *thread) { |
|
86 |
last_frame(thread).interpreter_frame_set_bcp(bcp); |
|
87 |
if (ProfileInterpreter) { |
|
88 |
// ProfileTraps uses MDOs independently of ProfileInterpreter. |
|
89 |
// That is why we must check both ProfileInterpreter and mdo != NULL. |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
90 |
MethodData* mdo = last_frame(thread).interpreter_frame_method()->method_data(); |
1 | 91 |
if (mdo != NULL) { |
92 |
NEEDS_CLEANUP; |
|
93 |
last_frame(thread).interpreter_frame_set_mdp(mdo->bci_to_dp(last_frame(thread).interpreter_frame_bci())); |
|
94 |
} |
|
95 |
} |
|
96 |
} |
|
97 |
||
98 |
//------------------------------------------------------------------------------------------------------------------------ |
|
99 |
// Constants |
|
100 |
||
101 |
||
102 |
IRT_ENTRY(void, InterpreterRuntime::ldc(JavaThread* thread, bool wide)) |
|
103 |
// access constant pool |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
104 |
ConstantPool* pool = method(thread)->constants(); |
5688 | 105 |
int index = wide ? get_index_u2(thread, Bytecodes::_ldc_w) : get_index_u1(thread, Bytecodes::_ldc); |
1 | 106 |
constantTag tag = pool->tag_at(index); |
107 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
108 |
assert (tag.is_unresolved_klass() || tag.is_klass(), "wrong ldc call"); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
109 |
Klass* klass = pool->klass_at(index, CHECK); |
8725
8c1e3dd5fe1b
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
8676
diff
changeset
|
110 |
oop java_class = klass->java_mirror(); |
1 | 111 |
thread->set_vm_result(java_class); |
112 |
IRT_END |
|
113 |
||
5882 | 114 |
IRT_ENTRY(void, InterpreterRuntime::resolve_ldc(JavaThread* thread, Bytecodes::Code bytecode)) { |
115 |
assert(bytecode == Bytecodes::_fast_aldc || |
|
116 |
bytecode == Bytecodes::_fast_aldc_w, "wrong bc"); |
|
117 |
ResourceMark rm(thread); |
|
118 |
methodHandle m (thread, method(thread)); |
|
7913 | 119 |
Bytecode_loadconstant ldc(m, bci(thread)); |
9960
43fe83652b18
7046732: JSR 292 assert(result == cpce->f1()) failed: expected result for assembly code
never
parents:
9116
diff
changeset
|
120 |
oop result = ldc.resolve_constant(CHECK); |
43fe83652b18
7046732: JSR 292 assert(result == cpce->f1()) failed: expected result for assembly code
never
parents:
9116
diff
changeset
|
121 |
#ifdef ASSERT |
43fe83652b18
7046732: JSR 292 assert(result == cpce->f1()) failed: expected result for assembly code
never
parents:
9116
diff
changeset
|
122 |
{ |
43fe83652b18
7046732: JSR 292 assert(result == cpce->f1()) failed: expected result for assembly code
never
parents:
9116
diff
changeset
|
123 |
// The bytecode wrappers aren't GC-safe so construct a new one |
43fe83652b18
7046732: JSR 292 assert(result == cpce->f1()) failed: expected result for assembly code
never
parents:
9116
diff
changeset
|
124 |
Bytecode_loadconstant ldc2(m, bci(thread)); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
125 |
oop coop = m->constants()->resolved_references()->obj_at(ldc2.cache_index()); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
126 |
assert(result == coop, "expected result for assembly code"); |
9960
43fe83652b18
7046732: JSR 292 assert(result == cpce->f1()) failed: expected result for assembly code
never
parents:
9116
diff
changeset
|
127 |
} |
43fe83652b18
7046732: JSR 292 assert(result == cpce->f1()) failed: expected result for assembly code
never
parents:
9116
diff
changeset
|
128 |
#endif |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
129 |
thread->set_vm_result(result); |
5882 | 130 |
} |
131 |
IRT_END |
|
132 |
||
1 | 133 |
|
134 |
//------------------------------------------------------------------------------------------------------------------------ |
|
135 |
// Allocation |
|
136 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
137 |
IRT_ENTRY(void, InterpreterRuntime::_new(JavaThread* thread, ConstantPool* pool, int index)) |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
138 |
Klass* k_oop = pool->klass_at(index, CHECK); |
1 | 139 |
instanceKlassHandle klass (THREAD, k_oop); |
140 |
||
141 |
// Make sure we are not instantiating an abstract klass |
|
142 |
klass->check_valid_for_instantiation(true, CHECK); |
|
143 |
||
144 |
// Make sure klass is initialized |
|
145 |
klass->initialize(CHECK); |
|
146 |
||
147 |
// At this point the class may not be fully initialized |
|
148 |
// because of recursive initialization. If it is fully |
|
149 |
// initialized & has_finalized is not set, we rewrite |
|
150 |
// it into its fast version (Note: no locking is needed |
|
151 |
// here since this is an atomic byte write and can be |
|
152 |
// done more than once). |
|
153 |
// |
|
154 |
// Note: In case of classes with has_finalized we don't |
|
155 |
// rewrite since that saves us an extra check in |
|
156 |
// the fast version which then would call the |
|
157 |
// slow version anyway (and do a call back into |
|
158 |
// Java). |
|
159 |
// If we have a breakpoint, then we don't rewrite |
|
160 |
// because the _breakpoint bytecode would be lost. |
|
161 |
oop obj = klass->allocate_instance(CHECK); |
|
162 |
thread->set_vm_result(obj); |
|
163 |
IRT_END |
|
164 |
||
165 |
||
166 |
IRT_ENTRY(void, InterpreterRuntime::newarray(JavaThread* thread, BasicType type, jint size)) |
|
167 |
oop obj = oopFactory::new_typeArray(type, size, CHECK); |
|
168 |
thread->set_vm_result(obj); |
|
169 |
IRT_END |
|
170 |
||
171 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
172 |
IRT_ENTRY(void, InterpreterRuntime::anewarray(JavaThread* thread, ConstantPool* pool, int index, jint size)) |
1 | 173 |
// Note: no oopHandle for pool & klass needed since they are not used |
174 |
// anymore after new_objArray() and no GC can happen before. |
|
175 |
// (This may have to change if this code changes!) |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
176 |
Klass* klass = pool->klass_at(index, CHECK); |
1 | 177 |
objArrayOop obj = oopFactory::new_objArray(klass, size, CHECK); |
178 |
thread->set_vm_result(obj); |
|
179 |
IRT_END |
|
180 |
||
181 |
||
182 |
IRT_ENTRY(void, InterpreterRuntime::multianewarray(JavaThread* thread, jint* first_size_address)) |
|
183 |
// We may want to pass in more arguments - could make this slightly faster |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
184 |
ConstantPool* constants = method(thread)->constants(); |
5688 | 185 |
int i = get_index_u2(thread, Bytecodes::_multianewarray); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
186 |
Klass* klass = constants->klass_at(i, CHECK); |
1 | 187 |
int nof_dims = number_of_dimensions(thread); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
188 |
assert(klass->is_klass(), "not a class"); |
1 | 189 |
assert(nof_dims >= 1, "multianewarray rank must be nonzero"); |
190 |
||
191 |
// We must create an array of jints to pass to multi_allocate. |
|
192 |
ResourceMark rm(thread); |
|
193 |
const int small_dims = 10; |
|
194 |
jint dim_array[small_dims]; |
|
195 |
jint *dims = &dim_array[0]; |
|
196 |
if (nof_dims > small_dims) { |
|
197 |
dims = (jint*) NEW_RESOURCE_ARRAY(jint, nof_dims); |
|
198 |
} |
|
199 |
for (int index = 0; index < nof_dims; index++) { |
|
200 |
// offset from first_size_address is addressed as local[index] |
|
201 |
int n = Interpreter::local_offset_in_bytes(index)/jintSize; |
|
202 |
dims[index] = first_size_address[n]; |
|
203 |
} |
|
13952
e3cf184080bc
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
13740
diff
changeset
|
204 |
oop obj = ArrayKlass::cast(klass)->multi_allocate(nof_dims, dims, CHECK); |
1 | 205 |
thread->set_vm_result(obj); |
206 |
IRT_END |
|
207 |
||
208 |
||
209 |
IRT_ENTRY(void, InterpreterRuntime::register_finalizer(JavaThread* thread, oopDesc* obj)) |
|
210 |
assert(obj->is_oop(), "must be a valid oop"); |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
211 |
assert(obj->klass()->has_finalizer(), "shouldn't be here otherwise"); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
212 |
InstanceKlass::register_finalizer(instanceOop(obj), CHECK); |
1 | 213 |
IRT_END |
214 |
||
215 |
||
216 |
// Quicken instance-of and check-cast bytecodes |
|
217 |
IRT_ENTRY(void, InterpreterRuntime::quicken_io_cc(JavaThread* thread)) |
|
218 |
// Force resolving; quicken the bytecode |
|
5688 | 219 |
int which = get_index_u2(thread, Bytecodes::_checkcast); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
220 |
ConstantPool* cpool = method(thread)->constants(); |
1 | 221 |
// We'd expect to assert that we're only here to quicken bytecodes, but in a multithreaded |
222 |
// program we might have seen an unquick'd bytecode in the interpreter but have another |
|
223 |
// thread quicken the bytecode before we get here. |
|
224 |
// assert( cpool->tag_at(which).is_unresolved_klass(), "should only come here to quicken bytecodes" ); |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
225 |
Klass* klass = cpool->klass_at(which, CHECK); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
226 |
thread->set_vm_result_2(klass); |
1 | 227 |
IRT_END |
228 |
||
229 |
||
230 |
//------------------------------------------------------------------------------------------------------------------------ |
|
231 |
// Exceptions |
|
232 |
||
22836
e7e511228518
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
19266
diff
changeset
|
233 |
void InterpreterRuntime::note_trap_inner(JavaThread* thread, int reason, |
e7e511228518
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
19266
diff
changeset
|
234 |
methodHandle trap_method, int trap_bci, TRAPS) { |
1 | 235 |
if (trap_method.not_null()) { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
236 |
MethodData* trap_mdo = trap_method->method_data(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
237 |
if (trap_mdo == NULL) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
238 |
Method::build_interpreter_method_data(trap_method, THREAD); |
1 | 239 |
if (HAS_PENDING_EXCEPTION) { |
22836
e7e511228518
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
19266
diff
changeset
|
240 |
assert((PENDING_EXCEPTION->is_a(SystemDictionary::OutOfMemoryError_klass())), |
e7e511228518
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
19266
diff
changeset
|
241 |
"we expect only an OOM error here"); |
1 | 242 |
CLEAR_PENDING_EXCEPTION; |
243 |
} |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
244 |
trap_mdo = trap_method->method_data(); |
1 | 245 |
// and fall through... |
246 |
} |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
247 |
if (trap_mdo != NULL) { |
1 | 248 |
// Update per-method count of trap events. The interpreter |
249 |
// is updating the MDO to simulate the effect of compiler traps. |
|
250 |
Deoptimization::update_method_data_from_interpreter(trap_mdo, trap_bci, reason); |
|
251 |
} |
|
252 |
} |
|
253 |
} |
|
254 |
||
22836
e7e511228518
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
19266
diff
changeset
|
255 |
// Assume the compiler is (or will be) interested in this event. |
e7e511228518
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
19266
diff
changeset
|
256 |
// If necessary, create an MDO to hold the information, and record it. |
e7e511228518
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
19266
diff
changeset
|
257 |
void InterpreterRuntime::note_trap(JavaThread* thread, int reason, TRAPS) { |
e7e511228518
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
19266
diff
changeset
|
258 |
assert(ProfileTraps, "call me only if profiling"); |
e7e511228518
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
19266
diff
changeset
|
259 |
methodHandle trap_method(thread, method(thread)); |
e7e511228518
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
19266
diff
changeset
|
260 |
int trap_bci = trap_method->bci_from(bcp(thread)); |
e7e511228518
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
19266
diff
changeset
|
261 |
note_trap_inner(thread, reason, trap_method, trap_bci, THREAD); |
e7e511228518
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
19266
diff
changeset
|
262 |
} |
e7e511228518
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
19266
diff
changeset
|
263 |
|
e7e511228518
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
19266
diff
changeset
|
264 |
#ifdef CC_INTERP |
e7e511228518
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
19266
diff
changeset
|
265 |
// As legacy note_trap, but we have more arguments. |
e7e511228518
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
19266
diff
changeset
|
266 |
IRT_ENTRY(void, InterpreterRuntime::note_trap(JavaThread* thread, int reason, Method *method, int trap_bci)) |
e7e511228518
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
19266
diff
changeset
|
267 |
methodHandle trap_method(method); |
e7e511228518
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
19266
diff
changeset
|
268 |
note_trap_inner(thread, reason, trap_method, trap_bci, THREAD); |
e7e511228518
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
19266
diff
changeset
|
269 |
IRT_END |
e7e511228518
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
19266
diff
changeset
|
270 |
|
e7e511228518
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
19266
diff
changeset
|
271 |
// Class Deoptimization is not visible in BytecodeInterpreter, so we need a wrapper |
e7e511228518
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
19266
diff
changeset
|
272 |
// for each exception. |
e7e511228518
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
19266
diff
changeset
|
273 |
void InterpreterRuntime::note_nullCheck_trap(JavaThread* thread, Method *method, int trap_bci) |
e7e511228518
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
19266
diff
changeset
|
274 |
{ if (ProfileTraps) note_trap(thread, Deoptimization::Reason_null_check, method, trap_bci); } |
e7e511228518
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
19266
diff
changeset
|
275 |
void InterpreterRuntime::note_div0Check_trap(JavaThread* thread, Method *method, int trap_bci) |
e7e511228518
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
19266
diff
changeset
|
276 |
{ if (ProfileTraps) note_trap(thread, Deoptimization::Reason_div0_check, method, trap_bci); } |
e7e511228518
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
19266
diff
changeset
|
277 |
void InterpreterRuntime::note_rangeCheck_trap(JavaThread* thread, Method *method, int trap_bci) |
e7e511228518
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
19266
diff
changeset
|
278 |
{ if (ProfileTraps) note_trap(thread, Deoptimization::Reason_range_check, method, trap_bci); } |
e7e511228518
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
19266
diff
changeset
|
279 |
void InterpreterRuntime::note_classCheck_trap(JavaThread* thread, Method *method, int trap_bci) |
e7e511228518
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
19266
diff
changeset
|
280 |
{ if (ProfileTraps) note_trap(thread, Deoptimization::Reason_class_check, method, trap_bci); } |
e7e511228518
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
19266
diff
changeset
|
281 |
void InterpreterRuntime::note_arrayCheck_trap(JavaThread* thread, Method *method, int trap_bci) |
e7e511228518
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
19266
diff
changeset
|
282 |
{ if (ProfileTraps) note_trap(thread, Deoptimization::Reason_array_check, method, trap_bci); } |
e7e511228518
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
19266
diff
changeset
|
283 |
#endif // CC_INTERP |
e7e511228518
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
19266
diff
changeset
|
284 |
|
e7e511228518
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
19266
diff
changeset
|
285 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
286 |
static Handle get_preinitialized_exception(Klass* k, TRAPS) { |
1 | 287 |
// get klass |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
288 |
InstanceKlass* klass = InstanceKlass::cast(k); |
1 | 289 |
assert(klass->is_initialized(), |
290 |
"this klass should have been initialized during VM initialization"); |
|
291 |
// create instance - do not call constructor since we may have no |
|
292 |
// (java) stack space left (should assert constructor is empty) |
|
293 |
Handle exception; |
|
294 |
oop exception_oop = klass->allocate_instance(CHECK_(exception)); |
|
295 |
exception = Handle(THREAD, exception_oop); |
|
296 |
if (StackTraceInThrowable) { |
|
297 |
java_lang_Throwable::fill_in_stack_trace(exception); |
|
298 |
} |
|
299 |
return exception; |
|
300 |
} |
|
301 |
||
302 |
// Special handling for stack overflow: since we don't have any (java) stack |
|
303 |
// space left we use the pre-allocated & pre-initialized StackOverflowError |
|
304 |
// klass to create an stack overflow error instance. We do not call its |
|
305 |
// constructor for the same reason (it is empty, anyway). |
|
306 |
IRT_ENTRY(void, InterpreterRuntime::throw_StackOverflowError(JavaThread* thread)) |
|
307 |
Handle exception = get_preinitialized_exception( |
|
308 |
SystemDictionary::StackOverflowError_klass(), |
|
309 |
CHECK); |
|
310 |
THROW_HANDLE(exception); |
|
311 |
IRT_END |
|
312 |
||
313 |
||
314 |
IRT_ENTRY(void, InterpreterRuntime::create_exception(JavaThread* thread, char* name, char* message)) |
|
315 |
// lookup exception klass |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7915
diff
changeset
|
316 |
TempNewSymbol s = SymbolTable::new_symbol(name, CHECK); |
1 | 317 |
if (ProfileTraps) { |
318 |
if (s == vmSymbols::java_lang_ArithmeticException()) { |
|
319 |
note_trap(thread, Deoptimization::Reason_div0_check, CHECK); |
|
320 |
} else if (s == vmSymbols::java_lang_NullPointerException()) { |
|
321 |
note_trap(thread, Deoptimization::Reason_null_check, CHECK); |
|
322 |
} |
|
323 |
} |
|
324 |
// create exception |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7915
diff
changeset
|
325 |
Handle exception = Exceptions::new_exception(thread, s, message); |
1 | 326 |
thread->set_vm_result(exception()); |
327 |
IRT_END |
|
328 |
||
329 |
||
330 |
IRT_ENTRY(void, InterpreterRuntime::create_klass_exception(JavaThread* thread, char* name, oopDesc* obj)) |
|
331 |
ResourceMark rm(thread); |
|
14488 | 332 |
const char* klass_name = obj->klass()->external_name(); |
1 | 333 |
// lookup exception klass |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7915
diff
changeset
|
334 |
TempNewSymbol s = SymbolTable::new_symbol(name, CHECK); |
1 | 335 |
if (ProfileTraps) { |
336 |
note_trap(thread, Deoptimization::Reason_class_check, CHECK); |
|
337 |
} |
|
338 |
// create exception, with klass name as detail message |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7915
diff
changeset
|
339 |
Handle exception = Exceptions::new_exception(thread, s, klass_name); |
1 | 340 |
thread->set_vm_result(exception()); |
341 |
IRT_END |
|
342 |
||
343 |
||
344 |
IRT_ENTRY(void, InterpreterRuntime::throw_ArrayIndexOutOfBoundsException(JavaThread* thread, char* name, jint index)) |
|
345 |
char message[jintAsStringSize]; |
|
346 |
// lookup exception klass |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7915
diff
changeset
|
347 |
TempNewSymbol s = SymbolTable::new_symbol(name, CHECK); |
1 | 348 |
if (ProfileTraps) { |
349 |
note_trap(thread, Deoptimization::Reason_range_check, CHECK); |
|
350 |
} |
|
351 |
// create exception |
|
352 |
sprintf(message, "%d", index); |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7915
diff
changeset
|
353 |
THROW_MSG(s, message); |
1 | 354 |
IRT_END |
355 |
||
356 |
IRT_ENTRY(void, InterpreterRuntime::throw_ClassCastException( |
|
357 |
JavaThread* thread, oopDesc* obj)) |
|
358 |
||
359 |
ResourceMark rm(thread); |
|
360 |
char* message = SharedRuntime::generate_class_cast_message( |
|
14488 | 361 |
thread, obj->klass()->external_name()); |
1 | 362 |
|
363 |
if (ProfileTraps) { |
|
364 |
note_trap(thread, Deoptimization::Reason_class_check, CHECK); |
|
365 |
} |
|
366 |
||
367 |
// create exception |
|
368 |
THROW_MSG(vmSymbols::java_lang_ClassCastException(), message); |
|
369 |
IRT_END |
|
370 |
||
371 |
// exception_handler_for_exception(...) returns the continuation address, |
|
372 |
// the exception oop (via TLS) and sets the bci/bcp for the continuation. |
|
373 |
// The exception oop is returned to make sure it is preserved over GC (it |
|
374 |
// is only on the stack if the exception was thrown explicitly via athrow). |
|
375 |
// During this operation, the expression stack contains the values for the |
|
376 |
// bci where the exception happened. If the exception was propagated back |
|
377 |
// from a call, the expression stack contains the values for the bci at the |
|
378 |
// invoke w/o arguments (i.e., as if one were inside the call). |
|
379 |
IRT_ENTRY(address, InterpreterRuntime::exception_handler_for_exception(JavaThread* thread, oopDesc* exception)) |
|
380 |
||
381 |
Handle h_exception(thread, exception); |
|
382 |
methodHandle h_method (thread, method(thread)); |
|
383 |
constantPoolHandle h_constants(thread, h_method->constants()); |
|
384 |
bool should_repeat; |
|
385 |
int handler_bci; |
|
5882 | 386 |
int current_bci = bci(thread); |
1 | 387 |
|
28039
bf5a8340bf8a
6898462: The escape analysis with G1 cause crash assertion src/share/vm/runtime/vframeArray.cpp:94
roland
parents:
27420
diff
changeset
|
388 |
if (thread->frames_to_pop_failed_realloc() > 0) { |
bf5a8340bf8a
6898462: The escape analysis with G1 cause crash assertion src/share/vm/runtime/vframeArray.cpp:94
roland
parents:
27420
diff
changeset
|
389 |
// Allocation of scalar replaced object used in this frame |
bf5a8340bf8a
6898462: The escape analysis with G1 cause crash assertion src/share/vm/runtime/vframeArray.cpp:94
roland
parents:
27420
diff
changeset
|
390 |
// failed. Unconditionally pop the frame. |
bf5a8340bf8a
6898462: The escape analysis with G1 cause crash assertion src/share/vm/runtime/vframeArray.cpp:94
roland
parents:
27420
diff
changeset
|
391 |
thread->dec_frames_to_pop_failed_realloc(); |
bf5a8340bf8a
6898462: The escape analysis with G1 cause crash assertion src/share/vm/runtime/vframeArray.cpp:94
roland
parents:
27420
diff
changeset
|
392 |
thread->set_vm_result(h_exception()); |
bf5a8340bf8a
6898462: The escape analysis with G1 cause crash assertion src/share/vm/runtime/vframeArray.cpp:94
roland
parents:
27420
diff
changeset
|
393 |
// If the method is synchronized we already unlocked the monitor |
bf5a8340bf8a
6898462: The escape analysis with G1 cause crash assertion src/share/vm/runtime/vframeArray.cpp:94
roland
parents:
27420
diff
changeset
|
394 |
// during deoptimization so the interpreter needs to skip it when |
bf5a8340bf8a
6898462: The escape analysis with G1 cause crash assertion src/share/vm/runtime/vframeArray.cpp:94
roland
parents:
27420
diff
changeset
|
395 |
// the frame is popped. |
bf5a8340bf8a
6898462: The escape analysis with G1 cause crash assertion src/share/vm/runtime/vframeArray.cpp:94
roland
parents:
27420
diff
changeset
|
396 |
thread->set_do_not_unlock_if_synchronized(true); |
bf5a8340bf8a
6898462: The escape analysis with G1 cause crash assertion src/share/vm/runtime/vframeArray.cpp:94
roland
parents:
27420
diff
changeset
|
397 |
return Interpreter::remove_activation_entry(); |
bf5a8340bf8a
6898462: The escape analysis with G1 cause crash assertion src/share/vm/runtime/vframeArray.cpp:94
roland
parents:
27420
diff
changeset
|
398 |
} |
bf5a8340bf8a
6898462: The escape analysis with G1 cause crash assertion src/share/vm/runtime/vframeArray.cpp:94
roland
parents:
27420
diff
changeset
|
399 |
|
1 | 400 |
// Need to do this check first since when _do_not_unlock_if_synchronized |
401 |
// is set, we don't want to trigger any classloading which may make calls |
|
402 |
// into java, or surprisingly find a matching exception handler for bci 0 |
|
403 |
// since at this moment the method hasn't been "officially" entered yet. |
|
404 |
if (thread->do_not_unlock_if_synchronized()) { |
|
405 |
ResourceMark rm; |
|
406 |
assert(current_bci == 0, "bci isn't zero for do_not_unlock_if_synchronized"); |
|
407 |
thread->set_vm_result(exception); |
|
408 |
#ifdef CC_INTERP |
|
409 |
return (address) -1; |
|
410 |
#else |
|
411 |
return Interpreter::remove_activation_entry(); |
|
412 |
#endif |
|
413 |
} |
|
414 |
||
415 |
do { |
|
416 |
should_repeat = false; |
|
417 |
||
418 |
// assertions |
|
419 |
#ifdef ASSERT |
|
420 |
assert(h_exception.not_null(), "NULL exceptions should be handled by athrow"); |
|
421 |
assert(h_exception->is_oop(), "just checking"); |
|
422 |
// Check that exception is a subclass of Throwable, otherwise we have a VerifyError |
|
4571 | 423 |
if (!(h_exception->is_a(SystemDictionary::Throwable_klass()))) { |
1 | 424 |
if (ExitVMOnVerifyError) vm_exit(-1); |
425 |
ShouldNotReachHere(); |
|
426 |
} |
|
427 |
#endif |
|
428 |
||
429 |
// tracing |
|
430 |
if (TraceExceptions) { |
|
431 |
ResourceMark rm(thread); |
|
25624
b3bd733f04e9
8048933: -XX:+TraceExceptions output should include the message
coleenp
parents:
25351
diff
changeset
|
432 |
Symbol* message = java_lang_Throwable::detail_message(h_exception()); |
b3bd733f04e9
8048933: -XX:+TraceExceptions output should include the message
coleenp
parents:
25351
diff
changeset
|
433 |
ttyLocker ttyl; // Lock after getting the detail message |
b3bd733f04e9
8048933: -XX:+TraceExceptions output should include the message
coleenp
parents:
25351
diff
changeset
|
434 |
if (message != NULL) { |
b3bd733f04e9
8048933: -XX:+TraceExceptions output should include the message
coleenp
parents:
25351
diff
changeset
|
435 |
tty->print_cr("Exception <%s: %s> (" INTPTR_FORMAT ")", |
b3bd733f04e9
8048933: -XX:+TraceExceptions output should include the message
coleenp
parents:
25351
diff
changeset
|
436 |
h_exception->print_value_string(), message->as_C_string(), |
b3bd733f04e9
8048933: -XX:+TraceExceptions output should include the message
coleenp
parents:
25351
diff
changeset
|
437 |
(address)h_exception()); |
b3bd733f04e9
8048933: -XX:+TraceExceptions output should include the message
coleenp
parents:
25351
diff
changeset
|
438 |
} else { |
b3bd733f04e9
8048933: -XX:+TraceExceptions output should include the message
coleenp
parents:
25351
diff
changeset
|
439 |
tty->print_cr("Exception <%s> (" INTPTR_FORMAT ")", |
b3bd733f04e9
8048933: -XX:+TraceExceptions output should include the message
coleenp
parents:
25351
diff
changeset
|
440 |
h_exception->print_value_string(), |
b3bd733f04e9
8048933: -XX:+TraceExceptions output should include the message
coleenp
parents:
25351
diff
changeset
|
441 |
(address)h_exception()); |
b3bd733f04e9
8048933: -XX:+TraceExceptions output should include the message
coleenp
parents:
25351
diff
changeset
|
442 |
} |
1 | 443 |
tty->print_cr(" thrown in interpreter method <%s>", h_method->print_value_string()); |
444 |
tty->print_cr(" at bci %d for thread " INTPTR_FORMAT, current_bci, thread); |
|
445 |
} |
|
446 |
// Don't go paging in something which won't be used. |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
447 |
// else if (extable->length() == 0) { |
1 | 448 |
// // disabled for now - interpreter is not using shortcut yet |
449 |
// // (shortcut is not to call runtime if we have no exception handlers) |
|
450 |
// // warning("performance bug: should not call runtime if method has no exception handlers"); |
|
451 |
// } |
|
452 |
// for AbortVMOnException flag |
|
453 |
NOT_PRODUCT(Exceptions::debug_check_abort(h_exception)); |
|
454 |
||
455 |
// exception handler lookup |
|
456 |
KlassHandle h_klass(THREAD, h_exception->klass()); |
|
15109
088b1ea04490
8001341: SIGSEGV in methodOopDesc::fast_exception_handler_bci_for(KlassHandle,int,Thread*)+0x3e9.
jiangli
parents:
14626
diff
changeset
|
457 |
handler_bci = Method::fast_exception_handler_bci_for(h_method, h_klass, current_bci, THREAD); |
1 | 458 |
if (HAS_PENDING_EXCEPTION) { |
459 |
// We threw an exception while trying to find the exception handler. |
|
460 |
// Transfer the new exception to the exception handle which will |
|
461 |
// be set into thread local storage, and do another lookup for an |
|
462 |
// exception handler for this exception, this time starting at the |
|
463 |
// BCI of the exception handler which caused the exception to be |
|
464 |
// thrown (bug 4307310). |
|
465 |
h_exception = Handle(THREAD, PENDING_EXCEPTION); |
|
466 |
CLEAR_PENDING_EXCEPTION; |
|
467 |
if (handler_bci >= 0) { |
|
468 |
current_bci = handler_bci; |
|
469 |
should_repeat = true; |
|
470 |
} |
|
471 |
} |
|
472 |
} while (should_repeat == true); |
|
473 |
||
474 |
// notify JVMTI of an exception throw; JVMTI will detect if this is a first |
|
475 |
// time throw or a stack unwinding throw and accordingly notify the debugger |
|
4761
bdb7375a1fee
6902182: 4/4 Starting with jdwp agent should not incur performance penalty
dcubed
parents:
4571
diff
changeset
|
476 |
if (JvmtiExport::can_post_on_exceptions()) { |
1 | 477 |
JvmtiExport::post_exception_throw(thread, h_method(), bcp(thread), h_exception()); |
478 |
} |
|
479 |
||
480 |
#ifdef CC_INTERP |
|
481 |
address continuation = (address)(intptr_t) handler_bci; |
|
482 |
#else |
|
483 |
address continuation = NULL; |
|
484 |
#endif |
|
485 |
address handler_pc = NULL; |
|
486 |
if (handler_bci < 0 || !thread->reguard_stack((address) &continuation)) { |
|
487 |
// Forward exception to callee (leaving bci/bcp untouched) because (a) no |
|
488 |
// handler in this method, or (b) after a stack overflow there is not yet |
|
489 |
// enough stack space available to reprotect the stack. |
|
490 |
#ifndef CC_INTERP |
|
491 |
continuation = Interpreter::remove_activation_entry(); |
|
492 |
#endif |
|
493 |
// Count this for compilation purposes |
|
17000
11bf92e571a2
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
15109
diff
changeset
|
494 |
h_method->interpreter_throwout_increment(THREAD); |
1 | 495 |
} else { |
496 |
// handler in this method => change bci/bcp to handler bci/bcp and continue there |
|
497 |
handler_pc = h_method->code_base() + handler_bci; |
|
498 |
#ifndef CC_INTERP |
|
499 |
set_bcp_and_mdp(handler_pc, thread); |
|
500 |
continuation = Interpreter::dispatch_table(vtos)[*handler_pc]; |
|
501 |
#endif |
|
502 |
} |
|
503 |
// notify debugger of an exception catch |
|
504 |
// (this is good for exceptions caught in native methods as well) |
|
4761
bdb7375a1fee
6902182: 4/4 Starting with jdwp agent should not incur performance penalty
dcubed
parents:
4571
diff
changeset
|
505 |
if (JvmtiExport::can_post_on_exceptions()) { |
1 | 506 |
JvmtiExport::notice_unwind_due_to_exception(thread, h_method(), handler_pc, h_exception(), (handler_pc != NULL)); |
507 |
} |
|
508 |
||
509 |
thread->set_vm_result(h_exception()); |
|
510 |
return continuation; |
|
511 |
IRT_END |
|
512 |
||
513 |
||
514 |
IRT_ENTRY(void, InterpreterRuntime::throw_pending_exception(JavaThread* thread)) |
|
515 |
assert(thread->has_pending_exception(), "must only ne called if there's an exception pending"); |
|
516 |
// nothing to do - eventually we should remove this code entirely (see comments @ call sites) |
|
517 |
IRT_END |
|
518 |
||
519 |
||
520 |
IRT_ENTRY(void, InterpreterRuntime::throw_AbstractMethodError(JavaThread* thread)) |
|
521 |
THROW(vmSymbols::java_lang_AbstractMethodError()); |
|
522 |
IRT_END |
|
523 |
||
524 |
||
525 |
IRT_ENTRY(void, InterpreterRuntime::throw_IncompatibleClassChangeError(JavaThread* thread)) |
|
526 |
THROW(vmSymbols::java_lang_IncompatibleClassChangeError()); |
|
527 |
IRT_END |
|
528 |
||
529 |
||
530 |
//------------------------------------------------------------------------------------------------------------------------ |
|
531 |
// Fields |
|
532 |
// |
|
533 |
||
534 |
IRT_ENTRY(void, InterpreterRuntime::resolve_get_put(JavaThread* thread, Bytecodes::Code bytecode)) |
|
535 |
// resolve field |
|
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
19266
diff
changeset
|
536 |
fieldDescriptor info; |
1 | 537 |
constantPoolHandle pool(thread, method(thread)->constants()); |
10265
4c869854aebd
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
10014
diff
changeset
|
538 |
bool is_put = (bytecode == Bytecodes::_putfield || bytecode == Bytecodes::_putstatic); |
1 | 539 |
bool is_static = (bytecode == Bytecodes::_getstatic || bytecode == Bytecodes::_putstatic); |
540 |
||
541 |
{ |
|
542 |
JvmtiHideSingleStepping jhss(thread); |
|
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
19266
diff
changeset
|
543 |
LinkResolver::resolve_field_access(info, pool, get_index_u2_cpcache(thread, bytecode), |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
19266
diff
changeset
|
544 |
bytecode, CHECK); |
1 | 545 |
} // end JvmtiHideSingleStepping |
546 |
||
547 |
// check if link resolution caused cpCache to be updated |
|
548 |
if (already_resolved(thread)) return; |
|
549 |
||
550 |
// compute auxiliary field attributes |
|
551 |
TosState state = as_TosState(info.field_type()); |
|
552 |
||
553 |
// We need to delay resolving put instructions on final fields |
|
554 |
// until we actually invoke one. This is required so we throw |
|
555 |
// exceptions at the correct place. If we do not resolve completely |
|
556 |
// in the current pass, leaving the put_code set to zero will |
|
557 |
// cause the next put instruction to reresolve. |
|
558 |
Bytecodes::Code put_code = (Bytecodes::Code)0; |
|
559 |
||
560 |
// We also need to delay resolving getstatic instructions until the |
|
561 |
// class is intitialized. This is required so that access to the static |
|
562 |
// field will call the initialization function every time until the class |
|
563 |
// is completely initialized ala. in 2.17.5 in JVM Specification. |
|
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
19266
diff
changeset
|
564 |
InstanceKlass* klass = InstanceKlass::cast(info.field_holder()); |
1 | 565 |
bool uninitialized_static = ((bytecode == Bytecodes::_getstatic || bytecode == Bytecodes::_putstatic) && |
566 |
!klass->is_initialized()); |
|
567 |
Bytecodes::Code get_code = (Bytecodes::Code)0; |
|
568 |
||
569 |
if (!uninitialized_static) { |
|
570 |
get_code = ((is_static) ? Bytecodes::_getstatic : Bytecodes::_getfield); |
|
571 |
if (is_put || !info.access_flags().is_final()) { |
|
572 |
put_code = ((is_static) ? Bytecodes::_putstatic : Bytecodes::_putfield); |
|
573 |
} |
|
574 |
} |
|
575 |
||
576 |
cache_entry(thread)->set_field( |
|
577 |
get_code, |
|
578 |
put_code, |
|
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
19266
diff
changeset
|
579 |
info.field_holder(), |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
19266
diff
changeset
|
580 |
info.index(), |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
19266
diff
changeset
|
581 |
info.offset(), |
1 | 582 |
state, |
583 |
info.access_flags().is_final(), |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
584 |
info.access_flags().is_volatile(), |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
585 |
pool->pool_holder() |
1 | 586 |
); |
587 |
IRT_END |
|
588 |
||
589 |
||
590 |
//------------------------------------------------------------------------------------------------------------------------ |
|
591 |
// Synchronization |
|
592 |
// |
|
593 |
// The interpreter's synchronization code is factored out so that it can |
|
594 |
// be shared by method invocation and synchronized blocks. |
|
595 |
//%note synchronization_3 |
|
596 |
||
597 |
//%note monitor_1 |
|
598 |
IRT_ENTRY_NO_ASYNC(void, InterpreterRuntime::monitorenter(JavaThread* thread, BasicObjectLock* elem)) |
|
599 |
#ifdef ASSERT |
|
600 |
thread->last_frame().interpreter_frame_verify_monitor(elem); |
|
601 |
#endif |
|
602 |
if (PrintBiasedLockingStatistics) { |
|
603 |
Atomic::inc(BiasedLocking::slow_path_entry_count_addr()); |
|
604 |
} |
|
605 |
Handle h_obj(thread, elem->obj()); |
|
606 |
assert(Universe::heap()->is_in_reserved_or_null(h_obj()), |
|
607 |
"must be NULL or an object"); |
|
608 |
if (UseBiasedLocking) { |
|
609 |
// Retry fast entry if bias is revoked to avoid unnecessary inflation |
|
610 |
ObjectSynchronizer::fast_enter(h_obj, elem->lock(), true, CHECK); |
|
611 |
} else { |
|
612 |
ObjectSynchronizer::slow_enter(h_obj, elem->lock(), CHECK); |
|
613 |
} |
|
614 |
assert(Universe::heap()->is_in_reserved_or_null(elem->obj()), |
|
615 |
"must be NULL or an object"); |
|
616 |
#ifdef ASSERT |
|
617 |
thread->last_frame().interpreter_frame_verify_monitor(elem); |
|
618 |
#endif |
|
619 |
IRT_END |
|
620 |
||
621 |
||
622 |
//%note monitor_1 |
|
623 |
IRT_ENTRY_NO_ASYNC(void, InterpreterRuntime::monitorexit(JavaThread* thread, BasicObjectLock* elem)) |
|
624 |
#ifdef ASSERT |
|
625 |
thread->last_frame().interpreter_frame_verify_monitor(elem); |
|
626 |
#endif |
|
627 |
Handle h_obj(thread, elem->obj()); |
|
628 |
assert(Universe::heap()->is_in_reserved_or_null(h_obj()), |
|
629 |
"must be NULL or an object"); |
|
630 |
if (elem == NULL || h_obj()->is_unlocked()) { |
|
631 |
THROW(vmSymbols::java_lang_IllegalMonitorStateException()); |
|
632 |
} |
|
633 |
ObjectSynchronizer::slow_exit(h_obj(), elem->lock(), thread); |
|
634 |
// Free entry. This must be done here, since a pending exception might be installed on |
|
635 |
// exit. If it is not cleared, the exception handling code will try to unlock the monitor again. |
|
636 |
elem->set_obj(NULL); |
|
637 |
#ifdef ASSERT |
|
638 |
thread->last_frame().interpreter_frame_verify_monitor(elem); |
|
639 |
#endif |
|
640 |
IRT_END |
|
641 |
||
642 |
||
643 |
IRT_ENTRY(void, InterpreterRuntime::throw_illegal_monitor_state_exception(JavaThread* thread)) |
|
644 |
THROW(vmSymbols::java_lang_IllegalMonitorStateException()); |
|
645 |
IRT_END |
|
646 |
||
647 |
||
648 |
IRT_ENTRY(void, InterpreterRuntime::new_illegal_monitor_state_exception(JavaThread* thread)) |
|
649 |
// Returns an illegal exception to install into the current thread. The |
|
650 |
// pending_exception flag is cleared so normal exception handling does not |
|
651 |
// trigger. Any current installed exception will be overwritten. This |
|
652 |
// method will be called during an exception unwind. |
|
653 |
||
654 |
assert(!HAS_PENDING_EXCEPTION, "no pending exception"); |
|
655 |
Handle exception(thread, thread->vm_result()); |
|
656 |
assert(exception() != NULL, "vm result should be set"); |
|
657 |
thread->set_vm_result(NULL); // clear vm result before continuing (may cause memory leaks and assert failures) |
|
4571 | 658 |
if (!exception->is_a(SystemDictionary::ThreadDeath_klass())) { |
1 | 659 |
exception = get_preinitialized_exception( |
660 |
SystemDictionary::IllegalMonitorStateException_klass(), |
|
661 |
CATCH); |
|
662 |
} |
|
663 |
thread->set_vm_result(exception()); |
|
664 |
IRT_END |
|
665 |
||
666 |
||
667 |
//------------------------------------------------------------------------------------------------------------------------ |
|
668 |
// Invokes |
|
669 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
670 |
IRT_ENTRY(Bytecodes::Code, InterpreterRuntime::get_original_bytecode_at(JavaThread* thread, Method* method, address bcp)) |
1 | 671 |
return method->orig_bytecode_at(method->bci_from(bcp)); |
672 |
IRT_END |
|
673 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
674 |
IRT_ENTRY(void, InterpreterRuntime::set_original_bytecode_at(JavaThread* thread, Method* method, address bcp, Bytecodes::Code new_code)) |
1 | 675 |
method->set_orig_bytecode_at(method->bci_from(bcp), new_code); |
676 |
IRT_END |
|
677 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
678 |
IRT_ENTRY(void, InterpreterRuntime::_breakpoint(JavaThread* thread, Method* method, address bcp)) |
1 | 679 |
JvmtiExport::post_raw_breakpoint(thread, method, bcp); |
680 |
IRT_END |
|
681 |
||
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
13296
diff
changeset
|
682 |
IRT_ENTRY(void, InterpreterRuntime::resolve_invoke(JavaThread* thread, Bytecodes::Code bytecode)) { |
1 | 683 |
// extract receiver from the outgoing argument list if necessary |
684 |
Handle receiver(thread, NULL); |
|
685 |
if (bytecode == Bytecodes::_invokevirtual || bytecode == Bytecodes::_invokeinterface) { |
|
686 |
ResourceMark rm(thread); |
|
687 |
methodHandle m (thread, method(thread)); |
|
7913 | 688 |
Bytecode_invoke call(m, bci(thread)); |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7915
diff
changeset
|
689 |
Symbol* signature = call.signature(); |
1 | 690 |
receiver = Handle(thread, |
691 |
thread->last_frame().interpreter_callee_receiver(signature)); |
|
692 |
assert(Universe::heap()->is_in_reserved_or_null(receiver()), |
|
693 |
"sanity check"); |
|
694 |
assert(receiver.is_null() || |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
695 |
!Universe::heap()->is_in_reserved(receiver->klass()), |
1 | 696 |
"sanity check"); |
697 |
} |
|
698 |
||
699 |
// resolve method |
|
700 |
CallInfo info; |
|
701 |
constantPoolHandle pool(thread, method(thread)->constants()); |
|
702 |
||
703 |
{ |
|
704 |
JvmtiHideSingleStepping jhss(thread); |
|
705 |
LinkResolver::resolve_invoke(info, receiver, pool, |
|
5688 | 706 |
get_index_u2_cpcache(thread, bytecode), bytecode, CHECK); |
1 | 707 |
if (JvmtiExport::can_hotswap_or_post_breakpoint()) { |
708 |
int retry_count = 0; |
|
709 |
while (info.resolved_method()->is_old()) { |
|
710 |
// It is very unlikely that method is redefined more than 100 times |
|
711 |
// in the middle of resolve. If it is looping here more than 100 times |
|
712 |
// means then there could be a bug here. |
|
713 |
guarantee((retry_count++ < 100), |
|
714 |
"Could not resolve to latest version of redefined method"); |
|
715 |
// method is redefined in the middle of resolve so re-try. |
|
716 |
LinkResolver::resolve_invoke(info, receiver, pool, |
|
5688 | 717 |
get_index_u2_cpcache(thread, bytecode), bytecode, CHECK); |
1 | 718 |
} |
719 |
} |
|
720 |
} // end JvmtiHideSingleStepping |
|
721 |
||
722 |
// check if link resolution caused cpCache to be updated |
|
723 |
if (already_resolved(thread)) return; |
|
724 |
||
725 |
if (bytecode == Bytecodes::_invokeinterface) { |
|
726 |
if (TraceItables && Verbose) { |
|
727 |
ResourceMark rm(thread); |
|
728 |
tty->print_cr("Resolving: klass: %s to method: %s", info.resolved_klass()->name()->as_C_string(), info.resolved_method()->name()->as_C_string()); |
|
729 |
} |
|
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
19266
diff
changeset
|
730 |
} |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
19266
diff
changeset
|
731 |
#ifdef ASSERT |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
19266
diff
changeset
|
732 |
if (bytecode == Bytecodes::_invokeinterface) { |
1 | 733 |
if (info.resolved_method()->method_holder() == |
4571 | 734 |
SystemDictionary::Object_klass()) { |
1 | 735 |
// NOTE: THIS IS A FIX FOR A CORNER CASE in the JVM spec |
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
19266
diff
changeset
|
736 |
// (see also CallInfo::set_interface for details) |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
19266
diff
changeset
|
737 |
assert(info.call_kind() == CallInfo::vtable_call || |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
19266
diff
changeset
|
738 |
info.call_kind() == CallInfo::direct_call, ""); |
1 | 739 |
methodHandle rm = info.resolved_method(); |
740 |
assert(rm->is_final() || info.has_vtable_index(), |
|
741 |
"should have been set already"); |
|
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
19266
diff
changeset
|
742 |
} else if (!info.resolved_method()->has_itable_index()) { |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
19266
diff
changeset
|
743 |
// Resolved something like CharSequence.toString. Use vtable not itable. |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
19266
diff
changeset
|
744 |
assert(info.call_kind() != CallInfo::itable_call, ""); |
1 | 745 |
} else { |
746 |
// Setup itable entry |
|
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
19266
diff
changeset
|
747 |
assert(info.call_kind() == CallInfo::itable_call, ""); |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
19266
diff
changeset
|
748 |
int index = info.resolved_method()->itable_index(); |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
19266
diff
changeset
|
749 |
assert(info.itable_index() == index, ""); |
1 | 750 |
} |
751 |
} else { |
|
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
19266
diff
changeset
|
752 |
assert(info.call_kind() == CallInfo::direct_call || |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
19266
diff
changeset
|
753 |
info.call_kind() == CallInfo::vtable_call, ""); |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
19266
diff
changeset
|
754 |
} |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
19266
diff
changeset
|
755 |
#endif |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
19266
diff
changeset
|
756 |
switch (info.call_kind()) { |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
19266
diff
changeset
|
757 |
case CallInfo::direct_call: |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
19266
diff
changeset
|
758 |
cache_entry(thread)->set_direct_call( |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
19266
diff
changeset
|
759 |
bytecode, |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
19266
diff
changeset
|
760 |
info.resolved_method()); |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
19266
diff
changeset
|
761 |
break; |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
19266
diff
changeset
|
762 |
case CallInfo::vtable_call: |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
19266
diff
changeset
|
763 |
cache_entry(thread)->set_vtable_call( |
1 | 764 |
bytecode, |
765 |
info.resolved_method(), |
|
766 |
info.vtable_index()); |
|
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
19266
diff
changeset
|
767 |
break; |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
19266
diff
changeset
|
768 |
case CallInfo::itable_call: |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
19266
diff
changeset
|
769 |
cache_entry(thread)->set_itable_call( |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
19266
diff
changeset
|
770 |
bytecode, |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
19266
diff
changeset
|
771 |
info.resolved_method(), |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
19266
diff
changeset
|
772 |
info.itable_index()); |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
19266
diff
changeset
|
773 |
break; |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
19266
diff
changeset
|
774 |
default: ShouldNotReachHere(); |
1 | 775 |
} |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
13296
diff
changeset
|
776 |
} |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
13296
diff
changeset
|
777 |
IRT_END |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
13296
diff
changeset
|
778 |
|
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
13296
diff
changeset
|
779 |
|
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
13296
diff
changeset
|
780 |
// First time execution: Resolve symbols, create a permanent MethodType object. |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
13296
diff
changeset
|
781 |
IRT_ENTRY(void, InterpreterRuntime::resolve_invokehandle(JavaThread* thread)) { |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
13296
diff
changeset
|
782 |
const Bytecodes::Code bytecode = Bytecodes::_invokehandle; |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
13296
diff
changeset
|
783 |
|
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
13296
diff
changeset
|
784 |
// resolve method |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
13296
diff
changeset
|
785 |
CallInfo info; |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
13296
diff
changeset
|
786 |
constantPoolHandle pool(thread, method(thread)->constants()); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
13296
diff
changeset
|
787 |
|
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
13296
diff
changeset
|
788 |
{ |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
13296
diff
changeset
|
789 |
JvmtiHideSingleStepping jhss(thread); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
13296
diff
changeset
|
790 |
LinkResolver::resolve_invoke(info, Handle(), pool, |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
13296
diff
changeset
|
791 |
get_index_u2_cpcache(thread, bytecode), bytecode, CHECK); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
13296
diff
changeset
|
792 |
} // end JvmtiHideSingleStepping |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
13296
diff
changeset
|
793 |
|
14393
93a4dcdbebfd
8001658: No need to pass resolved_references as argument to ConstantPoolCacheEntry::set_method_handle_common
twisti
parents:
13961
diff
changeset
|
794 |
cache_entry(thread)->set_method_handle(pool, info); |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
13296
diff
changeset
|
795 |
} |
1 | 796 |
IRT_END |
797 |
||
798 |
||
4429
d7eb4e2099aa
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
3696
diff
changeset
|
799 |
// First time execution: Resolve symbols, create a permanent CallSite object. |
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2534
diff
changeset
|
800 |
IRT_ENTRY(void, InterpreterRuntime::resolve_invokedynamic(JavaThread* thread)) { |
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2534
diff
changeset
|
801 |
const Bytecodes::Code bytecode = Bytecodes::_invokedynamic; |
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2534
diff
changeset
|
802 |
|
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
13296
diff
changeset
|
803 |
//TO DO: consider passing BCI to Java. |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
13296
diff
changeset
|
804 |
// int caller_bci = method(thread)->bci_from(bcp(thread)); |
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2534
diff
changeset
|
805 |
|
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
13296
diff
changeset
|
806 |
// resolve method |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
13296
diff
changeset
|
807 |
CallInfo info; |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
13296
diff
changeset
|
808 |
constantPoolHandle pool(thread, method(thread)->constants()); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
13296
diff
changeset
|
809 |
int index = get_index_u4(thread, bytecode); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
13296
diff
changeset
|
810 |
{ |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
13296
diff
changeset
|
811 |
JvmtiHideSingleStepping jhss(thread); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
13296
diff
changeset
|
812 |
LinkResolver::resolve_invoke(info, Handle(), pool, |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
13296
diff
changeset
|
813 |
index, bytecode, CHECK); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
13296
diff
changeset
|
814 |
} // end JvmtiHideSingleStepping |
6062
bab93afe9df7
6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
5883
diff
changeset
|
815 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
816 |
ConstantPoolCacheEntry* cp_cache_entry = pool->invokedynamic_cp_cache_entry_at(index); |
14393
93a4dcdbebfd
8001658: No need to pass resolved_references as argument to ConstantPoolCacheEntry::set_method_handle_common
twisti
parents:
13961
diff
changeset
|
817 |
cp_cache_entry->set_dynamic_call(pool, info); |
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2534
diff
changeset
|
818 |
} |
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2534
diff
changeset
|
819 |
IRT_END |
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2534
diff
changeset
|
820 |
|
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2534
diff
changeset
|
821 |
|
1 | 822 |
//------------------------------------------------------------------------------------------------------------------------ |
823 |
// Miscellaneous |
|
824 |
||
825 |
||
3696 | 826 |
nmethod* InterpreterRuntime::frequency_counter_overflow(JavaThread* thread, address branch_bcp) { |
827 |
nmethod* nm = frequency_counter_overflow_inner(thread, branch_bcp); |
|
828 |
assert(branch_bcp != NULL || nm == NULL, "always returns null for non OSR requests"); |
|
829 |
if (branch_bcp != NULL && nm != NULL) { |
|
830 |
// This was a successful request for an OSR nmethod. Because |
|
831 |
// frequency_counter_overflow_inner ends with a safepoint check, |
|
832 |
// nm could have been unloaded so look it up again. It's unsafe |
|
833 |
// to examine nm directly since it might have been freed and used |
|
834 |
// for something else. |
|
835 |
frame fr = thread->last_frame(); |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
836 |
Method* method = fr.interpreter_frame_method(); |
3696 | 837 |
int bci = method->bci_from(fr.interpreter_frame_bcp()); |
6453 | 838 |
nm = method->lookup_osr_nmethod_for(bci, CompLevel_none, false); |
3696 | 839 |
} |
12959
4d33f9be7e87
7174928: JSR 292: unresolved invokedynamic call sites deopt and osr infinitely
twisti
parents:
11572
diff
changeset
|
840 |
#ifndef PRODUCT |
4d33f9be7e87
7174928: JSR 292: unresolved invokedynamic call sites deopt and osr infinitely
twisti
parents:
11572
diff
changeset
|
841 |
if (TraceOnStackReplacement) { |
4d33f9be7e87
7174928: JSR 292: unresolved invokedynamic call sites deopt and osr infinitely
twisti
parents:
11572
diff
changeset
|
842 |
if (nm != NULL) { |
4d33f9be7e87
7174928: JSR 292: unresolved invokedynamic call sites deopt and osr infinitely
twisti
parents:
11572
diff
changeset
|
843 |
tty->print("OSR entry @ pc: " INTPTR_FORMAT ": ", nm->osr_entry()); |
4d33f9be7e87
7174928: JSR 292: unresolved invokedynamic call sites deopt and osr infinitely
twisti
parents:
11572
diff
changeset
|
844 |
nm->print(); |
4d33f9be7e87
7174928: JSR 292: unresolved invokedynamic call sites deopt and osr infinitely
twisti
parents:
11572
diff
changeset
|
845 |
} |
4d33f9be7e87
7174928: JSR 292: unresolved invokedynamic call sites deopt and osr infinitely
twisti
parents:
11572
diff
changeset
|
846 |
} |
4d33f9be7e87
7174928: JSR 292: unresolved invokedynamic call sites deopt and osr infinitely
twisti
parents:
11572
diff
changeset
|
847 |
#endif |
3696 | 848 |
return nm; |
849 |
} |
|
850 |
||
1 | 851 |
IRT_ENTRY(nmethod*, |
3696 | 852 |
InterpreterRuntime::frequency_counter_overflow_inner(JavaThread* thread, address branch_bcp)) |
1 | 853 |
// use UnlockFlagSaver to clear and restore the _do_not_unlock_if_synchronized |
854 |
// flag, in case this method triggers classloading which will call into Java. |
|
855 |
UnlockFlagSaver fs(thread); |
|
856 |
||
857 |
frame fr = thread->last_frame(); |
|
858 |
assert(fr.is_interpreted_frame(), "must come from interpreter"); |
|
859 |
methodHandle method(thread, fr.interpreter_frame_method()); |
|
6453 | 860 |
const int branch_bci = branch_bcp != NULL ? method->bci_from(branch_bcp) : InvocationEntryBci; |
861 |
const int bci = branch_bcp != NULL ? method->bci_from(fr.interpreter_frame_bcp()) : InvocationEntryBci; |
|
862 |
||
11572
84afef481892
7131259: compile_method and CompilationPolicy::event shouldn't be declared TRAPS
iveresov
parents:
10967
diff
changeset
|
863 |
assert(!HAS_PENDING_EXCEPTION, "Should not have any exceptions pending"); |
10014
a5c2141ee857
7057120: Tiered: Allow C1 to inline methods with loops
iveresov
parents:
10004
diff
changeset
|
864 |
nmethod* osr_nm = CompilationPolicy::policy()->event(method, method, branch_bci, bci, CompLevel_none, NULL, thread); |
11572
84afef481892
7131259: compile_method and CompilationPolicy::event shouldn't be declared TRAPS
iveresov
parents:
10967
diff
changeset
|
865 |
assert(!HAS_PENDING_EXCEPTION, "Event handler should not throw any exceptions"); |
1 | 866 |
|
6453 | 867 |
if (osr_nm != NULL) { |
868 |
// We may need to do on-stack replacement which requires that no |
|
869 |
// monitors in the activation are biased because their |
|
870 |
// BasicObjectLocks will need to migrate during OSR. Force |
|
871 |
// unbiasing of all monitors in the activation now (even though |
|
872 |
// the OSR nmethod might be invalidated) because we don't have a |
|
873 |
// safepoint opportunity later once the migration begins. |
|
874 |
if (UseBiasedLocking) { |
|
875 |
ResourceMark rm; |
|
876 |
GrowableArray<Handle>* objects_to_revoke = new GrowableArray<Handle>(); |
|
877 |
for( BasicObjectLock *kptr = fr.interpreter_frame_monitor_end(); |
|
878 |
kptr < fr.interpreter_frame_monitor_begin(); |
|
879 |
kptr = fr.next_monitor_in_interpreter_frame(kptr) ) { |
|
880 |
if( kptr->obj() != NULL ) { |
|
881 |
objects_to_revoke->append(Handle(THREAD, kptr->obj())); |
|
882 |
} |
|
1 | 883 |
} |
6453 | 884 |
BiasedLocking::revoke(objects_to_revoke); |
1 | 885 |
} |
886 |
} |
|
6453 | 887 |
return osr_nm; |
1 | 888 |
IRT_END |
889 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
890 |
IRT_LEAF(jint, InterpreterRuntime::bcp_to_di(Method* method, address cur_bcp)) |
1 | 891 |
assert(ProfileInterpreter, "must be profiling interpreter"); |
892 |
int bci = method->bci_from(cur_bcp); |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
893 |
MethodData* mdo = method->method_data(); |
1 | 894 |
if (mdo == NULL) return 0; |
895 |
return mdo->bci_to_di(bci); |
|
896 |
IRT_END |
|
897 |
||
7889
02144432d0e1
4930919: race condition in MDO creation at back branch locations
iveresov
parents:
7411
diff
changeset
|
898 |
IRT_ENTRY(void, InterpreterRuntime::profile_method(JavaThread* thread)) |
1 | 899 |
// use UnlockFlagSaver to clear and restore the _do_not_unlock_if_synchronized |
900 |
// flag, in case this method triggers classloading which will call into Java. |
|
901 |
UnlockFlagSaver fs(thread); |
|
902 |
||
903 |
assert(ProfileInterpreter, "must be profiling interpreter"); |
|
904 |
frame fr = thread->last_frame(); |
|
905 |
assert(fr.is_interpreted_frame(), "must come from interpreter"); |
|
906 |
methodHandle method(thread, fr.interpreter_frame_method()); |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
907 |
Method::build_interpreter_method_data(method, THREAD); |
1 | 908 |
if (HAS_PENDING_EXCEPTION) { |
909 |
assert((PENDING_EXCEPTION->is_a(SystemDictionary::OutOfMemoryError_klass())), "we expect only an OOM error here"); |
|
910 |
CLEAR_PENDING_EXCEPTION; |
|
911 |
// and fall through... |
|
912 |
} |
|
913 |
IRT_END |
|
914 |
||
915 |
||
916 |
#ifdef ASSERT |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
917 |
IRT_LEAF(void, InterpreterRuntime::verify_mdp(Method* method, address bcp, address mdp)) |
1 | 918 |
assert(ProfileInterpreter, "must be profiling interpreter"); |
919 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
920 |
MethodData* mdo = method->method_data(); |
1 | 921 |
assert(mdo != NULL, "must not be null"); |
922 |
||
923 |
int bci = method->bci_from(bcp); |
|
924 |
||
925 |
address mdp2 = mdo->bci_to_dp(bci); |
|
926 |
if (mdp != mdp2) { |
|
927 |
ResourceMark rm; |
|
928 |
ResetNoHandleMark rnm; // In a LEAF entry. |
|
929 |
HandleMark hm; |
|
930 |
tty->print_cr("FAILED verify : actual mdp %p expected mdp %p @ bci %d", mdp, mdp2, bci); |
|
931 |
int current_di = mdo->dp_to_di(mdp); |
|
932 |
int expected_di = mdo->dp_to_di(mdp2); |
|
933 |
tty->print_cr(" actual di %d expected di %d", current_di, expected_di); |
|
934 |
int expected_approx_bci = mdo->data_at(expected_di)->bci(); |
|
935 |
int approx_bci = -1; |
|
936 |
if (current_di >= 0) { |
|
937 |
approx_bci = mdo->data_at(current_di)->bci(); |
|
938 |
} |
|
939 |
tty->print_cr(" actual bci is %d expected bci %d", approx_bci, expected_approx_bci); |
|
940 |
mdo->print_on(tty); |
|
941 |
method->print_codes(); |
|
942 |
} |
|
943 |
assert(mdp == mdp2, "wrong mdp"); |
|
944 |
IRT_END |
|
945 |
#endif // ASSERT |
|
946 |
||
947 |
IRT_ENTRY(void, InterpreterRuntime::update_mdp_for_ret(JavaThread* thread, int return_bci)) |
|
948 |
assert(ProfileInterpreter, "must be profiling interpreter"); |
|
949 |
ResourceMark rm(thread); |
|
950 |
HandleMark hm(thread); |
|
951 |
frame fr = thread->last_frame(); |
|
952 |
assert(fr.is_interpreted_frame(), "must come from interpreter"); |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
953 |
MethodData* h_mdo = fr.interpreter_frame_method()->method_data(); |
1 | 954 |
|
955 |
// Grab a lock to ensure atomic access to setting the return bci and |
|
956 |
// the displacement. This can block and GC, invalidating all naked oops. |
|
957 |
MutexLocker ml(RetData_lock); |
|
958 |
||
959 |
// ProfileData is essentially a wrapper around a derived oop, so we |
|
960 |
// need to take the lock before making any ProfileData structures. |
|
961 |
ProfileData* data = h_mdo->data_at(h_mdo->dp_to_di(fr.interpreter_frame_mdp())); |
|
962 |
RetData* rdata = data->as_RetData(); |
|
963 |
address new_mdp = rdata->fixup_ret(return_bci, h_mdo); |
|
964 |
fr.interpreter_frame_set_mdp(new_mdp); |
|
965 |
IRT_END |
|
966 |
||
17000
11bf92e571a2
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
15109
diff
changeset
|
967 |
IRT_ENTRY(MethodCounters*, InterpreterRuntime::build_method_counters(JavaThread* thread, Method* m)) |
11bf92e571a2
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
15109
diff
changeset
|
968 |
MethodCounters* mcs = Method::build_method_counters(m, thread); |
11bf92e571a2
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
15109
diff
changeset
|
969 |
if (HAS_PENDING_EXCEPTION) { |
11bf92e571a2
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
15109
diff
changeset
|
970 |
assert((PENDING_EXCEPTION->is_a(SystemDictionary::OutOfMemoryError_klass())), "we expect only an OOM error here"); |
11bf92e571a2
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
15109
diff
changeset
|
971 |
CLEAR_PENDING_EXCEPTION; |
11bf92e571a2
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
15109
diff
changeset
|
972 |
} |
11bf92e571a2
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
15109
diff
changeset
|
973 |
return mcs; |
11bf92e571a2
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
15109
diff
changeset
|
974 |
IRT_END |
11bf92e571a2
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
15109
diff
changeset
|
975 |
|
1 | 976 |
|
977 |
IRT_ENTRY(void, InterpreterRuntime::at_safepoint(JavaThread* thread)) |
|
978 |
// We used to need an explict preserve_arguments here for invoke bytecodes. However, |
|
979 |
// stack traversal automatically takes care of preserving arguments for invoke, so |
|
980 |
// this is no longer needed. |
|
981 |
||
982 |
// IRT_END does an implicit safepoint check, hence we are guaranteed to block |
|
983 |
// if this is called during a safepoint |
|
984 |
||
985 |
if (JvmtiExport::should_post_single_step()) { |
|
986 |
// We are called during regular safepoints and when the VM is |
|
987 |
// single stepping. If any thread is marked for single stepping, |
|
988 |
// then we may have JVMTI work to do. |
|
989 |
JvmtiExport::at_single_stepping_point(thread, method(thread), bcp(thread)); |
|
990 |
} |
|
991 |
IRT_END |
|
992 |
||
993 |
IRT_ENTRY(void, InterpreterRuntime::post_field_access(JavaThread *thread, oopDesc* obj, |
|
994 |
ConstantPoolCacheEntry *cp_entry)) |
|
995 |
||
996 |
// check the access_flags for the field in the klass |
|
8725
8c1e3dd5fe1b
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
8676
diff
changeset
|
997 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
998 |
InstanceKlass* ik = InstanceKlass::cast(cp_entry->f1_as_klass()); |
1 | 999 |
int index = cp_entry->field_index(); |
10546 | 1000 |
if ((ik->field_access_flags(index) & JVM_ACC_FIELD_ACCESS_WATCHED) == 0) return; |
1 | 1001 |
|
1002 |
bool is_static = (obj == NULL); |
|
1003 |
HandleMark hm(thread); |
|
1004 |
||
1005 |
Handle h_obj; |
|
1006 |
if (!is_static) { |
|
1007 |
// non-static field accessors have an object, but we need a handle |
|
1008 |
h_obj = Handle(thread, obj); |
|
1009 |
} |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
1010 |
instanceKlassHandle h_cp_entry_f1(thread, (Klass*)cp_entry->f1_as_klass()); |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
13296
diff
changeset
|
1011 |
jfieldID fid = jfieldIDWorkaround::to_jfieldID(h_cp_entry_f1, cp_entry->f2_as_index(), is_static); |
1 | 1012 |
JvmtiExport::post_field_access(thread, method(thread), bcp(thread), h_cp_entry_f1, h_obj, fid); |
1013 |
IRT_END |
|
1014 |
||
1015 |
IRT_ENTRY(void, InterpreterRuntime::post_field_modification(JavaThread *thread, |
|
1016 |
oopDesc* obj, ConstantPoolCacheEntry *cp_entry, jvalue *value)) |
|
1017 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
1018 |
Klass* k = (Klass*)cp_entry->f1_as_klass(); |
1 | 1019 |
|
1020 |
// check the access_flags for the field in the klass |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
1021 |
InstanceKlass* ik = InstanceKlass::cast(k); |
1 | 1022 |
int index = cp_entry->field_index(); |
1023 |
// bail out if field modifications are not watched |
|
10546 | 1024 |
if ((ik->field_access_flags(index) & JVM_ACC_FIELD_MODIFICATION_WATCHED) == 0) return; |
1 | 1025 |
|
1026 |
char sig_type = '\0'; |
|
1027 |
||
1028 |
switch(cp_entry->flag_state()) { |
|
1029 |
case btos: sig_type = 'Z'; break; |
|
1030 |
case ctos: sig_type = 'C'; break; |
|
1031 |
case stos: sig_type = 'S'; break; |
|
1032 |
case itos: sig_type = 'I'; break; |
|
1033 |
case ftos: sig_type = 'F'; break; |
|
1034 |
case atos: sig_type = 'L'; break; |
|
1035 |
case ltos: sig_type = 'J'; break; |
|
1036 |
case dtos: sig_type = 'D'; break; |
|
1037 |
default: ShouldNotReachHere(); return; |
|
1038 |
} |
|
1039 |
bool is_static = (obj == NULL); |
|
1040 |
||
1041 |
HandleMark hm(thread); |
|
1042 |
instanceKlassHandle h_klass(thread, k); |
|
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
13296
diff
changeset
|
1043 |
jfieldID fid = jfieldIDWorkaround::to_jfieldID(h_klass, cp_entry->f2_as_index(), is_static); |
1 | 1044 |
jvalue fvalue; |
1045 |
#ifdef _LP64 |
|
1046 |
fvalue = *value; |
|
1047 |
#else |
|
1048 |
// Long/double values are stored unaligned and also noncontiguously with |
|
1049 |
// tagged stacks. We can't just do a simple assignment even in the non- |
|
1050 |
// J/D cases because a C++ compiler is allowed to assume that a jvalue is |
|
1051 |
// 8-byte aligned, and interpreter stack slots are only 4-byte aligned. |
|
1052 |
// We assume that the two halves of longs/doubles are stored in interpreter |
|
1053 |
// stack slots in platform-endian order. |
|
1054 |
jlong_accessor u; |
|
1055 |
jint* newval = (jint*)value; |
|
1056 |
u.words[0] = newval[0]; |
|
5419 | 1057 |
u.words[1] = newval[Interpreter::stackElementWords]; // skip if tag |
1 | 1058 |
fvalue.j = u.long_value; |
1059 |
#endif // _LP64 |
|
1060 |
||
1061 |
Handle h_obj; |
|
1062 |
if (!is_static) { |
|
1063 |
// non-static field accessors have an object, but we need a handle |
|
1064 |
h_obj = Handle(thread, obj); |
|
1065 |
} |
|
1066 |
||
1067 |
JvmtiExport::post_raw_field_modification(thread, method(thread), bcp(thread), h_klass, h_obj, |
|
1068 |
fid, sig_type, &fvalue); |
|
1069 |
IRT_END |
|
1070 |
||
1071 |
IRT_ENTRY(void, InterpreterRuntime::post_method_entry(JavaThread *thread)) |
|
1072 |
JvmtiExport::post_method_entry(thread, InterpreterRuntime::method(thread), InterpreterRuntime::last_frame(thread)); |
|
1073 |
IRT_END |
|
1074 |
||
1075 |
||
1076 |
IRT_ENTRY(void, InterpreterRuntime::post_method_exit(JavaThread *thread)) |
|
1077 |
JvmtiExport::post_method_exit(thread, InterpreterRuntime::method(thread), InterpreterRuntime::last_frame(thread)); |
|
1078 |
IRT_END |
|
1079 |
||
1080 |
IRT_LEAF(int, InterpreterRuntime::interpreter_contains(address pc)) |
|
1081 |
{ |
|
1082 |
return (Interpreter::contains(pc) ? 1 : 0); |
|
1083 |
} |
|
1084 |
IRT_END |
|
1085 |
||
1086 |
||
1087 |
// Implementation of SignatureHandlerLibrary |
|
1088 |
||
1089 |
address SignatureHandlerLibrary::set_handler_blob() { |
|
1090 |
BufferBlob* handler_blob = BufferBlob::create("native signature handlers", blob_size); |
|
1091 |
if (handler_blob == NULL) { |
|
1092 |
return NULL; |
|
1093 |
} |
|
6418 | 1094 |
address handler = handler_blob->code_begin(); |
1 | 1095 |
_handler_blob = handler_blob; |
1096 |
_handler = handler; |
|
1097 |
return handler; |
|
1098 |
} |
|
1099 |
||
1100 |
void SignatureHandlerLibrary::initialize() { |
|
1101 |
if (_fingerprints != NULL) { |
|
1102 |
return; |
|
1103 |
} |
|
1104 |
if (set_handler_blob() == NULL) { |
|
17087
f0b76c4c93a0
8011661: Insufficient memory message says "malloc" when sometimes it should say "mmap"
ccheung
parents:
17002
diff
changeset
|
1105 |
vm_exit_out_of_memory(blob_size, OOM_MALLOC_ERROR, "native signature handlers"); |
1 | 1106 |
} |
1107 |
||
1108 |
BufferBlob* bb = BufferBlob::create("Signature Handler Temp Buffer", |
|
1109 |
SignatureHandlerLibrary::buffer_size); |
|
6418 | 1110 |
_buffer = bb->code_begin(); |
1 | 1111 |
|
13195 | 1112 |
_fingerprints = new(ResourceObj::C_HEAP, mtCode)GrowableArray<uint64_t>(32, true); |
1113 |
_handlers = new(ResourceObj::C_HEAP, mtCode)GrowableArray<address>(32, true); |
|
1 | 1114 |
} |
1115 |
||
1116 |
address SignatureHandlerLibrary::set_handler(CodeBuffer* buffer) { |
|
1117 |
address handler = _handler; |
|
6418 | 1118 |
int insts_size = buffer->pure_insts_size(); |
1119 |
if (handler + insts_size > _handler_blob->code_end()) { |
|
1 | 1120 |
// get a new handler blob |
1121 |
handler = set_handler_blob(); |
|
1122 |
} |
|
1123 |
if (handler != NULL) { |
|
6418 | 1124 |
memcpy(handler, buffer->insts_begin(), insts_size); |
1 | 1125 |
pd_set_handler(handler); |
6418 | 1126 |
ICache::invalidate_range(handler, insts_size); |
1127 |
_handler = handler + insts_size; |
|
1 | 1128 |
} |
1129 |
return handler; |
|
1130 |
} |
|
1131 |
||
1132 |
void SignatureHandlerLibrary::add(methodHandle method) { |
|
1133 |
if (method->signature_handler() == NULL) { |
|
1134 |
// use slow signature handler if we can't do better |
|
1135 |
int handler_index = -1; |
|
1136 |
// check if we can use customized (fast) signature handler |
|
1137 |
if (UseFastSignatureHandlers && method->size_of_parameters() <= Fingerprinter::max_size_of_parameters) { |
|
1138 |
// use customized signature handler |
|
1139 |
MutexLocker mu(SignatureHandlerLibrary_lock); |
|
1140 |
// make sure data structure is initialized |
|
1141 |
initialize(); |
|
1142 |
// lookup method signature's fingerprint |
|
1143 |
uint64_t fingerprint = Fingerprinter(method).fingerprint(); |
|
1144 |
handler_index = _fingerprints->find(fingerprint); |
|
1145 |
// create handler if necessary |
|
1146 |
if (handler_index < 0) { |
|
1147 |
ResourceMark rm; |
|
1148 |
ptrdiff_t align_offset = (address) |
|
1149 |
round_to((intptr_t)_buffer, CodeEntryAlignment) - (address)_buffer; |
|
1150 |
CodeBuffer buffer((address)(_buffer + align_offset), |
|
1151 |
SignatureHandlerLibrary::buffer_size - align_offset); |
|
1152 |
InterpreterRuntime::SignatureHandlerGenerator(method, &buffer).generate(fingerprint); |
|
1153 |
// copy into code heap |
|
1154 |
address handler = set_handler(&buffer); |
|
1155 |
if (handler == NULL) { |
|
1156 |
// use slow signature handler |
|
1157 |
} else { |
|
1158 |
// debugging suppport |
|
1159 |
if (PrintSignatureHandlers) { |
|
1160 |
tty->cr(); |
|
1161 |
tty->print_cr("argument handler #%d for: %s %s (fingerprint = " UINT64_FORMAT ", %d bytes generated)", |
|
1162 |
_handlers->length(), |
|
1163 |
(method->is_static() ? "static" : "receiver"), |
|
1164 |
method->name_and_sig_as_C_string(), |
|
1165 |
fingerprint, |
|
6418 | 1166 |
buffer.insts_size()); |
1167 |
Disassembler::decode(handler, handler + buffer.insts_size()); |
|
1 | 1168 |
#ifndef PRODUCT |
1169 |
tty->print_cr(" --- associated result handler ---"); |
|
1170 |
address rh_begin = Interpreter::result_handler(method()->result_type()); |
|
1171 |
address rh_end = rh_begin; |
|
1172 |
while (*(int*)rh_end != 0) { |
|
1173 |
rh_end += sizeof(int); |
|
1174 |
} |
|
1175 |
Disassembler::decode(rh_begin, rh_end); |
|
1176 |
#endif |
|
1177 |
} |
|
1178 |
// add handler to library |
|
1179 |
_fingerprints->append(fingerprint); |
|
1180 |
_handlers->append(handler); |
|
1181 |
// set handler index |
|
1182 |
assert(_fingerprints->length() == _handlers->length(), "sanity check"); |
|
1183 |
handler_index = _fingerprints->length() - 1; |
|
1184 |
} |
|
1185 |
} |
|
8109
26c288ddbec3
7012088: jump to 0 address because of lack of memory ordering in SignatureHandlerLibrary::add
coleenp
parents:
8107
diff
changeset
|
1186 |
// Set handler under SignatureHandlerLibrary_lock |
1 | 1187 |
if (handler_index < 0) { |
1188 |
// use generic signature handler |
|
1189 |
method->set_signature_handler(Interpreter::slow_signature_handler()); |
|
1190 |
} else { |
|
1191 |
// set handler |
|
1192 |
method->set_signature_handler(_handlers->at(handler_index)); |
|
1193 |
} |
|
8109
26c288ddbec3
7012088: jump to 0 address because of lack of memory ordering in SignatureHandlerLibrary::add
coleenp
parents:
8107
diff
changeset
|
1194 |
} else { |
26c288ddbec3
7012088: jump to 0 address because of lack of memory ordering in SignatureHandlerLibrary::add
coleenp
parents:
8107
diff
changeset
|
1195 |
CHECK_UNHANDLED_OOPS_ONLY(Thread::current()->clear_unhandled_oops()); |
26c288ddbec3
7012088: jump to 0 address because of lack of memory ordering in SignatureHandlerLibrary::add
coleenp
parents:
8107
diff
changeset
|
1196 |
// use generic signature handler |
26c288ddbec3
7012088: jump to 0 address because of lack of memory ordering in SignatureHandlerLibrary::add
coleenp
parents:
8107
diff
changeset
|
1197 |
method->set_signature_handler(Interpreter::slow_signature_handler()); |
26c288ddbec3
7012088: jump to 0 address because of lack of memory ordering in SignatureHandlerLibrary::add
coleenp
parents:
8107
diff
changeset
|
1198 |
} |
1 | 1199 |
} |
7411
afcfb75ccae1
6704010: Internal Error (src/share/vm/interpreter/interpreterRuntime.cpp:1106)
coleenp
parents:
7397
diff
changeset
|
1200 |
#ifdef ASSERT |
8109
26c288ddbec3
7012088: jump to 0 address because of lack of memory ordering in SignatureHandlerLibrary::add
coleenp
parents:
8107
diff
changeset
|
1201 |
int handler_index = -1; |
26c288ddbec3
7012088: jump to 0 address because of lack of memory ordering in SignatureHandlerLibrary::add
coleenp
parents:
8107
diff
changeset
|
1202 |
int fingerprint_index = -2; |
7411
afcfb75ccae1
6704010: Internal Error (src/share/vm/interpreter/interpreterRuntime.cpp:1106)
coleenp
parents:
7397
diff
changeset
|
1203 |
{ |
afcfb75ccae1
6704010: Internal Error (src/share/vm/interpreter/interpreterRuntime.cpp:1106)
coleenp
parents:
7397
diff
changeset
|
1204 |
// '_handlers' and '_fingerprints' are 'GrowableArray's and are NOT synchronized |
afcfb75ccae1
6704010: Internal Error (src/share/vm/interpreter/interpreterRuntime.cpp:1106)
coleenp
parents:
7397
diff
changeset
|
1205 |
// in any way if accessed from multiple threads. To avoid races with another |
afcfb75ccae1
6704010: Internal Error (src/share/vm/interpreter/interpreterRuntime.cpp:1106)
coleenp
parents:
7397
diff
changeset
|
1206 |
// thread which may change the arrays in the above, mutex protected block, we |
afcfb75ccae1
6704010: Internal Error (src/share/vm/interpreter/interpreterRuntime.cpp:1106)
coleenp
parents:
7397
diff
changeset
|
1207 |
// have to protect this read access here with the same mutex as well! |
afcfb75ccae1
6704010: Internal Error (src/share/vm/interpreter/interpreterRuntime.cpp:1106)
coleenp
parents:
7397
diff
changeset
|
1208 |
MutexLocker mu(SignatureHandlerLibrary_lock); |
8109
26c288ddbec3
7012088: jump to 0 address because of lack of memory ordering in SignatureHandlerLibrary::add
coleenp
parents:
8107
diff
changeset
|
1209 |
if (_handlers != NULL) { |
7411
afcfb75ccae1
6704010: Internal Error (src/share/vm/interpreter/interpreterRuntime.cpp:1106)
coleenp
parents:
7397
diff
changeset
|
1210 |
handler_index = _handlers->find(method->signature_handler()); |
afcfb75ccae1
6704010: Internal Error (src/share/vm/interpreter/interpreterRuntime.cpp:1106)
coleenp
parents:
7397
diff
changeset
|
1211 |
fingerprint_index = _fingerprints->find(Fingerprinter(method).fingerprint()); |
afcfb75ccae1
6704010: Internal Error (src/share/vm/interpreter/interpreterRuntime.cpp:1106)
coleenp
parents:
7397
diff
changeset
|
1212 |
} |
8109
26c288ddbec3
7012088: jump to 0 address because of lack of memory ordering in SignatureHandlerLibrary::add
coleenp
parents:
8107
diff
changeset
|
1213 |
} |
1 | 1214 |
assert(method->signature_handler() == Interpreter::slow_signature_handler() || |
7411
afcfb75ccae1
6704010: Internal Error (src/share/vm/interpreter/interpreterRuntime.cpp:1106)
coleenp
parents:
7397
diff
changeset
|
1215 |
handler_index == fingerprint_index, "sanity check"); |
8109
26c288ddbec3
7012088: jump to 0 address because of lack of memory ordering in SignatureHandlerLibrary::add
coleenp
parents:
8107
diff
changeset
|
1216 |
#endif // ASSERT |
1 | 1217 |
} |
1218 |
||
1219 |
||
1220 |
BufferBlob* SignatureHandlerLibrary::_handler_blob = NULL; |
|
1221 |
address SignatureHandlerLibrary::_handler = NULL; |
|
1222 |
GrowableArray<uint64_t>* SignatureHandlerLibrary::_fingerprints = NULL; |
|
1223 |
GrowableArray<address>* SignatureHandlerLibrary::_handlers = NULL; |
|
1224 |
address SignatureHandlerLibrary::_buffer = NULL; |
|
1225 |
||
1226 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
1227 |
IRT_ENTRY(void, InterpreterRuntime::prepare_native_call(JavaThread* thread, Method* method)) |
1 | 1228 |
methodHandle m(thread, method); |
1229 |
assert(m->is_native(), "sanity check"); |
|
1230 |
// lookup native function entry point if it doesn't exist |
|
1231 |
bool in_base_library; |
|
1232 |
if (!m->has_native_function()) { |
|
1233 |
NativeLookup::lookup(m, in_base_library, CHECK); |
|
1234 |
} |
|
1235 |
// make sure signature handler is installed |
|
1236 |
SignatureHandlerLibrary::add(m); |
|
1237 |
// The interpreter entry point checks the signature handler first, |
|
1238 |
// before trying to fetch the native entry point and klass mirror. |
|
1239 |
// We must set the signature handler last, so that multiple processors |
|
1240 |
// preparing the same method will be sure to see non-null entry & mirror. |
|
1241 |
IRT_END |
|
1242 |
||
10520
db9177a52cee
7085012: ARM: com/sun/jdi/PopSynchronousTest.java still fails
roland
parents:
10265
diff
changeset
|
1243 |
#if defined(IA32) || defined(AMD64) || defined(ARM) |
1 | 1244 |
IRT_LEAF(void, InterpreterRuntime::popframe_move_outgoing_args(JavaThread* thread, void* src_address, void* dest_address)) |
1245 |
if (src_address == dest_address) { |
|
1246 |
return; |
|
1247 |
} |
|
1248 |
ResetNoHandleMark rnm; // In a LEAF entry. |
|
1249 |
HandleMark hm; |
|
1250 |
ResourceMark rm; |
|
1251 |
frame fr = thread->last_frame(); |
|
1252 |
assert(fr.is_interpreted_frame(), ""); |
|
1253 |
jint bci = fr.interpreter_frame_bci(); |
|
1254 |
methodHandle mh(thread, fr.interpreter_frame_method()); |
|
7913 | 1255 |
Bytecode_invoke invoke(mh, bci); |
1256 |
ArgumentSizeComputer asc(invoke.signature()); |
|
1257 |
int size_of_arguments = (asc.size() + (invoke.has_receiver() ? 1 : 0)); // receiver |
|
5883
8dc4bdc132d5
6730276: JDI_REGRESSION tests fail with "Error: count must be non-zero" error on x86
kvn
parents:
5882
diff
changeset
|
1258 |
Copy::conjoint_jbytes(src_address, dest_address, |
5419 | 1259 |
size_of_arguments * Interpreter::stackElementSize); |
1 | 1260 |
IRT_END |
1261 |
#endif |
|
19266
bb0324cbe0aa
7187554: JSR 292: JVMTI PopFrame needs to handle appendix arguments
sspitsyn
parents:
17087
diff
changeset
|
1262 |
|
bb0324cbe0aa
7187554: JSR 292: JVMTI PopFrame needs to handle appendix arguments
sspitsyn
parents:
17087
diff
changeset
|
1263 |
#if INCLUDE_JVMTI |
bb0324cbe0aa
7187554: JSR 292: JVMTI PopFrame needs to handle appendix arguments
sspitsyn
parents:
17087
diff
changeset
|
1264 |
// This is a support of the JVMTI PopFrame interface. |
bb0324cbe0aa
7187554: JSR 292: JVMTI PopFrame needs to handle appendix arguments
sspitsyn
parents:
17087
diff
changeset
|
1265 |
// Make sure it is an invokestatic of a polymorphic intrinsic that has a member_name argument |
bb0324cbe0aa
7187554: JSR 292: JVMTI PopFrame needs to handle appendix arguments
sspitsyn
parents:
17087
diff
changeset
|
1266 |
// and return it as a vm_result so that it can be reloaded in the list of invokestatic parameters. |
24678
9bb217f7f313
8034935: JSR 292 support for PopFrame has a fragile coupling with DirectMethodHandle
vlivanov
parents:
24424
diff
changeset
|
1267 |
// The member_name argument is a saved reference (in local#0) to the member_name. |
9bb217f7f313
8034935: JSR 292 support for PopFrame has a fragile coupling with DirectMethodHandle
vlivanov
parents:
24424
diff
changeset
|
1268 |
// For backward compatibility with some JDK versions (7, 8) it can also be a direct method handle. |
9bb217f7f313
8034935: JSR 292 support for PopFrame has a fragile coupling with DirectMethodHandle
vlivanov
parents:
24424
diff
changeset
|
1269 |
// FIXME: remove DMH case after j.l.i.InvokerBytecodeGenerator code shape is updated. |
9bb217f7f313
8034935: JSR 292 support for PopFrame has a fragile coupling with DirectMethodHandle
vlivanov
parents:
24424
diff
changeset
|
1270 |
IRT_ENTRY(void, InterpreterRuntime::member_name_arg_or_null(JavaThread* thread, address member_name, |
19266
bb0324cbe0aa
7187554: JSR 292: JVMTI PopFrame needs to handle appendix arguments
sspitsyn
parents:
17087
diff
changeset
|
1271 |
Method* method, address bcp)) |
bb0324cbe0aa
7187554: JSR 292: JVMTI PopFrame needs to handle appendix arguments
sspitsyn
parents:
17087
diff
changeset
|
1272 |
Bytecodes::Code code = Bytecodes::code_at(method, bcp); |
bb0324cbe0aa
7187554: JSR 292: JVMTI PopFrame needs to handle appendix arguments
sspitsyn
parents:
17087
diff
changeset
|
1273 |
if (code != Bytecodes::_invokestatic) { |
bb0324cbe0aa
7187554: JSR 292: JVMTI PopFrame needs to handle appendix arguments
sspitsyn
parents:
17087
diff
changeset
|
1274 |
return; |
bb0324cbe0aa
7187554: JSR 292: JVMTI PopFrame needs to handle appendix arguments
sspitsyn
parents:
17087
diff
changeset
|
1275 |
} |
bb0324cbe0aa
7187554: JSR 292: JVMTI PopFrame needs to handle appendix arguments
sspitsyn
parents:
17087
diff
changeset
|
1276 |
ConstantPool* cpool = method->constants(); |
bb0324cbe0aa
7187554: JSR 292: JVMTI PopFrame needs to handle appendix arguments
sspitsyn
parents:
17087
diff
changeset
|
1277 |
int cp_index = Bytes::get_native_u2(bcp + 1) + ConstantPool::CPCACHE_INDEX_TAG; |
bb0324cbe0aa
7187554: JSR 292: JVMTI PopFrame needs to handle appendix arguments
sspitsyn
parents:
17087
diff
changeset
|
1278 |
Symbol* cname = cpool->klass_name_at(cpool->klass_ref_index_at(cp_index)); |
bb0324cbe0aa
7187554: JSR 292: JVMTI PopFrame needs to handle appendix arguments
sspitsyn
parents:
17087
diff
changeset
|
1279 |
Symbol* mname = cpool->name_ref_at(cp_index); |
bb0324cbe0aa
7187554: JSR 292: JVMTI PopFrame needs to handle appendix arguments
sspitsyn
parents:
17087
diff
changeset
|
1280 |
|
bb0324cbe0aa
7187554: JSR 292: JVMTI PopFrame needs to handle appendix arguments
sspitsyn
parents:
17087
diff
changeset
|
1281 |
if (MethodHandles::has_member_arg(cname, mname)) { |
24678
9bb217f7f313
8034935: JSR 292 support for PopFrame has a fragile coupling with DirectMethodHandle
vlivanov
parents:
24424
diff
changeset
|
1282 |
oop member_name_oop = (oop) member_name; |
9bb217f7f313
8034935: JSR 292 support for PopFrame has a fragile coupling with DirectMethodHandle
vlivanov
parents:
24424
diff
changeset
|
1283 |
if (java_lang_invoke_DirectMethodHandle::is_instance(member_name_oop)) { |
9bb217f7f313
8034935: JSR 292 support for PopFrame has a fragile coupling with DirectMethodHandle
vlivanov
parents:
24424
diff
changeset
|
1284 |
// FIXME: remove after j.l.i.InvokerBytecodeGenerator code shape is updated. |
9bb217f7f313
8034935: JSR 292 support for PopFrame has a fragile coupling with DirectMethodHandle
vlivanov
parents:
24424
diff
changeset
|
1285 |
member_name_oop = java_lang_invoke_DirectMethodHandle::member(member_name_oop); |
9bb217f7f313
8034935: JSR 292 support for PopFrame has a fragile coupling with DirectMethodHandle
vlivanov
parents:
24424
diff
changeset
|
1286 |
} |
9bb217f7f313
8034935: JSR 292 support for PopFrame has a fragile coupling with DirectMethodHandle
vlivanov
parents:
24424
diff
changeset
|
1287 |
thread->set_vm_result(member_name_oop); |
19266
bb0324cbe0aa
7187554: JSR 292: JVMTI PopFrame needs to handle appendix arguments
sspitsyn
parents:
17087
diff
changeset
|
1288 |
} |
bb0324cbe0aa
7187554: JSR 292: JVMTI PopFrame needs to handle appendix arguments
sspitsyn
parents:
17087
diff
changeset
|
1289 |
IRT_END |
bb0324cbe0aa
7187554: JSR 292: JVMTI PopFrame needs to handle appendix arguments
sspitsyn
parents:
17087
diff
changeset
|
1290 |
#endif // INCLUDE_JVMTI |