# HG changeset patch # User aph # Date 1442333672 0 # Node ID 0096f1ef564e0457b220b56eeddd9ab5a10b4ac7 # Parent b2df86902f5e7ac07e7e1cf5fc76b1b75df78dcb Remove AArch64-specific code in generateOptoStub.cpp. In aarch64_enc_java_to_runtime leave a breadcrumb for JavaThread::pd_last_frame(). diff -r b2df86902f5e -r 0096f1ef564e src/cpu/aarch64/vm/aarch64.ad --- a/src/cpu/aarch64/vm/aarch64.ad Wed Dec 09 13:08:38 2015 +0000 +++ b/src/cpu/aarch64/vm/aarch64.ad Tue Sep 15 16:14:32 2015 +0000 @@ -2845,18 +2845,18 @@ int MachCallRuntimeNode::ret_addr_offset() { // for generated stubs the call will be - // far_call(addr) - // for real runtime callouts it iwll be - // mov(rscratch1, RuntimeAddress(addr) + // bl(addr) + // for real runtime callouts it will be six instructions + // see aarch64_enc_java_to_runtime + // adr(rscratch2, retaddr) + // lea(rscratch1, RuntimeAddress(addr) + // stp(zr, rscratch2, Address(__ pre(sp, -2 * wordSize))) // blrt rscratch1 CodeBlob *cb = CodeCache::find_blob(_entry_point); if (cb) { return MacroAssembler::far_branch_size(); } else { - // A 48-bit address. See movptr(). - // then a blrt - // return 16; - return 4 * NativeInstruction::instruction_size; + return 6 * NativeInstruction::instruction_size; } } @@ -4765,8 +4765,14 @@ int fpcnt; int rtype; getCallInfo(tf(), gpcnt, fpcnt, rtype); + Label retaddr; + __ adr(rscratch2, retaddr); __ lea(rscratch1, RuntimeAddress(entry)); + // Leave a breadcrumb for JavaThread::pd_last_frame(). + __ stp(zr, rscratch2, Address(__ pre(sp, -2 * wordSize))); __ blrt(rscratch1, gpcnt, fpcnt, rtype); + __ bind(retaddr); + __ add(sp, sp, 2 * wordSize); } %} @@ -7813,51 +7819,6 @@ ins_pipe(istore_mem); %} -// Save last Java PC to thread anchor - -// the ideal code cannot directly encode a reference to the current -// PC, never mind the PC of the return address which follows the -// runtime call whcih wil be generated at a later point. so this -// operation is encoded in the ideal code as a write of either -1 or -// -2 via the thread register with an offset which locates the last -// Java pc slot in the thread anchor. the encoding computes the -// correct Java pc to write by offsetting form the current pc to allwo -// for the intervening instructions which will precede the runtime -// call. Note that the constant is supplied as -2 when the stub caller -// return address is passed to the C function and -1 when no return -// address is required. we set the primary opcode to 1 or 0 -// accordingly as this affects the offset calculation. - -instruct storeLastJavaPC_no_retaddr(thread_anchor_pc mem, immP_M1 dummy_m1) -%{ - match(Set mem (StoreP mem dummy_m1)); - - ins_cost(INSN_COST); - format %{ "str ., $mem\t# save pc to thread (no ret addr)" %} - - // use opcode to indicate that we have no return address argument - opcode(0x0); - - ins_encode(aarch64_enc_save_pc()); - - ins_pipe(istore_mem); -%} - -instruct storeLastJavaPC_with_retaddr(thread_anchor_pc mem, immP_M2 dummy_m2) -%{ - match(Set mem (StoreP mem dummy_m2)); - - ins_cost(INSN_COST); - format %{ "str ., $mem\t# save pc to thread (w ret addr)" %} - - // use opcode to indicate that we have a return address argument - opcode(0x1); - - ins_encode(aarch64_enc_save_pc()); - - ins_pipe(istore_mem); -%} - // Store Compressed Pointer instruct storeN(iRegN src, memory mem) %{ diff -r b2df86902f5e -r 0096f1ef564e src/share/vm/opto/generateOptoStub.cpp --- a/src/share/vm/opto/generateOptoStub.cpp Wed Dec 09 13:08:38 2015 +0000 +++ b/src/share/vm/opto/generateOptoStub.cpp Tue Sep 15 16:14:32 2015 +0000 @@ -96,54 +96,6 @@ in_bytes(JavaFrameAnchor::flags_offset())); #endif /* defined(SPARC) */ -#if defined(AARCH64) - // the x86 code does not need to write return pc which follows the - // VM callout to the thread anchor pc slot. the frame walking code - // can safely compute that a called the stub's return pc by - // evaluating sp[-1] where sp is the top of the stub frame saved in - // the anchor sp field. AArch64 cannot make this assumption because - // the C compiler does not have to push the link register and, even - // if it does, can locate it somewhere other than at the bottom of - // the frame. - - // this poses a problem when we come to generate the opto runtime - // stubs. we cannot actually refer to generated code addresses in - // ideal code and, worse, we need to get the memory write to write a - // constant value derived form the code address of the instruction - // following the runtime callout i.e. the constant we need is only - // determined when we plant a separate instruction later in the - // instruction stream. - // - // rather than introduce a mechanism into the opto compiler to allow - // us to provide some sort of label and label resolve mechanism and - // then backpatch the required address we can actually do this with - // a minor hack. we generate a store to the anchor pc field but - // supply a small negative constant address (-1 or -2) as the value - // for the memory store. in the back end we detect this type of - // store and compute the desired address, substituting it in place - // of the supplied constant. - // - // the back end employs a special lowering rule to do this. it - // matches a write via the thread register with an offset which - // equals the thread anchor's pc slot. of course, those sort of - // writes only happen in these stubs! the encodign for this rule - // substitutes the supplied value with the current code buffer - // address plus an offset to the instruction following the VM - // callout. Of course, the offset varies according to what arguments - // are passed to the callout. For any given stub the arguments - // passed to the VM include the stub arguments, the thread and, - // optionally, the stub's caller's return pc. We supply -1 in the - // store if the call will not include the caller ret pc or -2 if it - // does. The back end can use this to work out exactly what the - // required offset is. - - const TypeRawPtr *t = TypeRawPtr::make((address)(return_pc ? -2L : -1L)); - - Node *last_pc = new (C) ConPNode(t); - _gvn.set_type(last_pc, t); - store_to_memory(NULL, adr_last_Java_pc, last_pc, T_ADDRESS, NoAlias, MemNode::unordered); - -#endif /* defined(AARCH64) */ // Drop in the last_Java_sp. last_Java_fp is not touched. // Always do this after the other "last_Java_frame" fields are set since