Skip to content

Commit 22f630c

Browse files
committed
8352415: x86: Tighten up template interpreter method entry code
Reviewed-by: adinn, jsjolen
1 parent 6fbaa06 commit 22f630c

File tree

1 file changed

+26
-16
lines changed

1 file changed

+26
-16
lines changed

src/hotspot/cpu/x86/templateInterpreterGenerator_x86.cpp

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -561,40 +561,50 @@ void TemplateInterpreterGenerator::lock_method() {
561561
// rdx: cp cache
562562
void TemplateInterpreterGenerator::generate_fixed_frame(bool native_call) {
563563
// initialize fixed part of activation frame
564-
__ push(rax); // save return address
565-
__ enter(); // save old & set new rbp
564+
__ push(rax); // save return address
565+
__ enter(); // save old & set new rbp
566566
__ push(rbcp); // set sender sp
567-
__ push(NULL_WORD); // leave last_sp as null
568-
__ movptr(rbcp, Address(rbx, Method::const_offset())); // get ConstMethod*
569-
__ lea(rbcp, Address(rbcp, ConstMethod::codes_offset())); // get codebase
567+
568+
// Resolve ConstMethod* -> ConstantPool*.
569+
// Get codebase, while we still have ConstMethod*.
570+
// Save ConstantPool* in rax for later use.
571+
__ movptr(rax, Address(rbx, Method::const_offset()));
572+
__ lea(rbcp, Address(rax, ConstMethod::codes_offset()));
573+
__ movptr(rax, Address(rax, ConstMethod::constants_offset()));
574+
575+
__ push(NULL_WORD); // leave last_sp as null
570576
__ push(rbx); // save Method*
571-
// Get mirror and store it in the frame as GC root for this Method*
572-
__ load_mirror(rdx, rbx, rscratch2);
577+
578+
// Get mirror and store it in the frame as GC root for this Method*.
579+
// rax is still ConstantPool*, resolve ConstantPool* -> InstanceKlass* -> Java mirror.
580+
__ movptr(rdx, Address(rax, ConstantPool::pool_holder_offset()));
581+
__ movptr(rdx, Address(rdx, in_bytes(Klass::java_mirror_offset())));
582+
__ resolve_oop_handle(rdx, rscratch2);
573583
__ push(rdx);
584+
574585
if (ProfileInterpreter) {
575586
Label method_data_continue;
576587
__ movptr(rdx, Address(rbx, in_bytes(Method::method_data_offset())));
577588
__ testptr(rdx, rdx);
578-
__ jcc(Assembler::zero, method_data_continue);
589+
__ jccb(Assembler::zero, method_data_continue);
579590
__ addptr(rdx, in_bytes(MethodData::data_offset()));
580591
__ bind(method_data_continue);
581592
__ push(rdx); // set the mdp (method data pointer)
582593
} else {
583-
__ push(0);
594+
__ push(NULL_WORD);
584595
}
585596

586-
__ movptr(rdx, Address(rbx, Method::const_offset()));
587-
__ movptr(rdx, Address(rdx, ConstMethod::constants_offset()));
588-
__ movptr(rdx, Address(rdx, ConstantPool::cache_offset()));
589-
__ push(rdx); // set constant pool cache
597+
// rax is still ConstantPool*, set the constant pool cache
598+
__ movptr(rdx, Address(rax, ConstantPool::cache_offset()));
599+
__ push(rdx);
590600

591601
__ movptr(rax, rlocals);
592602
__ subptr(rax, rbp);
593603
__ shrptr(rax, Interpreter::logStackElementSize); // rax = rlocals - fp();
594604
__ push(rax); // set relativized rlocals, see frame::interpreter_frame_locals()
595605

596606
if (native_call) {
597-
__ push(0); // no bcp
607+
__ push(NULL_WORD); // no bcp
598608
} else {
599609
__ push(rbcp); // set bcp
600610
}
@@ -1242,11 +1252,11 @@ address TemplateInterpreterGenerator::generate_normal_entry(bool synchronized) {
12421252
{
12431253
Label exit, loop;
12441254
__ testl(rdx, rdx);
1245-
__ jcc(Assembler::lessEqual, exit); // do nothing if rdx <= 0
1255+
__ jccb(Assembler::lessEqual, exit); // do nothing if rdx <= 0
12461256
__ bind(loop);
12471257
__ push(NULL_WORD); // initialize local variables
12481258
__ decrementl(rdx); // until everything initialized
1249-
__ jcc(Assembler::greater, loop);
1259+
__ jccb(Assembler::greater, loop);
12501260
__ bind(exit);
12511261
}
12521262

0 commit comments

Comments
 (0)