/* * 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.
bool LIR_Assembler::is_small_constant(LIR_Opr opr) {
ShouldNotCallThis(); // Not used on ARM returnfalse;
}
LIR_Opr LIR_Assembler::receiverOpr() { // The first register in Java calling conventions return FrameMap::R0_oop_opr;
}
assert(frame::interpreter_frame_monitor_size() == BasicObjectLock::size(), "adjust code below"); int monitor_offset = (method()->max_locals() + 2 * (number_of_locks - 1)) * BytesPerWord; for (int i = 0; i < number_of_locks; i++) { int slot_offset = monitor_offset - (i * 2 * BytesPerWord);
__ ldr(R1, Address(OSR_buf, slot_offset + 0*BytesPerWord));
__ ldr(R2, Address(OSR_buf, slot_offset + 1*BytesPerWord));
__ str(R1, frame_map()->address_for_monitor_lock(i));
__ str(R2, frame_map()->address_for_monitor_object(i));
}
}
int LIR_Assembler::check_icache() { Register receiver = LIR_Assembler::receiverOpr()->as_register(); int offset = __ offset();
__ inline_cache_check(receiver, Ricklass); return offset;
}
void LIR_Assembler::clinit_barrier(ciMethod* method) {
ShouldNotReachHere(); // not implemented
}
void LIR_Assembler::jobject2reg_with_patching(Register reg, CodeEmitInfo* info) {
jobject o = (jobject)Universe::non_oop_word(); int index = __ oop_recorder()->allocate_oop_index(o);
PatchingStub* patch = new PatchingStub(_masm, patching_id(info), index);
__ patchable_mov_oop(reg, o, index);
patching_epilog(patch, lir_patch_normal, reg, info);
}
void LIR_Assembler::klass2reg_with_patching(Register reg, CodeEmitInfo* info) {
Metadata* o = (Metadata*)Universe::non_oop_word(); int index = __ oop_recorder()->allocate_metadata_index(o);
PatchingStub* patch = new PatchingStub(_masm, PatchingStub::load_klass_id, index);
__ patchable_mov_metadata(reg, o, index);
patching_epilog(patch, lir_patch_normal, reg, info);
}
int LIR_Assembler::initial_frame_size_in_bytes() const { // Subtracts two words to account for return address and link return frame_map()->framesize()*VMRegImpl::stack_slot_size - 2*wordSize;
}
int LIR_Assembler::emit_exception_handler() {
address handler_base = __ start_a_stub(exception_handler_size()); if (handler_base == NULL) {
bailout("exception handler overflow"); return -1;
}
int offset = code_offset();
// check that there is really an exception
__ verify_not_null_oop(Rexception_obj);
// Emit the code to remove the frame from the stack in the exception // unwind path. int LIR_Assembler::emit_unwind_handler() { #ifndef PRODUCT if (CommentedAssembly) {
_masm->block_comment("Unwind handler");
} #endif
int offset = code_offset();
// Fetch the exception from TLS and clear out exception related thread state Register zero = __ zero_register(Rtemp);
__ ldr(Rexception_obj, Address(Rthread, JavaThread::exception_oop_offset()));
__ str(zero, Address(Rthread, JavaThread::exception_oop_offset()));
__ str(zero, Address(Rthread, JavaThread::exception_pc_offset()));
// remove the activation and dispatch to the unwind handler
__ remove_frame(initial_frame_size_in_bytes()); // restores FP and LR
__ jump(Runtime1::entry_for(Runtime1::unwind_exception_id), relocInfo::runtime_call_type, Rtemp);
// Emit the slow path assembly if (stub != NULL) {
stub->emit_code(this);
}
return offset;
}
int LIR_Assembler::emit_deopt_handler() {
address handler_base = __ start_a_stub(deopt_handler_size()); if (handler_base == NULL) {
bailout("deopt handler overflow"); return -1;
}
int offset = code_offset();
__ mov_relative_address(LR, __ pc());
__ push(LR); // stub expects LR to be saved
__ jump(SharedRuntime::deopt_blob()->unpack(), relocInfo::runtime_call_type, noreg);
void LIR_Assembler::return_op(LIR_Opr result, C1SafepointPollStub* code_stub) { // Pop the frame before safepoint polling
__ remove_frame(initial_frame_size_in_bytes());
__ read_polling_page(Rtemp, relocInfo::poll_return_type);
__ ret();
}
int LIR_Assembler::safepoint_poll(LIR_Opr tmp, CodeEmitInfo* info) {
int offset = __ offset();
__ get_polling_page(Rtemp);
__ relocate(relocInfo::poll_type);
add_debug_info_for_branch(info); // help pc_desc_at to find correct scope for current PC
__ ldr(Rtemp, Address(Rtemp));
switch (c->type()) { case T_INT: // fall through case T_FLOAT:
__ mov_slow(Rtemp, c->as_jint_bits());
__ str_32(Rtemp, frame_map()->address_for_slot(dest->single_stack_ix())); break;
case T_ADDRESS:
__ mov_slow(Rtemp, c->as_jint());
__ str(Rtemp, frame_map()->address_for_slot(dest->single_stack_ix())); break;
case T_OBJECT:
__ mov_oop(Rtemp, c->as_jobject());
__ str(Rtemp, frame_map()->address_for_slot(dest->single_stack_ix())); break;
case T_LONG: // fall through case T_DOUBLE:
__ mov_slow(Rtemp, c->as_jint_lo_bits());
__ str(Rtemp, frame_map()->address_for_slot(dest->double_stack_ix(), lo_word_offset_in_bytes)); if (c->as_jint_hi_bits() != c->as_jint_lo_bits()) {
__ mov_slow(Rtemp, c->as_jint_hi_bits());
}
__ str(Rtemp, frame_map()->address_for_slot(dest->double_stack_ix(), hi_word_offset_in_bytes)); break;
PatchingStub* patch = NULL; if (needs_patching) {
patch = new PatchingStub(_masm, PatchingStub::access_field_id);
}
int null_check_offset = code_offset();
switch (type) { case T_ARRAY: case T_OBJECT: if (UseCompressedOops && !wide) {
ShouldNotReachHere();
} else {
__ str(src->as_register(), as_Address(to_addr));
} break;
case T_ADDRESS:
__ str(src->as_pointer_register(), as_Address(to_addr)); break;
case T_BYTE: case T_BOOLEAN:
__ strb(src->as_register(), as_Address(to_addr)); break;
case T_CHAR: case T_SHORT:
__ strh(src->as_register(), as_Address(to_addr)); break;
case T_INT: #ifdef __SOFTFP__ case T_FLOAT: #endif// __SOFTFP__
__ str_32(src->as_register(), as_Address(to_addr)); break;
#ifdef __SOFTFP__ case T_DOUBLE: #endif// __SOFTFP__ case T_LONG: { Register from_lo = src->as_register_lo(); Register from_hi = src->as_register_hi(); if (to_addr->index()->is_register()) {
assert(to_addr->scale() == LIR_Address::times_1,"Unexpected scaled register");
assert(to_addr->disp() == 0, "Not yet supporting both");
__ add(Rtemp, base_reg, to_addr->index()->as_register());
base_reg = Rtemp;
__ str(from_lo, Address(Rtemp)); if (patch != NULL) {
__ nop(); // see comment before patching_epilog for 2nd str
patching_epilog(patch, lir_patch_low, base_reg, info);
patch = new PatchingStub(_masm, PatchingStub::access_field_id);
patch_code = lir_patch_high;
}
__ str(from_hi, Address(Rtemp, BytesPerWord));
} elseif (base_reg == from_lo) {
__ str(from_hi, as_Address_hi(to_addr)); if (patch != NULL) {
__ nop(); // see comment before patching_epilog for 2nd str
patching_epilog(patch, lir_patch_high, base_reg, info);
patch = new PatchingStub(_masm, PatchingStub::access_field_id);
patch_code = lir_patch_low;
}
__ str(from_lo, as_Address_lo(to_addr));
} else {
__ str(from_lo, as_Address_lo(to_addr)); if (patch != NULL) {
__ nop(); // see comment before patching_epilog for 2nd str
patching_epilog(patch, lir_patch_low, base_reg, info);
patch = new PatchingStub(_masm, PatchingStub::access_field_id);
patch_code = lir_patch_high;
}
__ str(from_hi, as_Address_hi(to_addr));
} break;
}
#ifndef __SOFTFP__ case T_FLOAT: if (to_addr->index()->is_register()) {
assert(to_addr->scale() == LIR_Address::times_1,"Unexpected scaled register");
__ add(Rtemp, base_reg, to_addr->index()->as_register()); if ((to_addr->disp() <= -4096) || (to_addr->disp() >= 4096)) { BAILOUT("offset not in range"); }
__ fsts(src->as_float_reg(), Address(Rtemp, to_addr->disp()));
} else {
__ fsts(src->as_float_reg(), as_Address(to_addr));
} break;
case T_DOUBLE: if (to_addr->index()->is_register()) {
assert(to_addr->scale() == LIR_Address::times_1,"Unexpected scaled register");
__ add(Rtemp, base_reg, to_addr->index()->as_register()); if ((to_addr->disp() <= -4096) || (to_addr->disp() >= 4096)) { BAILOUT("offset not in range"); }
__ fstd(src->as_double_reg(), Address(Rtemp, to_addr->disp()));
} else {
__ fstd(src->as_double_reg(), as_Address(to_addr));
} break; #endif// __SOFTFP__
default:
ShouldNotReachHere();
}
if (info != NULL) {
add_debug_info_for_null_check(null_check_offset, info);
}
if (patch != NULL) { // Offset embedded into LDR/STR instruction may appear not enough // to address a field. So, provide a space for one more instruction // that will deal with larger offsets.
__ nop();
patching_epilog(patch, patch_code, base_reg, info);
}
}
void LIR_Assembler::stack2reg(LIR_Opr src, LIR_Opr dest, BasicType type) {
assert(src->is_stack(), "should not call otherwise");
assert(dest->is_register(), "should not call otherwise");
PatchingStub* patch = NULL; if (patch_code != lir_patch_none) {
patch = new PatchingStub(_masm, PatchingStub::access_field_id);
} if (info != NULL) {
add_debug_info_for_null_check_here(info);
}
switch (type) { case T_OBJECT: // fall through case T_ARRAY: if (UseCompressedOops && !wide) {
__ ldr_u32(dest->as_register(), as_Address(addr));
} else {
__ ldr(dest->as_register(), as_Address(addr));
} break;
case T_ADDRESS:
__ ldr(dest->as_pointer_register(), as_Address(addr)); break;
case T_INT: #ifdef __SOFTFP__ case T_FLOAT: #endif// __SOFTFP__
__ ldr(dest->as_pointer_register(), as_Address(addr)); break;
case T_BOOLEAN:
__ ldrb(dest->as_register(), as_Address(addr)); break;
case T_BYTE:
__ ldrsb(dest->as_register(), as_Address(addr)); break;
case T_CHAR:
__ ldrh(dest->as_register(), as_Address(addr)); break;
case T_SHORT:
__ ldrsh(dest->as_register(), as_Address(addr)); break;
#ifdef __SOFTFP__ case T_DOUBLE: #endif// __SOFTFP__ case T_LONG: { Register to_lo = dest->as_register_lo(); Register to_hi = dest->as_register_hi(); if (addr->index()->is_register()) {
assert(addr->scale() == LIR_Address::times_1,"Unexpected scaled register");
assert(addr->disp() == 0, "Not yet supporting both");
__ add(Rtemp, base_reg, addr->index()->as_register());
base_reg = Rtemp;
__ ldr(to_lo, Address(Rtemp)); if (patch != NULL) {
__ nop(); // see comment before patching_epilog for 2nd ldr
patching_epilog(patch, lir_patch_low, base_reg, info);
patch = new PatchingStub(_masm, PatchingStub::access_field_id);
patch_code = lir_patch_high;
}
__ ldr(to_hi, Address(Rtemp, BytesPerWord));
} elseif (base_reg == to_lo) {
__ ldr(to_hi, as_Address_hi(addr)); if (patch != NULL) {
__ nop(); // see comment before patching_epilog for 2nd ldr
patching_epilog(patch, lir_patch_high, base_reg, info);
patch = new PatchingStub(_masm, PatchingStub::access_field_id);
patch_code = lir_patch_low;
}
__ ldr(to_lo, as_Address_lo(addr));
} else {
__ ldr(to_lo, as_Address_lo(addr)); if (patch != NULL) {
__ nop(); // see comment before patching_epilog for 2nd ldr
patching_epilog(patch, lir_patch_low, base_reg, info);
patch = new PatchingStub(_masm, PatchingStub::access_field_id);
patch_code = lir_patch_high;
}
__ ldr(to_hi, as_Address_hi(addr));
} break;
}
#ifndef __SOFTFP__ case T_FLOAT: if (addr->index()->is_register()) {
assert(addr->scale() == LIR_Address::times_1,"Unexpected scaled register");
__ add(Rtemp, base_reg, addr->index()->as_register()); if ((addr->disp() <= -4096) || (addr->disp() >= 4096)) { BAILOUT("offset not in range"); }
__ flds(dest->as_float_reg(), Address(Rtemp, addr->disp()));
} else {
__ flds(dest->as_float_reg(), as_Address(addr));
} break;
case T_DOUBLE: if (addr->index()->is_register()) {
assert(addr->scale() == LIR_Address::times_1,"Unexpected scaled register");
__ add(Rtemp, base_reg, addr->index()->as_register()); if ((addr->disp() <= -4096) || (addr->disp() >= 4096)) { BAILOUT("offset not in range"); }
__ fldd(dest->as_double_reg(), Address(Rtemp, addr->disp()));
} else {
__ fldd(dest->as_double_reg(), as_Address(addr));
} break; #endif// __SOFTFP__
default:
ShouldNotReachHere();
}
if (patch != NULL) { // Offset embedded into LDR/STR instruction may appear not enough // to address a field. So, provide a space for one more instruction // that will deal with larger offsets.
__ nop();
patching_epilog(patch, patch_code, base_reg, info);
}
if (op->code() == lir_idiv && op->in_opr2()->is_constant() && is_32) { int c = op->in_opr2()->as_constant_ptr()->as_jint();
assert(is_power_of_2(c), "non power-of-2 constant should be put in a register");
Register left = op->in_opr1()->as_register(); Register dest = op->result_opr()->as_register(); if (c == 1) {
__ mov(dest, left);
} elseif (c == 2) {
__ add_32(dest, left, AsmOperand(left, lsr, 31));
__ asr_32(dest, dest, 1);
} elseif (c != (int) 0x80000000) { int power = log2i_exact(c);
__ asr_32(Rtemp, left, 31);
__ add_32(dest, left, AsmOperand(Rtemp, lsr, 32-power)); // dest = left + (left < 0 ? 2^power - 1 : 0);
__ asr_32(dest, dest, power); // dest = dest >>> power;
} else { // x/0x80000000 is a special case, since dividend is a power of two, but is negative. // The only possible result values are 0 and 1, with 1 only for dividend == divisor == 0x80000000.
__ cmp_32(left, c);
__ mov(dest, 0, ne);
__ mov(dest, 1, eq);
}
} else {
assert(op->code() == lir_idiv || op->code() == lir_irem, "unexpected op3");
__ call(StubRoutines::Arm::idiv_irem_entry(), relocInfo::runtime_call_type);
add_debug_info_for_div0_here(op->info());
}
}
void LIR_Assembler::type_profile_helper(Register mdo, int mdo_offset_bias,
ciMethodData *md, ciProfileData *data, Register recv, Register tmp1, Label* update_done) {
assert_different_registers(mdo, recv, tmp1);
uint i; for (i = 0; i < VirtualCallData::row_limit(); i++) {
Label next_test; // See if the receiver is receiver[n].
Address receiver_addr(mdo, md->byte_offset_of_slot(data, ReceiverTypeData::receiver_offset(i)) -
mdo_offset_bias);
__ ldr(tmp1, receiver_addr);
__ verify_klass_ptr(tmp1);
__ cmp(recv, tmp1);
__ b(next_test, ne);
Address data_addr(mdo, md->byte_offset_of_slot(data, ReceiverTypeData::receiver_count_offset(i)) -
mdo_offset_bias);
__ ldr(tmp1, data_addr);
__ add(tmp1, tmp1, DataLayout::counter_increment);
__ str(tmp1, data_addr);
__ b(*update_done);
__ bind(next_test);
}
// Didn't find receiver; find next empty slot and fill it in for (i = 0; i < VirtualCallData::row_limit(); i++) {
Label next_test;
Address recv_addr(mdo, md->byte_offset_of_slot(data, ReceiverTypeData::receiver_offset(i)) -
mdo_offset_bias);
__ ldr(tmp1, recv_addr);
__ cbnz(tmp1, next_test);
__ str(recv, recv_addr);
__ mov(tmp1, DataLayout::counter_increment);
__ str(tmp1, Address(mdo, md->byte_offset_of_slot(data, ReceiverTypeData::receiver_count_offset(i)) -
mdo_offset_bias));
__ b(*update_done);
__ bind(next_test);
}
}
void LIR_Assembler::setup_md_access(ciMethod* method, int bci,
ciMethodData*& md, ciProfileData*& data, int& mdo_offset_bias) {
md = method->method_data_or_null();
assert(md != NULL, "Sanity");
data = md->bci_to_data(bci);
assert(data != NULL, "need data for checkcast");
assert(data->is_ReceiverTypeData(), "need ReceiverTypeData for type check"); if (md->byte_offset_of_slot(data, DataLayout::header_offset()) + data->size_in_bytes() >= 4096) { // The offset is large so bias the mdo by the base of the slot so // that the ldr can use an immediate offset to reference the slots of the data
mdo_offset_bias = md->byte_offset_of_slot(data, DataLayout::header_offset());
}
}
// On 32-bit ARM, code before this helper should test obj for null (ZF should be set if obj is null). void LIR_Assembler::typecheck_profile_helper1(ciMethod* method, int bci,
ciMethodData*& md, ciProfileData*& data, int& mdo_offset_bias, Register obj, Register mdo, Register data_val, Label* obj_is_null) {
assert(method != NULL, "Should have method");
assert_different_registers(obj, mdo, data_val);
setup_md_access(method, bci, md, data, mdo_offset_bias);
Label not_null;
__ b(not_null, ne);
__ mov_metadata(mdo, md->constant_encoding()); if (mdo_offset_bias > 0) {
__ mov_slow(data_val, mdo_offset_bias);
__ add(mdo, mdo, data_val);
}
Address flags_addr(mdo, md->byte_offset_of_slot(data, DataLayout::flags_offset()) - mdo_offset_bias);
__ ldrb(data_val, flags_addr);
__ orr(data_val, data_val, (uint)BitData::null_seen_byte_constant());
__ strb(data_val, flags_addr);
__ b(*obj_is_null);
__ bind(not_null);
}
if (stub->is_simple_exception_stub()) { // TODO: ARM - Late binding is used to prevent confusion of register allocator
assert(stub->is_exception_throw_stub(), "must be");
((SimpleExceptionStub*)stub)->set_obj(op->result_opr());
}
ciMethodData* md;
ciProfileData* data; int mdo_offset_bias = 0;
// Negate the condition and repeat the algorithm with the second operand if (opr1 == opr2) { break; }
opr1 = opr2;
acond = ncond;
}
}
#ifdef ASSERT staticint reg_size(LIR_Opr op) { switch (op->type()) { case T_FLOAT: case T_INT: return BytesPerInt; case T_LONG: case T_DOUBLE: return BytesPerLong; case T_OBJECT: case T_ARRAY: case T_METADATA: return BytesPerWord; case T_ADDRESS: case T_ILLEGAL: // fall through default: ShouldNotReachHere(); return -1;
}
} #endif
if (right->is_address()) { // special case for adding shifted/extended register constRegister res = dest->as_pointer_register(); constRegister lreg = left->as_pointer_register(); const LIR_Address* addr = right->as_address_ptr();
// Ricklass may contain something that is not a metadata pointer so // mov_metadata can't be used
InlinedAddress value((address)Universe::non_oop_word());
InlinedAddress addr(op->addr()); if (use_movw) {
__ movw(Ricklass, ((unsignedint)Universe::non_oop_word()) & 0xffff);
__ movt(Ricklass, ((unsignedint)Universe::non_oop_word()) >> 16);
} else { // No movw/movt, must be load a pc relative value but no // relocation so no metadata table to load from. // Use a b instruction rather than a bl, inline constant after the // branch, use a PC relative ldr to load the constant, arrange for // the call to return after the constant(s).
__ ldr_literal(Ricklass, value);
}
__ relocate(virtual_call_Relocation::spec(oop_address)); if (near_range && use_movw) {
__ bl(op->addr());
} else {
Label call_return;
__ adr(LR, call_return); if (near_range) {
__ b(op->addr());
} else {
__ indirect_jump(addr, Rtemp);
__ bind_literal(addr);
} if (!use_movw) {
__ bind_literal(value);
}
__ bind(call_return);
}
add_call_info(code_offset(), op->info());
}
InlinedMetadata metadata_literal(NULL);
__ relocate(static_stub_Relocation::spec(call_pc)); // If not a single instruction, NativeMovConstReg::next_instruction_address() // must jump over the whole following ldr_literal. // (See CompiledStaticCall::set_to_interpreted()) #ifdef ASSERT
address ldr_site = __ pc(); #endif
__ ldr_literal(Rmethod, metadata_literal);
assert(nativeMovConstReg_at(ldr_site)->next_instruction_address() == __ pc(), "Fix ldr_literal or its parsing"); bool near_range = __ cache_fully_reachable();
InlinedAddress dest((address)-1); if (near_range) {
address branch_site = __ pc();
__ b(branch_site); // b to self maps to special NativeJump -1 destination
} else {
__ indirect_jump(dest, Rtemp);
}
__ bind_literal(metadata_literal); // includes spec_for_immediate reloc if (!near_range) {
__ bind_literal(dest); // special NativeJump -1 destination
}
// If we don't know anything or it's an object array, just go through the generic arraycopy if (default_type == NULL) {
// save arguments, because they will be killed by a runtime call
save_in_reserved_area(R0, R1, R2, R3);
// pass length argument on SP[0]
__ str(length, Address(SP, -2*wordSize, pre_indexed)); // 2 words for a proper stack alignment
address copyfunc_addr = StubRoutines::generic_arraycopy();
assert(copyfunc_addr != NULL, "generic arraycopy stub required"); #ifndef PRODUCT if (PrintC1Statistics) {
__ inc_counter((address)&Runtime1::_generic_arraycopystub_cnt, tmp, tmp2);
} #endif// !PRODUCT // the stub is in the code cache so close enough
__ call(copyfunc_addr, relocInfo::runtime_call_type);
__ add(SP, SP, 2*wordSize);
__ cbz_32(R0, *stub->continuation());
__ mvn_32(tmp, R0);
restore_from_reserved_area(R0, R1, R2, R3); // load saved arguments in slow case only
__ sub_32(length, length, tmp);
__ add_32(src_pos, src_pos, tmp);
__ add_32(dst_pos, dst_pos, tmp);
__ b(*stub->entry());
__ bind(*stub->continuation()); return;
}
assert(default_type != NULL && default_type->is_array_klass() && default_type->is_loaded(), "must be true at this point"); int elem_size = type2aelembytes(basic_type); int shift = exact_log2(elem_size);
// Check for NULL if (flags & LIR_OpArrayCopy::src_null_check) { if (flags & LIR_OpArrayCopy::dst_null_check) {
__ cmp(src, 0);
__ cond_cmp(dst, 0, ne); // make one instruction shorter if both checks are needed
__ b(*stub->entry(), eq);
} else {
__ cbz(src, *stub->entry());
}
} elseif (flags & LIR_OpArrayCopy::dst_null_check) {
__ cbz(dst, *stub->entry());
}
// If the compiler was not able to prove that exact type of the source or the destination // of the arraycopy is an array type, check at runtime if the source or the destination is // an instance type. if (flags & LIR_OpArrayCopy::type_check) { if (!(flags & LIR_OpArrayCopy::LIR_OpArrayCopy::dst_objarray)) {
__ load_klass(tmp, dst);
__ ldr_u32(tmp2, Address(tmp, in_bytes(Klass::layout_helper_offset())));
__ mov_slow(tmp, Klass::_lh_neutral_value);
__ cmp_32(tmp2, tmp);
__ b(*stub->entry(), ge);
}
// Check if src and dst are of the same type if (flags & LIR_OpArrayCopy::type_check) { // We don't know the array types are compatible if (basic_type != T_OBJECT) { // Simple test for basic type arrays if (UseCompressedClassPointers) { // We don't need decode because we just need to compare
__ ldr_u32(tmp, Address(src, oopDesc::klass_offset_in_bytes()));
__ ldr_u32(tmp2, Address(dst, oopDesc::klass_offset_in_bytes()));
__ cmp_32(tmp, tmp2);
} else {
__ load_klass(tmp, src);
__ load_klass(tmp2, dst);
__ cmp(tmp, tmp2);
}
__ b(*stub->entry(), ne);
} else { // For object arrays, if src is a sub class of dst then we can // safely do the copy.
Label cont, slow;
__ mov(R6, R0);
__ mov(altFP_7_11, R1);
__ mov(R0, tmp);
__ mov(R1, tmp2);
__ call(Runtime1::entry_for(Runtime1::slow_subtype_check_id), relocInfo::runtime_call_type); // does not blow any registers except R0, LR and Rtemp
__ cmp_32(R0, 0);
__ mov(R0, R6);
__ mov(R1, altFP_7_11);
if (copyfunc_addr != NULL) { // use stub if available // src is not a sub class of dst so we have to do a // per-element check.
__ b(cont, ne);
__ bind(slow);
int mask = LIR_OpArrayCopy::src_objarray|LIR_OpArrayCopy::dst_objarray; if ((flags & mask) != mask) { // Check that at least both of them object arrays.
assert(flags & mask, "one of the two should be known to be an object array");
if (op->in_opr1()->is_valid()) {
assert(op->in_opr2()->is_valid(), "both operands must be valid");
comp_op(op->condition(), op->in_opr1(), op->in_opr2(), op);
} else {
assert(op->in_opr2()->is_illegal(), "both operands must be illegal");
assert(op->condition() == lir_cond_always, "no other conditions allowed");
}
Label ok; if (op->condition() != lir_cond_always) {
AsmCondition acond = al; switch (op->condition()) { case lir_cond_equal: acond = eq; break; case lir_cond_notEqual: acond = ne; break; case lir_cond_less: acond = lt; break; case lir_cond_lessEqual: acond = le; break; case lir_cond_greaterEqual: acond = ge; break; case lir_cond_greater: acond = gt; break; case lir_cond_aboveEqual: acond = hs; break; case lir_cond_belowEqual: acond = ls; break; default: ShouldNotReachHere();
}
__ b(ok, acond);
} if (op->halt()) { constchar* str = __ code_string(op->msg());
__ stop(str);
} else {
breakpoint();
}
__ bind(ok);
} #endif// ASSERT
void LIR_Assembler::emit_updatecrc32(LIR_OpUpdateCRC32* op) {
fatal("CRC32 intrinsic is not implemented on this platform");
}
// Update counter for all call types
ciMethodData* md = method->method_data_or_null();
assert(md != NULL, "Sanity");
ciProfileData* data = md->bci_to_data(bci);
assert(data != NULL && data->is_CounterData(), "need CounterData for calls");
assert(op->mdo()->is_single_cpu(), "mdo must be allocated"); Register mdo = op->mdo()->as_register();
assert(op->tmp1()->is_register(), "tmp1 must be allocated"); Register tmp1 = op->tmp1()->as_pointer_register();
assert_different_registers(mdo, tmp1);
__ mov_metadata(mdo, md->constant_encoding()); int mdo_offset_bias = 0; int max_offset = 4096; if (md->byte_offset_of_slot(data, CounterData::count_offset()) + data->size_in_bytes() >= max_offset) { // The offset is large so bias the mdo by the base of the slot so // that the ldr can use an immediate offset to reference the slots of the data
mdo_offset_bias = md->byte_offset_of_slot(data, CounterData::count_offset());
__ mov_slow(tmp1, mdo_offset_bias);
__ add(mdo, mdo, tmp1);
}
Address counter_addr(mdo, md->byte_offset_of_slot(data, CounterData::count_offset()) - mdo_offset_bias); // Perform additional virtual call profiling for invokevirtual and // invokeinterface bytecodes if (op->should_profile_receiver_type()) {
assert(op->recv()->is_single_cpu(), "recv must be allocated"); Register recv = op->recv()->as_register();
assert_different_registers(mdo, tmp1, recv);
assert(data->is_VirtualCallData(), "need VirtualCallData for virtual calls");
ciKlass* known_klass = op->known_holder(); if (C1OptimizeVirtualCallProfiling && known_klass != NULL) { // We know the type that will be seen at this call site; we can // statically update the MethodData* rather than needing to do // dynamic tests on the receiver type
// NOTE: we should probably put a lock around this search to // avoid collisions by concurrent compilations
ciVirtualCallData* vc_data = (ciVirtualCallData*) data;
uint i; for (i = 0; i < VirtualCallData::row_limit(); i++) {
ciKlass* receiver = vc_data->receiver(i); if (known_klass->equals(receiver)) {
Address data_addr(mdo, md->byte_offset_of_slot(data,
VirtualCallData::receiver_count_offset(i)) -
mdo_offset_bias);
__ ldr(tmp1, data_addr);
__ add(tmp1, tmp1, DataLayout::counter_increment);
__ str(tmp1, data_addr); return;
}
}
// Receiver type not found in profile data; select an empty slot
// Note that this is less efficient than it should be because it // always does a write to the receiver part of the // VirtualCallData rather than just the first time for (i = 0; i < VirtualCallData::row_limit(); i++) {
ciKlass* receiver = vc_data->receiver(i); if (receiver == NULL) {
Address recv_addr(mdo, md->byte_offset_of_slot(data, VirtualCallData::receiver_offset(i)) -
mdo_offset_bias);
__ mov_metadata(tmp1, known_klass->constant_encoding());
__ str(tmp1, recv_addr);
Address data_addr(mdo, md->byte_offset_of_slot(data, VirtualCallData::receiver_count_offset(i)) -
mdo_offset_bias);
__ ldr(tmp1, data_addr);
__ add(tmp1, tmp1, DataLayout::counter_increment);
__ str(tmp1, data_addr); return;
}
}
} else {
__ load_klass(recv, recv);
Label update_done;
type_profile_helper(mdo, mdo_offset_bias, md, data, recv, tmp1, &update_done); // Receiver did not match any saved receiver and there is no empty row for it. // Increment total counter to indicate polymorphic case.
__ ldr(tmp1, counter_addr);
__ add(tmp1, tmp1, DataLayout::counter_increment);
__ str(tmp1, counter_addr);
void LIR_Assembler::align_backward_branch_target() { // Some ARM processors do better with 8-byte branch target alignment
__ align(8);
}
void LIR_Assembler::negate(LIR_Opr left, LIR_Opr dest, LIR_Opr tmp) { // tmp must be unused
assert(tmp->is_illegal(), "wasting a register if tmp is allocated");
void LIR_Assembler::volatile_move_op(LIR_Opr src, LIR_Opr dest, BasicType type, CodeEmitInfo* info) {
assert(src->is_double_cpu() && dest->is_address() ||
src->is_address() && dest->is_double_cpu(), "Simple move_op is called for all other cases");
int null_check_offset; if (dest->is_address()) { // Store const LIR_Address* addr = dest->as_address_ptr(); constRegister src_lo = src->as_register_lo(); constRegister src_hi = src->as_register_hi();
assert(addr->index()->is_illegal() && addr->disp() == 0, "The address is simple already");
void LIR_Assembler::get_thread(LIR_Opr result_reg) { // Not used on ARM
Unimplemented();
}
void LIR_Assembler::peephole(LIR_List* lir) {
LIR_OpList* inst = lir->instructions_list(); constint inst_length = inst->length(); for (int i = 0; i < inst_length; i++) {
LIR_Op* op = inst->at(i); switch (op->code()) { case lir_cmp: { // Replace: // cmp rX, y // cmove [EQ] y, z, rX // with // cmp rX, y // cmove [EQ] illegalOpr, z, rX // // or // cmp rX, y // cmove [NE] z, y, rX // with // cmp rX, y // cmove [NE] z, illegalOpr, rX // // moves from illegalOpr should be removed when converting LIR to native assembly
LIR_Op2* cmp = op->as_Op2();
assert(cmp != NULL, "cmp LIR instruction is not an op2");
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 und die Messung sind noch experimentell.