src/cpu/ppc/vm/copy_ppc.hpp

Wed, 27 Nov 2013 16:16:21 -0800

author
goetz
date
Wed, 27 Nov 2013 16:16:21 -0800
changeset 6490
41b780b43b74
parent 6458
ec28f9c041ff
child 6495
67fa91961822
permissions
-rw-r--r--

8029015: PPC64 (part 216): opto: trap based null and range checks
Summary: On PPC64 use tdi instruction that does a compare and raises SIGTRAP for NULL and range checks.
Reviewed-by: kvn

goetz@6458 1 /*
goetz@6458 2 * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
goetz@6458 3 * Copyright 2012, 2013 SAP AG. All rights reserved.
goetz@6458 4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
goetz@6458 5 *
goetz@6458 6 * This code is free software; you can redistribute it and/or modify it
goetz@6458 7 * under the terms of the GNU General Public License version 2 only, as
goetz@6458 8 * published by the Free Software Foundation.
goetz@6458 9 *
goetz@6458 10 * This code is distributed in the hope that it will be useful, but WITHOUT
goetz@6458 11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
goetz@6458 12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
goetz@6458 13 * version 2 for more details (a copy is included in the LICENSE file that
goetz@6458 14 * accompanied this code).
goetz@6458 15 *
goetz@6458 16 * You should have received a copy of the GNU General Public License version
goetz@6458 17 * 2 along with this work; if not, write to the Free Software Foundation,
goetz@6458 18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
goetz@6458 19 *
goetz@6458 20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
goetz@6458 21 * or visit www.oracle.com if you need additional information or have any
goetz@6458 22 * questions.
goetz@6458 23 *
goetz@6458 24 */
goetz@6458 25
goetz@6458 26 #ifndef CPU_PPC_VM_COPY_PPC_HPP
goetz@6458 27 #define CPU_PPC_VM_COPY_PPC_HPP
goetz@6458 28
goetz@6458 29 #ifndef PPC64
goetz@6458 30 #error "copy currently only implemented for PPC64"
goetz@6458 31 #endif
goetz@6458 32
goetz@6458 33 // Inline functions for memory copy and fill.
goetz@6458 34
goetz@6458 35 static void pd_conjoint_words(HeapWord* from, HeapWord* to, size_t count) {
goetz@6458 36 (void)memmove(to, from, count * HeapWordSize);
goetz@6458 37 }
goetz@6458 38
goetz@6458 39 static void pd_disjoint_words(HeapWord* from, HeapWord* to, size_t count) {
goetz@6458 40 switch (count) {
goetz@6458 41 case 8: to[7] = from[7];
goetz@6458 42 case 7: to[6] = from[6];
goetz@6458 43 case 6: to[5] = from[5];
goetz@6458 44 case 5: to[4] = from[4];
goetz@6458 45 case 4: to[3] = from[3];
goetz@6458 46 case 3: to[2] = from[2];
goetz@6458 47 case 2: to[1] = from[1];
goetz@6458 48 case 1: to[0] = from[0];
goetz@6458 49 case 0: break;
goetz@6458 50 default: (void)memcpy(to, from, count * HeapWordSize);
goetz@6458 51 break;
goetz@6458 52 }
goetz@6458 53 }
goetz@6458 54
goetz@6458 55 static void pd_disjoint_words_atomic(HeapWord* from, HeapWord* to, size_t count) {
goetz@6458 56 switch (count) {
goetz@6458 57 case 8: to[7] = from[7];
goetz@6458 58 case 7: to[6] = from[6];
goetz@6458 59 case 6: to[5] = from[5];
goetz@6458 60 case 5: to[4] = from[4];
goetz@6458 61 case 4: to[3] = from[3];
goetz@6458 62 case 3: to[2] = from[2];
goetz@6458 63 case 2: to[1] = from[1];
goetz@6458 64 case 1: to[0] = from[0];
goetz@6458 65 case 0: break;
goetz@6458 66 default: while (count-- > 0) {
goetz@6458 67 *to++ = *from++;
goetz@6458 68 }
goetz@6458 69 break;
goetz@6458 70 }
goetz@6458 71 }
goetz@6458 72
goetz@6458 73 static void pd_aligned_conjoint_words(HeapWord* from, HeapWord* to, size_t count) {
goetz@6458 74 (void)memmove(to, from, count * HeapWordSize);
goetz@6458 75 }
goetz@6458 76
goetz@6458 77 static void pd_aligned_disjoint_words(HeapWord* from, HeapWord* to, size_t count) {
goetz@6458 78 pd_disjoint_words(from, to, count);
goetz@6458 79 }
goetz@6458 80
goetz@6458 81 static void pd_conjoint_bytes(void* from, void* to, size_t count) {
goetz@6458 82 (void)memmove(to, from, count);
goetz@6458 83 }
goetz@6458 84
goetz@6458 85 static void pd_conjoint_bytes_atomic(void* from, void* to, size_t count) {
goetz@6458 86 (void)memmove(to, from, count);
goetz@6458 87 }
goetz@6458 88
goetz@6458 89 // Template for atomic, element-wise copy.
goetz@6458 90 template <class T>
goetz@6458 91 static void copy_conjoint_atomic(T* from, T* to, size_t count) {
goetz@6458 92 if (from > to) {
goetz@6458 93 while (count-- > 0) {
goetz@6458 94 // Copy forwards
goetz@6458 95 *to++ = *from++;
goetz@6458 96 }
goetz@6458 97 } else {
goetz@6458 98 from += count - 1;
goetz@6458 99 to += count - 1;
goetz@6458 100 while (count-- > 0) {
goetz@6458 101 // Copy backwards
goetz@6458 102 *to-- = *from--;
goetz@6458 103 }
goetz@6458 104 }
goetz@6458 105 }
goetz@6458 106
goetz@6458 107 static void pd_conjoint_jshorts_atomic(jshort* from, jshort* to, size_t count) {
goetz@6458 108 copy_conjoint_atomic<jshort>(from, to, count);
goetz@6458 109 }
goetz@6458 110
goetz@6458 111 static void pd_conjoint_jints_atomic(jint* from, jint* to, size_t count) {
goetz@6458 112 copy_conjoint_atomic<jint>(from, to, count);
goetz@6458 113 }
goetz@6458 114
goetz@6458 115 static void pd_conjoint_jlongs_atomic(jlong* from, jlong* to, size_t count) {
goetz@6458 116 copy_conjoint_atomic<jlong>(from, to, count);
goetz@6458 117 }
goetz@6458 118
goetz@6458 119 static void pd_conjoint_oops_atomic(oop* from, oop* to, size_t count) {
goetz@6458 120 copy_conjoint_atomic<oop>(from, to, count);
goetz@6458 121 }
goetz@6458 122
goetz@6458 123 static void pd_arrayof_conjoint_bytes(HeapWord* from, HeapWord* to, size_t count) {
goetz@6458 124 pd_conjoint_bytes_atomic(from, to, count);
goetz@6458 125 }
goetz@6458 126
goetz@6458 127 static void pd_arrayof_conjoint_jshorts(HeapWord* from, HeapWord* to, size_t count) {
goetz@6458 128 pd_conjoint_jshorts_atomic((jshort*)from, (jshort*)to, count);
goetz@6458 129 }
goetz@6458 130
goetz@6458 131 static void pd_arrayof_conjoint_jints(HeapWord* from, HeapWord* to, size_t count) {
goetz@6458 132 pd_conjoint_jints_atomic((jint*)from, (jint*)to, count);
goetz@6458 133 }
goetz@6458 134
goetz@6458 135 static void pd_arrayof_conjoint_jlongs(HeapWord* from, HeapWord* to, size_t count) {
goetz@6458 136 pd_conjoint_jlongs_atomic((jlong*)from, (jlong*)to, count);
goetz@6458 137 }
goetz@6458 138
goetz@6458 139 static void pd_arrayof_conjoint_oops(HeapWord* from, HeapWord* to, size_t count) {
goetz@6458 140 pd_conjoint_oops_atomic((oop*)from, (oop*)to, count);
goetz@6458 141 }
goetz@6458 142
goetz@6458 143 static void pd_fill_to_words(HeapWord* tohw, size_t count, juint value) {
goetz@6458 144 julong* to = (julong*)tohw;
goetz@6458 145 julong v = ((julong)value << 32) | value;
goetz@6458 146 while (count-- > 0) {
goetz@6458 147 *to++ = v;
goetz@6458 148 }
goetz@6458 149 }
goetz@6458 150
goetz@6458 151 static void pd_fill_to_aligned_words(HeapWord* tohw, size_t count, juint value) {
goetz@6458 152 pd_fill_to_words(tohw, count, value);
goetz@6458 153 }
goetz@6458 154
goetz@6458 155 static void pd_fill_to_bytes(void* to, size_t count, jubyte value) {
goetz@6458 156 (void)memset(to, value, count);
goetz@6458 157 }
goetz@6458 158
goetz@6458 159 static void pd_zero_to_words(HeapWord* tohw, size_t count) {
goetz@6458 160 pd_fill_to_words(tohw, count, 0);
goetz@6458 161 }
goetz@6458 162
goetz@6458 163 static void pd_zero_to_bytes(void* to, size_t count) {
goetz@6458 164 (void)memset(to, 0, count);
goetz@6458 165 }
goetz@6458 166
goetz@6458 167 #endif // CPU_PPC_VM_COPY_PPC_HPP

mercurial