Mercurial > hg > graal-jvmci-8
comparison src/share/vm/runtime/sharedRuntime.cpp @ 13451:02f27ecb4f3a
Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Wed, 18 Dec 2013 00:00:24 +0100 |
parents | cefad50507d8 df832bd8edb9 |
children | d8041d695d19 |
comparison
equal
deleted
inserted
replaced
13371:4db09b7304da | 13451:02f27ecb4f3a |
---|---|
82 #include "c1/c1_Runtime1.hpp" | 82 #include "c1/c1_Runtime1.hpp" |
83 #endif | 83 #endif |
84 | 84 |
85 // Shared stub locations | 85 // Shared stub locations |
86 RuntimeStub* SharedRuntime::_wrong_method_blob; | 86 RuntimeStub* SharedRuntime::_wrong_method_blob; |
87 RuntimeStub* SharedRuntime::_wrong_method_abstract_blob; | |
87 RuntimeStub* SharedRuntime::_ic_miss_blob; | 88 RuntimeStub* SharedRuntime::_ic_miss_blob; |
88 RuntimeStub* SharedRuntime::_resolve_opt_virtual_call_blob; | 89 RuntimeStub* SharedRuntime::_resolve_opt_virtual_call_blob; |
89 RuntimeStub* SharedRuntime::_resolve_virtual_call_blob; | 90 RuntimeStub* SharedRuntime::_resolve_virtual_call_blob; |
90 RuntimeStub* SharedRuntime::_resolve_static_call_blob; | 91 RuntimeStub* SharedRuntime::_resolve_static_call_blob; |
91 | 92 |
99 #endif // COMPILER2 | 100 #endif // COMPILER2 |
100 | 101 |
101 | 102 |
102 //----------------------------generate_stubs----------------------------------- | 103 //----------------------------generate_stubs----------------------------------- |
103 void SharedRuntime::generate_stubs() { | 104 void SharedRuntime::generate_stubs() { |
104 _wrong_method_blob = generate_resolve_blob(CAST_FROM_FN_PTR(address, SharedRuntime::handle_wrong_method), "wrong_method_stub"); | 105 _wrong_method_blob = generate_resolve_blob(CAST_FROM_FN_PTR(address, SharedRuntime::handle_wrong_method), "wrong_method_stub"); |
105 _ic_miss_blob = generate_resolve_blob(CAST_FROM_FN_PTR(address, SharedRuntime::handle_wrong_method_ic_miss), "ic_miss_stub"); | 106 _wrong_method_abstract_blob = generate_resolve_blob(CAST_FROM_FN_PTR(address, SharedRuntime::handle_wrong_method_abstract), "wrong_method_abstract_stub"); |
106 _resolve_opt_virtual_call_blob = generate_resolve_blob(CAST_FROM_FN_PTR(address, SharedRuntime::resolve_opt_virtual_call_C), "resolve_opt_virtual_call"); | 107 _ic_miss_blob = generate_resolve_blob(CAST_FROM_FN_PTR(address, SharedRuntime::handle_wrong_method_ic_miss), "ic_miss_stub"); |
107 _resolve_virtual_call_blob = generate_resolve_blob(CAST_FROM_FN_PTR(address, SharedRuntime::resolve_virtual_call_C), "resolve_virtual_call"); | 108 _resolve_opt_virtual_call_blob = generate_resolve_blob(CAST_FROM_FN_PTR(address, SharedRuntime::resolve_opt_virtual_call_C), "resolve_opt_virtual_call"); |
108 _resolve_static_call_blob = generate_resolve_blob(CAST_FROM_FN_PTR(address, SharedRuntime::resolve_static_call_C), "resolve_static_call"); | 109 _resolve_virtual_call_blob = generate_resolve_blob(CAST_FROM_FN_PTR(address, SharedRuntime::resolve_virtual_call_C), "resolve_virtual_call"); |
110 _resolve_static_call_blob = generate_resolve_blob(CAST_FROM_FN_PTR(address, SharedRuntime::resolve_static_call_C), "resolve_static_call"); | |
109 | 111 |
110 #ifdef COMPILER2 | 112 #ifdef COMPILER2 |
111 // Vectors are generated only by C2. | 113 // Vectors are generated only by C2. |
112 if (is_wide_vector(MaxVectorSize)) { | 114 if (is_wide_vector(MaxVectorSize)) { |
113 _polling_page_vectors_safepoint_handler_blob = generate_handler_blob(CAST_FROM_FN_PTR(address, SafepointSynchronize::handle_polling_page_exception), POLL_AT_VECTOR_LOOP); | 115 _polling_page_vectors_safepoint_handler_blob = generate_handler_blob(CAST_FROM_FN_PTR(address, SafepointSynchronize::handle_polling_page_exception), POLL_AT_VECTOR_LOOP); |
1236 frame caller_frame = thread->last_frame().sender(&cbl_map); | 1238 frame caller_frame = thread->last_frame().sender(&cbl_map); |
1237 | 1239 |
1238 CodeBlob* caller_cb = caller_frame.cb(); | 1240 CodeBlob* caller_cb = caller_frame.cb(); |
1239 guarantee(caller_cb != NULL && caller_cb->is_nmethod(), "must be called from nmethod"); | 1241 guarantee(caller_cb != NULL && caller_cb->is_nmethod(), "must be called from nmethod"); |
1240 nmethod* caller_nm = caller_cb->as_nmethod_or_null(); | 1242 nmethod* caller_nm = caller_cb->as_nmethod_or_null(); |
1243 | |
1241 // make sure caller is not getting deoptimized | 1244 // make sure caller is not getting deoptimized |
1242 // and removed before we are done with it. | 1245 // and removed before we are done with it. |
1243 // CLEANUP - with lazy deopt shouldn't need this lock | 1246 // CLEANUP - with lazy deopt shouldn't need this lock |
1244 nmethodLocker caller_lock(caller_nm); | 1247 nmethodLocker caller_lock(caller_nm); |
1245 | |
1246 | 1248 |
1247 // determine call info & receiver | 1249 // determine call info & receiver |
1248 // note: a) receiver is NULL for static calls | 1250 // note: a) receiver is NULL for static calls |
1249 // b) an exception is thrown if receiver is NULL for non-static calls | 1251 // b) an exception is thrown if receiver is NULL for non-static calls |
1250 CallInfo call_info; | 1252 CallInfo call_info; |
1256 assert((!is_virtual && invoke_code == Bytecodes::_invokestatic ) || | 1258 assert((!is_virtual && invoke_code == Bytecodes::_invokestatic ) || |
1257 (!is_virtual && invoke_code == Bytecodes::_invokehandle ) || | 1259 (!is_virtual && invoke_code == Bytecodes::_invokehandle ) || |
1258 (!is_virtual && invoke_code == Bytecodes::_invokedynamic) || | 1260 (!is_virtual && invoke_code == Bytecodes::_invokedynamic) || |
1259 ( is_virtual && invoke_code != Bytecodes::_invokestatic ), "inconsistent bytecode"); | 1261 ( is_virtual && invoke_code != Bytecodes::_invokestatic ), "inconsistent bytecode"); |
1260 | 1262 |
1263 // We do not patch the call site if the caller nmethod has been made non-entrant. | |
1264 if (!caller_nm->is_in_use()) { | |
1265 return callee_method; | |
1266 } | |
1267 | |
1261 #ifndef PRODUCT | 1268 #ifndef PRODUCT |
1262 // tracing/debugging/statistics | 1269 // tracing/debugging/statistics |
1263 int *addr = (is_optimized) ? (&_resolve_opt_virtual_ctr) : | 1270 int *addr = (is_optimized) ? (&_resolve_opt_virtual_ctr) : |
1264 (is_virtual) ? (&_resolve_virtual_ctr) : | 1271 (is_virtual) ? (&_resolve_virtual_ctr) : |
1265 (&_resolve_static_ctr); | 1272 (&_resolve_static_ctr); |
1295 CompiledICInfo virtual_call_info; | 1302 CompiledICInfo virtual_call_info; |
1296 | 1303 |
1297 // Make sure the callee nmethod does not get deoptimized and removed before | 1304 // Make sure the callee nmethod does not get deoptimized and removed before |
1298 // we are done patching the code. | 1305 // we are done patching the code. |
1299 nmethod* callee_nm = callee_method->code(); | 1306 nmethod* callee_nm = callee_method->code(); |
1307 if (callee_nm != NULL && !callee_nm->is_in_use()) { | |
1308 // Patch call site to C2I adapter if callee nmethod is deoptimized or unloaded. | |
1309 callee_nm = NULL; | |
1310 } | |
1300 nmethodLocker nl_callee(callee_nm); | 1311 nmethodLocker nl_callee(callee_nm); |
1301 #ifdef ASSERT | 1312 #ifdef ASSERT |
1302 address dest_entry_point = callee_nm == NULL ? 0 : callee_nm->entry_point(); // used below | 1313 address dest_entry_point = callee_nm == NULL ? 0 : callee_nm->entry_point(); // used below |
1303 #endif | 1314 #endif |
1304 | 1315 |
1316 | 1327 |
1317 // grab lock, check for deoptimization and potentially patch caller | 1328 // grab lock, check for deoptimization and potentially patch caller |
1318 { | 1329 { |
1319 MutexLocker ml_patch(CompiledIC_lock); | 1330 MutexLocker ml_patch(CompiledIC_lock); |
1320 | 1331 |
1332 // Lock blocks for safepoint during which both nmethods can change state. | |
1333 | |
1321 // Now that we are ready to patch if the Method* was redefined then | 1334 // Now that we are ready to patch if the Method* was redefined then |
1322 // don't update call site and let the caller retry. | 1335 // don't update call site and let the caller retry. |
1323 | 1336 // Don't update call site if caller nmethod has been made non-entrant |
1324 if (!callee_method->is_old()) { | 1337 // as it is a waste of time. |
1338 // Don't update call site if callee nmethod was unloaded or deoptimized. | |
1339 // Don't update call site if callee nmethod was replaced by an other nmethod | |
1340 // which may happen when multiply alive nmethod (tiered compilation) | |
1341 // will be supported. | |
1342 if (!callee_method->is_old() && caller_nm->is_in_use() && | |
1343 (callee_nm == NULL || callee_nm->is_in_use() && (callee_method->code() == callee_nm))) { | |
1325 #ifdef ASSERT | 1344 #ifdef ASSERT |
1326 // We must not try to patch to jump to an already unloaded method. | 1345 // We must not try to patch to jump to an already unloaded method. |
1327 if (dest_entry_point != 0) { | 1346 if (dest_entry_point != 0) { |
1328 assert(CodeCache::find_blob(dest_entry_point) != NULL, | 1347 CodeBlob* cb = CodeCache::find_blob(dest_entry_point); |
1329 "should not unload nmethod while locked"); | 1348 assert((cb != NULL) && cb->is_nmethod() && (((nmethod*)cb) == callee_nm), |
1349 "should not call unloaded nmethod"); | |
1330 } | 1350 } |
1331 #endif | 1351 #endif |
1332 if (is_virtual) { | 1352 if (is_virtual) { |
1333 nmethod* nm = callee_nm; | 1353 nmethod* nm = callee_nm; |
1334 if (nm == NULL) CodeCache::find_blob(caller_frame.pc()); | 1354 if (nm == NULL) CodeCache::find_blob(caller_frame.pc()); |
1403 thread->set_vm_result_2(callee_method()); | 1423 thread->set_vm_result_2(callee_method()); |
1404 JRT_BLOCK_END | 1424 JRT_BLOCK_END |
1405 // return compiled code entry point after potential safepoints | 1425 // return compiled code entry point after potential safepoints |
1406 assert(callee_method->verified_code_entry() != NULL, " Jump to zero!"); | 1426 assert(callee_method->verified_code_entry() != NULL, " Jump to zero!"); |
1407 return callee_method->verified_code_entry(); | 1427 return callee_method->verified_code_entry(); |
1428 JRT_END | |
1429 | |
1430 // Handle abstract method call | |
1431 JRT_BLOCK_ENTRY(address, SharedRuntime::handle_wrong_method_abstract(JavaThread* thread)) | |
1432 return StubRoutines::throw_AbstractMethodError_entry(); | |
1408 JRT_END | 1433 JRT_END |
1409 | 1434 |
1410 | 1435 |
1411 // resolve a static call and patch code | 1436 // resolve a static call and patch code |
1412 JRT_BLOCK_ENTRY(address, SharedRuntime::resolve_static_call_C(JavaThread *thread )) | 1437 JRT_BLOCK_ENTRY(address, SharedRuntime::resolve_static_call_C(JavaThread *thread )) |
2401 if (_adapters != NULL) return; | 2426 if (_adapters != NULL) return; |
2402 _adapters = new AdapterHandlerTable(); | 2427 _adapters = new AdapterHandlerTable(); |
2403 | 2428 |
2404 // Create a special handler for abstract methods. Abstract methods | 2429 // Create a special handler for abstract methods. Abstract methods |
2405 // are never compiled so an i2c entry is somewhat meaningless, but | 2430 // are never compiled so an i2c entry is somewhat meaningless, but |
2406 // fill it in with something appropriate just in case. Pass handle | 2431 // throw AbstractMethodError just in case. |
2407 // wrong method for the c2i transitions. | 2432 // Pass wrong_method_abstract for the c2i transitions to return |
2408 address wrong_method = SharedRuntime::get_handle_wrong_method_stub(); | 2433 // AbstractMethodError for invalid invocations. |
2434 address wrong_method_abstract = SharedRuntime::get_handle_wrong_method_abstract_stub(); | |
2409 _abstract_method_handler = AdapterHandlerLibrary::new_entry(new AdapterFingerPrint(0, NULL), | 2435 _abstract_method_handler = AdapterHandlerLibrary::new_entry(new AdapterFingerPrint(0, NULL), |
2410 StubRoutines::throw_AbstractMethodError_entry(), | 2436 StubRoutines::throw_AbstractMethodError_entry(), |
2411 wrong_method, wrong_method); | 2437 wrong_method_abstract, wrong_method_abstract); |
2412 } | 2438 } |
2413 | 2439 |
2414 AdapterHandlerEntry* AdapterHandlerLibrary::new_entry(AdapterFingerPrint* fingerprint, | 2440 AdapterHandlerEntry* AdapterHandlerLibrary::new_entry(AdapterFingerPrint* fingerprint, |
2415 address i2c_entry, | 2441 address i2c_entry, |
2416 address c2i_entry, | 2442 address c2i_entry, |