changeset 298:9dcd4ef5edf1

Chapter 1.b: Add ByteOrders for array/buffer tests.
author shade
date Fri, 10 Jun 2016 16:39:06 +0300
parents 2cb629dfc2be
children da7d08d212be
files jcstress-test-gen/src/main/java/org/openjdk/jcstress/chapters/Chapter1bTestGenerator.java jcstress-test-gen/src/main/resources/operationAtomic/byteArray/X-AddAndGetTest.java.template jcstress-test-gen/src/main/resources/operationAtomic/byteArray/X-CAETest.java.template jcstress-test-gen/src/main/resources/operationAtomic/byteArray/X-CASTest.java.template jcstress-test-gen/src/main/resources/operationAtomic/byteArray/X-GetAndAddTest.java.template jcstress-test-gen/src/main/resources/operationAtomic/byteArray/X-GetAndSetTest.java.template jcstress-test-gen/src/main/resources/operationAtomic/byteArray/X-WeakCASContendStrongTest.java.template jcstress-test-gen/src/main/resources/operationAtomic/byteArray/X-WeakCASTest.java.template jcstress-test-gen/src/main/resources/operationAtomic/byteBuffer/X-AddAndGetTest.java.template jcstress-test-gen/src/main/resources/operationAtomic/byteBuffer/X-CAETest.java.template jcstress-test-gen/src/main/resources/operationAtomic/byteBuffer/X-CASTest.java.template jcstress-test-gen/src/main/resources/operationAtomic/byteBuffer/X-GetAndAddTest.java.template jcstress-test-gen/src/main/resources/operationAtomic/byteBuffer/X-GetAndSetTest.java.template jcstress-test-gen/src/main/resources/operationAtomic/byteBuffer/X-WeakCASContendStrongTest.java.template jcstress-test-gen/src/main/resources/operationAtomic/byteBuffer/X-WeakCASTest.java.template
diffstat 15 files changed, 45 insertions(+), 38 deletions(-) [+]
line wrap: on
line diff
--- a/jcstress-test-gen/src/main/java/org/openjdk/jcstress/chapters/Chapter1bTestGenerator.java	Fri Jun 10 16:26:59 2016 +0300
+++ b/jcstress-test-gen/src/main/java/org/openjdk/jcstress/chapters/Chapter1bTestGenerator.java	Fri Jun 10 16:39:06 2016 +0300
@@ -64,6 +64,7 @@
 import org.openjdk.jcstress.chapters.Chapter1bTestGenerator.Target.Operation;
 
 import java.io.IOException;
+import java.nio.ByteOrder;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Map.Entry;
@@ -154,17 +155,22 @@
                 if (!VIEW_SOURCE.supported(operation.method, type))
                     break;
 
-                String result = generateConcreteOperation(template, target.target, operation.operation,
-                        "(\\$type\\$) vh.get(\\$object\\$\\$index_para\\$)",
-                        "vh.set(\\$object\\$\\$index_para\\$, $1);");
+                for (ByteOrder bo : new ByteOrder[] { ByteOrder.BIG_ENDIAN, ByteOrder.LITTLE_ENDIAN }) {
+                    String result = generateConcreteOperation(template, target.target, operation.operation,
+                            "(\\$type\\$) vh.get(\\$object\\$\\$index_para\\$)",
+                            "vh.set(\\$object\\$\\$index_para\\$, $1);");
 
-                String pkg = BASE_PKG + "." + vhType + bufferType.pkgAppendix() + "." + templateName.replaceAll("^X-", "");
-                String testName = operation.method.name() + upcaseFirst(type.type);
+                    String pkg = BASE_PKG + "." + vhType + bufferType.pkgAppendix() + "." +
+                            bo.toString().toLowerCase().replace("_endian", "") + "." +
+                            templateName.replaceAll("^X-", "");
 
-                writeOut(dest, pkg, testName, Spp.spp(result,
-                        keys(type),
-                        viewVars(type, object, pkg, testName, bufferType.allocateOp)
-                ));
+                    String testName = operation.method.name() + upcaseFirst(type.type);
+
+                    writeOut(dest, pkg, testName, Spp.spp(result,
+                            keys(type),
+                            viewVars(type, object, pkg, testName, bufferType.allocateOp, bo)
+                    ));
+                }
             }
         }
     }
