8247908: Replace IsRegisteredEnum with std::is_enum
Reviewed-by: tschatzl, dholmes
This commit is contained in:
parent
0ef80293f9
commit
55b19e84f2
src/hotspot/share
aot
metaprogramming
runtime
services
test/hotspot/gtest
@ -27,7 +27,6 @@
|
||||
#include "aot/aotCompiledMethod.hpp"
|
||||
#include "classfile/symbolTable.hpp"
|
||||
#include "metaprogramming/integralConstant.hpp"
|
||||
#include "metaprogramming/isRegisteredEnum.hpp"
|
||||
#include "oops/metadata.hpp"
|
||||
#include "oops/method.hpp"
|
||||
|
||||
@ -37,8 +36,6 @@ enum CodeState {
|
||||
invalid = 2 // AOT code is invalidated because dependencies failed
|
||||
};
|
||||
|
||||
template<> struct IsRegisteredEnum<CodeState> : public TrueType {};
|
||||
|
||||
typedef struct {
|
||||
AOTCompiledMethod* _aot;
|
||||
CodeState _state; // State change cases: not_set->in_use, not_set->invalid
|
||||
|
@ -1,40 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 2019, 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_ISREGISTEREDENUM_HPP
|
||||
#define SHARE_METAPROGRAMMING_ISREGISTEREDENUM_HPP
|
||||
|
||||
#include "metaprogramming/integralConstant.hpp"
|
||||
|
||||
// Recognize registered enum types.
|
||||
// Registration is by specializing this trait.
|
||||
//
|
||||
// This is a manual stand-in for the C++11 std::is_enum<T> type trait.
|
||||
// It's a lot of work to implement is_enum portably in C++98, so this
|
||||
// manual approach is being taken for those enum types we need to
|
||||
// distinguish.
|
||||
template<typename T>
|
||||
struct IsRegisteredEnum : public FalseType {};
|
||||
|
||||
#endif // SHARE_METAPROGRAMMING_ISREGISTEREDENUM_HPP
|
@ -30,8 +30,8 @@
|
||||
#include "metaprogramming/integralConstant.hpp"
|
||||
#include "metaprogramming/isFloatingPoint.hpp"
|
||||
#include "metaprogramming/isIntegral.hpp"
|
||||
#include "metaprogramming/isRegisteredEnum.hpp"
|
||||
#include "utilities/debug.hpp"
|
||||
#include <type_traits>
|
||||
|
||||
class PrimitiveConversions : public AllStatic {
|
||||
public:
|
||||
@ -68,8 +68,8 @@ private:
|
||||
// Return an object of type T with the same value representation as x.
|
||||
//
|
||||
// T and U must be of the same size. It is expected that one of T and
|
||||
// U is an integral type, and the other is an integral type, a
|
||||
// (registered) enum type, or a floating point type
|
||||
// U is an integral type, and the other is an integral type, an enum type,
|
||||
// or a floating point type.
|
||||
//
|
||||
// This implementation uses the "union trick", which seems to be the
|
||||
// best of a bad set of options. Though technically undefined
|
||||
@ -122,7 +122,7 @@ template<typename T, typename U>
|
||||
struct PrimitiveConversions::Cast<
|
||||
T, U, true,
|
||||
typename EnableIf<IsIntegral<T>::value &&
|
||||
(IsRegisteredEnum<U>::value ||
|
||||
(std::is_enum<U>::value ||
|
||||
IsFloatingPoint<U>::value)>::type>
|
||||
{
|
||||
T operator()(U x) const { return cast_using_union<T>(x); }
|
||||
@ -133,7 +133,7 @@ template<typename T, typename U>
|
||||
struct PrimitiveConversions::Cast<
|
||||
T, U, true,
|
||||
typename EnableIf<IsIntegral<U>::value &&
|
||||
(IsRegisteredEnum<T>::value ||
|
||||
(std::is_enum<T>::value ||
|
||||
IsFloatingPoint<T>::value)>::type>
|
||||
{
|
||||
T operator()(U x) const { return cast_using_union<T>(x); }
|
||||
|
@ -38,6 +38,7 @@
|
||||
#include "utilities/align.hpp"
|
||||
#include "utilities/bytes.hpp"
|
||||
#include "utilities/macros.hpp"
|
||||
#include <type_traits>
|
||||
|
||||
enum atomic_memory_order {
|
||||
// The modes that align with C++11 are intended to
|
||||
@ -383,7 +384,7 @@ template<typename T, typename PlatformOp>
|
||||
struct Atomic::LoadImpl<
|
||||
T,
|
||||
PlatformOp,
|
||||
typename EnableIf<IsIntegral<T>::value || IsRegisteredEnum<T>::value || IsPointer<T>::value>::type>
|
||||
typename EnableIf<IsIntegral<T>::value || std::is_enum<T>::value || IsPointer<T>::value>::type>
|
||||
{
|
||||
T operator()(T const volatile* dest) const {
|
||||
// Forward to the platform handler for the size of T.
|
||||
@ -435,7 +436,7 @@ template<typename T, typename PlatformOp>
|
||||
struct Atomic::StoreImpl<
|
||||
T, T,
|
||||
PlatformOp,
|
||||
typename EnableIf<IsIntegral<T>::value || IsRegisteredEnum<T>::value>::type>
|
||||
typename EnableIf<IsIntegral<T>::value || std::is_enum<T>::value>::type>
|
||||
{
|
||||
void operator()(T volatile* dest, T new_value) const {
|
||||
// Forward to the platform handler for the size of T.
|
||||
@ -737,7 +738,7 @@ inline bool Atomic::replace_if_null(D* volatile* dest, T* value,
|
||||
template<typename T>
|
||||
struct Atomic::CmpxchgImpl<
|
||||
T, T, T,
|
||||
typename EnableIf<IsIntegral<T>::value || IsRegisteredEnum<T>::value>::type>
|
||||
typename EnableIf<IsIntegral<T>::value || std::is_enum<T>::value>::type>
|
||||
{
|
||||
T operator()(T volatile* dest, T compare_value, T exchange_value,
|
||||
atomic_memory_order order) const {
|
||||
@ -871,7 +872,7 @@ inline T Atomic::CmpxchgByteUsingInt::operator()(T volatile* dest,
|
||||
template<typename T>
|
||||
struct Atomic::XchgImpl<
|
||||
T, T,
|
||||
typename EnableIf<IsIntegral<T>::value || IsRegisteredEnum<T>::value>::type>
|
||||
typename EnableIf<IsIntegral<T>::value || std::is_enum<T>::value>::type>
|
||||
{
|
||||
T operator()(T volatile* dest, T exchange_value, atomic_memory_order order) const {
|
||||
// Forward to the platform handler for the size of T.
|
||||
|
@ -27,7 +27,6 @@
|
||||
|
||||
#include "memory/allocation.hpp"
|
||||
#include "memory/padded.hpp"
|
||||
#include "metaprogramming/isRegisteredEnum.hpp"
|
||||
#include "oops/markWord.hpp"
|
||||
#include "runtime/os.hpp"
|
||||
#include "runtime/park.hpp"
|
||||
@ -378,7 +377,4 @@ class ObjectMonitor {
|
||||
void install_displaced_markword_in_object(const oop obj);
|
||||
};
|
||||
|
||||
// Register for atomic operations.
|
||||
template<> struct IsRegisteredEnum<ObjectMonitor::AllocationState> : public TrueType {};
|
||||
|
||||
#endif // SHARE_RUNTIME_OBJECTMONITOR_HPP
|
||||
|
@ -27,7 +27,6 @@
|
||||
|
||||
#include "jvm.h"
|
||||
#include "jvmtifiles/jvmti.h"
|
||||
#include "metaprogramming/isRegisteredEnum.hpp"
|
||||
#include "metaprogramming/integralConstant.hpp"
|
||||
#include "utilities/exceptions.hpp"
|
||||
#include "utilities/ostream.hpp"
|
||||
@ -972,10 +971,6 @@ class os: AllStatic {
|
||||
|
||||
};
|
||||
|
||||
#ifndef _WINDOWS
|
||||
template<> struct IsRegisteredEnum<os::SuspendResume::State> : public TrueType {};
|
||||
#endif // !_WINDOWS
|
||||
|
||||
// Note that "PAUSE" is almost always used with synchronization
|
||||
// so arguably we should provide Atomic::SpinPause() instead
|
||||
// of the global SpinPause() with C linkage.
|
||||
|
@ -26,7 +26,6 @@
|
||||
#define SHARE_SERVICES_ATTACHLISTENER_HPP
|
||||
|
||||
#include "memory/allocation.hpp"
|
||||
#include "metaprogramming/isRegisteredEnum.hpp"
|
||||
#include "runtime/atomic.hpp"
|
||||
#include "utilities/debug.hpp"
|
||||
#include "utilities/globalDefinitions.hpp"
|
||||
@ -57,8 +56,6 @@ enum AttachListenerState {
|
||||
AL_INITIALIZED
|
||||
};
|
||||
|
||||
template<> struct IsRegisteredEnum<AttachListenerState> : public TrueType {};
|
||||
|
||||
class AttachListener: AllStatic {
|
||||
public:
|
||||
static void vm_start() NOT_SERVICES_RETURN;
|
||||
|
@ -1,44 +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/integralConstant.hpp"
|
||||
#include "metaprogramming/isRegisteredEnum.hpp"
|
||||
|
||||
#include "unittest.hpp"
|
||||
|
||||
struct IsRegisteredEnumTest : AllStatic {
|
||||
enum A { A_x, A_y, A_z };
|
||||
enum B { B_x, B_y, B_z };
|
||||
};
|
||||
|
||||
typedef IsRegisteredEnumTest::A A;
|
||||
typedef IsRegisteredEnumTest::B B;
|
||||
|
||||
template<> struct IsRegisteredEnum<A> : public TrueType {};
|
||||
|
||||
STATIC_ASSERT(!IsRegisteredEnum<int>::value);
|
||||
STATIC_ASSERT(IsRegisteredEnum<A>::value);
|
||||
STATIC_ASSERT(!IsRegisteredEnum<B>::value);
|
@ -22,7 +22,6 @@
|
||||
*/
|
||||
|
||||
#include "precompiled.hpp"
|
||||
#include "metaprogramming/isRegisteredEnum.hpp"
|
||||
#include "runtime/atomic.hpp"
|
||||
#include "runtime/os.hpp"
|
||||
#include "utilities/globalCounter.hpp"
|
||||
@ -40,7 +39,6 @@ enum NestedTestState {
|
||||
SYNCHRONIZING,
|
||||
SYNCHRONIZED
|
||||
};
|
||||
template<> struct IsRegisteredEnum<NestedTestState> : public TrueType {};
|
||||
|
||||
class RCUNestedThread : public JavaTestThread {
|
||||
volatile NestedTestState _state;
|
||||
|
Loading…
x
Reference in New Issue
Block a user