Skip to content

Commit 48f5220

Browse files
committedFeb 5, 2021
8260369: [PPC64] Add support for JDK-8200555
Reviewed-by: lucy
1 parent 224c166 commit 48f5220

7 files changed

+111
-87
lines changed
 

‎src/hotspot/cpu/ppc/interp_masm_ppc.hpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ class InterpreterMacroAssembler: public MacroAssembler {
7777
Register tmp1, Register tmp2, Register tmp3, Label &ok_is_subtype);
7878

7979
// Load object from cpool->resolved_references(index).
80-
void load_resolved_reference_at_index(Register result, Register index, Register tmp1, Label *L_handle_null = NULL);
80+
void load_resolved_reference_at_index(Register result, Register index, Register tmp1, Register tmp2,
81+
Label *L_handle_null = NULL);
8182

8283
// load cpool->resolved_klass_at(index)
8384
void load_resolved_klass_at_offset(Register Rcpool, Register Roffset, Register Rklass);

‎src/hotspot/cpu/ppc/interp_masm_ppc_64.cpp

+9-8
Original file line numberDiff line numberDiff line change
@@ -477,33 +477,34 @@ void InterpreterMacroAssembler::get_u4(Register Rdst, Register Rsrc, int offset,
477477
// Load object from cpool->resolved_references(index).
478478
// Kills:
479479
// - index
480-
void InterpreterMacroAssembler::load_resolved_reference_at_index(Register result, Register index, Register tmp1,
480+
void InterpreterMacroAssembler::load_resolved_reference_at_index(Register result, Register index,
481+
Register tmp1, Register tmp2,
481482
Label *L_handle_null) {
482-
assert_different_registers(result, index);
483+
assert_different_registers(result, index, tmp1, tmp2);
484+
assert(index->is_nonvolatile(), "needs to survive C-call in resolve_oop_handle");
483485
get_constant_pool(result);
484486

485487
// Convert from field index to resolved_references() index and from
486488
// word index to byte offset. Since this is a java object, it can be compressed.
487-
Register tmp2 = index; // reuse
488-
sldi(tmp1, index, LogBytesPerHeapOop);
489+
sldi(index, index, LogBytesPerHeapOop);
489490
// Load pointer for resolved_references[] objArray.
490491
ld(result, ConstantPool::cache_offset_in_bytes(), result);
491492
ld(result, ConstantPoolCache::resolved_references_offset_in_bytes(), result);
492-
resolve_oop_handle(result);
493+
resolve_oop_handle(result, tmp1, tmp2, MacroAssembler::PRESERVATION_NONE);
493494
#ifdef ASSERT
494495
Label index_ok;
495496
lwa(R0, arrayOopDesc::length_offset_in_bytes(), result);
496497
sldi(R0, R0, LogBytesPerHeapOop);
497-
cmpd(CCR0, tmp1, R0);
498+
cmpd(CCR0, index, R0);
498499
blt(CCR0, index_ok);
499500
stop("resolved reference index out of bounds");
500501
bind(index_ok);
501502
#endif
502503
// Add in the index.
503-
add(result, tmp1, result);
504+
add(result, index, result);
504505
load_heap_oop(result, arrayOopDesc::base_offset_in_bytes(T_OBJECT), result,
505506
tmp1, tmp2,
506-
MacroAssembler::PRESERVATION_FRAME_LR,
507+
MacroAssembler::PRESERVATION_NONE,
507508
0, L_handle_null);
508509
}
509510

‎src/hotspot/cpu/ppc/macroAssembler_ppc.cpp

+14-8
Original file line numberDiff line numberDiff line change
@@ -3233,16 +3233,22 @@ void MacroAssembler::load_klass(Register dst, Register src) {
32333233
}
32343234

32353235
// ((OopHandle)result).resolve();
3236-
void MacroAssembler::resolve_oop_handle(Register result) {
3237-
// OopHandle::resolve is an indirection.
3238-
ld(result, 0, result);
3236+
void MacroAssembler::resolve_oop_handle(Register result, Register tmp1, Register tmp2,
3237+
MacroAssembler::PreservationLevel preservation_level) {
3238+
access_load_at(T_OBJECT, IN_NATIVE, result, noreg, result, tmp1, tmp2, preservation_level);
32393239
}
32403240

3241-
void MacroAssembler::load_mirror_from_const_method(Register mirror, Register const_method) {
3242-
ld(mirror, in_bytes(ConstMethod::constants_offset()), const_method);
3243-
ld(mirror, ConstantPool::pool_holder_offset_in_bytes(), mirror);
3244-
ld(mirror, in_bytes(Klass::java_mirror_offset()), mirror);
3245-
resolve_oop_handle(mirror);
3241+
void MacroAssembler::resolve_weak_handle(Register result, Register tmp1, Register tmp2,
3242+
MacroAssembler::PreservationLevel preservation_level) {
3243+
Label resolved;
3244+
3245+
// A null weak handle resolves to null.
3246+
cmpdi(CCR0, result, 0);
3247+
beq(CCR0, resolved);
3248+
3249+
access_load_at(T_OBJECT, IN_NATIVE | ON_PHANTOM_OOP_REF, result, noreg, result, tmp1, tmp2,
3250+
preservation_level);
3251+
bind(resolved);
32463252
}
32473253

32483254
void MacroAssembler::load_method_holder(Register holder, Register method) {

‎src/hotspot/cpu/ppc/macroAssembler_ppc.hpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -743,8 +743,10 @@ class MacroAssembler: public Assembler {
743743
void store_klass(Register dst_oop, Register klass, Register tmp = R0);
744744
void store_klass_gap(Register dst_oop, Register val = noreg); // Will store 0 if val not specified.
745745

746-
void resolve_oop_handle(Register result);
747-
void load_mirror_from_const_method(Register mirror, Register const_method);
746+
void resolve_oop_handle(Register result, Register tmp1, Register tmp2,
747+
MacroAssembler::PreservationLevel preservation_level);
748+
void resolve_weak_handle(Register result, Register tmp1, Register tmp2,
749+
MacroAssembler::PreservationLevel preservation_level);
748750
void load_method_holder(Register holder, Register method);
749751

750752
static int instr_size_for_decode_klass_not_null();

‎src/hotspot/cpu/ppc/templateInterpreterGenerator_ppc.cpp

+32-27
Original file line numberDiff line numberDiff line change
@@ -933,11 +933,14 @@ void TemplateInterpreterGenerator::lock_method(Register Rflags, Register Rscratc
933933
// state_size: We save the current state of the interpreter to this area.
934934
//
935935
void TemplateInterpreterGenerator::generate_fixed_frame(bool native_call, Register Rsize_of_parameters, Register Rsize_of_locals) {
936-
Register parent_frame_resize = R6_ARG4, // Frame will grow by this number of bytes.
937-
top_frame_size = R7_ARG5,
938-
Rconst_method = R8_ARG6;
936+
Register Rparent_frame_resize = R6_ARG4, // Frame will grow by this number of bytes.
937+
Rtop_frame_size = R7_ARG5,
938+
Rconst_method = R8_ARG6,
939+
Rconst_pool = R9_ARG7,
940+
Rmirror = R10_ARG8;
939941

940-
assert_different_registers(Rsize_of_parameters, Rsize_of_locals, parent_frame_resize, top_frame_size);
942+
assert_different_registers(Rsize_of_parameters, Rsize_of_locals, Rparent_frame_resize, Rtop_frame_size,
943+
Rconst_method, Rconst_pool);
941944

942945
__ ld(Rconst_method, method_(const));
943946
__ lhz(Rsize_of_parameters /* number of params */,
@@ -948,51 +951,51 @@ void TemplateInterpreterGenerator::generate_fixed_frame(bool native_call, Regist
948951
// We add two slots to the parameter_count, one for the jni
949952
// environment and one for a possible native mirror.
950953
Label skip_native_calculate_max_stack;
951-
__ addi(top_frame_size, Rsize_of_parameters, 2);
952-
__ cmpwi(CCR0, top_frame_size, Argument::n_register_parameters);
954+
__ addi(Rtop_frame_size, Rsize_of_parameters, 2);
955+
__ cmpwi(CCR0, Rtop_frame_size, Argument::n_register_parameters);
953956
__ bge(CCR0, skip_native_calculate_max_stack);
954-
__ li(top_frame_size, Argument::n_register_parameters);
957+
__ li(Rtop_frame_size, Argument::n_register_parameters);
955958
__ bind(skip_native_calculate_max_stack);
956959
__ sldi(Rsize_of_parameters, Rsize_of_parameters, Interpreter::logStackElementSize);
957-
__ sldi(top_frame_size, top_frame_size, Interpreter::logStackElementSize);
958-
__ sub(parent_frame_resize, R1_SP, R15_esp); // <0, off by Interpreter::stackElementSize!
960+
__ sldi(Rtop_frame_size, Rtop_frame_size, Interpreter::logStackElementSize);
961+
__ sub(Rparent_frame_resize, R1_SP, R15_esp); // <0, off by Interpreter::stackElementSize!
959962
assert(Rsize_of_locals == noreg, "Rsize_of_locals not initialized"); // Only relevant value is Rsize_of_parameters.
960963
} else {
961964
__ lhz(Rsize_of_locals /* number of params */, in_bytes(ConstMethod::size_of_locals_offset()), Rconst_method);
962965
__ sldi(Rsize_of_parameters, Rsize_of_parameters, Interpreter::logStackElementSize);
963966
__ sldi(Rsize_of_locals, Rsize_of_locals, Interpreter::logStackElementSize);
964-
__ lhz(top_frame_size, in_bytes(ConstMethod::max_stack_offset()), Rconst_method);
967+
__ lhz(Rtop_frame_size, in_bytes(ConstMethod::max_stack_offset()), Rconst_method);
965968
__ sub(R11_scratch1, Rsize_of_locals, Rsize_of_parameters); // >=0
966-
__ sub(parent_frame_resize, R1_SP, R15_esp); // <0, off by Interpreter::stackElementSize!
967-
__ sldi(top_frame_size, top_frame_size, Interpreter::logStackElementSize);
968-
__ add(parent_frame_resize, parent_frame_resize, R11_scratch1);
969+
__ sub(Rparent_frame_resize, R1_SP, R15_esp); // <0, off by Interpreter::stackElementSize!
970+
__ sldi(Rtop_frame_size, Rtop_frame_size, Interpreter::logStackElementSize);
971+
__ add(Rparent_frame_resize, Rparent_frame_resize, R11_scratch1);
969972
}
970973

971974
// Compute top frame size.
972-
__ addi(top_frame_size, top_frame_size, frame::abi_reg_args_size + frame::ijava_state_size);
975+
__ addi(Rtop_frame_size, Rtop_frame_size, frame::abi_reg_args_size + frame::ijava_state_size);
973976

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

977-
__ round_to(top_frame_size, frame::alignment_in_bytes);
978-
__ round_to(parent_frame_resize, frame::alignment_in_bytes);
979-
// parent_frame_resize = (locals-parameters) - (ESP-SP-ABI48) Rounded to frame alignment size.
980+
__ round_to(Rtop_frame_size, frame::alignment_in_bytes);
981+
__ round_to(Rparent_frame_resize, frame::alignment_in_bytes);
982+
// Rparent_frame_resize = (locals-parameters) - (ESP-SP-ABI48) Rounded to frame alignment size.
980983
// Enlarge by locals-parameters (not in case of native_call), shrink by ESP-SP-ABI48.
981984

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

991994
// Set up interpreter state registers.
992995

993996
__ add(R18_locals, R15_esp, Rsize_of_parameters);
994-
__ ld(R27_constPoolCache, in_bytes(ConstMethod::constants_offset()), Rconst_method);
995-
__ ld(R27_constPoolCache, ConstantPool::cache_offset_in_bytes(), R27_constPoolCache);
997+
__ ld(Rconst_pool, in_bytes(ConstMethod::constants_offset()), Rconst_method);
998+
__ ld(R27_constPoolCache, ConstantPool::cache_offset_in_bytes(), Rconst_pool);
996999

9971000
// Set method data pointer.
9981001
if (ProfileInterpreter) {
@@ -1012,19 +1015,21 @@ void TemplateInterpreterGenerator::generate_fixed_frame(bool native_call, Regist
10121015

10131016
// Resize parent frame.
10141017
__ mflr(R12_scratch2);
1015-
__ neg(parent_frame_resize, parent_frame_resize);
1016-
__ resize_frame(parent_frame_resize, R11_scratch1);
1018+
__ neg(Rparent_frame_resize, Rparent_frame_resize);
1019+
__ resize_frame(Rparent_frame_resize, R11_scratch1);
10171020
__ std(R12_scratch2, _abi0(lr), R1_SP);
10181021

10191022
// Get mirror and store it in the frame as GC root for this Method*.
1020-
__ load_mirror_from_const_method(R12_scratch2, Rconst_method);
1023+
__ ld(Rmirror, ConstantPool::pool_holder_offset_in_bytes(), Rconst_pool);
1024+
__ ld(Rmirror, in_bytes(Klass::java_mirror_offset()), Rmirror);
1025+
__ resolve_oop_handle(Rmirror, R11_scratch1, R12_scratch2, MacroAssembler::PRESERVATION_FRAME_LR_GP_REGS);
10211026

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

10251030
// Store values.
10261031
__ std(R19_method, _ijava_state_neg(method), R1_SP);
1027-
__ std(R12_scratch2, _ijava_state_neg(mirror), R1_SP);
1032+
__ std(Rmirror, _ijava_state_neg(mirror), R1_SP);
10281033
__ std(R18_locals, _ijava_state_neg(locals), R1_SP);
10291034
__ std(R27_constPoolCache, _ijava_state_neg(cpoolCache), R1_SP);
10301035

@@ -1046,12 +1051,12 @@ void TemplateInterpreterGenerator::generate_fixed_frame(bool native_call, Regist
10461051
__ std(R0, _ijava_state_neg(oop_tmp), R1_SP); // only used for native_call
10471052

10481053
// Store sender's SP and this frame's top SP.
1049-
__ subf(R12_scratch2, top_frame_size, R1_SP);
1054+
__ subf(R12_scratch2, Rtop_frame_size, R1_SP);
10501055
__ std(R21_sender_SP, _ijava_state_neg(sender_sp), R1_SP);
10511056
__ std(R12_scratch2, _ijava_state_neg(top_frame_sp), R1_SP);
10521057

10531058
// Push top frame.
1054-
__ push_frame(top_frame_size, R11_scratch1);
1059+
__ push_frame(Rtop_frame_size, R11_scratch1);
10551060
}
10561061

10571062
// End of helpers

‎src/hotspot/cpu/ppc/templateTable_ppc.hpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
#ifndef CPU_PPC_TEMPLATETABLE_PPC_HPP
2727
#define CPU_PPC_TEMPLATETABLE_PPC_HPP
2828

29-
static void prepare_invoke(int byte_no, Register Rmethod, Register Rret_addr, Register Rindex, Register Rrecv, Register Rflags, Register Rscratch);
29+
static void prepare_invoke(int byte_no, Register Rmethod, Register Rret_addr, Register Rindex, Register Rrecv, Register Rflags,
30+
Register Rscratch1, Register Rscratch2);
3031
static void invokevfinal_helper(Register Rmethod, Register Rflags, Register Rscratch1, Register Rscratch2);
3132
static void generate_vtable_call(Register Rrecv_klass, Register Rindex, Register Rret, Register Rtemp);
3233
static void invokeinterface_object_method(Register Rrecv_klass, Register Rret, Register Rflags, Register Rindex, Register Rtemp, Register Rtemp2);

0 commit comments

Comments
 (0)
Please sign in to comment.