@@ -213,11 +219,12 @@
     }
 
     private static Map<String, String> viewVars(Type type, String object, String pkg, String testName,
-            String bufferAllocateOp) {
+                                                String bufferAllocateOp, ByteOrder bo) {
         Map<String, String> map = commonVars(type, object, pkg, testName);
         map.put("index_para", ", 0");
         map.put("unit_size", String.valueOf(type.sizeInArray));
         map.put("buffer_allocate", bufferAllocateOp);
+        map.put("byte_order", bo.toString());
         return map;
     }
 
--- a/jcstress-test-gen/src/main/resources/operationAtomic/byteArray/X-AddAndGetTest.java.template	Fri Jun 10 16:26:59 2016 +0300
+++ b/jcstress-test-gen/src/main/resources/operationAtomic/byteArray/X-AddAndGetTest.java.template	Fri Jun 10 16:39:06 2016 +0300
@@ -24,11 +24,11 @@
  */
 package $package$;
 
-import static java.nio.ByteOrder.BIG_ENDIAN;
 import java.lang.invoke.MethodHandles;
 import java.lang.invoke.VarHandle;
 import java.util.Random;
 import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
 
 import org.openjdk.jcstress.annotations.Actor;
 import org.openjdk.jcstress.annotations.Arbiter;
