Path: blob/master/src/hotspot/os_cpu/linux_aarch64/copy_linux_aarch64.hpp
41144 views
/*1* Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.2* Copyright (c) 2014, Red Hat Inc. All rights reserved.3* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.4*5* This code is free software; you can redistribute it and/or modify it6* under the terms of the GNU General Public License version 2 only, as7* published by the Free Software Foundation.8*9* This code is distributed in the hope that it will be useful, but WITHOUT10* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or11* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License12* version 2 for more details (a copy is included in the LICENSE file that13* accompanied this code).14*15* You should have received a copy of the GNU General Public License version16* 2 along with this work; if not, write to the Free Software Foundation,17* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.18*19* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA20* or visit www.oracle.com if you need additional information or have any21* questions.22*23*/2425#ifndef OS_CPU_LINUX_AARCH64_COPY_LINUX_AARCH64_HPP26#define OS_CPU_LINUX_AARCH64_COPY_LINUX_AARCH64_HPP2728#define COPY_SMALL(from, to, count) \29{ \30long tmp0, tmp1, tmp2, tmp3; \31long tmp4, tmp5, tmp6, tmp7; \32__asm volatile( \33" adr %[t0], 0f;" \34" add %[t0], %[t0], %[cnt], lsl #5;" \35" br %[t0];" \36" .align 5;" \37"0:" \38" b 1f;" \39" .align 5;" \40" ldr %[t0], [%[s], #0];" \41" str %[t0], [%[d], #0];" \42" b 1f;" \43" .align 5;" \44" ldp %[t0], %[t1], [%[s], #0];" \45" stp %[t0], %[t1], [%[d], #0];" \46" b 1f;" \47" .align 5;" \48" ldp %[t0], %[t1], [%[s], #0];" \49" ldr %[t2], [%[s], #16];" \50" stp %[t0], %[t1], [%[d], #0];" \51" str %[t2], [%[d], #16];" \52" b 1f;" \53" .align 5;" \54" ldp %[t0], %[t1], [%[s], #0];" \55" ldp %[t2], %[t3], [%[s], #16];" \56" stp %[t0], %[t1], [%[d], #0];" \57" stp %[t2], %[t3], [%[d], #16];" \58" b 1f;" \59" .align 5;" \60" ldp %[t0], %[t1], [%[s], #0];" \61" ldp %[t2], %[t3], [%[s], #16];" \62" ldr %[t4], [%[s], #32];" \63" stp %[t0], %[t1], [%[d], #0];" \64" stp %[t2], %[t3], [%[d], #16];" \65" str %[t4], [%[d], #32];" \66" b 1f;" \67" .align 5;" \68" ldp %[t0], %[t1], [%[s], #0];" \69" ldp %[t2], %[t3], [%[s], #16];" \70" ldp %[t4], %[t5], [%[s], #32];" \71"2:" \72" stp %[t0], %[t1], [%[d], #0];" \73" stp %[t2], %[t3], [%[d], #16];" \74" stp %[t4], %[t5], [%[d], #32];" \75" b 1f;" \76" .align 5;" \77" ldr %[t6], [%[s], #0];" \78" ldp %[t0], %[t1], [%[s], #8];" \79" ldp %[t2], %[t3], [%[s], #24];" \80" ldp %[t4], %[t5], [%[s], #40];" \81" str %[t6], [%[d]], #8;" \82" b 2b;" \83" .align 5;" \84" ldp %[t0], %[t1], [%[s], #0];" \85" ldp %[t2], %[t3], [%[s], #16];" \86" ldp %[t4], %[t5], [%[s], #32];" \87" ldp %[t6], %[t7], [%[s], #48];" \88" stp %[t0], %[t1], [%[d], #0];" \89" stp %[t2], %[t3], [%[d], #16];" \90" stp %[t4], %[t5], [%[d], #32];" \91" stp %[t6], %[t7], [%[d], #48];" \92"1:" \93\94: [s]"+r"(from), [d]"+r"(to), [cnt]"+r"(count), \95[t0]"=&r"(tmp0), [t1]"=&r"(tmp1), [t2]"=&r"(tmp2), [t3]"=&r"(tmp3), \96[t4]"=&r"(tmp4), [t5]"=&r"(tmp5), [t6]"=&r"(tmp6), [t7]"=&r"(tmp7) \97: \98: "memory", "cc"); \99}100101static void pd_conjoint_words(const HeapWord* from, HeapWord* to, size_t count) {102__asm volatile( "prfm pldl1strm, [%[s], #0];" :: [s]"r"(from) : "memory");103if (__builtin_expect(count <= 8, 1)) {104COPY_SMALL(from, to, count);105return;106}107_Copy_conjoint_words(from, to, count);108}109110static void pd_disjoint_words(const HeapWord* from, HeapWord* to, size_t count) {111if (__builtin_constant_p(count)) {112memcpy(to, from, count * sizeof(HeapWord));113return;114}115__asm volatile( "prfm pldl1strm, [%[s], #0];" :: [s]"r"(from) : "memory");116if (__builtin_expect(count <= 8, 1)) {117COPY_SMALL(from, to, count);118return;119}120_Copy_disjoint_words(from, to, count);121}122123static void pd_disjoint_words_atomic(const HeapWord* from, HeapWord* to, size_t count) {124__asm volatile( "prfm pldl1strm, [%[s], #0];" :: [s]"r"(from) : "memory");125if (__builtin_expect(count <= 8, 1)) {126COPY_SMALL(from, to, count);127return;128}129_Copy_disjoint_words(from, to, count);130}131132static void pd_aligned_conjoint_words(const HeapWord* from, HeapWord* to, size_t count) {133pd_conjoint_words(from, to, count);134}135136static void pd_aligned_disjoint_words(const HeapWord* from, HeapWord* to, size_t count) {137pd_disjoint_words(from, to, count);138}139140static void pd_conjoint_bytes(const void* from, void* to, size_t count) {141(void)memmove(to, from, count);142}143144static void pd_conjoint_bytes_atomic(const void* from, void* to, size_t count) {145pd_conjoint_bytes(from, to, count);146}147148static void pd_conjoint_jshorts_atomic(const jshort* from, jshort* to, size_t count) {149_Copy_conjoint_jshorts_atomic(from, to, count);150}151152static void pd_conjoint_jints_atomic(const jint* from, jint* to, size_t count) {153_Copy_conjoint_jints_atomic(from, to, count);154}155156static void pd_conjoint_jlongs_atomic(const jlong* from, jlong* to, size_t count) {157_Copy_conjoint_jlongs_atomic(from, to, count);158}159160static void pd_conjoint_oops_atomic(const oop* from, oop* to, size_t count) {161assert(BytesPerLong == BytesPerOop, "jlongs and oops must be the same size");162_Copy_conjoint_jlongs_atomic((const jlong*)from, (jlong*)to, count);163}164165static void pd_arrayof_conjoint_bytes(const HeapWord* from, HeapWord* to, size_t count) {166_Copy_arrayof_conjoint_bytes(from, to, count);167}168169static void pd_arrayof_conjoint_jshorts(const HeapWord* from, HeapWord* to, size_t count) {170_Copy_arrayof_conjoint_jshorts(from, to, count);171}172173static void pd_arrayof_conjoint_jints(const HeapWord* from, HeapWord* to, size_t count) {174_Copy_arrayof_conjoint_jints(from, to, count);175}176177static void pd_arrayof_conjoint_jlongs(const HeapWord* from, HeapWord* to, size_t count) {178_Copy_arrayof_conjoint_jlongs(from, to, count);179}180181static void pd_arrayof_conjoint_oops(const HeapWord* from, HeapWord* to, size_t count) {182assert(!UseCompressedOops, "foo!");183assert(BytesPerLong == BytesPerOop, "jlongs and oops must be the same size");184_Copy_arrayof_conjoint_jlongs(from, to, count);185}186187#endif // OS_CPU_LINUX_AARCH64_COPY_LINUX_AARCH64_HPP188189190