annotate src/cpu/sparc/vm/bytes_sparc.hpp @ 3883:ce9bde819dcb hs22-b04

7086589: bump the hs22 build number to 04 Reviewed-by: johnc Contributed-by: alejandro.murillo@oracle.com
author jcoomes
date Fri, 02 Sep 2011 03:49:30 -0700
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: 1552
diff changeset
2 * Copyright (c) 1997, 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: 1552
diff changeset
25 #ifndef CPU_SPARC_VM_BYTES_SPARC_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
26 #define CPU_SPARC_VM_BYTES_SPARC_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
27
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
28 #include "memory/allocation.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
29
0
a61af66fc99e Initial load
duke
parents:
diff changeset
30 class Bytes: AllStatic {
a61af66fc99e Initial load
duke
parents:
diff changeset
31 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
32 // Efficient reading and writing of unaligned unsigned data in platform-specific byte ordering
a61af66fc99e Initial load
duke
parents:
diff changeset
33 // Sparc needs to check for alignment.
a61af66fc99e Initial load
duke
parents:
diff changeset
34
a61af66fc99e Initial load
duke
parents:
diff changeset
35 // can I count on address always being a pointer to an unsigned char? Yes
a61af66fc99e Initial load
duke
parents:
diff changeset
36
a61af66fc99e Initial load
duke
parents:
diff changeset
37 // Returns true, if the byte ordering used by Java is different from the nativ byte ordering
a61af66fc99e Initial load
duke
parents:
diff changeset
38 // of the underlying machine. For example, true for Intel x86, False, for Solaris on Sparc.
a61af66fc99e Initial load
duke
parents:
diff changeset
39 static inline bool is_Java_byte_ordering_different() { return false; }
a61af66fc99e Initial load
duke
parents:
diff changeset
40
a61af66fc99e Initial load
duke
parents:
diff changeset
41 // Thus, a swap between native and Java ordering is always a no-op:
a61af66fc99e Initial load
duke
parents:
diff changeset
42 static inline u2 swap_u2(u2 x) { return x; }
a61af66fc99e Initial load
duke
parents:
diff changeset
43 static inline u4 swap_u4(u4 x) { return x; }
a61af66fc99e Initial load
duke
parents:
diff changeset
44 static inline u8 swap_u8(u8 x) { return x; }
a61af66fc99e Initial load
duke
parents:
diff changeset
45
a61af66fc99e Initial load
duke
parents:
diff changeset
46 static inline u2 get_native_u2(address p){
a61af66fc99e Initial load
duke
parents:
diff changeset
47 return (intptr_t(p) & 1) == 0
a61af66fc99e Initial load
duke
parents:
diff changeset
48 ? *(u2*)p
a61af66fc99e Initial load
duke
parents:
diff changeset
49 : ( u2(p[0]) << 8 )
a61af66fc99e Initial load
duke
parents:
diff changeset
50 | ( u2(p[1]) );
a61af66fc99e Initial load
duke
parents:
diff changeset
51 }
a61af66fc99e Initial load
duke
parents:
diff changeset
52
a61af66fc99e Initial load
duke
parents:
diff changeset
53 static inline u4 get_native_u4(address p) {
a61af66fc99e Initial load
duke
parents:
diff changeset
54 switch (intptr_t(p) & 3) {
a61af66fc99e Initial load
duke
parents:
diff changeset
55 case 0: return *(u4*)p;
a61af66fc99e Initial load
duke
parents:
diff changeset
56
a61af66fc99e Initial load
duke
parents:
diff changeset
57 case 2: return ( u4( ((u2*)p)[0] ) << 16 )
a61af66fc99e Initial load
duke
parents:
diff changeset
58 | ( u4( ((u2*)p)[1] ) );
a61af66fc99e Initial load
duke
parents:
diff changeset
59
a61af66fc99e Initial load
duke
parents:
diff changeset
60 default: return ( u4(p[0]) << 24 )
a61af66fc99e Initial load
duke
parents:
diff changeset
61 | ( u4(p[1]) << 16 )
a61af66fc99e Initial load
duke
parents:
diff changeset
62 | ( u4(p[2]) << 8 )
a61af66fc99e Initial load
duke
parents:
diff changeset
63 | u4(p[3]);
a61af66fc99e Initial load
duke
parents:
diff changeset
64 }
a61af66fc99e Initial load
duke
parents:
diff changeset
65 }
a61af66fc99e Initial load
duke
parents:
diff changeset
66
a61af66fc99e Initial load
duke
parents:
diff changeset
67 static inline u8 get_native_u8(address p) {
a61af66fc99e Initial load
duke
parents:
diff changeset
68 switch (intptr_t(p) & 7) {
a61af66fc99e Initial load
duke
parents:
diff changeset
69 case 0: return *(u8*)p;
a61af66fc99e Initial load
duke
parents:
diff changeset
70
a61af66fc99e Initial load
duke
parents:
diff changeset
71 case 4: return ( u8( ((u4*)p)[0] ) << 32 )
a61af66fc99e Initial load
duke
parents:
diff changeset
72 | ( u8( ((u4*)p)[1] ) );
a61af66fc99e Initial load
duke
parents:
diff changeset
73
a61af66fc99e Initial load
duke
parents:
diff changeset
74 case 2: return ( u8( ((u2*)p)[0] ) << 48 )
a61af66fc99e Initial load
duke
parents:
diff changeset
75 | ( u8( ((u2*)p)[1] ) << 32 )
a61af66fc99e Initial load
duke
parents:
diff changeset
76 | ( u8( ((u2*)p)[2] ) << 16 )
a61af66fc99e Initial load
duke
parents:
diff changeset
77 | ( u8( ((u2*)p)[3] ) );
a61af66fc99e Initial load
duke
parents:
diff changeset
78
a61af66fc99e Initial load
duke
parents:
diff changeset
79 default: return ( u8(p[0]) << 56 )
a61af66fc99e Initial load
duke
parents:
diff changeset
80 | ( u8(p[1]) << 48 )
a61af66fc99e Initial load
duke
parents:
diff changeset
81 | ( u8(p[2]) << 40 )
a61af66fc99e Initial load
duke
parents:
diff changeset
82 | ( u8(p[3]) << 32 )
a61af66fc99e Initial load
duke
parents:
diff changeset
83 | ( u8(p[4]) << 24 )
a61af66fc99e Initial load
duke
parents:
diff changeset
84 | ( u8(p[5]) << 16 )
a61af66fc99e Initial load
duke
parents:
diff changeset
85 | ( u8(p[6]) << 8 )
a61af66fc99e Initial load
duke
parents:
diff changeset
86 | u8(p[7]);
a61af66fc99e Initial load
duke
parents:
diff changeset
87 }
a61af66fc99e Initial load
duke
parents:
diff changeset
88 }
a61af66fc99e Initial load
duke
parents:
diff changeset
89
a61af66fc99e Initial load
duke
parents:
diff changeset
90
a61af66fc99e Initial load
duke
parents:
diff changeset
91
a61af66fc99e Initial load
duke
parents:
diff changeset
92 static inline void put_native_u2(address p, u2 x) {
a61af66fc99e Initial load
duke
parents:
diff changeset
93 if ( (intptr_t(p) & 1) == 0 ) *(u2*)p = x;
a61af66fc99e Initial load
duke
parents:
diff changeset
94 else {
a61af66fc99e Initial load
duke
parents:
diff changeset
95 p[0] = x >> 8;
a61af66fc99e Initial load
duke
parents:
diff changeset
96 p[1] = x;
a61af66fc99e Initial load
duke
parents:
diff changeset
97 }
a61af66fc99e Initial load
duke
parents:
diff changeset
98 }
a61af66fc99e Initial load
duke
parents:
diff changeset
99
a61af66fc99e Initial load
duke
parents:
diff changeset
100 static inline void put_native_u4(address p, u4 x) {
a61af66fc99e Initial load
duke
parents:
diff changeset
101 switch ( intptr_t(p) & 3 ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
102 case 0: *(u4*)p = x;
a61af66fc99e Initial load
duke
parents:
diff changeset
103 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
104
a61af66fc99e Initial load
duke
parents:
diff changeset
105 case 2: ((u2*)p)[0] = x >> 16;
a61af66fc99e Initial load
duke
parents:
diff changeset
106 ((u2*)p)[1] = x;
a61af66fc99e Initial load
duke
parents:
diff changeset
107 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
108
a61af66fc99e Initial load
duke
parents:
diff changeset
109 default: ((u1*)p)[0] = x >> 24;
a61af66fc99e Initial load
duke
parents:
diff changeset
110 ((u1*)p)[1] = x >> 16;
a61af66fc99e Initial load
duke
parents:
diff changeset
111 ((u1*)p)[2] = x >> 8;
a61af66fc99e Initial load
duke
parents:
diff changeset
112 ((u1*)p)[3] = x;
a61af66fc99e Initial load
duke
parents:
diff changeset
113 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
114 }
a61af66fc99e Initial load
duke
parents:
diff changeset
115 }
a61af66fc99e Initial load
duke
parents:
diff changeset
116
a61af66fc99e Initial load
duke
parents:
diff changeset
117 static inline void put_native_u8(address p, u8 x) {
a61af66fc99e Initial load
duke
parents:
diff changeset
118 switch ( intptr_t(p) & 7 ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
119 case 0: *(u8*)p = x;
a61af66fc99e Initial load
duke
parents:
diff changeset
120 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
121
a61af66fc99e Initial load
duke
parents:
diff changeset
122 case 4: ((u4*)p)[0] = x >> 32;
a61af66fc99e Initial load
duke
parents:
diff changeset
123 ((u4*)p)[1] = x;
a61af66fc99e Initial load
duke
parents:
diff changeset
124 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
125
a61af66fc99e Initial load
duke
parents:
diff changeset
126 case 2: ((u2*)p)[0] = x >> 48;
a61af66fc99e Initial load
duke
parents:
diff changeset
127 ((u2*)p)[1] = x >> 32;
a61af66fc99e Initial load
duke
parents:
diff changeset
128 ((u2*)p)[2] = x >> 16;
a61af66fc99e Initial load
duke
parents:
diff changeset
129 ((u2*)p)[3] = x;
a61af66fc99e Initial load
duke
parents:
diff changeset
130 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
131
a61af66fc99e Initial load
duke
parents:
diff changeset
132 default: ((u1*)p)[0] = x >> 56;
a61af66fc99e Initial load
duke
parents:
diff changeset
133 ((u1*)p)[1] = x >> 48;
a61af66fc99e Initial load
duke
parents:
diff changeset
134 ((u1*)p)[2] = x >> 40;
a61af66fc99e Initial load
duke
parents:
diff changeset
135 ((u1*)p)[3] = x >> 32;
a61af66fc99e Initial load
duke
parents:
diff changeset
136 ((u1*)p)[4] = x >> 24;
a61af66fc99e Initial load
duke
parents:
diff changeset
137 ((u1*)p)[5] = x >> 16;
a61af66fc99e Initial load
duke
parents:
diff changeset
138 ((u1*)p)[6] = x >> 8;
a61af66fc99e Initial load
duke
parents:
diff changeset
139 ((u1*)p)[7] = x;
a61af66fc99e Initial load
duke
parents:
diff changeset
140 }
a61af66fc99e Initial load
duke
parents:
diff changeset
141 }
a61af66fc99e Initial load
duke
parents:
diff changeset
142
a61af66fc99e Initial load
duke
parents:
diff changeset
143
a61af66fc99e Initial load
duke
parents:
diff changeset
144 // Efficient reading and writing of unaligned unsigned data in Java byte ordering (i.e. big-endian ordering)
a61af66fc99e Initial load
duke
parents:
diff changeset
145 // (no byte-order reversal is needed since SPARC CPUs are big-endian oriented)
a61af66fc99e Initial load
duke
parents:
diff changeset
146 static inline u2 get_Java_u2(address p) { return get_native_u2(p); }
a61af66fc99e Initial load
duke
parents:
diff changeset
147 static inline u4 get_Java_u4(address p) { return get_native_u4(p); }
a61af66fc99e Initial load
duke
parents:
diff changeset
148 static inline u8 get_Java_u8(address p) { return get_native_u8(p); }
a61af66fc99e Initial load
duke
parents:
diff changeset
149
a61af66fc99e Initial load
duke
parents:
diff changeset
150 static inline void put_Java_u2(address p, u2 x) { put_native_u2(p, x); }
a61af66fc99e Initial load
duke
parents:
diff changeset
151 static inline void put_Java_u4(address p, u4 x) { put_native_u4(p, x); }
a61af66fc99e Initial load
duke
parents:
diff changeset
152 static inline void put_Java_u8(address p, u8 x) { put_native_u8(p, x); }
a61af66fc99e Initial load
duke
parents:
diff changeset
153 };
a61af66fc99e Initial load
duke
parents:
diff changeset
154
a61af66fc99e Initial load
duke
parents:
diff changeset
155 //Reconciliation History
a61af66fc99e Initial load
duke
parents:
diff changeset
156 // 1.7 98/02/24 10:18:41 bytes_i486.hpp
a61af66fc99e Initial load
duke
parents:
diff changeset
157 // 1.10 98/04/08 18:47:57 bytes_i486.hpp
a61af66fc99e Initial load
duke
parents:
diff changeset
158 // 1.13 98/07/15 17:10:03 bytes_i486.hpp
a61af66fc99e Initial load
duke
parents:
diff changeset
159 // 1.14 98/08/13 10:38:23 bytes_i486.hpp
a61af66fc99e Initial load
duke
parents:
diff changeset
160 // 1.15 98/10/05 16:30:21 bytes_i486.hpp
a61af66fc99e Initial load
duke
parents:
diff changeset
161 // 1.17 99/06/22 16:37:35 bytes_i486.hpp
a61af66fc99e Initial load
duke
parents:
diff changeset
162 //End
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
163
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
164 #endif // CPU_SPARC_VM_BYTES_SPARC_HPP