From 03a9a88efbb68537e24b7de28c5b81d6cd8fdb04 Mon Sep 17 00:00:00 2001 From: Justin King Date: Mon, 23 Jan 2023 16:03:28 +0000 Subject: [PATCH] 8300265: Remove metaprogramming/isSigned.hpp Reviewed-by: kbarrett, tschatzl --- .../share/memory/metaspace/counters.hpp | 7 +-- .../share/metaprogramming/isSigned.hpp | 38 --------------- src/hotspot/share/runtime/atomic.hpp | 9 ++-- .../share/utilities/population_count.hpp | 3 +- .../gtest/metaprogramming/test_isSigned.cpp | 48 ------------------- .../utilities/test_count_leading_zeros.cpp | 10 ++-- 6 files changed, 14 insertions(+), 101 deletions(-) delete mode 100644 src/hotspot/share/metaprogramming/isSigned.hpp delete mode 100644 test/hotspot/gtest/metaprogramming/test_isSigned.cpp diff --git a/src/hotspot/share/memory/metaspace/counters.hpp b/src/hotspot/share/memory/metaspace/counters.hpp index 163b33edca7..33c19d1186a 100644 --- a/src/hotspot/share/memory/metaspace/counters.hpp +++ b/src/hotspot/share/memory/metaspace/counters.hpp @@ -26,11 +26,12 @@ #ifndef SHARE_MEMORY_METASPACE_COUNTERS_HPP #define SHARE_MEMORY_METASPACE_COUNTERS_HPP -#include "metaprogramming/isSigned.hpp" #include "runtime/atomic.hpp" #include "utilities/debug.hpp" #include "utilities/globalDefinitions.hpp" +#include + namespace metaspace { // We seem to be counting a lot of things which makes it worthwhile to @@ -43,7 +44,7 @@ class AbstractCounter { T _c; // Only allow unsigned values for now - STATIC_ASSERT(IsSigned::value == false); + STATIC_ASSERT(std::is_signed::value == false); public: @@ -86,7 +87,7 @@ class AbstractAtomicCounter { volatile T _c; // Only allow unsigned values for now - STATIC_ASSERT(IsSigned::value == false); + STATIC_ASSERT(std::is_signed::value == false); public: diff --git a/src/hotspot/share/metaprogramming/isSigned.hpp b/src/hotspot/share/metaprogramming/isSigned.hpp deleted file mode 100644 index 2023d656b3c..00000000000 --- a/src/hotspot/share/metaprogramming/isSigned.hpp +++ /dev/null @@ -1,38 +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_ISSIGNED_HPP -#define SHARE_METAPROGRAMMING_ISSIGNED_HPP - -#include "metaprogramming/integralConstant.hpp" - -#include -#include - -template -struct IsSigned - : public IntegralConstant::type>::is_signed> -{}; - -#endif // SHARE_METAPROGRAMMING_ISSIGNED_HPP diff --git a/src/hotspot/share/runtime/atomic.hpp b/src/hotspot/share/runtime/atomic.hpp index 523a5b9ca42..c730d985645 100644 --- a/src/hotspot/share/runtime/atomic.hpp +++ b/src/hotspot/share/runtime/atomic.hpp @@ -27,7 +27,6 @@ #include "memory/allocation.hpp" #include "metaprogramming/enableIf.hpp" -#include "metaprogramming/isSigned.hpp" #include "metaprogramming/primitiveConversions.hpp" #include "runtime/orderAccess.hpp" #include "utilities/align.hpp" @@ -526,10 +525,10 @@ inline D Atomic::sub(D volatile* dest, I sub_value, atomic_memory_order order) { STATIC_ASSERT(std::is_integral::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. - using PI = std::conditional_t::value, intptr_t, uintptr_t>; + using PI = std::conditional_t::value, intptr_t, uintptr_t>; using AddendType = std::conditional_t::value, PI, D>; // Only allow conversions that can't change the value. - STATIC_ASSERT(IsSigned::value == IsSigned::value); + STATIC_ASSERT(std::is_signed::value == std::is_signed::value); STATIC_ASSERT(sizeof(I) <= sizeof(AddendType)); AddendType addend = sub_value; // Assumes two's complement integer representation. @@ -675,7 +674,7 @@ struct Atomic::AddImpl< typename EnableIf::value && std::is_integral::value && (sizeof(I) <= sizeof(D)) && - (IsSigned::value == IsSigned::value)>::type> + (std::is_signed::value == std::is_signed::value)>::type> { static D add_and_fetch(D volatile* dest, I add_value, atomic_memory_order order) { D addend = add_value; @@ -697,7 +696,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 = std::conditional_t::value, intptr_t, uintptr_t>; + using SI = std::conditional_t::value, intptr_t, uintptr_t>; // Type of the unscaled destination. A pointer type with pointee size == 1. using UP = const char*; diff --git a/src/hotspot/share/utilities/population_count.hpp b/src/hotspot/share/utilities/population_count.hpp index 50b7d33cfcd..df4dc335215 100644 --- a/src/hotspot/share/utilities/population_count.hpp +++ b/src/hotspot/share/utilities/population_count.hpp @@ -26,7 +26,6 @@ #define SHARE_UTILITIES_POPULATION_COUNT_HPP #include "metaprogramming/enableIf.hpp" -#include "metaprogramming/isSigned.hpp" #include "utilities/debug.hpp" #include "utilities/globalDefinitions.hpp" @@ -48,7 +47,7 @@ inline unsigned population_count(T x) { STATIC_ASSERT(BitsPerWord <= 128); STATIC_ASSERT(BitsPerByte == 8); STATIC_ASSERT(std::is_integral::value); - STATIC_ASSERT(!IsSigned::value); + STATIC_ASSERT(!std::is_signed::value); // 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 diff --git a/test/hotspot/gtest/metaprogramming/test_isSigned.cpp b/test/hotspot/gtest/metaprogramming/test_isSigned.cpp deleted file mode 100644 index 4da3ab85de6..00000000000 --- a/test/hotspot/gtest/metaprogramming/test_isSigned.cpp +++ /dev/null @@ -1,48 +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/isSigned.hpp" -#include "utilities/debug.hpp" - -class IsSignedTest: AllStatic { - template - class TestIntegers: AllStatic { - static const bool _signed_type_is_signed = IsSigned::value; - STATIC_ASSERT(_signed_type_is_signed); - static const bool _unsigned_type_is_unsigned = !IsSigned::value; - STATIC_ASSERT(_unsigned_type_is_unsigned); - - static const bool _cvsigned_type_is_signed = IsSigned::value; - STATIC_ASSERT(_signed_type_is_signed); - static const bool _cvunsigned_type_is_unsigned = !IsSigned::value; - STATIC_ASSERT(_unsigned_type_is_unsigned); - }; - - const TestIntegers TestByte; - const TestIntegers TestShort; - const TestIntegers TestInt; - const TestIntegers TestLong; -}; diff --git a/test/hotspot/gtest/utilities/test_count_leading_zeros.cpp b/test/hotspot/gtest/utilities/test_count_leading_zeros.cpp index 35d92401573..e482c8970f1 100644 --- a/test/hotspot/gtest/utilities/test_count_leading_zeros.cpp +++ b/test/hotspot/gtest/utilities/test_count_leading_zeros.cpp @@ -23,17 +23,17 @@ */ #include "precompiled.hpp" -#include "metaprogramming/isSigned.hpp" #include "utilities/count_leading_zeros.hpp" #include "utilities/globalDefinitions.hpp" #include "unittest.hpp" #include +#include template void one_or_two_set_bits() { uint32_t bit1_pos = 0; uint32_t bits = sizeof(T) * BitsPerByte; - uint32_t limit = bits - (IsSigned::value ? 1 : 0); + uint32_t limit = bits - (std::is_signed::value ? 1 : 0); for (uint64_t ix = 1; bit1_pos < limit; ix = ix * 2, ++bit1_pos) { uint32_t bit2_pos = 0; for (uint64_t jx = 1; bit2_pos < limit; jx = jx * 2, ++bit2_pos) { @@ -56,7 +56,7 @@ TEST(count_leading_zeros, one_or_two_set_bits) { } template void high_zeros_low_ones() { - uint32_t number_of_leading_zeros = (IsSigned::value ? 1 : 0); + uint32_t number_of_leading_zeros = (std::is_signed::value ? 1 : 0); T value = std::numeric_limits::max(); for ( ; value != 0; value >>= 1, ++number_of_leading_zeros) { EXPECT_EQ(number_of_leading_zeros, count_leading_zeros(value)) @@ -78,7 +78,7 @@ TEST(count_leading_zeros, high_zeros_low_ones) { template void high_ones_low_zeros() { T value = std::numeric_limits::max(); - uint32_t number_of_leading_zeros = (IsSigned::value ? 1 : 0); + uint32_t number_of_leading_zeros = (std::is_signed::value ? 1 : 0); for (uint64_t i = 1; value != 0; value -= i, i <<= 1) { EXPECT_EQ(number_of_leading_zeros, count_leading_zeros(value)) << "value = " << value; @@ -97,4 +97,4 @@ TEST(count_leading_zeros, high_ones_low_zeros) { high_ones_low_zeros(); high_ones_low_zeros(); high_ones_low_zeros(); -} \ No newline at end of file +}