< prev index next >

src/hotspot/cpu/x86/interp_masm_x86.cpp

Print this page

 309   save_bcp();
 310 #ifdef ASSERT
 311   {
 312     Label L;
 313     cmpptr(Address(rbp, frame::interpreter_frame_last_sp_offset * wordSize), NULL_WORD);
 314     jcc(Assembler::equal, L);
 315     stop("InterpreterMacroAssembler::call_VM_base:"
 316          " last_sp isn't null");
 317     bind(L);
 318   }
 319 #endif /* ASSERT */
 320   // super call
 321   MacroAssembler::call_VM_base(oop_result, last_java_sp,
 322                                entry_point, number_of_arguments,
 323                                check_exceptions);
 324   // interpreter specific
 325   restore_bcp();
 326   restore_locals();
 327 }
 328 
 329 void InterpreterMacroAssembler::call_VM_preemptable(Register oop_result,
 330                                                     address entry_point,
 331                                                     Register arg_1) {
 332   assert(arg_1 == c_rarg1, "");
 333   Label resume_pc, not_preempted;
 334 
 335 #ifdef ASSERT
 336   {
 337     Label L;
 338     cmpptr(Address(r15_thread, JavaThread::preempt_alternate_return_offset()), NULL_WORD);
 339     jcc(Assembler::equal, L);
 340     stop("Should not have alternate return address set");
 341     bind(L);
 342   }
 343 #endif /* ASSERT */
 344 
 345   // Force freeze slow path.
 346   push_cont_fastpath();
 347 
 348   // Make VM call. In case of preemption set last_pc to the one we want to resume to.
 349   // Note: call_VM_helper requires last_Java_pc for anchor to be at the top of the stack.
 350   lea(rscratch1, resume_pc);
 351   push(rscratch1);
 352   MacroAssembler::call_VM_helper(oop_result, entry_point, 1, false /*check_exceptions*/);
 353   pop(rscratch1);
 354 
 355   pop_cont_fastpath();
 356 
 357   // Check if preempted.
 358   movptr(rscratch1, Address(r15_thread, JavaThread::preempt_alternate_return_offset()));
 359   cmpptr(rscratch1, NULL_WORD);
 360   jccb(Assembler::zero, not_preempted);
 361   movptr(Address(r15_thread, JavaThread::preempt_alternate_return_offset()), NULL_WORD);
 362   jmp(rscratch1);
 363 
 364   // In case of preemption, this is where we will resume once we finally acquire the monitor.
 365   bind(resume_pc);
 366   restore_after_resume(false /* is_native */);
 367 


















 368   bind(not_preempted);
 369 }
 370 































 371 void InterpreterMacroAssembler::restore_after_resume(bool is_native) {
 372   lea(rscratch1, ExternalAddress(Interpreter::cont_resume_interpreter_adapter()));
 373   call(rscratch1);
 374   if (is_native) {
 375     // On resume we need to set up stack as expected.
 376     push(dtos);
 377     push(ltos);
 378   }
 379 }
 380 
 381 void InterpreterMacroAssembler::check_and_handle_popframe() {
 382   if (JvmtiExport::can_pop_frame()) {
 383     Label L;
 384     // Initiate popframe handling only if it is not already being
 385     // processed.  If the flag has the popframe_processing bit set, it
 386     // means that this code is called *during* popframe handling - we
 387     // don't want to reenter.
 388     // This method is only called just after the call into the vm in
 389     // call_VM_base, so the arg registers are available.
 390     Register pop_cond = c_rarg0;

 309   save_bcp();
 310 #ifdef ASSERT
 311   {
 312     Label L;
 313     cmpptr(Address(rbp, frame::interpreter_frame_last_sp_offset * wordSize), NULL_WORD);
 314     jcc(Assembler::equal, L);
 315     stop("InterpreterMacroAssembler::call_VM_base:"
 316          " last_sp isn't null");
 317     bind(L);
 318   }
 319 #endif /* ASSERT */
 320   // super call
 321   MacroAssembler::call_VM_base(oop_result, last_java_sp,
 322                                entry_point, number_of_arguments,
 323                                check_exceptions);
 324   // interpreter specific
 325   restore_bcp();
 326   restore_locals();
 327 }
 328 
 329 void InterpreterMacroAssembler::call_VM_preemptable_helper(Register oop_result,
 330                                                            address entry_point,
 331                                                            int number_of_arguments,
 332                                                            bool check_exceptions) {
 333   Label resume_pc, not_preempted;
 334 
 335 #ifdef ASSERT
 336   {
 337     Label L;
 338     cmpptr(Address(r15_thread, JavaThread::preempt_alternate_return_offset()), NULL_WORD);
 339     jcc(Assembler::equal, L);
 340     stop("Should not have alternate return address set");
 341     bind(L);
 342   }
 343 #endif /* ASSERT */
 344 
 345   // Force freeze slow path.
 346   push_cont_fastpath();
 347 
 348   // Make VM call. In case of preemption set last_pc to the one we want to resume to.
 349   // Note: call_VM_helper requires last_Java_pc for anchor to be at the top of the stack.
 350   lea(rscratch1, resume_pc);
 351   push(rscratch1);
 352   MacroAssembler::call_VM_helper(oop_result, entry_point, number_of_arguments, check_exceptions);
 353   pop(rscratch1);
 354 
 355   pop_cont_fastpath();
 356 
 357   // Check if preempted.
 358   movptr(rscratch1, Address(r15_thread, JavaThread::preempt_alternate_return_offset()));
 359   cmpptr(rscratch1, NULL_WORD);
 360   jccb(Assembler::zero, not_preempted);
 361   movptr(Address(r15_thread, JavaThread::preempt_alternate_return_offset()), NULL_WORD);
 362   jmp(rscratch1);
 363 
 364   // In case of preemption, this is where we will resume once we finally acquire the monitor.
 365   bind(resume_pc);
 366   restore_after_resume(false /* is_native */);
 367 
 368   if (check_exceptions) {
 369     // check for pending exceptions (java_thread is set upon return)
 370     cmpptr(Address(r15_thread, Thread::pending_exception_offset()), NULL_WORD);
 371     Label ok;
 372     jcc(Assembler::equal, ok);
 373     // Exception stub expects return pc to be at top of stack. We only need
 374     // it to check Interpreter::contains(return_address) so anything will do.
 375     lea(rscratch1, resume_pc);
 376     push(rscratch1);
 377     jump(RuntimeAddress(StubRoutines::forward_exception_entry()));
 378     bind(ok);
 379   }
 380 
 381   // get oop result if there is one and reset the value in the thread
 382   if (oop_result->is_valid()) {
 383     get_vm_result_oop(oop_result);
 384   }
 385 
 386   bind(not_preempted);
 387 }
 388 
 389 static void pass_arg1(MacroAssembler* masm, Register arg) {
 390   if (c_rarg1 != arg ) {
 391     masm->mov(c_rarg1, arg);
 392   }
 393 }
 394 
 395 static void pass_arg2(MacroAssembler* masm, Register arg) {
 396   if (c_rarg2 != arg ) {
 397     masm->mov(c_rarg2, arg);
 398   }
 399 }
 400 
 401 void InterpreterMacroAssembler::call_VM_preemptable(Register oop_result,
 402                                          address entry_point,
 403                                          Register arg_1,
 404                                          bool check_exceptions) {
 405   pass_arg1(this, arg_1);
 406   call_VM_preemptable_helper(oop_result, entry_point, 1, check_exceptions);
 407 }
 408 
 409 void InterpreterMacroAssembler::call_VM_preemptable(Register oop_result,
 410                                          address entry_point,
 411                                          Register arg_1,
 412                                          Register arg_2,
 413                                          bool check_exceptions) {
 414   LP64_ONLY(assert_different_registers(arg_1, c_rarg2));
 415   pass_arg2(this, arg_2);
 416   pass_arg1(this, arg_1);
 417   call_VM_preemptable_helper(oop_result, entry_point, 2, check_exceptions);
 418 }
 419 
 420 void InterpreterMacroAssembler::restore_after_resume(bool is_native) {
 421   lea(rscratch1, ExternalAddress(Interpreter::cont_resume_interpreter_adapter()));
 422   call(rscratch1);
 423   if (is_native) {
 424     // On resume we need to set up stack as expected.
 425     push(dtos);
 426     push(ltos);
 427   }
 428 }
 429 
 430 void InterpreterMacroAssembler::check_and_handle_popframe() {
 431   if (JvmtiExport::can_pop_frame()) {
 432     Label L;
 433     // Initiate popframe handling only if it is not already being
 434     // processed.  If the flag has the popframe_processing bit set, it
 435     // means that this code is called *during* popframe handling - we
 436     // don't want to reenter.
 437     // This method is only called just after the call into the vm in
 438     // call_VM_base, so the arg registers are available.
 439     Register pop_cond = c_rarg0;
< prev index next >