annotate src/share/vm/utilities/copy.cpp @ 1603:d93949c5bdcc

6730276: JDI_REGRESSION tests fail with "Error: count must be non-zero" error on x86 Summary: Modify assembler code to check for 0 count for all copy routines. Reviewed-by: never, ysr, jcoomes
author kvn
date Thu, 10 Jun 2010 13:04:20 -0700
parents c18cbe5936b8
children f95d63e2154a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
2 * Copyright (c) 2006, 2007, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
a61af66fc99e Initial load
duke
parents:
diff changeset
25 # include "incls/_precompiled.incl"
a61af66fc99e Initial load
duke
parents:
diff changeset
26 # include "incls/_copy.cpp.incl"
a61af66fc99e Initial load
duke
parents:
diff changeset
27
a61af66fc99e Initial load
duke
parents:
diff changeset
28
a61af66fc99e Initial load
duke
parents:
diff changeset
29 // Copy bytes; larger units are filled atomically if everything is aligned.
a61af66fc99e Initial load
duke
parents:
diff changeset
30 void Copy::conjoint_memory_atomic(void* from, void* to, size_t size) {
a61af66fc99e Initial load
duke
parents:
diff changeset
31 address src = (address) from;
a61af66fc99e Initial load
duke
parents:
diff changeset
32 address dst = (address) to;
a61af66fc99e Initial load
duke
parents:
diff changeset
33 uintptr_t bits = (uintptr_t) src | (uintptr_t) dst | (uintptr_t) size;
a61af66fc99e Initial load
duke
parents:
diff changeset
34
a61af66fc99e Initial load
duke
parents:
diff changeset
35 // (Note: We could improve performance by ignoring the low bits of size,
a61af66fc99e Initial load
duke
parents:
diff changeset
36 // and putting a short cleanup loop after each bulk copy loop.
a61af66fc99e Initial load
duke
parents:
diff changeset
37 // There are plenty of other ways to make this faster also,
a61af66fc99e Initial load
duke
parents:
diff changeset
38 // and it's a slippery slope. For now, let's keep this code simple
a61af66fc99e Initial load
duke
parents:
diff changeset
39 // since the simplicity helps clarify the atomicity semantics of
a61af66fc99e Initial load
duke
parents:
diff changeset
40 // this operation. There are also CPU-specific assembly versions
a61af66fc99e Initial load
duke
parents:
diff changeset
41 // which may or may not want to include such optimizations.)
a61af66fc99e Initial load
duke
parents:
diff changeset
42
a61af66fc99e Initial load
duke
parents:
diff changeset
43 if (bits % sizeof(jlong) == 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
44 Copy::conjoint_jlongs_atomic((jlong*) src, (jlong*) dst, size / sizeof(jlong));
a61af66fc99e Initial load
duke
parents:
diff changeset
45 } else if (bits % sizeof(jint) == 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
46 Copy::conjoint_jints_atomic((jint*) src, (jint*) dst, size / sizeof(jint));
a61af66fc99e Initial load
duke
parents:
diff changeset
47 } else if (bits % sizeof(jshort) == 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
48 Copy::conjoint_jshorts_atomic((jshort*) src, (jshort*) dst, size / sizeof(jshort));
a61af66fc99e Initial load
duke
parents:
diff changeset
49 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
50 // Not aligned, so no need to be atomic.
1603
d93949c5bdcc 6730276: JDI_REGRESSION tests fail with "Error: count must be non-zero" error on x86
kvn
parents: 1552
diff changeset
51 Copy::conjoint_jbytes((void*) src, (void*) dst, size);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
52 }
a61af66fc99e Initial load
duke
parents:
diff changeset
53 }
a61af66fc99e Initial load
duke
parents:
diff changeset
54
a61af66fc99e Initial load
duke
parents:
diff changeset
55
a61af66fc99e Initial load
duke
parents:
diff changeset
56 // Fill bytes; larger units are filled atomically if everything is aligned.
a61af66fc99e Initial load
duke
parents:
diff changeset
57 void Copy::fill_to_memory_atomic(void* to, size_t size, jubyte value) {
a61af66fc99e Initial load
duke
parents:
diff changeset
58 address dst = (address) to;
a61af66fc99e Initial load
duke
parents:
diff changeset
59 uintptr_t bits = (uintptr_t) to | (uintptr_t) size;
a61af66fc99e Initial load
duke
parents:
diff changeset
60 if (bits % sizeof(jlong) == 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
61 jlong fill = (julong)( (jubyte)value ); // zero-extend
a61af66fc99e Initial load
duke
parents:
diff changeset
62 if (fill != 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
63 fill += fill << 8;
a61af66fc99e Initial load
duke
parents:
diff changeset
64 fill += fill << 16;
a61af66fc99e Initial load
duke
parents:
diff changeset
65 fill += fill << 32;
a61af66fc99e Initial load
duke
parents:
diff changeset
66 }
a61af66fc99e Initial load
duke
parents:
diff changeset
67 //Copy::fill_to_jlongs_atomic((jlong*) dst, size / sizeof(jlong));
a61af66fc99e Initial load
duke
parents:
diff changeset
68 for (uintptr_t off = 0; off < size; off += sizeof(jlong)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
69 *(jlong*)(dst + off) = fill;
a61af66fc99e Initial load
duke
parents:
diff changeset
70 }
a61af66fc99e Initial load
duke
parents:
diff changeset
71 } else if (bits % sizeof(jint) == 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
72 jint fill = (juint)( (jubyte)value ); // zero-extend
a61af66fc99e Initial load
duke
parents:
diff changeset
73 if (fill != 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
74 fill += fill << 8;
a61af66fc99e Initial load
duke
parents:
diff changeset
75 fill += fill << 16;
a61af66fc99e Initial load
duke
parents:
diff changeset
76 }
a61af66fc99e Initial load
duke
parents:
diff changeset
77 //Copy::fill_to_jints_atomic((jint*) dst, size / sizeof(jint));
a61af66fc99e Initial load
duke
parents:
diff changeset
78 for (uintptr_t off = 0; off < size; off += sizeof(jint)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
79 *(jint*)(dst + off) = fill;
a61af66fc99e Initial load
duke
parents:
diff changeset
80 }
a61af66fc99e Initial load
duke
parents:
diff changeset
81 } else if (bits % sizeof(jshort) == 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
82 jshort fill = (jushort)( (jubyte)value ); // zero-extend
a61af66fc99e Initial load
duke
parents:
diff changeset
83 fill += fill << 8;
a61af66fc99e Initial load
duke
parents:
diff changeset
84 //Copy::fill_to_jshorts_atomic((jshort*) dst, size / sizeof(jshort));
a61af66fc99e Initial load
duke
parents:
diff changeset
85 for (uintptr_t off = 0; off < size; off += sizeof(jshort)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
86 *(jshort*)(dst + off) = fill;
a61af66fc99e Initial load
duke
parents:
diff changeset
87 }
a61af66fc99e Initial load
duke
parents:
diff changeset
88 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
89 // Not aligned, so no need to be atomic.
a61af66fc99e Initial load
duke
parents:
diff changeset
90 Copy::fill_to_bytes(dst, size, value);
a61af66fc99e Initial load
duke
parents:
diff changeset
91 }
a61af66fc99e Initial load
duke
parents:
diff changeset
92 }