# HG changeset patch # Parent b892d18221519a45f8a88d659023adc8e8336fe1 diff --git a/src/hotspot/share/oops/access.cpp b/src/hotspot/share/oops/access.cpp --- a/src/hotspot/share/oops/access.cpp +++ b/src/hotspot/share/oops/access.cpp @@ -29,7 +29,7 @@ // This macro allows instantiating selected accesses to be usable from the // access.hpp file, to break dependencies to the access.inline.hpp file. #define INSTANTIATE_HPP_ACCESS(decorators, T, barrier_type) \ - template struct RuntimeDispatch::value, T, barrier_type> + template struct RuntimeDispatch::value, T, VoidAddr, VoidAddr, barrier_type> namespace AccessInternal { INSTANTIATE_HPP_ACCESS(INTERNAL_EMPTY, oop, BARRIER_EQUALS); diff --git a/src/hotspot/share/oops/access.hpp b/src/hotspot/share/oops/access.hpp --- a/src/hotspot/share/oops/access.hpp +++ b/src/hotspot/share/oops/access.hpp @@ -155,11 +155,11 @@ return AccessInternal::atomic_xchg_at(new_value, base, offset); } - template - static inline void arraycopy(arrayOop src_obj, arrayOop dst_obj, size_t src_offset_in_bytes, size_t dst_offset_in_bytes, T* src_raw, T* dst_raw, size_t length) { + template + static inline void arraycopy(SrcAddrType src, DstAddrType dst, size_t length) { verify_decorators(); - AccessInternal::arraycopy(src_obj, dst_obj, src_offset_in_bytes, dst_offset_in_bytes, src_raw, dst_raw, length); + AccessInternal::arraycopy(src, dst, length); } // Oop heap accesses @@ -193,10 +193,10 @@ return AccessInternal::atomic_xchg_at(new_oop_value, base, offset); } - template - static inline bool oop_arraycopy(arrayOop src_obj, arrayOop dst_obj, size_t src_offset_in_bytes, size_t dst_offset_in_bytes, T* src_raw, T* dst_raw, size_t length) { + template + static inline bool oop_arraycopy(SrcAddrType src, DstAddrType dst, size_t length) { verify_decorators(); - return AccessInternal::arraycopy(src_obj, dst_obj, src_offset_in_bytes, dst_offset_in_bytes, src_raw, dst_raw, length); + return AccessInternal::arraycopy(src, dst, length); } // Clone an object from src to dst diff --git a/src/hotspot/share/oops/access.inline.hpp b/src/hotspot/share/oops/access.inline.hpp --- a/src/hotspot/share/oops/access.inline.hpp +++ b/src/hotspot/share/oops/access.inline.hpp @@ -122,18 +122,16 @@ template struct PostRuntimeDispatch: public AllStatic { - template - static bool access_barrier(arrayOop src_obj, arrayOop dst_obj, size_t src_offset_in_bytes, size_t dst_offset_in_bytes, T* src_raw, T* dst_raw, size_t length) { - GCBarrierType::arraycopy_in_heap(src_obj, dst_obj, src_offset_in_bytes, dst_offset_in_bytes, src_raw, dst_raw, length); + template + static bool access_barrier(SrcAddrType src, DstAddrType dst, size_t length) { + GCBarrierType::arraycopy_in_heap(src, dst, length); return true; } - template - static bool oop_access_barrier(arrayOop src_obj, arrayOop dst_obj, size_t src_offset_in_bytes, size_t dst_offset_in_bytes, T* src_raw, T* dst_raw, size_t length) { + template + static bool oop_access_barrier(SrcAddrType src, DstAddrType dst, size_t length) { typedef typename HeapOopType::type OopType; - return GCBarrierType::oop_arraycopy_in_heap(src_obj, dst_obj, src_offset_in_bytes, dst_offset_in_bytes, - reinterpret_cast(src_raw), - reinterpret_cast(dst_raw), length); + return GCBarrierType::oop_arraycopy_in_heap(src, dst, length); } }; @@ -280,85 +278,85 @@ // it resolves which accessor to be used in future invocations and patches the // function pointer to this new accessor. - template - void RuntimeDispatch::store_init(void* addr, T value) { + template + void RuntimeDispatch::store_init(void* addr, T value) { func_t function = BarrierResolver::resolve_barrier(); _store_func = function; function(addr, value); } - template - void RuntimeDispatch::store_at_init(oop base, ptrdiff_t offset, T value) { + template + void RuntimeDispatch::store_at_init(oop base, ptrdiff_t offset, T value) { func_t function = BarrierResolver::resolve_barrier(); _store_at_func = function; function(base, offset, value); } - template - T RuntimeDispatch::load_init(void* addr) { + template + T RuntimeDispatch::load_init(void* addr) { func_t function = BarrierResolver::resolve_barrier(); _load_func = function; return function(addr); } - template - T RuntimeDispatch::load_at_init(oop base, ptrdiff_t offset) { + template + T RuntimeDispatch::load_at_init(oop base, ptrdiff_t offset) { func_t function = BarrierResolver::resolve_barrier(); _load_at_func = function; return function(base, offset); } - template - T RuntimeDispatch::atomic_cmpxchg_init(T new_value, void* addr, T compare_value) { + template + T RuntimeDispatch::atomic_cmpxchg_init(T new_value, void* addr, T compare_value) { func_t function = BarrierResolver::resolve_barrier(); _atomic_cmpxchg_func = function; return function(new_value, addr, compare_value); } - template - T RuntimeDispatch::atomic_cmpxchg_at_init(T new_value, oop base, ptrdiff_t offset, T compare_value) { + template + T RuntimeDispatch::atomic_cmpxchg_at_init(T new_value, oop base, ptrdiff_t offset, T compare_value) { func_t function = BarrierResolver::resolve_barrier(); _atomic_cmpxchg_at_func = function; return function(new_value, base, offset, compare_value); } - template - T RuntimeDispatch::atomic_xchg_init(T new_value, void* addr) { + template + T RuntimeDispatch::atomic_xchg_init(T new_value, void* addr) { func_t function = BarrierResolver::resolve_barrier(); _atomic_xchg_func = function; return function(new_value, addr); } - template - T RuntimeDispatch::atomic_xchg_at_init(T new_value, oop base, ptrdiff_t offset) { + template + T RuntimeDispatch::atomic_xchg_at_init(T new_value, oop base, ptrdiff_t offset) { func_t function = BarrierResolver::resolve_barrier(); _atomic_xchg_at_func = function; return function(new_value, base, offset); } - template - bool RuntimeDispatch::arraycopy_init(arrayOop src_obj, arrayOop dst_obj, size_t src_offset_in_bytes, size_t dst_offset_in_bytes, T* src_raw, T* dst_raw, size_t length) { + template + bool RuntimeDispatch::arraycopy_init(SrcAddrType src, DstAddrType dst, size_t length) { func_t function = BarrierResolver::resolve_barrier(); _arraycopy_func = function; - return function(src_obj, dst_obj, src_offset_in_bytes, dst_offset_in_bytes, src_raw, dst_raw, length); + return function(src, dst, length); } - template - void RuntimeDispatch::clone_init(oop src, oop dst, size_t size) { + template + void RuntimeDispatch::clone_init(oop src, oop dst, size_t size) { func_t function = BarrierResolver::resolve_barrier(); _clone_func = function; function(src, dst, size); } - template - oop RuntimeDispatch::resolve_init(oop obj) { + template + oop RuntimeDispatch::resolve_init(oop obj) { func_t function = BarrierResolver::resolve_barrier(); _resolve_func = function; return function(obj); } - template - bool RuntimeDispatch::equals_init(oop o1, oop o2) { + template + bool RuntimeDispatch::equals_init(oop o1, oop o2) { func_t function = BarrierResolver::resolve_barrier(); _equals_func = function; return function(o1, o2); diff --git a/src/hotspot/share/oops/accessAddress.hpp b/src/hotspot/share/oops/accessAddress.hpp new file mode 100644 --- /dev/null +++ b/src/hotspot/share/oops/accessAddress.hpp @@ -0,0 +1,37 @@ + +#ifndef SHARE_OOPS_ACCESSADDRESS_HPP +#define SHARE_OOPS_ACCESSADDRESS_HPP + +#include "oops/accessDecorators.hpp" +#include "oops/oop.hpp" + +template +class HeapAddress { +private: + oop _object; + size_t _offset; + +public: + HeapAddress(oop object, size_t offset) : _object(object), _offset(offset) {} + T* address() { + char* base = reinterpret_cast((void*) _object); + return reinterpret_cast(base + _offset); + } +}; + +template +class RawAddress { +private: + T* _address; + +public: + RawAddress(T* address) : _address(address) {} + T* address() { + return _address; + } +}; + +class VoidAddress { +}; + +#endif // SHARE_OOPS_ACCESSADDRESS_HPP diff --git a/src/hotspot/share/oops/accessBackend.hpp b/src/hotspot/share/oops/accessBackend.hpp --- a/src/hotspot/share/oops/accessBackend.hpp +++ b/src/hotspot/share/oops/accessBackend.hpp @@ -41,6 +41,7 @@ #include "utilities/debug.hpp" #include "utilities/globalDefinitions.hpp" +class VoidAddr; // This metafunction returns either oop or narrowOop depending on whether // an access needs to use compressed oops or not. @@ -98,7 +99,7 @@ struct PossiblyLockedAccess: public IntegralConstant 4)> {}; #endif - template + template struct AccessFunctionTypes { typedef T (*load_at_func_t)(oop base, ptrdiff_t offset); typedef void (*store_at_func_t)(oop base, ptrdiff_t offset, T value); @@ -110,23 +111,18 @@ typedef T (*atomic_cmpxchg_func_t)(T new_value, void* addr, T compare_value); typedef T (*atomic_xchg_func_t)(T new_value, void* addr); - typedef bool (*arraycopy_func_t)(arrayOop src_obj, arrayOop dst_obj, size_t src_offset_in_bytes, size_t dst_offset_in_bytes, T* src_raw, T* dst_raw, size_t length); + typedef bool (*arraycopy_func_t)(SrcAddrType src, DstAddrType dst, size_t length); typedef void (*clone_func_t)(oop src, oop dst, size_t size); typedef oop (*resolve_func_t)(oop obj); typedef bool (*equals_func_t)(oop o1, oop o2); }; - template - struct AccessFunctionTypes { - typedef bool (*arraycopy_func_t)(arrayOop src_obj, arrayOop dst_obj, size_t src_offset_in_bytes, size_t dst_offset_in_bytes, void* src, void* dst, size_t length); - }; - - template struct AccessFunction {}; + template struct AccessFunction {}; #define ACCESS_GENERATE_ACCESS_FUNCTION(bt, func) \ - template \ - struct AccessFunction: AllStatic{ \ - typedef typename AccessFunctionTypes::func type; \ + template \ + struct AccessFunction: AllStatic{ \ + typedef typename AccessFunctionTypes::func type; \ } ACCESS_GENERATE_ACCESS_FUNCTION(BARRIER_STORE, store_func_t); ACCESS_GENERATE_ACCESS_FUNCTION(BARRIER_STORE_AT, store_at_func_t); @@ -142,11 +138,11 @@ ACCESS_GENERATE_ACCESS_FUNCTION(BARRIER_EQUALS, equals_func_t); #undef ACCESS_GENERATE_ACCESS_FUNCTION - template - typename AccessFunction::type resolve_barrier(); + template + typename AccessFunction::type resolve_barrier(); - template - typename AccessFunction::type resolve_oop_barrier(); + template + typename AccessFunction::type resolve_oop_barrier(); class AccessLocker { public: @@ -352,8 +348,8 @@ return atomic_xchg_maybe_locked(new_value, addr); } - template - static bool arraycopy(arrayOop src_obj, arrayOop dst_obj, size_t src_offset_in_bytes, size_t dst_offset_in_bytes, T* src_raw, T* dst_raw, size_t length); + template + static bool arraycopy(SrcAddrType src, DstAddrType dst, size_t length); template static void oop_store(void* addr, T value); @@ -395,8 +391,8 @@ return atomic_xchg(new_value, field_addr(base, offset)); } - template - static bool oop_arraycopy(arrayOop src_obj, arrayOop dst_obj, size_t src_offset_in_bytes, size_t dst_offset_in_bytes, T* src_raw, T* dst_raw, size_t length); + template + static bool oop_arraycopy(SrcAddrType src, DstAddrType dst, size_t length); static void clone(oop src, oop dst, size_t size); @@ -455,12 +451,12 @@ // it resolves which accessor to be used in future invocations and patches the // function pointer to this new accessor. - template + template struct RuntimeDispatch: AllStatic {}; - template - struct RuntimeDispatch: AllStatic { - typedef typename AccessFunction::type func_t; + template + struct RuntimeDispatch: AllStatic { + typedef typename AccessFunction::type func_t; static func_t _store_func; static void store_init(void* addr, T value); @@ -470,9 +466,9 @@ } }; - template - struct RuntimeDispatch: AllStatic { - typedef typename AccessFunction::type func_t; + template + struct RuntimeDispatch: AllStatic { + typedef typename AccessFunction::type func_t; static func_t _store_at_func; static void store_at_init(oop base, ptrdiff_t offset, T value); @@ -482,9 +478,9 @@ } }; - template - struct RuntimeDispatch: AllStatic { - typedef typename AccessFunction::type func_t; + template + struct RuntimeDispatch: AllStatic { + typedef typename AccessFunction::type func_t; static func_t _load_func; static T load_init(void* addr); @@ -494,9 +490,9 @@ } }; - template - struct RuntimeDispatch: AllStatic { - typedef typename AccessFunction::type func_t; + template + struct RuntimeDispatch: AllStatic { + typedef typename AccessFunction::type func_t; static func_t _load_at_func; static T load_at_init(oop base, ptrdiff_t offset); @@ -506,9 +502,9 @@ } }; - template - struct RuntimeDispatch: AllStatic { - typedef typename AccessFunction::type func_t; + template + struct RuntimeDispatch: AllStatic { + typedef typename AccessFunction::type func_t; static func_t _atomic_cmpxchg_func; static T atomic_cmpxchg_init(T new_value, void* addr, T compare_value); @@ -518,9 +514,9 @@ } }; - template - struct RuntimeDispatch: AllStatic { - typedef typename AccessFunction::type func_t; + template + struct RuntimeDispatch: AllStatic { + typedef typename AccessFunction::type func_t; static func_t _atomic_cmpxchg_at_func; static T atomic_cmpxchg_at_init(T new_value, oop base, ptrdiff_t offset, T compare_value); @@ -530,9 +526,9 @@ } }; - template - struct RuntimeDispatch: AllStatic { - typedef typename AccessFunction::type func_t; + template + struct RuntimeDispatch: AllStatic { + typedef typename AccessFunction::type func_t; static func_t _atomic_xchg_func; static T atomic_xchg_init(T new_value, void* addr); @@ -542,9 +538,9 @@ } }; - template - struct RuntimeDispatch: AllStatic { - typedef typename AccessFunction::type func_t; + template + struct RuntimeDispatch: AllStatic { + typedef typename AccessFunction::type func_t; static func_t _atomic_xchg_at_func; static T atomic_xchg_at_init(T new_value, oop base, ptrdiff_t offset); @@ -554,21 +550,21 @@ } }; - template - struct RuntimeDispatch: AllStatic { - typedef typename AccessFunction::type func_t; + template + struct RuntimeDispatch: AllStatic { + typedef typename AccessFunction::type func_t; static func_t _arraycopy_func; - static bool arraycopy_init(arrayOop src_obj, arrayOop dst_obj, size_t src_offset_in_bytes, size_t dst_offset_in_bytes, T* src_raw, T* dst_raw, size_t length); + static bool arraycopy_init(SrcAddrType src, DstAddrType dst, size_t length); - static inline bool arraycopy(arrayOop src_obj, arrayOop dst_obj, size_t src_offset_in_bytes, size_t dst_offset_in_bytes, T* src_raw, T* dst_raw, size_t length) { - return _arraycopy_func(src_obj, dst_obj, src_offset_in_bytes, dst_offset_in_bytes, src_raw, dst_raw, length); + static inline bool arraycopy(SrcAddrType src, DstAddrType dst, size_t length) { + return _arraycopy_func(src, dst, length); } }; - template - struct RuntimeDispatch: AllStatic { - typedef typename AccessFunction::type func_t; + template + struct RuntimeDispatch: AllStatic { + typedef typename AccessFunction::type func_t; static func_t _clone_func; static void clone_init(oop src, oop dst, size_t size); @@ -578,9 +574,9 @@ } }; - template - struct RuntimeDispatch: AllStatic { - typedef typename AccessFunction::type func_t; + template + struct RuntimeDispatch: AllStatic { + typedef typename AccessFunction::type func_t; static func_t _resolve_func; static oop resolve_init(oop obj); @@ -590,9 +586,9 @@ } }; - template - struct RuntimeDispatch: AllStatic { - typedef typename AccessFunction::type func_t; + template + struct RuntimeDispatch: AllStatic { + typedef typename AccessFunction::type func_t; static func_t _equals_func; static bool equals_init(oop o1, oop o2); @@ -603,53 +599,53 @@ }; // Initialize the function pointers to point to the resolving function. - template - typename AccessFunction::type - RuntimeDispatch::_store_func = &store_init; + template + typename AccessFunction::type + RuntimeDispatch::_store_func = &store_init; - template - typename AccessFunction::type - RuntimeDispatch::_store_at_func = &store_at_init; + template + typename AccessFunction::type + RuntimeDispatch::_store_at_func = &store_at_init; - template - typename AccessFunction::type - RuntimeDispatch::_load_func = &load_init; + template + typename AccessFunction::type + RuntimeDispatch::_load_func = &load_init; - template - typename AccessFunction::type - RuntimeDispatch::_load_at_func = &load_at_init; + template + typename AccessFunction::type + RuntimeDispatch::_load_at_func = &load_at_init; - template - typename AccessFunction::type - RuntimeDispatch::_atomic_cmpxchg_func = &atomic_cmpxchg_init; + template + typename AccessFunction::type + RuntimeDispatch::_atomic_cmpxchg_func = &atomic_cmpxchg_init; - template - typename AccessFunction::type - RuntimeDispatch::_atomic_cmpxchg_at_func = &atomic_cmpxchg_at_init; + template + typename AccessFunction::type + RuntimeDispatch::_atomic_cmpxchg_at_func = &atomic_cmpxchg_at_init; - template - typename AccessFunction::type - RuntimeDispatch::_atomic_xchg_func = &atomic_xchg_init; + template + typename AccessFunction::type + RuntimeDispatch::_atomic_xchg_func = &atomic_xchg_init; - template - typename AccessFunction::type - RuntimeDispatch::_atomic_xchg_at_func = &atomic_xchg_at_init; + template + typename AccessFunction::type + RuntimeDispatch::_atomic_xchg_at_func = &atomic_xchg_at_init; - template - typename AccessFunction::type - RuntimeDispatch::_arraycopy_func = &arraycopy_init; + template + typename AccessFunction::type + RuntimeDispatch::_arraycopy_func = &arraycopy_init; - template - typename AccessFunction::type - RuntimeDispatch::_clone_func = &clone_init; + template + typename AccessFunction::type + RuntimeDispatch::_clone_func = &clone_init; - template - typename AccessFunction::type - RuntimeDispatch::_resolve_func = &resolve_init; + template + typename AccessFunction::type + RuntimeDispatch::_resolve_func = &resolve_init; - template - typename AccessFunction::type - RuntimeDispatch::_equals_func = &equals_init; + template + typename AccessFunction::type + RuntimeDispatch::_equals_func = &equals_init; // Step 3: Pre-runtime dispatching. // The PreRuntimeDispatch class is responsible for filtering the barrier strength @@ -706,7 +702,7 @@ const DecoratorSet expanded_decorators = decorators | AS_RAW; PreRuntimeDispatch::store(addr, value); } else { - RuntimeDispatch::store(addr, value); + RuntimeDispatch::store(addr, value); } } @@ -725,7 +721,7 @@ const DecoratorSet expanded_decorators = decorators | AS_RAW; PreRuntimeDispatch::store_at(base, offset, value); } else { - RuntimeDispatch::store_at(base, offset, value); + RuntimeDispatch::store_at(base, offset, value); } } @@ -762,7 +758,7 @@ const DecoratorSet expanded_decorators = decorators | AS_RAW; return PreRuntimeDispatch::load(addr); } else { - return RuntimeDispatch::load(addr); + return RuntimeDispatch::load(addr); } } @@ -781,7 +777,7 @@ const DecoratorSet expanded_decorators = decorators | AS_RAW; return PreRuntimeDispatch::load_at(base, offset); } else { - return RuntimeDispatch::load_at(base, offset); + return RuntimeDispatch::load_at(base, offset); } } @@ -818,7 +814,7 @@ const DecoratorSet expanded_decorators = decorators | AS_RAW; return PreRuntimeDispatch::atomic_cmpxchg(new_value, addr, compare_value); } else { - return RuntimeDispatch::atomic_cmpxchg(new_value, addr, compare_value); + return RuntimeDispatch::atomic_cmpxchg(new_value, addr, compare_value); } } @@ -837,7 +833,7 @@ const DecoratorSet expanded_decorators = decorators | AS_RAW; return PreRuntimeDispatch::atomic_cmpxchg_at(new_value, base, offset, compare_value); } else { - return RuntimeDispatch::atomic_cmpxchg_at(new_value, base, offset, compare_value); + return RuntimeDispatch::atomic_cmpxchg_at(new_value, base, offset, compare_value); } } @@ -874,7 +870,7 @@ const DecoratorSet expanded_decorators = decorators | AS_RAW; return PreRuntimeDispatch::atomic_xchg(new_value, addr); } else { - return RuntimeDispatch::atomic_xchg(new_value, addr); + return RuntimeDispatch::atomic_xchg(new_value, addr); } } @@ -893,44 +889,44 @@ const DecoratorSet expanded_decorators = decorators | AS_RAW; return PreRuntimeDispatch::atomic_xchg(new_value, base, offset); } else { - return RuntimeDispatch::atomic_xchg_at(new_value, base, offset); + return RuntimeDispatch::atomic_xchg_at(new_value, base, offset); } } - template + template inline static typename EnableIf< HasDecorator::value && CanHardwireRaw::value, bool>::type - arraycopy(arrayOop src_obj, arrayOop dst_obj, size_t src_offset_in_bytes, size_t dst_offset_in_bytes, T* src_raw, T* dst_raw, size_t length) { + arraycopy(SrcAddrType src, DstAddrType dst, size_t length) { typedef RawAccessBarrier Raw; if (HasDecorator::value) { - return Raw::oop_arraycopy(src_obj, dst_obj, src_offset_in_bytes, dst_offset_in_bytes, src_raw, dst_raw, length); + return Raw::oop_arraycopy(src, dst, length); } else { - return Raw::arraycopy(src_obj, dst_obj, src_offset_in_bytes, dst_offset_in_bytes, src_raw, dst_raw, length); + return Raw::arraycopy(src, dst, length); } } - template + template inline static typename EnableIf< HasDecorator::value && !CanHardwireRaw::value, bool>::type - arraycopy(arrayOop src_obj, arrayOop dst_obj, size_t src_offset_in_bytes, size_t dst_offset_in_bytes, T* src_raw, T* dst_raw, size_t length) { + arraycopy(SrcAddrType src, DstAddrType dst, size_t length) { if (UseCompressedOops) { const DecoratorSet expanded_decorators = decorators | convert_compressed_oops; - return PreRuntimeDispatch::arraycopy(src_obj, dst_obj, src_offset_in_bytes, dst_offset_in_bytes, src_raw, dst_raw, length); + return PreRuntimeDispatch::arraycopy(src, dst, length); } else { const DecoratorSet expanded_decorators = decorators & ~convert_compressed_oops; - return PreRuntimeDispatch::arraycopy(src_obj, dst_obj, src_offset_in_bytes, dst_offset_in_bytes, src_raw, dst_raw, length); + return PreRuntimeDispatch::arraycopy(src, dst, length); } } - template + template inline static typename EnableIf< !HasDecorator::value, bool>::type - arraycopy(arrayOop src_obj, arrayOop dst_obj, size_t src_offset_in_bytes, size_t dst_offset_in_bytes, T* src_raw, T* dst_raw, size_t length) { + arraycopy(SrcAddrType src, DstAddrType dst, size_t length) { if (is_hardwired_primitive()) { const DecoratorSet expanded_decorators = decorators | AS_RAW; - return PreRuntimeDispatch::arraycopy(src_obj, dst_obj, src_offset_in_bytes, dst_offset_in_bytes, src_raw, dst_raw, length); + return PreRuntimeDispatch::arraycopy(src, dst, length); } else { - return RuntimeDispatch::arraycopy(src_obj, dst_obj, src_offset_in_bytes, dst_offset_in_bytes, src_raw, dst_raw, length); + return RuntimeDispatch::arraycopy(src, dst, length); } } @@ -946,7 +942,7 @@ inline static typename EnableIf< !HasDecorator::value>::type clone(oop src, oop dst, size_t size) { - RuntimeDispatch::clone(src, dst, size); + RuntimeDispatch::clone(src, dst, size); } template @@ -961,7 +957,7 @@ inline static typename EnableIf< !HasDecorator::value, oop>::type resolve(oop obj) { - return RuntimeDispatch::resolve(obj); + return RuntimeDispatch::resolve(obj); } template @@ -976,7 +972,7 @@ inline static typename EnableIf< !HasDecorator::value, bool>::type equals(oop o1, oop o2) { - return RuntimeDispatch::equals(o1, o2); + return RuntimeDispatch::equals(o1, o2); } }; @@ -1116,24 +1112,24 @@ return PreRuntimeDispatch::load(addr); } - template - inline bool arraycopy_reduce_types(arrayOop src_obj, arrayOop dst_obj, size_t src_offset_in_bytes, size_t dst_offset_in_bytes, T* src_raw, T* dst_raw, size_t length) { - return PreRuntimeDispatch::arraycopy(src_obj, dst_obj, src_offset_in_bytes, dst_offset_in_bytes, src_raw, dst_raw, length); + template + inline bool arraycopy_reduce_types(SrcAddrType src, DstAddrType dst, size_t length) { + return PreRuntimeDispatch::arraycopy(src, dst, length); } - template - inline bool arraycopy_reduce_types(arrayOop src_obj, arrayOop dst_obj, size_t src_offset_in_bytes, size_t dst_offset_in_bytes, HeapWord* src_raw, HeapWord* dst_raw, size_t length) { + template + inline bool arraycopy_reduce_types(SrcAddrType src, DstAddrType dst, size_t length) { const DecoratorSet expanded_decorators = decorators | INTERNAL_CONVERT_COMPRESSED_OOP; - return PreRuntimeDispatch::arraycopy(src_obj, dst_obj, src_offset_in_bytes, dst_offset_in_bytes, src_raw, dst_raw, length); + return PreRuntimeDispatch::arraycopy(src, dst, length); } - - template - inline bool arraycopy_reduce_types(arrayOop src_obj, arrayOop dst_obj, size_t src_offset_in_bytes, size_t dst_offset_in_bytes, narrowOop* src_raw, narrowOop* dst_raw, size_t length) { + /* + template + inline bool arraycopy_reduce_types(SrcAddrType src, DstAddrType dst, size_t length) { const DecoratorSet expanded_decorators = decorators | INTERNAL_CONVERT_COMPRESSED_OOP | INTERNAL_RT_USE_COMPRESSED_OOPS; - return PreRuntimeDispatch::arraycopy(src_obj, dst_obj, src_offset_in_bytes, dst_offset_in_bytes, src_raw, dst_raw, length); + return PreRuntimeDispatch::arraycopy(src, dst, length); } - + */ // Step 1: Set default decorators. This step remembers if a type was volatile // and then sets the MO_VOLATILE decorator by default. Otherwise, a default // memory ordering is set for the access, and the implied decorator rules @@ -1263,17 +1259,14 @@ return PreRuntimeDispatch::atomic_xchg_at(new_decayed_value, base, offset); } - template - inline bool arraycopy(arrayOop src_obj, arrayOop dst_obj, size_t src_offset_in_bytes, size_t dst_offset_in_bytes, T* src_raw, T* dst_raw, size_t length) { + template + inline bool arraycopy(SrcAddrType src, DstAddrType dst, size_t length) { STATIC_ASSERT((HasDecorator::value || (IsSame::value || IsIntegral::value) || IsFloatingPoint::value)); // arraycopy allows type erased void elements typedef typename Decay::type DecayedT; const DecoratorSet expanded_decorators = DecoratorFixup::value; - return arraycopy_reduce_types(src_obj, dst_obj, src_offset_in_bytes, dst_offset_in_bytes, - const_cast(src_raw), - const_cast(dst_raw), - length); + return arraycopy_reduce_types(src, dst, length); } template diff --git a/src/hotspot/share/oops/accessBackend.inline.hpp b/src/hotspot/share/oops/accessBackend.inline.hpp --- a/src/hotspot/share/oops/accessBackend.inline.hpp +++ b/src/hotspot/share/oops/accessBackend.inline.hpp @@ -117,9 +117,9 @@ } template -template -inline bool RawAccessBarrier::oop_arraycopy(arrayOop src_obj, arrayOop dst_obj, size_t src_offset_in_bytes, size_t dst_offset_in_bytes, T* src_raw, T* dst_raw, size_t length) { - return arraycopy(src_obj, dst_obj, src_offset_in_bytes, dst_offset_in_bytes, src_raw, dst_raw, length); +template +inline bool RawAccessBarrier::oop_arraycopy(SrcAddrType src, DstAddrType dst, size_t length) { + return arraycopy(src, dst, length); } template @@ -244,13 +244,13 @@ class RawAccessBarrierArrayCopy: public AllStatic { public: - template + template static inline typename EnableIf< HasDecorator::value>::type - arraycopy(arrayOop src_obj, arrayOop dst_obj, size_t src_offset_in_bytes, size_t dst_offset_in_bytes, T* src_raw, T* dst_raw, size_t length) { + arraycopy(SrcAddrType src, DstAddrType dst, size_t length) { - src_raw = arrayOopDesc::obj_offset_to_raw(src_obj, src_offset_in_bytes, src_raw); - dst_raw = arrayOopDesc::obj_offset_to_raw(dst_obj, dst_offset_in_bytes, dst_raw); + T* src_raw = src.address(); + T* dst_raw = dst.address(); // We do not check for ARRAYCOPY_ATOMIC for oops, because they are unconditionally always atomic. if (HasDecorator::value) { @@ -262,13 +262,13 @@ } } - template + template static inline typename EnableIf< !HasDecorator::value>::type - arraycopy(arrayOop src_obj, arrayOop dst_obj, size_t src_offset_in_bytes, size_t dst_offset_in_bytes, T* src_raw, T* dst_raw, size_t length) { + arraycopy(SrcAddrType src, DstAddrType dst, size_t length) { - src_raw = arrayOopDesc::obj_offset_to_raw(src_obj, src_offset_in_bytes, src_raw); - dst_raw = arrayOopDesc::obj_offset_to_raw(dst_obj, dst_offset_in_bytes, dst_raw); + T* src_raw = src.address(); + T* dst_raw = dst.address(); if (HasDecorator::value) { AccessInternal::arraycopy_arrayof_conjoint(src_raw, dst_raw, length); @@ -288,13 +288,13 @@ } } - template + template static inline typename EnableIf< !HasDecorator::value>::type - arraycopy(arrayOop src_obj, arrayOop dst_obj, size_t src_offset_in_bytes, size_t dst_offset_in_bytes, void* src_raw, void* dst_raw, size_t length) { + arraycopy(SrcAddrType src, DstAddrType dst, size_t length) { - src_raw = arrayOopDesc::obj_offset_to_raw(src_obj, src_offset_in_bytes, src_raw); - dst_raw = arrayOopDesc::obj_offset_to_raw(dst_obj, dst_offset_in_bytes, dst_raw); + void* src_raw = src.address(); + void* dst_raw = dst.address(); if (HasDecorator::value) { AccessInternal::arraycopy_conjoint_atomic(src_raw, dst_raw, length); @@ -305,9 +305,9 @@ }; template -template -inline bool RawAccessBarrier::arraycopy(arrayOop src_obj, arrayOop dst_obj, size_t src_offset_in_bytes, size_t dst_offset_in_bytes, T* src_raw, T* dst_raw, size_t length) { - RawAccessBarrierArrayCopy::arraycopy(src_obj, dst_obj, src_offset_in_bytes, dst_offset_in_bytes, src_raw, dst_raw, length); +template +inline bool RawAccessBarrier::arraycopy(SrcAddrType src, DstAddrType dst, size_t length) { + RawAccessBarrierArrayCopy::arraycopy(src, dst, length); return true; } diff --git a/src/hotspot/share/oops/typeArrayOop.hpp b/src/hotspot/share/oops/typeArrayOop.hpp --- a/src/hotspot/share/oops/typeArrayOop.hpp +++ b/src/hotspot/share/oops/typeArrayOop.hpp @@ -33,12 +33,6 @@ #include class typeArrayOopDesc : public arrayOopDesc { -private: - template - static ptrdiff_t element_offset(BasicType bt, int index) { - return arrayOopDesc::base_offset_in_bytes(bt) + sizeof(T) * index; - } - protected: jchar* char_base() const; jboolean* bool_base() const; @@ -52,6 +46,11 @@ friend class TypeArrayKlass; public: + template + static ptrdiff_t element_offset(BasicType bt, int index) { + return arrayOopDesc::base_offset_in_bytes(bt) + sizeof(T) * index; + } + jbyte* byte_at_addr(int which) const; jboolean* bool_at_addr(int which) const; jchar* char_at_addr(int which) const; diff --git a/src/hotspot/share/prims/jni.cpp b/src/hotspot/share/prims/jni.cpp --- a/src/hotspot/share/prims/jni.cpp +++ b/src/hotspot/share/prims/jni.cpp @@ -44,6 +44,7 @@ #include "memory/resourceArea.hpp" #include "memory/universe.hpp" #include "oops/access.inline.hpp" +#include "oops/accessAddress.hpp" #include "oops/arrayOop.inline.hpp" #include "oops/instanceKlass.hpp" #include "oops/instanceOop.hpp" @@ -2465,7 +2466,7 @@ if (buf != NULL) { if (s_len > 0) { if (!is_latin1) { - memcpy(buf, s_value->char_at_addr(0), sizeof(jchar)*s_len); + HeapAccess<>::arraycopy(HeapAddress(s_value, typeArrayOopDesc::element_offset(T_CHAR, 0)), RawAddress(buf), s_len); } else { for (int i = 0; i < s_len; i++) { buf[i] = ((jchar) s_value->byte_at(i)) & 0xff;