Skip to content

Commit

Permalink
feedback from Niklas
Browse files Browse the repository at this point in the history
  • Loading branch information
TheRealMDoerr committed Feb 5, 2021
1 parent be66f4e commit 32e919d
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 30 deletions.
59 changes: 30 additions & 29 deletions src/hotspot/cpu/ppc/templateInterpreterGenerator_ppc.cpp
Expand Up @@ -932,13 +932,14 @@ void TemplateInterpreterGenerator::lock_method(Register Rflags, Register Rscratc
// state_size: We save the current state of the interpreter to this area.
//
void TemplateInterpreterGenerator::generate_fixed_frame(bool native_call, Register Rsize_of_parameters, Register Rsize_of_locals) {
Register parent_frame_resize = R6_ARG4, // Frame will grow by this number of bytes.
top_frame_size = R7_ARG5,
Rconst_method = R8_ARG6,
Rconst_pool = R9_ARG7,
R10_tmp = R10_ARG8;
Register Rparent_frame_resize = R6_ARG4, // Frame will grow by this number of bytes.
Rtop_frame_size = R7_ARG5,
Rconst_method = R8_ARG6,
Rconst_pool = R9_ARG7,
Rmirror = R10_ARG8;

assert_different_registers(Rsize_of_parameters, Rsize_of_locals, parent_frame_resize, top_frame_size);
assert_different_registers(Rsize_of_parameters, Rsize_of_locals, Rparent_frame_resize, Rtop_frame_size,
Rconst_method, Rconst_pool);

__ ld(Rconst_method, method_(const));
__ lhz(Rsize_of_parameters /* number of params */,
Expand All @@ -949,43 +950,43 @@ void TemplateInterpreterGenerator::generate_fixed_frame(bool native_call, Regist
// We add two slots to the parameter_count, one for the jni
// environment and one for a possible native mirror.
Label skip_native_calculate_max_stack;
__ addi(top_frame_size, Rsize_of_parameters, 2);
__ cmpwi(CCR0, top_frame_size, Argument::n_register_parameters);
__ addi(Rtop_frame_size, Rsize_of_parameters, 2);
__ cmpwi(CCR0, Rtop_frame_size, Argument::n_register_parameters);
__ bge(CCR0, skip_native_calculate_max_stack);
__ li(top_frame_size, Argument::n_register_parameters);
__ li(Rtop_frame_size, Argument::n_register_parameters);
__ bind(skip_native_calculate_max_stack);
__ sldi(Rsize_of_parameters, Rsize_of_parameters, Interpreter::logStackElementSize);
__ sldi(top_frame_size, top_frame_size, Interpreter::logStackElementSize);
__ sub(parent_frame_resize, R1_SP, R15_esp); // <0, off by Interpreter::stackElementSize!
__ sldi(Rtop_frame_size, Rtop_frame_size, Interpreter::logStackElementSize);
__ sub(Rparent_frame_resize, R1_SP, R15_esp); // <0, off by Interpreter::stackElementSize!
assert(Rsize_of_locals == noreg, "Rsize_of_locals not initialized"); // Only relevant value is Rsize_of_parameters.
} else {
__ lhz(Rsize_of_locals /* number of params */, in_bytes(ConstMethod::size_of_locals_offset()), Rconst_method);
__ sldi(Rsize_of_parameters, Rsize_of_parameters, Interpreter::logStackElementSize);
__ sldi(Rsize_of_locals, Rsize_of_locals, Interpreter::logStackElementSize);
__ lhz(top_frame_size, in_bytes(ConstMethod::max_stack_offset()), Rconst_method);
__ lhz(Rtop_frame_size, in_bytes(ConstMethod::max_stack_offset()), Rconst_method);
__ sub(R11_scratch1, Rsize_of_locals, Rsize_of_parameters); // >=0
__ sub(parent_frame_resize, R1_SP, R15_esp); // <0, off by Interpreter::stackElementSize!
__ sldi(top_frame_size, top_frame_size, Interpreter::logStackElementSize);
__ add(parent_frame_resize, parent_frame_resize, R11_scratch1);
__ sub(Rparent_frame_resize, R1_SP, R15_esp); // <0, off by Interpreter::stackElementSize!
__ sldi(Rtop_frame_size, Rtop_frame_size, Interpreter::logStackElementSize);
__ add(Rparent_frame_resize, Rparent_frame_resize, R11_scratch1);
}

// Compute top frame size.
__ addi(top_frame_size, top_frame_size, frame::abi_reg_args_size + frame::ijava_state_size);
__ addi(Rtop_frame_size, Rtop_frame_size, frame::abi_reg_args_size + frame::ijava_state_size);

// Cut back area between esp and max_stack.
__ addi(parent_frame_resize, parent_frame_resize, frame::abi_minframe_size - Interpreter::stackElementSize);
__ addi(Rparent_frame_resize, Rparent_frame_resize, frame::abi_minframe_size - Interpreter::stackElementSize);

__ round_to(top_frame_size, frame::alignment_in_bytes);
__ round_to(parent_frame_resize, frame::alignment_in_bytes);
// parent_frame_resize = (locals-parameters) - (ESP-SP-ABI48) Rounded to frame alignment size.
__ round_to(Rtop_frame_size, frame::alignment_in_bytes);
__ round_to(Rparent_frame_resize, frame::alignment_in_bytes);
// Rparent_frame_resize = (locals-parameters) - (ESP-SP-ABI48) Rounded to frame alignment size.
// Enlarge by locals-parameters (not in case of native_call), shrink by ESP-SP-ABI48.

if (!native_call) {
// Stack overflow check.
// Native calls don't need the stack size check since they have no
// expression stack and the arguments are already on the stack and
// we only add a handful of words to the stack.
__ add(R11_scratch1, parent_frame_resize, top_frame_size);
__ add(R11_scratch1, Rparent_frame_resize, Rtop_frame_size);
generate_stack_overflow_check(R11_scratch1, R12_scratch2);
}

Expand Down Expand Up @@ -1013,21 +1014,21 @@ void TemplateInterpreterGenerator::generate_fixed_frame(bool native_call, Regist

// Resize parent frame.
__ mflr(R12_scratch2);
__ neg(parent_frame_resize, parent_frame_resize);
__ resize_frame(parent_frame_resize, R11_scratch1);
__ neg(Rparent_frame_resize, Rparent_frame_resize);
__ resize_frame(Rparent_frame_resize, R11_scratch1);
__ std(R12_scratch2, _abi0(lr), R1_SP);

// Get mirror and store it in the frame as GC root for this Method*.
__ ld(R10_tmp, ConstantPool::pool_holder_offset_in_bytes(), Rconst_pool);
__ ld(R10_tmp, in_bytes(Klass::java_mirror_offset()), R10_tmp);
__ resolve_oop_handle(R10_tmp, R11_scratch1, R12_scratch2, MacroAssembler::PRESERVATION_FRAME_LR_GP_REGS);
__ ld(Rmirror, ConstantPool::pool_holder_offset_in_bytes(), Rconst_pool);
__ ld(Rmirror, in_bytes(Klass::java_mirror_offset()), Rmirror);
__ resolve_oop_handle(Rmirror, R11_scratch1, R12_scratch2, MacroAssembler::PRESERVATION_FRAME_LR_GP_REGS);

__ addi(R26_monitor, R1_SP, -frame::ijava_state_size);
__ addi(R15_esp, R26_monitor, -Interpreter::stackElementSize);

// Store values.
__ std(R19_method, _ijava_state_neg(method), R1_SP);
__ std(R10_tmp, _ijava_state_neg(mirror), R1_SP);
__ std(Rmirror, _ijava_state_neg(mirror), R1_SP);
__ std(R18_locals, _ijava_state_neg(locals), R1_SP);
__ std(R27_constPoolCache, _ijava_state_neg(cpoolCache), R1_SP);

Expand All @@ -1049,12 +1050,12 @@ void TemplateInterpreterGenerator::generate_fixed_frame(bool native_call, Regist
__ std(R0, _ijava_state_neg(oop_tmp), R1_SP); // only used for native_call

// Store sender's SP and this frame's top SP.
__ subf(R12_scratch2, top_frame_size, R1_SP);
__ subf(R12_scratch2, Rtop_frame_size, R1_SP);
__ std(R21_sender_SP, _ijava_state_neg(sender_sp), R1_SP);
__ std(R12_scratch2, _ijava_state_neg(top_frame_sp), R1_SP);

// Push top frame.
__ push_frame(top_frame_size, R11_scratch1);
__ push_frame(Rtop_frame_size, R11_scratch1);
}

// End of helpers
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/cpu/ppc/templateTable_ppc_64.cpp
Expand Up @@ -3362,7 +3362,7 @@ void TemplateTable::prepare_invoke(int byte_no,

// Load receiver if needed (after appendix is pushed so parameter size is correct).
if (load_receiver) {
const Register Rparam_count = Rscratch1;
Register Rparam_count = Rscratch1;
__ andi(Rparam_count, Rflags, ConstantPoolCacheEntry::parameter_size_mask);
__ load_receiver(Rparam_count, Rrecv);
__ verify_oop(Rrecv);
Expand Down

0 comments on commit 32e919d

Please sign in to comment.