Path: blob/master/src/hotspot/os_cpu/bsd_aarch64/copy_bsd_aarch64.hpp
40930 views
/*1* Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved.2* Copyright (c) 2014, Red Hat Inc. All rights reserved.3* Copyright (c) 2021, Azul Systems, Inc. All rights reserved.4* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.5*6* This code is free software; you can redistribute it and/or modify it7* under the terms of the GNU General Public License version 2 only, as8* published by the Free Software Foundation.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*24*/2526#ifndef OS_CPU_BSD_AARCH64_COPY_BSD_AARCH64_HPP27#define OS_CPU_BSD_AARCH64_COPY_BSD_AARCH64_HPP2829#define COPY_SMALL(from, to, count) \30{ \31long tmp0, tmp1, tmp2, tmp3; \32long tmp4, tmp5, tmp6, tmp7; \33__asm volatile( \34" adr %[t0], 0f;\n" \35" add %[t0], %[t0], %[cnt], lsl #5;\n" \36" br %[t0];\n" \37" .align 5;\n" \38"0:" \39" b 1f;\n" \40" .align 5;\n" \41" ldr %[t0], [%[s], #0];\n" \42" str %[t0], [%[d], #0];\n" \43" b 1f;\n" \44" .align 5;\n" \45" ldp %[t0], %[t1], [%[s], #0];\n" \46" stp %[t0], %[t1], [%[d], #0];\n" \47" b 1f;\n" \48" .align 5;\n" \49" ldp %[t0], %[t1], [%[s], #0];\n" \50" ldr %[t2], [%[s], #16];\n" \51" stp %[t0], %[t1], [%[d], #0];\n" \52" str %[t2], [%[d], #16];\n" \53" b 1f;\n" \54" .align 5;\n" \55" ldp %[t0], %[t1], [%[s], #0];\n" \56" ldp %[t2], %[t3], [%[s], #16];\n" \57" stp %[t0], %[t1], [%[d], #0];\n" \58" stp %[t2], %[t3], [%[d], #16];\n" \59" b 1f;\n" \60" .align 5;\n" \61" ldp %[t0], %[t1], [%[s], #0];\n" \62" ldp %[t2], %[t3], [%[s], #16];\n" \63" ldr %[t4], [%[s], #32];\n" \64" stp %[t0], %[t1], [%[d], #0];\n" \65" stp %[t2], %[t3], [%[d], #16];\n" \66" str %[t4], [%[d], #32];\n" \67" b 1f;\n" \68" .align 5;\n" \69" ldp %[t0], %[t1], [%[s], #0];\n" \70" ldp %[t2], %[t3], [%[s], #16];\n" \71" ldp %[t4], %[t5], [%[s], #32];\n" \72"2:" \73" stp %[t0], %[t1], [%[d], #0];\n" \74" stp %[t2], %[t3], [%[d], #16];\n" \75" stp %[t4], %[t5], [%[d], #32];\n" \76" b 1f;\n" \77" .align 5;\n" \78" ldr %[t6], [%[s], #0];\n" \79" ldp %[t0], %[t1], [%[s], #8];\n" \80" ldp %[t2], %[t3], [%[s], #24];\n" \81" ldp %[t4], %[t5], [%[s], #40];\n" \82" str %[t6], [%[d]], #8;\n" \83" b 2b;\n" \84" .align 5;\n" \85" ldp %[t0], %[t1], [%[s], #0];\n" \86" ldp %[t2], %[t3], [%[s], #16];\n" \87" ldp %[t4], %[t5], [%[s], #32];\n" \88" ldp %[t6], %[t7], [%[s], #48];\n" \89" stp %[t0], %[t1], [%[d], #0];\n" \90" stp %[t2], %[t3], [%[d], #16];\n" \91" stp %[t4], %[t5], [%[d], #32];\n" \92" stp %[t6], %[t7], [%[d], #48];\n" \93"1:" \94\95: [s]"+r"(from), [d]"+r"(to), [cnt]"+r"(count), \96[t0]"=&r"(tmp0), [t1]"=&r"(tmp1), [t2]"=&r"(tmp2), [t3]"=&r"(tmp3), \97[t4]"=&r"(tmp4), [t5]"=&r"(tmp5), [t6]"=&r"(tmp6), [t7]"=&r"(tmp7) \98: \99: "memory", "cc"); \100}101102static void pd_conjoint_words(const HeapWord* from, HeapWord* to, size_t count) {103__asm volatile( "prfm pldl1strm, [%[s], #0];" :: [s]"r"(from) : "memory");104if (__builtin_expect(count <= 8, 1)) {105COPY_SMALL(from, to, count);106return;107}108_Copy_conjoint_words(from, to, count);109}110111static void pd_disjoint_words(const HeapWord* from, HeapWord* to, size_t count) {112if (__builtin_constant_p(count)) {113memcpy(to, from, count * sizeof(HeapWord));114return;115}116__asm volatile( "prfm pldl1strm, [%[s], #0];" :: [s]"r"(from) : "memory");117if (__builtin_expect(count <= 8, 1)) {118COPY_SMALL(from, to, count);119return;120}121_Copy_disjoint_words(from, to, count);122}123124static void pd_disjoint_words_atomic(const HeapWord* from, HeapWord* to, size_t count) {125__asm volatile( "prfm pldl1strm, [%[s], #0];" :: [s]"r"(from) : "memory");126if (__builtin_expect(count <= 8, 1)) {127COPY_SMALL(from, to, count);128return;129}130_Copy_disjoint_words(from, to, count);131}132133static void pd_aligned_conjoint_words(const HeapWord* from, HeapWord* to, size_t count) {134pd_conjoint_words(from, to, count);135}136137static void pd_aligned_disjoint_words(const HeapWord* from, HeapWord* to, size_t count) {138pd_disjoint_words(from, to, count);139}140141static void pd_conjoint_bytes(const void* from, void* to, size_t count) {142(void)memmove(to, from, count);143}144145static void pd_conjoint_bytes_atomic(const void* from, void* to, size_t count) {146pd_conjoint_bytes(from, to, count);147}148149static void pd_conjoint_jshorts_atomic(const jshort* from, jshort* to, size_t count) {150_Copy_conjoint_jshorts_atomic(from, to, count);151}152153static void pd_conjoint_jints_atomic(const jint* from, jint* to, size_t count) {154_Copy_conjoint_jints_atomic(from, to, count);155}156157static void pd_conjoint_jlongs_atomic(const jlong* from, jlong* to, size_t count) {158_Copy_conjoint_jlongs_atomic(from, to, count);159}160161static void pd_conjoint_oops_atomic(const oop* from, oop* to, size_t count) {162assert(BytesPerLong == BytesPerOop, "jlongs and oops must be the same size");163_Copy_conjoint_jlongs_atomic((const jlong*)from, (jlong*)to, count);164}165166static void pd_arrayof_conjoint_bytes(const HeapWord* from, HeapWord* to, size_t count) {167_Copy_arrayof_conjoint_bytes(from, to, count);168}169170static void pd_arrayof_conjoint_jshorts(const HeapWord* from, HeapWord* to, size_t count) {171_Copy_arrayof_conjoint_jshorts(from, to, count);172}173174static void pd_arrayof_conjoint_jints(const HeapWord* from, HeapWord* to, size_t count) {175_Copy_arrayof_conjoint_jints(from, to, count);176}177178static void pd_arrayof_conjoint_jlongs(const HeapWord* from, HeapWord* to, size_t count) {179_Copy_arrayof_conjoint_jlongs(from, to, count);180}181182static void pd_arrayof_conjoint_oops(const HeapWord* from, HeapWord* to, size_t count) {183assert(!UseCompressedOops, "foo!");184assert(BytesPerLong == BytesPerOop, "jlongs and oops must be the same size");185_Copy_arrayof_conjoint_jlongs(from, to, count);186}187188#endif // OS_CPU_BSD_AARCH64_COPY_BSD_AARCH64_HPP189190191