1356 // Back from jni method Lmethod in this frame is DEAD, DEAD, DEAD
1357
1358 __ restore_thread(L7_thread_cache); // restore G2_thread
1359 __ reinit_heapbase();
1360
1361 // must we block?
1362
1363 // Block, if necessary, before resuming in _thread_in_Java state.
1364 // In order for GC to work, don't clear the last_Java_sp until after blocking.
1365 { Label no_block;
1366
1367 // Switch thread to "native transition" state before reading the synchronization state.
1368 // This additional state is necessary because reading and testing the synchronization
1369 // state is not atomic w.r.t. GC, as this scenario demonstrates:
1370 // Java thread A, in _thread_in_native state, loads _not_synchronized and is preempted.
1371 // VM thread changes sync state to synchronizing and suspends threads for GC.
1372 // Thread A is resumed to finish this native method, but doesn't block here since it
1373 // didn't see any synchronization is progress, and escapes.
1374 __ set(_thread_in_native_trans, G3_scratch);
1375 __ st(G3_scratch, thread_state);
1376 if (os::is_MP()) {
1377 if (UseMembar) {
1378 // Force this write out before the read below
1379 __ membar(Assembler::StoreLoad);
1380 } else {
1381 // Write serialization page so VM thread can do a pseudo remote membar.
1382 // We use the current thread pointer to calculate a thread specific
1383 // offset to write to within the page. This minimizes bus traffic
1384 // due to cache line collision.
1385 __ serialize_memory(G2_thread, G1_scratch, G3_scratch);
1386 }
1387 }
1388
1389 Label L;
1390 __ safepoint_poll(L, false, G2_thread, G3_scratch);
1391 __ delayed()->ld(G2_thread, JavaThread::suspend_flags_offset(), G3_scratch);
1392 __ cmp_and_br_short(G3_scratch, 0, Assembler::equal, Assembler::pt, no_block);
1393 __ bind(L);
1394
1395 // Block. Save any potential method result value before the operation and
1396 // use a leaf call to leave the last_Java_frame setup undisturbed.
1397 save_native_result();
1398 __ call_VM_leaf(L7_thread_cache,
1399 CAST_FROM_FN_PTR(address, JavaThread::check_special_condition_for_native_trans),
1400 G2_thread);
1401
1402 // Restore any method result value
1403 restore_native_result();
1404 __ bind(no_block);
1405 }
1406
|
1356 // Back from jni method Lmethod in this frame is DEAD, DEAD, DEAD
1357
1358 __ restore_thread(L7_thread_cache); // restore G2_thread
1359 __ reinit_heapbase();
1360
1361 // must we block?
1362
1363 // Block, if necessary, before resuming in _thread_in_Java state.
1364 // In order for GC to work, don't clear the last_Java_sp until after blocking.
1365 { Label no_block;
1366
1367 // Switch thread to "native transition" state before reading the synchronization state.
1368 // This additional state is necessary because reading and testing the synchronization
1369 // state is not atomic w.r.t. GC, as this scenario demonstrates:
1370 // Java thread A, in _thread_in_native state, loads _not_synchronized and is preempted.
1371 // VM thread changes sync state to synchronizing and suspends threads for GC.
1372 // Thread A is resumed to finish this native method, but doesn't block here since it
1373 // didn't see any synchronization is progress, and escapes.
1374 __ set(_thread_in_native_trans, G3_scratch);
1375 __ st(G3_scratch, thread_state);
1376
1377 if (UseMembar) {
1378 // Force this write out before the read below
1379 __ membar(Assembler::StoreLoad);
1380 } else {
1381 // Write serialization page so VM thread can do a pseudo remote membar.
1382 // We use the current thread pointer to calculate a thread specific
1383 // offset to write to within the page. This minimizes bus traffic
1384 // due to cache line collision.
1385 __ serialize_memory(G2_thread, G1_scratch, G3_scratch);
1386 }
1387
1388 Label L;
1389 __ safepoint_poll(L, false, G2_thread, G3_scratch);
1390 __ delayed()->ld(G2_thread, JavaThread::suspend_flags_offset(), G3_scratch);
1391 __ cmp_and_br_short(G3_scratch, 0, Assembler::equal, Assembler::pt, no_block);
1392 __ bind(L);
1393
1394 // Block. Save any potential method result value before the operation and
1395 // use a leaf call to leave the last_Java_frame setup undisturbed.
1396 save_native_result();
1397 __ call_VM_leaf(L7_thread_cache,
1398 CAST_FROM_FN_PTR(address, JavaThread::check_special_condition_for_native_trans),
1399 G2_thread);
1400
1401 // Restore any method result value
1402 restore_native_result();
1403 __ bind(no_block);
1404 }
1405
|