8344168: Change Unsafe base offset from int to long

Reviewed-by: liach
This commit is contained in:
Shaojin Wen 2025-01-30 15:57:13 +00:00
parent 5d5b294b0a
commit fdfb68c8d0
53 changed files with 164 additions and 154 deletions

View file

@ -6383,7 +6383,7 @@ public class ConcurrentHashMap<K,V> extends AbstractMap<K,V>
= U.objectFieldOffset(ConcurrentHashMap.class, "cellsBusy");
private static final long CELLVALUE
= U.objectFieldOffset(CounterCell.class, "value");
private static final int ABASE = U.arrayBaseOffset(Node[].class);
private static final long ABASE = U.arrayBaseOffset(Node[].class);
private static final int ASHIFT;
static {

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -222,9 +222,9 @@ public final class CRC32C implements Checksum {
if (end - off >= 8 && Unsafe.ARRAY_BYTE_INDEX_SCALE == 1) {
// align on 8 bytes
int alignLength
long alignLength
= (8 - ((Unsafe.ARRAY_BYTE_BASE_OFFSET + off) & 0x7)) & 0x7;
for (int alignEnd = off + alignLength; off < alignEnd; off++) {
for (long alignEnd = off + alignLength; off < alignEnd; off++) {
crc = (crc >>> 8) ^ byteTable[(crc ^ b[off]) & 0xFF];
}
@ -238,11 +238,11 @@ public final class CRC32C implements Checksum {
int secondHalf;
if (Unsafe.ADDRESS_SIZE == 4) {
// On 32 bit platforms read two ints instead of a single 64bit long
firstHalf = UNSAFE.getInt(b, (long)Unsafe.ARRAY_BYTE_BASE_OFFSET + off);
secondHalf = UNSAFE.getInt(b, (long)Unsafe.ARRAY_BYTE_BASE_OFFSET + off
firstHalf = UNSAFE.getInt(b, Unsafe.ARRAY_BYTE_BASE_OFFSET + off);
secondHalf = UNSAFE.getInt(b, Unsafe.ARRAY_BYTE_BASE_OFFSET + off
+ Integer.BYTES);
} else {
long value = UNSAFE.getLong(b, (long)Unsafe.ARRAY_BYTE_BASE_OFFSET + off);
long value = UNSAFE.getLong(b, Unsafe.ARRAY_BYTE_BASE_OFFSET + off);
if (ByteOrder.nativeOrder() == ByteOrder.LITTLE_ENDIAN) {
firstHalf = (int) value;
secondHalf = (int) (value >>> 32);

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -174,7 +174,7 @@ class ZipUtils {
Preconditions.checkIndex(off, b.length, Preconditions.AIOOBE_FORMATTER);
Preconditions.checkIndex(off + 1, b.length, Preconditions.AIOOBE_FORMATTER);
return Short.toUnsignedInt(
UNSAFE.getShortUnaligned(b, off + (long) Unsafe.ARRAY_BYTE_BASE_OFFSET, false));
UNSAFE.getShortUnaligned(b, off + Unsafe.ARRAY_BYTE_BASE_OFFSET, false));
}
/**
@ -185,7 +185,7 @@ class ZipUtils {
Preconditions.checkIndex(off, b.length, Preconditions.AIOOBE_FORMATTER);
Preconditions.checkIndex(off + 3, b.length, Preconditions.AIOOBE_FORMATTER);
return Integer.toUnsignedLong(
UNSAFE.getIntUnaligned(b, off + (long) Unsafe.ARRAY_BYTE_BASE_OFFSET, false));
UNSAFE.getIntUnaligned(b, off + Unsafe.ARRAY_BYTE_BASE_OFFSET, false));
}
/**
@ -195,7 +195,7 @@ class ZipUtils {
public static final long get64S(byte[] b, int off) {
Preconditions.checkIndex(off, b.length, Preconditions.AIOOBE_FORMATTER);
Preconditions.checkIndex(off + 7, b.length, Preconditions.AIOOBE_FORMATTER);
return UNSAFE.getLongUnaligned(b, off + (long) Unsafe.ARRAY_BYTE_BASE_OFFSET, false);
return UNSAFE.getLongUnaligned(b, off + Unsafe.ARRAY_BYTE_BASE_OFFSET, false);
}
/**
@ -206,7 +206,7 @@ class ZipUtils {
public static final int get32S(byte[] b, int off) {
Preconditions.checkIndex(off, b.length, Preconditions.AIOOBE_FORMATTER);
Preconditions.checkIndex(off + 3, b.length, Preconditions.AIOOBE_FORMATTER);
return UNSAFE.getIntUnaligned(b, off + (long) Unsafe.ARRAY_BYTE_BASE_OFFSET, false);
return UNSAFE.getIntUnaligned(b, off + Unsafe.ARRAY_BYTE_BASE_OFFSET, false);
}
/*