< prev index next >

src/hotspot/cpu/ppc/templateInterpreterGenerator_ppc.cpp

Print this page
rev 55858 : 8228649: [PPC64] SA reads wrong slots from interpreter frames
Summary: Make frame layout consistent between dbg and product build and implement offsets accordingly.
Reviewed-by: goetz, gromero


1033     __ beq(CCR0, zero_continue);
1034     __ addi(R28_mdx, R28_mdx, in_bytes(MethodData::data_offset()));
1035     __ bind(zero_continue);
1036   }
1037 
1038   if (native_call) {
1039     __ li(R14_bcp, 0); // Must initialize.
1040   } else {
1041     __ add(R14_bcp, in_bytes(ConstMethod::codes_offset()), Rconst_method);
1042   }
1043 
1044   // Resize parent frame.
1045   __ mflr(R12_scratch2);
1046   __ neg(parent_frame_resize, parent_frame_resize);
1047   __ resize_frame(parent_frame_resize, R11_scratch1);
1048   __ std(R12_scratch2, _abi(lr), R1_SP);
1049 
1050   // Get mirror and store it in the frame as GC root for this Method*.
1051   __ load_mirror_from_const_method(R12_scratch2, Rconst_method);
1052 
1053   __ addi(R26_monitor, R1_SP, - frame::ijava_state_size);
1054   __ addi(R15_esp, R26_monitor, - Interpreter::stackElementSize);
1055 
1056   // Store values.
1057   // R15_esp, R14_bcp, R26_monitor, R28_mdx are saved at java calls
1058   // in InterpreterMacroAssembler::call_from_interpreter.
1059   __ std(R19_method, _ijava_state_neg(method), R1_SP);
1060   __ std(R12_scratch2, _ijava_state_neg(mirror), R1_SP);
1061   __ std(R21_sender_SP, _ijava_state_neg(sender_sp), R1_SP);
1062   __ std(R27_constPoolCache, _ijava_state_neg(cpoolCache), R1_SP);
1063   __ std(R18_locals, _ijava_state_neg(locals), R1_SP);

1064 
1065   // Note: esp, bcp, monitor, mdx live in registers. Hence, the correct version can only
1066   // be found in the frame after save_interpreter_state is done. This is always true
1067   // for non-top frames. But when a signal occurs, dumping the top frame can go wrong,
1068   // because e.g. frame::interpreter_frame_bcp() will not access the correct value
1069   // (Enhanced Stack Trace).
1070   // The signal handler does not save the interpreter state into the frame.




