annotate src/share/vm/utilities/copy.cpp @ 2177:3582bf76420e

6990754: Use native memory and reference counting to implement SymbolTable Summary: move symbols from permgen into C heap and reference count them Reviewed-by: never, acorn, jmasa, stefank
author coleenp
date Thu, 27 Jan 2011 16:11:27 -0800
parents f95d63e2154a
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1603
diff changeset
2 * Copyright (c) 2006, 2010, 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
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1603
diff changeset
25 #include "precompiled.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1603
diff changeset
26 #include "runtime/sharedRuntime.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1603
diff changeset
27 #include "utilities/copy.hpp"
0
a61af66fc99e Initial load
duke
parents:
diff changeset
28
a61af66fc99e Initial load
duke
parents:
diff changeset
29
a61af66fc99e Initial load
duke
parents:
diff changeset
30 // Copy bytes; larger units are filled atomically if everything is aligned.
a61af66fc99e Initial load
duke
parents:
diff changeset
31 void Copy::conjoint_memory_atomic(void* from, void* to, size_t size) {
a61af66fc99e Initial load
duke
parents:
diff changeset
32 address src = (address) from;
a61af66fc99e Initial load
duke
parents:
diff changeset
33 address dst = (address) to;
a61af66fc99e Initial load
duke
parents:
diff changeset
34 uintptr_t bits = (uintptr_t) src | (uintptr_t) dst | (uintptr_t) size;
a61af66fc99e Initial load
duke
parents:
diff changeset
35
a61af66fc99e Initial load
duke
parents:
diff changeset
36 // (Note: We could improve performance by ignoring the low bits of size,
a61af66fc99e Initial load
duke
parents:
diff changeset
37 // and putting a short cleanup loop after each bulk copy loop.
a61af66fc99e Initial load
duke
parents:
diff changeset
38 // There are plenty of other ways to make this faster also,
a61af66fc99e Initial load
duke
parents:
diff changeset
39 // and it's a slippery slope. For now, let's keep this code simple
a61af66fc99e Initial load
duke
parents:
diff changeset
40 // since the simplicity helps clarify the atomicity semantics of
a61af66fc99e Initial load
duke
parents:
diff changeset
41 // this operation. There are also CPU-specific assembly versions
a61af66fc99e Initial load
duke
parents:
diff changeset
42 // which may or may not want to include such optimizations.)
a61af66fc99e Initial load
duke
parents:
diff changeset
43
a61af66fc99e Initial load
duke
parents:
diff changeset
44 if (bits % sizeof(jlong) == 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
45 Copy::conjoint_jlongs_atomic((jlong*) src, (jlong*) dst, size / sizeof(jlong));
a61af66fc99e Initial load
duke
parents:
diff changeset
46 } else if (bits % sizeof(jint) == 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
47 Copy::conjoint_jints_atomic((jint*) src, (jint*) dst, size / sizeof(jint));
a61af66fc99e Initial load
duke
parents:
diff changeset
48 } else if (bits % sizeof(jshort) == 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
49 Copy::conjoint_jshorts_atomic((jshort*) src, (jshort*) dst, size / sizeof(jshort));
a61af66fc99e Initial load
duke
parents:
diff changeset
50 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
51 // 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
52 Copy::conjoint_jbytes((void*) src, (void*) dst, size);
0
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
a61af66fc99e Initial load
duke
parents:
diff changeset
57 // Fill bytes; larger units are filled atomically if everything is aligned.
a61af66fc99e Initial load
duke
parents:
diff changeset
58 void Copy::fill_to_memory_atomic(void* to, size_t size, jubyte value) {
a61af66fc99e Initial load
duke
parents:
diff changeset
59 address dst = (address) to;
a61af66fc99e Initial load
duke
parents:
diff changeset
60 uintptr_t bits = (uintptr_t) to | (uintptr_t) size;
a61af66fc99e Initial load
duke
parents:
diff changeset
61 if (bits % sizeof(jlong) == 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
62 jlong fill = (julong)( (jubyte)value ); // zero-extend
a61af66fc99e Initial load
duke
parents:
diff changeset
63 if (fill != 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
64 fill += fill << 8;
a61af66fc99e Initial load
duke
parents:
diff changeset
65 fill += fill << 16;
a61af66fc99e Initial load
duke
parents:
diff changeset
66 fill += fill << 32;
a61af66fc99e Initial load
duke
parents:
diff changeset
67 }
a61af66fc99e Initial load
duke
parents:
diff changeset
68 //Copy::fill_to_jlongs_atomic((jlong*) dst, size / sizeof(jlong));
a61af66fc99e Initial load
duke
parents:
diff changeset
69 for (uintptr_t off = 0; off < size; off += sizeof(jlong)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
70 *(jlong*)(dst + off) = fill;
a61af66fc99e Initial load
duke
parents:
diff changeset
71 }
a61af66fc99e Initial load
duke
parents:
diff changeset
72 } else if (bits % sizeof(jint) == 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
73 jint fill = (juint)( (jubyte)value ); // zero-extend
a61af66fc99e Initial load
duke
parents:
diff changeset
74 if (fill != 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
75 fill += fill << 8;
a61af66fc99e Initial load
duke
parents:
diff changeset
76 fill += fill << 16;
a61af66fc99e Initial load
duke
parents:
diff changeset
77 }
a61af66fc99e Initial load
duke
parents:
diff changeset
78 //Copy::fill_to_jints_atomic((jint*) dst, size / sizeof(jint));
a61af66fc99e Initial load
duke
parents:
diff changeset
79 for (uintptr_t off = 0; off < size; off += sizeof(jint)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
80 *(jint*)(dst + off) = fill;
a61af66fc99e Initial load
duke
parents:
diff changeset
81 }
a61af66fc99e Initial load
duke
parents:
diff changeset
82 } else if (bits % sizeof(jshort) == 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
83 jshort fill = (jushort)( (jubyte)value ); // zero-extend
a61af66fc99e Initial load
duke
parents:
diff changeset
84 fill += fill << 8;
a61af66fc99e Initial load
duke
parents:
diff changeset
85 //Copy::fill_to_jshorts_atomic((jshort*) dst, size / sizeof(jshort));
a61af66fc99e Initial load
duke
parents:
diff changeset
86 for (uintptr_t off = 0; off < size; off += sizeof(jshort)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
87 *(jshort*)(dst + off) = fill;
a61af66fc99e Initial load
duke
parents:
diff changeset
88 }
a61af66fc99e Initial load
duke
parents:
diff changeset
89 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
90 // Not aligned, so no need to be atomic.
a61af66fc99e Initial load
duke
parents:
diff changeset
91 Copy::fill_to_bytes(dst, size, value);
a61af66fc99e Initial load
duke
parents:
diff changeset
92 }
a61af66fc99e Initial load
duke
parents:
diff changeset
93 }