/* * 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. *
*/
// Declaration and definition of StubGenerator (no .hpp file). // For a more detailed description of the stub routine structure // see the comment in stubRoutines.hpp
// Platform dependent parameters for array copy stubs
// Note: we have noticed a huge change in behavior on a microbenchmark // from platform to platform depending on the configuration.
// Instead of adding a series of command line options (which // unfortunately have to be done in the shared file and cannot appear // only in the ARM port), the tested result are hard-coded here in a set // of options, selected by specifying 'ArmCopyPlatform'
// Currently, this 'platform' is hardcoded to a value that is a good // enough trade-off. However, one can easily modify this file to test // the hard-coded configurations or create new ones. If the gain is // significant, we could decide to either add command line options or // add code to automatically choose a configuration.
// see comments below for the various configurations created #define DEFAULT_ARRAYCOPY_CONFIG 0 #define TEGRA2_ARRAYCOPY_CONFIG 1 #define IMX515_ARRAYCOPY_CONFIG 2
// Hard coded choices (XXX: could be changed to a command line option) #define ArmCopyPlatform DEFAULT_ARRAYCOPY_CONFIG
#define ArmCopyCacheLineSize 32 // not worth optimizing to 64 according to measured gains
// configuration for each kind of loop typedefstruct { int pld_distance; // prefetch distance (0 => no prefetch, <0: prefetch_before); bool split_ldm; // if true, split each STM in STMs with fewer registers bool split_stm; // if true, split each LTM in LTMs with fewer registers
} arraycopy_loop_config;
// Configurations were chosen based on manual analysis of benchmark // results, minimizing overhead with respect to best results on the // different test cases.
// Prefetch before is always favored since it avoids dirtying the // cache uselessly for small copies. Code for prefetch after has // been kept in case the difference is significant for some // platforms but we might consider dropping it.
// distance, ldm, stm
{ // default: tradeoff tegra2/imx515/nv-tegra2, // Notes on benchmarking: // - not far from optimal configuration on nv-tegra2 // - within 5% of optimal configuration except for backward aligned on IMX // - up to 40% from optimal configuration for backward shifted and backward align for tegra2 // but still on par with the operating system copy
{-256, true, true }, // forward aligned
{-256, true, true }, // backward aligned
{-256, false, false }, // forward shifted
{-256, true, true } // backward shifted
},
{ // configuration tuned on tegra2-4. // Warning: should not be used on nv-tegra2 ! // Notes: // - prefetch after gives 40% gain on backward copies on tegra2-4, // resulting in better number than the operating system // copy. However, this can lead to a 300% loss on nv-tegra and has // more impact on the cache (fetches further than what is // copied). Use this configuration with care, in case it improves // reference benchmarks.
{-256, true, true }, // forward aligned
{96, false, false }, // backward aligned
{-256, false, false }, // forward shifted
{96, false, false } // backward shifted
},
{ // configuration tuned on imx515 // Notes: // - smaller prefetch distance is sufficient to get good result and might be more stable // - refined backward aligned options within 5% of optimal configuration except for // tests were the arrays fit in the cache
{-160, false, false }, // forward aligned
{-160, false, false }, // backward aligned
{-160, false, false }, // forward shifted
{-160, true, true } // backward shifted
}
};
// XXX: TODO // Would be better with respect to native tools if the following // setting of FP was changed to conform to the native ABI, with FP // pointing to the saved FP slot (and the corresponding modifications // for entry_frame_call_wrapper_offset and frame::real_fp).
__ mov(FP, SP);
// Check for special cases: divisor <= 0 or dividend < 0
__ cmp(divisor, 0);
__ orrs(quotient, dividend, divisor, ne);
__ b(negative_or_zero, le);
__ bind(positive_arguments); // Save return address on stack to free one extra register
__ push(LR); // Approximate the mamximum order of the quotient
__ clz(tmp, dividend);
__ clz(quotient, divisor);
__ subs(tmp, quotient, tmp);
__ mov(quotient, 0); // Jump to the appropriate place in the unrolled loop below
__ ldr(PC, Address(PC, tmp, lsl, 2), pl); // If divisor is greater than dividend, return immediately
__ pop(PC);
// Offset table
Label offset_table[32]; int i; for (i = 0; i <= 31; i++) {
__ emit_address(offset_table[i]);
}
// Unrolled loop of 32 division steps for (i = 31; i >= 0; i--) {
__ bind(offset_table[i]);
__ cmp(remainder, AsmOperand(divisor, lsl, i));
__ sub(remainder, remainder, AsmOperand(divisor, lsl, i), hs);
__ add(quotient, quotient, 1 << i, hs);
}
__ pop(PC);
__ bind(negative_or_zero); // Find the combination of argument signs and jump to corresponding handler
__ andr(quotient, dividend, 0x80000000, ne);
__ orr(quotient, quotient, AsmOperand(divisor, lsr, 31), ne);
__ add(PC, PC, AsmOperand(quotient, ror, 26), ne);
__ str(LR, Address(Rthread, JavaThread::saved_exception_pc_offset()));
// The leaf runtime function can destroy R0-R3 and R12 registers which are still alive
RegisterSet saved_registers = RegisterSet(R3) | RegisterSet(R12); #if R9_IS_SCRATCHED // Safer to save R9 here since callers may have been written // assuming R9 survives. This is suboptimal but may not be worth // revisiting for this slow case.
// As per atomic.hpp the Atomic read-modify-write operations must be logically implemented as: // <fence>; <op>; <membar StoreLoad|StoreStore> // But for load-linked/store-conditional based systems a fence here simply means // no load/store can be reordered with respect to the initial load-linked, so we have: // <membar storeload|loadload> ; load-linked; <op>; store-conditional; <membar storeload|storestore> // There are no memory actions in <op> so nothing further is needed. // // So we define the following for convenience: #define MEMBAR_ATOMIC_OP_PRE \
MacroAssembler::Membar_mask_bits(MacroAssembler::StoreLoad|MacroAssembler::LoadLoad) #define MEMBAR_ATOMIC_OP_POST \
MacroAssembler::Membar_mask_bits(MacroAssembler::StoreLoad|MacroAssembler::StoreStore)
// Note: JDK 9 only supports ARMv7+ so we always have ldrexd available even though the // code below allows for it to be otherwise. The else clause indicates an ARMv5 system // for which we do not support MP and so membars are not necessary. This ARMv5 code will // be removed in the future.
// Implementation of atomic_add(jint add_value, volatile jint* dest) // used by Atomic::add(volatile jint* dest, jint add_value) // // Arguments : // // add_value: R0 // dest: R1 // // Results: // // R0: the new stored in dest // // Overwrites: // // R1, R2, R3 //
address generate_atomic_add() {
address start;
// Stack is unaligned, maintain double word alignment by pushing // odd number of regs.
__ push(RegisterSet(temp_result) | RegisterSet(temp_lo, temp_hi));
__ ldr(addr, Address(SP, 12));
if (VM_Version::supports_ldrexd()) {
__ ldrexd(result_lo, Address(src));
__ clrex(); // FIXME: safe to remove?
} elseif (!os::is_MP()) { // Last-ditch attempt: we are allegedly running on uni-processor. // Load the thing non-atomically and hope for the best.
__ ldmia(src, RegisterSet(result_lo, result_hi));
} else {
__ stop("Atomic load(jlong) unsupported on this platform");
}
__ bx(LR);
StubCodeMark mark(this, "StubRoutines", "atomic_store_long");
start = __ pc(); Register newval_lo = R0; Register newval_hi = R1; Register dest = R2; Register scratch_lo = R2; Register scratch_hi = R3; /* After load from stack */ Register result = R3;
if (VM_Version::supports_ldrexd()) {
__ mov(Rtemp, dest); // get dest to Rtemp
Label retry;
__ bind(retry);
__ ldrexd(scratch_lo, Address(Rtemp));
__ strexd(result, R0, Address(Rtemp));
__ rsbs(result, result, 1);
__ b(retry, eq);
} elseif (!os::is_MP()) { // Last-ditch attempt: we are allegedly running on uni-processor. // Store the thing non-atomically and hope for the best.
__ stmia(dest, RegisterSet(newval_lo, newval_hi));
} else {
__ stop("Atomic store(jlong) unsupported on this platform");
}
__ bx(LR);
return start;
}
#ifdef COMPILER2 // Support for uint StubRoutine::Arm::partial_subtype_check( Klass sub, Klass super ); // Arguments : // // ret : R0, returned // icc/xcc: set as R0 (depending on wordSize) // sub : R1, argument, not changed // super: R2, argument, not changed // raddr: LR, blown by call
address generate_partial_subtype_check() {
__ align(CodeEntryAlignment);
StubCodeMark mark(this, "StubRoutines", "partial_subtype_check");
address start = __ pc();
// based on SPARC check_klass_subtype_[fast|slow]_path (without CompressedOops)
// R0 used as tmp_reg (in addition to return reg) Register sub_klass = R1; Register super_klass = R2; Register tmp_reg2 = R3; Register tmp_reg3 = R4; #define saved_set tmp_reg2, tmp_reg3
Label L_loop, L_fail;
int sc_offset = in_bytes(Klass::secondary_super_cache_offset());
// fast check should be redundant
// slow check
{
__ raw_push(saved_set);
// a couple of useful fields in sub_klass: int ss_offset = in_bytes(Klass::secondary_supers_offset());
// Do a linear scan of the secondary super-klass chain. // This code is rarely used, so simplicity is a virtue here.
// Top of search loop
__ bind(L_loop); // Notes: // scan_temp starts at the array elements // count_temp is 1+size
__ subs(count_temp, count_temp, 1);
__ b(L_fail, eq); // not found in the array
// Load next super to check // In the array of super classes elements are pointer sized. int element_size = wordSize;
__ ldr(R0, Address(scan_temp, element_size, post_indexed));
// Look for Rsuper_klass on Rsub_klass's secondary super-class-overflow list
__ subs(R0, R0, search_key); // set R0 to 0 on success (and flags to eq)
// A miss means we are NOT a subtype and need to keep looping
__ b(L_loop, ne);
// Falling out the bottom means we found a hit; we ARE a subtype
// Success. Cache the super we found and proceed in triumph.
__ str(super_klass, Address(sub_klass, sc_offset));
// Return success // R0 is already 0 and flags are already set to eq
__ raw_pop(saved_set);
__ ret();
// Incoming arguments: // // R0: error message (char* ) // R1: address of register save area // R2: oop to verify // // All registers are saved before calling this stub. However, condition flags should be saved here.
// make sure object is 'reasonable'
__ cbz(oop, exit); // if obj is NULL it is ok
// Check if the oop is in the right area of memory // Note: oop_mask and oop_bits must be updated if the code is saved/reused const address oop_mask = (address) Universe::verify_oop_mask(); const address oop_bits = (address) Universe::verify_oop_bits();
__ mov_address(tmp1, oop_mask);
__ andr(tmp2, oop, tmp1);
__ mov_address(tmp1, oop_bits);
__ cmp(tmp2, tmp1);
__ b(error, ne);
// make sure klass is 'reasonable'
__ load_klass(klass, oop); // get klass
__ cbz(klass, error); // if klass is NULL it is broken
// return if everything seems ok
__ bind(exit);
__ msr(Assembler::CPSR_f, flags);
__ ret();
// handle errors
__ bind(error);
__ mov(ret_addr, LR); // save return address
// R0: error message // R1: register save area
__ call(CAST_FROM_FN_PTR(address, MacroAssembler::debug));
// probably we should choose between "prefetch-store before or after store", not "before or after load". void prefetch(Register from, Register to, int offset, int to_delta = 0) {
__ prefetch_read(Address(from, offset));
}
// Generate the inner loop for forward aligned array copy // // Arguments // from: src address, 64 bits aligned // to: dst address, wordSize aligned // count: number of elements (32-bit int) // bytes_per_count: number of bytes for each unit of 'count' // // Return the minimum initial value for count // // Notes: // - 'from' aligned on 64-bit (recommended for 32-bit ARM in case this speeds up LDMIA) // - 'to' aligned on wordSize // - 'count' must be greater or equal than the returned value // // Increases 'from' and 'to' by count*bytes_per_count. // // Scratches 'count', R3. // R4-R10 are preserved (saved/restored). // int generate_forward_aligned_copy_loop(Register from, Register to, Register count, int bytes_per_count, bool unsafe_copy = false) {
assert (from == R0 && to == R1 && count == R2, "adjust the implementation below");
constint bytes_per_loop = 8*wordSize; // 8 registers are read and written on every loop iteration
arraycopy_loop_config *config=&arraycopy_configurations[ArmCopyPlatform].forward_aligned; int pld_offset = config->pld_distance; constint count_per_loop = bytes_per_loop / bytes_per_count;
{ // UnsafeCopyMemory page error: continue after ucm
UnsafeCopyMemoryMark ucmm(this, unsafe_copy, true); // predecrease to exit when there is less than count_per_loop
__ sub_32(count, count, count_per_loop);
if (prefetch_before) { // If prefetch is done ahead, final PLDs that overflow the // copied area can be easily avoided. 'count' is predecreased // by the prefetch distance to optimize the inner loop and the // outer loop skips the PLD.
__ subs_32(count, count, (bytes_per_loop+pld_offset)/bytes_per_count);
// skip prefetch for small copies
__ b(L_skip_pld, lt);
}
int offset = ArmCopyCacheLineSize; while (offset <= pld_offset) {
prefetch(from, to, offset);
offset += ArmCopyCacheLineSize;
};
}
{ // 32-bit ARM note: we have tried implementing loop unrolling to skip one // PLD with 64 bytes cache line but the gain was not significant.
if (prefetch_before) {
prefetch(from, to, bytes_per_loop + pld_offset);
__ BIND(L_skip_pld);
}
if (split_read) { // Split the register set in two sets so that there is less // latency between LDM and STM (R3-R6 available while R7-R10 // still loading) and less register locking issue when iterating // on the first LDM.
__ ldmia(from, RegisterSet(R3, R6), writeback);
__ ldmia(from, RegisterSet(R7, R10), writeback);
} else {
__ ldmia(from, RegisterSet(R3, R10), writeback);
}
__ subs_32(count, count, count_per_loop);
if (prefetch_after) {
prefetch(from, to, pld_offset, bytes_per_loop);
}
if (prefetch_before) { // the inner loop may end earlier, allowing to skip PLD for the last iterations
__ cmn_32(count, (bytes_per_loop + pld_offset)/bytes_per_count);
__ b(L_skip_pld, ge);
}
}
BLOCK_COMMENT("Remaining bytes:"); // still 0..bytes_per_loop-1 aligned bytes to copy, count already decreased by (at least) bytes_per_loop bytes
// __ add(count, count, ...); // addition useless for the bit tests
assert (pld_offset % bytes_per_loop == 0, "decreasing count by pld_offset before loop must not change tested bits");
// Generate the inner loop for backward aligned array copy // // Arguments // end_from: src end address, 64 bits aligned // end_to: dst end address, wordSize aligned // count: number of elements (32-bit int) // bytes_per_count: number of bytes for each unit of 'count' // // Return the minimum initial value for count // // Notes: // - 'end_from' aligned on 64-bit (recommended for 32-bit ARM in case this speeds up LDMIA) // - 'end_to' aligned on wordSize // - 'count' must be greater or equal than the returned value // // Decreases 'end_from' and 'end_to' by count*bytes_per_count. // // Scratches 'count', R3. // ARM R4-R10 are preserved (saved/restored). // int generate_backward_aligned_copy_loop(Register end_from, Register end_to, Register count, int bytes_per_count, bool unsafe_copy = false) {
assert (end_from == R0 && end_to == R1 && count == R2, "adjust the implementation below");
constint bytes_per_loop = 8*wordSize; // 8 registers are read and written on every loop iteration constint count_per_loop = bytes_per_loop / bytes_per_count;
arraycopy_loop_config *config=&arraycopy_configurations[ArmCopyPlatform].backward_aligned; int pld_offset = config->pld_distance;
if (prefetch_before) {
__ cmn_32(count, (bytes_per_loop + pld_offset)/bytes_per_count);
__ b(L_skip_pld, ge);
}
}
BLOCK_COMMENT("Remaining bytes:"); // still 0..bytes_per_loop-1 aligned bytes to copy, count already decreased by (at least) bytes_per_loop bytes
// __ add(count, count, ...); // addition useless for the bit tests
assert (pld_offset % bytes_per_loop == 0, "decreasing count by pld_offset before loop must not change tested bits");
// Generate the inner loop for shifted forward array copy (unaligned copy). // It can be used when bytes_per_count < wordSize, i.e. byte/short copy // // Arguments // from: start src address, 64 bits aligned // to: start dst address, (now) wordSize aligned // count: number of elements (32-bit int) // bytes_per_count: number of bytes for each unit of 'count' // lsr_shift: shift applied to 'old' value to skipped already written bytes // lsl_shift: shift applied to 'new' value to set the high bytes of the next write // // Return the minimum initial value for count // // Notes: // - 'from' aligned on 64-bit (recommended for 32-bit ARM in case this speeds up LDMIA) // - 'to' aligned on wordSize // - 'count' must be greater or equal than the returned value // - 'lsr_shift' + 'lsl_shift' = BitsPerWord // - 'bytes_per_count' is 1 or 2 // // Increases 'to' by count*bytes_per_count. // // Scratches 'from' and 'count', R3-R10, R12 // // On entry: // - R12 is preloaded with the first 'BitsPerWord' bits read just before 'from' // - (R12 >> lsr_shift) is the part not yet written (just before 'to') // --> (*to) = (R12 >> lsr_shift) | (*from) << lsl_shift); ... // // This implementation may read more bytes than required. // Actually, it always reads exactly all data from the copied region with upper bound aligned up by wordSize, // so excessive read do not cross a word bound and is thus harmless. // int generate_forward_shifted_copy_loop(Register from, Register to, Register count, int bytes_per_count, int lsr_shift, int lsl_shift) {
assert (from == R0 && to == R1 && count == R2, "adjust the implementation below");
constint bytes_per_loop = 8*wordSize; // 8 registers are read and written on every loop iter constint count_per_loop = bytes_per_loop / bytes_per_count;
arraycopy_loop_config *config=&arraycopy_configurations[ArmCopyPlatform].forward_shifted; int pld_offset = config->pld_distance;
if (prefetch_before) { // do it early if there might be register locking issues
prefetch(from, to, bytes_per_loop + pld_offset);
__ BIND(L_skip_pld);
} else {
__ cmp_32(count, count_per_loop);
__ b(L_last_read, lt);
}
// read 32 bytes if (split_read) { // if write is not split, use less registers in first set to reduce locking
RegisterSet set1 = split_write ? RegisterSet(R4, R7) : RegisterSet(R4, R5);
RegisterSet set2 = (split_write ? RegisterSet(R8, R10) : RegisterSet(R6, R10)) | R12;
__ ldmia(from, set1, writeback);
__ mov(R3, AsmOperand(R12, lsr, lsr_shift)); // part of R12 not yet written
__ ldmia(from, set2, writeback);
__ subs(count, count, count_per_loop); // XXX: should it be before the 2nd LDM ? (latency vs locking)
} else {
__ mov(R3, AsmOperand(R12, lsr, lsr_shift)); // part of R12 not yet written
__ ldmia(from, RegisterSet(R4, R10) | R12, writeback); // Note: small latency on R4
__ subs(count, count, count_per_loop);
}
if (prefetch_after) { // do it after the 1st ldm/ldp anyway (no locking issues with early STM/STP)
prefetch(from, to, pld_offset, bytes_per_loop);
}
// prepare (shift) the values in R3..R10
__ orr(R3, R3, AsmOperand(R4, lsl, lsl_shift)); // merged below low bytes of next val
__ logical_shift_right(R4, R4, lsr_shift); // unused part of next val
__ orr(R4, R4, AsmOperand(R5, lsl, lsl_shift)); // ...
__ logical_shift_right(R5, R5, lsr_shift);
__ orr(R5, R5, AsmOperand(R6, lsl, lsl_shift));
__ logical_shift_right(R6, R6, lsr_shift);
__ orr(R6, R6, AsmOperand(R7, lsl, lsl_shift)); if (split_write) { // write the first half as soon as possible to reduce stm locking
__ stmia(to, RegisterSet(R3, R6), writeback, prefetch_before ? gt : ge);
}
__ logical_shift_right(R7, R7, lsr_shift);
__ orr(R7, R7, AsmOperand(R8, lsl, lsl_shift));
__ logical_shift_right(R8, R8, lsr_shift);
__ orr(R8, R8, AsmOperand(R9, lsl, lsl_shift));
__ logical_shift_right(R9, R9, lsr_shift);
__ orr(R9, R9, AsmOperand(R10, lsl, lsl_shift));
__ logical_shift_right(R10, R10, lsr_shift);
__ orr(R10, R10, AsmOperand(R12, lsl, lsl_shift));
if (split_write) {
__ stmia(to, RegisterSet(R7, R10), writeback, prefetch_before ? gt : ge);
} else {
__ stmia(to, RegisterSet(R3, R10), writeback, prefetch_before ? gt : ge);
}
__ b(L_shifted_loop, gt); // no need to loop if 0 (when count need not be precise modulo bytes_per_loop)
if (prefetch_before) { // the first loop may end earlier, allowing to skip pld at the end
__ cmn_32(count, (bytes_per_loop + pld_offset)/bytes_per_count);
__ stmia(to, RegisterSet(R3, R10), writeback); // stmia was skipped
__ b(L_skip_pld, ge);
__ adds_32(count, count, ((bytes_per_loop + pld_offset) / bytes_per_count) + count_per_loop);
}
// Note: R3 might contain enough bytes ready to write (3 needed at most), // thus load on lsl_shift==24 is not needed (in fact forces reading // beyond source buffer end boundary) if (lsl_shift == 8) {
__ ldr(R4, Address(from, 4, post_indexed), ge);
__ orr(R3, R3, AsmOperand(R4, lsl, lsl_shift), ge);
} elseif (lsl_shift == 16) {
__ ldr(R4, Address(from, 4, post_indexed), gt);
__ orr(R3, R3, AsmOperand(R4, lsl, lsl_shift), gt);
}
__ strh(R3, Address(to, 2, post_indexed), ge); // two last bytes
__ mov(R3, AsmOperand(R3, lsr, 16), gt);
__ tst(count, 1);
__ strb(R3, Address(to, 1, post_indexed), ne); // one last byte break;
}
__ BIND(L_done); return 0; // no minimum
}
// Generate the inner loop for shifted backward array copy (unaligned copy). // It can be used when bytes_per_count < wordSize, i.e. byte/short copy // // Arguments // end_from: end src address, 64 bits aligned // end_to: end dst address, (now) wordSize aligned // count: number of elements (32-bit int) // bytes_per_count: number of bytes for each unit of 'count' // lsl_shift: shift applied to 'old' value to skipped already written bytes // lsr_shift: shift applied to 'new' value to set the low bytes of the next write // // Return the minimum initial value for count // // Notes: // - 'end_from' aligned on 64-bit (recommended for 32-bit ARM in case this speeds up LDMIA) // - 'end_to' aligned on wordSize // - 'count' must be greater or equal than the returned value // - 'lsr_shift' + 'lsl_shift' = 'BitsPerWord' // - 'bytes_per_count' is 1 or 2 on 32-bit ARM // // Decreases 'end_to' by count*bytes_per_count. // // Scratches 'end_from', 'count', R3-R10, R12 // // On entry: // - R3 is preloaded with the first 'BitsPerWord' bits read just after 'from' // - (R3 << lsl_shift) is the part not yet written // --> (*--to) = (R3 << lsl_shift) | (*--from) >> lsr_shift); ... // // This implementation may read more bytes than required. // Actually, it always reads exactly all data from the copied region with beginning aligned down by wordSize, // so excessive read do not cross a word bound and is thus harmless. // int generate_backward_shifted_copy_loop(Register end_from, Register end_to, Register count, int bytes_per_count, int lsr_shift, int lsl_shift) {
assert (end_from == R0 && end_to == R1 && count == R2, "adjust the implementation below");
constint bytes_per_loop = 8*wordSize; // 8 registers are read and written on every loop iter constint count_per_loop = bytes_per_loop / bytes_per_count;
arraycopy_loop_config *config=&arraycopy_configurations[ArmCopyPlatform].backward_shifted; int pld_offset = config->pld_distance;
if (prefetch_before) {
__ cmp_32(count, count_per_loop);
__ b(L_last_read, lt);
// skip prefetch for small copies // warning: count is predecreased by the prefetch distance to optimize the inner loop
__ subs_32(count, count, ((bytes_per_loop + pld_offset)/bytes_per_count) + count_per_loop);
__ b(L_skip_pld, lt);
}
int offset = ArmCopyCacheLineSize; while (offset <= pld_offset) {
prefetch(end_from, end_to, -(wordSize + offset));
offset += ArmCopyCacheLineSize;
};
}
if (prefetch_before) { // do the 1st ldm/ldp first anyway (no locking issues with early STM/STP)
prefetch(end_from, end_to, -(wordSize + bytes_per_loop + pld_offset));
__ BIND(L_skip_pld);
} else {
__ cmp_32(count, count_per_loop);
__ b(L_last_read, lt);
}
if (split_read) {
__ ldmdb(end_from, RegisterSet(R7, R10), writeback);
__ mov(R12, AsmOperand(R3, lsl, lsl_shift)); // part of R3 not yet written
__ ldmdb(end_from, RegisterSet(R3, R6), writeback);
} else {
__ mov(R12, AsmOperand(R3, lsl, lsl_shift)); // part of R3 not yet written
__ ldmdb(end_from, RegisterSet(R3, R10), writeback);
}
__ subs_32(count, count, count_per_loop);
if (prefetch_after) { // do prefetch during ldm/ldp latency
prefetch(end_from, end_to, -(wordSize + pld_offset), -bytes_per_loop);
}
__ b(L_shifted_loop, gt); // no need to loop if 0 (when count need not be precise modulo bytes_per_loop)
if (prefetch_before) { // the first loop may end earlier, allowing to skip pld at the end
__ cmn_32(count, ((bytes_per_loop + pld_offset)/bytes_per_count));
__ stmdb(end_to, RegisterSet(R4, R10) | R12, writeback); // stmdb was skipped
__ b(L_skip_pld, ge);
__ adds_32(count, count, ((bytes_per_loop + pld_offset) / bytes_per_count) + count_per_loop);
}
// Copies data from 'from' to 'to' in specified direction to align 'from' by 64 bits. // (on 32-bit ARM 64-bit alignment is better for LDM). // // Arguments: // from: beginning (if forward) or upper bound (if !forward) of the region to be read // to: beginning (if forward) or upper bound (if !forward) of the region to be written // count: 32-bit int, maximum number of elements which can be copied // bytes_per_count: size of an element // forward: specifies copy direction // // Notes: // 'from' and 'to' must be aligned by 'bytes_per_count' // 'count' must not be less than the returned value // shifts 'from' and 'to' by the number of copied bytes in corresponding direction // decreases 'count' by the number of elements copied // // Returns maximum number of bytes which may be copied. int align_src(Register from, Register to, Register count, Register tmp, int bytes_per_count, bool forward) {
assert_different_registers(from, to, count, tmp); if (bytes_per_count < 8) {
Label L_align_src;
__ BIND(L_align_src);
__ tst(from, 7); // ne => not aligned: copy one element and (if bytes_per_count < 4) loop
__ sub(count, count, 1, ne);
load_one(tmp, from, bytes_per_count, forward, ne);
store_one(tmp, to, bytes_per_count, forward, ne); if (bytes_per_count < 4) {
__ b(L_align_src, ne); // if bytes_per_count == 4, then 0 or 1 loop iterations are enough
}
} return 7/bytes_per_count;
}
// Copies 'count' of 'bytes_per_count'-sized elements in the specified direction. // // Arguments: // from: beginning (if forward) or upper bound (if !forward) of the region to be read // to: beginning (if forward) or upper bound (if !forward) of the region to be written // count: 32-bit int, number of elements to be copied // entry: copy loop entry point // bytes_per_count: size of an element // forward: specifies copy direction // // Notes: // shifts 'from' and 'to' void copy_small_array(Register from, Register to, Register count, Register tmp, Register tmp2, int bytes_per_count, bool forward, Label & entry, bool unsafe_copy = false) {
assert_different_registers(from, to, count, tmp);
// Aligns 'to' by reading one word from 'from' and writing its part to 'to'. // // Arguments: // to: beginning (if forward) or upper bound (if !forward) of the region to be written // count: 32-bit int, number of elements allowed to be copied // to_remainder: remainder of dividing 'to' by wordSize // bytes_per_count: size of an element // forward: specifies copy direction // Rval: contains an already read but not yet written word; // its' LSBs (if forward) or MSBs (if !forward) are to be written to align 'to'. // // Notes: // 'count' must not be less then the returned value // 'to' must be aligned by bytes_per_count but must not be aligned by wordSize // shifts 'to' by the number of written bytes (so that it becomes the bound of memory to be written) // decreases 'count' by the number of elements written // Rval's MSBs or LSBs remain to be written further by generate_{forward,backward}_shifted_copy_loop int align_dst(Register to, Register count, Register Rval, Register tmp, int to_remainder, int bytes_per_count, bool forward) {
assert_different_registers(to, count, tmp, Rval);
assert (0 < to_remainder && to_remainder < wordSize, "to_remainder is not valid");
assert (to_remainder % bytes_per_count == 0, "to must be aligned by bytes_per_count");
int bytes_to_write = forward ? (wordSize - to_remainder) : to_remainder;
int offset = 0;
for (int l = 0; l < LogBytesPerWord; ++l) { int s = (1 << l); if (bytes_to_write & s) { int new_offset = offset + s*BitsPerByte; if (forward) { if (offset == 0) {
store_one(Rval, to, s, forward);
} else {
__ logical_shift_right(tmp, Rval, offset);
store_one(tmp, to, s, forward);
}
} else {
__ logical_shift_right(tmp, Rval, BitsPerWord - new_offset);
store_one(tmp, to, s, forward);
}
offset = new_offset;
}
}
assert (offset == bytes_to_write * BitsPerByte, "all bytes must be copied");
// Copies 'count' of elements using shifted copy loop // // Arguments: // from: beginning (if forward) or upper bound (if !forward) of the region to be read // to: beginning (if forward) or upper bound (if !forward) of the region to be written // count: 32-bit int, number of elements to be copied // to_remainder: remainder of dividing 'to' by wordSize // bytes_per_count: size of an element // forward: specifies copy direction // Rval: contains an already read but not yet written word // // // Notes: // 'count' must not be less then the returned value // 'from' must be aligned by wordSize // 'to' must be aligned by bytes_per_count but must not be aligned by wordSize // shifts 'to' by the number of copied bytes // // Scratches R3-R10, R12 int align_dst_and_generate_shifted_copy_loop(Register from, Register to, Register count, Register Rval, int to_remainder, int bytes_per_count, bool forward) {
int required_to_align = align_dst(to, count, Rval, tmp, to_remainder, bytes_per_count, forward);
int lsr_shift = (wordSize - to_remainder) * BitsPerByte; int lsl_shift = to_remainder * BitsPerByte;
int min_copy; if (forward) {
min_copy = generate_forward_shifted_copy_loop(from, to, count, bytes_per_count, lsr_shift, lsl_shift);
} else {
min_copy = generate_backward_shifted_copy_loop(from, to, count, bytes_per_count, lsr_shift, lsl_shift);
}
return min_copy + required_to_align;
}
// Copies 'count' of elements using shifted copy loop // // Arguments: // from: beginning (if forward) or upper bound (if !forward) of the region to be read // to: beginning (if forward) or upper bound (if !forward) of the region to be written // count: 32-bit int, number of elements to be copied // bytes_per_count: size of an element // forward: specifies copy direction // // Notes: // 'count' must not be less then the returned value // 'from' must be aligned by wordSize // 'to' must be aligned by bytes_per_count but must not be aligned by wordSize // shifts 'to' by the number of copied bytes // // Scratches 'from', 'count', R3 and R12. // R4-R10 saved for use. int align_dst_and_generate_shifted_copy_loop(Register from, Register to, Register count, int bytes_per_count, bool forward, bool unsafe_copy = false) {
// Note: if {seq} is a sequence of numbers, L{seq} means that if the execution reaches this point, // then the remainder of 'to' divided by wordSize is one of elements of {seq}.
// // Generate stub for primitive array copy. If "aligned" is true, the // "from" and "to" addresses are assumed to be heapword aligned. // // If "disjoint" is true, arrays are assumed to be disjoint, otherwise they may overlap and // "nooverlap_target" must be specified as the address to jump if they don't. // // Arguments for generated stub: // from: R0 // to: R1 // count: R2 treated as signed 32-bit int //
address generate_primitive_copy(bool aligned, constchar * name, bool status, int bytes_per_count, bool disjoint, address nooverlap_target = NULL) {
__ align(CodeEntryAlignment);
StubCodeMark mark(this, "StubRoutines", name);
address start = __ pc();
// Conjoint case: since execution reaches this point, the arrays overlap, so performing backward copy // Disjoint case: perform forward copy bool forward = disjoint;
if (!forward) { // Set 'from' and 'to' to upper bounds int log_bytes_per_count = exact_log2(bytes_per_count);
__ add_ptr_scaled_int32(to, to, count, log_bytes_per_count);
__ add_ptr_scaled_int32(from, from, count, log_bytes_per_count);
}
// There are two main copy loop implementations: // *) The huge and complex one applicable only for large enough arrays // *) The small and simple one applicable for any array (but not efficient for large arrays). // Currently "small" implementation is used if and only if the "large" one could not be used. // XXX optim: tune the limit higher ? // Large implementation lower applicability bound is actually determined by // aligned copy loop which require <=7 bytes for src alignment, and 8 words for aligned copy loop. constint small_copy_limit = (8*wordSize + 7) / bytes_per_count;
bool from_is_aligned = (bytes_per_count >= 8); if (aligned && forward && (HeapWordSize % 8 == 0)) { // if 'from' is heapword aligned and HeapWordSize is divisible by 8, // then from is aligned by 8
from_is_aligned = true;
}
int count_required_to_align = 0;
{ // UnsafeCopyMemoryMark page error: continue at UnsafeCopyMemory common_error_exit
UnsafeCopyMemoryMark ucmm(this, !aligned, false);
count_required_to_align = from_is_aligned ? 0 : align_src(from, to, count, tmp1, bytes_per_count, forward);
assert (small_copy_limit >= count_required_to_align, "alignment could exhaust count");
}
// now 'from' is aligned
bool to_is_aligned = false;
if (bytes_per_count >= wordSize) { // 'to' is aligned by bytes_per_count, so it is aligned by wordSize
to_is_aligned = true;
} else { if (aligned && (8 % HeapWordSize == 0) && (HeapWordSize % wordSize == 0)) { // Originally 'from' and 'to' were heapword aligned; // (from - to) has not been changed, so since now 'from' is 8-byte aligned, then it is also heapword aligned, // so 'to' is also heapword aligned and thus aligned by wordSize.
to_is_aligned = true;
}
}
Label L_unaligned_dst;
if (!to_is_aligned) {
BLOCK_COMMENT("Check dst alignment:");
__ tst(to, wordSize - 1);
__ b(L_unaligned_dst, ne); // 'to' is not aligned
}
// 'from' and 'to' are properly aligned
int min_copy; if (forward) {
min_copy = generate_forward_aligned_copy_loop(from, to, count, bytes_per_count, !aligned /*add UnsafeCopyMemory entry*/);
} else {
min_copy = generate_backward_aligned_copy_loop(from, to, count, bytes_per_count, !aligned /*add UnsafeCopyMemory entry*/);
}
assert(small_copy_limit >= count_required_to_align + min_copy, "first loop might exhaust count");
if (! to_is_aligned) {
__ BIND(L_unaligned_dst); int min_copy_shifted = align_dst_and_generate_shifted_copy_loop(from, to, count, bytes_per_count, forward, !aligned /*add UnsafeCopyMemory entry*/);
assert (small_copy_limit >= count_required_to_align + min_copy_shifted, "first loop might exhaust count");
if (status) {
__ mov(R0, 0); // OK
}
__ ret();
}
return start;
}
// Generates pattern of code to be placed after raw data copying in generate_oop_copy // Includes return from arraycopy stub. // // Arguments: // to: destination pointer after copying. // if 'forward' then 'to' == upper bound, else 'to' == beginning of the modified region // count: total number of copied elements, 32-bit int // // Blows all volatile R0-R3, Rtemp, LR) and 'to', 'count', 'tmp' registers. void oop_arraycopy_stub_epilogue_helper(Register to, Register count, Register tmp, boolstatus, bool forward, DecoratorSet decorators) {
assert_different_registers(to, count, tmp);
if (forward) { // 'to' is upper bound of the modified region // restore initial dst:
__ sub_ptr_scaled_int32(to, to, count, LogBytesPerHeapOop);
}
// 'to' is the beginning of the region
BarrierSetAssembler *bs = BarrierSet::barrier_set()->barrier_set_assembler();
bs->arraycopy_epilogue(_masm, decorators, true, to, count, tmp);
if (status) {
__ mov(R0, 0); // OK
}
__ pop(PC);
}
// Generate stub for assign-compatible oop copy. If "aligned" is true, the // "from" and "to" addresses are assumed to be heapword aligned. // // If "disjoint" is true, arrays are assumed to be disjoint, otherwise they may overlap and // "nooverlap_target" must be specified as the address to jump if they don't. // // Arguments for generated stub: // from: R0 // to: R1 // count: R2 treated as signed 32-bit int //
address generate_oop_copy(bool aligned, constchar * name, bool status, bool disjoint, address nooverlap_target = NULL) {
__ align(CodeEntryAlignment);
StubCodeMark mark(this, "StubRoutines", name);
address start = __ pc();
Register from = R0; Register to = R1; Register count = R2; Register tmp1 = R3; Register tmp2 = R12;
if (!aligned) {
BLOCK_COMMENT("Entry:");
}
__ zap_high_non_significant_bits(R2);
if (!disjoint) {
assert (nooverlap_target != NULL, "must be specified for conjoint case");
array_overlap_test(nooverlap_target, LogBytesPerHeapOop, tmp1, tmp2);
}
// Conjoint case: since execution reaches this point, the arrays overlap, so performing backward copy // Disjoint case: perform forward copy bool forward = disjoint;
// LR is used later to save barrier args
__ push(LR);
DecoratorSet decorators = IN_HEAP | IS_ARRAY; if (disjoint) {
decorators |= ARRAYCOPY_DISJOINT;
} if (aligned) {
decorators |= ARRAYCOPY_ALIGNED;
}
BarrierSetAssembler *bs = BarrierSet::barrier_set()->barrier_set_assembler();
bs->arraycopy_prologue(_masm, decorators, true, to, count, callee_saved_regs);
// save arguments for barrier generation (after the pre barrier)
__ mov(saved_count, count);
if (!forward) {
__ add_ptr_scaled_int32(to, to, count, log_bytes_per_count);
__ add_ptr_scaled_int32(from, from, count, log_bytes_per_count);
}
// for short arrays, just do single element copy
Label L_small_array; constint small_copy_limit = (8*wordSize + 7)/bytes_per_count; // XXX optim: tune the limit higher ?
__ cmp_32(count, small_copy_limit);
__ b(L_small_array, le);
bool from_is_aligned = (bytes_per_count >= 8); if (aligned && forward && (HeapWordSize % 8 == 0)) { // if 'from' is heapword aligned and HeapWordSize is divisible by 8, // then from is aligned by 8
from_is_aligned = true;
}
int count_required_to_align = from_is_aligned ? 0 : align_src(from, to, count, tmp1, bytes_per_count, forward);
assert (small_copy_limit >= count_required_to_align, "alignment could exhaust count");
// now 'from' is aligned
bool to_is_aligned = false;
if (bytes_per_count >= wordSize) { // 'to' is aligned by bytes_per_count, so it is aligned by wordSize
to_is_aligned = true;
} else { if (aligned && (8 % HeapWordSize == 0) && (HeapWordSize % wordSize == 0)) { // Originally 'from' and 'to' were heapword aligned; // (from - to) has not been changed, so since now 'from' is 8-byte aligned, then it is also heapword aligned, // so 'to' is also heapword aligned and thus aligned by wordSize.
to_is_aligned = true;
}
}
Label L_unaligned_dst;
if (!to_is_aligned) {
BLOCK_COMMENT("Check dst alignment:");
__ tst(to, wordSize - 1);
__ b(L_unaligned_dst, ne); // 'to' is not aligned
}
int min_copy; if (forward) {
min_copy = generate_forward_aligned_copy_loop(from, to, count, bytes_per_count);
} else {
min_copy = generate_backward_aligned_copy_loop(from, to, count, bytes_per_count);
}
assert(small_copy_limit >= count_required_to_align + min_copy, "first loop might exhaust count");
// Generate 'unsafe' array copy stub // Though just as safe as the other stubs, it takes an unscaled // size_t argument instead of an element count. // // Arguments for generated stub: // from: R0 // to: R1 // count: R2 byte count, treated as ssize_t, can be zero // // Examines the alignment of the operands and dispatches // to a long, int, short, or byte copy loop. //
address generate_unsafe_copy(constchar* name) {
// Top of search loop
__ bind(L_loop); // Notes: // scan_temp starts at the array elements // count_temp is 1+size
__ subs(count_temp, count_temp, 1);
__ b(L_fail, eq); // not found
// Load next super to check // In the array of super classes elements are pointer sized. int element_size = wordSize;
__ ldr(tmp3, Address(scan_temp, element_size, post_indexed));
// Look for Rsuper_klass on Rsub_klass's secondary super-class-overflow list
__ cmp(tmp3, search_key);
// A miss means we are NOT a subtype and need to keep looping
__ b(L_loop, ne);
// Falling out the bottom means we found a hit; we ARE a subtype
// Success. Cache the super we found and proceed in triumph.
__ str(super_klass, Address(sub_klass, sc_offset));
// Jump to success
__ b(L_success);
// Fall through on failure!
__ bind(L_fail);
}
// Generate stub for checked oop copy. // // Arguments for generated stub: // from: R0 // to: R1 // count: R2 treated as signed 32-bit int // ckoff: R3 (super_check_offset) // ckval: R4 (super_klass) // ret: R0 zero for success; (-1^K) where K is partial transfer count (32-bit) //
address generate_checkcast_copy(constchar * name) {
__ align(CodeEntryAlignment);
StubCodeMark mark(this, "StubRoutines", name);
address start = __ pc();
constRegister from = R0; // source array address constRegister to = R1; // destination array address constRegister count = R2; // elements count
__ ldr(R4_ckval,Address(SP, wordSize*pushed)); // read the argument that was on the stack
// Save arguments for barrier generation (after the pre barrier): // - must be a caller saved register and not LR // - ARM32: avoid R10 in case RThread is needed constRegister saved_count = altFP_7_11;
__ movs(saved_count, count); // and test count
__ b(load_element,ne);
// nothing to copy
__ mov(R0, 0);
__ pop(caller_saved_regs);
__ pop(PC);
// ======== begin loop ======== // (Loop is rotated; its entry is load_element.)
__ align(OptoLoopAlignment);
__ BIND(store_element); if (UseCompressedOops) {
__ store_heap_oop(Address(to, BytesPerHeapOop, post_indexed), R5); // store the oop, changes flags
__ subs_32(count,count,1);
} else {
__ subs_32(count,count,1);
__ str(R5, Address(to, BytesPerHeapOop, post_indexed)); // store the oop
}
__ b(do_epilogue, eq); // count exhausted
// ======== loop entry is here ========
__ BIND(load_element);
__ load_heap_oop(R5, Address(from, BytesPerHeapOop, post_indexed)); // load the oop
__ cbz(R5, store_element); // NULL
__ load_klass(R6, R5);
generate_type_check(R6, R3_ckoff, R4_ckval, /*tmps*/ R12, R8, R9, // branch to this on success:
store_element); // ======== end loop ========
// It was a real error; we must depend on the caller to finish the job. // Register count has number of *remaining* oops, saved_count number of *total* oops. // Emit GC store barriers for the oops we have copied // and report their number to the caller (0 or (-1^n))
__ BIND(fail);
// Note: fail marked by the fact that count differs from saved_count
__ subs_32(copied, saved_count, count); // copied count (in saved reg)
__ b(L_not_copied, eq); // nothing was copied, skip post barrier
__ sub(to, to, AsmOperand(copied, lsl, LogBytesPerHeapOop)); // initial to value
__ mov(R12, copied); // count arg scratched by post barrier
bs->arraycopy_epilogue(_masm, decorators, true, to, R12, R3);
// bump this on entry, not on exit:
inc_counter_np(SharedRuntime::_generic_array_copy_ctr, R5, R12);
constRegister length = R4; // elements count
__ ldr(length, Address(SP,4*pushed));
//----------------------------------------------------------------------- // Assembler stubs will be used for this call to arraycopy // if the following conditions are met: // // (1) src and dst must not be null. // (2) src_pos must not be negative. // (3) dst_pos must not be negative. // (4) length must not be negative. // (5) src klass and dst klass should be the same and not NULL. // (6) src and dst should be arrays. // (7) src_pos + length must not exceed length of src. // (8) dst_pos + length must not exceed length of dst.
BLOCK_COMMENT("arraycopy initial argument checks");
// if (src == NULL) return -1;
__ cbz(src, L_failed);
// next registers should be set before the jump to corresponding stub constRegister from = R0; // source array address constRegister to = R1; // destination array address constRegister count = R2; // elements count
// 'from', 'to', 'count' registers should be set in this order // since they are the same as 'src', 'src_pos', 'dst'.
// ObjArrayKlass
__ BIND(L_objArray); // live at this point: R5_src_klass, R6_dst_klass, src[_pos], dst[_pos], length
Label L_plain_copy, L_checkcast_copy; // test array classes for subtyping
__ cmp(R5_src_klass, R6_dst_klass); // usual case is exact equality
__ b(L_checkcast_copy, ne);
BLOCK_COMMENT("Identically typed arrays");
{ // Identically typed arrays can be copied without element-wise checks.
arraycopy_range_checks(src, src_pos, dst, dst_pos, length,
R8_temp, R_lh, L_failed);
// next registers should be set before the jump to corresponding stub constRegister from = R0; // source array address constRegister to = R1; // destination array address constRegister count = R2; // elements count
__ pop(saved_regs); // XXX optim: avoid later push in oop_arraycopy ?
__ b(StubRoutines::_oop_arraycopy);
}
{
__ BIND(L_checkcast_copy); // live at this point: R5_src_klass, R6_dst_klass
// Before looking at dst.length, make sure dst is also an objArray.
__ ldr_u32(R8_temp, Address(R6_dst_klass, lh_offset));
__ cmp_32(R_lh, R8_temp);
__ b(L_failed, ne);
// It is safe to examine both src.length and dst.length.
// next registers should be set before the jump to corresponding stub constRegister from = R0; // source array address constRegister to = R1; // destination array address constRegister count = R2; // elements count
Register sco_temp = R3; // this register is free now
assert_different_registers(from, to, count, sco_temp,
R6_dst_klass, R5_src_klass);
// Generate the type check. int sco_offset = in_bytes(Klass::super_check_offset_offset());
__ ldr_u32(sco_temp, Address(R6_dst_klass, sco_offset));
generate_type_check(R5_src_klass, sco_temp, R6_dst_klass,
R8_temp, R9,
R12,
L_plain_copy);
// Fetch destination element klass from the ObjArrayKlass header. int ek_offset = in_bytes(ObjArrayKlass::element_klass_offset());
// the checkcast_copy loop needs two extra arguments: constRegister Rdst_elem_klass = R3;
__ ldr(Rdst_elem_klass, Address(R6_dst_klass, ek_offset)); // dest elem klass
__ pop(saved_regs); // XXX optim: avoid later push in oop_arraycopy ?
__ str(Rdst_elem_klass, Address(SP,0)); // dest elem klass argument
__ ldr_u32(R3, Address(Rdst_elem_klass, sco_offset)); // sco of elem klass
__ b(StubRoutines::_checkcast_arraycopy);
}
// Note: the disjoint stubs must be generated first, some of // the conjoint stubs use them.
bool status = false; // non failing C2 stubs need not return a status in R0
#ifdef TEST_C2_GENERIC_ARRAYCOPY /* Internal development flag */ // With this flag, the C2 stubs are tested by generating calls to // generic_arraycopy instead of Runtime1::arraycopy
// Runtime1::arraycopy return a status in R0 (0 if OK, else ~copied) // and the result is tested to see whether the arraycopy stub should // be called.
// When we test arraycopy this way, we must generate extra code in the // arraycopy methods callable from C2 generic_arraycopy to set the // status to 0 for those who always succeed (calling the slow path stub might // lead to errors since the copy has already been performed).
status = true; // generate a status compatible with C1 calls #endif
//------------------------------------------------------------------------------------------------------------------------ // Continuation point for throwing of implicit exceptions that are not handled in // the current activation. Fabricates an exception oop and initiates normal // exception dispatching in this frame.
address generate_throw_exception(constchar* name, address runtime_entry) { int insts_size = 128; int locs_size = 32;
CodeBuffer code(name, insts_size, locs_size);
OopMapSet* oop_maps; int frame_size; int frame_complete;
oop_maps = new OopMapSet();
MacroAssembler* masm = new MacroAssembler(&code);
// For c2: c_rarg0 is junk, call to runtime to write a checkpoint. // It returns a jobject handle to the event writer. // The handle is dereferenced and the return value is the event writer oop. static RuntimeStub* generate_jfr_write_checkpoint() { enum layout {
r1_off,
r2_off,
return_off,
framesize // inclusive of return address
};
CodeBuffer code("jfr_write_checkpoint", 512, 64);
MacroAssembler* masm = new MacroAssembler(&code);
void generate_initial() { // Generates all stubs and initializes the entry points
//------------------------------------------------------------------------------------------------------------------------ // entry points that exist in all platforms // Note: This is code that could be shared among different platforms - however the benefit seems to be smaller than // the disadvantage of having a much more complicated generator structure. See also comment in stubRoutines.hpp.
StubRoutines::_forward_exception_entry = generate_forward_exception();
StubRoutines::_call_stub_entry =
generate_call_stub(StubRoutines::_call_stub_return_address); // is referenced by megamorphic call
StubRoutines::_catch_exception_entry = generate_catch_exception();
// stub for throwing stack overflow error used both by interpreter and compiler
StubRoutines::_throw_StackOverflowError_entry = generate_throw_exception("StackOverflowError throw_exception", CAST_FROM_FN_PTR(address, SharedRuntime::throw_StackOverflowError));
// integer division used both by interpreter and compiler
StubRoutines::Arm::_idiv_irem_entry = generate_idiv_irem();
void generate_all() { // Generates all stubs and initializes the entry points
#ifdef COMPILER2 // Generate partial_subtype_check first here since its code depends on // UseZeroBaseCompressedOops which is defined after heap initialization.
StubRoutines::Arm::_partial_subtype_check = generate_partial_subtype_check(); #endif // These entry points require SharedInfo::stack0 to be set up in non-core builds // and need to be relocatable, so they each fabricate a RuntimeStub internally.
StubRoutines::_throw_AbstractMethodError_entry = generate_throw_exception("AbstractMethodError throw_exception", CAST_FROM_FN_PTR(address, SharedRuntime::throw_AbstractMethodError));
StubRoutines::_throw_IncompatibleClassChangeError_entry= generate_throw_exception("IncompatibleClassChangeError throw_exception", CAST_FROM_FN_PTR(address, SharedRuntime::throw_IncompatibleClassChangeError));
StubRoutines::_throw_NullPointerException_at_call_entry= generate_throw_exception("NullPointerException at call throw_exception", CAST_FROM_FN_PTR(address, SharedRuntime::throw_NullPointerException_at_call));
//------------------------------------------------------------------------------------------------------------------------ // entry points that are platform specific
// support for verify_oop (must happen after universe_init)
StubRoutines::_verify_oop_subroutine_entry = generate_verify_oop();
// arraycopy stubs used by compilers
generate_arraycopy_stubs();
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.