changeset 58072:26136b5b27bf

8183574: Unify the is_power_of_2 functions Reviewed-by: kbarrett, redestad
author stefank
date Mon, 17 Feb 2020 10:03:17 +0100
parents 690fc7e5a90f
children efc0da4a10a9
files src/hotspot/cpu/aarch64/c1_LIRAssembler_aarch64.cpp src/hotspot/cpu/aarch64/c1_LIRGenerator_aarch64.cpp src/hotspot/cpu/aarch64/c1_Runtime1_aarch64.cpp src/hotspot/cpu/aarch64/interp_masm_aarch64.cpp src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp src/hotspot/cpu/aarch64/macroAssembler_aarch64.hpp src/hotspot/cpu/aarch64/stubGenerator_aarch64.cpp src/hotspot/cpu/aarch64/templateInterpreterGenerator_aarch64.cpp src/hotspot/cpu/aarch64/templateTable_aarch64.cpp src/hotspot/cpu/arm/c1_LIRAssembler_arm.cpp src/hotspot/cpu/arm/c1_LIRGenerator_arm.cpp src/hotspot/cpu/arm/c1_MacroAssembler_arm.cpp src/hotspot/cpu/arm/interp_masm_arm.cpp src/hotspot/cpu/arm/macroAssembler_arm.cpp src/hotspot/cpu/arm/macroAssembler_arm.hpp src/hotspot/cpu/arm/sharedRuntime_arm.cpp src/hotspot/cpu/arm/stubGenerator_arm.cpp src/hotspot/cpu/arm/templateTable_arm.cpp src/hotspot/cpu/ppc/assembler_ppc.cpp src/hotspot/cpu/ppc/c1_LIRAssembler_ppc.cpp src/hotspot/cpu/ppc/c1_LIRGenerator_ppc.cpp src/hotspot/cpu/ppc/c1_MacroAssembler_ppc.cpp src/hotspot/cpu/ppc/c1_Runtime1_ppc.cpp src/hotspot/cpu/ppc/interp_masm_ppc_64.cpp src/hotspot/cpu/ppc/macroAssembler_ppc.cpp src/hotspot/cpu/ppc/macroAssembler_ppc.inline.hpp src/hotspot/cpu/ppc/ppc.ad src/hotspot/cpu/ppc/stubGenerator_ppc.cpp src/hotspot/cpu/ppc/templateTable_ppc_64.cpp src/hotspot/cpu/ppc/vm_version_ppc.cpp src/hotspot/cpu/s390/c1_LIRAssembler_s390.cpp src/hotspot/cpu/s390/c1_LIRGenerator_s390.cpp src/hotspot/cpu/s390/c1_Runtime1_s390.cpp src/hotspot/cpu/s390/interp_masm_s390.cpp src/hotspot/cpu/s390/macroAssembler_s390.cpp src/hotspot/cpu/s390/stubGenerator_s390.cpp src/hotspot/cpu/s390/templateTable_s390.cpp src/hotspot/cpu/sparc/c1_LIRAssembler_sparc.cpp src/hotspot/cpu/sparc/c1_LIRGenerator_sparc.cpp src/hotspot/cpu/sparc/interp_masm_sparc.cpp src/hotspot/cpu/sparc/macroAssembler_sparc.cpp src/hotspot/cpu/x86/assembler_x86.hpp src/hotspot/cpu/x86/c1_LIRAssembler_x86.cpp src/hotspot/cpu/x86/c1_LIRGenerator_x86.cpp src/hotspot/cpu/x86/interp_masm_x86.cpp src/hotspot/cpu/x86/vm_version_x86.cpp src/hotspot/cpu/x86/x86_64.ad src/hotspot/os/linux/os_linux.cpp src/hotspot/share/adlc/main.cpp src/hotspot/share/aot/aotCodeHeap.cpp src/hotspot/share/asm/codeBuffer.cpp src/hotspot/share/c1/c1_GraphBuilder.cpp src/hotspot/share/c1/c1_LIRGenerator.cpp src/hotspot/share/ci/ciArray.cpp src/hotspot/share/code/codeHeapState.cpp src/hotspot/share/code/vtableStubs.cpp src/hotspot/share/gc/g1/g1BiasedArray.hpp src/hotspot/share/gc/g1/g1RegionMarkStatsCache.cpp src/hotspot/share/gc/g1/g1RegionToSpaceMapper.cpp src/hotspot/share/gc/parallel/parallelArguments.cpp src/hotspot/share/gc/shared/jvmFlagConstraintsGC.cpp src/hotspot/share/gc/shared/oopStorage.cpp src/hotspot/share/gc/shared/stringdedup/stringDedupTable.cpp src/hotspot/share/gc/shenandoah/shenandoahCodeRoots.cpp src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp src/hotspot/share/gc/z/zAddress.inline.hpp src/hotspot/share/gc/z/zLiveMap.cpp src/hotspot/share/gc/z/zMarkCache.cpp src/hotspot/share/gc/z/zMarkStack.cpp src/hotspot/share/gc/z/zNMethodTable.cpp src/hotspot/share/gc/z/zRelocationSetSelector.cpp src/hotspot/share/memory/arena.hpp src/hotspot/share/memory/heap.cpp src/hotspot/share/memory/virtualspace.cpp src/hotspot/share/oops/klass.cpp src/hotspot/share/opto/arraycopynode.cpp src/hotspot/share/opto/block.hpp src/hotspot/share/opto/callnode.cpp src/hotspot/share/opto/divnode.cpp src/hotspot/share/opto/graphKit.cpp src/hotspot/share/opto/library_call.cpp src/hotspot/share/opto/loopnode.cpp src/hotspot/share/opto/macro.cpp src/hotspot/share/opto/macroArrayCopy.cpp src/hotspot/share/opto/memnode.cpp src/hotspot/share/opto/mulnode.cpp src/hotspot/share/opto/output.cpp src/hotspot/share/opto/regmask.cpp src/hotspot/share/opto/superword.cpp src/hotspot/share/opto/type.cpp src/hotspot/share/opto/vectornode.cpp src/hotspot/share/runtime/arguments.cpp src/hotspot/share/runtime/flags/jvmFlagConstraintsCompiler.cpp src/hotspot/share/runtime/flags/jvmFlagConstraintsRuntime.cpp src/hotspot/share/utilities/align.hpp src/hotspot/share/utilities/globalDefinitions.cpp src/hotspot/share/utilities/globalDefinitions.hpp src/hotspot/share/utilities/powerOfTwo.hpp test/hotspot/gtest/gc/z/test_zForwarding.cpp test/hotspot/gtest/utilities/test_powerOfTwo.cpp
diffstat 100 files changed, 183 insertions(+), 75 deletions(-) [+]
line wrap: on
line diff
--- a/src/hotspot/cpu/aarch64/c1_LIRAssembler_aarch64.cpp	Mon Feb 17 08:59:26 2020 +0100
+++ b/src/hotspot/cpu/aarch64/c1_LIRAssembler_aarch64.cpp	Mon Feb 17 10:03:17 2020 +0100
@@ -40,10 +40,10 @@
 #include "oops/objArrayKlass.hpp"
 #include "runtime/frame.inline.hpp"
 #include "runtime/sharedRuntime.hpp"
+#include "utilities/powerOfTwo.hpp"
 #include "vmreg_aarch64.inline.hpp"
 
 
-
 #ifndef PRODUCT
 #define COMMENT(x)   do { __ block_comment(x); } while (0)
 #else
@@ -1747,7 +1747,7 @@
           code == lir_add ? __ add(dreg, lreg_lo, c) : __ sub(dreg, lreg_lo, c);
           break;
         case lir_div:
-          assert(c > 0 && is_power_of_2_long(c), "divisor must be power-of-2 constant");
+          assert(c > 0 && is_power_of_2(c), "divisor must be power-of-2 constant");
           if (c == 1) {
             // move lreg_lo to dreg if divisor is 1
             __ mov(dreg, lreg_lo);
@@ -1760,7 +1760,7 @@
           }
           break;
         case lir_rem:
