Skip to content

Commit

Permalink
8299971: Remove metaprogramming/conditional.hpp
Browse files Browse the repository at this point in the history
Reviewed-by: tschatzl, kbarrett
  • Loading branch information
jcking authored and Kim Barrett committed Jan 16, 2023
1 parent 4073b68 commit 4c1e66e
Show file tree
Hide file tree
Showing 11 changed files with 31 additions and 129 deletions.
3 changes: 1 addition & 2 deletions src/hotspot/share/gc/shared/oopStorage.inline.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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) {
Expand Down
6 changes: 3 additions & 3 deletions src/hotspot/share/gc/shared/oopStorageParState.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
#include "gc/shared/oopStorage.hpp"
#include "utilities/globalDefinitions.hpp"

#include <type_traits>

//////////////////////////////////////////////////////////////////////////////
// Support for parallel and optionally concurrent state iteration.
//
Expand Down Expand Up @@ -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,
Expand Down
5 changes: 3 additions & 2 deletions src/hotspot/share/gc/shared/oopStorageParState.inline.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down
43 changes: 0 additions & 43 deletions src/hotspot/share/metaprogramming/conditional.hpp

This file was deleted.

21 changes: 10 additions & 11 deletions src/hotspot/share/oops/accessBackend.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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 {
Expand All @@ -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>
Expand Down Expand Up @@ -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<
Expand All @@ -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 |
Expand Down
11 changes: 5 additions & 6 deletions src/hotspot/share/runtime/atomic.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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);
Expand All @@ -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));
Expand Down Expand Up @@ -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*;
Expand Down
5 changes: 3 additions & 2 deletions src/hotspot/share/runtime/continuationFreezeThaw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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).
*
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/utilities/moveBits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -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));
Expand Down
3 changes: 1 addition & 2 deletions src/hotspot/share/utilities/population_count.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down
13 changes: 3 additions & 10 deletions test/hotspot/gtest/gc/shared/test_oopStorage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -570,9 +569,7 @@ class OopStorageTest::CountingIterateClosure {
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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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) :
Expand Down
46 changes: 0 additions & 46 deletions test/hotspot/gtest/metaprogramming/test_conditional.cpp

This file was deleted.

1 comment on commit 4c1e66e

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.