158 case stos:
159 case atos:
160 case itos: __ mr(R17_tos, R3_RET); break; // RET -> TOS cache
161 case ftos:
162 case dtos: __ fmr(F15_ftos, F1_RET); break; // TOS cache -> GR_FRET
163 case vtos: break; // Nothing to do, this was a void return.
164 default : ShouldNotReachHere();
165 }
166
167 __ restore_interpreter_state(R11_scratch1); // Sets R11_scratch1 = fp.
168 __ ld(R12_scratch2, _ijava_state_neg(top_frame_sp), R11_scratch1);
169 __ resize_frame_absolute(R12_scratch2, R11_scratch1, R0);
170
171 // Compiled code destroys templateTableBase, reload.
172 __ load_const_optimized(R25_templateTableBase, (address)Interpreter::dispatch_table((TosState)0), R12_scratch2);
173
174 const Register cache = R11_scratch1;
175 const Register size = R12_scratch2;
176 __ get_cache_and_index_at_bcp(cache, 1, index_size);
177
178 // Big Endian (get least significant byte of 64 bit value):
179 __ lbz(size, in_bytes(ConstantPoolCache::base_offset() + ConstantPoolCacheEntry::flags_offset()) + 7, cache);
180 __ sldi(size, size, Interpreter::logStackElementSize);
181 __ add(R15_esp, R15_esp, size);
182 __ dispatch_next(state, step);
183 return entry;
184 }
185
186 address TemplateInterpreterGenerator::generate_deopt_entry_for(TosState state, int step) {
187 address entry = __ pc();
188 // If state != vtos, we're returning from a native method, which put it's result
189 // into the result register. So move the value out of the return register back
190 // to the TOS cache of current frame.
191
192 switch (state) {
193 case ltos:
194 case btos:
195 case ctos:
196 case stos:
197 case atos:
198 case itos: __ mr(R17_tos, R3_RET); break; // GR_RET -> TOS cache
199 case ftos:
840 // from jni but before we can get back to Java.
841
842 // First set the frame anchor while the SP/FP registers are
843 // convenient and the slow signature handler can use this same frame
844 // anchor.
845
846 // We have a TOP_IJAVA_FRAME here, which belongs to us.
847 __ set_top_ijava_frame_at_SP_as_last_Java_frame(R1_SP, R12_scratch2/*tmp*/);
848
849 // Now the interpreter frame (and its call chain) have been
850 // invalidated and flushed. We are now protected against eager
851 // being enabled in native code. Even if it goes eager the
852 // registers will be reloaded as clean and we will invalidate after
853 // the call so no spurious flush should be possible.
854
855 // Call signature handler and pass locals address.
856 //
857 // Our signature handlers copy required arguments to the C stack
858 // (outgoing C args), R3_ARG1 to R10_ARG8, and FARG1 to FARG13.
859 __ mr(R3_ARG1, R18_locals);
860 __ ld(signature_handler_fd, 0, signature_handler_fd);
861
862 __ call_stub(signature_handler_fd);
863
864 // Remove the register parameter varargs slots we allocated in
865 // compute_interpreter_state. SP+16 ends up pointing to the ABI
866 // outgoing argument area.
867 //
868 // Not needed on PPC64.
869 //__ add(SP, SP, Argument::n_register_parameters*BytesPerWord);
870
871 assert(result_handler_addr->is_nonvolatile(), "result_handler_addr must be in a non-volatile register");
872 // Save across call to native method.
873 __ mr(result_handler_addr, R3_RET);
874
875 __ isync(); // Acquire signature handler before trying to fetch the native entry point and klass mirror.
876
877 // Set up fixed parameters and call the native method.
878 // If the method is static, get mirror into R4_ARG2.
879 {
880 Label method_is_not_static;
1002
1003 // TODO PPC port assert(4 == Thread::sz_suspend_flags(), "unexpected field size");
1004 __ lwz(suspend_flags, thread_(suspend_flags));
1005
1006 Label sync_check_done;
1007 Label do_safepoint;
1008 // No synchronization in progress nor yet synchronized.
1009 __ cmpwi(CCR0, sync_state, SafepointSynchronize::_not_synchronized);
1010 // Not suspended.
1011 __ cmpwi(CCR1, suspend_flags, 0);
1012
1013 __ bne(CCR0, do_safepoint);
1014 __ beq(CCR1, sync_check_done);
1015 __ bind(do_safepoint);
1016 __ isync();
1017 // Block. We do the call directly and leave the current
1018 // last_Java_frame setup undisturbed. We must save any possible
1019 // native result across the call. No oop is present.
1020
1021 __ mr(R3_ARG1, R16_thread);
1022 __ call_c(CAST_FROM_FN_PTR(FunctionDescriptor*, JavaThread::check_special_condition_for_native_trans),
1023 relocInfo::none);
1024
1025 __ bind(sync_check_done);
1026
1027 //=============================================================================
1028 // <<<<<< Back in Interpreter Frame >>>>>
1029
1030 // We are in thread_in_native_trans here and back in the normal
1031 // interpreter frame. We don't have to do anything special about
1032 // safepoints and we can switch to Java mode anytime we are ready.
1033
1034 // Note: frame::interpreter_frame_result has a dependency on how the
1035 // method result is saved across the call to post_method_exit. For
1036 // native methods it assumes that the non-FPU/non-void result is
1037 // saved in _native_lresult and a FPU result in _native_fresult. If
1038 // this changes then the interpreter_frame_result implementation
1039 // will need to be updated too.
1040
1041 // On PPC64, we have stored the result directly after the native call.
1042
1043 //=============================================================================
|
158 case stos:
159 case atos:
160 case itos: __ mr(R17_tos, R3_RET); break; // RET -> TOS cache
161 case ftos:
162 case dtos: __ fmr(F15_ftos, F1_RET); break; // TOS cache -> GR_FRET
163 case vtos: break; // Nothing to do, this was a void return.
164 default : ShouldNotReachHere();
165 }
166
167 __ restore_interpreter_state(R11_scratch1); // Sets R11_scratch1 = fp.
168 __ ld(R12_scratch2, _ijava_state_neg(top_frame_sp), R11_scratch1);
169 __ resize_frame_absolute(R12_scratch2, R11_scratch1, R0);
170
171 // Compiled code destroys templateTableBase, reload.
172 __ load_const_optimized(R25_templateTableBase, (address)Interpreter::dispatch_table((TosState)0), R12_scratch2);
173
174 const Register cache = R11_scratch1;
175 const Register size = R12_scratch2;
176 __ get_cache_and_index_at_bcp(cache, 1, index_size);
177
178 // Get least significant byte of 64 bit value:
179 #if defined(VM_LITTLE_ENDIAN)
180 __ lbz(size, in_bytes(ConstantPoolCache::base_offset() + ConstantPoolCacheEntry::flags_offset()), cache);
181 #else
182 __ lbz(size, in_bytes(ConstantPoolCache::base_offset() + ConstantPoolCacheEntry::flags_offset()) + 7, cache);
183 #endif
184 __ sldi(size, size, Interpreter::logStackElementSize);
185 __ add(R15_esp, R15_esp, size);
186 __ dispatch_next(state, step);
187 return entry;
188 }
189
190 address TemplateInterpreterGenerator::generate_deopt_entry_for(TosState state, int step) {
191 address entry = __ pc();
192 // If state != vtos, we're returning from a native method, which put it's result
193 // into the result register. So move the value out of the return register back
194 // to the TOS cache of current frame.
195
196 switch (state) {
197 case ltos:
198 case btos:
199 case ctos:
200 case stos:
201 case atos:
202 case itos: __ mr(R17_tos, R3_RET); break; // GR_RET -> TOS cache
203 case ftos:
844 // from jni but before we can get back to Java.
845
846 // First set the frame anchor while the SP/FP registers are
847 // convenient and the slow signature handler can use this same frame
848 // anchor.
849
850 // We have a TOP_IJAVA_FRAME here, which belongs to us.
851 __ set_top_ijava_frame_at_SP_as_last_Java_frame(R1_SP, R12_scratch2/*tmp*/);
852
853 // Now the interpreter frame (and its call chain) have been
854 // invalidated and flushed. We are now protected against eager
855 // being enabled in native code. Even if it goes eager the
856 // registers will be reloaded as clean and we will invalidate after
857 // the call so no spurious flush should be possible.
858
859 // Call signature handler and pass locals address.
860 //
861 // Our signature handlers copy required arguments to the C stack
862 // (outgoing C args), R3_ARG1 to R10_ARG8, and FARG1 to FARG13.
863 __ mr(R3_ARG1, R18_locals);
864 #if !defined(ABI_ELFv2)
865 __ ld(signature_handler_fd, 0, signature_handler_fd);
866 #endif
867
868 __ call_stub(signature_handler_fd);
869
870 // Remove the register parameter varargs slots we allocated in
871 // compute_interpreter_state. SP+16 ends up pointing to the ABI
872 // outgoing argument area.
873 //
874 // Not needed on PPC64.
875 //__ add(SP, SP, Argument::n_register_parameters*BytesPerWord);
876
877 assert(result_handler_addr->is_nonvolatile(), "result_handler_addr must be in a non-volatile register");
878 // Save across call to native method.
879 __ mr(result_handler_addr, R3_RET);
880
881 __ isync(); // Acquire signature handler before trying to fetch the native entry point and klass mirror.
882
883 // Set up fixed parameters and call the native method.
884 // If the method is static, get mirror into R4_ARG2.
885 {
886 Label method_is_not_static;
1008
1009 // TODO PPC port assert(4 == Thread::sz_suspend_flags(), "unexpected field size");
1010 __ lwz(suspend_flags, thread_(suspend_flags));
1011
1012 Label sync_check_done;
1013 Label do_safepoint;
1014 // No synchronization in progress nor yet synchronized.
1015 __ cmpwi(CCR0, sync_state, SafepointSynchronize::_not_synchronized);
1016 // Not suspended.
1017 __ cmpwi(CCR1, suspend_flags, 0);
1018
1019 __ bne(CCR0, do_safepoint);
1020 __ beq(CCR1, sync_check_done);
1021 __ bind(do_safepoint);
1022 __ isync();
1023 // Block. We do the call directly and leave the current
1024 // last_Java_frame setup undisturbed. We must save any possible
1025 // native result across the call. No oop is present.
1026
1027 __ mr(R3_ARG1, R16_thread);
1028 #if defined(ABI_ELFv2)
1029 __ call_c(CAST_FROM_FN_PTR(address, JavaThread::check_special_condition_for_native_trans),
1030 relocInfo::none);
1031 #else
1032 __ call_c(CAST_FROM_FN_PTR(FunctionDescriptor*, JavaThread::check_special_condition_for_native_trans),
1033 relocInfo::none);
1034 #endif
1035
1036 __ bind(sync_check_done);
1037
1038 //=============================================================================
1039 // <<<<<< Back in Interpreter Frame >>>>>
1040
1041 // We are in thread_in_native_trans here and back in the normal
1042 // interpreter frame. We don't have to do anything special about
1043 // safepoints and we can switch to Java mode anytime we are ready.
1044
1045 // Note: frame::interpreter_frame_result has a dependency on how the
1046 // method result is saved across the call to post_method_exit. For
1047 // native methods it assumes that the non-FPU/non-void result is
1048 // saved in _native_lresult and a FPU result in _native_fresult. If
1049 // this changes then the interpreter_frame_result implementation
1050 // will need to be updated too.
1051
1052 // On PPC64, we have stored the result directly after the native call.
1053
1054 //=============================================================================
|