/* * Copyright (c) 2008, 2022, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. *
*/
// Note: Rtemp usage is this file should not impact C2 and should be // correct as long as it is not implicitly used in lower layers (the // arm [macro]assembler) and used with care in the other C1 specific // files.
// Implementation of StubAssembler
int StubAssembler::call_RT(Register oop_result1, Register metadata_result, address entry, int args_size) {
mov(R0, Rthread);
int call_offset = set_last_Java_frame(SP, FP, false, Rtemp);
call(entry); if (call_offset == -1) { // PC not saved
call_offset = offset();
}
reset_last_Java_frame(Rtemp);
assert(frame_size() != no_frame_size, "frame must be fixed"); if (_stub_id != Runtime1::forward_exception_id) {
ldr(R3, Address(Rthread, Thread::pending_exception_offset()));
}
if (oop_result1->is_valid()) {
assert_different_registers(oop_result1, R3, Rtemp);
get_vm_result(oop_result1, Rtemp);
} if (metadata_result->is_valid()) {
assert_different_registers(metadata_result, R3, Rtemp);
get_vm_result_2(metadata_result, Rtemp);
}
// Check for pending exception // unpack_with_exception_in_tls path is taken through // Runtime1::exception_handler_for_pc if (_stub_id != Runtime1::forward_exception_id) {
assert(frame_size() != no_frame_size, "cannot directly call forward_exception_id");
cmp(R3, 0);
jump(Runtime1::entry_for(Runtime1::forward_exception_id), relocInfo::runtime_call_type, Rtemp, ne);
} else { #ifdef ASSERT // Should not have pending exception in forward_exception stub
ldr(R3, Address(Rthread, Thread::pending_exception_offset()));
cmp(R3, 0);
breakpoint(ne); #endif// ASSERT
} return call_offset;
}
static OopMap* generate_oop_map(StubAssembler* sasm, bool save_fpu_registers = HaveVFP) {
sasm->set_frame_size(reg_save_size /* in words */);
// Record saved value locations in an OopMap. // Locations are offsets from sp after runtime call.
OopMap* map = new OopMap(VMRegImpl::slots_per_word * reg_save_size, 0);
int j=0; for (int i = R0_offset; i < R10_offset; i++) { if (j == FP_REG_NUM) { // skip the FP register, saved below
j++;
}
map->set_callee_saved(VMRegImpl::stack2reg(i), as_Register(j)->as_VMReg());
j++;
}
assert(j == R10->encoding(), "must be"); #if (FP_REG_NUM != 11) // add R11, if not saved as FP
map->set_callee_saved(VMRegImpl::stack2reg(R11_offset), R11->as_VMReg()); #endif
map->set_callee_saved(VMRegImpl::stack2reg(FP_offset), FP->as_VMReg());
map->set_callee_saved(VMRegImpl::stack2reg(LR_offset), LR->as_VMReg());
if (save_fpu_registers) { for (int i = 0; i < fpu_save_size; i++) {
map->set_callee_saved(VMRegImpl::stack2reg(i), as_FloatRegister(i)->as_VMReg());
}
}
return map;
}
static OopMap* save_live_registers(StubAssembler* sasm, bool save_fpu_registers = HaveVFP) {
__ block_comment("save_live_registers");
sasm->set_frame_size(reg_save_size /* in words */);
OopMapSet* oop_maps = new OopMapSet();
oop_maps->add_gc_map(call_offset, oop_map);
DEBUG_ONLY(STOP("generate_exception_throw");) // Should not reach here return oop_maps;
}
staticvoid restore_sp_for_method_handle(StubAssembler* sasm) { // Restore SP from its saved reg (FP) if the exception PC is a MethodHandle call site.
__ ldr_s32(Rtemp, Address(Rthread, JavaThread::is_method_handle_return_offset()));
__ cmp(Rtemp, 0);
__ mov(SP, Rmh_SP_save, ne);
}
// Save registers, if required.
OopMapSet* oop_maps = new OopMapSet();
OopMap* oop_map = NULL;
switch (id) { case forward_exception_id: {
save_fpu_registers = HaveVFP;
oop_map = generate_oop_map(sasm);
__ ldr(Rexception_obj, Address(Rthread, Thread::pending_exception_offset()));
__ ldr(Rexception_pc, Address(SP, LR_offset * wordSize)); Register zero = __ zero_register(Rtemp);
__ str(zero, Address(Rthread, Thread::pending_exception_offset())); break;
} case handle_exception_id:
save_fpu_registers = HaveVFP; // fall-through case handle_exception_nofpu_id: // At this point all registers MAY be live.
oop_map = save_live_registers(sasm, save_fpu_registers); break; case handle_exception_from_callee_id: // At this point all registers except exception oop (R4/R19) and // exception pc (R5/R20) are dead.
oop_map = save_live_registers(sasm); // TODO it's not required to save all registers break; default: ShouldNotReachHere();
}
__ str(Rexception_pc, Address(SP, LR_offset * wordSize)); // patch throwing pc into return address
int call_offset = __ call_RT(noreg, noreg, CAST_FROM_FN_PTR(address, exception_handler_for_pc));
oop_maps->add_gc_map(call_offset, oop_map);
// Exception handler found
__ str(R0, Address(SP, LR_offset * wordSize)); // patch the return address
// Restore the registers that were saved at the beginning, remove // frame and jump to the exception handler. switch (id) { case forward_exception_id: case handle_exception_nofpu_id: case handle_exception_id:
restore_live_registers(sasm, save_fpu_registers); // Note: the restore live registers includes the jump to LR (patched to R0) break; case handle_exception_from_callee_id:
restore_live_registers_without_return(sasm); // must not jump immediately to handler
restore_sp_for_method_handle(sasm);
__ ret(); break; default: ShouldNotReachHere();
}
DEBUG_ONLY(STOP("generate_handle_exception");) // Should not reach here
return oop_maps;
}
void Runtime1::generate_unwind_exception(StubAssembler* sasm) { // FP no longer used to find the frame start // on entry, remove_frame() has already been called (restoring FP and LR)
// search the exception handler address of the caller (using the return address)
__ mov(c_rarg0, Rthread);
__ mov(Rexception_pc, LR);
__ mov(c_rarg1, LR);
__ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::exception_handler_for_return_address), c_rarg0, c_rarg1);
// Exception oop should be still in Rexception_obj and pc in Rexception_pc // Jump to handler
__ verify_not_null_oop(Rexception_obj);
// Deoptimization needed // TODO: ARM - no need to restore FP & LR because unpack_with_reexecution() stores them back
__ pop(RegisterSet(FP) | RegisterSet(LR));
case new_type_array_id: case new_object_array_id:
{ if (id == new_type_array_id) {
__ set_info("new_type_array", dont_gc_arguments);
} else {
__ set_info("new_object_array", dont_gc_arguments);
}
constRegister result = R0; constRegister klass = R1; constRegister length = R2;
OopMap* map = save_live_registers(sasm); int call_offset; if (id == new_type_array_id) {
call_offset = __ call_RT(result, noreg, CAST_FROM_FN_PTR(address, new_type_array), klass, length);
} else {
call_offset = __ call_RT(result, noreg, CAST_FROM_FN_PTR(address, new_object_array), klass, length);
}
oop_maps = new OopMapSet();
oop_maps->add_gc_map(call_offset, map);
// MacroAssembler::StoreStore useless (included in the runtime exit path)
restore_live_registers_except_R0(sasm);
} break;
case new_multi_array_id:
{
__ set_info("new_multi_array", dont_gc_arguments);
// R0: klass // R2: rank // SP: address of 1st dimension constRegister result = R0;
OopMap* map = save_live_registers(sasm);
oop_maps = new OopMapSet();
oop_maps->add_gc_map(call_offset, map);
// MacroAssembler::StoreStore useless (included in the runtime exit path)
restore_live_registers_except_R0(sasm);
} break;
case register_finalizer_id:
{
__ set_info("register_finalizer", dont_gc_arguments);
// Do not call runtime if JVM_ACC_HAS_FINALIZER flag is not set
__ load_klass(Rtemp, R0);
__ ldr_u32(Rtemp, Address(Rtemp, Klass::access_flags_offset()));
// We get here if an equal cache entry is found
__ str(R1, Address(R0, Klass::secondary_super_cache_offset()));
__ mov(R0, 1);
__ raw_pop_and_ret(R2, R3);
// A cache entry not found - return false
__ bind(miss);
__ mov(R0, 0);
__ raw_pop_and_ret(R2, R3);
} break;
case monitorenter_nofpu_id:
save_fpu_registers = false; // fall through case monitorenter_id:
{
__ set_info("monitorenter", dont_gc_arguments); constRegister obj = R1; constRegister lock = R2;
OopMap* map = save_live_registers(sasm, save_fpu_registers);
__ ldr(obj, Address(SP, arg1_offset));
__ ldr(lock, Address(SP, arg2_offset)); int call_offset = __ call_RT(noreg, noreg, CAST_FROM_FN_PTR(address, monitorenter), obj, lock);
oop_maps = new OopMapSet();
oop_maps->add_gc_map(call_offset, map);
restore_live_registers(sasm, save_fpu_registers);
} break;
case monitorexit_nofpu_id:
save_fpu_registers = false; // fall through case monitorexit_id:
{
__ set_info("monitorexit", dont_gc_arguments); constRegister lock = R1;
OopMap* map = save_live_registers(sasm, save_fpu_registers);
__ ldr(lock, Address(SP, arg1_offset)); int call_offset = __ call_RT(noreg, noreg, CAST_FROM_FN_PTR(address, monitorexit), lock);
oop_maps = new OopMapSet();
oop_maps->add_gc_map(call_offset, map);
restore_live_registers(sasm, save_fpu_registers);
} break;
case deoptimize_id:
{
__ set_info("deoptimize", dont_gc_arguments);
OopMap* oop_map = save_live_registers(sasm); constRegister trap_request = R1;
__ ldr(trap_request, Address(SP, arg1_offset)); int call_offset = __ call_RT(noreg, noreg, CAST_FROM_FN_PTR(address, deoptimize), trap_request);
oop_maps = new OopMapSet();
oop_maps->add_gc_map(call_offset, oop_map);
restore_live_registers_without_return(sasm);
DeoptimizationBlob* deopt_blob = SharedRuntime::deopt_blob();
assert(deopt_blob != NULL, "deoptimization blob must have been created");
__ jump(deopt_blob->unpack_with_reexecution(), relocInfo::runtime_call_type, noreg);
} break;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.