Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openjdk-multiarch-jdk8u
Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/cpu/sparc/vm/bytes_sparc.hpp
32285 views
1
/*
2
* Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
7
* published by the Free Software Foundation.
8
*
9
* This code is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12
* version 2 for more details (a copy is included in the LICENSE file that
13
* accompanied this code).
14
*
15
* You should have received a copy of the GNU General Public License version
16
* 2 along with this work; if not, write to the Free Software Foundation,
17
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18
*
19
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20
* or visit www.oracle.com if you need additional information or have any
21
* questions.
22
*
23
*/
24
25
#ifndef CPU_SPARC_VM_BYTES_SPARC_HPP
26
#define CPU_SPARC_VM_BYTES_SPARC_HPP
27
28
#include "memory/allocation.hpp"
29
30
class Bytes: AllStatic {
31
public:
32
// Efficient reading and writing of unaligned unsigned data in platform-specific byte ordering
33
// Sparc needs to check for alignment.
34
35
// can I count on address always being a pointer to an unsigned char? Yes
36
37
// Returns true, if the byte ordering used by Java is different from the nativ byte ordering
38
// of the underlying machine. For example, true for Intel x86, False, for Solaris on Sparc.
39
static inline bool is_Java_byte_ordering_different() { return false; }
40
41
// Thus, a swap between native and Java ordering is always a no-op:
42
static inline u2 swap_u2(u2 x) { return x; }
43
static inline u4 swap_u4(u4 x) { return x; }
44
static inline u8 swap_u8(u8 x) { return x; }
45
46
static inline u2 get_native_u2(address p){
47
return (intptr_t(p) & 1) == 0
48
? *(u2*)p
49
: ( u2(p[0]) << 8 )
50
| ( u2(p[1]) );
51
}
52
53
static inline u4 get_native_u4(address p) {
54
switch (intptr_t(p) & 3) {
55
case 0: return *(u4*)p;
56
57
case 2: return ( u4( ((u2*)p)[0] ) << 16 )
58
| ( u4( ((u2*)p)[1] ) );
59
60
default: return ( u4(p[0]) << 24 )
61
| ( u4(p[1]) << 16 )
62
| ( u4(p[2]) << 8 )
63
| u4(p[3]);
64
}
65
}
66
67
static inline u8 get_native_u8(address p) {
68
switch (intptr_t(p) & 7) {
69
case 0: return *(u8*)p;
70
71
case 4: return ( u8( ((u4*)p)[0] ) << 32 )
72
| ( u8( ((u4*)p)[1] ) );
73
74
case 2: return ( u8( ((u2*)p)[0] ) << 48 )
75
| ( u8( ((u2*)p)[1] ) << 32 )
76
| ( u8( ((u2*)p)[2] ) << 16 )
77
| ( u8( ((u2*)p)[3] ) );
78
79
default: return ( u8(p[0]) << 56 )
80
| ( u8(p[1]) << 48 )
81
| ( u8(p[2]) << 40 )
82
| ( u8(p[3]) << 32 )
83
| ( u8(p[4]) << 24 )
84
| ( u8(p[5]) << 16 )
85
| ( u8(p[6]) << 8 )
86
| u8(p[7]);
87
}
88
}
89
90
91
92
static inline void put_native_u2(address p, u2 x) {
93
if ( (intptr_t(p) & 1) == 0 ) *(u2*)p = x;
94
else {
95
p[0] = x >> 8;
96
p[1] = x;
97
}
98
}
99
100
static inline void put_native_u4(address p, u4 x) {
101
switch ( intptr_t(p) & 3 ) {
102
case 0: *(u4*)p = x;
103
break;
104
105
case 2: ((u2*)p)[0] = x >> 16;
106
((u2*)p)[1] = x;
107
break;
108
109
default: ((u1*)p)[0] = x >> 24;
110
((u1*)p)[1] = x >> 16;
111
((u1*)p)[2] = x >> 8;
112
((u1*)p)[3] = x;
113
break;
114
}
115
}
116
117
static inline void put_native_u8(address p, u8 x) {
118
switch ( intptr_t(p) & 7 ) {
119
case 0: *(u8*)p = x;
120
break;
121
122
case 4: ((u4*)p)[0] = x >> 32;
123
((u4*)p)[1] = x;
124
break;
125
126
case 2: ((u2*)p)[0] = x >> 48;
127
((u2*)p)[1] = x >> 32;
128
((u2*)p)[2] = x >> 16;
129
((u2*)p)[3] = x;
130
break;
131
132
default: ((u1*)p)[0] = x >> 56;
133
((u1*)p)[1] = x >> 48;
134
((u1*)p)[2] = x >> 40;
135
((u1*)p)[3] = x >> 32;
136
((u1*)p)[4] = x >> 24;
137
((u1*)p)[5] = x >> 16;
138
((u1*)p)[6] = x >> 8;
139
((u1*)p)[7] = x;
140
}
141
}
142
143
144
// Efficient reading and writing of unaligned unsigned data in Java byte ordering (i.e. big-endian ordering)
145
// (no byte-order reversal is needed since SPARC CPUs are big-endian oriented)
146
static inline u2 get_Java_u2(address p) { return get_native_u2(p); }
147
static inline u4 get_Java_u4(address p) { return get_native_u4(p); }
148
static inline u8 get_Java_u8(address p) { return get_native_u8(p); }
149
150
static inline void put_Java_u2(address p, u2 x) { put_native_u2(p, x); }
151
static inline void put_Java_u4(address p, u4 x) { put_native_u4(p, x); }
152
static inline void put_Java_u8(address p, u8 x) { put_native_u8(p, x); }
153
};
154
155
//Reconciliation History
156
// 1.7 98/02/24 10:18:41 bytes_i486.hpp
157
// 1.10 98/04/08 18:47:57 bytes_i486.hpp
158
// 1.13 98/07/15 17:10:03 bytes_i486.hpp
159
// 1.14 98/08/13 10:38:23 bytes_i486.hpp
160
// 1.15 98/10/05 16:30:21 bytes_i486.hpp
161
// 1.17 99/06/22 16:37:35 bytes_i486.hpp
162
//End
163
164
#endif // CPU_SPARC_VM_BYTES_SPARC_HPP
165
166