src/cpu/zero/vm/copy_zero.hpp

Thu, 15 Apr 2010 02:40:12 -0700

author
twisti
date
Thu, 15 Apr 2010 02:40:12 -0700
changeset 1814
f9271ff9d324
parent 1445
354d3184f6b2
child 1907
c18cbe5936b8
permissions
-rw-r--r--

6941224: Improved stack overflow handling for Zero
Summary: Adding stack overflow checking to Shark brought to light a bunch of deficiencies in Zero's stack overflow code.
Reviewed-by: twisti
Contributed-by: Gary Benson <gbenson@redhat.com>

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

mercurial