< prev index next >

src/hotspot/cpu/x86/templateInterpreterGenerator_x86.cpp

Print this page

 370   default       : ShouldNotReachHere();
 371   }
 372   __ ret(0);                                   // return from result handler
 373   return entry;
 374 }
 375 
 376 address TemplateInterpreterGenerator::generate_safept_entry_for(
 377         TosState state,
 378         address runtime_entry) {
 379   address entry = __ pc();
 380 
 381   __ push(state);
 382   __ push_cont_fastpath();
 383   __ call_VM(noreg, runtime_entry);
 384   __ pop_cont_fastpath();
 385 
 386   __ dispatch_via(vtos, Interpreter::_normal_table.table_for(vtos));
 387   return entry;
 388 }
 389 
























 390 
 391 
 392 // Helpers for commoning out cases in the various type of method entries.
 393 //
 394 
 395 
 396 // increment invocation count & check for overflow
 397 //
 398 // Note: checking for negative value instead of overflow
 399 //       so we have a 'sticky' overflow test
 400 //
 401 // rbx: method
 402 // rcx: invocation counter
 403 //
 404 void TemplateInterpreterGenerator::generate_counter_incr(Label* overflow) {
 405   Label done;
 406   // Note: In tiered we increment either counters in Method* or in MDO depending if we're profiling or not.
 407   Label no_mdo;
 408   if (ProfileInterpreter) {
 409     // Are we profiling?

1032    __ set_last_Java_frame(rsp, rbp, (address) __ pc(), rscratch1);
1033 #endif // _LP64
1034 
1035   // change thread state
1036 #ifdef ASSERT
1037   {
1038     Label L;
1039     __ movl(t, Address(thread, JavaThread::thread_state_offset()));
1040     __ cmpl(t, _thread_in_Java);
1041     __ jcc(Assembler::equal, L);
1042     __ stop("Wrong thread state in native stub");
1043     __ bind(L);
1044   }
1045 #endif
1046 
1047   // Change state to native
1048 
1049   __ movl(Address(thread, JavaThread::thread_state_offset()),
1050           _thread_in_native);
1051 


1052   // Call the native method.
1053   __ call(rax);
1054   // 32: result potentially in rdx:rax or ST0
1055   // 64: result potentially in rax or xmm0
1056 


1057   // Verify or restore cpu control state after JNI call
1058   __ restore_cpu_control_state_after_jni(rscratch1);
1059 
1060   // NOTE: The order of these pushes is known to frame::interpreter_frame_result
1061   // in order to extract the result of a method call. If the order of these
1062   // pushes change or anything else is added to the stack then the code in
1063   // interpreter_frame_result must also change.
1064 
1065 #ifndef _LP64
1066   // save potential result in ST(0) & rdx:rax
1067   // (if result handler is the T_FLOAT or T_DOUBLE handler, result must be in ST0 -
1068   // the check is necessary to avoid potential Intel FPU overflow problems by saving/restoring 'empty' FPU registers)
1069   // It is safe to do this push because state is _thread_in_native and return address will be found
1070   // via _last_native_pc and not via _last_jave_sp
1071 
1072   // NOTE: the order of these push(es) is known to frame::interpreter_frame_result.
1073   // If the order changes or anything else is added to the stack the code in
1074   // interpreter_frame_result will have to be changed.
1075 
1076   { Label L;
1077     Label push_double;
1078     ExternalAddress float_handler(AbstractInterpreter::result_handler(T_FLOAT));
1079     ExternalAddress double_handler(AbstractInterpreter::result_handler(T_DOUBLE));
1080     __ cmpptr(Address(rbp, (frame::interpreter_frame_oop_temp_offset + 1)*wordSize),
1081               float_handler.addr(), noreg);
1082     __ jcc(Assembler::equal, push_double);
1083     __ cmpptr(Address(rbp, (frame::interpreter_frame_oop_temp_offset + 1)*wordSize),
1084               double_handler.addr(), noreg);
1085     __ jcc(Assembler::notEqual, L);
1086     __ bind(push_double);
1087     __ push_d(); // FP values are returned using the FPU, so push FPU contents (even if UseSSE > 0).
1088     __ bind(L);
1089   }
1090 #else
1091   __ push(dtos);
1092 #endif // _LP64
1093 
1094   __ push(ltos);
1095 
1096   // change thread state
1097   NOT_LP64(__ get_thread(thread));
1098   __ movl(Address(thread, JavaThread::thread_state_offset()),
1099           _thread_in_native_trans);
1100 
1101   // Force this write out before the read below
1102   if (!UseSystemMemoryBarrier) {
1103     __ membar(Assembler::Membar_mask_bits(

1133     __ push(thread);
1134     __ call(RuntimeAddress(CAST_FROM_FN_PTR(address,
1135                                             JavaThread::check_special_condition_for_native_trans)));
1136     __ increment(rsp, wordSize);
1137     __ get_thread(thread);
1138 #else
1139     __ mov(c_rarg0, r15_thread);
1140     __ mov(r12, rsp); // remember sp (can only use r12 if not using call_VM)
1141     __ subptr(rsp, frame::arg_reg_save_area_bytes); // windows
1142     __ andptr(rsp, -16); // align stack as required by ABI
1143     __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, JavaThread::check_special_condition_for_native_trans)));
1144     __ mov(rsp, r12); // restore sp
1145     __ reinit_heapbase();
1146 #endif // _LP64
1147     __ bind(Continue);
1148   }
1149 
1150   // change thread state
1151   __ movl(Address(thread, JavaThread::thread_state_offset()), _thread_in_Java);
1152 













1153   // reset_last_Java_frame
1154   __ reset_last_Java_frame(thread, true);
1155 
1156   if (CheckJNICalls) {
1157     // clear_pending_jni_exception_check
1158     __ movptr(Address(thread, JavaThread::pending_jni_exception_check_fn_offset()), NULL_WORD);
1159   }
1160 
1161   // reset handle block
1162   __ movptr(t, Address(thread, JavaThread::active_handles_offset()));
1163   __ movl(Address(t, JNIHandleBlock::top_offset()), NULL_WORD);
1164 
1165   // If result is an oop unbox and store it in frame where gc will see it
1166   // and result handler will pick it up
1167 
1168   {
1169     Label no_oop;
1170     __ lea(t, ExternalAddress(AbstractInterpreter::result_handler(T_OBJECT)));
1171     __ cmpptr(t, Address(rbp, frame::interpreter_frame_result_handler_offset*wordSize));
1172     __ jcc(Assembler::notEqual, no_oop);

 370   default       : ShouldNotReachHere();
 371   }
 372   __ ret(0);                                   // return from result handler
 373   return entry;
 374 }
 375 
 376 address TemplateInterpreterGenerator::generate_safept_entry_for(
 377         TosState state,
 378         address runtime_entry) {
 379   address entry = __ pc();
 380 
 381   __ push(state);
 382   __ push_cont_fastpath();
 383   __ call_VM(noreg, runtime_entry);
 384   __ pop_cont_fastpath();
 385 
 386   __ dispatch_via(vtos, Interpreter::_normal_table.table_for(vtos));
 387   return entry;
 388 }
 389 
 390 address TemplateInterpreterGenerator::generate_cont_resume_interpreter_adapter() {
 391   if (!Continuations::enabled()) return nullptr;
 392   address start = __ pc();
 393 
 394   __ pop(rbp);
 395 
 396   // We will return to the intermediate call made in call_VM skipping the restoration
 397   // of bcp and locals done in InterpreterMacroAssembler::call_VM_base, so fix them here.
 398   __ restore_bcp();
 399   __ restore_locals();
 400 
 401   // Get return address before adjusting rsp
 402   __ movptr(rax, Address(rsp, 0));
 403 
 404   // Restore stack bottom
 405   __ movptr(rcx, Address(rbp, frame::interpreter_frame_last_sp_offset * wordSize));
 406   __ lea(rsp, Address(rbp, rcx, Address::times_ptr));
 407   // and NULL it as marker that esp is now tos until next java call
 408   __ movptr(Address(rbp, frame::interpreter_frame_last_sp_offset * wordSize), NULL_WORD);
 409 
 410   __ jmp(rax);
 411 
 412   return start;
 413 }
 414 
 415 
 416 // Helpers for commoning out cases in the various type of method entries.
 417 //
 418 
 419 
 420 // increment invocation count & check for overflow
 421 //
 422 // Note: checking for negative value instead of overflow
 423 //       so we have a 'sticky' overflow test
 424 //
 425 // rbx: method
 426 // rcx: invocation counter
 427 //
 428 void TemplateInterpreterGenerator::generate_counter_incr(Label* overflow) {
 429   Label done;
 430   // Note: In tiered we increment either counters in Method* or in MDO depending if we're profiling or not.
 431   Label no_mdo;
 432   if (ProfileInterpreter) {
 433     // Are we profiling?

1056    __ set_last_Java_frame(rsp, rbp, (address) __ pc(), rscratch1);
1057 #endif // _LP64
1058 
1059   // change thread state
1060 #ifdef ASSERT
1061   {
1062     Label L;
1063     __ movl(t, Address(thread, JavaThread::thread_state_offset()));
1064     __ cmpl(t, _thread_in_Java);
1065     __ jcc(Assembler::equal, L);
1066     __ stop("Wrong thread state in native stub");
1067     __ bind(L);
1068   }
1069 #endif
1070 
1071   // Change state to native
1072 
1073   __ movl(Address(thread, JavaThread::thread_state_offset()),
1074           _thread_in_native);
1075 
1076   __ push_cont_fastpath();
1077 
1078   // Call the native method.
1079   __ call(rax);
1080   // 32: result potentially in rdx:rax or ST0
1081   // 64: result potentially in rax or xmm0
1082 
1083   __ pop_cont_fastpath();
1084 
1085   // Verify or restore cpu control state after JNI call
1086   __ restore_cpu_control_state_after_jni(rscratch1);
1087 
1088   // NOTE: The order of these pushes is known to frame::interpreter_frame_result
1089   // in order to extract the result of a method call. If the order of these
1090   // pushes change or anything else is added to the stack then the code in
1091   // interpreter_frame_result must also change.
1092 
1093 #ifndef _LP64
1094   // save potential result in ST(0) & rdx:rax
1095   // (if result handler is the T_FLOAT or T_DOUBLE handler, result must be in ST0 -
1096   // the check is necessary to avoid potential Intel FPU overflow problems by saving/restoring 'empty' FPU registers)
1097   // It is safe to do this push because state is _thread_in_native and return address will be found
1098   // via _last_native_pc and not via _last_jave_sp
1099 
1100   // NOTE: the order of these push(es) is known to frame::interpreter_frame_result.
1101   // If the order changes or anything else is added to the stack the code in
1102   // interpreter_frame_result will have to be changed.
1103 
1104   { Label L;
1105     Label push_double;
1106     ExternalAddress float_handler(AbstractInterpreter::result_handler(T_FLOAT));
1107     ExternalAddress double_handler(AbstractInterpreter::result_handler(T_DOUBLE));
1108     __ cmpptr(Address(rbp, (frame::interpreter_frame_result_handler_offset)*wordSize),
1109               float_handler.addr(), noreg);
1110     __ jcc(Assembler::equal, push_double);
1111     __ cmpptr(Address(rbp, (frame::interpreter_frame_result_handler_offset)*wordSize),
1112               double_handler.addr(), noreg);
1113     __ jcc(Assembler::notEqual, L);
1114     __ bind(push_double);
1115     __ push_d(); // FP values are returned using the FPU, so push FPU contents (even if UseSSE > 0).
1116     __ bind(L);
1117   }
1118 #else
1119   __ push(dtos);
1120 #endif // _LP64
1121 
1122   __ push(ltos);
1123 
1124   // change thread state
1125   NOT_LP64(__ get_thread(thread));
1126   __ movl(Address(thread, JavaThread::thread_state_offset()),
1127           _thread_in_native_trans);
1128 
1129   // Force this write out before the read below
1130   if (!UseSystemMemoryBarrier) {
1131     __ membar(Assembler::Membar_mask_bits(

1161     __ push(thread);
1162     __ call(RuntimeAddress(CAST_FROM_FN_PTR(address,
1163                                             JavaThread::check_special_condition_for_native_trans)));
1164     __ increment(rsp, wordSize);
1165     __ get_thread(thread);
1166 #else
1167     __ mov(c_rarg0, r15_thread);
1168     __ mov(r12, rsp); // remember sp (can only use r12 if not using call_VM)
1169     __ subptr(rsp, frame::arg_reg_save_area_bytes); // windows
1170     __ andptr(rsp, -16); // align stack as required by ABI
1171     __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, JavaThread::check_special_condition_for_native_trans)));
1172     __ mov(rsp, r12); // restore sp
1173     __ reinit_heapbase();
1174 #endif // _LP64
1175     __ bind(Continue);
1176   }
1177 
1178   // change thread state
1179   __ movl(Address(thread, JavaThread::thread_state_offset()), _thread_in_Java);
1180 
1181   // Check preemption for Object.wait()
1182   Label not_preempted;
1183   __ movptr(rscratch1, Address(r15_thread, JavaThread::preempt_alternate_return_offset()));
1184   __ cmpptr(rscratch1, NULL_WORD);
1185   __ jccb(Assembler::equal, not_preempted);
1186   __ movptr(Address(r15_thread, JavaThread::preempt_alternate_return_offset()), NULL_WORD);
1187   __ jmp(rscratch1);
1188   Interpreter::_native_frame_resume_entry = __ pc();
1189   // On resume we need to set up stack as expected
1190   __ push(dtos);
1191   __ push(ltos);
1192   __ bind(not_preempted);
1193 
1194   // reset_last_Java_frame
1195   __ reset_last_Java_frame(thread, true);
1196 
1197   if (CheckJNICalls) {
1198     // clear_pending_jni_exception_check
1199     __ movptr(Address(thread, JavaThread::pending_jni_exception_check_fn_offset()), NULL_WORD);
1200   }
1201 
1202   // reset handle block
1203   __ movptr(t, Address(thread, JavaThread::active_handles_offset()));
1204   __ movl(Address(t, JNIHandleBlock::top_offset()), NULL_WORD);
1205 
1206   // If result is an oop unbox and store it in frame where gc will see it
1207   // and result handler will pick it up
1208 
1209   {
1210     Label no_oop;
1211     __ lea(t, ExternalAddress(AbstractInterpreter::result_handler(T_OBJECT)));
1212     __ cmpptr(t, Address(rbp, frame::interpreter_frame_result_handler_offset*wordSize));
1213     __ jcc(Assembler::notEqual, no_oop);
< prev index next >