< prev index next >

test/hotspot/jtreg/compiler/vectorapi/VectorMemoryAlias.java

Print this page
@@ -1,7 +1,7 @@
  /*
-  *  Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
+  *  Copyright (c) 2021, 2022, Oracle and/or its affiliates. All rights reserved.
   *  Copyright (c) 2021, Rado Smogura. 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

@@ -34,12 +34,12 @@
   * @modules jdk.incubator.vector
   */
  
  package compiler.vectorapi;
  
- import java.nio.ByteBuffer;
  import java.nio.ByteOrder;
+ import jdk.incubator.foreign.MemorySegment;
  import jdk.incubator.vector.ByteVector;
  import jdk.incubator.vector.VectorSpecies;
  
  public class VectorMemoryAlias {
    public static final VectorSpecies<Byte> SPECIES = VectorSpecies.ofLargestShape(byte.class);

@@ -51,17 +51,17 @@
      }
    }
  
    public static int test() {
      byte arr[] = new byte[256];
-     final var bb = ByteBuffer.wrap(arr);
+     final var ms = MemorySegment.ofArray(arr);
      final var ones = ByteVector.broadcast(SPECIES, 1);
      var res = ByteVector.zero(SPECIES);
  
      int result = 0;
      result += arr[2];
-     res.add(ones).intoByteBuffer(bb, 0, ByteOrder.nativeOrder());
+     res.add(ones).intoMemorySegment(ms, 0L, ByteOrder.nativeOrder());
      result += arr[2];
  
      return result;
    }
  }
< prev index next >