8183574: Unify the is_power_of_2 functions
Reviewed-by: kbarrett, redestad
This commit is contained in:
parent
248b61710e
commit
e4b27a48a0
src/hotspot
cpu
aarch64
c1_LIRAssembler_aarch64.cppc1_LIRGenerator_aarch64.cppc1_Runtime1_aarch64.cppinterp_masm_aarch64.cppmacroAssembler_aarch64.cppmacroAssembler_aarch64.hppstubGenerator_aarch64.cpptemplateInterpreterGenerator_aarch64.cpptemplateTable_aarch64.cpp
arm
c1_LIRAssembler_arm.cppc1_LIRGenerator_arm.cppc1_MacroAssembler_arm.cppinterp_masm_arm.cppmacroAssembler_arm.cppmacroAssembler_arm.hppsharedRuntime_arm.cppstubGenerator_arm.cpptemplateTable_arm.cpp
ppc
assembler_ppc.cppc1_LIRAssembler_ppc.cppc1_LIRGenerator_ppc.cppc1_MacroAssembler_ppc.cppc1_Runtime1_ppc.cppinterp_masm_ppc_64.cppmacroAssembler_ppc.cppmacroAssembler_ppc.inline.hppppc.adstubGenerator_ppc.cpptemplateTable_ppc_64.cppvm_version_ppc.cpp
s390
c1_LIRAssembler_s390.cppc1_LIRGenerator_s390.cppc1_Runtime1_s390.cppinterp_masm_s390.cppmacroAssembler_s390.cppstubGenerator_s390.cpptemplateTable_s390.cpp
sparc
x86
os/linux
share
adlc
aot
asm
c1
ci
code
gc
g1
parallel
shared
shenandoah
z
memory
oops
opto
arraycopynode.cppblock.hppcallnode.cppdivnode.cppgraphKit.cpplibrary_call.cpploopnode.cppmacro.cppmacroArrayCopy.cppmemnode.cppmulnode.cppoutput.cppregmask.cppsuperword.cpptype.cppvectornode.cpp
runtime
utilities
test/hotspot/gtest
@ -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 @@ void LIR_Assembler::arith_op(LIR_Code code, LIR_Opr left, LIR_Opr right, LIR_Opr
|
||||
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 @@ void LIR_Assembler::arith_op(LIR_Code code, LIR_Opr left, LIR_Opr right, LIR_Opr
|
||||
}
|
||||
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);
|
||||
|
@ -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 @@ void LIRGenerator::do_ArithmeticOp_Long(ArithmeticOp* x) {
|
||||
// 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();
|
||||
|
@ -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"
|
||||
|
||||
|
||||
|
@ -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) {
|
||||
|
||||
|
@ -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
|
||||
|
@ -28,6 +28,7 @@
|
||||
|
||||
#include "asm/assembler.hpp"
|
||||
#include "oops/compressedOops.hpp"
|
||||
#include "utilities/powerOfTwo.hpp"
|
||||
|
||||
// MacroAssembler extends Assembler by frequently used macros.
|
||||
//
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -40,6 +40,7 @@
|
||||
#include "runtime/sharedRuntime.hpp"
|
||||
#include "runtime/stubRoutines.hpp"
|
||||
#include "runtime/synchronizer.hpp"
|
||||
#include "utilities/powerOfTwo.hpp"
|
||||
|
||||
#define __ _masm->
|
||||
|
||||
|
@ -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->
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -44,6 +44,7 @@
|
||||
#include "runtime/frame.inline.hpp"
|
||||
#include "runtime/safepointMechanism.hpp"
|
||||
#include "runtime/sharedRuntime.hpp"
|
||||
#include "utilities/powerOfTwo.hpp"
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// Implementation of InterpreterMacroAssembler
|
||||
|
@ -46,6 +46,7 @@
|
||||
#include "runtime/sharedRuntime.hpp"
|
||||
#include "runtime/stubRoutines.hpp"
|
||||
#include "utilities/macros.hpp"
|
||||
#include "utilities/powerOfTwo.hpp"
|
||||
|
||||
// Implementation of AddressLiteral
|
||||
|
||||
|
@ -26,6 +26,7 @@
|
||||
#define CPU_ARM_MACROASSEMBLER_ARM_HPP
|
||||
|
||||
#include "code/relocInfo.hpp"
|
||||
#include "utilities/powerOfTwo.hpp"
|
||||
|
||||
class BiasedLockingCounters;
|
||||
|
||||
|
@ -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"
|
||||
|
@ -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
|
||||
|
@ -39,6 +39,7 @@
|
||||
#include "runtime/sharedRuntime.hpp"
|
||||
#include "runtime/stubRoutines.hpp"
|
||||
#include "runtime/synchronizer.hpp"
|
||||
#include "utilities/powerOfTwo.hpp"
|
||||
|
||||
#define __ _masm->
|
||||
|
||||
|
@ -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 @@ int Assembler::branch_destination(int inst, int pos) {
|
||||
|
||||
// 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 {
|
||||
|
@ -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 @@ void LIR_Assembler::logic_op(LIR_Code code, LIR_Opr left, LIR_Opr right, LIR_Opr
|
||||
|
||||
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); }
|
||||
|
@ -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 @@ inline bool can_handle_logic_op_as_uimm(ValueType *type, Bytecodes::Code bc) {
|
||||
|
||||
// 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) &&
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -34,6 +34,7 @@
|
||||
#include "runtime/frame.inline.hpp"
|
||||
#include "runtime/safepointMechanism.hpp"
|
||||
#include "runtime/sharedRuntime.hpp"
|
||||
#include "utilities/powerOfTwo.hpp"
|
||||
|
||||
// Implementation of InterpreterMacroAssembler.
|
||||
|
||||
|
@ -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
|
||||
|
@ -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 int MacroAssembler::get_ld_largeoffset_offset(address a) {
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
|
@ -4350,7 +4350,7 @@ operand immIhi16() %{
|
||||
%}
|
||||
|
||||
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 immInegpow2() %{
|
||||
%}
|
||||
|
||||
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 immIpow2minus1() %{
|
||||
%}
|
||||
|
||||
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 immLhighest16() %{
|
||||
%}
|
||||
|
||||
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 immLnegpow2() %{
|
||||
%}
|
||||
|
||||
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);
|
||||
|
@ -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
|
||||
|
@ -42,6 +42,7 @@
|
||||
#include "runtime/stubRoutines.hpp"
|
||||
#include "runtime/synchronizer.hpp"
|
||||
#include "utilities/macros.hpp"
|
||||
#include "utilities/powerOfTwo.hpp"
|
||||
|
||||
#undef __
|
||||
#define __ _masm->
|
||||
|
@ -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)
|
||||
|
@ -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 @@ void LIR_Assembler::arithmetic_idiv(LIR_Code code, LIR_Opr left, LIR_Opr right,
|
||||
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");
|
||||
|
||||
|
@ -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__)->
|
||||
|
@ -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
|
||||
|
||||
|
@ -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.
|
||||
|
@ -55,6 +55,7 @@
|
||||
#include "runtime/stubRoutines.hpp"
|
||||
#include "utilities/events.hpp"
|
||||
#include "utilities/macros.hpp"
|
||||
#include "utilities/powerOfTwo.hpp"
|
||||
|
||||
#include <ucontext.h>
|
||||
|
||||
|
@ -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
|
||||
|
@ -39,6 +39,7 @@
|
||||
#include "runtime/sharedRuntime.hpp"
|
||||
#include "runtime/stubRoutines.hpp"
|
||||
#include "runtime/synchronizer.hpp"
|
||||
#include "utilities/powerOfTwo.hpp"
|
||||
|
||||
#ifdef PRODUCT
|
||||
#define __ _masm->
|
||||
|
@ -40,6 +40,7 @@
|
||||
#include "runtime/jniHandles.inline.hpp"
|
||||
#include "runtime/safepointMechanism.inline.hpp"
|
||||
#include "runtime/sharedRuntime.hpp"
|
||||
#include "utilities/powerOfTwo.hpp"
|
||||
|
||||
#define __ _masm->
|
||||
|
||||
|
@ -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
|
||||
|
@ -42,6 +42,7 @@
|
||||
#include "runtime/sharedRuntime.hpp"
|
||||
#include "runtime/thread.inline.hpp"
|
||||
#include "utilities/align.hpp"
|
||||
#include "utilities/powerOfTwo.hpp"
|
||||
|
||||
// Implementation of InterpreterMacroAssembler
|
||||
|
||||
|
@ -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
|
||||
|
@ -27,6 +27,7 @@
|
||||
|
||||
#include "asm/register.hpp"
|
||||
#include "runtime/vm_version.hpp"
|
||||
#include "utilities/powerOfTwo.hpp"
|
||||
|
||||
class BiasedLockingCounters;
|
||||
|
||||
|
@ -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"
|
||||
|
||||
|
||||
|
@ -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
|
||||
|
@ -39,6 +39,7 @@
|
||||
#include "runtime/safepointMechanism.hpp"
|
||||
#include "runtime/sharedRuntime.hpp"
|
||||
#include "runtime/thread.inline.hpp"
|
||||
#include "utilities/powerOfTwo.hpp"
|
||||
|
||||
// Implementation of InterpreterMacroAssembler
|
||||
|
||||
|
@ -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)
|
||||
|
@ -3120,7 +3120,7 @@ operand immL32()
|
||||
|
||||
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_Pow2()
|
||||
|
||||
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);
|
||||
|
@ -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
|
||||
|
@ -233,6 +233,7 @@ int main(int argc, char *argv[])
|
||||
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 @@ int main(int argc, char *argv[])
|
||||
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:
|
||||
|
@ -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;
|
||||
|
@ -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:
|
||||
|
@ -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:
|
||||
|
@ -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__)->
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include "oops/objArrayOop.inline.hpp"
|
||||
#include "oops/oop.inline.hpp"
|
||||
#include "oops/typeArrayOop.inline.hpp"
|
||||
#include "utilities/powerOfTwo.hpp"
|
||||
|
||||
// ciArray
|
||||
//
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include "code/codeHeapState.hpp"
|
||||
#include "compiler/compileBroker.hpp"
|
||||
#include "runtime/sweeper.hpp"
|
||||
#include "utilities/powerOfTwo.hpp"
|
||||
|
||||
// -------------------------
|
||||
// | General Description |
|
||||
|
@ -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 @@ void VtableStubs::initialize() {
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
@ -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.
|
||||
|
@ -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),
|
||||
|
@ -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,
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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
|
||||
|
@ -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) {}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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();
|
||||
|
@ -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>
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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),
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "gc/z/zMarkStackAllocator.hpp"
|
||||
#include "logging/log.hpp"
|
||||
#include "utilities/debug.hpp"
|
||||
#include "utilities/powerOfTwo.hpp"
|
||||
|
||||
ZMarkStripe::ZMarkStripe() :
|
||||
_published(),
|
||||
|
@ -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;
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include "logging/log.hpp"
|
||||
#include "runtime/globals.hpp"
|
||||
#include "utilities/debug.hpp"
|
||||
#include "utilities/powerOfTwo.hpp"
|
||||
|
||||
ZRelocationSetSelectorGroupStats::ZRelocationSetSelectorGroupStats() :
|
||||
_npages(0),
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include "memory/allocation.hpp"
|
||||
#include "runtime/globals.hpp"
|
||||
#include "utilities/globalDefinitions.hpp"
|
||||
#include "utilities/powerOfTwo.hpp"
|
||||
|
||||
#include <new>
|
||||
|
||||
|
@ -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);
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include "runtime/os.inline.hpp"
|
||||
#include "services/memTracker.hpp"
|
||||
#include "utilities/align.hpp"
|
||||
#include "utilities/powerOfTwo.hpp"
|
||||
|
||||
// ReservedSpace
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -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),
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include "opto/multnode.hpp"
|
||||
#include "opto/node.hpp"
|
||||
#include "opto/phase.hpp"
|
||||
#include "utilities/powerOfTwo.hpp"
|
||||
|
||||
// Optimization - Graph Style
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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 @@ static Node *transform_long_divide( PhaseGVN *phase, Node *dividend, jlong divis
|
||||
// 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 @@ static Node *transform_long_divide( PhaseGVN *phase, Node *dividend, jlong divis
|
||||
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 *ModLNode::Ideal(PhaseGVN *phase, bool can_reshape) {
|
||||
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 @@ Node *ModLNode::Ideal(PhaseGVN *phase, bool can_reshape) {
|
||||
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));
|
||||
|
@ -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.
|
||||
|
@ -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:
|
||||
|
@ -40,6 +40,7 @@
|
||||
#include "opto/mulnode.hpp"
|
||||
#include "opto/rootnode.hpp"
|
||||
#include "opto/superword.hpp"
|
||||
#include "utilities/powerOfTwo.hpp"
|
||||
|
||||
//=============================================================================
|
||||
//--------------------------is_cloop_ind_var-----------------------------------
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
|
@ -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 *MulLNode::Ideal(PhaseGVN *phase, bool can_reshape) {
|
||||
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 @@ const Type* FmaFNode::Value(PhaseGVN* phase) const {
|
||||
uint MulAddS2INode::hash() const {
|
||||
return (uintptr_t)in(1) + (uintptr_t)in(2) + (uintptr_t)in(3) + (uintptr_t)in(4) + Opcode();
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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 */
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "memory/allocation.inline.hpp"
|
||||
#include "opto/connode.hpp"
|
||||
#include "opto/vectornode.hpp"
|
||||
#include "utilities/powerOfTwo.hpp"
|
||||
|
||||
//------------------------------VectorNode--------------------------------------
|
||||
|
||||
|
@ -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"
|
||||
|
@ -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)) {
|
||||
|
@ -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)) {
|
||||
|
@ -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 @@ inline T align_up(T size, A alignment) {
|
||||
|
||||
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 @@ inline T align_down(T size, A alignment) {
|
||||
|
||||
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);
|
||||
}
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include "runtime/os.hpp"
|
||||
#include "runtime/signature.hpp"
|
||||
#include "utilities/globalDefinitions.hpp"
|
||||
#include "utilities/powerOfTwo.hpp"
|
||||
|
||||
// Basic error support
|
||||
|
||||
|
@ -988,16 +988,6 @@ inline T clamp(T value, T min, T max) {
|
||||
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 @@ inline int log2_jlong(jlong x) {
|
||||
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); }
|
||||
|
||||
|
@ -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 @@ inline typename EnableIf<IsSigned<T>::value, T>::type round_up_power_of_2(T valu
|
||||
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 @@ inline typename EnableIf<!IsSigned<T>::value, T>::type round_up_power_of_2(T val
|
||||
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);
|
||||
|
@ -40,10 +40,6 @@ class ZForwardingTest : public Test {
|
||||
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 @@ public:
|
||||
// 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) {
|
||||
|
@ -32,6 +32,40 @@ template <typename T> T max_pow2() {
|
||||
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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user