changeset 14069:d1b18cbc666d

Value Array clean up, remove packed layout, removed atomic impl
author dsimms
date Thu, 04 Feb 2016 08:18:31 +0100
parents a9c330f8a4cd
children ca246d44ad08
files make/mapfiles/libjava/mapfile-vers src/java.base/share/classes/java/util/Arrays.java src/java.base/share/classes/jdk/internal/misc/Unsafe.java src/java.base/share/classes/sun/misc/Unsafe.java src/java.base/share/native/include/jvm.h src/java.base/share/native/libjava/Arrays.c
diffstat 6 files changed, 65 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/make/mapfiles/libjava/mapfile-vers	Thu Jan 21 13:41:43 2016 +0100
+++ b/make/mapfiles/libjava/mapfile-vers	Thu Feb 04 08:18:31 2016 +0100
@@ -235,6 +235,8 @@
 		Java_java_security_AccessController_doPrivileged__Ljava_security_PrivilegedExceptionAction_2Ljava_security_AccessControlContext_2;
 		Java_java_security_AccessController_getStackAccessControlContext;
 		Java_java_security_AccessController_getInheritedAccessControlContext;
+                Java_java_util_Arrays_ensureAtomicAccess;
+                Java_java_util_Arrays_isAccessAtomic;
 		Java_java_util_TimeZone_getSystemTimeZoneID;
 		Java_java_util_TimeZone_getSystemGMTOffsetID;
 		Java_java_util_concurrent_atomic_AtomicLong_VMSupportsCS8;
--- a/src/java.base/share/classes/java/util/Arrays.java	Thu Jan 21 13:41:43 2016 +0100
+++ b/src/java.base/share/classes/java/util/Arrays.java	Thu Feb 04 08:18:31 2016 +0100
@@ -26,7 +26,6 @@
 package java.util;
 
 import jdk.internal.HotSpotIntrinsicCandidate;
-import jdk.internal.misc.Unsafe;
 
 import java.lang.reflect.Array;
 import java.util.concurrent.ForkJoinPool;
@@ -8887,7 +8886,6 @@
 
 
     // Valhalla prototype hacks...
-    private static final Unsafe unsafe = Unsafe.getUnsafe();
 
     /**
      * Query whether the given array supports atomic access.
@@ -8899,9 +8897,7 @@
      * @param array An array.
      * @return true if setting or getting elements are preformed atomically.
      */
-    public static /*<any T>*/ boolean isAccessAtomic(/*T[]*/Object array) {
-        return unsafe.isArrayAccessAtomic(array);
-    }
+    public static native /*<any T>*/ boolean isAccessAtomic(/*T[]*/Object array);
 
     /**
      * Enable atomic array access.
@@ -8909,15 +8905,10 @@
      * Ensures operations which read from or written elements to the array
      * may never interleave with other threads.
      *
-     * Note: this may hurt performance.
-     *
      * @param array An array.
      * @return an array, whose set or get elements will never interleave with
      *         other threads. Possibly a copy of the given <code>array</code>,
      *         possible the same array.
      */
-    public static /*<any T> T[]*/ Object ensureAtomicAccess(/*T[]*/Object array) {
-        return /*(T[])*/ unsafe.ensureArrayAtomicAccess(array);
-    }
-
+    public static native /*<any T> T[]*/ Object ensureAtomicAccess(/*T[]*/Object array);
 }
--- a/src/java.base/share/classes/jdk/internal/misc/Unsafe.java	Thu Jan 21 13:41:43 2016 +0100
+++ b/src/java.base/share/classes/jdk/internal/misc/Unsafe.java	Thu Feb 04 08:18:31 2016 +0100
@@ -1390,9 +1390,4 @@
     private static short convEndian(boolean big, short n) { return big == BE ? n : Short.reverseBytes(n)    ; }
     private static int convEndian(boolean big, int n)     { return big == BE ? n : Integer.reverseBytes(n)  ; }
     private static long convEndian(boolean big, long n)   { return big == BE ? n : Long.reverseBytes(n)     ; }
-
-    // Valhalla prototype hacks...
-
-    public final native boolean isArrayAccessAtomic(Object array);
-    public final native Object ensureArrayAtomicAccess(Object array);
 }
--- a/src/java.base/share/classes/sun/misc/Unsafe.java	Thu Jan 21 13:41:43 2016 +0100
+++ b/src/java.base/share/classes/sun/misc/Unsafe.java	Thu Feb 04 08:18:31 2016 +0100
@@ -1042,8 +1042,4 @@
     // JVM interface methods
     private native boolean unalignedAccess0();
     private native boolean isBigEndian0();
-
-    // Valhalla prototype hacks...
-    public final native boolean isArrayAccessAtomic(Object array);
-    public final native Object ensureArrayAtomicAccess(Object array);
 }
--- a/src/java.base/share/native/include/jvm.h	Thu Jan 21 13:41:43 2016 +0100
+++ b/src/java.base/share/native/include/jvm.h	Thu Feb 04 08:18:31 2016 +0100
@@ -551,6 +551,22 @@
 JVM_AssertionStatusDirectives(JNIEnv *env, jclass unused);
 
 /*
+ * java.util.Arrays
+ */
+
+/*
+ * Query whether access to the given array is atomic
+ */
+JNIEXPORT jboolean JNICALL
+JVM_ArrayIsAccessAtomic(JNIEnv *env, jclass unused, jobject array);
+
+/*
+ * Return an array whose loads and stores will always be atomic
+ */
+JNIEXPORT jobject JNICALL
+JVM_ArrayEnsureAccessAtomic(JNIEnv *env, jclass unused, jobject array);
+
+/*
  * java.util.concurrent.atomic.AtomicLong
  */
 JNIEXPORT jboolean JNICALL
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.base/share/native/libjava/Arrays.c	Thu Feb 04 08:18:31 2016 +0100
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2016, 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+#include "jni.h"
+#include "jvm.h"
+#include "java_util_Arrays.h"
+
+/*
+ * Native code for java.util.Arrays
+ */
+
+JNIEXPORT jboolean JNICALL
+Java_java_util_Arrays_isAccessAtomic(JNIEnv *env, jclass ignore, jobject arr)
+{
+    return JVM_ArrayIsAccessAtomic(env, ignore, arr);
+}
+
+JNIEXPORT jobject JNICALL
+Java_java_util_Arrays_ensureAtomicAccess(JNIEnv *env, jclass ignore, jobject arr)
+{
+    return JVM_ArrayEnsureAccessAtomic(env, ignore, arr);
+}
+