--- old/src/hotspot/share/gc/g1/g1SATBCardTableModRefBS.inline.hpp 2018-01-09 11:28:06.268208622 +0100 +++ new/src/hotspot/share/gc/g1/g1SATBCardTableModRefBS.inline.hpp 2018-01-09 11:28:05.980208632 +0100 @@ -27,7 +27,6 @@ #include "gc/shared/accessBarrierSupport.inline.hpp" #include "gc/g1/g1SATBCardTableModRefBS.hpp" -#include "oops/oop.inline.hpp" template <DecoratorSet decorators, typename T> inline void G1SATBCardTableModRefBS::write_ref_field_pre(T* field) { --- old/src/hotspot/share/gc/shared/barrierSet.hpp 2018-01-09 11:28:07.208208589 +0100 +++ new/src/hotspot/share/gc/shared/barrierSet.hpp 2018-01-09 11:28:06.896208600 +0100 @@ -147,9 +147,8 @@ // 3) Provide specializations for BarrierSet::GetName and BarrierSet::GetType. template <DecoratorSet decorators, typename BarrierSetT> class AccessBarrier: protected RawAccessBarrier<decorators> { - protected: + private: typedef RawAccessBarrier<decorators> Raw; - typedef typename BarrierSetT::template AccessBarrier<decorators> CRTPAccessBarrier; public: // Primitive heap accesses. These accessors get resolved when --- old/src/hotspot/share/oops/access.hpp 2018-01-09 11:28:08.076208559 +0100 +++ new/src/hotspot/share/oops/access.hpp 2018-01-09 11:28:07.784208569 +0100 @@ -342,7 +342,7 @@ template <DecoratorSet expected_mo_decorators> static void verify_primitive_decorators() { const DecoratorSet primitive_decorators = (AS_DECORATOR_MASK ^ AS_NO_KEEPALIVE) | IN_HEAP | - IN_HEAP_ARRAY | MO_DECORATOR_MASK; + IN_HEAP_ARRAY; verify_decorators<expected_mo_decorators | primitive_decorators>(); } @@ -350,7 +350,7 @@ static void verify_oop_decorators() { const DecoratorSet oop_decorators = AS_DECORATOR_MASK | IN_DECORATOR_MASK | (ON_DECORATOR_MASK ^ ON_UNKNOWN_OOP_REF) | // no unknown oop refs outside of the heap - OOP_DECORATOR_MASK | MO_DECORATOR_MASK; + OOP_DECORATOR_MASK; verify_decorators<expected_mo_decorators | oop_decorators>(); } @@ -358,8 +358,7 @@ static void verify_heap_oop_decorators() { const DecoratorSet heap_oop_decorators = AS_DECORATOR_MASK | ON_DECORATOR_MASK | OOP_DECORATOR_MASK | (IN_DECORATOR_MASK ^ - (IN_ROOT ^ IN_CONCURRENT_ROOT)) | // no root accesses in the heap - MO_DECORATOR_MASK; + (IN_ROOT | IN_CONCURRENT_ROOT)); // no root accesses in the heap verify_decorators<expected_mo_decorators | heap_oop_decorators>(); } --- old/src/hotspot/share/oops/access.inline.hpp 2018-01-09 11:28:09.060208524 +0100 +++ new/src/hotspot/share/oops/access.inline.hpp 2018-01-09 11:28:08.740208536 +0100 @@ -491,11 +491,12 @@ // not possible. struct PreRuntimeDispatch: AllStatic { template<DecoratorSet decorators> - static bool can_hardwire_raw() { - return !HasDecorator<decorators, INTERNAL_VALUE_IS_OOP>::value || // primitive access - !HasDecorator<decorators, INTERNAL_CONVERT_COMPRESSED_OOP>::value || // don't care about compressed oops (oop* address) - HasDecorator<decorators, INTERNAL_RT_USE_COMPRESSED_OOPS>::value; // we can infer we use compressed oops (narrowOop* address) - } + struct CanHardwireRaw: public IntegralConstant< + bool, + !HasDecorator<decorators, INTERNAL_VALUE_IS_OOP>::value || // primitive access + !HasDecorator<decorators, INTERNAL_CONVERT_COMPRESSED_OOP>::value || // don't care about compressed oops (oop* address) + HasDecorator<decorators, INTERNAL_RT_USE_COMPRESSED_OOPS>::value> // we can infer we use compressed oops (narrowOop* address) + {}; static const DecoratorSet convert_compressed_oops = INTERNAL_RT_USE_COMPRESSED_OOPS | INTERNAL_CONVERT_COMPRESSED_OOP; @@ -507,16 +508,21 @@ template <DecoratorSet decorators, typename T> inline static typename EnableIf< - HasDecorator<decorators, AS_RAW>::value>::type + HasDecorator<decorators, AS_RAW>::value && CanHardwireRaw<decorators>::value>::type store(void* addr, T value) { typedef RawAccessBarrier<decorators & RAW_DECORATOR_MASK> Raw; - if (can_hardwire_raw<decorators>()) { - if (HasDecorator<decorators, INTERNAL_VALUE_IS_OOP>::value) { - Raw::oop_store(addr, value); - } else { - Raw::store(addr, value); - } - } else if (UseCompressedOops) { + if (HasDecorator<decorators, INTERNAL_VALUE_IS_OOP>::value) { + Raw::oop_store(addr, value); + } else { + Raw::store(addr, value); + } + } + + template <DecoratorSet decorators, typename T> + inline static typename EnableIf< + HasDecorator<decorators, AS_RAW>::value && !CanHardwireRaw<decorators>::value>::type + store(void* addr, T value) { + if (UseCompressedOops) { const DecoratorSet expanded_decorators = decorators | convert_compressed_oops; PreRuntimeDispatch::store<expanded_decorators>(addr, value); } else { @@ -558,16 +564,21 @@ template <DecoratorSet decorators, typename T> inline static typename EnableIf< - HasDecorator<decorators, AS_RAW>::value, T>::type + HasDecorator<decorators, AS_RAW>::value && CanHardwireRaw<decorators>::value, T>::type load(void* addr) { typedef RawAccessBarrier<decorators & RAW_DECORATOR_MASK> Raw; - if (can_hardwire_raw<decorators>()) { - if (HasDecorator<decorators, INTERNAL_VALUE_IS_OOP>::value) { - return Raw::template oop_load<T>(addr); - } else { - return Raw::template load<T>(addr); - } - } else if (UseCompressedOops) { + if (HasDecorator<decorators, INTERNAL_VALUE_IS_OOP>::value) { + return Raw::template oop_load<T>(addr); + } else { + return Raw::template load<T>(addr); + } + } + + template <DecoratorSet decorators, typename T> + inline static typename EnableIf< + HasDecorator<decorators, AS_RAW>::value && !CanHardwireRaw<decorators>::value, T>::type + load(void* addr) { + if (UseCompressedOops) { const DecoratorSet expanded_decorators = decorators | convert_compressed_oops; return PreRuntimeDispatch::load<expanded_decorators, T>(addr); } else { @@ -609,16 +620,21 @@ template <DecoratorSet decorators, typename T> inline static typename EnableIf< - HasDecorator<decorators, AS_RAW>::value, T>::type + HasDecorator<decorators, AS_RAW>::value && CanHardwireRaw<decorators>::value, T>::type atomic_cmpxchg(T new_value, void* addr, T compare_value) { typedef RawAccessBarrier<decorators & RAW_DECORATOR_MASK> Raw; - if (can_hardwire_raw<decorators>()) { - if (HasDecorator<decorators, INTERNAL_VALUE_IS_OOP>::value) { - return Raw::oop_atomic_cmpxchg(new_value, addr, compare_value); - } else { - return Raw::atomic_cmpxchg(new_value, addr, compare_value); - } - } else if (UseCompressedOops) { + if (HasDecorator<decorators, INTERNAL_VALUE_IS_OOP>::value) { + return Raw::oop_atomic_cmpxchg(new_value, addr, compare_value); + } else { + return Raw::atomic_cmpxchg(new_value, addr, compare_value); + } + } + + template <DecoratorSet decorators, typename T> + inline static typename EnableIf< + HasDecorator<decorators, AS_RAW>::value && !CanHardwireRaw<decorators>::value, T>::type + atomic_cmpxchg(T new_value, void* addr, T compare_value) { + if (UseCompressedOops) { const DecoratorSet expanded_decorators = decorators | convert_compressed_oops; return PreRuntimeDispatch::atomic_cmpxchg<expanded_decorators>(new_value, addr, compare_value); } else { @@ -661,16 +677,21 @@ template <DecoratorSet decorators, typename T> inline static typename EnableIf< - HasDecorator<decorators, AS_RAW>::value, T>::type + HasDecorator<decorators, AS_RAW>::value && CanHardwireRaw<decorators>::value, T>::type atomic_xchg(T new_value, void* addr) { typedef RawAccessBarrier<decorators & RAW_DECORATOR_MASK> Raw; - if (can_hardwire_raw<decorators>()) { - if (HasDecorator<decorators, INTERNAL_VALUE_IS_OOP>::value) { - return Raw::oop_atomic_xchg(new_value, addr); - } else { - return Raw::atomic_xchg(new_value, addr); - } - } else if (UseCompressedOops) { + if (HasDecorator<decorators, INTERNAL_VALUE_IS_OOP>::value) { + return Raw::oop_atomic_xchg(new_value, addr); + } else { + return Raw::atomic_xchg(new_value, addr); + } + } + + template <DecoratorSet decorators, typename T> + inline static typename EnableIf< + HasDecorator<decorators, AS_RAW>::value && !CanHardwireRaw<decorators>::value, T>::type + atomic_xchg(T new_value, void* addr) { + if (UseCompressedOops) { const DecoratorSet expanded_decorators = decorators | convert_compressed_oops; return PreRuntimeDispatch::atomic_xchg<expanded_decorators>(new_value, addr); } else { @@ -798,6 +819,13 @@ } template <DecoratorSet decorators> + inline void store_reduce_types(narrowOop* addr, narrowOop value) { + const DecoratorSet expanded_decorators = decorators | INTERNAL_CONVERT_COMPRESSED_OOP | + INTERNAL_RT_USE_COMPRESSED_OOPS; + PreRuntimeDispatch::store<expanded_decorators>(addr, value); + } + + template <DecoratorSet decorators> inline void store_reduce_types(HeapWord* addr, oop value) { const DecoratorSet expanded_decorators = decorators | INTERNAL_CONVERT_COMPRESSED_OOP; PreRuntimeDispatch::store<expanded_decorators>(addr, value); @@ -816,7 +844,16 @@ } template <DecoratorSet decorators> - inline oop atomic_cmpxchg_reduce_types(oop new_value, HeapWord* addr, oop compare_value) { + inline narrowOop atomic_cmpxchg_reduce_types(narrowOop new_value, narrowOop* addr, narrowOop compare_value) { + const DecoratorSet expanded_decorators = decorators | INTERNAL_CONVERT_COMPRESSED_OOP | + INTERNAL_RT_USE_COMPRESSED_OOPS; + return PreRuntimeDispatch::atomic_cmpxchg<expanded_decorators>(new_value, addr, compare_value); + } + + template <DecoratorSet decorators> + inline oop atomic_cmpxchg_reduce_types(oop new_value, + HeapWord* addr, + oop compare_value) { const DecoratorSet expanded_decorators = decorators | INTERNAL_CONVERT_COMPRESSED_OOP; return PreRuntimeDispatch::atomic_cmpxchg<expanded_decorators>(new_value, addr, compare_value); } @@ -835,6 +872,13 @@ } template <DecoratorSet decorators> + inline narrowOop atomic_xchg_reduce_types(narrowOop new_value, narrowOop* addr) { + const DecoratorSet expanded_decorators = decorators | INTERNAL_CONVERT_COMPRESSED_OOP | + INTERNAL_RT_USE_COMPRESSED_OOPS; + return PreRuntimeDispatch::atomic_xchg<expanded_decorators>(new_value, addr); + } + + template <DecoratorSet decorators> inline oop atomic_xchg_reduce_types(oop new_value, HeapWord* addr) { const DecoratorSet expanded_decorators = decorators | INTERNAL_CONVERT_COMPRESSED_OOP; return PreRuntimeDispatch::atomic_xchg<expanded_decorators>(new_value, addr); @@ -846,9 +890,10 @@ } template <DecoratorSet decorators, typename T> - inline oop load_reduce_types(narrowOop* addr) { - const DecoratorSet expanded_decorators = decorators | INTERNAL_CONVERT_COMPRESSED_OOP | INTERNAL_RT_USE_COMPRESSED_OOPS; - return PreRuntimeDispatch::load<expanded_decorators, oop>(addr); + inline typename OopOrNarrowOop<T>::type load_reduce_types(narrowOop* addr) { + const DecoratorSet expanded_decorators = decorators | INTERNAL_CONVERT_COMPRESSED_OOP | + INTERNAL_RT_USE_COMPRESSED_OOPS; + return PreRuntimeDispatch::load<expanded_decorators, typename OopOrNarrowOop<T>::type>(addr); } template <DecoratorSet decorators, typename T> --- old/src/hotspot/share/oops/accessBackend.hpp 2018-01-09 11:28:09.912208495 +0100 +++ new/src/hotspot/share/oops/accessBackend.hpp 2018-01-09 11:28:09.628208505 +0100 @@ -28,6 +28,7 @@ #include "metaprogramming/conditional.hpp" #include "metaprogramming/enableIf.hpp" #include "metaprogramming/integralConstant.hpp" +#include "metaprogramming/isSame.hpp" #include "utilities/debug.hpp" #include "utilities/globalDefinitions.hpp" @@ -54,11 +55,11 @@ BARRIER_CLONE }; - template <DecoratorSet decorators> + template <DecoratorSet decorators, typename T> struct MustConvertCompressedOop: public IntegralConstant<bool, HasDecorator<decorators, INTERNAL_VALUE_IS_OOP>::value && - HasDecorator<decorators, INTERNAL_CONVERT_COMPRESSED_OOP>::value && - HasDecorator<decorators, INTERNAL_RT_USE_COMPRESSED_OOPS>::value> {}; + IsSame<typename HeapOopType<decorators>::type, narrowOop>::value && + IsSame<T, oop>::value> {}; // This metafunction returns an appropriate oop type if the value is oop-like // and otherwise returns the same type T. @@ -172,13 +173,13 @@ // Only encode if INTERNAL_VALUE_IS_OOP template <DecoratorSet idecorators, typename T> static inline typename EnableIf< - AccessInternal::MustConvertCompressedOop<idecorators>::value, + AccessInternal::MustConvertCompressedOop<idecorators, T>::value, typename HeapOopType<idecorators>::type>::type encode_internal(T value); template <DecoratorSet idecorators, typename T> static inline typename EnableIf< - !AccessInternal::MustConvertCompressedOop<idecorators>::value, T>::type + !AccessInternal::MustConvertCompressedOop<idecorators, T>::value, T>::type encode_internal(T value) { return value; } @@ -192,12 +193,12 @@ // Only decode if INTERNAL_VALUE_IS_OOP template <DecoratorSet idecorators, typename T> static inline typename EnableIf< - AccessInternal::MustConvertCompressedOop<idecorators>::value, T>::type + AccessInternal::MustConvertCompressedOop<idecorators, T>::value, T>::type decode_internal(typename HeapOopType<idecorators>::type value); template <DecoratorSet idecorators, typename T> static inline typename EnableIf< - !AccessInternal::MustConvertCompressedOop<idecorators>::value, T>::type + !AccessInternal::MustConvertCompressedOop<idecorators, T>::value, T>::type decode_internal(T value) { return value; } --- old/src/hotspot/share/oops/accessBackend.inline.hpp 2018-01-09 11:28:10.876208461 +0100 +++ new/src/hotspot/share/oops/accessBackend.inline.hpp 2018-01-09 11:28:10.556208472 +0100 @@ -32,7 +32,7 @@ template <DecoratorSet decorators> template <DecoratorSet idecorators, typename T> inline typename EnableIf< - AccessInternal::MustConvertCompressedOop<idecorators>::value, T>::type + AccessInternal::MustConvertCompressedOop<idecorators, T>::value, T>::type RawAccessBarrier<decorators>::decode_internal(typename HeapOopType<idecorators>::type value) { if (HasDecorator<decorators, OOP_NOT_NULL>::value) { return oopDesc::decode_heap_oop_not_null(value); @@ -44,7 +44,7 @@ template <DecoratorSet decorators> template <DecoratorSet idecorators, typename T> inline typename EnableIf< - AccessInternal::MustConvertCompressedOop<idecorators>::value, + AccessInternal::MustConvertCompressedOop<idecorators, T>::value, typename HeapOopType<idecorators>::type>::type RawAccessBarrier<decorators>::encode_internal(T value) { if (HasDecorator<decorators, OOP_NOT_NULL>::value) {