1071   __ li(R0, 0);
1072 #ifdef ASSERT
1073   // Fill remaining slots with constants.
1074   __ load_const_optimized(R11_scratch1, 0x5afe);
1075   __ load_const_optimized(R12_scratch2, 0xdead);
1076 #endif
1077   // We have to initialize some frame slots for native calls (accessed by GC).
1078   if (native_call) {
1079     __ std(R26_monitor, _ijava_state_neg(monitors), R1_SP);
1080     __ std(R14_bcp, _ijava_state_neg(bcp), R1_SP);
1081     if (ProfileInterpreter) { __ std(R28_mdx, _ijava_state_neg(mdx), R1_SP); }
1082   }
1083 #ifdef ASSERT
1084   else {
1085     __ std(R12_scratch2, _ijava_state_neg(monitors), R1_SP);
1086     __ std(R12_scratch2, _ijava_state_neg(bcp), R1_SP);
1087     __ std(R12_scratch2, _ijava_state_neg(mdx), R1_SP);
1088   }
1089   __ std(R11_scratch1, _ijava_state_neg(ijava_reserved), R1_SP);
1090   __ std(R12_scratch2, _ijava_state_neg(esp), R1_SP);
1091   __ std(R12_scratch2, _ijava_state_neg(lresult), R1_SP);
1092   __ std(R12_scratch2, _ijava_state_neg(fresult), R1_SP);
1093 #endif
1094   __ subf(R12_scratch2, top_frame_size, R1_SP);
1095   __ std(R0, _ijava_state_neg(oop_tmp), R1_SP);
1096   __ std(R12_scratch2, _ijava_state_neg(top_frame_sp), R1_SP);
1097 
1098   // Push top frame.
1099   __ push_frame(top_frame_size, R11_scratch1);
1100 }
1101 
1102 // End of helpers
1103 
1104 address TemplateInterpreterGenerator::generate_math_entry(AbstractInterpreter::MethodKind kind) {
1105 
1106   // Decide what to do: Use same platform specific instructions and runtime calls as compilers.
1107   bool use_instruction = false;
1108   address runtime_entry = NULL;
1109   int num_args = 1;
1110   bool double_precision = true;
1111 
1112   // PPC64 specific:
1113   switch (kind) {
1114     case Interpreter::java_lang_math_sqrt: use_instruction = VM_Version::has_fsqrt(); break;
1115     case Interpreter::java_lang_math_abs:  use_instruction = true; break;




1033     __ beq(CCR0, zero_continue);
1034     __ addi(R28_mdx, R28_mdx, in_bytes(MethodData::data_offset()));
1035     __ bind(zero_continue);
1036   }
1037 
1038   if (native_call) {
1039     __ li(R14_bcp, 0); // Must initialize.
1040   } else {
1041     __ add(R14_bcp, in_bytes(ConstMethod::codes_offset()), Rconst_method);
1042   }
1043 
1044   // Resize parent frame.
1045   __ mflr(R12_scratch2);
1046   __ neg(parent_frame_resize, parent_frame_resize);
1047   __ resize_frame(parent_frame_resize, R11_scratch1);
1048   __ std(R12_scratch2, _abi(lr), R1_SP);
1049 
1050   // Get mirror and store it in the frame as GC root for this Method*.
1051   __ load_mirror_from_const_method(R12_scratch2, Rconst_method);
1052 
1053   __ addi(R26_monitor, R1_SP, -frame::ijava_state_size);
1054   __ addi(R15_esp, R26_monitor, -Interpreter::stackElementSize);
1055 
1056   // Store values.


1057   __ std(R19_method, _ijava_state_neg(method), R1_SP);
1058   __ std(R12_scratch2, _ijava_state_neg(mirror), R1_SP);


1059   __ std(R18_locals, _ijava_state_neg(locals), R1_SP);
1060   __ std(R27_constPoolCache, _ijava_state_neg(cpoolCache), R1_SP);
1061 
1062   // Note: esp, bcp, monitor, mdx live in registers. Hence, the correct version can only
1063   // be found in the frame after save_interpreter_state is done. This is always true
1064   // for non-top frames. But when a signal occurs, dumping the top frame can go wrong,
1065   // because e.g. frame::interpreter_frame_bcp() will not access the correct value
1066   // (Enhanced Stack Trace).
1067   // The signal handler does not save the interpreter state into the frame.
1068 
1069   // We have to initialize some of these frame slots for native calls (accessed by GC).
1070   // Also initialize them for non-native calls for better tool support (even though
1071   // you may not get the most recent version as described above).
1072   __ li(R0, 0);







1073   __ std(R26_monitor, _ijava_state_neg(monitors), R1_SP);
1074   __ std(R14_bcp, _ijava_state_neg(bcp), R1_SP);
1075   if (ProfileInterpreter) { __ std(R28_mdx, _ijava_state_neg(mdx), R1_SP); }
1076   __ std(R15_esp, _ijava_state_neg(esp), R1_SP);
1077   __ std(R0, _ijava_state_neg(oop_tmp), R1_SP); // only used for native_call
1078 
1079   // Store sender's SP and this frame's top SP.








1080   __ subf(R12_scratch2, top_frame_size, R1_SP);
1081   __ std(R21_sender_SP, _ijava_state_neg(sender_sp), R1_SP);
1082   __ std(R12_scratch2, _ijava_state_neg(top_frame_sp), R1_SP);
1083 
1084   // Push top frame.
1085   __ push_frame(top_frame_size, R11_scratch1);
1086 }
1087 
1088 // End of helpers
1089 
1090 address TemplateInterpreterGenerator::generate_math_entry(AbstractInterpreter::MethodKind kind) {
1091 
1092   // Decide what to do: Use same platform specific instructions and runtime calls as compilers.
1093   bool use_instruction = false;
1094   address runtime_entry = NULL;
1095   int num_args = 1;
1096   bool double_precision = true;
1097 
1098   // PPC64 specific:
1099   switch (kind) {
1100     case Interpreter::java_lang_math_sqrt: use_instruction = VM_Version::has_fsqrt(); break;
1101     case Interpreter::java_lang_math_abs:  use_instruction = true; break;


< prev index next >