Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/cpu/sparc/vm/copy_sparc.hpp
32285 views
/*1* Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#ifndef CPU_SPARC_VM_COPY_SPARC_HPP25#define CPU_SPARC_VM_COPY_SPARC_HPP2627// Inline functions for memory copy and fill.2829static void pd_conjoint_words(HeapWord* from, HeapWord* to, size_t count) {30(void)memmove(to, from, count * HeapWordSize);31}3233static void pd_disjoint_words(HeapWord* from, HeapWord* to, size_t count) {34switch (count) {35case 8: to[7] = from[7];36case 7: to[6] = from[6];37case 6: to[5] = from[5];38case 5: to[4] = from[4];39case 4: to[3] = from[3];40case 3: to[2] = from[2];41case 2: to[1] = from[1];42case 1: to[0] = from[0];43case 0: break;44default: (void)memcpy(to, from, count * HeapWordSize);45break;46}47}4849static void pd_disjoint_words_atomic(HeapWord* from, HeapWord* to, size_t count) {50switch (count) {51case 8: to[7] = from[7];52case 7: to[6] = from[6];53case 6: to[5] = from[5];54case 5: to[4] = from[4];55case 4: to[3] = from[3];56case 3: to[2] = from[2];57case 2: to[1] = from[1];58case 1: to[0] = from[0];59case 0: break;60default: while (count-- > 0) {61*to++ = *from++;62}63break;64}65}6667static void pd_aligned_conjoint_words(HeapWord* from, HeapWord* to, size_t count) {68(void)memmove(to, from, count * HeapWordSize);69}7071static void pd_aligned_disjoint_words(HeapWord* from, HeapWord* to, size_t count) {72pd_disjoint_words(from, to, count);73}7475static void pd_conjoint_bytes(void* from, void* to, size_t count) {76(void)memmove(to, from, count);77}7879static void pd_conjoint_bytes_atomic(void* from, void* to, size_t count) {80(void)memmove(to, from, count);81}8283static void pd_conjoint_jshorts_atomic(jshort* from, jshort* to, size_t count) {84if (from > to) {85while (count-- > 0) {86// Copy forwards87*to++ = *from++;88}89} else {90from += count - 1;91to += count - 1;92while (count-- > 0) {93// Copy backwards94*to-- = *from--;95}96}97}9899static void pd_conjoint_jints_atomic(jint* from, jint* to, size_t count) {100if (from > to) {101while (count-- > 0) {102// Copy forwards103*to++ = *from++;104}105} else {106from += count - 1;107to += count - 1;108while (count-- > 0) {109// Copy backwards110*to-- = *from--;111}112}113}114115static void pd_conjoint_jlongs_atomic(jlong* from, jlong* to, size_t count) {116#ifdef _LP64117assert(BytesPerLong == BytesPerOop, "jlongs and oops must be the same size");118pd_conjoint_oops_atomic((oop*)from, (oop*)to, count);119#else120// Guarantee use of ldd/std via some asm code, because compiler won't.121// See solaris_sparc.il.122_Copy_conjoint_jlongs_atomic(from, to, count);123#endif124}125126static void pd_conjoint_oops_atomic(oop* from, oop* to, size_t count) {127// Do better than this: inline memmove body NEEDS CLEANUP128if (from > to) {129while (count-- > 0) {130// Copy forwards131*to++ = *from++;132}133} else {134from += count - 1;135to += count - 1;136while (count-- > 0) {137// Copy backwards138*to-- = *from--;139}140}141}142143static void pd_arrayof_conjoint_bytes(HeapWord* from, HeapWord* to, size_t count) {144pd_conjoint_bytes_atomic(from, to, count);145}146147static void pd_arrayof_conjoint_jshorts(HeapWord* from, HeapWord* to, size_t count) {148pd_conjoint_jshorts_atomic((jshort*)from, (jshort*)to, count);149}150151static void pd_arrayof_conjoint_jints(HeapWord* from, HeapWord* to, size_t count) {152pd_conjoint_jints_atomic((jint*)from, (jint*)to, count);153}154155static void pd_arrayof_conjoint_jlongs(HeapWord* from, HeapWord* to, size_t count) {156pd_conjoint_jlongs_atomic((jlong*)from, (jlong*)to, count);157}158159static void pd_arrayof_conjoint_oops(HeapWord* from, HeapWord* to, size_t count) {160pd_conjoint_oops_atomic((oop*)from, (oop*)to, count);161}162163static void pd_fill_to_words(HeapWord* tohw, size_t count, juint value) {164#ifdef _LP64165guarantee(mask_bits((uintptr_t)tohw, right_n_bits(LogBytesPerLong)) == 0,166"unaligned fill words");167julong* to = (julong*)tohw;168julong v = ((julong)value << 32) | value;169while (count-- > 0) {170*to++ = v;171}172#else // _LP64173juint* to = (juint*)tohw;174while (count-- > 0) {175*to++ = value;176}177#endif // _LP64178}179180typedef void (*_zero_Fn)(HeapWord* to, size_t count);181182static void pd_fill_to_aligned_words(HeapWord* tohw, size_t count, juint value) {183assert(MinObjAlignmentInBytes >= BytesPerLong, "need alternate implementation");184185if (value == 0 && UseBlockZeroing &&186(count > (size_t)(BlockZeroingLowLimit >> LogHeapWordSize))) {187// Call it only when block zeroing is used188((_zero_Fn)StubRoutines::zero_aligned_words())(tohw, count);189} else {190julong* to = (julong*)tohw;191julong v = ((julong)value << 32) | value;192// If count is odd, odd will be equal to 1 on 32-bit platform193// and be equal to 0 on 64-bit platform.194size_t odd = count % (BytesPerLong / HeapWordSize) ;195196size_t aligned_count = align_object_offset(count - odd) / HeapWordsPerLong;197julong* end = ((julong*)tohw) + aligned_count - 1;198while (to <= end) {199DEBUG_ONLY(count -= BytesPerLong / HeapWordSize ;)200*to++ = v;201}202assert(count == odd, "bad bounds on loop filling to aligned words");203if (odd) {204*((juint*)to) = value;205206}207}208}209210static void pd_fill_to_bytes(void* to, size_t count, jubyte value) {211(void)memset(to, value, count);212}213214static void pd_zero_to_words(HeapWord* tohw, size_t count) {215pd_fill_to_words(tohw, count, 0);216}217218static void pd_zero_to_bytes(void* to, size_t count) {219(void)memset(to, 0, count);220}221222#endif // CPU_SPARC_VM_COPY_SPARC_HPP223224225