On Thu, 25 Jul 2024 01:14:32 GMT, Shaojin Wen <d...@openjdk.org> wrote:

>> @cl4es I would wait, to be honest. I'm currently quite busy, but I hope I 
>> can do something here in the next 2-3 weeks.
>
> @eme64  Unsafe.putByte MergeStore of master branch doesn't work
> 
> 
> import sun.misc.Unsafe;
> 
> public class PutBytesTest {
>     static final Unsafe UNSAFE = JDKUtils.UNSAFE;
> 
>     // MergeStore not work
>     static void putCharsAt(byte[] val, int index, int c1, int c2, int c3, int 
> c4) {
>         putByte(val, index    , (byte)(c1));
>         putByte(val, index + 1, (byte)(c2));
>         putByte(val, index + 2, (byte)(c3));
>         putByte(val, index + 3, (byte)(c4));
>     }
> 
>     // MergeStore work
>     static void putCharsAtArrayStore(byte[] val, int index, int c1, int c2, 
> int c3, int c4) {
>         val[index] = (byte) c1;
>         val[index + 1] = (byte) c2;
>         val[index + 2] = (byte) c3;
>         val[index + 3] = (byte) c4;
>     }
> 
>     static void putByte(byte[] bytes, int index, byte c) {
>         UNSAFE.putByte(bytes, Unsafe.ARRAY_BYTE_BASE_OFFSET + index, c);
>     }
> 
>     static void putNull(byte[] bytes, int index) {
>         putCharsAt(bytes, index, 'n', 'u', 'l', 'l');
>     }
> 
>     public static void main(String[] args) {
>         for (int i = 0; i < 5; i++) {
>             testNull();
>         }
>         System.out.println("done");
>     }
> 
>     private static void testNull() {
>         byte[] bytes = new byte[4096];
>         for (int i = 0; i < 1000; i++) {
>             int index = 0;
>             for (int j = 0; j < 1024; j++) {
>                 putNull(bytes, index);
>                 index += 4;
>             }
>         }
>     }
> }

@wenshao Yes, I am aware. I detected a bug with `Unsafe`, and now just disabled 
it. I'm trying to make it work again, but it will take some time, 
unfortunately. I need to be sure about the VM logic, and also sufficient 
testing.

-------------

PR Comment: https://git.openjdk.org/jdk/pull/19626#issuecomment-2252675824

Reply via email to