< prev index next >

src/hotspot/cpu/s390/sharedRuntime_s390.cpp

Print this page
rev 48251 : 8193257: PPC64, s390 implementation for Thread-local handshakes
Reviewed-by:


2148   // In order for GC to work, don't clear the last_Java_sp until after blocking.
2149   //--------------------------------------------------------------------
2150   Label after_transition;
2151   {
2152     Label no_block, sync;
2153 
2154     save_native_result(masm, ret_type, workspace_slot_offset); // Make Z_R2 available as work reg.
2155 
2156     if (os::is_MP()) {
2157       if (UseMembar) {
2158         // Force this write out before the read below.
2159         __ z_fence();
2160       } else {
2161         // Write serialization page so VM thread can do a pseudo remote membar.
2162         // We use the current thread pointer to calculate a thread specific
2163         // offset to write to within the page. This minimizes bus traffic
2164         // due to cache line collision.
2165         __ serialize_memory(Z_thread, Z_R1, Z_R2);
2166       }
2167     }
2168     __ generate_safepoint_check(sync, Z_R1, true);
2169 
2170     __ load_and_test_int(Z_R0, Address(Z_thread, JavaThread::suspend_flags_offset()));
2171     __ z_bre(no_block);
2172 
2173     // Block. Save any potential method result value before the operation and
2174     // use a leaf call to leave the last_Java_frame setup undisturbed. Doing this
2175     // lets us share the oopMap we used when we went native rather than create
2176     // a distinct one for this pc.
2177     //
2178     __ bind(sync);
2179     __ z_acquire();
2180 
2181     address entry_point = is_critical_native ? CAST_FROM_FN_PTR(address, JavaThread::check_special_condition_for_native_trans_and_transition)
2182                                              : CAST_FROM_FN_PTR(address, JavaThread::check_special_condition_for_native_trans);
2183 
2184     __ call_VM_leaf(entry_point, Z_thread);
2185 
2186     if (is_critical_native) {
2187       restore_native_result(masm, ret_type, workspace_slot_offset);
2188       __ z_bru(after_transition); // No thread state transition here.


3173 // Generate a special Compile2Runtime blob that saves all registers,
3174 // and setup oopmap.
3175 SafepointBlob* SharedRuntime::generate_handler_blob(address call_ptr, int poll_type) {
3176   assert(StubRoutines::forward_exception_entry() != NULL,
3177          "must be generated before");
3178 
3179   ResourceMark rm;
3180   OopMapSet *oop_maps = new OopMapSet();
3181   OopMap* map;
3182 
3183   // Allocate space for the code. Setup code generation tools.
3184   CodeBuffer buffer("handler_blob", 2048, 1024);
3185   MacroAssembler* masm = new MacroAssembler(&buffer);
3186 
3187   unsigned int start_off = __ offset();
3188   address call_pc = NULL;
3189   int frame_size_in_bytes;
3190 
3191   bool cause_return = (poll_type == POLL_AT_RETURN);
3192   // Make room for return address (or push it again)
3193   if (!cause_return)
3194     __ z_lg(Z_R14, Address(Z_thread, JavaThread::saved_exception_pc_offset()));

3195 
3196   // Save registers, fpu state, and flags
3197   map = RegisterSaver::save_live_registers(masm, RegisterSaver::all_registers);
3198 





3199   // The following is basically a call_VM. However, we need the precise
3200   // address of the call in order to generate an oopmap. Hence, we do all the
3201   // work outselves.
3202   __ set_last_Java_frame(Z_SP, noreg);
3203 
3204   // call into the runtime to handle the safepoint poll
3205   __ call_VM_leaf(call_ptr, Z_thread);
3206 
3207 
3208   // Set an oopmap for the call site. This oopmap will map all
3209   // oop-registers and debug-info registers as callee-saved. This
3210   // will allow deoptimization at this safepoint to find all possible
3211   // debug-info recordings, as well as let GC find all oops.
3212 
3213   oop_maps->add_gc_map((int)(__ offset()-start_off), map);
3214 
3215   Label noException;
3216 
3217   __ reset_last_Java_frame();
3218 
3219   __ load_and_test_long(Z_R1, thread_(pending_exception));
3220   __ z_bre(noException);
3221 
3222   // Pending exception case, used (sporadically) by
3223   // api/java_lang/Thread.State/index#ThreadState et al.
3224   RegisterSaver::restore_live_registers(masm, RegisterSaver::all_registers);
3225 
3226   // Jump to forward_exception_entry, with the issuing PC in Z_R14
3227   // so it looks like the original nmethod called forward_exception_entry.
3228   __ load_const_optimized(Z_R1_scratch, StubRoutines::forward_exception_entry());
3229   __ z_br(Z_R1_scratch);
3230 
3231   // No exception case
3232   __ bind(noException);















3233 
3234   // Normal exit, restore registers and exit.
3235   RegisterSaver::restore_live_registers(masm, RegisterSaver::all_registers);
3236 
3237   __ z_br(Z_R14);
3238 
3239   // Make sure all code is generated
3240   masm->flush();
3241 
3242   // Fill-out other meta info
3243   return SafepointBlob::create(&buffer, oop_maps, RegisterSaver::live_reg_frame_size(RegisterSaver::all_registers)/wordSize);
3244 }
3245 
3246 
3247 //
3248 // generate_resolve_blob - call resolution (static/virtual/opt-virtual/ic-miss
3249 //
3250 // Generate a stub that calls into vm to find out the proper destination
3251 // of a Java call. All the argument registers are live at this point
3252 // but since this is generic code we don't know what they are and the caller




2148   // In order for GC to work, don't clear the last_Java_sp until after blocking.
2149   //--------------------------------------------------------------------
2150   Label after_transition;
2151   {
2152     Label no_block, sync;
2153 
2154     save_native_result(masm, ret_type, workspace_slot_offset); // Make Z_R2 available as work reg.
2155 
2156     if (os::is_MP()) {
2157       if (UseMembar) {
2158         // Force this write out before the read below.
2159         __ z_fence();
2160       } else {
2161         // Write serialization page so VM thread can do a pseudo remote membar.
2162         // We use the current thread pointer to calculate a thread specific
2163         // offset to write to within the page. This minimizes bus traffic
2164         // due to cache line collision.
2165         __ serialize_memory(Z_thread, Z_R1, Z_R2);
2166       }
2167     }
2168     __ safepoint_poll(sync, Z_R1);
2169 
2170     __ load_and_test_int(Z_R0, Address(Z_thread, JavaThread::suspend_flags_offset()));
2171     __ z_bre(no_block);
2172 
2173     // Block. Save any potential method result value before the operation and
2174     // use a leaf call to leave the last_Java_frame setup undisturbed. Doing this
2175     // lets us share the oopMap we used when we went native rather than create
2176     // a distinct one for this pc.
2177     //
2178     __ bind(sync);
2179     __ z_acquire();
2180 
2181     address entry_point = is_critical_native ? CAST_FROM_FN_PTR(address, JavaThread::check_special_condition_for_native_trans_and_transition)
2182                                              : CAST_FROM_FN_PTR(address, JavaThread::check_special_condition_for_native_trans);
2183 
2184     __ call_VM_leaf(entry_point, Z_thread);
2185 
2186     if (is_critical_native) {
2187       restore_native_result(masm, ret_type, workspace_slot_offset);
2188       __ z_bru(after_transition); // No thread state transition here.


3173 // Generate a special Compile2Runtime blob that saves all registers,
3174 // and setup oopmap.
3175 SafepointBlob* SharedRuntime::generate_handler_blob(address call_ptr, int poll_type) {
3176   assert(StubRoutines::forward_exception_entry() != NULL,
3177          "must be generated before");
3178 
3179   ResourceMark rm;
3180   OopMapSet *oop_maps = new OopMapSet();
3181   OopMap* map;
3182 
3183   // Allocate space for the code. Setup code generation tools.
3184   CodeBuffer buffer("handler_blob", 2048, 1024);
3185   MacroAssembler* masm = new MacroAssembler(&buffer);
3186 
3187   unsigned int start_off = __ offset();
3188   address call_pc = NULL;
3189   int frame_size_in_bytes;
3190 
3191   bool cause_return = (poll_type == POLL_AT_RETURN);
3192   // Make room for return address (or push it again)
3193   if (!cause_return) {
3194     __ z_lg(Z_R14, Address(Z_thread, JavaThread::saved_exception_pc_offset()));
3195   }
3196 
3197   // Save registers, fpu state, and flags
3198   map = RegisterSaver::save_live_registers(masm, RegisterSaver::all_registers);
3199 
3200   if (SafepointMechanism::uses_thread_local_poll() && !cause_return) {
3201     // Keep a copy of the return pc to detect if it gets modified.
3202     __ z_lgr(Z_R6, Z_R14);
3203   }
3204 
3205   // The following is basically a call_VM. However, we need the precise
3206   // address of the call in order to generate an oopmap. Hence, we do all the
3207   // work outselves.
3208   __ set_last_Java_frame(Z_SP, noreg);
3209 
3210   // call into the runtime to handle the safepoint poll
3211   __ call_VM_leaf(call_ptr, Z_thread);
3212 
3213 
3214   // Set an oopmap for the call site. This oopmap will map all
3215   // oop-registers and debug-info registers as callee-saved. This
3216   // will allow deoptimization at this safepoint to find all possible
3217   // debug-info recordings, as well as let GC find all oops.
3218 
3219   oop_maps->add_gc_map((int)(__ offset()-start_off), map);
3220 
3221   Label noException;
3222 
3223   __ reset_last_Java_frame();
3224 
3225   __ load_and_test_long(Z_R1, thread_(pending_exception));
3226   __ z_bre(noException);
3227 
3228   // Pending exception case, used (sporadically) by
3229   // api/java_lang/Thread.State/index#ThreadState et al.
3230   RegisterSaver::restore_live_registers(masm, RegisterSaver::all_registers);
3231 
3232   // Jump to forward_exception_entry, with the issuing PC in Z_R14
3233   // so it looks like the original nmethod called forward_exception_entry.
3234   __ load_const_optimized(Z_R1_scratch, StubRoutines::forward_exception_entry());
3235   __ z_br(Z_R1_scratch);
3236 
3237   // No exception case
3238   __ bind(noException);
3239 
3240   if (SafepointMechanism::uses_thread_local_poll() && !cause_return) {
3241     Label no_adjust;
3242      // If our stashed return pc was modified by the runtime we avoid touching it
3243     const int offset_of_return_pc = _z_abi16(return_pc) + RegisterSaver::live_reg_frame_size(RegisterSaver::all_registers);
3244     __ z_cg(Z_R6, offset_of_return_pc, Z_SP);
3245     __ z_brne(no_adjust);
3246 
3247     // Adjust return pc forward to step over the safepoint poll instruction
3248     __ instr_size(Z_R1_scratch, Z_R6);
3249     __ z_agr(Z_R6, Z_R1_scratch);
3250     __ z_stg(Z_R6, offset_of_return_pc, Z_SP);
3251 
3252     __ bind(no_adjust);
3253   }
3254 
3255   // Normal exit, restore registers and exit.
3256   RegisterSaver::restore_live_registers(masm, RegisterSaver::all_registers);
3257 
3258   __ z_br(Z_R14);
3259 
3260   // Make sure all code is generated
3261   masm->flush();
3262 
3263   // Fill-out other meta info
3264   return SafepointBlob::create(&buffer, oop_maps, RegisterSaver::live_reg_frame_size(RegisterSaver::all_registers)/wordSize);
3265 }
3266 
3267 
3268 //
3269 // generate_resolve_blob - call resolution (static/virtual/opt-virtual/ic-miss
3270 //
3271 // Generate a stub that calls into vm to find out the proper destination
3272 // of a Java call. All the argument registers are live at this point
3273 // but since this is generic code we don't know what they are and the caller


< prev index next >