8193063: Enabling narrowOop values for RawAccess accesses

Reviewed-by: pliden, kbarrett
This commit is contained in:
Erik Österlund 2018-01-10 18:04:56 +01:00
parent 1cf8169a2e
commit c5f5601b1c
6 changed files with 106 additions and 63 deletions

View file

@ -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 @@ namespace AccessInternal {
// 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 @@ namespace AccessInternal {
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 @@ namespace AccessInternal {
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 @@ namespace AccessInternal {
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 @@ namespace AccessInternal {
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 {
@ -797,6 +818,13 @@ namespace AccessInternal {
PreRuntimeDispatch::store<expanded_decorators>(addr, value);
}
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;
@ -816,7 +844,16 @@ namespace AccessInternal {
}
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);
}
@ -834,6 +871,13 @@ namespace AccessInternal {
return PreRuntimeDispatch::atomic_xchg<expanded_decorators>(new_value, addr);
}
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;
@ -846,9 +890,10 @@ namespace AccessInternal {
}
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>