8299971: Remove metaprogramming/conditional.hpp
Reviewed-by: tschatzl, kbarrett
This commit is contained in:
parent
4073b68565
commit
4c1e66e0ab
src/hotspot/share
gc/shared
metaprogramming
oops
runtime
utilities
test/hotspot/gtest
@ -28,7 +28,6 @@
|
||||
#include "gc/shared/oopStorage.hpp"
|
||||
|
||||
#include "memory/allocation.hpp"
|
||||
#include "metaprogramming/conditional.hpp"
|
||||
#include "oops/oop.hpp"
|
||||
#include "runtime/safepoint.hpp"
|
||||
#include "utilities/align.hpp"
|
||||
@ -362,7 +361,7 @@ inline bool OopStorage::iterate_impl(F f, Storage* storage) {
|
||||
assert_at_safepoint();
|
||||
// Propagate const/non-const iteration to the block layer, by using
|
||||
// const or non-const blocks as corresponding to Storage.
|
||||
typedef typename Conditional<std::is_const<Storage>::value, const Block*, Block*>::type BlockPtr;
|
||||
using BlockPtr = std::conditional_t<std::is_const<Storage>::value, const Block*, Block*>;
|
||||
ActiveArray* blocks = storage->_active_array;
|
||||
size_t limit = blocks->block_count();
|
||||
for (size_t i = 0; i < limit; ++i) {
|
||||
|
@ -28,6 +28,8 @@
|
||||
#include "gc/shared/oopStorage.hpp"
|
||||
#include "utilities/globalDefinitions.hpp"
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// Support for parallel and optionally concurrent state iteration.
|
||||
//
|
||||
@ -167,9 +169,7 @@ template<bool concurrent, bool is_const>
|
||||
class OopStorage::ParState {
|
||||
BasicParState _basic_state;
|
||||
|
||||
typedef typename Conditional<is_const,
|
||||
const OopStorage*,
|
||||
OopStorage*>::type StoragePtr;
|
||||
using StoragePtr = std::conditional_t<is_const, const OopStorage*, OopStorage*>;
|
||||
|
||||
public:
|
||||
ParState(StoragePtr storage,
|
||||
|
@ -28,9 +28,10 @@
|
||||
#include "gc/shared/oopStorageParState.hpp"
|
||||
|
||||
#include "gc/shared/oopStorage.inline.hpp"
|
||||
#include "metaprogramming/conditional.hpp"
|
||||
#include "utilities/macros.hpp"
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
template<typename F>
|
||||
class OopStorage::BasicParState::AlwaysTrueFn {
|
||||
F _f;
|
||||
@ -56,7 +57,7 @@ inline void OopStorage::BasicParState::iterate(F f) {
|
||||
while (claim_next_segment(&data)) {
|
||||
assert(data._segment_start < data._segment_end, "invariant");
|
||||
assert(data._segment_end <= _block_count, "invariant");
|
||||
typedef typename Conditional<is_const, const Block*, Block*>::type BlockPtr;
|
||||
using BlockPtr = std::conditional_t<is_const, const Block*, Block*>;
|
||||
size_t i = data._segment_start;
|
||||
do {
|
||||
BlockPtr block = _active_array->at(i);
|
||||
|
@ -1,43 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 2022, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef SHARE_METAPROGRAMMING_CONDITIONAL_HPP
|
||||
#define SHARE_METAPROGRAMMING_CONDITIONAL_HPP
|
||||
|
||||
#include "memory/allStatic.hpp"
|
||||
|
||||
// This trait evaluates its typedef called "type" to TrueType iff the condition
|
||||
// is true. Otherwise it evaluates to FalseType.
|
||||
|
||||
template <bool condition, typename TrueType, typename FalseType>
|
||||
struct Conditional: AllStatic {
|
||||
typedef TrueType type;
|
||||
};
|
||||
|
||||
template <typename TrueType, typename FalseType>
|
||||
struct Conditional<false, TrueType, FalseType>: AllStatic {
|
||||
typedef FalseType type;
|
||||
};
|
||||
|
||||
#endif // SHARE_METAPROGRAMMING_CONDITIONAL_HPP
|
@ -27,7 +27,6 @@
|
||||
|
||||
#include "gc/shared/barrierSetConfig.hpp"
|
||||
#include "memory/allocation.hpp"
|
||||
#include "metaprogramming/conditional.hpp"
|
||||
#include "metaprogramming/enableIf.hpp"
|
||||
#include "metaprogramming/integralConstant.hpp"
|
||||
#include "metaprogramming/isPointer.hpp"
|
||||
@ -46,7 +45,7 @@ template <DecoratorSet decorators>
|
||||
struct HeapOopType: AllStatic {
|
||||
static const bool needs_oop_compress = HasDecorator<decorators, INTERNAL_CONVERT_COMPRESSED_OOP>::value &&
|
||||
HasDecorator<decorators, INTERNAL_RT_USE_COMPRESSED_OOPS>::value;
|
||||
typedef typename Conditional<needs_oop_compress, narrowOop, oop>::type type;
|
||||
using type = std::conditional_t<needs_oop_compress, narrowOop, oop>;
|
||||
};
|
||||
|
||||
namespace AccessInternal {
|
||||
@ -73,9 +72,9 @@ namespace AccessInternal {
|
||||
// and otherwise returns the same type T.
|
||||
template <DecoratorSet decorators, typename T>
|
||||
struct EncodedType: AllStatic {
|
||||
typedef typename Conditional<
|
||||
HasDecorator<decorators, INTERNAL_VALUE_IS_OOP>::value,
|
||||
typename HeapOopType<decorators>::type, T>::type type;
|
||||
using type = std::conditional_t<HasDecorator<decorators, INTERNAL_VALUE_IS_OOP>::value,
|
||||
typename HeapOopType<decorators>::type,
|
||||
T>;
|
||||
};
|
||||
|
||||
template <DecoratorSet decorators>
|
||||
@ -1126,9 +1125,9 @@ namespace AccessInternal {
|
||||
inline T load(P* addr) {
|
||||
verify_types<decorators, T>();
|
||||
using DecayedP = std::decay_t<P>;
|
||||
typedef typename Conditional<HasDecorator<decorators, INTERNAL_VALUE_IS_OOP>::value,
|
||||
typename OopOrNarrowOop<T>::type,
|
||||
std::decay_t<T>>::type DecayedT;
|
||||
using DecayedT = std::conditional_t<HasDecorator<decorators, INTERNAL_VALUE_IS_OOP>::value,
|
||||
typename OopOrNarrowOop<T>::type,
|
||||
std::decay_t<T>>;
|
||||
// If a volatile address is passed in but no memory ordering decorator,
|
||||
// set the memory ordering to MO_RELAXED by default.
|
||||
const DecoratorSet expanded_decorators = DecoratorFixup<
|
||||
@ -1140,9 +1139,9 @@ namespace AccessInternal {
|
||||
template <DecoratorSet decorators, typename T>
|
||||
inline T load_at(oop base, ptrdiff_t offset) {
|
||||
verify_types<decorators, T>();
|
||||
typedef typename Conditional<HasDecorator<decorators, INTERNAL_VALUE_IS_OOP>::value,
|
||||
typename OopOrNarrowOop<T>::type,
|
||||
std::decay_t<T>>::type DecayedT;
|
||||
using DecayedT = std::conditional_t<HasDecorator<decorators, INTERNAL_VALUE_IS_OOP>::value,
|
||||
typename OopOrNarrowOop<T>::type,
|
||||
std::decay_t<T>>;
|
||||
// Expand the decorators (figure out sensible defaults)
|
||||
// Potentially remember if we need compressed oop awareness
|
||||
const DecoratorSet expanded_decorators = DecoratorFixup<decorators |
|
||||
|
@ -26,7 +26,6 @@
|
||||
#define SHARE_RUNTIME_ATOMIC_HPP
|
||||
|
||||
#include "memory/allocation.hpp"
|
||||
#include "metaprogramming/conditional.hpp"
|
||||
#include "metaprogramming/enableIf.hpp"
|
||||
#include "metaprogramming/isPointer.hpp"
|
||||
#include "metaprogramming/isSame.hpp"
|
||||
@ -510,14 +509,14 @@ struct Atomic::PlatformStore {
|
||||
template<typename D>
|
||||
inline void Atomic::inc(D volatile* dest, atomic_memory_order order) {
|
||||
STATIC_ASSERT(IsPointer<D>::value || std::is_integral<D>::value);
|
||||
typedef typename Conditional<IsPointer<D>::value, ptrdiff_t, D>::type I;
|
||||
using I = std::conditional_t<IsPointer<D>::value, ptrdiff_t, D>;
|
||||
Atomic::add(dest, I(1), order);
|
||||
}
|
||||
|
||||
template<typename D>
|
||||
inline void Atomic::dec(D volatile* dest, atomic_memory_order order) {
|
||||
STATIC_ASSERT(IsPointer<D>::value || std::is_integral<D>::value);
|
||||
typedef typename Conditional<IsPointer<D>::value, ptrdiff_t, D>::type I;
|
||||
using I = std::conditional_t<IsPointer<D>::value, ptrdiff_t, D>;
|
||||
// Assumes two's complement integer representation.
|
||||
#pragma warning(suppress: 4146)
|
||||
Atomic::add(dest, I(-1), order);
|
||||
@ -529,8 +528,8 @@ inline D Atomic::sub(D volatile* dest, I sub_value, atomic_memory_order order) {
|
||||
STATIC_ASSERT(std::is_integral<I>::value);
|
||||
// If D is a pointer type, use [u]intptr_t as the addend type,
|
||||
// matching signedness of I. Otherwise, use D as the addend type.
|
||||
typedef typename Conditional<IsSigned<I>::value, intptr_t, uintptr_t>::type PI;
|
||||
typedef typename Conditional<IsPointer<D>::value, PI, D>::type AddendType;
|
||||
using PI = std::conditional_t<IsSigned<I>::value, intptr_t, uintptr_t>;
|
||||
using AddendType = std::conditional_t<IsPointer<D>::value, PI, D>;
|
||||
// Only allow conversions that can't change the value.
|
||||
STATIC_ASSERT(IsSigned<I>::value == IsSigned<AddendType>::value);
|
||||
STATIC_ASSERT(sizeof(I) <= sizeof(AddendType));
|
||||
@ -700,7 +699,7 @@ struct Atomic::AddImpl<
|
||||
|
||||
// Type of the scaled addend. An integral type of the same size as a
|
||||
// pointer, and the same signedness as I.
|
||||
using SI = typename Conditional<IsSigned<I>::value, intptr_t, uintptr_t>::type;
|
||||
using SI = std::conditional_t<IsSigned<I>::value, intptr_t, uintptr_t>;
|
||||
|
||||
// Type of the unscaled destination. A pointer type with pointee size == 1.
|
||||
using UP = const char*;
|
||||
|
@ -38,7 +38,6 @@
|
||||
#include "jfr/jfrEvents.hpp"
|
||||
#include "logging/log.hpp"
|
||||
#include "logging/logStream.hpp"
|
||||
#include "metaprogramming/conditional.hpp"
|
||||
#include "oops/access.inline.hpp"
|
||||
#include "oops/method.inline.hpp"
|
||||
#include "oops/oopsHierarchy.hpp"
|
||||
@ -68,6 +67,8 @@
|
||||
#include "utilities/exceptions.hpp"
|
||||
#include "utilities/macros.hpp"
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
/*
|
||||
* This file contains the implementation of continuation freezing (yield) and thawing (run).
|
||||
*
|
||||
@ -260,7 +261,7 @@ template <oop_kind oops, typename BarrierSetT>
|
||||
class Config {
|
||||
public:
|
||||
typedef Config<oops, BarrierSetT> SelfT;
|
||||
typedef typename Conditional<oops == oop_kind::NARROW, narrowOop, oop>::type OopT;
|
||||
using OopT = std::conditional_t<oops == oop_kind::NARROW, narrowOop, oop>;
|
||||
|
||||
static int freeze(JavaThread* thread, intptr_t* const sp) {
|
||||
return freeze_internal<SelfT>(thread, sp);
|
||||
|
@ -25,9 +25,9 @@
|
||||
#ifndef SHARE_UTILITIES_MOVEBITS_HPP
|
||||
#define SHARE_UTILITIES_MOVEBITS_HPP
|
||||
|
||||
#include "metaprogramming/conditional.hpp"
|
||||
#include "metaprogramming/enableIf.hpp"
|
||||
#include "utilities/globalDefinitions.hpp"
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
template <typename T>
|
||||
@ -38,7 +38,7 @@ class ReverseBitsImpl {
|
||||
"unsupported size");
|
||||
|
||||
// The unsigned integral type for calculations.
|
||||
using I = typename Conditional<NB <= 32, uint32_t, uint64_t>::type;
|
||||
using I = std::conditional_t<NB <= 32, uint32_t, uint64_t>;
|
||||
|
||||
static const I rep_5555 = static_cast<I>(UCONST64(0x5555555555555555));
|
||||
static const I rep_3333 = static_cast<I>(UCONST64(0x3333333333333333));
|
||||
|
@ -25,7 +25,6 @@
|
||||
#ifndef SHARE_UTILITIES_POPULATION_COUNT_HPP
|
||||
#define SHARE_UTILITIES_POPULATION_COUNT_HPP
|
||||
|
||||
#include "metaprogramming/conditional.hpp"
|
||||
#include "metaprogramming/enableIf.hpp"
|
||||
#include "metaprogramming/isSigned.hpp"
|
||||
#include "utilities/debug.hpp"
|
||||
@ -53,7 +52,7 @@ inline unsigned population_count(T x) {
|
||||
// We need to take care with implicit integer promotion when dealing with
|
||||
// integers < 32-bit. We chose to do this by explicitly widening constants
|
||||
// to unsigned
|
||||
typedef typename Conditional<(sizeof(T) < sizeof(unsigned)), unsigned, T>::type P;
|
||||
using P = std::conditional_t<(sizeof(T) < sizeof(unsigned)), unsigned, T>;
|
||||
const T all = ~T(0); // 0xFF..FF
|
||||
const P fives = all/3; // 0x55..55
|
||||
const P threes = (all/15) * 3; // 0x33..33
|
||||
|
@ -27,7 +27,6 @@
|
||||
#include "gc/shared/workerThread.hpp"
|
||||
#include "memory/allocation.inline.hpp"
|
||||
#include "memory/resourceArea.hpp"
|
||||
#include "metaprogramming/conditional.hpp"
|
||||
#include "metaprogramming/enableIf.hpp"
|
||||
#include "runtime/handles.inline.hpp"
|
||||
#include "runtime/interfaceSupport.inline.hpp"
|
||||
@ -570,9 +569,7 @@ public:
|
||||
template<bool is_const>
|
||||
class OopStorageTest::VM_CountAtSafepoint : public VM_GTestExecuteAtSafepoint {
|
||||
public:
|
||||
typedef typename Conditional<is_const,
|
||||
const OopStorage,
|
||||
OopStorage>::type Storage;
|
||||
using Storage = std::conditional_t<is_const, const OopStorage, OopStorage>;
|
||||
|
||||
VM_CountAtSafepoint(Storage* storage, CountingIterateClosure* cl) :
|
||||
_storage(storage), _cl(cl)
|
||||
@ -795,9 +792,7 @@ const size_t OopStorageTestIteration::_max_workers;
|
||||
template<bool is_const>
|
||||
class OopStorageTestIteration::VM_Verify : public VM_GTestExecuteAtSafepoint {
|
||||
public:
|
||||
typedef typename Conditional<is_const,
|
||||
const OopStorage,
|
||||
OopStorage>::type Storage;
|
||||
using Storage = std::conditional_t<is_const, const OopStorage, OopStorage>;
|
||||
|
||||
VM_Verify(Storage* storage, VerifyState* vstate) :
|
||||
_storage(storage), _vstate(vstate), _result(false)
|
||||
@ -892,9 +887,7 @@ template<bool concurrent, bool is_const>
|
||||
class OopStorageTestParIteration::Task : public WorkerTask {
|
||||
typedef OopStorage::ParState<concurrent, is_const> StateType;
|
||||
|
||||
typedef typename Conditional<is_const,
|
||||
const OopStorage,
|
||||
OopStorage>::type Storage;
|
||||
using Storage = std::conditional_t<is_const, const OopStorage, OopStorage>;
|
||||
|
||||
public:
|
||||
Task(const char* name, Storage* storage, VerifyState* vstate) :
|
||||
|
@ -1,46 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "precompiled.hpp"
|
||||
#include "memory/allocation.hpp"
|
||||
#include "metaprogramming/conditional.hpp"
|
||||
#include "metaprogramming/isSame.hpp"
|
||||
#include "utilities/debug.hpp"
|
||||
|
||||
class ConditionalTest {
|
||||
class A: AllStatic {};
|
||||
class B: AllStatic {};
|
||||
|
||||
typedef Conditional<true, A, B>::type A_B_if_true;
|
||||
static const bool A_B_if_true_is_A = IsSame<A_B_if_true, A>::value;
|
||||
static const bool A_B_if_true_is_B = IsSame<A_B_if_true, B>::value;
|
||||
STATIC_ASSERT(A_B_if_true_is_A);
|
||||
STATIC_ASSERT(!A_B_if_true_is_B);
|
||||
|
||||
typedef Conditional<false, A, B>::type A_B_if_false;
|
||||
static const bool A_B_if_false_is_A = IsSame<A_B_if_false, A>::value;
|
||||
static const bool A_B_if_false_is_B = IsSame<A_B_if_false, B>::value;
|
||||
STATIC_ASSERT(!A_B_if_false_is_A);
|
||||
STATIC_ASSERT(A_B_if_false_is_B);
|
||||
};
|
Loading…
x
Reference in New Issue
Block a user