Mercurial > hg > truffle
annotate src/share/vm/c1/c1_Runtime1.cpp @ 1931:48bbaead8b6c
Adjustments after merge with OpenJDK repository.
author | Thomas Wuerthinger <wuerthinger@ssw.jku.at> |
---|---|
date | Tue, 30 Nov 2010 16:39:35 +0100 |
parents | 2d26b0046e0d |
children | 00bc9eaf0e24 |
rev | line source |
---|---|
0 | 1 /* |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1247
diff
changeset
|
2 * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. |
0 | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1247
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1247
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1247
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
25 #include "incls/_precompiled.incl" | |
26 #include "incls/_c1_Runtime1.cpp.incl" | |
27 | |
28 | |
29 // Implementation of StubAssembler | |
30 | |
31 StubAssembler::StubAssembler(CodeBuffer* code, const char * name, int stub_id) : C1_MacroAssembler(code) { | |
32 _name = name; | |
33 _must_gc_arguments = false; | |
34 _frame_size = no_frame_size; | |
35 _num_rt_args = 0; | |
36 _stub_id = stub_id; | |
37 } | |
38 | |
39 | |
40 void StubAssembler::set_info(const char* name, bool must_gc_arguments) { | |
41 _name = name; | |
42 _must_gc_arguments = must_gc_arguments; | |
43 } | |
44 | |
45 | |
46 void StubAssembler::set_frame_size(int size) { | |
47 if (_frame_size == no_frame_size) { | |
48 _frame_size = size; | |
49 } | |
50 assert(_frame_size == size, "can't change the frame size"); | |
51 } | |
52 | |
53 | |
54 void StubAssembler::set_num_rt_args(int args) { | |
55 if (_num_rt_args == 0) { | |
56 _num_rt_args = args; | |
57 } | |
58 assert(_num_rt_args == args, "can't change the number of args"); | |
59 } | |
60 | |
61 // Implementation of Runtime1 | |
62 | |
63 CodeBlob* Runtime1::_blobs[Runtime1::number_of_ids]; | |
64 const char *Runtime1::_blob_names[] = { | |
65 RUNTIME1_STUBS(STUB_NAME, LAST_STUB_NAME) | |
66 }; | |
67 | |
68 #ifndef PRODUCT | |
69 // statistics | |
70 int Runtime1::_generic_arraycopy_cnt = 0; | |
71 int Runtime1::_primitive_arraycopy_cnt = 0; | |
72 int Runtime1::_oop_arraycopy_cnt = 0; | |
73 int Runtime1::_arraycopy_slowcase_cnt = 0; | |
74 int Runtime1::_new_type_array_slowcase_cnt = 0; | |
75 int Runtime1::_new_object_array_slowcase_cnt = 0; | |
76 int Runtime1::_new_instance_slowcase_cnt = 0; | |
77 int Runtime1::_new_multi_array_slowcase_cnt = 0; | |
78 int Runtime1::_monitorenter_slowcase_cnt = 0; | |
79 int Runtime1::_monitorexit_slowcase_cnt = 0; | |
80 int Runtime1::_patch_code_slowcase_cnt = 0; | |
81 int Runtime1::_throw_range_check_exception_count = 0; | |
82 int Runtime1::_throw_index_exception_count = 0; | |
83 int Runtime1::_throw_div0_exception_count = 0; | |
84 int Runtime1::_throw_null_pointer_exception_count = 0; | |
85 int Runtime1::_throw_class_cast_exception_count = 0; | |
86 int Runtime1::_throw_incompatible_class_change_error_count = 0; | |
87 int Runtime1::_throw_array_store_exception_count = 0; | |
88 int Runtime1::_throw_count = 0; | |
89 #endif | |
90 | |
91 // Simple helper to see if the caller of a runtime stub which | |
92 // entered the VM has been deoptimized | |
93 | |
94 static bool caller_is_deopted() { | |
95 JavaThread* thread = JavaThread::current(); | |
96 RegisterMap reg_map(thread, false); | |
97 frame runtime_frame = thread->last_frame(); | |
98 frame caller_frame = runtime_frame.sender(®_map); | |
99 assert(caller_frame.is_compiled_frame(), "must be compiled"); | |
100 return caller_frame.is_deoptimized_frame(); | |
101 } | |
102 | |
103 // Stress deoptimization | |
104 static void deopt_caller() { | |
105 if ( !caller_is_deopted()) { | |
106 JavaThread* thread = JavaThread::current(); | |
107 RegisterMap reg_map(thread, false); | |
108 frame runtime_frame = thread->last_frame(); | |
109 frame caller_frame = runtime_frame.sender(®_map); | |
1213
6deeaebad47a
6902182: 4/4 Starting with jdwp agent should not incur performance penalty
dcubed
parents:
1142
diff
changeset
|
110 Deoptimization::deoptimize_frame(thread, caller_frame.id()); |
0 | 111 assert(caller_is_deopted(), "Must be deoptimized"); |
112 } | |
113 } | |
114 | |
115 | |
1584 | 116 void Runtime1::generate_blob_for(BufferBlob* buffer_blob, StubID id) { |
0 | 117 assert(0 <= id && id < number_of_ids, "illegal stub id"); |
118 ResourceMark rm; | |
119 // create code buffer for code storage | |
1748 | 120 CodeBuffer code(buffer_blob); |
0 | 121 |
1584 | 122 Compilation::setup_code_buffer(&code, 0); |
0 | 123 |
124 // create assembler for code generation | |
125 StubAssembler* sasm = new StubAssembler(&code, name_for(id), id); | |
126 // generate code for runtime stub | |
127 OopMapSet* oop_maps; | |
128 oop_maps = generate_code_for(id, sasm); | |
129 assert(oop_maps == NULL || sasm->frame_size() != no_frame_size, | |
130 "if stub has an oop map it must have a valid frame size"); | |
131 | |
132 #ifdef ASSERT | |
133 // Make sure that stubs that need oopmaps have them | |
134 switch (id) { | |
135 // These stubs don't need to have an oopmap | |
136 case dtrace_object_alloc_id: | |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
137 case g1_pre_barrier_slow_id: |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
138 case g1_post_barrier_slow_id: |
0 | 139 case slow_subtype_check_id: |
140 case fpu2long_stub_id: | |
141 case unwind_exception_id: | |
1449
8cfe3537a0d3
Pointer verification stub. Two loose oop fixes in C1X C++ part. Logging which methods have been compiled.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1434
diff
changeset
|
142 case c1x_verify_pointer_id: |
1429
abc670a709dc
* -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents:
1247
diff
changeset
|
143 case c1x_unwind_exception_call_id: |
abc670a709dc
* -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents:
1247
diff
changeset
|
144 case c1x_slow_subtype_check_id: |
1434
72cfb36c6bb2
* enabled all jtt tests
Lukas Stadler <lukas.stadler@oracle.com>
parents:
1429
diff
changeset
|
145 case c1x_arithmetic_frem_id: |
72cfb36c6bb2
* enabled all jtt tests
Lukas Stadler <lukas.stadler@oracle.com>
parents:
1429
diff
changeset
|
146 case c1x_arithmetic_drem_id: |
0 | 147 #ifndef TIERED |
148 case counter_overflow_id: // Not generated outside the tiered world | |
149 #endif | |
150 #ifdef SPARC | |
151 case handle_exception_nofpu_id: // Unused on sparc | |
152 #endif | |
153 break; | |
154 | |
155 // All other stubs should have oopmaps | |
156 default: | |
157 assert(oop_maps != NULL, "must have an oopmap"); | |
158 } | |
159 #endif | |
160 | |
161 // align so printing shows nop's instead of random code at the end (SimpleStubs are aligned) | |
162 sasm->align(BytesPerWord); | |
163 // make sure all code is in code buffer | |
164 sasm->flush(); | |
165 // create blob - distinguish a few special cases | |
166 CodeBlob* blob = RuntimeStub::new_runtime_stub(name_for(id), | |
167 &code, | |
168 CodeOffsets::frame_never_safe, | |
169 sasm->frame_size(), | |
170 oop_maps, | |
171 sasm->must_gc_arguments()); | |
172 // install blob | |
173 assert(blob != NULL, "blob must exist"); | |
174 _blobs[id] = blob; | |
175 } | |
176 | |
177 | |
1584 | 178 void Runtime1::initialize(BufferBlob* blob) { |
179 // platform-dependent initialization | |
180 initialize_pd(); | |
181 // generate stubs | |
182 for (int id = 0; id < number_of_ids; id++) generate_blob_for(blob, (StubID)id); | |
183 // printing | |
0 | 184 #ifndef PRODUCT |
1584 | 185 if (PrintSimpleStubs) { |
186 ResourceMark rm; | |
187 for (int id = 0; id < number_of_ids; id++) { | |
188 _blobs[id]->print(); | |
189 if (_blobs[id]->oop_maps() != NULL) { | |
190 _blobs[id]->oop_maps()->print(); | |
0 | 191 } |
192 } | |
1584 | 193 } |
0 | 194 #endif |
195 } | |
196 | |
197 | |
198 CodeBlob* Runtime1::blob_for(StubID id) { | |
199 assert(0 <= id && id < number_of_ids, "illegal stub id"); | |
200 return _blobs[id]; | |
201 } | |
202 | |
203 | |
204 const char* Runtime1::name_for(StubID id) { | |
205 assert(0 <= id && id < number_of_ids, "illegal stub id"); | |
206 return _blob_names[id]; | |
207 } | |
208 | |
209 const char* Runtime1::name_for_address(address entry) { | |
210 for (int id = 0; id < number_of_ids; id++) { | |
211 if (entry == entry_for((StubID)id)) return name_for((StubID)id); | |
212 } | |
213 | |
214 #define FUNCTION_CASE(a, f) \ | |
215 if ((intptr_t)a == CAST_FROM_FN_PTR(intptr_t, f)) return #f | |
216 | |
217 FUNCTION_CASE(entry, os::javaTimeMillis); | |
218 FUNCTION_CASE(entry, os::javaTimeNanos); | |
219 FUNCTION_CASE(entry, SharedRuntime::OSR_migration_end); | |
220 FUNCTION_CASE(entry, SharedRuntime::d2f); | |
221 FUNCTION_CASE(entry, SharedRuntime::d2i); | |
222 FUNCTION_CASE(entry, SharedRuntime::d2l); | |
223 FUNCTION_CASE(entry, SharedRuntime::dcos); | |
224 FUNCTION_CASE(entry, SharedRuntime::dexp); | |
225 FUNCTION_CASE(entry, SharedRuntime::dlog); | |
226 FUNCTION_CASE(entry, SharedRuntime::dlog10); | |
227 FUNCTION_CASE(entry, SharedRuntime::dpow); | |
228 FUNCTION_CASE(entry, SharedRuntime::drem); | |
229 FUNCTION_CASE(entry, SharedRuntime::dsin); | |
230 FUNCTION_CASE(entry, SharedRuntime::dtan); | |
231 FUNCTION_CASE(entry, SharedRuntime::f2i); | |
232 FUNCTION_CASE(entry, SharedRuntime::f2l); | |
233 FUNCTION_CASE(entry, SharedRuntime::frem); | |
234 FUNCTION_CASE(entry, SharedRuntime::l2d); | |
235 FUNCTION_CASE(entry, SharedRuntime::l2f); | |
236 FUNCTION_CASE(entry, SharedRuntime::ldiv); | |
237 FUNCTION_CASE(entry, SharedRuntime::lmul); | |
238 FUNCTION_CASE(entry, SharedRuntime::lrem); | |
239 FUNCTION_CASE(entry, SharedRuntime::lrem); | |
240 FUNCTION_CASE(entry, SharedRuntime::dtrace_method_entry); | |
241 FUNCTION_CASE(entry, SharedRuntime::dtrace_method_exit); | |
242 FUNCTION_CASE(entry, trace_block_entry); | |
243 | |
244 #undef FUNCTION_CASE | |
245 | |
1681
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1603
diff
changeset
|
246 // Soft float adds more runtime names. |
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1603
diff
changeset
|
247 return pd_name_for_address(entry); |
0 | 248 } |
249 | |
250 | |
251 JRT_ENTRY(void, Runtime1::new_instance(JavaThread* thread, klassOopDesc* klass)) | |
252 NOT_PRODUCT(_new_instance_slowcase_cnt++;) | |
253 | |
254 assert(oop(klass)->is_klass(), "not a class"); | |
255 instanceKlassHandle h(thread, klass); | |
256 h->check_valid_for_instantiation(true, CHECK); | |
257 // make sure klass is initialized | |
258 h->initialize(CHECK); | |
259 // allocate instance and return via TLS | |
260 oop obj = h->allocate_instance(CHECK); | |
261 thread->set_vm_result(obj); | |
262 JRT_END | |
263 | |
264 | |
265 JRT_ENTRY(void, Runtime1::new_type_array(JavaThread* thread, klassOopDesc* klass, jint length)) | |
266 NOT_PRODUCT(_new_type_array_slowcase_cnt++;) | |
267 // Note: no handle for klass needed since they are not used | |
268 // anymore after new_typeArray() and no GC can happen before. | |
269 // (This may have to change if this code changes!) | |
270 assert(oop(klass)->is_klass(), "not a class"); | |
271 BasicType elt_type = typeArrayKlass::cast(klass)->element_type(); | |
272 oop obj = oopFactory::new_typeArray(elt_type, length, CHECK); | |
273 thread->set_vm_result(obj); | |
274 // This is pretty rare but this runtime patch is stressful to deoptimization | |
275 // if we deoptimize here so force a deopt to stress the path. | |
276 if (DeoptimizeALot) { | |
277 deopt_caller(); | |
278 } | |
279 | |
280 JRT_END | |
281 | |
282 | |
283 JRT_ENTRY(void, Runtime1::new_object_array(JavaThread* thread, klassOopDesc* array_klass, jint length)) | |
284 NOT_PRODUCT(_new_object_array_slowcase_cnt++;) | |
285 | |
286 // Note: no handle for klass needed since they are not used | |
287 // anymore after new_objArray() and no GC can happen before. | |
288 // (This may have to change if this code changes!) | |
289 assert(oop(array_klass)->is_klass(), "not a class"); | |
290 klassOop elem_klass = objArrayKlass::cast(array_klass)->element_klass(); | |
291 objArrayOop obj = oopFactory::new_objArray(elem_klass, length, CHECK); | |
292 thread->set_vm_result(obj); | |
293 // This is pretty rare but this runtime patch is stressful to deoptimization | |
294 // if we deoptimize here so force a deopt to stress the path. | |
295 if (DeoptimizeALot) { | |
296 deopt_caller(); | |
297 } | |
298 JRT_END | |
299 | |
300 | |
301 JRT_ENTRY(void, Runtime1::new_multi_array(JavaThread* thread, klassOopDesc* klass, int rank, jint* dims)) | |
302 NOT_PRODUCT(_new_multi_array_slowcase_cnt++;) | |
303 | |
304 assert(oop(klass)->is_klass(), "not a class"); | |
305 assert(rank >= 1, "rank must be nonzero"); | |
306 oop obj = arrayKlass::cast(klass)->multi_allocate(rank, dims, CHECK); | |
307 thread->set_vm_result(obj); | |
308 JRT_END | |
309 | |
310 | |
311 JRT_ENTRY(void, Runtime1::unimplemented_entry(JavaThread* thread, StubID id)) | |
312 tty->print_cr("Runtime1::entry_for(%d) returned unimplemented entry point", id); | |
313 JRT_END | |
314 | |
315 | |
316 JRT_ENTRY(void, Runtime1::throw_array_store_exception(JavaThread* thread)) | |
317 THROW(vmSymbolHandles::java_lang_ArrayStoreException()); | |
318 JRT_END | |
319 | |
320 | |
321 JRT_ENTRY(void, Runtime1::post_jvmti_exception_throw(JavaThread* thread)) | |
1213
6deeaebad47a
6902182: 4/4 Starting with jdwp agent should not incur performance penalty
dcubed
parents:
1142
diff
changeset
|
322 if (JvmtiExport::can_post_on_exceptions()) { |
0 | 323 vframeStream vfst(thread, true); |
324 address bcp = vfst.method()->bcp_from(vfst.bci()); | |
325 JvmtiExport::post_exception_throw(thread, vfst.method(), bcp, thread->exception_oop()); | |
326 } | |
327 JRT_END | |
328 | |
1783 | 329 // This is a helper to allow us to safepoint but allow the outer entry |
330 // to be safepoint free if we need to do an osr | |
331 static nmethod* counter_overflow_helper(JavaThread* THREAD, int branch_bci, methodOopDesc* m) { | |
332 nmethod* osr_nm = NULL; | |
333 methodHandle method(THREAD, m); | |
334 | |
335 RegisterMap map(THREAD, false); | |
336 frame fr = THREAD->last_frame().sender(&map); | |
0 | 337 nmethod* nm = (nmethod*) fr.cb(); |
1783 | 338 assert(nm!= NULL && nm->is_nmethod(), "Sanity check"); |
339 methodHandle enclosing_method(THREAD, nm->method()); | |
340 | |
341 CompLevel level = (CompLevel)nm->comp_level(); | |
342 int bci = InvocationEntryBci; | |
343 if (branch_bci != InvocationEntryBci) { | |
344 // Compute desination bci | |
345 address pc = method()->code_base() + branch_bci; | |
346 Bytecodes::Code branch = Bytecodes::code_at(pc, method()); | |
347 int offset = 0; | |
348 switch (branch) { | |
349 case Bytecodes::_if_icmplt: case Bytecodes::_iflt: | |
350 case Bytecodes::_if_icmpgt: case Bytecodes::_ifgt: | |
351 case Bytecodes::_if_icmple: case Bytecodes::_ifle: | |
352 case Bytecodes::_if_icmpge: case Bytecodes::_ifge: | |
353 case Bytecodes::_if_icmpeq: case Bytecodes::_if_acmpeq: case Bytecodes::_ifeq: | |
354 case Bytecodes::_if_icmpne: case Bytecodes::_if_acmpne: case Bytecodes::_ifne: | |
355 case Bytecodes::_ifnull: case Bytecodes::_ifnonnull: case Bytecodes::_goto: | |
356 offset = (int16_t)Bytes::get_Java_u2(pc + 1); | |
357 break; | |
358 case Bytecodes::_goto_w: | |
359 offset = Bytes::get_Java_u4(pc + 1); | |
360 break; | |
361 default: ; | |
0 | 362 } |
1783 | 363 bci = branch_bci + offset; |
364 } | |
365 | |
366 osr_nm = CompilationPolicy::policy()->event(enclosing_method, method, branch_bci, bci, level, THREAD); | |
367 return osr_nm; | |
368 } | |
369 | |
370 JRT_BLOCK_ENTRY(address, Runtime1::counter_overflow(JavaThread* thread, int bci, methodOopDesc* method)) | |
371 nmethod* osr_nm; | |
372 JRT_BLOCK | |
373 osr_nm = counter_overflow_helper(thread, bci, method); | |
374 if (osr_nm != NULL) { | |
375 RegisterMap map(thread, false); | |
376 frame fr = thread->last_frame().sender(&map); | |
1905
ce6848d0666d
6968367: can_post_on_exceptions is still using VM_DeoptimizeFrame in some places
never
parents:
1783
diff
changeset
|
377 Deoptimization::deoptimize_frame(thread, fr.id()); |
0 | 378 } |
1783 | 379 JRT_BLOCK_END |
380 return NULL; | |
0 | 381 JRT_END |
382 | |
383 extern void vm_exit(int code); | |
384 | |
385 // Enter this method from compiled code handler below. This is where we transition | |
386 // to VM mode. This is done as a helper routine so that the method called directly | |
387 // from compiled code does not have to transition to VM. This allows the entry | |
388 // method to see if the nmethod that we have just looked up a handler for has | |
389 // been deoptimized while we were in the vm. This simplifies the assembly code | |
390 // cpu directories. | |
391 // | |
392 // We are entering here from exception stub (via the entry method below) | |
393 // If there is a compiled exception handler in this method, we will continue there; | |
394 // otherwise we will unwind the stack and continue at the caller of top frame method | |
395 // Note: we enter in Java using a special JRT wrapper. This wrapper allows us to | |
396 // control the area where we can allow a safepoint. After we exit the safepoint area we can | |
397 // check to see if the handler we are going to return is now in a nmethod that has | |
398 // been deoptimized. If that is the case we return the deopt blob | |
399 // unpack_with_exception entry instead. This makes life for the exception blob easier | |
400 // because making that same check and diverting is painful from assembly language. | |
401 // | |
402 | |
403 | |
404 JRT_ENTRY_NO_ASYNC(static address, exception_handler_for_pc_helper(JavaThread* thread, oopDesc* ex, address pc, nmethod*& nm)) | |
405 | |
406 Handle exception(thread, ex); | |
1429
abc670a709dc
* -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents:
1247
diff
changeset
|
407 if (UseC1X && exception.is_null()) { |
abc670a709dc
* -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents:
1247
diff
changeset
|
408 exception = Exceptions::new_exception(thread, vmSymbols::java_lang_NullPointerException(), NULL); |
abc670a709dc
* -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents:
1247
diff
changeset
|
409 } |
0 | 410 nm = CodeCache::find_nmethod(pc); |
411 assert(nm != NULL, "this is not an nmethod"); | |
412 // Adjust the pc as needed/ | |
413 if (nm->is_deopt_pc(pc)) { | |
414 RegisterMap map(thread, false); | |
415 frame exception_frame = thread->last_frame().sender(&map); | |
416 // if the frame isn't deopted then pc must not correspond to the caller of last_frame | |
417 assert(exception_frame.is_deoptimized_frame(), "must be deopted"); | |
418 pc = exception_frame.pc(); | |
419 } | |
420 #ifdef ASSERT | |
421 assert(exception.not_null(), "NULL exceptions should be handled by throw_exception"); | |
422 assert(exception->is_oop(), "just checking"); | |
423 // Check that exception is a subclass of Throwable, otherwise we have a VerifyError | |
1142 | 424 if (!(exception->is_a(SystemDictionary::Throwable_klass()))) { |
0 | 425 if (ExitVMOnVerifyError) vm_exit(-1); |
426 ShouldNotReachHere(); | |
427 } | |
428 #endif | |
429 | |
430 // Check the stack guard pages and reenable them if necessary and there is | |
431 // enough space on the stack to do so. Use fast exceptions only if the guard | |
432 // pages are enabled. | |
433 bool guard_pages_enabled = thread->stack_yellow_zone_enabled(); | |
434 if (!guard_pages_enabled) guard_pages_enabled = thread->reguard_stack(); | |
435 | |
1213
6deeaebad47a
6902182: 4/4 Starting with jdwp agent should not incur performance penalty
dcubed
parents:
1142
diff
changeset
|
436 if (JvmtiExport::can_post_on_exceptions()) { |
0 | 437 // To ensure correct notification of exception catches and throws |
438 // we have to deoptimize here. If we attempted to notify the | |
439 // catches and throws during this exception lookup it's possible | |
440 // we could deoptimize on the way out of the VM and end back in | |
441 // the interpreter at the throw site. This would result in double | |
442 // notifications since the interpreter would also notify about | |
443 // these same catches and throws as it unwound the frame. | |
444 | |
445 RegisterMap reg_map(thread); | |
446 frame stub_frame = thread->last_frame(); | |
447 frame caller_frame = stub_frame.sender(®_map); | |
448 | |
449 // We don't really want to deoptimize the nmethod itself since we | |
450 // can actually continue in the exception handler ourselves but I | |
451 // don't see an easy way to have the desired effect. | |
1905
ce6848d0666d
6968367: can_post_on_exceptions is still using VM_DeoptimizeFrame in some places
never
parents:
1783
diff
changeset
|
452 Deoptimization::deoptimize_frame(thread, caller_frame.id()); |
ce6848d0666d
6968367: can_post_on_exceptions is still using VM_DeoptimizeFrame in some places
never
parents:
1783
diff
changeset
|
453 assert(caller_is_deopted(), "Must be deoptimized"); |
0 | 454 |
455 return SharedRuntime::deopt_blob()->unpack_with_exception_in_tls(); | |
456 } | |
457 | |
458 // ExceptionCache is used only for exceptions at call and not for implicit exceptions | |
459 if (guard_pages_enabled) { | |
460 address fast_continuation = nm->handler_for_exception_and_pc(exception, pc); | |
461 if (fast_continuation != NULL) { | |
462 if (fast_continuation == ExceptionCache::unwind_handler()) fast_continuation = NULL; | |
463 return fast_continuation; | |
464 } | |
465 } | |
466 | |
467 // If the stack guard pages are enabled, check whether there is a handler in | |
468 // the current method. Otherwise (guard pages disabled), force an unwind and | |
469 // skip the exception cache update (i.e., just leave continuation==NULL). | |
470 address continuation = NULL; | |
471 if (guard_pages_enabled) { | |
472 | |
473 // New exception handling mechanism can support inlined methods | |
474 // with exception handlers since the mappings are from PC to PC | |
475 | |
476 // debugging support | |
477 // tracing | |
478 if (TraceExceptions) { | |
479 ttyLocker ttyl; | |
480 ResourceMark rm; | |
481 tty->print_cr("Exception <%s> (0x%x) thrown in compiled method <%s> at PC " PTR_FORMAT " for thread 0x%x", | |
482 exception->print_value_string(), (address)exception(), nm->method()->print_value_string(), pc, thread); | |
483 } | |
484 // for AbortVMOnException flag | |
485 NOT_PRODUCT(Exceptions::debug_check_abort(exception)); | |
486 | |
487 // Clear out the exception oop and pc since looking up an | |
488 // exception handler can cause class loading, which might throw an | |
489 // exception and those fields are expected to be clear during | |
490 // normal bytecode execution. | |
491 thread->set_exception_oop(NULL); | |
492 thread->set_exception_pc(NULL); | |
493 | |
494 continuation = SharedRuntime::compute_compiled_exc_handler(nm, pc, exception, false, false); | |
495 // If an exception was thrown during exception dispatch, the exception oop may have changed | |
496 thread->set_exception_oop(exception()); | |
497 thread->set_exception_pc(pc); | |
498 | |
499 // the exception cache is used only by non-implicit exceptions | |
500 if (continuation == NULL) { | |
501 nm->add_handler_for_exception_and_pc(exception, pc, ExceptionCache::unwind_handler()); | |
502 } else { | |
503 nm->add_handler_for_exception_and_pc(exception, pc, continuation); | |
504 } | |
505 } | |
506 | |
507 thread->set_vm_result(exception()); | |
508 | |
509 if (TraceExceptions) { | |
510 ttyLocker ttyl; | |
511 ResourceMark rm; | |
512 tty->print_cr("Thread " PTR_FORMAT " continuing at PC " PTR_FORMAT " for exception thrown at PC " PTR_FORMAT, | |
513 thread, continuation, pc); | |
514 } | |
515 | |
516 return continuation; | |
517 JRT_END | |
518 | |
519 // Enter this method from compiled code only if there is a Java exception handler | |
520 // in the method handling the exception | |
521 // We are entering here from exception stub. We don't do a normal VM transition here. | |
522 // We do it in a helper. This is so we can check to see if the nmethod we have just | |
523 // searched for an exception handler has been deoptimized in the meantime. | |
524 address Runtime1::exception_handler_for_pc(JavaThread* thread) { | |
525 oop exception = thread->exception_oop(); | |
526 address pc = thread->exception_pc(); | |
527 // Still in Java mode | |
528 debug_only(ResetNoHandleMark rnhm); | |
529 nmethod* nm = NULL; | |
530 address continuation = NULL; | |
531 { | |
532 // Enter VM mode by calling the helper | |
533 | |
534 ResetNoHandleMark rnhm; | |
535 continuation = exception_handler_for_pc_helper(thread, exception, pc, nm); | |
536 } | |
537 // Back in JAVA, use no oops DON'T safepoint | |
538 | |
539 // Now check to see if the nmethod we were called from is now deoptimized. | |
540 // If so we must return to the deopt blob and deoptimize the nmethod | |
541 | |
542 if (nm != NULL && caller_is_deopted()) { | |
543 continuation = SharedRuntime::deopt_blob()->unpack_with_exception_in_tls(); | |
544 } | |
545 | |
546 return continuation; | |
547 } | |
548 | |
549 | |
550 JRT_ENTRY(void, Runtime1::throw_range_check_exception(JavaThread* thread, int index)) | |
551 NOT_PRODUCT(_throw_range_check_exception_count++;) | |
552 Events::log("throw_range_check"); | |
553 char message[jintAsStringSize]; | |
554 sprintf(message, "%d", index); | |
555 SharedRuntime::throw_and_post_jvmti_exception(thread, vmSymbols::java_lang_ArrayIndexOutOfBoundsException(), message); | |
556 JRT_END | |
557 | |
558 | |
559 JRT_ENTRY(void, Runtime1::throw_index_exception(JavaThread* thread, int index)) | |
560 NOT_PRODUCT(_throw_index_exception_count++;) | |
561 Events::log("throw_index"); | |
562 char message[16]; | |
563 sprintf(message, "%d", index); | |
564 SharedRuntime::throw_and_post_jvmti_exception(thread, vmSymbols::java_lang_IndexOutOfBoundsException(), message); | |
565 JRT_END | |
566 | |
567 | |
568 JRT_ENTRY(void, Runtime1::throw_div0_exception(JavaThread* thread)) | |
569 NOT_PRODUCT(_throw_div0_exception_count++;) | |
570 SharedRuntime::throw_and_post_jvmti_exception(thread, vmSymbols::java_lang_ArithmeticException(), "/ by zero"); | |
571 JRT_END | |
572 | |
573 | |
574 JRT_ENTRY(void, Runtime1::throw_null_pointer_exception(JavaThread* thread)) | |
575 NOT_PRODUCT(_throw_null_pointer_exception_count++;) | |
576 SharedRuntime::throw_and_post_jvmti_exception(thread, vmSymbols::java_lang_NullPointerException()); | |
577 JRT_END | |
578 | |
579 | |
580 JRT_ENTRY(void, Runtime1::throw_class_cast_exception(JavaThread* thread, oopDesc* object)) | |
581 NOT_PRODUCT(_throw_class_cast_exception_count++;) | |
582 ResourceMark rm(thread); | |
583 char* message = SharedRuntime::generate_class_cast_message( | |
584 thread, Klass::cast(object->klass())->external_name()); | |
585 SharedRuntime::throw_and_post_jvmti_exception( | |
586 thread, vmSymbols::java_lang_ClassCastException(), message); | |
587 JRT_END | |
588 | |
589 | |
590 JRT_ENTRY(void, Runtime1::throw_incompatible_class_change_error(JavaThread* thread)) | |
591 NOT_PRODUCT(_throw_incompatible_class_change_error_count++;) | |
592 ResourceMark rm(thread); | |
593 SharedRuntime::throw_and_post_jvmti_exception(thread, vmSymbols::java_lang_IncompatibleClassChangeError()); | |
594 JRT_END | |
595 | |
596 | |
597 JRT_ENTRY_NO_ASYNC(void, Runtime1::monitorenter(JavaThread* thread, oopDesc* obj, BasicObjectLock* lock)) | |
598 NOT_PRODUCT(_monitorenter_slowcase_cnt++;) | |
599 if (PrintBiasedLockingStatistics) { | |
600 Atomic::inc(BiasedLocking::slow_path_entry_count_addr()); | |
601 } | |
602 Handle h_obj(thread, obj); | |
603 assert(h_obj()->is_oop(), "must be NULL or an object"); | |
604 if (UseBiasedLocking) { | |
605 // Retry fast entry if bias is revoked to avoid unnecessary inflation | |
606 ObjectSynchronizer::fast_enter(h_obj, lock->lock(), true, CHECK); | |
607 } else { | |
608 if (UseFastLocking) { | |
609 // When using fast locking, the compiled code has already tried the fast case | |
610 assert(obj == lock->obj(), "must match"); | |
611 ObjectSynchronizer::slow_enter(h_obj, lock->lock(), THREAD); | |
612 } else { | |
613 lock->set_obj(obj); | |
614 ObjectSynchronizer::fast_enter(h_obj, lock->lock(), false, THREAD); | |
615 } | |
616 } | |
617 JRT_END | |
618 | |
619 | |
620 JRT_LEAF(void, Runtime1::monitorexit(JavaThread* thread, BasicObjectLock* lock)) | |
621 NOT_PRODUCT(_monitorexit_slowcase_cnt++;) | |
622 assert(thread == JavaThread::current(), "threads must correspond"); | |
623 assert(thread->last_Java_sp(), "last_Java_sp must be set"); | |
624 // monitorexit is non-blocking (leaf routine) => no exceptions can be thrown | |
625 EXCEPTION_MARK; | |
626 | |
627 oop obj = lock->obj(); | |
1480
2fe369533fed
Additional debug output.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1472
diff
changeset
|
628 |
2fe369533fed
Additional debug output.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1472
diff
changeset
|
629 #ifdef DEBUG |
2fe369533fed
Additional debug output.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1472
diff
changeset
|
630 if (!obj->is_oop()) { |
2fe369533fed
Additional debug output.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1472
diff
changeset
|
631 ResetNoHandleMark rhm; |
2fe369533fed
Additional debug output.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1472
diff
changeset
|
632 nmethod* method = thread->last_frame().cb()->as_nmethod_or_null(); |
2fe369533fed
Additional debug output.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1472
diff
changeset
|
633 if (method != NULL) { |
2fe369533fed
Additional debug output.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1472
diff
changeset
|
634 tty->print_cr("ERROR in monitorexit in method %s", method->name()); |
2fe369533fed
Additional debug output.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1472
diff
changeset
|
635 } |
2fe369533fed
Additional debug output.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1472
diff
changeset
|
636 thread->print_stack_on(tty); |
2fe369533fed
Additional debug output.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1472
diff
changeset
|
637 assert(false, "invalid lock object pointer dected"); |
2fe369533fed
Additional debug output.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1472
diff
changeset
|
638 } |
2fe369533fed
Additional debug output.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1472
diff
changeset
|
639 #endif |
2fe369533fed
Additional debug output.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1472
diff
changeset
|
640 |
0 | 641 if (UseFastLocking) { |
642 // When using fast locking, the compiled code has already tried the fast case | |
643 ObjectSynchronizer::slow_exit(obj, lock->lock(), THREAD); | |
644 } else { | |
645 ObjectSynchronizer::fast_exit(obj, lock->lock(), THREAD); | |
646 } | |
647 JRT_END | |
648 | |
649 | |
650 static klassOop resolve_field_return_klass(methodHandle caller, int bci, TRAPS) { | |
1602 | 651 Bytecode_field* field_access = Bytecode_field_at(caller, bci); |
0 | 652 // This can be static or non-static field access |
653 Bytecodes::Code code = field_access->code(); | |
654 | |
655 // We must load class, initialize class and resolvethe field | |
656 FieldAccessInfo result; // initialize class if needed | |
657 constantPoolHandle constants(THREAD, caller->constants()); | |
658 LinkResolver::resolve_field(result, constants, field_access->index(), Bytecodes::java_code(code), false, CHECK_NULL); | |
659 return result.klass()(); | |
660 } | |
661 | |
662 | |
663 // | |
664 // This routine patches sites where a class wasn't loaded or | |
665 // initialized at the time the code was generated. It handles | |
666 // references to classes, fields and forcing of initialization. Most | |
667 // of the cases are straightforward and involving simply forcing | |
668 // resolution of a class, rewriting the instruction stream with the | |
669 // needed constant and replacing the call in this function with the | |
670 // patched code. The case for static field is more complicated since | |
671 // the thread which is in the process of initializing a class can | |
672 // access it's static fields but other threads can't so the code | |
673 // either has to deoptimize when this case is detected or execute a | |
674 // check that the current thread is the initializing thread. The | |
675 // current | |
676 // | |
677 // Patches basically look like this: | |
678 // | |
679 // | |
680 // patch_site: jmp patch stub ;; will be patched | |
681 // continue: ... | |
682 // ... | |
683 // ... | |
684 // ... | |
685 // | |
686 // They have a stub which looks like this: | |
687 // | |
688 // ;; patch body | |
689 // movl <const>, reg (for class constants) | |
690 // <or> movl [reg1 + <const>], reg (for field offsets) | |
691 // <or> movl reg, [reg1 + <const>] (for field offsets) | |
692 // <being_init offset> <bytes to copy> <bytes to skip> | |
693 // patch_stub: call Runtime1::patch_code (through a runtime stub) | |
694 // jmp patch_site | |
695 // | |
696 // | |
697 // A normal patch is done by rewriting the patch body, usually a move, | |
698 // and then copying it into place over top of the jmp instruction | |
699 // being careful to flush caches and doing it in an MP-safe way. The | |
700 // constants following the patch body are used to find various pieces | |
701 // of the patch relative to the call site for Runtime1::patch_code. | |
702 // The case for getstatic and putstatic is more complicated because | |
703 // getstatic and putstatic have special semantics when executing while | |
704 // the class is being initialized. getstatic/putstatic on a class | |
705 // which is being_initialized may be executed by the initializing | |
706 // thread but other threads have to block when they execute it. This | |
707 // is accomplished in compiled code by executing a test of the current | |
708 // thread against the initializing thread of the class. It's emitted | |
709 // as boilerplate in their stub which allows the patched code to be | |
710 // executed before it's copied back into the main body of the nmethod. | |
711 // | |
712 // being_init: get_thread(<tmp reg> | |
713 // cmpl [reg1 + <init_thread_offset>], <tmp reg> | |
714 // jne patch_stub | |
715 // movl [reg1 + <const>], reg (for field offsets) <or> | |
716 // movl reg, [reg1 + <const>] (for field offsets) | |
717 // jmp continue | |
718 // <being_init offset> <bytes to copy> <bytes to skip> | |
719 // patch_stub: jmp Runtim1::patch_code (through a runtime stub) | |
720 // jmp patch_site | |
721 // | |
722 // If the class is being initialized the patch body is rewritten and | |
723 // the patch site is rewritten to jump to being_init, instead of | |
724 // patch_stub. Whenever this code is executed it checks the current | |
725 // thread against the intializing thread so other threads will enter | |
726 // the runtime and end up blocked waiting the class to finish | |
727 // initializing inside the calls to resolve_field below. The | |
728 // initializing class will continue on it's way. Once the class is | |
729 // fully_initialized, the intializing_thread of the class becomes | |
730 // NULL, so the next thread to execute this code will fail the test, | |
731 // call into patch_code and complete the patching process by copying | |
732 // the patch body back into the main part of the nmethod and resume | |
733 // executing. | |
734 // | |
735 // | |
736 | |
737 JRT_ENTRY(void, Runtime1::patch_code(JavaThread* thread, Runtime1::StubID stub_id )) | |
738 NOT_PRODUCT(_patch_code_slowcase_cnt++;) | |
739 | |
740 ResourceMark rm(thread); | |
741 RegisterMap reg_map(thread, false); | |
742 frame runtime_frame = thread->last_frame(); | |
743 frame caller_frame = runtime_frame.sender(®_map); | |
744 | |
745 // last java frame on stack | |
746 vframeStream vfst(thread, true); | |
747 assert(!vfst.at_end(), "Java frame must exist"); | |
748 | |
749 methodHandle caller_method(THREAD, vfst.method()); | |
750 // Note that caller_method->code() may not be same as caller_code because of OSR's | |
751 // Note also that in the presence of inlining it is not guaranteed | |
752 // that caller_method() == caller_code->method() | |
753 | |
754 | |
755 int bci = vfst.bci(); | |
756 | |
757 Events::log("patch_code @ " INTPTR_FORMAT , caller_frame.pc()); | |
758 | |
759 Bytecodes::Code code = Bytecode_at(caller_method->bcp_from(bci))->java_code(); | |
760 | |
761 #ifndef PRODUCT | |
762 // this is used by assertions in the access_field_patching_id | |
763 BasicType patch_field_type = T_ILLEGAL; | |
764 #endif // PRODUCT | |
765 bool deoptimize_for_volatile = false; | |
766 int patch_field_offset = -1; | |
767 KlassHandle init_klass(THREAD, klassOop(NULL)); // klass needed by access_field_patching code | |
768 Handle load_klass(THREAD, NULL); // oop needed by load_klass_patching code | |
769 if (stub_id == Runtime1::access_field_patching_id) { | |
770 | |
1602 | 771 Bytecode_field* field_access = Bytecode_field_at(caller_method, bci); |
0 | 772 FieldAccessInfo result; // initialize class if needed |
773 Bytecodes::Code code = field_access->code(); | |
774 constantPoolHandle constants(THREAD, caller_method->constants()); | |
775 LinkResolver::resolve_field(result, constants, field_access->index(), Bytecodes::java_code(code), false, CHECK); | |
776 patch_field_offset = result.field_offset(); | |
777 | |
778 // If we're patching a field which is volatile then at compile it | |
779 // must not have been know to be volatile, so the generated code | |
780 // isn't correct for a volatile reference. The nmethod has to be | |
781 // deoptimized so that the code can be regenerated correctly. | |
782 // This check is only needed for access_field_patching since this | |
783 // is the path for patching field offsets. load_klass is only | |
784 // used for patching references to oops which don't need special | |
785 // handling in the volatile case. | |
786 deoptimize_for_volatile = result.access_flags().is_volatile(); | |
787 | |
788 #ifndef PRODUCT | |
789 patch_field_type = result.field_type(); | |
790 #endif | |
791 } else if (stub_id == Runtime1::load_klass_patching_id) { | |
792 oop k; | |
793 switch (code) { | |
794 case Bytecodes::_putstatic: | |
795 case Bytecodes::_getstatic: | |
796 { klassOop klass = resolve_field_return_klass(caller_method, bci, CHECK); | |
797 // Save a reference to the class that has to be checked for initialization | |
798 init_klass = KlassHandle(THREAD, klass); | |
799 k = klass; | |
800 } | |
801 break; | |
802 case Bytecodes::_new: | |
803 { Bytecode_new* bnew = Bytecode_new_at(caller_method->bcp_from(bci)); | |
804 k = caller_method->constants()->klass_at(bnew->index(), CHECK); | |
805 } | |
806 break; | |
807 case Bytecodes::_multianewarray: | |
808 { Bytecode_multianewarray* mna = Bytecode_multianewarray_at(caller_method->bcp_from(bci)); | |
809 k = caller_method->constants()->klass_at(mna->index(), CHECK); | |
810 } | |
811 break; | |
812 case Bytecodes::_instanceof: | |
813 { Bytecode_instanceof* io = Bytecode_instanceof_at(caller_method->bcp_from(bci)); | |
814 k = caller_method->constants()->klass_at(io->index(), CHECK); | |
815 } | |
816 break; | |
817 case Bytecodes::_checkcast: | |
818 { Bytecode_checkcast* cc = Bytecode_checkcast_at(caller_method->bcp_from(bci)); | |
819 k = caller_method->constants()->klass_at(cc->index(), CHECK); | |
820 } | |
821 break; | |
822 case Bytecodes::_anewarray: | |
823 { Bytecode_anewarray* anew = Bytecode_anewarray_at(caller_method->bcp_from(bci)); | |
824 klassOop ek = caller_method->constants()->klass_at(anew->index(), CHECK); | |
825 k = Klass::cast(ek)->array_klass(CHECK); | |
826 } | |
827 break; | |
828 case Bytecodes::_ldc: | |
829 case Bytecodes::_ldc_w: | |
830 { | |
1602 | 831 Bytecode_loadconstant* cc = Bytecode_loadconstant_at(caller_method, bci); |
832 k = cc->resolve_constant(CHECK); | |
833 assert(k != NULL && !k->is_klass(), "must be class mirror or other Java constant"); | |
0 | 834 } |
835 break; | |
1472
7641338cfc92
Small NPE fix. More detailed error in case of wrong bytecode in patching stub.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1449
diff
changeset
|
836 default: |
7641338cfc92
Small NPE fix. More detailed error in case of wrong bytecode in patching stub.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1449
diff
changeset
|
837 tty->print_cr("Unhandled bytecode: %d stub_id=%d caller=%s bci=%d pc=%d", code, stub_id, caller_method->name()->as_C_string(), bci, caller_frame.pc()); |
7641338cfc92
Small NPE fix. More detailed error in case of wrong bytecode in patching stub.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1449
diff
changeset
|
838 Unimplemented(); |
0 | 839 } |
840 // convert to handle | |
841 load_klass = Handle(THREAD, k); | |
842 } else { | |
843 ShouldNotReachHere(); | |
844 } | |
845 | |
846 if (deoptimize_for_volatile) { | |
847 // At compile time we assumed the field wasn't volatile but after | |
848 // loading it turns out it was volatile so we have to throw the | |
849 // compiled code out and let it be regenerated. | |
850 if (TracePatching) { | |
851 tty->print_cr("Deoptimizing for patching volatile field reference"); | |
852 } | |
485
ac8fe14c93e4
6767587: missing call to make_not_entrant after deoptimizing for patching volatiles
never
parents:
362
diff
changeset
|
853 // It's possible the nmethod was invalidated in the last |
ac8fe14c93e4
6767587: missing call to make_not_entrant after deoptimizing for patching volatiles
never
parents:
362
diff
changeset
|
854 // safepoint, but if it's still alive then make it not_entrant. |
ac8fe14c93e4
6767587: missing call to make_not_entrant after deoptimizing for patching volatiles
never
parents:
362
diff
changeset
|
855 nmethod* nm = CodeCache::find_nmethod(caller_frame.pc()); |
ac8fe14c93e4
6767587: missing call to make_not_entrant after deoptimizing for patching volatiles
never
parents:
362
diff
changeset
|
856 if (nm != NULL) { |
ac8fe14c93e4
6767587: missing call to make_not_entrant after deoptimizing for patching volatiles
never
parents:
362
diff
changeset
|
857 nm->make_not_entrant(); |
ac8fe14c93e4
6767587: missing call to make_not_entrant after deoptimizing for patching volatiles
never
parents:
362
diff
changeset
|
858 } |
ac8fe14c93e4
6767587: missing call to make_not_entrant after deoptimizing for patching volatiles
never
parents:
362
diff
changeset
|
859 |
1905
ce6848d0666d
6968367: can_post_on_exceptions is still using VM_DeoptimizeFrame in some places
never
parents:
1783
diff
changeset
|
860 Deoptimization::deoptimize_frame(thread, caller_frame.id()); |
0 | 861 |
862 // Return to the now deoptimized frame. | |
863 } | |
864 | |
1602 | 865 // If we are patching in a non-perm oop, make sure the nmethod |
866 // is on the right list. | |
867 if (ScavengeRootsInCode && load_klass.not_null() && load_klass->is_scavengable()) { | |
868 MutexLockerEx ml_code (CodeCache_lock, Mutex::_no_safepoint_check_flag); | |
869 nmethod* nm = CodeCache::find_nmethod(caller_frame.pc()); | |
870 guarantee(nm != NULL, "only nmethods can contain non-perm oops"); | |
871 if (!nm->on_scavenge_root_list()) | |
872 CodeCache::add_scavenge_root_nmethod(nm); | |
873 } | |
0 | 874 |
875 // Now copy code back | |
876 | |
877 { | |
878 MutexLockerEx ml_patch (Patching_lock, Mutex::_no_safepoint_check_flag); | |
879 // | |
880 // Deoptimization may have happened while we waited for the lock. | |
881 // In that case we don't bother to do any patching we just return | |
882 // and let the deopt happen | |
883 if (!caller_is_deopted()) { | |
884 NativeGeneralJump* jump = nativeGeneralJump_at(caller_frame.pc()); | |
885 address instr_pc = jump->jump_destination(); | |
886 NativeInstruction* ni = nativeInstruction_at(instr_pc); | |
887 if (ni->is_jump() ) { | |
888 // the jump has not been patched yet | |
889 // The jump destination is slow case and therefore not part of the stubs | |
890 // (stubs are only for StaticCalls) | |
891 | |
892 // format of buffer | |
893 // .... | |
894 // instr byte 0 <-- copy_buff | |
895 // instr byte 1 | |
896 // .. | |
897 // instr byte n-1 | |
898 // n | |
899 // .... <-- call destination | |
900 | |
901 address stub_location = caller_frame.pc() + PatchingStub::patch_info_offset(); | |
902 unsigned char* byte_count = (unsigned char*) (stub_location - 1); | |
903 unsigned char* byte_skip = (unsigned char*) (stub_location - 2); | |
904 unsigned char* being_initialized_entry_offset = (unsigned char*) (stub_location - 3); | |
905 address copy_buff = stub_location - *byte_skip - *byte_count; | |
906 address being_initialized_entry = stub_location - *being_initialized_entry_offset; | |
907 if (TracePatching) { | |
908 tty->print_cr(" Patching %s at bci %d at address 0x%x (%s)", Bytecodes::name(code), bci, | |
909 instr_pc, (stub_id == Runtime1::access_field_patching_id) ? "field" : "klass"); | |
910 nmethod* caller_code = CodeCache::find_nmethod(caller_frame.pc()); | |
911 assert(caller_code != NULL, "nmethod not found"); | |
912 | |
913 // NOTE we use pc() not original_pc() because we already know they are | |
914 // identical otherwise we'd have never entered this block of code | |
915 | |
916 OopMap* map = caller_code->oop_map_for_return_address(caller_frame.pc()); | |
917 assert(map != NULL, "null check"); | |
918 map->print(); | |
919 tty->cr(); | |
920 | |
921 Disassembler::decode(copy_buff, copy_buff + *byte_count, tty); | |
922 } | |
923 // depending on the code below, do_patch says whether to copy the patch body back into the nmethod | |
924 bool do_patch = true; | |
925 if (stub_id == Runtime1::access_field_patching_id) { | |
926 // The offset may not be correct if the class was not loaded at code generation time. | |
927 // Set it now. | |
928 NativeMovRegMem* n_move = nativeMovRegMem_at(copy_buff); | |
929 assert(n_move->offset() == 0 || (n_move->offset() == 4 && (patch_field_type == T_DOUBLE || patch_field_type == T_LONG)), "illegal offset for type"); | |
930 assert(patch_field_offset >= 0, "illegal offset"); | |
931 n_move->add_offset_in_bytes(patch_field_offset); | |
932 } else if (stub_id == Runtime1::load_klass_patching_id) { | |
933 // If a getstatic or putstatic is referencing a klass which | |
934 // isn't fully initialized, the patch body isn't copied into | |
935 // place until initialization is complete. In this case the | |
936 // patch site is setup so that any threads besides the | |
937 // initializing thread are forced to come into the VM and | |
938 // block. | |
939 do_patch = (code != Bytecodes::_getstatic && code != Bytecodes::_putstatic) || | |
940 instanceKlass::cast(init_klass())->is_initialized(); | |
941 NativeGeneralJump* jump = nativeGeneralJump_at(instr_pc); | |
942 if (jump->jump_destination() == being_initialized_entry) { | |
943 assert(do_patch == true, "initialization must be complete at this point"); | |
944 } else { | |
945 // patch the instruction <move reg, klass> | |
946 NativeMovConstReg* n_copy = nativeMovConstReg_at(copy_buff); | |
1681
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1603
diff
changeset
|
947 |
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1603
diff
changeset
|
948 assert(n_copy->data() == 0 || |
1783 | 949 n_copy->data() == (intptr_t)Universe::non_oop_word(), |
1681
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1603
diff
changeset
|
950 "illegal init value"); |
0 | 951 assert(load_klass() != NULL, "klass not set"); |
952 n_copy->set_data((intx) (load_klass())); | |
953 | |
954 if (TracePatching) { | |
955 Disassembler::decode(copy_buff, copy_buff + *byte_count, tty); | |
956 } | |
957 | |
1681
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1603
diff
changeset
|
958 #if defined(SPARC) || defined(PPC) |
0 | 959 // Update the oop location in the nmethod with the proper |
960 // oop. When the code was generated, a NULL was stuffed | |
961 // in the oop table and that table needs to be update to | |
962 // have the right value. On intel the value is kept | |
963 // directly in the instruction instead of in the oop | |
964 // table, so set_data above effectively updated the value. | |
965 nmethod* nm = CodeCache::find_nmethod(instr_pc); | |
966 assert(nm != NULL, "invalid nmethod_pc"); | |
967 RelocIterator oops(nm, copy_buff, copy_buff + 1); | |
968 bool found = false; | |
969 while (oops.next() && !found) { | |
970 if (oops.type() == relocInfo::oop_type) { | |
971 oop_Relocation* r = oops.oop_reloc(); | |
972 oop* oop_adr = r->oop_addr(); | |
973 *oop_adr = load_klass(); | |
974 r->fix_oop_relocation(); | |
975 found = true; | |
976 } | |
977 } | |
978 assert(found, "the oop must exist!"); | |
979 #endif | |
980 | |
981 } | |
982 } else { | |
983 ShouldNotReachHere(); | |
984 } | |
985 if (do_patch) { | |
986 // replace instructions | |
987 // first replace the tail, then the call | |
1681
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1603
diff
changeset
|
988 #ifdef ARM |
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1603
diff
changeset
|
989 if(stub_id == Runtime1::load_klass_patching_id && !VM_Version::supports_movw()) { |
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1603
diff
changeset
|
990 copy_buff -= *byte_count; |
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1603
diff
changeset
|
991 NativeMovConstReg* n_copy2 = nativeMovConstReg_at(copy_buff); |
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1603
diff
changeset
|
992 n_copy2->set_data((intx) (load_klass()), instr_pc); |
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1603
diff
changeset
|
993 } |
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1603
diff
changeset
|
994 #endif |
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1603
diff
changeset
|
995 |
0 | 996 for (int i = NativeCall::instruction_size; i < *byte_count; i++) { |
997 address ptr = copy_buff + i; | |
998 int a_byte = (*ptr) & 0xFF; | |
999 address dst = instr_pc + i; | |
1000 *(unsigned char*)dst = (unsigned char) a_byte; | |
1001 } | |
1002 ICache::invalidate_range(instr_pc, *byte_count); | |
1003 NativeGeneralJump::replace_mt_safe(instr_pc, copy_buff); | |
1004 | |
1005 if (stub_id == Runtime1::load_klass_patching_id) { | |
1006 // update relocInfo to oop | |
1007 nmethod* nm = CodeCache::find_nmethod(instr_pc); | |
1008 assert(nm != NULL, "invalid nmethod_pc"); | |
1009 | |
1010 // The old patch site is now a move instruction so update | |
1011 // the reloc info so that it will get updated during | |
1012 // future GCs. | |
1013 RelocIterator iter(nm, (address)instr_pc, (address)(instr_pc + 1)); | |
1014 relocInfo::change_reloc_info_for_address(&iter, (address) instr_pc, | |
1015 relocInfo::none, relocInfo::oop_type); | |
1016 #ifdef SPARC | |
1017 // Sparc takes two relocations for an oop so update the second one. | |
1018 address instr_pc2 = instr_pc + NativeMovConstReg::add_offset; | |
1019 RelocIterator iter2(nm, instr_pc2, instr_pc2 + 1); | |
1020 relocInfo::change_reloc_info_for_address(&iter2, (address) instr_pc2, | |
1021 relocInfo::none, relocInfo::oop_type); | |
1022 #endif | |
1681
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1603
diff
changeset
|
1023 #ifdef PPC |
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1603
diff
changeset
|
1024 { address instr_pc2 = instr_pc + NativeMovConstReg::lo_offset; |
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1603
diff
changeset
|
1025 RelocIterator iter2(nm, instr_pc2, instr_pc2 + 1); |
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1603
diff
changeset
|
1026 relocInfo::change_reloc_info_for_address(&iter2, (address) instr_pc2, relocInfo::none, relocInfo::oop_type); |
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1603
diff
changeset
|
1027 } |
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1603
diff
changeset
|
1028 #endif |
0 | 1029 } |
1030 | |
1031 } else { | |
1032 ICache::invalidate_range(copy_buff, *byte_count); | |
1033 NativeGeneralJump::insert_unconditional(instr_pc, being_initialized_entry); | |
1034 } | |
1035 } | |
1036 } | |
1037 } | |
1038 JRT_END | |
1039 | |
1040 // | |
1041 // Entry point for compiled code. We want to patch a nmethod. | |
1042 // We don't do a normal VM transition here because we want to | |
1043 // know after the patching is complete and any safepoint(s) are taken | |
1044 // if the calling nmethod was deoptimized. We do this by calling a | |
1045 // helper method which does the normal VM transition and when it | |
1046 // completes we can check for deoptimization. This simplifies the | |
1047 // assembly code in the cpu directories. | |
1048 // | |
1049 int Runtime1::move_klass_patching(JavaThread* thread) { | |
1050 // | |
1051 // NOTE: we are still in Java | |
1052 // | |
1053 Thread* THREAD = thread; | |
1054 debug_only(NoHandleMark nhm;) | |
1055 { | |
1056 // Enter VM mode | |
1057 | |
1058 ResetNoHandleMark rnhm; | |
1059 patch_code(thread, load_klass_patching_id); | |
1060 } | |
1061 // Back in JAVA, use no oops DON'T safepoint | |
1062 | |
1063 // Return true if calling code is deoptimized | |
1064 | |
1065 return caller_is_deopted(); | |
1066 } | |
1067 | |
1068 // | |
1069 // Entry point for compiled code. We want to patch a nmethod. | |
1070 // We don't do a normal VM transition here because we want to | |
1071 // know after the patching is complete and any safepoint(s) are taken | |
1072 // if the calling nmethod was deoptimized. We do this by calling a | |
1073 // helper method which does the normal VM transition and when it | |
1074 // completes we can check for deoptimization. This simplifies the | |
1075 // assembly code in the cpu directories. | |
1076 // | |
1077 | |
1078 int Runtime1::access_field_patching(JavaThread* thread) { | |
1079 // | |
1080 // NOTE: we are still in Java | |
1081 // | |
1082 Thread* THREAD = thread; | |
1083 debug_only(NoHandleMark nhm;) | |
1084 { | |
1085 // Enter VM mode | |
1086 | |
1087 ResetNoHandleMark rnhm; | |
1088 patch_code(thread, access_field_patching_id); | |
1089 } | |
1090 // Back in JAVA, use no oops DON'T safepoint | |
1091 | |
1092 // Return true if calling code is deoptimized | |
1093 | |
1094 return caller_is_deopted(); | |
1095 JRT_END | |
1096 | |
1097 | |
1098 JRT_LEAF(void, Runtime1::trace_block_entry(jint block_id)) | |
1099 // for now we just print out the block id | |
1100 tty->print("%d ", block_id); | |
1101 JRT_END | |
1102 | |
1103 | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
1104 // Array copy return codes. |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
1105 enum { |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
1106 ac_failed = -1, // arraycopy failed |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
1107 ac_ok = 0 // arraycopy succeeded |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
1108 }; |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
1109 |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
1110 |
1245
6484c4ee11cb
6904516: More object array barrier fixes, following up on 6906727
ysr
parents:
1142
diff
changeset
|
1111 // Below length is the # elements copied. |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
1112 template <class T> int obj_arraycopy_work(oopDesc* src, T* src_addr, |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
1113 oopDesc* dst, T* dst_addr, |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
1114 int length) { |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
1115 |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
1116 // For performance reasons, we assume we are using a card marking write |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
1117 // barrier. The assert will fail if this is not the case. |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
1118 // Note that we use the non-virtual inlineable variant of write_ref_array. |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
1119 BarrierSet* bs = Universe::heap()->barrier_set(); |
1245
6484c4ee11cb
6904516: More object array barrier fixes, following up on 6906727
ysr
parents:
1142
diff
changeset
|
1120 assert(bs->has_write_ref_array_opt(), "Barrier set must have ref array opt"); |
6484c4ee11cb
6904516: More object array barrier fixes, following up on 6906727
ysr
parents:
1142
diff
changeset
|
1121 assert(bs->has_write_ref_array_pre_opt(), "For pre-barrier as well."); |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
1122 if (src == dst) { |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
1123 // same object, no check |
1245
6484c4ee11cb
6904516: More object array barrier fixes, following up on 6906727
ysr
parents:
1142
diff
changeset
|
1124 bs->write_ref_array_pre(dst_addr, length); |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
1125 Copy::conjoint_oops_atomic(src_addr, dst_addr, length); |
1245
6484c4ee11cb
6904516: More object array barrier fixes, following up on 6906727
ysr
parents:
1142
diff
changeset
|
1126 bs->write_ref_array((HeapWord*)dst_addr, length); |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
1127 return ac_ok; |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
1128 } else { |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
1129 klassOop bound = objArrayKlass::cast(dst->klass())->element_klass(); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
1130 klassOop stype = objArrayKlass::cast(src->klass())->element_klass(); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
1131 if (stype == bound || Klass::cast(stype)->is_subtype_of(bound)) { |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
1132 // Elements are guaranteed to be subtypes, so no check necessary |
1245
6484c4ee11cb
6904516: More object array barrier fixes, following up on 6906727
ysr
parents:
1142
diff
changeset
|
1133 bs->write_ref_array_pre(dst_addr, length); |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
1134 Copy::conjoint_oops_atomic(src_addr, dst_addr, length); |
1245
6484c4ee11cb
6904516: More object array barrier fixes, following up on 6906727
ysr
parents:
1142
diff
changeset
|
1135 bs->write_ref_array((HeapWord*)dst_addr, length); |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
1136 return ac_ok; |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
1137 } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
1138 } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
1139 return ac_failed; |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
1140 } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
1141 |
0 | 1142 // fast and direct copy of arrays; returning -1, means that an exception may be thrown |
1143 // and we did not copy anything | |
1144 JRT_LEAF(int, Runtime1::arraycopy(oopDesc* src, int src_pos, oopDesc* dst, int dst_pos, int length)) | |
1145 #ifndef PRODUCT | |
1146 _generic_arraycopy_cnt++; // Slow-path oop array copy | |
1147 #endif | |
1148 | |
1149 if (src == NULL || dst == NULL || src_pos < 0 || dst_pos < 0 || length < 0) return ac_failed; | |
1150 if (!dst->is_array() || !src->is_array()) return ac_failed; | |
1151 if ((unsigned int) arrayOop(src)->length() < (unsigned int)src_pos + (unsigned int)length) return ac_failed; | |
1152 if ((unsigned int) arrayOop(dst)->length() < (unsigned int)dst_pos + (unsigned int)length) return ac_failed; | |
1153 | |
1154 if (length == 0) return ac_ok; | |
1155 if (src->is_typeArray()) { | |
1156 const klassOop klass_oop = src->klass(); | |
1157 if (klass_oop != dst->klass()) return ac_failed; | |
1158 typeArrayKlass* klass = typeArrayKlass::cast(klass_oop); | |
1159 const int l2es = klass->log2_element_size(); | |
1160 const int ihs = klass->array_header_in_bytes() / wordSize; | |
1161 char* src_addr = (char*) ((oopDesc**)src + ihs) + (src_pos << l2es); | |
1162 char* dst_addr = (char*) ((oopDesc**)dst + ihs) + (dst_pos << l2es); | |
1163 // Potential problem: memmove is not guaranteed to be word atomic | |
1164 // Revisit in Merlin | |
1165 memmove(dst_addr, src_addr, length << l2es); | |
1166 return ac_ok; | |
1167 } else if (src->is_objArray() && dst->is_objArray()) { | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
1168 if (UseCompressedOops) { // will need for tiered |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
1169 narrowOop *src_addr = objArrayOop(src)->obj_at_addr<narrowOop>(src_pos); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
1170 narrowOop *dst_addr = objArrayOop(dst)->obj_at_addr<narrowOop>(dst_pos); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
1171 return obj_arraycopy_work(src, src_addr, dst, dst_addr, length); |
0 | 1172 } else { |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
1173 oop *src_addr = objArrayOop(src)->obj_at_addr<oop>(src_pos); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
1174 oop *dst_addr = objArrayOop(dst)->obj_at_addr<oop>(dst_pos); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
1175 return obj_arraycopy_work(src, src_addr, dst, dst_addr, length); |
0 | 1176 } |
1177 } | |
1178 return ac_failed; | |
1179 JRT_END | |
1180 | |
1181 | |
1182 JRT_LEAF(void, Runtime1::primitive_arraycopy(HeapWord* src, HeapWord* dst, int length)) | |
1183 #ifndef PRODUCT | |
1184 _primitive_arraycopy_cnt++; | |
1185 #endif | |
1186 | |
1187 if (length == 0) return; | |
1188 // Not guaranteed to be word atomic, but that doesn't matter | |
1189 // for anything but an oop array, which is covered by oop_arraycopy. | |
1603
d93949c5bdcc
6730276: JDI_REGRESSION tests fail with "Error: count must be non-zero" error on x86
kvn
parents:
1602
diff
changeset
|
1190 Copy::conjoint_jbytes(src, dst, length); |
0 | 1191 JRT_END |
1192 | |
1193 JRT_LEAF(void, Runtime1::oop_arraycopy(HeapWord* src, HeapWord* dst, int num)) | |
1194 #ifndef PRODUCT | |
1195 _oop_arraycopy_cnt++; | |
1196 #endif | |
1197 | |
1198 if (num == 0) return; | |
1245
6484c4ee11cb
6904516: More object array barrier fixes, following up on 6906727
ysr
parents:
1142
diff
changeset
|
1199 BarrierSet* bs = Universe::heap()->barrier_set(); |
6484c4ee11cb
6904516: More object array barrier fixes, following up on 6906727
ysr
parents:
1142
diff
changeset
|
1200 assert(bs->has_write_ref_array_opt(), "Barrier set must have ref array opt"); |
6484c4ee11cb
6904516: More object array barrier fixes, following up on 6906727
ysr
parents:
1142
diff
changeset
|
1201 assert(bs->has_write_ref_array_pre_opt(), "For pre-barrier as well."); |
6484c4ee11cb
6904516: More object array barrier fixes, following up on 6906727
ysr
parents:
1142
diff
changeset
|
1202 if (UseCompressedOops) { |
6484c4ee11cb
6904516: More object array barrier fixes, following up on 6906727
ysr
parents:
1142
diff
changeset
|
1203 bs->write_ref_array_pre((narrowOop*)dst, num); |
6484c4ee11cb
6904516: More object array barrier fixes, following up on 6906727
ysr
parents:
1142
diff
changeset
|
1204 } else { |
6484c4ee11cb
6904516: More object array barrier fixes, following up on 6906727
ysr
parents:
1142
diff
changeset
|
1205 bs->write_ref_array_pre((oop*)dst, num); |
6484c4ee11cb
6904516: More object array barrier fixes, following up on 6906727
ysr
parents:
1142
diff
changeset
|
1206 } |
0 | 1207 Copy::conjoint_oops_atomic((oop*) src, (oop*) dst, num); |
1245
6484c4ee11cb
6904516: More object array barrier fixes, following up on 6906727
ysr
parents:
1142
diff
changeset
|
1208 bs->write_ref_array(dst, num); |
0 | 1209 JRT_END |
1210 | |
1211 | |
1212 #ifndef PRODUCT | |
1213 void Runtime1::print_statistics() { | |
1214 tty->print_cr("C1 Runtime statistics:"); | |
1215 tty->print_cr(" _resolve_invoke_virtual_cnt: %d", SharedRuntime::_resolve_virtual_ctr); | |
1216 tty->print_cr(" _resolve_invoke_opt_virtual_cnt: %d", SharedRuntime::_resolve_opt_virtual_ctr); | |
1217 tty->print_cr(" _resolve_invoke_static_cnt: %d", SharedRuntime::_resolve_static_ctr); | |
1218 tty->print_cr(" _handle_wrong_method_cnt: %d", SharedRuntime::_wrong_method_ctr); | |
1219 tty->print_cr(" _ic_miss_cnt: %d", SharedRuntime::_ic_miss_ctr); | |
1220 tty->print_cr(" _generic_arraycopy_cnt: %d", _generic_arraycopy_cnt); | |
1221 tty->print_cr(" _primitive_arraycopy_cnt: %d", _primitive_arraycopy_cnt); | |
1222 tty->print_cr(" _oop_arraycopy_cnt: %d", _oop_arraycopy_cnt); | |
1223 tty->print_cr(" _arraycopy_slowcase_cnt: %d", _arraycopy_slowcase_cnt); | |
1224 | |
1225 tty->print_cr(" _new_type_array_slowcase_cnt: %d", _new_type_array_slowcase_cnt); | |
1226 tty->print_cr(" _new_object_array_slowcase_cnt: %d", _new_object_array_slowcase_cnt); | |
1227 tty->print_cr(" _new_instance_slowcase_cnt: %d", _new_instance_slowcase_cnt); | |
1228 tty->print_cr(" _new_multi_array_slowcase_cnt: %d", _new_multi_array_slowcase_cnt); | |
1229 tty->print_cr(" _monitorenter_slowcase_cnt: %d", _monitorenter_slowcase_cnt); | |
1230 tty->print_cr(" _monitorexit_slowcase_cnt: %d", _monitorexit_slowcase_cnt); | |
1231 tty->print_cr(" _patch_code_slowcase_cnt: %d", _patch_code_slowcase_cnt); | |
1232 | |
1233 tty->print_cr(" _throw_range_check_exception_count: %d:", _throw_range_check_exception_count); | |
1234 tty->print_cr(" _throw_index_exception_count: %d:", _throw_index_exception_count); | |
1235 tty->print_cr(" _throw_div0_exception_count: %d:", _throw_div0_exception_count); | |
1236 tty->print_cr(" _throw_null_pointer_exception_count: %d:", _throw_null_pointer_exception_count); | |
1237 tty->print_cr(" _throw_class_cast_exception_count: %d:", _throw_class_cast_exception_count); | |
1238 tty->print_cr(" _throw_incompatible_class_change_error_count: %d:", _throw_incompatible_class_change_error_count); | |
1239 tty->print_cr(" _throw_array_store_exception_count: %d:", _throw_array_store_exception_count); | |
1240 tty->print_cr(" _throw_count: %d:", _throw_count); | |
1241 | |
1242 SharedRuntime::print_ic_miss_histogram(); | |
1243 tty->cr(); | |
1244 } | |
1245 #endif // PRODUCT |