Skip to content

Commit 19360a9

Browse files
chadrakoSendaoYan
authored and
SendaoYan
committed
8356949: AArch64: Tighten up template interpreter method entry code
Reviewed-by: aph, shade
1 parent 061b24d commit 19360a9

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

src/hotspot/cpu/aarch64/templateInterpreterGenerator_aarch64.cpp

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -865,6 +865,10 @@ void TemplateInterpreterGenerator::lock_method() {
865865
// rcpool: cp cache
866866
// stack_pointer: previous sp
867867
void TemplateInterpreterGenerator::generate_fixed_frame(bool native_call) {
868+
// Save ConstMethod* in r5_const_method for later use to avoid loading multiple times
869+
Register r5_const_method = r5;
870+
__ ldr(r5_const_method, Address(rmethod, Method::const_offset()));
871+
868872
// initialize fixed part of activation frame
869873
if (native_call) {
870874
__ sub(esp, sp, 14 * wordSize);
@@ -875,8 +879,7 @@ void TemplateInterpreterGenerator::generate_fixed_frame(bool native_call) {
875879
__ stp(zr, zr, Address(sp, 12 * wordSize));
876880
} else {
877881
__ sub(esp, sp, 12 * wordSize);
878-
__ ldr(rscratch1, Address(rmethod, Method::const_offset())); // get ConstMethod
879-
__ add(rbcp, rscratch1, in_bytes(ConstMethod::codes_offset())); // get codebase
882+
__ add(rbcp, r5_const_method, in_bytes(ConstMethod::codes_offset())); // get codebase
880883
__ mov(rscratch1, frame::interpreter_frame_initial_sp_offset);
881884
__ stp(rscratch1, rbcp, Address(__ pre(sp, -12 * wordSize)));
882885
}
@@ -896,9 +899,10 @@ void TemplateInterpreterGenerator::generate_fixed_frame(bool native_call) {
896899
__ stp(rfp, lr, Address(sp, 10 * wordSize));
897900
__ lea(rfp, Address(sp, 10 * wordSize));
898901

899-
__ ldr(rcpool, Address(rmethod, Method::const_offset()));
900-
__ ldr(rcpool, Address(rcpool, ConstMethod::constants_offset()));
901-
__ ldr(rcpool, Address(rcpool, ConstantPool::cache_offset()));
902+
// Save ConstantPool* in r11_constants for later use to avoid loading multiple times
903+
Register r11_constants = r11;
904+
__ ldr(r11_constants, Address(r5_const_method, ConstMethod::constants_offset()));
905+
__ ldr(rcpool, Address(r11_constants, ConstantPool::cache_offset()));
902906
__ sub(rscratch1, rlocals, rfp);
903907
__ lsr(rscratch1, rscratch1, Interpreter::logStackElementSize); // rscratch1 = rlocals - fp();
904908
// Store relativized rlocals, see frame::interpreter_frame_locals().
@@ -908,11 +912,12 @@ void TemplateInterpreterGenerator::generate_fixed_frame(bool native_call) {
908912
// leave last_sp as null
909913
__ stp(zr, r19_sender_sp, Address(sp, 8 * wordSize));
910914

911-
// Get mirror
912-
__ load_mirror(r10, rmethod, r5, rscratch2);
915+
// Get mirror. Resolve ConstantPool* -> InstanceKlass* -> Java mirror.
916+
__ ldr(r10, Address(r11_constants, ConstantPool::pool_holder_offset()));
917+
__ ldr(r10, Address(r10, in_bytes(Klass::java_mirror_offset())));
918+
__ resolve_oop_handle(r10, rscratch1, rscratch2);
913919
if (! native_call) {
914-
__ ldr(rscratch1, Address(rmethod, Method::const_offset()));
915-
__ ldrh(rscratch1, Address(rscratch1, ConstMethod::max_stack_offset()));
920+
__ ldrh(rscratch1, Address(r5_const_method, ConstMethod::max_stack_offset()));
916921
__ add(rscratch1, rscratch1, MAX2(3, Method::extra_stack_entries()));
917922
__ sub(rscratch1, sp, rscratch1, ext::uxtw, 3);
918923
__ andr(rscratch1, rscratch1, -16);

0 commit comments

Comments
 (0)