never@1445: /* stefank@2314: * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. never@1445: * Copyright 2007 Red Hat, Inc. never@1445: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. never@1445: * never@1445: * This code is free software; you can redistribute it and/or modify it never@1445: * under the terms of the GNU General Public License version 2 only, as never@1445: * published by the Free Software Foundation. never@1445: * never@1445: * This code is distributed in the hope that it will be useful, but WITHOUT never@1445: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or never@1445: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License never@1445: * version 2 for more details (a copy is included in the LICENSE file that never@1445: * accompanied this code). never@1445: * never@1445: * You should have received a copy of the GNU General Public License version never@1445: * 2 along with this work; if not, write to the Free Software Foundation, never@1445: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. never@1445: * trims@1907: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA trims@1907: * or visit www.oracle.com if you need additional information or have any trims@1907: * questions. never@1445: * never@1445: */ never@1445: stefank@2314: #ifndef CPU_ZERO_VM_COPY_ZERO_HPP stefank@2314: #define CPU_ZERO_VM_COPY_ZERO_HPP stefank@2314: never@1445: // Inline functions for memory copy and fill. never@1445: never@1445: static void pd_conjoint_words(HeapWord* from, HeapWord* to, size_t count) { never@1445: memmove(to, from, count * HeapWordSize); never@1445: } never@1445: never@1445: static void pd_disjoint_words(HeapWord* from, HeapWord* to, size_t count) { never@1445: switch (count) { never@1445: case 8: to[7] = from[7]; never@1445: case 7: to[6] = from[6]; never@1445: case 6: to[5] = from[5]; never@1445: case 5: to[4] = from[4]; never@1445: case 4: to[3] = from[3]; never@1445: case 3: to[2] = from[2]; never@1445: case 2: to[1] = from[1]; never@1445: case 1: to[0] = from[0]; never@1445: case 0: break; never@1445: default: never@1445: memcpy(to, from, count * HeapWordSize); never@1445: break; never@1445: } never@1445: } never@1445: never@1445: static void pd_disjoint_words_atomic(HeapWord* from, never@1445: HeapWord* to, never@1445: size_t count) { never@1445: switch (count) { never@1445: case 8: to[7] = from[7]; never@1445: case 7: to[6] = from[6]; never@1445: case 6: to[5] = from[5]; never@1445: case 5: to[4] = from[4]; never@1445: case 4: to[3] = from[3]; never@1445: case 3: to[2] = from[2]; never@1445: case 2: to[1] = from[1]; never@1445: case 1: to[0] = from[0]; never@1445: case 0: break; never@1445: default: never@1445: while (count-- > 0) { never@1445: *to++ = *from++; never@1445: } never@1445: break; never@1445: } never@1445: } never@1445: never@1445: static void pd_aligned_conjoint_words(HeapWord* from, never@1445: HeapWord* to, never@1445: size_t count) { never@1445: memmove(to, from, count * HeapWordSize); never@1445: } never@1445: never@1445: static void pd_aligned_disjoint_words(HeapWord* from, never@1445: HeapWord* to, never@1445: size_t count) { never@1445: pd_disjoint_words(from, to, count); never@1445: } never@1445: never@1445: static void pd_conjoint_bytes(void* from, void* to, size_t count) { never@1445: memmove(to, from, count); never@1445: } never@1445: never@1445: static void pd_conjoint_bytes_atomic(void* from, void* to, size_t count) { never@1445: memmove(to, from, count); never@1445: } never@1445: never@1445: static void pd_conjoint_jshorts_atomic(jshort* from, jshort* to, size_t count) { never@1445: _Copy_conjoint_jshorts_atomic(from, to, count); never@1445: } never@1445: never@1445: static void pd_conjoint_jints_atomic(jint* from, jint* to, size_t count) { never@1445: _Copy_conjoint_jints_atomic(from, to, count); never@1445: } never@1445: never@1445: static void pd_conjoint_jlongs_atomic(jlong* from, jlong* to, size_t count) { never@1445: _Copy_conjoint_jlongs_atomic(from, to, count); never@1445: } never@1445: never@1445: static void pd_conjoint_oops_atomic(oop* from, oop* to, size_t count) { never@1445: #ifdef _LP64 never@1445: assert(BytesPerLong == BytesPerOop, "jlongs and oops must be the same size"); never@1445: _Copy_conjoint_jlongs_atomic((jlong*)from, (jlong*)to, count); never@1445: #else never@1445: assert(BytesPerInt == BytesPerOop, "jints and oops must be the same size"); never@1445: _Copy_conjoint_jints_atomic((jint*)from, (jint*)to, count); never@1445: #endif // _LP64 never@1445: } never@1445: never@1445: static void pd_arrayof_conjoint_bytes(HeapWord* from, never@1445: HeapWord* to, never@1445: size_t count) { never@1445: _Copy_arrayof_conjoint_bytes(from, to, count); never@1445: } never@1445: never@1445: static void pd_arrayof_conjoint_jshorts(HeapWord* from, never@1445: HeapWord* to, never@1445: size_t count) { never@1445: _Copy_arrayof_conjoint_jshorts(from, to, count); never@1445: } never@1445: never@1445: static void pd_arrayof_conjoint_jints(HeapWord* from, never@1445: HeapWord* to, never@1445: size_t count) { never@1445: _Copy_arrayof_conjoint_jints(from, to, count); never@1445: } never@1445: never@1445: static void pd_arrayof_conjoint_jlongs(HeapWord* from, never@1445: HeapWord* to, never@1445: size_t count) { never@1445: _Copy_arrayof_conjoint_jlongs(from, to, count); never@1445: } never@1445: never@1445: static void pd_arrayof_conjoint_oops(HeapWord* from, never@1445: HeapWord* to, never@1445: size_t count) { never@1445: #ifdef _LP64 never@1445: assert(BytesPerLong == BytesPerOop, "jlongs and oops must be the same size"); never@1445: _Copy_arrayof_conjoint_jlongs(from, to, count); never@1445: #else never@1445: assert(BytesPerInt == BytesPerOop, "jints and oops must be the same size"); never@1445: _Copy_arrayof_conjoint_jints(from, to, count); never@1445: #endif // _LP64 never@1445: } never@1445: never@1445: static void pd_fill_to_words(HeapWord* tohw, size_t count, juint value) { never@1445: #ifdef _LP64 never@1445: julong* to = (julong*) tohw; never@1445: julong v = ((julong) value << 32) | value; never@1445: #else never@1445: juint* to = (juint*) tohw; never@1445: juint v = value; never@1445: #endif // _LP64 never@1445: never@1445: while (count-- > 0) { never@1445: *to++ = v; never@1445: } never@1445: } never@1445: never@1445: static void pd_fill_to_aligned_words(HeapWord* tohw, never@1445: size_t count, never@1445: juint value) { never@1445: pd_fill_to_words(tohw, count, value); never@1445: } never@1445: never@1445: static void pd_fill_to_bytes(void* to, size_t count, jubyte value) { never@1445: memset(to, value, count); never@1445: } never@1445: never@1445: static void pd_zero_to_words(HeapWord* tohw, size_t count) { never@1445: pd_fill_to_words(tohw, count, 0); never@1445: } never@1445: never@1445: static void pd_zero_to_bytes(void* to, size_t count) { never@1445: memset(to, 0, count); never@1445: } stefank@2314: stefank@2314: #endif // CPU_ZERO_VM_COPY_ZERO_HPP