-          assert(c > 0 && is_power_of_2_long(c), "divisor must be power-of-2 constant");
+          assert(c > 0 && is_power_of_2(c), "divisor must be power-of-2 constant");
           if (c == 1) {
             // move 0 to dreg if divisor is 1
             __ mov(dreg, zr);
--- a/src/hotspot/cpu/aarch64/c1_LIRGenerator_aarch64.cpp	Mon Feb 17 08:59:26 2020 +0100
+++ b/src/hotspot/cpu/aarch64/c1_LIRGenerator_aarch64.cpp	Mon Feb 17 10:03:17 2020 +0100
@@ -37,6 +37,7 @@
 #include "ci/ciTypeArrayKlass.hpp"
 #include "runtime/sharedRuntime.hpp"
 #include "runtime/stubRoutines.hpp"
+#include "utilities/powerOfTwo.hpp"
 #include "vmreg_aarch64.inline.hpp"
 
 #ifdef ASSERT
@@ -447,7 +448,7 @@
       // no need to do div-by-zero check if the divisor is a non-zero constant
       if (c != 0) need_zero_check = false;
       // do not load right if the divisor is a power-of-2 constant
-      if (c > 0 && is_power_of_2_long(c)) {
+      if (c > 0 && is_power_of_2(c)) {
         right.dont_load_item();
       } else {
         right.load_item();
--- a/src/hotspot/cpu/aarch64/c1_Runtime1_aarch64.cpp	Mon Feb 17 08:59:26 2020 +0100
+++ b/src/hotspot/cpu/aarch64/c1_Runtime1_aarch64.cpp	Mon Feb 17 10:03:17 2020 +0100
@@ -43,6 +43,7 @@
 #include "runtime/signature.hpp"
 #include "runtime/vframe.hpp"
 #include "runtime/vframeArray.hpp"
+#include "utilities/powerOfTwo.hpp"
 #include "vmreg_aarch64.inline.hpp"
 
 
--- a/src/hotspot/cpu/aarch64/interp_masm_aarch64.cpp	Mon Feb 17 08:59:26 2020 +0100
+++ b/src/hotspot/cpu/aarch64/interp_masm_aarch64.cpp	Mon Feb 17 10:03:17 2020 +0100
@@ -43,7 +43,7 @@
 #include "runtime/safepointMechanism.hpp"
 #include "runtime/sharedRuntime.hpp"
 #include "runtime/thread.inline.hpp"
-
+#include "utilities/powerOfTwo.hpp"
 
 void InterpreterMacroAssembler::narrow(Register result) {
 
--- a/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp	Mon Feb 17 08:59:26 2020 +0100
+++ b/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp	Mon Feb 17 10:03:17 2020 +0100
@@ -47,6 +47,7 @@
 #include "runtime/jniHandles.inline.hpp"
 #include "runtime/sharedRuntime.hpp"
 #include "runtime/thread.hpp"
+#include "utilities/powerOfTwo.hpp"
 #ifdef COMPILER1
 #include "c1/c1_LIRAssembler.hpp"
 #endif
--- a/src/hotspot/cpu/aarch64/macroAssembler_aarch64.hpp	Mon Feb 17 08:59:26 2020 +0100
+++ b/src/hotspot/cpu/aarch64/macroAssembler_aarch64.hpp	Mon Feb 17 10:03:17 2020 +0100
@@ -28,6 +28,7 @@
 
 #include "asm/assembler.hpp"
 #include "oops/compressedOops.hpp"
+#include "utilities/powerOfTwo.hpp"
 
 // MacroAssembler extends Assembler by frequently used macros.
 //
--- a/src/hotspot/cpu/aarch64/stubGenerator_aarch64.cpp	Mon Feb 17 08:59:26 2020 +0100
+++ b/src/hotspot/cpu/aarch64/stubGenerator_aarch64.cpp	Mon Feb 17 10:03:17 2020 +0100
@@ -43,6 +43,7 @@
 #include "runtime/stubRoutines.hpp"
 #include "runtime/thread.inline.hpp"
 #include "utilities/align.hpp"
+#include "utilities/powerOfTwo.hpp"
 #ifdef COMPILER2
 #include "opto/runtime.hpp"
 #endif
--- a/src/hotspot/cpu/aarch64/templateInterpreterGenerator_aarch64.cpp	Mon Feb 17 08:59:26 2020 +0100
+++ b/src/hotspot/cpu/aarch64/templateInterpreterGenerator_aarch64.cpp	Mon Feb 17 10:03:17 2020 +0100
@@ -49,6 +49,7 @@
 #include "runtime/timer.hpp"
 #include "runtime/vframeArray.hpp"
 #include "utilities/debug.hpp"
+#include "utilities/powerOfTwo.hpp"
 #include <sys/types.h>
 
 #ifndef PRODUCT
--- a/src/hotspot/cpu/aarch64/templateTable_aarch64.cpp	Mon Feb 17 08:59:26 2020 +0100
+++ b/src/hotspot/cpu/aarch64/templateTable_aarch64.cpp	Mon Feb 17 10:03:17 2020 +0100
@@ -40,6 +40,7 @@
 #include "runtime/sharedRuntime.hpp"
 #include "runtime/stubRoutines.hpp"
 #include "runtime/synchronizer.hpp"
+#include "utilities/powerOfTwo.hpp"
 
 #define __ _masm->
 
--- a/src/hotspot/cpu/arm/c1_LIRAssembler_arm.cpp	Mon Feb 17 08:59:26 2020 +0100
+++ b/src/hotspot/cpu/arm/c1_LIRAssembler_arm.cpp	Mon Feb 17 10:03:17 2020 +0100
@@ -37,6 +37,7 @@
 #include "oops/objArrayKlass.hpp"
 #include "runtime/frame.inline.hpp"
 #include "runtime/sharedRuntime.hpp"
+#include "utilities/powerOfTwo.hpp"
 #include "vmreg_arm.inline.hpp"
 
 #define __ _masm->
--- a/src/hotspot/cpu/arm/c1_LIRGenerator_arm.cpp	Mon Feb 17 08:59:26 2020 +0100
+++ b/src/hotspot/cpu/arm/c1_LIRGenerator_arm.cpp	Mon Feb 17 10:03:17 2020 +0100
@@ -40,6 +40,7 @@
 #include "gc/shared/cardTableBarrierSet.hpp"
 #include "runtime/sharedRuntime.hpp"
 #include "runtime/stubRoutines.hpp"
+#include "utilities/powerOfTwo.hpp"
 #include "vmreg_arm.inline.hpp"
 
 #ifdef ASSERT
--- a/src/hotspot/cpu/arm/c1_MacroAssembler_arm.cpp	Mon Feb 17 08:59:26 2020 +0100
+++ b/src/hotspot/cpu/arm/c1_MacroAssembler_arm.cpp	Mon Feb 17 10:03:17 2020 +0100
@@ -35,6 +35,7 @@
 #include "runtime/os.hpp"
 #include "runtime/sharedRuntime.hpp"
 #include "runtime/stubRoutines.hpp"
+#include "utilities/powerOfTwo.hpp"
 
 // Note: Rtemp usage is this file should not impact C2 and should be
 // correct as long as it is not implicitly used in lower layers (the
--- a/src/hotspot/cpu/arm/interp_masm_arm.cpp	Mon Feb 17 08:59:26 2020 +0100
+++ b/src/hotspot/cpu/arm/interp_masm_arm.cpp	Mon Feb 17 10:03:17 2020 +0100
@@ -44,6 +44,7 @@
 #include "runtime/frame.inline.hpp"
 #include "runtime/safepointMechanism.hpp"
 #include "runtime/sharedRuntime.hpp"
+#include "utilities/powerOfTwo.hpp"
 
 //--------------------------------------------------------------------
 // Implementation of InterpreterMacroAssembler
--- a/src/hotspot/cpu/arm/macroAssembler_arm.cpp	Mon Feb 17 08:59:26 2020 +0100
+++ b/src/hotspot/cpu/arm/macroAssembler_arm.cpp	Mon Feb 17 10:03:17 2020 +0100
@@ -46,6 +46,7 @@
 #include "runtime/sharedRuntime.hpp"
 #include "runtime/stubRoutines.hpp"
 #include "utilities/macros.hpp"
+#include "utilities/powerOfTwo.hpp"
 
 // Implementation of AddressLiteral
 
--- a/src/hotspot/cpu/arm/macroAssembler_arm.hpp	Mon Feb 17 08:59:26 2020 +0100
+++ b/src/hotspot/cpu/arm/macroAssembler_arm.hpp	Mon Feb 17 10:03:17 2020 +0100
@@ -26,6 +26,7 @@
 #define CPU_ARM_MACROASSEMBLER_ARM_HPP
 
 #include "code/relocInfo.hpp"
+#include "utilities/powerOfTwo.hpp"
 
 class BiasedLockingCounters;
 
--- a/src/hotspot/cpu/arm/sharedRuntime_arm.cpp	Mon Feb 17 08:59:26 2020 +0100
+++ b/src/hotspot/cpu/arm/sharedRuntime_arm.cpp	Mon Feb 17 10:03:17 2020 +0100
@@ -37,6 +37,7 @@
 #include "runtime/safepointMechanism.hpp"
 #include "runtime/vframeArray.hpp"
 #include "utilities/align.hpp"
+#include "utilities/powerOfTwo.hpp"
 #include "vmreg_arm.inline.hpp"
 #ifdef COMPILER1
 #include "c1/c1_Runtime1.hpp"
--- a/src/hotspot/cpu/arm/stubGenerator_arm.cpp	Mon Feb 17 08:59:26 2020 +0100
+++ b/src/hotspot/cpu/arm/stubGenerator_arm.cpp	Mon Feb 17 10:03:17 2020 +0100
@@ -41,6 +41,7 @@
 #include "runtime/stubCodeGenerator.hpp"
 #include "runtime/stubRoutines.hpp"
 #include "utilities/align.hpp"
+#include "utilities/powerOfTwo.hpp"
 #ifdef COMPILER2
 #include "opto/runtime.hpp"
 #endif
--- a/src/hotspot/cpu/arm/templateTable_arm.cpp	Mon Feb 17 08:59:26 2020 +0100
+++ b/src/hotspot/cpu/arm/templateTable_arm.cpp	Mon Feb 17 10:03:17 2020 +0100
@@ -39,6 +39,7 @@
 #include "runtime/sharedRuntime.hpp"
 #include "runtime/stubRoutines.hpp"
 #include "runtime/synchronizer.hpp"
+#include "utilities/powerOfTwo.hpp"
 
 #define __ _masm->
 
--- a/src/hotspot/cpu/ppc/assembler_ppc.cpp	Mon Feb 17 08:59:26 2020 +0100
+++ b/src/hotspot/cpu/ppc/assembler_ppc.cpp	Mon Feb 17 10:03:17 2020 +0100
@@ -37,6 +37,7 @@
 #include "runtime/sharedRuntime.hpp"
 #include "runtime/stubRoutines.hpp"
 #include "utilities/macros.hpp"
+#include "utilities/powerOfTwo.hpp"
 
 #ifdef PRODUCT
 #define BLOCK_COMMENT(str) // nothing
@@ -78,13 +79,13 @@
 
 // Low-level andi-one-instruction-macro.
 void Assembler::andi(Register a, Register s, const long ui16) {
-  if (is_power_of_2_long(((jlong) ui16)+1)) {
+  if (is_power_of_2(((jlong) ui16)+1)) {
     // pow2minus1
-    clrldi(a, s, 64-log2_long((((jlong) ui16)+1)));
-  } else if (is_power_of_2_long((jlong) ui16)) {
+    clrldi(a, s, 64-log2((((jlong) ui16)+1)));
+  } else if (is_power_of_2((jlong) ui16)) {
     // pow2
     rlwinm(a, s, 0, 31-log2_long((jlong) ui16), 31-log2_long((jlong) ui16));
-  } else if (is_power_of_2_long((jlong)-ui16)) {
+  } else if (is_power_of_2((jlong)-ui16)) {
     // negpow2
     clrrdi(a, s, log2_long((jlong)-ui16));
   } else {
--- a/src/hotspot/cpu/ppc/c1_LIRAssembler_ppc.cpp	Mon Feb 17 08:59:26 2020 +0100
+++ b/src/hotspot/cpu/ppc/c1_LIRAssembler_ppc.cpp	Mon Feb 17 10:03:17 2020 +0100
@@ -40,6 +40,7 @@
 #include "runtime/frame.inline.hpp"
 #include "runtime/safepointMechanism.inline.hpp"
 #include "runtime/sharedRuntime.hpp"
+#include "utilities/powerOfTwo.hpp"
 
 #define __ _masm->
 
@@ -1762,7 +1763,7 @@
 
     switch (code) {
       case lir_logic_and:
-        if (uimmss != 0 || (uimms != 0 && (uimm & 0xFFFF) != 0) || is_power_of_2_long(uimm)) {
+        if (uimmss != 0 || (uimms != 0 && (uimm & 0xFFFF) != 0) || is_power_of_2(uimm)) {
           __ andi(d, l, uimm); // special cases
         } else if (uimms != 0) { __ andis_(d, l, uimms); }
         else { __ andi_(d, l, uimm); }
--- a/src/hotspot/cpu/ppc/c1_LIRGenerator_ppc.cpp	Mon Feb 17 08:59:26 2020 +0100
+++ b/src/hotspot/cpu/ppc/c1_LIRGenerator_ppc.cpp	Mon Feb 17 10:03:17 2020 +0100
@@ -37,6 +37,7 @@
 #include "ci/ciTypeArrayKlass.hpp"
 #include "runtime/sharedRuntime.hpp"
 #include "runtime/stubRoutines.hpp"
+#include "utilities/powerOfTwo.hpp"
 #include "vmreg_ppc.inline.hpp"
 
 #ifdef ASSERT
@@ -574,13 +575,13 @@
 
   // see Assembler::andi
   if (bc == Bytecodes::_iand &&
-      (is_power_of_2_long(int_or_long_const+1) ||
-       is_power_of_2_long(int_or_long_const) ||
-       is_power_of_2_long(-int_or_long_const))) return true;
+      (is_power_of_2(int_or_long_const+1) ||
+       is_power_of_2(int_or_long_const) ||
+       is_power_of_2(-int_or_long_const))) return true;
   if (bc == Bytecodes::_land &&
-      (is_power_of_2_long(int_or_long_const+1) ||
-       (Assembler::is_uimm(int_or_long_const, 32) && is_power_of_2_long(int_or_long_const)) ||
-       (int_or_long_const != min_jlong && is_power_of_2_long(-int_or_long_const)))) return true;
+      (is_power_of_2(int_or_long_const+1) ||
+       (Assembler::is_uimm(int_or_long_const, 32) && is_power_of_2(int_or_long_const)) ||
+       (int_or_long_const != min_jlong && is_power_of_2(-int_or_long_const)))) return true;
 
   // special case: xor -1
   if ((bc == Bytecodes::_ixor || bc == Bytecodes::_lxor) &&
--- a/src/hotspot/cpu/ppc/c1_MacroAssembler_ppc.cpp	Mon Feb 17 08:59:26 2020 +0100
+++ b/src/hotspot/cpu/ppc/c1_MacroAssembler_ppc.cpp	Mon Feb 17 10:03:17 2020 +0100
@@ -38,7 +38,7 @@
 #include "runtime/sharedRuntime.hpp"
 #include "runtime/stubRoutines.hpp"
 #include "utilities/align.hpp"
-
+#include "utilities/powerOfTwo.hpp"
 
 void C1_MacroAssembler::inline_cache_check(Register receiver, Register iCache) {
   const Register temp_reg = R12_scratch2;
--- a/src/hotspot/cpu/ppc/c1_Runtime1_ppc.cpp	Mon Feb 17 08:59:26 2020 +0100
+++ b/src/hotspot/cpu/ppc/c1_Runtime1_ppc.cpp	Mon Feb 17 10:03:17 2020 +0100
@@ -42,6 +42,7 @@
 #include "runtime/vframeArray.hpp"
 #include "utilities/align.hpp"
 #include "utilities/macros.hpp"
+#include "utilities/powerOfTwo.hpp"
 #include "vmreg_ppc.inline.hpp"
 
 // Implementation of StubAssembler
--- a/src/hotspot/cpu/ppc/interp_masm_ppc_64.cpp	Mon Feb 17 08:59:26 2020 +0100
+++ b/src/hotspot/cpu/ppc/interp_masm_ppc_64.cpp	Mon Feb 17 10:03:17 2020 +0100
@@ -34,6 +34,7 @@
 #include "runtime/frame.inline.hpp"
 #include "runtime/safepointMechanism.hpp"
 #include "runtime/sharedRuntime.hpp"
+#include "utilities/powerOfTwo.hpp"
 
 // Implementation of InterpreterMacroAssembler.
 
--- a/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp	Mon Feb 17 08:59:26 2020 +0100
+++ b/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp	Mon Feb 17 10:03:17 2020 +0100
@@ -44,6 +44,7 @@
 #include "runtime/sharedRuntime.hpp"
 #include "runtime/stubRoutines.hpp"
 #include "utilities/macros.hpp"
+#include "utilities/powerOfTwo.hpp"
 #ifdef COMPILER2
 #include "opto/intrinsicnode.hpp"
 #endif
--- a/src/hotspot/cpu/ppc/macroAssembler_ppc.inline.hpp	Mon Feb 17 08:59:26 2020 +0100
+++ b/src/hotspot/cpu/ppc/macroAssembler_ppc.inline.hpp	Mon Feb 17 10:03:17 2020 +0100
@@ -35,6 +35,7 @@
 #include "oops/accessDecorators.hpp"
 #include "oops/compressedOops.hpp"
 #include "runtime/safepointMechanism.hpp"
+#include "utilities/powerOfTwo.hpp"
 
 inline bool MacroAssembler::is_ld_largeoffset(address a) {
   const int inst1 = *(int *)a;
@@ -56,7 +57,7 @@
 }
 
 inline void MacroAssembler::round_to(Register r, int modulus) {
-  assert(is_power_of_2_long((jlong)modulus), "must be power of 2");
+  assert(is_power_of_2((jlong)modulus), "must be power of 2");
   addi(r, r, modulus-1);
   clrrdi(r, r, log2_long((jlong)modulus));
 }
--- a/src/hotspot/cpu/ppc/ppc.ad	Mon Feb 17 08:59:26 2020 +0100
+++ b/src/hotspot/cpu/ppc/ppc.ad	Mon Feb 17 10:03:17 2020 +0100
@@ -4350,7 +4350,7 @@
 %}
 
 operand immInegpow2() %{
-  predicate(is_power_of_2_long((jlong) (julong) (juint) (-(n->get_int()))));
+  predicate(is_power_of_2((jlong) (julong) (juint) (-(n->get_int()))));
   match(ConI);
   op_cost(0);
   format %{ %}
@@ -4358,7 +4358,7 @@
 %}
 
 operand immIpow2minus1() %{
-  predicate(is_power_of_2_long((((jlong) (n->get_int()))+1)));
+  predicate(is_power_of_2((((jlong) (n->get_int()))+1)));
   match(ConI);
   op_cost(0);
   format %{ %}
@@ -4366,7 +4366,7 @@
 %}
 
 operand immIpowerOf2() %{
-  predicate(is_power_of_2_long((((jlong) (julong) (juint) (n->get_int())))));
+  predicate(is_power_of_2((((jlong) (julong) (juint) (n->get_int())))));
   match(ConI);
   op_cost(0);
   format %{ %}
@@ -4600,7 +4600,7 @@
 %}
 
 operand immLnegpow2() %{
-  predicate(is_power_of_2_long((jlong)-(n->get_long())));
+  predicate(is_power_of_2((jlong)-(n->get_long())));
   match(ConL);
   op_cost(0);
   format %{ %}
@@ -4608,7 +4608,7 @@
 %}
 
 operand immLpow2minus1() %{
-  predicate(is_power_of_2_long((((jlong) (n->get_long()))+1)) &&
+  predicate(is_power_of_2((((jlong) (n->get_long()))+1)) &&
             (n->get_long() != (jlong)0xffffffffffffffffL));
   match(ConL);
   op_cost(0);
--- a/src/hotspot/cpu/ppc/stubGenerator_ppc.cpp	Mon Feb 17 08:59:26 2020 +0100
+++ b/src/hotspot/cpu/ppc/stubGenerator_ppc.cpp	Mon Feb 17 10:03:17 2020 +0100
@@ -41,6 +41,7 @@
 #include "runtime/stubRoutines.hpp"
 #include "runtime/thread.inline.hpp"
 #include "utilities/align.hpp"
+#include "utilities/powerOfTwo.hpp"
 
 // Declaration and definition of StubGenerator (no .hpp file).
 // For a more detailed description of the stub routine structure
--- a/src/hotspot/cpu/ppc/templateTable_ppc_64.cpp	Mon Feb 17 08:59:26 2020 +0100
+++ b/src/hotspot/cpu/ppc/templateTable_ppc_64.cpp	Mon Feb 17 10:03:17 2020 +0100
@@ -42,6 +42,7 @@
 #include "runtime/stubRoutines.hpp"
 #include "runtime/synchronizer.hpp"
 #include "utilities/macros.hpp"
+#include "utilities/powerOfTwo.hpp"
 
 #undef __
 #define __ _masm->
--- a/src/hotspot/cpu/ppc/vm_version_ppc.cpp	Mon Feb 17 08:59:26 2020 +0100
+++ b/src/hotspot/cpu/ppc/vm_version_ppc.cpp	Mon Feb 17 10:03:17 2020 +0100
@@ -36,6 +36,7 @@
 #include "utilities/align.hpp"
 #include "utilities/defaultStream.hpp"
 #include "utilities/globalDefinitions.hpp"
+#include "utilities/powerOfTwo.hpp"
 
 #include <sys/sysinfo.h>
 #if defined(_AIX)
--- a/src/hotspot/cpu/s390/c1_LIRAssembler_s390.cpp	Mon Feb 17 08:59:26 2020 +0100
+++ b/src/hotspot/cpu/s390/c1_LIRAssembler_s390.cpp	Mon Feb 17 10:03:17 2020 +0100
@@ -39,6 +39,7 @@
 #include "runtime/frame.inline.hpp"
 #include "runtime/safepointMechanism.inline.hpp"
 #include "runtime/sharedRuntime.hpp"
+#include "utilities/powerOfTwo.hpp"
 #include "vmreg_s390.inline.hpp"
 
 #define __ _masm->
@@ -1798,7 +1799,7 @@
   if (left->is_double_cpu()) {
     // 64 bit integer case
     assert(left->is_double_cpu(), "left must be register");
-    assert(right->is_double_cpu() || is_power_of_2_long(right->as_jlong()),
+    assert(right->is_double_cpu() || is_power_of_2(right->as_jlong()),
            "right must be register or power of 2 constant");
     assert(result->is_double_cpu(), "result must be register");
 
--- a/src/hotspot/cpu/s390/c1_LIRGenerator_s390.cpp	Mon Feb 17 08:59:26 2020 +0100
+++ b/src/hotspot/cpu/s390/c1_LIRGenerator_s390.cpp	Mon Feb 17 10:03:17 2020 +0100
@@ -37,6 +37,7 @@
 #include "runtime/sharedRuntime.hpp"
 #include "runtime/stubRoutines.hpp"
 #include "vmreg_s390.inline.hpp"
+#include "utilities/powerOfTwo.hpp"
 
 #ifdef ASSERT
 #define __ gen()->lir(__FILE__, __LINE__)->
--- a/src/hotspot/cpu/s390/c1_Runtime1_s390.cpp	Mon Feb 17 08:59:26 2020 +0100
+++ b/src/hotspot/cpu/s390/c1_Runtime1_s390.cpp	Mon Feb 17 10:03:17 2020 +0100
@@ -38,12 +38,13 @@
 #include "oops/oop.inline.hpp"
 #include "prims/jvmtiExport.hpp"
 #include "register_s390.hpp"
+#include "registerSaver_s390.hpp"
 #include "runtime/sharedRuntime.hpp"
 #include "runtime/signature.hpp"
 #include "runtime/vframeArray.hpp"
 #include "utilities/macros.hpp"
+#include "utilities/powerOfTwo.hpp"
 #include "vmreg_s390.inline.hpp"
-#include "registerSaver_s390.hpp"
 
 // Implementation of StubAssembler
 
--- a/src/hotspot/cpu/s390/interp_masm_s390.cpp	Mon Feb 17 08:59:26 2020 +0100
+++ b/src/hotspot/cpu/s390/interp_masm_s390.cpp	Mon Feb 17 10:03:17 2020 +0100
@@ -42,6 +42,7 @@
 #include "runtime/safepointMechanism.hpp"
 #include "runtime/sharedRuntime.hpp"
 #include "runtime/thread.inline.hpp"
+#include "utilities/powerOfTwo.hpp"
 
 // Implementation of InterpreterMacroAssembler.
 // This file specializes the assembler with interpreter-specific macros.
--- a/src/hotspot/cpu/s390/macroAssembler_s390.cpp	Mon Feb 17 08:59:26 2020 +0100
+++ b/src/hotspot/cpu/s390/macroAssembler_s390.cpp	Mon Feb 17 10:03:17 2020 +0100
@@ -55,6 +55,7 @@
 #include "runtime/stubRoutines.hpp"
 #include "utilities/events.hpp"
 #include "utilities/macros.hpp"
+#include "utilities/powerOfTwo.hpp"
 
 #include <ucontext.h>
 
--- a/src/hotspot/cpu/s390/stubGenerator_s390.cpp	Mon Feb 17 08:59:26 2020 +0100
+++ b/src/hotspot/cpu/s390/stubGenerator_s390.cpp	Mon Feb 17 10:03:17 2020 +0100
@@ -42,6 +42,7 @@
 #include "runtime/stubCodeGenerator.hpp"
 #include "runtime/stubRoutines.hpp"
 #include "runtime/thread.inline.hpp"
+#include "utilities/powerOfTwo.hpp"
 
 // Declaration and definition of StubGenerator (no .hpp file).
 // For a more detailed description of the stub routine structure
--- a/src/hotspot/cpu/s390/templateTable_s390.cpp	Mon Feb 17 08:59:26 2020 +0100
+++ b/src/hotspot/cpu/s390/templateTable_s390.cpp	Mon Feb 17 10:03:17 2020 +0100
@@ -39,6 +39,7 @@
 #include "runtime/sharedRuntime.hpp"
 #include "runtime/stubRoutines.hpp"
 #include "runtime/synchronizer.hpp"
+#include "utilities/powerOfTwo.hpp"
 
 #ifdef PRODUCT
 #define __ _masm->
--- a/src/hotspot/cpu/sparc/c1_LIRAssembler_sparc.cpp	Mon Feb 17 08:59:26 2020 +0100
+++ b/src/hotspot/cpu/sparc/c1_LIRAssembler_sparc.cpp	Mon Feb 17 10:03:17 2020 +0100
@@ -40,6 +40,7 @@
 #include "runtime/jniHandles.inline.hpp"
 #include "runtime/safepointMechanism.inline.hpp"
 #include "runtime/sharedRuntime.hpp"
+#include "utilities/powerOfTwo.hpp"
 
 #define __ _masm->
 
--- a/src/hotspot/cpu/sparc/c1_LIRGenerator_sparc.cpp	Mon Feb 17 08:59:26 2020 +0100
+++ b/src/hotspot/cpu/sparc/c1_LIRGenerator_sparc.cpp	Mon Feb 17 10:03:17 2020 +0100
@@ -37,6 +37,7 @@
 #include "runtime/safepointMechanism.hpp"
 #include "runtime/sharedRuntime.hpp"
 #include "runtime/stubRoutines.hpp"
+#include "utilities/powerOfTwo.hpp"
 #include "vmreg_sparc.inline.hpp"
 
 #ifdef ASSERT
--- a/src/hotspot/cpu/sparc/interp_masm_sparc.cpp	Mon Feb 17 08:59:26 2020 +0100
+++ b/src/hotspot/cpu/sparc/interp_masm_sparc.cpp	Mon Feb 17 10:03:17 2020 +0100
@@ -42,6 +42,7 @@
 #include "runtime/sharedRuntime.hpp"
 #include "runtime/thread.inline.hpp"
 #include "utilities/align.hpp"
+#include "utilities/powerOfTwo.hpp"
 
 // Implementation of InterpreterMacroAssembler
 
--- a/src/hotspot/cpu/sparc/macroAssembler_sparc.cpp	Mon Feb 17 08:59:26 2020 +0100
+++ b/src/hotspot/cpu/sparc/macroAssembler_sparc.cpp	Mon Feb 17 10:03:17 2020 +0100
@@ -48,6 +48,7 @@
 #include "runtime/stubRoutines.hpp"
 #include "utilities/align.hpp"
 #include "utilities/macros.hpp"
+#include "utilities/powerOfTwo.hpp"
 #ifdef COMPILER2
 #include "opto/intrinsicnode.hpp"
 #endif
--- a/src/hotspot/cpu/x86/assembler_x86.hpp	Mon Feb 17 08:59:26 2020 +0100
+++ b/src/hotspot/cpu/x86/assembler_x86.hpp	Mon Feb 17 10:03:17 2020 +0100
@@ -27,6 +27,7 @@
 
 #include "asm/register.hpp"
 #include "runtime/vm_version.hpp"
+#include "utilities/powerOfTwo.hpp"
 
 class BiasedLockingCounters;
 
--- a/src/hotspot/cpu/x86/c1_LIRAssembler_x86.cpp	Mon Feb 17 08:59:26 2020 +0100
+++ b/src/hotspot/cpu/x86/c1_LIRAssembler_x86.cpp	Mon Feb 17 10:03:17 2020 +0100
@@ -38,6 +38,7 @@
 #include "runtime/frame.inline.hpp"
 #include "runtime/safepointMechanism.hpp"
 #include "runtime/sharedRuntime.hpp"
+#include "utilities/powerOfTwo.hpp"
 #include "vmreg_x86.inline.hpp"
 
 
--- a/src/hotspot/cpu/x86/c1_LIRGenerator_x86.cpp	Mon Feb 17 08:59:26 2020 +0100
+++ b/src/hotspot/cpu/x86/c1_LIRGenerator_x86.cpp	Mon Feb 17 10:03:17 2020 +0100
@@ -36,6 +36,7 @@
 #include "gc/shared/c1/barrierSetC1.hpp"
 #include "runtime/sharedRuntime.hpp"
 #include "runtime/stubRoutines.hpp"
+#include "utilities/powerOfTwo.hpp"
 #include "vmreg_x86.inline.hpp"
 
 #ifdef ASSERT
--- a/src/hotspot/cpu/x86/interp_masm_x86.cpp	Mon Feb 17 08:59:26 2020 +0100
+++ b/src/hotspot/cpu/x86/interp_masm_x86.cpp	Mon Feb 17 10:03:17 2020 +0100
@@ -39,6 +39,7 @@
 #include "runtime/safepointMechanism.hpp"
 #include "runtime/sharedRuntime.hpp"
 #include "runtime/thread.inline.hpp"
+#include "utilities/powerOfTwo.hpp"
 
 // Implementation of InterpreterMacroAssembler
 
--- a/src/hotspot/cpu/x86/vm_version_x86.cpp	Mon Feb 17 08:59:26 2020 +0100
+++ b/src/hotspot/cpu/x86/vm_version_x86.cpp	Mon Feb 17 10:03:17 2020 +0100
@@ -33,6 +33,7 @@
 #include "runtime/os.hpp"
 #include "runtime/stubCodeGenerator.hpp"
 #include "runtime/vm_version.hpp"
+#include "utilities/powerOfTwo.hpp"
 #include "utilities/virtualizationSupport.hpp"
 
 #include OS_HEADER_INLINE(os)
--- a/src/hotspot/cpu/x86/x86_64.ad	Mon Feb 17 08:59:26 2020 +0100
+++ b/src/hotspot/cpu/x86/x86_64.ad	Mon Feb 17 10:03:17 2020 +0100
@@ -3120,7 +3120,7 @@
 
 operand immL_Pow2()
 %{
-  predicate(is_power_of_2_long(n->get_long()));
+  predicate(is_power_of_2(n->get_long()));
   match(ConL);
 
   op_cost(15);
@@ -3130,7 +3130,7 @@
 
 operand immL_NotPow2()
 %{
-  predicate(is_power_of_2_long(~n->get_long()));
+  predicate(is_power_of_2(~n->get_long()));
   match(ConL);
 
   op_cost(15);
--- a/src/hotspot/os/linux/os_linux.cpp	Mon Feb 17 08:59:26 2020 +0100
+++ b/src/hotspot/os/linux/os_linux.cpp	Mon Feb 17 10:03:17 2020 +0100
@@ -74,6 +74,7 @@
 #include "utilities/elfFile.hpp"
 #include "utilities/growableArray.hpp"
 #include "utilities/macros.hpp"
+#include "utilities/powerOfTwo.hpp"
 #include "utilities/vmError.hpp"
 
 // put OS-includes here
--- a/src/hotspot/share/adlc/main.cpp	Mon Feb 17 08:59:26 2020 +0100
+++ b/src/hotspot/share/adlc/main.cpp	Mon Feb 17 10:03:17 2020 +0100
@@ -233,6 +233,7 @@
   AD.addInclude(AD._CPP_file, "runtime/sharedRuntime.hpp");
   AD.addInclude(AD._CPP_file, "runtime/stubRoutines.hpp");
   AD.addInclude(AD._CPP_file, "utilities/growableArray.hpp");
+  AD.addInclude(AD._CPP_file, "utilities/powerOfTwo.hpp");
   AD.addInclude(AD._HPP_file, "memory/allocation.hpp");
   AD.addInclude(AD._HPP_file, "oops/compressedOops.hpp");
   AD.addInclude(AD._HPP_file, "code/nativeInst.hpp");
@@ -268,6 +269,8 @@
   AD.addInclude(AD._DFA_file, "opto/narrowptrnode.hpp");
   AD.addInclude(AD._DFA_file, "opto/opcodes.hpp");
   AD.addInclude(AD._DFA_file, "opto/convertnode.hpp");
+  AD.addInclude(AD._DFA_file, "utilities/powerOfTwo.hpp");
+
   // Make sure each .cpp file starts with include lines:
   // files declaring and defining generators for Mach* Objects (hpp,cpp)
   // Generate the result files:
--- a/src/hotspot/share/aot/aotCodeHeap.cpp	Mon Feb 17 08:59:26 2020 +0100
+++ b/src/hotspot/share/aot/aotCodeHeap.cpp	Mon Feb 17 10:03:17 2020 +0100
@@ -47,6 +47,7 @@
 #include "runtime/safepointVerifiers.hpp"
 #include "runtime/sharedRuntime.hpp"
 #include "runtime/vmOperations.hpp"
+#include "utilities/powerOfTwo.hpp"
 #include "utilities/sizes.hpp"
 
 bool AOTLib::_narrow_oop_shift_initialized = false;
--- a/src/hotspot/share/asm/codeBuffer.cpp	Mon Feb 17 08:59:26 2020 +0100
+++ b/src/hotspot/share/asm/codeBuffer.cpp	Mon Feb 17 10:03:17 2020 +0100
@@ -32,6 +32,7 @@
 #include "runtime/safepointVerifiers.hpp"
 #include "utilities/align.hpp"
 #include "utilities/copy.hpp"
+#include "utilities/powerOfTwo.hpp"
 #include "utilities/xmlstream.hpp"
 
 // The structure of a CodeSection:
--- a/src/hotspot/share/c1/c1_GraphBuilder.cpp	Mon Feb 17 08:59:26 2020 +0100
+++ b/src/hotspot/share/c1/c1_GraphBuilder.cpp	Mon Feb 17 10:03:17 2020 +0100
@@ -42,6 +42,7 @@
 #include "runtime/sharedRuntime.hpp"
 #include "runtime/vm_version.hpp"
 #include "utilities/bitMap.inline.hpp"
+#include "utilities/powerOfTwo.hpp"
 
 class BlockListBuilder {
  private:
--- a/src/hotspot/share/c1/c1_LIRGenerator.cpp	Mon Feb 17 08:59:26 2020 +0100
+++ b/src/hotspot/share/c1/c1_LIRGenerator.cpp	Mon Feb 17 10:03:17 2020 +0100
@@ -43,6 +43,7 @@
 #include "runtime/vm_version.hpp"
 #include "utilities/bitMap.inline.hpp"
 #include "utilities/macros.hpp"
+#include "utilities/powerOfTwo.hpp"
 
 #ifdef ASSERT
 #define __ gen()->lir(__FILE__, __LINE__)->
--- a/src/hotspot/share/ci/ciArray.cpp	Mon Feb 17 08:59:26 2020 +0100
+++ b/src/hotspot/share/ci/ciArray.cpp	Mon Feb 17 10:03:17 2020 +0100
@@ -31,6 +31,7 @@
 #include "oops/objArrayOop.inline.hpp"
 #include "oops/oop.inline.hpp"
 #include "oops/typeArrayOop.inline.hpp"
+#include "utilities/powerOfTwo.hpp"
 
 // ciArray
 //
--- a/src/hotspot/share/code/codeHeapState.cpp	Mon Feb 17 08:59:26 2020 +0100
+++ b/src/hotspot/share/code/codeHeapState.cpp	Mon Feb 17 10:03:17 2020 +0100
@@ -27,6 +27,7 @@
 #include "code/codeHeapState.hpp"
 #include "compiler/compileBroker.hpp"
 #include "runtime/sweeper.hpp"
+#include "utilities/powerOfTwo.hpp"
 
 // -------------------------
 // |  General Description  |
--- a/src/hotspot/share/code/vtableStubs.cpp	Mon Feb 17 08:59:26 2020 +0100
+++ b/src/hotspot/share/code/vtableStubs.cpp	Mon Feb 17 10:03:17 2020 +0100
@@ -38,6 +38,7 @@
 #include "runtime/mutexLocker.hpp"
 #include "runtime/sharedRuntime.hpp"
 #include "utilities/align.hpp"
+#include "utilities/powerOfTwo.hpp"
 #ifdef COMPILER2
 #include "opto/matcher.hpp"
 #endif
@@ -128,7 +129,7 @@
   {
     MutexLocker ml(VtableStubs_lock, Mutex::_no_safepoint_check_flag);
     assert(_number_of_vtable_stubs == 0, "potential performance bug: VtableStubs initialized more than once");
-    assert(is_power_of_2(N), "N must be a power of 2");
+    assert(is_power_of_2(int(N)), "N must be a power of 2");
     for (int i = 0; i < N; i++) {
       _table[i] = NULL;
     }
--- a/src/hotspot/share/gc/g1/g1BiasedArray.hpp	Mon Feb 17 08:59:26 2020 +0100
+++ b/src/hotspot/share/gc/g1/g1BiasedArray.hpp	Mon Feb 17 10:03:17 2020 +0100
@@ -27,6 +27,7 @@
 
 #include "memory/memRegion.hpp"
 #include "utilities/debug.hpp"
+#include "utilities/powerOfTwo.hpp"
 
 // Implements the common base functionality for arrays that contain provisions
 // for accessing its elements using a biased index.
--- a/src/hotspot/share/gc/g1/g1RegionMarkStatsCache.cpp	Mon Feb 17 08:59:26 2020 +0100
+++ b/src/hotspot/share/gc/g1/g1RegionMarkStatsCache.cpp	Mon Feb 17 10:03:17 2020 +0100
@@ -25,6 +25,7 @@
 #include "precompiled.hpp"
 #include "gc/g1/g1RegionMarkStatsCache.inline.hpp"
 #include "memory/allocation.inline.hpp"
+#include "utilities/powerOfTwo.hpp"
 
 G1RegionMarkStatsCache::G1RegionMarkStatsCache(G1RegionMarkStats* target, uint max_regions, uint num_cache_entries) :
   _target(target),
--- a/src/hotspot/share/gc/g1/g1RegionToSpaceMapper.cpp	Mon Feb 17 08:59:26 2020 +0100
+++ b/src/hotspot/share/gc/g1/g1RegionToSpaceMapper.cpp	Mon Feb 17 10:03:17 2020 +0100
@@ -35,6 +35,7 @@
 #include "utilities/align.hpp"
 #include "utilities/bitMap.inline.hpp"
 #include "utilities/formatBuffer.hpp"
+#include "utilities/powerOfTwo.hpp"
 
 G1RegionToSpaceMapper::G1RegionToSpaceMapper(ReservedSpace rs,
                                              size_t used_size,
--- a/src/hotspot/share/gc/parallel/parallelArguments.cpp	Mon Feb 17 08:59:26 2020 +0100
+++ b/src/hotspot/share/gc/parallel/parallelArguments.cpp	Mon Feb 17 10:03:17 2020 +0100
@@ -35,6 +35,7 @@
 #include "runtime/globals_extension.hpp"
 #include "runtime/java.hpp"
 #include "utilities/defaultStream.hpp"
+#include "utilities/powerOfTwo.hpp"
 
 static const double MaxRamFractionForYoung = 0.8;
 
--- a/src/hotspot/share/gc/shared/jvmFlagConstraintsGC.cpp	Mon Feb 17 08:59:26 2020 +0100
+++ b/src/hotspot/share/gc/shared/jvmFlagConstraintsGC.cpp	Mon Feb 17 10:03:17 2020 +0100
@@ -36,6 +36,7 @@
 #include "runtime/thread.inline.hpp"
 #include "utilities/align.hpp"
 #include "utilities/macros.hpp"
+#include "utilities/powerOfTwo.hpp"
 #if INCLUDE_G1GC
 #include "gc/g1/jvmFlagConstraintsG1.hpp"
 #endif
--- a/src/hotspot/share/gc/shared/oopStorage.cpp	Mon Feb 17 08:59:26 2020 +0100
+++ b/src/hotspot/share/gc/shared/oopStorage.cpp	Mon Feb 17 10:03:17 2020 +0100
@@ -45,6 +45,7 @@
 #include "utilities/globalDefinitions.hpp"
 #include "utilities/macros.hpp"
 #include "utilities/ostream.hpp"
+#include "utilities/powerOfTwo.hpp"
 
 OopStorage::AllocationListEntry::AllocationListEntry() : _prev(NULL), _next(NULL) {}
 
--- a/src/hotspot/share/gc/shared/stringdedup/stringDedupTable.cpp	Mon Feb 17 08:59:26 2020 +0100
+++ b/src/hotspot/share/gc/shared/stringdedup/stringDedupTable.cpp	Mon Feb 17 10:03:17 2020 +0100
@@ -38,6 +38,7 @@
 #include "runtime/atomic.hpp"
 #include "runtime/mutexLocker.hpp"
 #include "runtime/safepointVerifiers.hpp"
+#include "utilities/powerOfTwo.hpp"
 
 //
 // List of deduplication table entries. Links table
--- a/src/hotspot/share/gc/shenandoah/shenandoahCodeRoots.cpp	Mon Feb 17 08:59:26 2020 +0100
+++ b/src/hotspot/share/gc/shenandoah/shenandoahCodeRoots.cpp	Mon Feb 17 10:03:17 2020 +0100
@@ -34,6 +34,7 @@
 #include "memory/resourceArea.hpp"
 #include "memory/universe.hpp"
 #include "runtime/atomic.hpp"
+#include "utilities/powerOfTwo.hpp"
 
 ShenandoahParallelCodeCacheIterator::ShenandoahParallelCodeCacheIterator(const GrowableArray<CodeHeap*>* heaps) {
   _length = heaps->length();
--- a/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp	Mon Feb 17 08:59:26 2020 +0100
+++ b/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp	Mon Feb 17 10:03:17 2020 +0100
@@ -80,6 +80,7 @@
 #include "runtime/safepointMechanism.hpp"
 #include "runtime/vmThread.hpp"
 #include "services/mallocTracker.hpp"
+#include "utilities/powerOfTwo.hpp"
 
 #ifdef ASSERT
 template <class T>
--- a/src/hotspot/share/gc/z/zAddress.inline.hpp	Mon Feb 17 08:59:26 2020 +0100
+++ b/src/hotspot/share/gc/z/zAddress.inline.hpp	Mon Feb 17 10:03:17 2020 +0100
@@ -28,6 +28,7 @@
 #include "gc/z/zGlobals.hpp"
 #include "utilities/globalDefinitions.hpp"
 #include "utilities/macros.hpp"
+#include "utilities/powerOfTwo.hpp"
 
 inline bool ZAddress::is_null(uintptr_t value) {
   return value == 0;
--- a/src/hotspot/share/gc/z/zLiveMap.cpp	Mon Feb 17 08:59:26 2020 +0100
+++ b/src/hotspot/share/gc/z/zLiveMap.cpp	Mon Feb 17 10:03:17 2020 +0100
@@ -29,6 +29,7 @@
 #include "logging/log.hpp"
 #include "runtime/atomic.hpp"
 #include "utilities/debug.hpp"
+#include "utilities/powerOfTwo.hpp"
 
 static const ZStatCounter ZCounterMarkSeqNumResetContention("Contention", "Mark SeqNum Reset Contention", ZStatUnitOpsPerSecond);
 static const ZStatCounter ZCounterMarkSegmentResetContention("Contention", "Mark Segment Reset Contention", ZStatUnitOpsPerSecond);
--- a/src/hotspot/share/gc/z/zMarkCache.cpp	Mon Feb 17 08:59:26 2020 +0100
+++ b/src/hotspot/share/gc/z/zMarkCache.cpp	Mon Feb 17 10:03:17 2020 +0100
@@ -24,6 +24,7 @@
 #include "precompiled.hpp"
 #include "gc/z/zMarkCache.inline.hpp"
 #include "utilities/globalDefinitions.hpp"
+#include "utilities/powerOfTwo.hpp"
 
 ZMarkCacheEntry::ZMarkCacheEntry() :
     _page(NULL),
--- a/src/hotspot/share/gc/z/zMarkStack.cpp	Mon Feb 17 08:59:26 2020 +0100
+++ b/src/hotspot/share/gc/z/zMarkStack.cpp	Mon Feb 17 10:03:17 2020 +0100
@@ -26,6 +26,7 @@
 #include "gc/z/zMarkStackAllocator.hpp"
 #include "logging/log.hpp"
 #include "utilities/debug.hpp"
+#include "utilities/powerOfTwo.hpp"
 
 ZMarkStripe::ZMarkStripe() :
     _published(),
--- a/src/hotspot/share/gc/z/zNMethodTable.cpp	Mon Feb 17 08:59:26 2020 +0100
+++ b/src/hotspot/share/gc/z/zNMethodTable.cpp	Mon Feb 17 10:03:17 2020 +0100
@@ -43,6 +43,7 @@
 #include "memory/iterator.hpp"
 #include "memory/resourceArea.hpp"
 #include "utilities/debug.hpp"
+#include "utilities/powerOfTwo.hpp"
 
 ZNMethodTableEntry* ZNMethodTable::_table = NULL;
 size_t ZNMethodTable::_size = 0;
--- a/src/hotspot/share/gc/z/zRelocationSetSelector.cpp	Mon Feb 17 08:59:26 2020 +0100
+++ b/src/hotspot/share/gc/z/zRelocationSetSelector.cpp	Mon Feb 17 10:03:17 2020 +0100
@@ -29,6 +29,7 @@
 #include "logging/log.hpp"
 #include "runtime/globals.hpp"
 #include "utilities/debug.hpp"
+#include "utilities/powerOfTwo.hpp"
 
 ZRelocationSetSelectorGroupStats::ZRelocationSetSelectorGroupStats() :
     _npages(0),
--- a/src/hotspot/share/memory/arena.hpp	Mon Feb 17 08:59:26 2020 +0100
+++ b/src/hotspot/share/memory/arena.hpp	Mon Feb 17 10:03:17 2020 +0100
@@ -28,6 +28,7 @@
 #include "memory/allocation.hpp"
 #include "runtime/globals.hpp"
 #include "utilities/globalDefinitions.hpp"
+#include "utilities/powerOfTwo.hpp"
 
 #include <new>
 
--- a/src/hotspot/share/memory/heap.cpp	Mon Feb 17 08:59:26 2020 +0100
+++ b/src/hotspot/share/memory/heap.cpp	Mon Feb 17 10:03:17 2020 +0100
@@ -28,6 +28,7 @@
 #include "runtime/os.hpp"
 #include "services/memTracker.hpp"
 #include "utilities/align.hpp"
+#include "utilities/powerOfTwo.hpp"
 
 size_t CodeHeap::header_size() {
   return sizeof(HeapBlock);
--- a/src/hotspot/share/memory/virtualspace.cpp	Mon Feb 17 08:59:26 2020 +0100
+++ b/src/hotspot/share/memory/virtualspace.cpp	Mon Feb 17 10:03:17 2020 +0100
@@ -32,6 +32,7 @@
 #include "runtime/os.inline.hpp"
 #include "services/memTracker.hpp"
 #include "utilities/align.hpp"
+#include "utilities/powerOfTwo.hpp"
 
 // ReservedSpace
 
--- a/src/hotspot/share/oops/klass.cpp	Mon Feb 17 08:59:26 2020 +0100
+++ b/src/hotspot/share/oops/klass.cpp	Mon Feb 17 10:03:17 2020 +0100
@@ -47,6 +47,7 @@
 #include "runtime/atomic.hpp"
 #include "runtime/handles.inline.hpp"
 #include "utilities/macros.hpp"
+#include "utilities/powerOfTwo.hpp"
 #include "utilities/stack.inline.hpp"
 
 void Klass::set_java_mirror(Handle m) {
--- a/src/hotspot/share/opto/arraycopynode.cpp	Mon Feb 17 08:59:26 2020 +0100
+++ b/src/hotspot/share/opto/arraycopynode.cpp	Mon Feb 17 10:03:17 2020 +0100
@@ -30,6 +30,7 @@
 #include "opto/graphKit.hpp"
 #include "runtime/sharedRuntime.hpp"
 #include "utilities/macros.hpp"
+#include "utilities/powerOfTwo.hpp"
 
 ArrayCopyNode::ArrayCopyNode(Compile* C, bool alloc_tightly_coupled, bool has_negative_length_guard)
   : CallNode(arraycopy_type(), NULL, TypePtr::BOTTOM),
--- a/src/hotspot/share/opto/block.hpp	Mon Feb 17 08:59:26 2020 +0100
+++ b/src/hotspot/share/opto/block.hpp	Mon Feb 17 10:03:17 2020 +0100
@@ -28,6 +28,7 @@
 #include "opto/multnode.hpp"
 #include "opto/node.hpp"
 #include "opto/phase.hpp"
+#include "utilities/powerOfTwo.hpp"
 
 // Optimization - Graph Style
 
--- a/src/hotspot/share/opto/callnode.cpp	Mon Feb 17 08:59:26 2020 +0100
+++ b/src/hotspot/share/opto/callnode.cpp	Mon Feb 17 10:03:17 2020 +0100
@@ -42,6 +42,7 @@
 #include "opto/regmask.hpp"
 #include "opto/rootnode.hpp"
 #include "opto/runtime.hpp"
+#include "utilities/powerOfTwo.hpp"
 
 // Portions of code courtesy of Clifford Click
 
--- a/src/hotspot/share/opto/divnode.cpp	Mon Feb 17 08:59:26 2020 +0100
+++ b/src/hotspot/share/opto/divnode.cpp	Mon Feb 17 10:03:17 2020 +0100
@@ -34,6 +34,7 @@
 #include "opto/mulnode.hpp"
 #include "opto/phaseX.hpp"
 #include "opto/subnode.hpp"
+#include "utilities/powerOfTwo.hpp"
 
 // Portions of code courtesy of Clifford Click
 
@@ -359,7 +360,7 @@
       // Just negate the value
       q = new SubLNode(phase->longcon(0), dividend);
     }
-  } else if ( is_power_of_2_long(d) ) {
+  } else if ( is_power_of_2(d) ) {
 
     // division by +/- a power of 2
 
@@ -377,7 +378,7 @@
       const TypeLong *andconl_t = phase->type( dividend->in(2) )->isa_long();
       if( andconl_t && andconl_t->is_con() ) {
         jlong andconl = andconl_t->get_con();
-        if( andconl < 0 && is_power_of_2_long(-andconl) && (-andconl) >= d ) {
+        if( andconl < 0 && is_power_of_2(-andconl) && (-andconl) >= d ) {
           if( (-andconl) == d ) // Remove AND if it clears bits which will be shifted
             dividend = dividend->in(1);
           needs_rounding = false;
@@ -1044,7 +1045,7 @@
   Node *hook = new Node(1);
 
   // Expand mod
-  if( con >= 0 && con < max_jlong && is_power_of_2_long(con+1) ) {
+  if( con >= 0 && con < max_jlong && is_power_of_2(con+1) ) {
     uint k = exact_log2_long(con+1);  // Extract k
 
     // Basic algorithm by David Detlefs.  See fastmod_long.java for gory details.
@@ -1108,7 +1109,7 @@
   int log2_con = -1;
 
   // If this is a power of two, then maybe we can mask it
-  if( is_power_of_2_long(pos_con) ) {
+  if( is_power_of_2(pos_con) ) {
     log2_con = exact_log2_long(pos_con);
 
     const Type *dt = phase->type(in(1));
--- a/src/hotspot/share/opto/graphKit.cpp	Mon Feb 17 08:59:26 2020 +0100
+++ b/src/hotspot/share/opto/graphKit.cpp	Mon Feb 17 10:03:17 2020 +0100
@@ -44,6 +44,7 @@
 #include "runtime/deoptimization.hpp"
 #include "runtime/sharedRuntime.hpp"
 #include "utilities/bitMap.inline.hpp"
+#include "utilities/powerOfTwo.hpp"
 
 //----------------------------GraphKit-----------------------------------------
 // Main utility constructor.
--- a/src/hotspot/share/opto/library_call.cpp	Mon Feb 17 08:59:26 2020 +0100
+++ b/src/hotspot/share/opto/library_call.cpp	Mon Feb 17 10:03:17 2020 +0100
@@ -58,7 +58,7 @@
 #include "runtime/objectMonitor.hpp"
 #include "runtime/sharedRuntime.hpp"
 #include "utilities/macros.hpp"
-
+#include "utilities/powerOfTwo.hpp"
 
 class LibraryIntrinsic : public InlineCallGenerator {
   // Extend the set of intrinsics known to the runtime:
--- a/src/hotspot/share/opto/loopnode.cpp	Mon Feb 17 08:59:26 2020 +0100
+++ b/src/hotspot/share/opto/loopnode.cpp	Mon Feb 17 10:03:17 2020 +0100
@@ -40,6 +40,7 @@
 #include "opto/mulnode.hpp"
 #include "opto/rootnode.hpp"
 #include "opto/superword.hpp"
+#include "utilities/powerOfTwo.hpp"
 
 //=============================================================================
 //--------------------------is_cloop_ind_var-----------------------------------
--- a/src/hotspot/share/opto/macro.cpp	Mon Feb 17 08:59:26 2020 +0100
+++ b/src/hotspot/share/opto/macro.cpp	Mon Feb 17 10:03:17 2020 +0100
@@ -49,6 +49,7 @@
 #include "opto/type.hpp"
 #include "runtime/sharedRuntime.hpp"
 #include "utilities/macros.hpp"
+#include "utilities/powerOfTwo.hpp"
 #if INCLUDE_G1GC
 #include "gc/g1/g1ThreadLocalData.hpp"
 #endif // INCLUDE_G1GC
--- a/src/hotspot/share/opto/macroArrayCopy.cpp	Mon Feb 17 08:59:26 2020 +0100
+++ b/src/hotspot/share/opto/macroArrayCopy.cpp	Mon Feb 17 10:03:17 2020 +0100
@@ -31,7 +31,7 @@
 #include "opto/macro.hpp"
 #include "opto/runtime.hpp"
 #include "utilities/align.hpp"
-
+#include "utilities/powerOfTwo.hpp"
 
 void PhaseMacroExpand::insert_mem_bar(Node** ctrl, Node** mem, int opcode, Node* precedent) {
   MemBarNode* mb = MemBarNode::make(C, opcode, Compile::AliasIdxBot, precedent);
--- a/src/hotspot/share/opto/memnode.cpp	Mon Feb 17 08:59:26 2020 +0100
+++ b/src/hotspot/share/opto/memnode.cpp	Mon Feb 17 10:03:17 2020 +0100
@@ -48,6 +48,7 @@
 #include "utilities/align.hpp"
 #include "utilities/copy.hpp"
 #include "utilities/macros.hpp"
+#include "utilities/powerOfTwo.hpp"
 #include "utilities/vmError.hpp"
 
 // Portions of code courtesy of Clifford Click
--- a/src/hotspot/share/opto/mulnode.cpp	Mon Feb 17 08:59:26 2020 +0100
+++ b/src/hotspot/share/opto/mulnode.cpp	Mon Feb 17 10:03:17 2020 +0100
@@ -31,6 +31,7 @@
 #include "opto/mulnode.hpp"
 #include "opto/phaseX.hpp"
 #include "opto/subnode.hpp"
+#include "utilities/powerOfTwo.hpp"
 
 // Portions of code courtesy of Clifford Click
 
@@ -306,7 +307,7 @@
       Node *n2 = phase->transform(new LShiftLNode(in(1), phase->intcon(log2_long(bit2))));
       res = new AddLNode(n2, n1);
 
-    } else if (is_power_of_2_long(abs_con+1)) {
+    } else if (is_power_of_2(abs_con+1)) {
       // Sleezy: power-of-2 -1.  Next time be generic.
       julong temp = abs_con + 1;
       Node *n1 = phase->transform( new LShiftLNode(in(1), phase->intcon(log2_long(temp))));
@@ -1409,4 +1410,3 @@
 uint MulAddS2INode::hash() const {
   return (uintptr_t)in(1) + (uintptr_t)in(2) + (uintptr_t)in(3) + (uintptr_t)in(4) + Opcode();
 }
-
--- a/src/hotspot/share/opto/output.cpp	Mon Feb 17 08:59:26 2020 +0100
+++ b/src/hotspot/share/opto/output.cpp	Mon Feb 17 10:03:17 2020 +0100
@@ -46,6 +46,7 @@
 #include "opto/subnode.hpp"
 #include "opto/type.hpp"
 #include "runtime/handles.inline.hpp"
+#include "utilities/powerOfTwo.hpp"
 #include "utilities/xmlstream.hpp"
 
 #ifndef PRODUCT
--- a/src/hotspot/share/opto/regmask.cpp	Mon Feb 17 08:59:26 2020 +0100
+++ b/src/hotspot/share/opto/regmask.cpp	Mon Feb 17 10:03:17 2020 +0100
@@ -29,6 +29,7 @@
 #include "opto/node.hpp"
 #include "opto/regmask.hpp"
 #include "utilities/population_count.hpp"
+#include "utilities/powerOfTwo.hpp"
 
 #define RM_SIZE _RM_SIZE /* a constant private to the class RegMask */
 
--- a/src/hotspot/share/opto/superword.cpp	Mon Feb 17 08:59:26 2020 +0100
+++ b/src/hotspot/share/opto/superword.cpp	Mon Feb 17 10:03:17 2020 +0100
@@ -39,6 +39,7 @@
 #include "opto/superword.hpp"
 #include "opto/vectornode.hpp"
 #include "opto/movenode.hpp"
+#include "utilities/powerOfTwo.hpp"
 
 //
 //                  S U P E R W O R D   T R A N S F O R M
--- a/src/hotspot/share/opto/type.cpp	Mon Feb 17 08:59:26 2020 +0100
+++ b/src/hotspot/share/opto/type.cpp	Mon Feb 17 10:03:17 2020 +0100
@@ -39,6 +39,7 @@
 #include "opto/node.hpp"
 #include "opto/opcodes.hpp"
 #include "opto/type.hpp"
+#include "utilities/powerOfTwo.hpp"
 
 // Portions of code courtesy of Clifford Click
 
--- a/src/hotspot/share/opto/vectornode.cpp	Mon Feb 17 08:59:26 2020 +0100
+++ b/src/hotspot/share/opto/vectornode.cpp	Mon Feb 17 10:03:17 2020 +0100
@@ -25,6 +25,7 @@
 #include "memory/allocation.inline.hpp"
 #include "opto/connode.hpp"
 #include "opto/vectornode.hpp"
+#include "utilities/powerOfTwo.hpp"
 
 //------------------------------VectorNode--------------------------------------
 
--- a/src/hotspot/share/runtime/arguments.cpp	Mon Feb 17 08:59:26 2020 +0100
+++ b/src/hotspot/share/runtime/arguments.cpp	Mon Feb 17 10:03:17 2020 +0100
@@ -54,6 +54,7 @@
 #include "utilities/align.hpp"
 #include "utilities/defaultStream.hpp"
 #include "utilities/macros.hpp"
+#include "utilities/powerOfTwo.hpp"
 #include "utilities/stringUtils.hpp"
 #if INCLUDE_JFR
 #include "jfr/jfr.hpp"
--- a/src/hotspot/share/runtime/flags/jvmFlagConstraintsCompiler.cpp	Mon Feb 17 08:59:26 2020 +0100
+++ b/src/hotspot/share/runtime/flags/jvmFlagConstraintsCompiler.cpp	Mon Feb 17 10:03:17 2020 +0100
@@ -33,6 +33,7 @@
 #include "runtime/flags/jvmFlagConstraintsCompiler.hpp"
 #include "runtime/globals.hpp"
 #include "runtime/globals_extension.hpp"
+#include "utilities/powerOfTwo.hpp"
 
 JVMFlag::Error AliasLevelConstraintFunc(intx value, bool verbose) {
   if ((value <= 1) && (Arguments::mode() == Arguments::_comp || Arguments::mode() == Arguments::_mixed)) {
--- a/src/hotspot/share/runtime/flags/jvmFlagConstraintsRuntime.cpp	Mon Feb 17 08:59:26 2020 +0100
+++ b/src/hotspot/share/runtime/flags/jvmFlagConstraintsRuntime.cpp	Mon Feb 17 10:03:17 2020 +0100
@@ -29,6 +29,7 @@
 #include "runtime/globals.hpp"
 #include "runtime/safepointMechanism.hpp"
 #include "runtime/task.hpp"
+#include "utilities/powerOfTwo.hpp"
 
 JVMFlag::Error ObjectAlignmentInBytesConstraintFunc(intx value, bool verbose) {
   if (!is_power_of_2(value)) {
--- a/src/hotspot/share/utilities/align.hpp	Mon Feb 17 08:59:26 2020 +0100
+++ b/src/hotspot/share/utilities/align.hpp	Mon Feb 17 10:03:17 2020 +0100
@@ -26,6 +26,7 @@
 #define SHARE_UTILITIES_ALIGN_HPP
 
 #include "utilities/globalDefinitions.hpp"
+#include "utilities/powerOfTwo.hpp"
 
 // Signed variants of alignment helpers.  There are two versions of each, a macro
 // for use in places like enum definitions that require compile-time constant
@@ -46,17 +47,11 @@
 
 #define is_aligned_(size, alignment) (((size) & align_mask(alignment)) == 0)
 
-// Temporary declaration until this file has been restructured.
-template <typename T>
-bool is_power_of_2_t(T x) {
-  return (x != T(0)) && ((x & (x - 1)) == T(0));
-}
-
 // Helpers to align sizes and check for alignment
 
 template <typename T, typename A>
 inline T align_up(T size, A alignment) {
-  assert(is_power_of_2_t(alignment), "must be a power of 2: " UINT64_FORMAT, (uint64_t)alignment);
+  assert(is_power_of_2(alignment), "must be a power of 2: " UINT64_FORMAT, (uint64_t)alignment);
 
   T ret = align_up_(size, alignment);
   assert(is_aligned_(ret, alignment), "must be aligned: " UINT64_FORMAT, (uint64_t)ret);
@@ -66,7 +61,7 @@
 
 template <typename T, typename A>
 inline T align_down(T size, A alignment) {
-  assert(is_power_of_2_t(alignment), "must be a power of 2: " UINT64_FORMAT, (uint64_t)alignment);
+  assert(is_power_of_2(alignment), "must be a power of 2: " UINT64_FORMAT, (uint64_t)alignment);
 
   T ret = align_down_(size, alignment);
   assert(is_aligned_(ret, alignment), "must be aligned: " UINT64_FORMAT, (uint64_t)ret);
@@ -76,7 +71,7 @@
 
 template <typename T, typename A>
 inline bool is_aligned(T size, A alignment) {
-  assert(is_power_of_2_t(alignment), "must be a power of 2: " UINT64_FORMAT, (uint64_t)alignment);
+  assert(is_power_of_2(alignment), "must be a power of 2: " UINT64_FORMAT, (uint64_t)alignment);
 
   return is_aligned_(size, alignment);
 }
--- a/src/hotspot/share/utilities/globalDefinitions.cpp	Mon Feb 17 08:59:26 2020 +0100
+++ b/src/hotspot/share/utilities/globalDefinitions.cpp	Mon Feb 17 10:03:17 2020 +0100
@@ -27,6 +27,7 @@
 #include "runtime/os.hpp"
 #include "runtime/signature.hpp"
 #include "utilities/globalDefinitions.hpp"
+#include "utilities/powerOfTwo.hpp"
 
 // Basic error support
 
--- a/src/hotspot/share/utilities/globalDefinitions.hpp	Mon Feb 17 08:59:26 2020 +0100
+++ b/src/hotspot/share/utilities/globalDefinitions.hpp	Mon Feb 17 10:03:17 2020 +0100
@@ -988,16 +988,6 @@
   return MIN2(MAX2(value, min), max);
 }
 
-// true if x is a power of 2, false otherwise
-inline bool is_power_of_2(intptr_t x) {
-  return ((x != NoBits) && (mask_bits(x, x - 1) == NoBits));
-}
-
-// long version of is_power_of_2
-inline bool is_power_of_2_long(jlong x) {
-  return ((x != NoLongBits) && (mask_long_bits(x, x - 1) == NoLongBits));
-}
-
 // Returns largest i such that 2^i <= x.
 // If x == 0, the function returns -1.
 inline int log2_intptr(uintptr_t x) {
@@ -1051,18 +1041,6 @@
   return log2_long((julong)x);
 }
 
-//* the argument must be exactly a power of 2
-inline int exact_log2(intptr_t x) {
-  assert(is_power_of_2(x), "x must be a power of 2: " INTPTR_FORMAT, x);
-  return log2_intptr(x);
-}
-
-//* the argument must be exactly a power of 2
-inline int exact_log2_long(jlong x) {
-  assert(is_power_of_2_long(x), "x must be a power of 2: " JLONG_FORMAT, x);
-  return log2_long(x);
-}
-
 inline bool is_odd (intx x) { return x & 1;      }
 inline bool is_even(intx x) { return !is_odd(x); }
 
--- a/src/hotspot/share/utilities/powerOfTwo.hpp	Mon Feb 17 08:59:26 2020 +0100
+++ b/src/hotspot/share/utilities/powerOfTwo.hpp	Mon Feb 17 10:03:17 2020 +0100
@@ -28,13 +28,29 @@
 #include "metaprogramming/enableIf.hpp"
 #include "metaprogramming/isIntegral.hpp"
 #include "metaprogramming/isSigned.hpp"
-#include "utilities/align.hpp"
 #include "utilities/count_leading_zeros.hpp"
 #include "utilities/debug.hpp"
 #include "utilities/globalDefinitions.hpp"
 
 // Power of two convenience library.
 
+template <typename T>
+bool is_power_of_2(T x) {
+  return (x != T(0)) && ((x & (x - 1)) == T(0));
+}
+
+// Log2 of a power of 2
+inline int exact_log2(intptr_t x) {
+  assert(is_power_of_2(x), "x must be a power of 2: " INTPTR_FORMAT, x);
+  return log2_intptr(x);
+}
+
+// Log2 of a power of 2
+inline int exact_log2_long(jlong x) {
+  assert(is_power_of_2(x), "x must be a power of 2: " JLONG_FORMAT, x);
+  return log2_long(x);
+}
+
 // Round down to the closest power of two greater to or equal to the given
 // value.
 
@@ -69,7 +85,7 @@
   STATIC_ASSERT(IsIntegral<T>::value);
   STATIC_ASSERT(IsSigned<T>::value);
   assert(value > 0, "Invalid value");
-  if (is_power_of_2_t(value)) {
+  if (is_power_of_2(value)) {
     return value;
   }
   uint32_t lz = count_leading_zeros(value);
@@ -85,7 +101,7 @@
   STATIC_ASSERT(IsIntegral<T>::value);
   STATIC_ASSERT(!IsSigned<T>::value);
   assert(value != 0, "Invalid value");
-  if (is_power_of_2_t(value)) {
+  if (is_power_of_2(value)) {
     return value;
   }
   uint32_t lz = count_leading_zeros(value);
--- a/test/hotspot/gtest/gc/z/test_zForwarding.cpp	Mon Feb 17 08:59:26 2020 +0100
+++ b/test/hotspot/gtest/gc/z/test_zForwarding.cpp	Mon Feb 17 10:03:17 2020 +0100
@@ -40,10 +40,6 @@
 public:
   // Helper functions
 
-  static bool is_power_of_2(size_t value) {
-    return ::is_power_of_2((intptr_t)value);
-  }
-
   class SequenceToFromIndex : AllStatic {
   public:
     static uintptr_t even(size_t sequence_number) {
@@ -60,7 +56,7 @@
   // Test functions
 
   static void setup(ZForwarding* forwarding) {
-    EXPECT_PRED1(is_power_of_2, forwarding->_entries.length()) << CAPTURE(forwarding->_entries.length());
+    EXPECT_PRED1(is_power_of_2<size_t>, forwarding->_entries.length()) << CAPTURE(forwarding->_entries.length());
   }
 
   static void find_empty(ZForwarding* forwarding) {
--- a/test/hotspot/gtest/utilities/test_powerOfTwo.cpp	Mon Feb 17 08:59:26 2020 +0100
+++ b/test/hotspot/gtest/utilities/test_powerOfTwo.cpp	Mon Feb 17 10:03:17 2020 +0100
@@ -32,6 +32,40 @@
   return max_val - (max_val >> 1);
 }
 
+template <typename T> static void test_is_power_of_2() {
+  EXPECT_FALSE(is_power_of_2(T(0)));
+  EXPECT_FALSE(is_power_of_2(~T(0)));
+
+  // Test true
+  for (T i = max_pow2<T>(); i > 0; i = (i >> 1)) {
+    EXPECT_TRUE(is_power_of_2(i)) << "value = " << T(i);
+  }
+
+  // Test one less
+  for (T i = max_pow2<T>(); i > 2; i = (i >> 1)) {
+    EXPECT_FALSE(is_power_of_2(i - 1)) << "value = " << T(i - 1);
+  }
+
+  // Test one more
+  for (T i = max_pow2<T>(); i > 1; i = (i >> 1)) {
+    EXPECT_FALSE(is_power_of_2(i + 1)) << "value = " << T(i + 1);
+  }
+}
+
+TEST(power_of_2, is_power_of_2) {
+  test_is_power_of_2<int8_t>();
+  test_is_power_of_2<int16_t>();
+  test_is_power_of_2<int32_t>();
+  test_is_power_of_2<int64_t>();
+  test_is_power_of_2<int8_t>();
+  test_is_power_of_2<int16_t>();
+  test_is_power_of_2<int32_t>();
+  test_is_power_of_2<int64_t>();
+
+  test_is_power_of_2<jint>();
+  test_is_power_of_2<jlong>();
+}
+
 template <typename T> void round_up_power_of_2() {
   EXPECT_EQ(round_up_power_of_2(T(1)), T(1)) << "value = " << T(1);
   EXPECT_EQ(round_up_power_of_2(T(2)), T(2)) << "value = " << T(2);