8197999: Accessors in typeArrayOopDesc should use new Access API
Reviewed-by: eosterlund, pliden
--- a/src/hotspot/share/ci/ciArray.cpp Wed Feb 21 07:49:36 2018 -0500
+++ b/src/hotspot/share/ci/ciArray.cpp Thu Feb 15 23:45:15 2018 +0100
@@ -30,7 +30,7 @@
#include "ci/ciUtilities.hpp"
#include "oops/objArrayOop.inline.hpp"
#include "oops/oop.inline.hpp"
-#include "oops/typeArrayOop.hpp"
+#include "oops/typeArrayOop.inline.hpp"
// ciArray
//
--- a/src/hotspot/share/ci/ciTypeArray.cpp Wed Feb 21 07:49:36 2018 -0500
+++ b/src/hotspot/share/ci/ciTypeArray.cpp Thu Feb 15 23:45:15 2018 +0100
@@ -25,6 +25,7 @@
#include "precompiled.hpp"
#include "ci/ciTypeArray.hpp"
#include "ci/ciUtilities.hpp"
+#include "oops/typeArrayOop.inline.hpp"
// ciTypeArray
//
--- a/src/hotspot/share/classfile/javaAssertions.cpp Wed Feb 21 07:49:36 2018 -0500
+++ b/src/hotspot/share/classfile/javaAssertions.cpp Thu Feb 15 23:45:15 2018 +0100
@@ -31,6 +31,7 @@
#include "memory/oopFactory.hpp"
#include "oops/objArrayOop.inline.hpp"
#include "oops/oop.inline.hpp"
+#include "oops/typeArrayOop.inline.hpp"
#include "runtime/handles.inline.hpp"
bool JavaAssertions::_userDefault = false;
--- a/src/hotspot/share/classfile/javaClasses.cpp Wed Feb 21 07:49:36 2018 -0500
+++ b/src/hotspot/share/classfile/javaClasses.cpp Thu Feb 15 23:45:15 2018 +0100
@@ -46,7 +46,7 @@
#include "oops/objArrayOop.inline.hpp"
#include "oops/oop.inline.hpp"
#include "oops/symbol.hpp"
-#include "oops/typeArrayOop.hpp"
+#include "oops/typeArrayOop.inline.hpp"
#include "prims/resolvedMethodTable.hpp"
#include "runtime/fieldDescriptor.hpp"
#include "runtime/handles.inline.hpp"
--- a/src/hotspot/share/jvmci/jvmciCodeInstaller.cpp Wed Feb 21 07:49:36 2018 -0500
+++ b/src/hotspot/share/jvmci/jvmciCodeInstaller.cpp Thu Feb 15 23:45:15 2018 +0100
@@ -36,6 +36,7 @@
#include "jvmci/jvmciRuntime.hpp"
#include "oops/oop.inline.hpp"
#include "oops/objArrayOop.inline.hpp"
+#include "oops/typeArrayOop.inline.hpp"
#include "runtime/javaCalls.hpp"
#include "runtime/safepointMechanism.inline.hpp"
#include "utilities/align.hpp"
--- a/src/hotspot/share/jvmci/jvmciCompilerToVM.cpp Wed Feb 21 07:49:36 2018 -0500
+++ b/src/hotspot/share/jvmci/jvmciCompilerToVM.cpp Thu Feb 15 23:45:15 2018 +0100
@@ -32,6 +32,7 @@
#include "oops/fieldStreams.hpp"
#include "oops/oop.inline.hpp"
#include "oops/objArrayOop.inline.hpp"
+#include "oops/typeArrayOop.inline.hpp"
#include "runtime/fieldDescriptor.hpp"
#include "runtime/javaCalls.hpp"
#include "jvmci/jvmciRuntime.hpp"
--- a/src/hotspot/share/oops/annotations.cpp Wed Feb 21 07:49:36 2018 -0500
+++ b/src/hotspot/share/oops/annotations.cpp Thu Feb 15 23:45:15 2018 +0100
@@ -31,6 +31,7 @@
#include "memory/oopFactory.hpp"
#include "oops/annotations.hpp"
#include "oops/instanceKlass.hpp"
+#include "oops/typeArrayOop.inline.hpp"
#include "utilities/ostream.hpp"
// Allocate annotations in metadata area
--- a/src/hotspot/share/oops/constantPool.cpp Wed Feb 21 07:49:36 2018 -0500
+++ b/src/hotspot/share/oops/constantPool.cpp Thu Feb 15 23:45:15 2018 +0100
@@ -43,6 +43,7 @@
#include "oops/objArrayKlass.hpp"
#include "oops/objArrayOop.inline.hpp"
#include "oops/oop.inline.hpp"
+#include "oops/typeArrayOop.inline.hpp"
#include "runtime/fieldType.hpp"
#include "runtime/init.hpp"
#include "runtime/javaCalls.hpp"
--- a/src/hotspot/share/oops/typeArrayOop.hpp Wed Feb 21 07:49:36 2018 -0500
+++ b/src/hotspot/share/oops/typeArrayOop.hpp Thu Feb 15 23:45:15 2018 +0100
@@ -34,6 +34,12 @@
#include <limits.h>
class typeArrayOopDesc : public arrayOopDesc {
+private:
+ template <class T>
+ static ptrdiff_t element_offset(BasicType bt, int index) {
+ return arrayOopDesc::base_offset_in_bytes(bt) + sizeof(T) * index;
+ }
+
protected:
jchar* char_base() const { return (jchar*) base(T_CHAR); }
jboolean* bool_base() const { return (jboolean*)base(T_BOOLEAN); }
@@ -92,52 +98,38 @@
return &double_base()[which];
}
- jbyte byte_at(int which) const { return *byte_at_addr(which); }
- void byte_at_put(int which, jbyte contents) { *byte_at_addr(which) = contents; }
+ jbyte byte_at(int which) const;
+ void byte_at_put(int which, jbyte contents);
- jboolean bool_at(int which) const { return *bool_at_addr(which); }
- void bool_at_put(int which, jboolean contents) { *bool_at_addr(which) = (((jint)contents) & 1); }
-
- jchar char_at(int which) const { return *char_at_addr(which); }
- void char_at_put(int which, jchar contents) { *char_at_addr(which) = contents; }
+ jboolean bool_at(int which) const;
+ void bool_at_put(int which, jboolean contents);
- jint int_at(int which) const { return *int_at_addr(which); }
- void int_at_put(int which, jint contents) { *int_at_addr(which) = contents; }
-
- jshort short_at(int which) const { return *short_at_addr(which); }
- void short_at_put(int which, jshort contents) { *short_at_addr(which) = contents; }
+ jchar char_at(int which) const;
+ void char_at_put(int which, jchar contents);
- jushort ushort_at(int which) const { return *ushort_at_addr(which); }
- void ushort_at_put(int which, jushort contents) { *ushort_at_addr(which) = contents; }
+ jint int_at(int which) const;
+ void int_at_put(int which, jint contents);
- jlong long_at(int which) const { return *long_at_addr(which); }
- void long_at_put(int which, jlong contents) { *long_at_addr(which) = contents; }
+ jshort short_at(int which) const;
+ void short_at_put(int which, jshort contents);
- jfloat float_at(int which) const { return *float_at_addr(which); }
- void float_at_put(int which, jfloat contents) { *float_at_addr(which) = contents; }
+ jushort ushort_at(int which) const;
+ void ushort_at_put(int which, jushort contents);
- jdouble double_at(int which) const { return *double_at_addr(which); }
- void double_at_put(int which, jdouble contents) { *double_at_addr(which) = contents; }
+ jlong long_at(int which) const;
+ void long_at_put(int which, jlong contents);
- jbyte byte_at_acquire(int which) const { return OrderAccess::load_acquire(byte_at_addr(which)); }
- void release_byte_at_put(int which, jbyte contents) { OrderAccess::release_store(byte_at_addr(which), contents); }
+ jfloat float_at(int which) const;
+ void float_at_put(int which, jfloat contents);
- // Java thinks Symbol arrays are just arrays of either long or int, since
- // there doesn't seem to be T_ADDRESS, so this is a bit of unfortunate
- // casting
-#ifdef _LP64
- Symbol* symbol_at(int which) const {
- return (Symbol*)*long_at_addr(which); }
- void symbol_at_put(int which, Symbol* contents) {
- *long_at_addr(which) = (jlong)contents;
- }
-#else
- Symbol* symbol_at(int which) const {
- return (Symbol*)*int_at_addr(which); }
- void symbol_at_put(int which, Symbol* contents) {
- *int_at_addr(which) = (int)contents;
- }
-#endif // _LP64
+ jdouble double_at(int which) const;
+ void double_at_put(int which, jdouble contents);
+
+ jbyte byte_at_acquire(int which) const;
+ void release_byte_at_put(int which, jbyte contents);
+
+ Symbol* symbol_at(int which) const;
+ void symbol_at_put(int which, Symbol* contents);
// Sizing
--- a/src/hotspot/share/oops/typeArrayOop.inline.hpp Wed Feb 21 07:49:36 2018 -0500
+++ b/src/hotspot/share/oops/typeArrayOop.inline.hpp Thu Feb 15 23:45:15 2018 +0100
@@ -25,6 +25,7 @@
#ifndef SHARE_VM_OOPS_TYPEARRAYOOP_INLINE_HPP
#define SHARE_VM_OOPS_TYPEARRAYOOP_INLINE_HPP
+#include "oops/access.inline.hpp"
#include "oops/oop.inline.hpp"
#include "oops/typeArrayOop.hpp"
@@ -33,4 +34,118 @@
return object_size(tk->layout_helper(), length());
}
+inline jbyte typeArrayOopDesc::byte_at(int which) const {
+ ptrdiff_t offset = element_offset<jbyte>(T_BYTE, which);
+ return HeapAccess<IN_HEAP_ARRAY>::load_at(as_oop(), offset);
+}
+inline void typeArrayOopDesc::byte_at_put(int which, jbyte contents) {
+ ptrdiff_t offset = element_offset<jbyte>(T_BYTE, which);
+ HeapAccess<IN_HEAP_ARRAY>::store_at(as_oop(), offset, contents);
+}
+
+inline jboolean typeArrayOopDesc::bool_at(int which) const {
+ ptrdiff_t offset = element_offset<jboolean>(T_BOOLEAN, which);
+ return HeapAccess<IN_HEAP_ARRAY>::load_at(as_oop(), offset);
+}
+inline void typeArrayOopDesc::bool_at_put(int which, jboolean contents) {
+ ptrdiff_t offset = element_offset<jboolean>(T_BOOLEAN, which);
+ HeapAccess<IN_HEAP_ARRAY>::store_at(as_oop(), offset, ((jint)contents) & 1);
+}
+
+inline jchar typeArrayOopDesc::char_at(int which) const {
+ ptrdiff_t offset = element_offset<jchar>(T_CHAR, which);
+ return HeapAccess<IN_HEAP_ARRAY>::load_at(as_oop(), offset);
+}
+inline void typeArrayOopDesc::char_at_put(int which, jchar contents) {
+ ptrdiff_t offset = element_offset<jchar>(T_CHAR, which);
+ HeapAccess<IN_HEAP_ARRAY>::store_at(as_oop(), offset, contents);
+}
+
+inline jint typeArrayOopDesc::int_at(int which) const {
+ ptrdiff_t offset = element_offset<jint>(T_INT, which);
+ return HeapAccess<IN_HEAP_ARRAY>::load_at(as_oop(), offset);
+}
+inline void typeArrayOopDesc::int_at_put(int which, jint contents) {
+ ptrdiff_t offset = element_offset<jint>(T_INT, which);
+ HeapAccess<IN_HEAP_ARRAY>::store_at(as_oop(), offset, contents);
+}
+
+inline jshort typeArrayOopDesc::short_at(int which) const {
+ ptrdiff_t offset = element_offset<jshort>(T_SHORT, which);
+ return HeapAccess<IN_HEAP_ARRAY>::load_at(as_oop(), offset);
+}
+inline void typeArrayOopDesc::short_at_put(int which, jshort contents) {
+ ptrdiff_t offset = element_offset<jshort>(T_BOOLEAN, which);
+ HeapAccess<IN_HEAP_ARRAY>::store_at(as_oop(), offset, contents);
+}
+
+inline jushort typeArrayOopDesc::ushort_at(int which) const {
+ ptrdiff_t offset = element_offset<jushort>(T_SHORT, which);
+ return HeapAccess<IN_HEAP_ARRAY>::load_at(as_oop(), offset);
+}
+inline void typeArrayOopDesc::ushort_at_put(int which, jushort contents) {
+ ptrdiff_t offset = element_offset<jushort>(T_SHORT, which);
+ HeapAccess<IN_HEAP_ARRAY>::store_at(as_oop(), offset, contents);
+}
+
+inline jlong typeArrayOopDesc::long_at(int which) const {
+ ptrdiff_t offset = element_offset<jlong>(T_LONG, which);
+ return HeapAccess<IN_HEAP_ARRAY>::load_at(as_oop(), offset);
+}
+inline void typeArrayOopDesc::long_at_put(int which, jlong contents) {
+ ptrdiff_t offset = element_offset<jlong>(T_LONG, which);
+ HeapAccess<IN_HEAP_ARRAY>::store_at(as_oop(), offset, contents);
+}
+
+inline jfloat typeArrayOopDesc::float_at(int which) const {
+ ptrdiff_t offset = element_offset<jfloat>(T_FLOAT, which);
+ return HeapAccess<IN_HEAP_ARRAY>::load_at(as_oop(), offset);
+}
+inline void typeArrayOopDesc::float_at_put(int which, jfloat contents) {
+ ptrdiff_t offset = element_offset<jfloat>(T_FLOAT, which);
+ HeapAccess<IN_HEAP_ARRAY>::store_at(as_oop(), offset, contents);
+}
+
+inline jdouble typeArrayOopDesc::double_at(int which) const {
+ ptrdiff_t offset = element_offset<jdouble>(T_DOUBLE, which);
+ return HeapAccess<IN_HEAP_ARRAY>::load_at(as_oop(), offset);
+}
+inline void typeArrayOopDesc::double_at_put(int which, jdouble contents) {
+ ptrdiff_t offset = element_offset<jdouble>(T_DOUBLE, which);
+ HeapAccess<IN_HEAP_ARRAY>::store_at(as_oop(), offset, contents);
+}
+
+inline jbyte typeArrayOopDesc::byte_at_acquire(int which) const {
+ ptrdiff_t offset = element_offset<jbyte>(T_BYTE, which);
+ return HeapAccess<MO_ACQUIRE | IN_HEAP_ARRAY>::load_at(as_oop(), offset);
+}
+inline void typeArrayOopDesc::release_byte_at_put(int which, jbyte contents) {
+ ptrdiff_t offset = element_offset<jbyte>(T_BYTE, which);
+ HeapAccess<MO_RELEASE | IN_HEAP_ARRAY>::store_at(as_oop(), offset, contents);
+}
+
+// Java thinks Symbol arrays are just arrays of either long or int, since
+// there doesn't seem to be T_ADDRESS, so this is a bit of unfortunate
+// casting
+#ifdef _LP64
+inline Symbol* typeArrayOopDesc::symbol_at(int which) const {
+ ptrdiff_t offset = element_offset<jlong>(T_LONG, which);
+ return (Symbol*)(jlong) HeapAccess<IN_HEAP_ARRAY>::load_at(as_oop(), offset);
+}
+inline void typeArrayOopDesc::symbol_at_put(int which, Symbol* contents) {
+ ptrdiff_t offset = element_offset<jlong>(T_LONG, which);
+ HeapAccess<IN_HEAP_ARRAY>::store_at(as_oop(), offset, (jlong)contents);
+}
+#else
+inline Symbol* typeArrayOopDesc::symbol_at(int which) const {
+ ptrdiff_t offset = element_offset<jint>(T_INT, which);
+ return (Symbol*)(jint) HeapAccess<IN_HEAP_ARRAY>::load_at(as_oop(), offset);
+}
+inline void typeArrayOopDesc::symbol_at_put(int which, Symbol* contents) {
+ ptrdiff_t offset = element_offset<jint>(T_INT, which);
+ HeapAccess<IN_HEAP_ARRAY>::store_at(as_oop(), offset, (jint)contents);
+}
+#endif // _LP64
+
+
#endif // SHARE_VM_OOPS_TYPEARRAYOOP_INLINE_HPP
--- a/src/hotspot/share/prims/jni.cpp Wed Feb 21 07:49:36 2018 -0500
+++ b/src/hotspot/share/prims/jni.cpp Thu Feb 15 23:45:15 2018 +0100
@@ -53,7 +53,7 @@
#include "oops/oop.inline.hpp"
#include "oops/symbol.hpp"
#include "oops/typeArrayKlass.hpp"
-#include "oops/typeArrayOop.hpp"
+#include "oops/typeArrayOop.inline.hpp"
#include "prims/jniCheck.hpp"
#include "prims/jniExport.hpp"
#include "prims/jniFastGetField.hpp"
--- a/src/hotspot/share/prims/jvmtiTagMap.cpp Wed Feb 21 07:49:36 2018 -0500
+++ b/src/hotspot/share/prims/jvmtiTagMap.cpp Thu Feb 15 23:45:15 2018 +0100
@@ -35,6 +35,7 @@
#include "oops/objArrayKlass.hpp"
#include "oops/objArrayOop.inline.hpp"
#include "oops/oop.inline.hpp"
+#include "oops/typeArrayOop.inline.hpp"
#include "prims/jvmtiEventController.hpp"
#include "prims/jvmtiEventController.inline.hpp"
#include "prims/jvmtiExport.hpp"
--- a/src/hotspot/share/prims/methodHandles.cpp Wed Feb 21 07:49:36 2018 -0500
+++ b/src/hotspot/share/prims/methodHandles.cpp Thu Feb 15 23:45:15 2018 +0100
@@ -36,6 +36,7 @@
#include "memory/resourceArea.hpp"
#include "oops/objArrayOop.inline.hpp"
#include "oops/oop.inline.hpp"
+#include "oops/typeArrayOop.inline.hpp"
#include "prims/methodHandles.hpp"
#include "runtime/compilationPolicy.hpp"
#include "runtime/javaCalls.hpp"
--- a/src/hotspot/share/prims/unsafe.cpp Wed Feb 21 07:49:36 2018 -0500
+++ b/src/hotspot/share/prims/unsafe.cpp Thu Feb 15 23:45:15 2018 +0100
@@ -33,6 +33,7 @@
#include "oops/fieldStreams.hpp"
#include "oops/objArrayOop.inline.hpp"
#include "oops/oop.inline.hpp"
+#include "oops/typeArrayOop.inline.hpp"
#include "prims/unsafe.hpp"
#include "runtime/atomic.hpp"
#include "runtime/globals.hpp"
--- a/src/hotspot/share/prims/whitebox.cpp Wed Feb 21 07:49:36 2018 -0500
+++ b/src/hotspot/share/prims/whitebox.cpp Thu Feb 15 23:45:15 2018 +0100
@@ -44,6 +44,7 @@
#include "oops/objArrayKlass.hpp"
#include "oops/objArrayOop.inline.hpp"
#include "oops/oop.inline.hpp"
+#include "oops/typeArrayOop.inline.hpp"
#include "prims/wbtestmethods/parserTests.hpp"
#include "prims/whitebox.hpp"
#include "runtime/arguments.hpp"
--- a/src/hotspot/share/runtime/deoptimization.cpp Wed Feb 21 07:49:36 2018 -0500
+++ b/src/hotspot/share/runtime/deoptimization.cpp Thu Feb 15 23:45:15 2018 +0100
@@ -40,6 +40,7 @@
#include "oops/objArrayOop.inline.hpp"
#include "oops/oop.inline.hpp"
#include "oops/fieldStreams.hpp"
+#include "oops/typeArrayOop.inline.hpp"
#include "oops/verifyOopClosure.hpp"
#include "prims/jvmtiThreadState.hpp"
#include "runtime/biasedLocking.hpp"
--- a/src/hotspot/share/runtime/reflection.cpp Wed Feb 21 07:49:36 2018 -0500
+++ b/src/hotspot/share/runtime/reflection.cpp Thu Feb 15 23:45:15 2018 +0100
@@ -39,6 +39,7 @@
#include "oops/objArrayKlass.hpp"
#include "oops/objArrayOop.inline.hpp"
#include "oops/oop.inline.hpp"
+#include "oops/typeArrayOop.inline.hpp"
#include "prims/jvmtiExport.hpp"
#include "runtime/arguments.hpp"
#include "runtime/handles.inline.hpp"
--- a/src/hotspot/share/runtime/thread.cpp Wed Feb 21 07:49:36 2018 -0500
+++ b/src/hotspot/share/runtime/thread.cpp Thu Feb 15 23:45:15 2018 +0100
@@ -51,6 +51,7 @@
#include "oops/objArrayOop.hpp"
#include "oops/oop.inline.hpp"
#include "oops/symbol.hpp"
+#include "oops/typeArrayOop.inline.hpp"
#include "oops/verifyOopClosure.hpp"
#include "prims/jvm_misc.hpp"
#include "prims/jvmtiExport.hpp"
--- a/src/hotspot/share/services/heapDumper.cpp Wed Feb 21 07:49:36 2018 -0500
+++ b/src/hotspot/share/services/heapDumper.cpp Thu Feb 15 23:45:15 2018 +0100
@@ -35,6 +35,7 @@
#include "oops/objArrayKlass.hpp"
#include "oops/objArrayOop.inline.hpp"
#include "oops/oop.inline.hpp"
+#include "oops/typeArrayOop.inline.hpp"
#include "runtime/javaCalls.hpp"
#include "runtime/jniHandles.hpp"
#include "runtime/os.hpp"
--- a/src/hotspot/share/services/management.cpp Wed Feb 21 07:49:36 2018 -0500
+++ b/src/hotspot/share/services/management.cpp Thu Feb 15 23:45:15 2018 +0100
@@ -33,6 +33,7 @@
#include "oops/objArrayKlass.hpp"
#include "oops/objArrayOop.inline.hpp"
#include "oops/oop.inline.hpp"
+#include "oops/typeArrayOop.inline.hpp"
#include "runtime/arguments.hpp"
#include "runtime/globals.hpp"
#include "runtime/handles.inline.hpp"