# HG changeset patch # User eosterlund # Date 1515603896 -3600 # Node ID 69d65d9dcadbbfa455af39974e603788d3d52478 # Parent bf12b502df9466f28c4ed423ad18706cb89f6bd3 8193063: Enabling narrowOop values for RawAccess accesses Reviewed-by: pliden, kbarrett diff -r bf12b502df94 -r 69d65d9dcadb src/hotspot/share/gc/g1/g1SATBCardTableModRefBS.inline.hpp --- a/src/hotspot/share/gc/g1/g1SATBCardTableModRefBS.inline.hpp Wed Jan 10 10:21:25 2018 +0100 +++ b/src/hotspot/share/gc/g1/g1SATBCardTableModRefBS.inline.hpp Wed Jan 10 18:04:56 2018 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2018, 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 @@ -27,7 +27,6 @@ #include "gc/shared/accessBarrierSupport.inline.hpp" #include "gc/g1/g1SATBCardTableModRefBS.hpp" -#include "oops/oop.inline.hpp" template inline void G1SATBCardTableModRefBS::write_ref_field_pre(T* field) { diff -r bf12b502df94 -r 69d65d9dcadb src/hotspot/share/gc/shared/barrierSet.hpp --- a/src/hotspot/share/gc/shared/barrierSet.hpp Wed Jan 10 10:21:25 2018 +0100 +++ b/src/hotspot/share/gc/shared/barrierSet.hpp Wed Jan 10 18:04:56 2018 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2018, 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 @@ -147,9 +147,8 @@ // 3) Provide specializations for BarrierSet::GetName and BarrierSet::GetType. template class AccessBarrier: protected RawAccessBarrier { - protected: + private: typedef RawAccessBarrier Raw; - typedef typename BarrierSetT::template AccessBarrier CRTPAccessBarrier; public: // Primitive heap accesses. These accessors get resolved when diff -r bf12b502df94 -r 69d65d9dcadb src/hotspot/share/oops/access.hpp --- a/src/hotspot/share/oops/access.hpp Wed Jan 10 10:21:25 2018 +0100 +++ b/src/hotspot/share/oops/access.hpp Wed Jan 10 18:04:56 2018 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2018, 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 @@ -342,7 +342,7 @@ template 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(); } @@ -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(); } @@ -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(); } diff -r bf12b502df94 -r 69d65d9dcadb src/hotspot/share/oops/access.inline.hpp --- a/src/hotspot/share/oops/access.inline.hpp Wed Jan 10 10:21:25 2018 +0100 +++ b/src/hotspot/share/oops/access.inline.hpp Wed Jan 10 18:04:56 2018 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2018, 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 @@ -491,11 +491,12 @@ // not possible. struct PreRuntimeDispatch: AllStatic { template - static bool can_hardwire_raw() { - return !HasDecorator::value || // primitive access - !HasDecorator::value || // don't care about compressed oops (oop* address) - HasDecorator::value; // we can infer we use compressed oops (narrowOop* address) - } + struct CanHardwireRaw: public IntegralConstant< + bool, + !HasDecorator::value || // primitive access + !HasDecorator::value || // don't care about compressed oops (oop* address) + HasDecorator::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 inline static typename EnableIf< - HasDecorator::value>::type + HasDecorator::value && CanHardwireRaw::value>::type store(void* addr, T value) { typedef RawAccessBarrier Raw; - if (can_hardwire_raw()) { - if (HasDecorator::value) { - Raw::oop_store(addr, value); - } else { - Raw::store(addr, value); - } - } else if (UseCompressedOops) { + if (HasDecorator::value) { + Raw::oop_store(addr, value); + } else { + Raw::store(addr, value); + } + } + + template + inline static typename EnableIf< + HasDecorator::value && !CanHardwireRaw::value>::type + store(void* addr, T value) { + if (UseCompressedOops) { const DecoratorSet expanded_decorators = decorators | convert_compressed_oops; PreRuntimeDispatch::store(addr, value); } else { @@ -558,16 +564,21 @@ template inline static typename EnableIf< - HasDecorator::value, T>::type + HasDecorator::value && CanHardwireRaw::value, T>::type load(void* addr) { typedef RawAccessBarrier Raw; - if (can_hardwire_raw()) { - if (HasDecorator::value) { - return Raw::template oop_load(addr); - } else { - return Raw::template load(addr); - } - } else if (UseCompressedOops) { + if (HasDecorator::value) { + return Raw::template oop_load(addr); + } else { + return Raw::template load(addr); + } + } + + template + inline static typename EnableIf< + HasDecorator::value && !CanHardwireRaw::value, T>::type + load(void* addr) { + if (UseCompressedOops) { const DecoratorSet expanded_decorators = decorators | convert_compressed_oops; return PreRuntimeDispatch::load(addr); } else { @@ -609,16 +620,21 @@ template inline static typename EnableIf< - HasDecorator::value, T>::type + HasDecorator::value && CanHardwireRaw::value, T>::type atomic_cmpxchg(T new_value, void* addr, T compare_value) { typedef RawAccessBarrier Raw; - if (can_hardwire_raw()) { - if (HasDecorator::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::value) { + return Raw::oop_atomic_cmpxchg(new_value, addr, compare_value); + } else { + return Raw::atomic_cmpxchg(new_value, addr, compare_value); + } + } + + template + inline static typename EnableIf< + HasDecorator::value && !CanHardwireRaw::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(new_value, addr, compare_value); } else { @@ -661,16 +677,21 @@ template inline static typename EnableIf< - HasDecorator::value, T>::type + HasDecorator::value && CanHardwireRaw::value, T>::type atomic_xchg(T new_value, void* addr) { typedef RawAccessBarrier Raw; - if (can_hardwire_raw()) { - if (HasDecorator::value) { - return Raw::oop_atomic_xchg(new_value, addr); - } else { - return Raw::atomic_xchg(new_value, addr); - } - } else if (UseCompressedOops) { + if (HasDecorator::value) { + return Raw::oop_atomic_xchg(new_value, addr); + } else { + return Raw::atomic_xchg(new_value, addr); + } + } + + template + inline static typename EnableIf< + HasDecorator::value && !CanHardwireRaw::value, T>::type + atomic_xchg(T new_value, void* addr) { + if (UseCompressedOops) { const DecoratorSet expanded_decorators = decorators | convert_compressed_oops; return PreRuntimeDispatch::atomic_xchg(new_value, addr); } else { @@ -798,6 +819,13 @@ } template + 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(addr, value); + } + + template inline void store_reduce_types(HeapWord* addr, oop value) { const DecoratorSet expanded_decorators = decorators | INTERNAL_CONVERT_COMPRESSED_OOP; PreRuntimeDispatch::store(addr, value); @@ -816,7 +844,16 @@ } template - 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(new_value, addr, compare_value); + } + + template + 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(new_value, addr, compare_value); } @@ -835,6 +872,13 @@ } template + 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(new_value, addr); + } + + template inline oop atomic_xchg_reduce_types(oop new_value, HeapWord* addr) { const DecoratorSet expanded_decorators = decorators | INTERNAL_CONVERT_COMPRESSED_OOP; return PreRuntimeDispatch::atomic_xchg(new_value, addr); @@ -846,9 +890,10 @@ } template - inline oop load_reduce_types(narrowOop* addr) { - const DecoratorSet expanded_decorators = decorators | INTERNAL_CONVERT_COMPRESSED_OOP | INTERNAL_RT_USE_COMPRESSED_OOPS; - return PreRuntimeDispatch::load(addr); + inline typename OopOrNarrowOop::type load_reduce_types(narrowOop* addr) { + const DecoratorSet expanded_decorators = decorators | INTERNAL_CONVERT_COMPRESSED_OOP | + INTERNAL_RT_USE_COMPRESSED_OOPS; + return PreRuntimeDispatch::load::type>(addr); } template diff -r bf12b502df94 -r 69d65d9dcadb src/hotspot/share/oops/accessBackend.hpp --- a/src/hotspot/share/oops/accessBackend.hpp Wed Jan 10 10:21:25 2018 +0100 +++ b/src/hotspot/share/oops/accessBackend.hpp Wed Jan 10 18:04:56 2018 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2018, 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 @@ -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 + template struct MustConvertCompressedOop: public IntegralConstant::value && - HasDecorator::value && - HasDecorator::value> {}; + IsSame::type, narrowOop>::value && + IsSame::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 static inline typename EnableIf< - AccessInternal::MustConvertCompressedOop::value, + AccessInternal::MustConvertCompressedOop::value, typename HeapOopType::type>::type encode_internal(T value); template static inline typename EnableIf< - !AccessInternal::MustConvertCompressedOop::value, T>::type + !AccessInternal::MustConvertCompressedOop::value, T>::type encode_internal(T value) { return value; } @@ -192,12 +193,12 @@ // Only decode if INTERNAL_VALUE_IS_OOP template static inline typename EnableIf< - AccessInternal::MustConvertCompressedOop::value, T>::type + AccessInternal::MustConvertCompressedOop::value, T>::type decode_internal(typename HeapOopType::type value); template static inline typename EnableIf< - !AccessInternal::MustConvertCompressedOop::value, T>::type + !AccessInternal::MustConvertCompressedOop::value, T>::type decode_internal(T value) { return value; } diff -r bf12b502df94 -r 69d65d9dcadb src/hotspot/share/oops/accessBackend.inline.hpp --- a/src/hotspot/share/oops/accessBackend.inline.hpp Wed Jan 10 10:21:25 2018 +0100 +++ b/src/hotspot/share/oops/accessBackend.inline.hpp Wed Jan 10 18:04:56 2018 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2018, 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 @@ -32,7 +32,7 @@ template template inline typename EnableIf< - AccessInternal::MustConvertCompressedOop::value, T>::type + AccessInternal::MustConvertCompressedOop::value, T>::type RawAccessBarrier::decode_internal(typename HeapOopType::type value) { if (HasDecorator::value) { return oopDesc::decode_heap_oop_not_null(value); @@ -44,7 +44,7 @@ template template inline typename EnableIf< - AccessInternal::MustConvertCompressedOop::value, + AccessInternal::MustConvertCompressedOop::value, typename HeapOopType::type>::type RawAccessBarrier::encode_internal(T value) { if (HasDecorator::value) {