@@ -54,7 +54,7 @@
 
     static {
         try {
-            vh = MethodHandles.byteArrayViewVarHandle($type$[].class, BIG_ENDIAN);
+            vh = MethodHandles.byteArrayViewVarHandle($type$[].class, ByteOrder.$byte_order$);
         } catch (Exception e) {
             throw new RuntimeException(e);
         }
--- a/jcstress-test-gen/src/main/resources/operationAtomic/byteArray/X-CAETest.java.template	Fri Jun 10 16:26:59 2016 +0300
+++ b/jcstress-test-gen/src/main/resources/operationAtomic/byteArray/X-CAETest.java.template	Fri Jun 10 16:39:06 2016 +0300
@@ -24,11 +24,11 @@
  */
 package $package$;
 
-import static java.nio.ByteOrder.BIG_ENDIAN;
 import java.lang.invoke.MethodHandles;
 import java.lang.invoke.VarHandle;
 import java.util.Random;
 import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
 
 import org.openjdk.jcstress.annotations.Actor;
 import org.openjdk.jcstress.annotations.Arbiter;
@@ -56,7 +56,7 @@
 
     static {
         try {
-            vh = MethodHandles.byteArrayViewVarHandle($type$[].class, BIG_ENDIAN);
+            vh = MethodHandles.byteArrayViewVarHandle($type$[].class, ByteOrder.$byte_order$);
         } catch (Exception e) {
             throw new RuntimeException(e);
         }
--- a/jcstress-test-gen/src/main/resources/operationAtomic/byteArray/X-CASTest.java.template	Fri Jun 10 16:26:59 2016 +0300
+++ b/jcstress-test-gen/src/main/resources/operationAtomic/byteArray/X-CASTest.java.template	Fri Jun 10 16:39:06 2016 +0300
@@ -24,11 +24,11 @@
  */
 package $package$;
 
-import static java.nio.ByteOrder.BIG_ENDIAN;
 import java.lang.invoke.MethodHandles;
 import java.lang.invoke.VarHandle;
 import java.util.Random;
 import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
 
 import org.openjdk.jcstress.annotations.Actor;
 import org.openjdk.jcstress.annotations.Arbiter;
@@ -56,7 +56,7 @@
 
     static {
         try {
-            vh = MethodHandles.byteArrayViewVarHandle($type$[].class, BIG_ENDIAN);
+            vh = MethodHandles.byteArrayViewVarHandle($type$[].class, ByteOrder.$byte_order$);
         } catch (Exception e) {
             throw new RuntimeException(e);
         }
--- a/jcstress-test-gen/src/main/resources/operationAtomic/byteArray/X-GetAndAddTest.java.template	Fri Jun 10 16:26:59 2016 +0300
+++ b/jcstress-test-gen/src/main/resources/operationAtomic/byteArray/X-GetAndAddTest.java.template	Fri Jun 10 16:39:06 2016 +0300
@@ -24,11 +24,11 @@
  */
 package $package$;
 
-import static java.nio.ByteOrder.BIG_ENDIAN;
 import java.lang.invoke.MethodHandles;
 import java.lang.invoke.VarHandle;
 import java.util.Random;
 import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
 
 import org.openjdk.jcstress.annotations.Actor;
 import org.openjdk.jcstress.annotations.Arbiter;
@@ -54,7 +54,7 @@
 
     static {
         try {
-            vh = MethodHandles.byteArrayViewVarHandle($type$[].class, BIG_ENDIAN);
+            vh = MethodHandles.byteArrayViewVarHandle($type$[].class, ByteOrder.$byte_order$);
         } catch (Exception e) {
             throw new RuntimeException(e);
         }
--- a/jcstress-test-gen/src/main/resources/operationAtomic/byteArray/X-GetAndSetTest.java.template	Fri Jun 10 16:26:59 2016 +0300
+++ b/jcstress-test-gen/src/main/resources/operationAtomic/byteArray/X-GetAndSetTest.java.template	Fri Jun 10 16:39:06 2016 +0300
@@ -24,11 +24,11 @@
  */
 package $package$;
 
-import static java.nio.ByteOrder.BIG_ENDIAN;
 import java.lang.invoke.MethodHandles;
 import java.lang.invoke.VarHandle;
 import java.util.Random;
 import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
 
 import org.openjdk.jcstress.annotations.Actor;
 import org.openjdk.jcstress.annotations.Arbiter;
@@ -55,7 +55,7 @@
 
     static {
         try {
-            vh = MethodHandles.byteArrayViewVarHandle($type$[].class, BIG_ENDIAN);
+            vh = MethodHandles.byteArrayViewVarHandle($type$[].class, ByteOrder.$byte_order$);
         } catch (Exception e) {
             throw new RuntimeException(e);
         }
--- a/jcstress-test-gen/src/main/resources/operationAtomic/byteArray/X-WeakCASContendStrongTest.java.template	Fri Jun 10 16:26:59 2016 +0300
+++ b/jcstress-test-gen/src/main/resources/operationAtomic/byteArray/X-WeakCASContendStrongTest.java.template	Fri Jun 10 16:39:06 2016 +0300
@@ -24,11 +24,11 @@
  */
 package $package$;
 
-import static java.nio.ByteOrder.BIG_ENDIAN;
 import java.lang.invoke.MethodHandles;
 import java.lang.invoke.VarHandle;
 import java.util.Random;
 import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
 
 import org.openjdk.jcstress.annotations.Actor;
 import org.openjdk.jcstress.annotations.Arbiter;
@@ -56,7 +56,7 @@
 
     static {
         try {
-            vh = MethodHandles.byteArrayViewVarHandle($type$[].class, BIG_ENDIAN);
+            vh = MethodHandles.byteArrayViewVarHandle($type$[].class, ByteOrder.$byte_order$);
         } catch (Exception e) {
             throw new RuntimeException(e);
         }
--- a/jcstress-test-gen/src/main/resources/operationAtomic/byteArray/X-WeakCASTest.java.template	Fri Jun 10 16:26:59 2016 +0300
+++ b/jcstress-test-gen/src/main/resources/operationAtomic/byteArray/X-WeakCASTest.java.template	Fri Jun 10 16:39:06 2016 +0300
@@ -24,11 +24,11 @@
  */
 package $package$;
 
-import static java.nio.ByteOrder.BIG_ENDIAN;
 import java.lang.invoke.MethodHandles;
 import java.lang.invoke.VarHandle;
 import java.util.Random;
 import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
 
 import org.openjdk.jcstress.annotations.Actor;
 import org.openjdk.jcstress.annotations.Arbiter;
@@ -56,7 +56,7 @@
 
     static {
         try {
-            vh = MethodHandles.byteArrayViewVarHandle($type$[].class, BIG_ENDIAN);
+            vh = MethodHandles.byteArrayViewVarHandle($type$[].class, ByteOrder.$byte_order$);
         } catch (Exception e) {
             throw new RuntimeException(e);
         }
--- a/jcstress-test-gen/src/main/resources/operationAtomic/byteBuffer/X-AddAndGetTest.java.template	Fri Jun 10 16:26:59 2016 +0300
+++ b/jcstress-test-gen/src/main/resources/operationAtomic/byteBuffer/X-AddAndGetTest.java.template	Fri Jun 10 16:39:06 2016 +0300
@@ -24,11 +24,11 @@
  */
 package $package$;
 
-import static java.nio.ByteOrder.BIG_ENDIAN;
 import java.lang.invoke.MethodHandles;
 import java.lang.invoke.VarHandle;
 import java.util.Random;
 import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
 
 import org.openjdk.jcstress.annotations.Actor;
 import org.openjdk.jcstress.annotations.Arbiter;
@@ -54,7 +54,7 @@
 
     static {
         try {
-            vh = MethodHandles.byteBufferViewVarHandle($type$[].class, BIG_ENDIAN);
+            vh = MethodHandles.byteBufferViewVarHandle($type$[].class, ByteOrder.$byte_order$);
         } catch (Exception e) {
             throw new RuntimeException(e);
         }
--- a/jcstress-test-gen/src/main/resources/operationAtomic/byteBuffer/X-CAETest.java.template	Fri Jun 10 16:26:59 2016 +0300
+++ b/jcstress-test-gen/src/main/resources/operationAtomic/byteBuffer/X-CAETest.java.template	Fri Jun 10 16:39:06 2016 +0300
@@ -24,11 +24,11 @@
  */
 package $package$;
 
-import static java.nio.ByteOrder.BIG_ENDIAN;
 import java.lang.invoke.MethodHandles;
 import java.lang.invoke.VarHandle;
 import java.util.Random;
 import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
 
 import org.openjdk.jcstress.annotations.Actor;
 import org.openjdk.jcstress.annotations.Arbiter;
@@ -56,7 +56,7 @@
 
     static {
         try {
-            vh = MethodHandles.byteBufferViewVarHandle($type$[].class, BIG_ENDIAN);
+            vh = MethodHandles.byteBufferViewVarHandle($type$[].class, ByteOrder.$byte_order$);
         } catch (Exception e) {
             throw new RuntimeException(e);
         }
--- a/jcstress-test-gen/src/main/resources/operationAtomic/byteBuffer/X-CASTest.java.template	Fri Jun 10 16:26:59 2016 +0300
+++ b/jcstress-test-gen/src/main/resources/operationAtomic/byteBuffer/X-CASTest.java.template	Fri Jun 10 16:39:06 2016 +0300
@@ -24,11 +24,11 @@
  */
 package $package$;
 
-import static java.nio.ByteOrder.BIG_ENDIAN;
 import java.lang.invoke.MethodHandles;
 import java.lang.invoke.VarHandle;
 import java.util.Random;
 import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
 
 import org.openjdk.jcstress.annotations.Actor;
 import org.openjdk.jcstress.annotations.Arbiter;
@@ -56,7 +56,7 @@
 
     static {
         try {
-            vh = MethodHandles.byteBufferViewVarHandle($type$[].class, BIG_ENDIAN);
+            vh = MethodHandles.byteBufferViewVarHandle($type$[].class, ByteOrder.$byte_order$);
         } catch (Exception e) {
             throw new RuntimeException(e);
         }
--- a/jcstress-test-gen/src/main/resources/operationAtomic/byteBuffer/X-GetAndAddTest.java.template	Fri Jun 10 16:26:59 2016 +0300
+++ b/jcstress-test-gen/src/main/resources/operationAtomic/byteBuffer/X-GetAndAddTest.java.template	Fri Jun 10 16:39:06 2016 +0300
@@ -24,11 +24,11 @@
  */
 package $package$;
 
-import static java.nio.ByteOrder.BIG_ENDIAN;
 import java.lang.invoke.MethodHandles;
 import java.lang.invoke.VarHandle;
 import java.util.Random;
 import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
 
 import org.openjdk.jcstress.annotations.Actor;
 import org.openjdk.jcstress.annotations.Arbiter;
@@ -54,7 +54,7 @@
 
     static {
         try {
-            vh = MethodHandles.byteBufferViewVarHandle($type$[].class, BIG_ENDIAN);
+            vh = MethodHandles.byteBufferViewVarHandle($type$[].class, ByteOrder.$byte_order$);
         } catch (Exception e) {
             throw new RuntimeException(e);
         }
--- a/jcstress-test-gen/src/main/resources/operationAtomic/byteBuffer/X-GetAndSetTest.java.template	Fri Jun 10 16:26:59 2016 +0300
+++ b/jcstress-test-gen/src/main/resources/operationAtomic/byteBuffer/X-GetAndSetTest.java.template	Fri Jun 10 16:39:06 2016 +0300
@@ -24,11 +24,11 @@
  */
 package $package$;
 
-import static java.nio.ByteOrder.BIG_ENDIAN;
 import java.lang.invoke.MethodHandles;
 import java.lang.invoke.VarHandle;
 import java.util.Random;
 import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
 
 import org.openjdk.jcstress.annotations.Actor;
 import org.openjdk.jcstress.annotations.Arbiter;
@@ -55,7 +55,7 @@
 
     static {
         try {
-            vh = MethodHandles.byteBufferViewVarHandle($type$[].class, BIG_ENDIAN);
+            vh = MethodHandles.byteBufferViewVarHandle($type$[].class, ByteOrder.$byte_order$);
         } catch (Exception e) {
             throw new RuntimeException(e);
         }
--- a/jcstress-test-gen/src/main/resources/operationAtomic/byteBuffer/X-WeakCASContendStrongTest.java.template	Fri Jun 10 16:26:59 2016 +0300
+++ b/jcstress-test-gen/src/main/resources/operationAtomic/byteBuffer/X-WeakCASContendStrongTest.java.template	Fri Jun 10 16:39:06 2016 +0300
@@ -24,11 +24,11 @@
  */
 package $package$;
 
-import static java.nio.ByteOrder.BIG_ENDIAN;
 import java.lang.invoke.MethodHandles;
 import java.lang.invoke.VarHandle;
 import java.util.Random;
 import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
 
 import org.openjdk.jcstress.annotations.Actor;
 import org.openjdk.jcstress.annotations.Arbiter;
@@ -56,7 +56,7 @@
 
     static {
         try {
-            vh = MethodHandles.byteBufferViewVarHandle($type$[].class, BIG_ENDIAN);
+            vh = MethodHandles.byteBufferViewVarHandle($type$[].class, ByteOrder.$byte_order$);
         } catch (Exception e) {
             throw new RuntimeException(e);
         }
--- a/jcstress-test-gen/src/main/resources/operationAtomic/byteBuffer/X-WeakCASTest.java.template	Fri Jun 10 16:26:59 2016 +0300
+++ b/jcstress-test-gen/src/main/resources/operationAtomic/byteBuffer/X-WeakCASTest.java.template	Fri Jun 10 16:39:06 2016 +0300
@@ -24,11 +24,11 @@
  */
 package $package$;
 
-import static java.nio.ByteOrder.BIG_ENDIAN;
 import java.lang.invoke.MethodHandles;
 import java.lang.invoke.VarHandle;
 import java.util.Random;
 import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
 
 import org.openjdk.jcstress.annotations.Actor;
 import org.openjdk.jcstress.annotations.Arbiter;
@@ -56,7 +56,7 @@
 
     static {
         try {
-            vh = MethodHandles.byteBufferViewVarHandle($type$[].class, BIG_ENDIAN);
+            vh = MethodHandles.byteBufferViewVarHandle($type$[].class, ByteOrder.$byte_order$);
         } catch (Exception e) {
             throw new RuntimeException(e);
         }