Skip to content

Commit 0e90697

Browse files
committed
8290133: JFR: Remove unused methods in Bits.java
Reviewed-by: mgronlun
1 parent ea12615 commit 0e90697

File tree

2 files changed

+3
-79
lines changed

2 files changed

+3
-79
lines changed

Diff for: src/jdk.jfr/share/classes/jdk/jfr/internal/Bits.java

-77
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,6 @@ private Bits() { }
3737

3838
// -- Swapping --
3939

40-
private static short swap(short x) {
41-
return Short.reverseBytes(x);
42-
}
43-
44-
private static char swap(char x) {
45-
return Character.reverseBytes(x);
46-
}
47-
4840
private static int swap(int x) {
4941
return Integer.reverseBytes(x);
5042
}
@@ -69,12 +61,6 @@ private static boolean isAddressAligned(long a, int datumSize) {
6961

7062
// -- Primitives stored per byte
7163

72-
private static byte char1(char x) { return (byte)(x >> 8); }
73-
private static byte char0(char x) { return (byte)(x ); }
74-
75-
private static byte short1(short x) { return (byte)(x >> 8); }
76-
private static byte short0(short x) { return (byte)(x ); }
77-
7864
private static byte int3(int x) { return (byte)(x >> 24); }
7965
private static byte int2(int x) { return (byte)(x >> 16); }
8066
private static byte int1(int x) { return (byte)(x >> 8); }
@@ -89,16 +75,6 @@ private static boolean isAddressAligned(long a, int datumSize) {
8975
private static byte long1(long x) { return (byte)(x >> 8); }
9076
private static byte long0(long x) { return (byte)(x ); }
9177

92-
private static void putCharBigEndianUnaligned(long a, char x) {
93-
putByte_(a , char1(x));
94-
putByte_(a + 1, char0(x));
95-
}
96-
97-
private static void putShortBigEndianUnaligned(long a, short x) {
98-
putByte_(a , short1(x));
99-
putByte_(a + 1, short0(x));
100-
}
101-
10278
private static void putIntBigEndianUnaligned(long a, int x) {
10379
putByte_(a , int3(x));
10480
putByte_(a + 1, int2(x));
@@ -129,26 +105,10 @@ private static void putByte_(long a, byte b) {
129105
unsafe.putByte(a, b);
130106
}
131107

132-
private static void putBoolean_(long a, boolean x) {
133-
unsafe.putBoolean(null, a, x);
134-
}
135-
136-
private static void putChar_(long a, char x) {
137-
unsafe.putChar(a, bigEndian ? x : swap(x));
138-
}
139-
140-
private static void putShort_(long a, short x) {
141-
unsafe.putShort(a, bigEndian ? x : swap(x));
142-
}
143-
144108
private static void putInt_(long a, int x) {
145109
unsafe.putInt(a, bigEndian ? x : swap(x));
146110
}
147111

148-
private static void putLong_(long a, long x) {
149-
unsafe.putLong(a, bigEndian ? x : swap(x));
150-
}
151-
152112
private static void putFloat_(long a, float x) {
153113
unsafe.putFloat(a, bigEndian ? x : swap(x));
154114
}
@@ -158,34 +118,6 @@ private static void putDouble_(long a, double x) {
158118
}
159119

160120
// external api
161-
public static int putByte(long a, byte x) {
162-
putByte_(a, x);
163-
return Byte.BYTES;
164-
}
165-
166-
public static int putBoolean(long a, boolean x) {
167-
putBoolean_(a, x);
168-
return Byte.BYTES;
169-
}
170-
171-
static int putChar(long a, char x) {
172-
if (unalignedAccess || isAddressAligned(a, Character.BYTES)) {
173-
putChar_(a, x);
174-
return Character.BYTES;
175-
}
176-
putCharBigEndianUnaligned(a, x);
177-
return Character.BYTES;
178-
}
179-
180-
static int putShort(long a, short x) {
181-
if (unalignedAccess || isAddressAligned(a, Short.BYTES)) {
182-
putShort_(a, x);
183-
return Short.BYTES;
184-
}
185-
putShortBigEndianUnaligned(a, x);
186-
return Short.BYTES;
187-
}
188-
189121
public static int putInt(long a, int x) {
190122
if (unalignedAccess || isAddressAligned(a, Integer.BYTES)) {
191123
putInt_(a, x);
@@ -195,15 +127,6 @@ public static int putInt(long a, int x) {
195127
return Integer.BYTES;
196128
}
197129

198-
static int putLong(long a, long x) {
199-
if (unalignedAccess || isAddressAligned(a, Long.BYTES)) {
200-
putLong_(a, x);
201-
return Long.BYTES;
202-
}
203-
putLongBigEndianUnaligned(a, x);
204-
return Long.BYTES;
205-
}
206-
207130
public static int putFloat(long a, float x) {
208131
if (unalignedAccess || isAddressAligned(a, Float.BYTES)) {
209132
putFloat_(a, x);

Diff for: src/jdk.jfr/share/classes/jdk/jfr/internal/event/EventWriter.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ private EventWriter() {
8181

8282
public void putBoolean(boolean i) {
8383
if (isValidForSize(Byte.BYTES)) {
84-
currentPosition += Bits.putBoolean(currentPosition, i);
84+
unsafe.putBoolean(null, currentPosition, i);
85+
++currentPosition;
8586
}
8687
}
8788

@@ -289,7 +290,7 @@ public boolean endEvent() {
289290
Bits.putInt(startPosition, makePaddedInt(eventSize));
290291
} else {
291292
if (eventSize < 128) {
292-
Bits.putByte(startPosition, (byte) eventSize);
293+
unsafe.putByte(startPosition, (byte) eventSize);
293294
} else {
294295
eventType.setLargeSize();
295296
reset();

0 commit comments

Comments
 (0)