Fixed power-of-2 predicates, excluding 0.
R=dslomov@chromium.org Review URL: https://codereview.chromium.org/219213003 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@20383 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
parent
4a5bccfc61
commit
4da732e321
@ -1293,7 +1293,7 @@ void LCodeGen::DoDivByPowerOf2I(LDivByPowerOf2I* instr) {
|
||||
Register dividend = ToRegister(instr->dividend());
|
||||
int32_t divisor = instr->divisor();
|
||||
Register result = ToRegister(instr->result());
|
||||
ASSERT(divisor == kMinInt || (divisor != 0 && IsPowerOf2(Abs(divisor))));
|
||||
ASSERT(divisor == kMinInt || IsPowerOf2(Abs(divisor)));
|
||||
ASSERT(!result.is(dividend));
|
||||
|
||||
// Check for (0 / -x) that will produce negative zero.
|
||||
|
@ -2636,7 +2636,7 @@ void LCodeGen::DoDivByPowerOf2I(LDivByPowerOf2I* instr) {
|
||||
Register dividend = ToRegister32(instr->dividend());
|
||||
int32_t divisor = instr->divisor();
|
||||
Register result = ToRegister32(instr->result());
|
||||
ASSERT(divisor == kMinInt || (divisor != 0 && IsPowerOf2(Abs(divisor))));
|
||||
ASSERT(divisor == kMinInt || IsPowerOf2(Abs(divisor)));
|
||||
ASSERT(!result.is(dividend));
|
||||
|
||||
// Check for (0 / -x) that will produce negative zero.
|
||||
|
@ -1513,12 +1513,9 @@ void MacroAssembler::Claim(uint64_t count, uint64_t unit_size) {
|
||||
|
||||
|
||||
void MacroAssembler::Claim(const Register& count, uint64_t unit_size) {
|
||||
if (unit_size == 0) return;
|
||||
ASSERT(IsPowerOf2(unit_size));
|
||||
|
||||
if (unit_size == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
const int shift = CountTrailingZeros(unit_size, kXRegSizeInBits);
|
||||
const Operand size(count, LSL, shift);
|
||||
|
||||
@ -1574,12 +1571,9 @@ void MacroAssembler::Drop(uint64_t count, uint64_t unit_size) {
|
||||
|
||||
|
||||
void MacroAssembler::Drop(const Register& count, uint64_t unit_size) {
|
||||
if (unit_size == 0) return;
|
||||
ASSERT(IsPowerOf2(unit_size));
|
||||
|
||||
if (unit_size == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
const int shift = CountTrailingZeros(unit_size, kXRegSizeInBits);
|
||||
const Operand size(count, LSL, shift);
|
||||
|
||||
|
@ -252,8 +252,8 @@ class MachOSection : public DebugSectionBase<MachOSectionHeader> {
|
||||
segment_(segment),
|
||||
align_(align),
|
||||
flags_(flags) {
|
||||
ASSERT(IsPowerOf2(align));
|
||||
if (align_ != 0) {
|
||||
ASSERT(IsPowerOf2(align));
|
||||
align_ = WhichPowerOf2(align_);
|
||||
}
|
||||
}
|
||||
|
@ -3761,7 +3761,7 @@ class HBinaryOperation : public HTemplateInstruction<3> {
|
||||
bool RightIsPowerOf2() {
|
||||
if (!right()->IsInteger32Constant()) return false;
|
||||
int32_t value = right()->GetInteger32Constant();
|
||||
return value != 0 && (IsPowerOf2(value) || IsPowerOf2(-value));
|
||||
return IsPowerOf2(value) || IsPowerOf2(-value);
|
||||
}
|
||||
|
||||
DECLARE_ABSTRACT_INSTRUCTION(BinaryOperation)
|
||||
|
@ -1493,7 +1493,7 @@ void LCodeGen::DoDivByPowerOf2I(LDivByPowerOf2I* instr) {
|
||||
Register dividend = ToRegister(instr->dividend());
|
||||
int32_t divisor = instr->divisor();
|
||||
Register result = ToRegister(instr->result());
|
||||
ASSERT(divisor == kMinInt || (divisor != 0 && IsPowerOf2(Abs(divisor))));
|
||||
ASSERT(divisor == kMinInt || IsPowerOf2(Abs(divisor)));
|
||||
ASSERT(!result.is(dividend));
|
||||
|
||||
// Check for (0 / -x) that will produce negative zero.
|
||||
|
@ -1174,7 +1174,7 @@ void LCodeGen::DoDivByPowerOf2I(LDivByPowerOf2I* instr) {
|
||||
Register dividend = ToRegister(instr->dividend());
|
||||
int32_t divisor = instr->divisor();
|
||||
Register result = ToRegister(instr->result());
|
||||
ASSERT(divisor == kMinInt || (divisor != 0 && IsPowerOf2(Abs(divisor))));
|
||||
ASSERT(divisor == kMinInt || IsPowerOf2(Abs(divisor)));
|
||||
ASSERT(!result.is(dividend));
|
||||
|
||||
// Check for (0 / -x) that will produce negative zero.
|
||||
|
@ -13914,7 +13914,7 @@ MaybeObject* HashTable<Shape, Key>::Allocate(Heap* heap,
|
||||
int at_least_space_for,
|
||||
MinimumCapacity capacity_option,
|
||||
PretenureFlag pretenure) {
|
||||
ASSERT(!capacity_option || IS_POWER_OF_TWO(at_least_space_for));
|
||||
ASSERT(!capacity_option || IsPowerOf2(at_least_space_for));
|
||||
int capacity = (capacity_option == USE_CUSTOM_MINIMUM_CAPACITY)
|
||||
? at_least_space_for
|
||||
: ComputeCapacity(at_least_space_for);
|
||||
|
@ -631,7 +631,7 @@ STATIC_ASSERT(
|
||||
// Use this mask to distinguish between cons and slice only after making
|
||||
// sure that the string is one of the two (an indirect string).
|
||||
const uint32_t kSlicedNotConsMask = kSlicedStringTag & ~kConsStringTag;
|
||||
STATIC_ASSERT(IS_POWER_OF_TWO(kSlicedNotConsMask) && kSlicedNotConsMask != 0);
|
||||
STATIC_ASSERT(IS_POWER_OF_TWO(kSlicedNotConsMask));
|
||||
|
||||
// If bit 7 is clear, then bit 3 indicates whether this two-byte
|
||||
// string actually contains one byte data.
|
||||
|
@ -43,10 +43,10 @@ namespace internal {
|
||||
// ----------------------------------------------------------------------------
|
||||
// General helper functions
|
||||
|
||||
#define IS_POWER_OF_TWO(x) (((x) & ((x) - 1)) == 0)
|
||||
#define IS_POWER_OF_TWO(x) ((x) != 0 && (((x) & ((x) - 1)) == 0))
|
||||
|
||||
// Returns true iff x is a power of 2 (or zero). Cannot be used with the
|
||||
// maximally negative value of the type T (the -1 overflows).
|
||||
// Returns true iff x is a power of 2. Cannot be used with the maximally
|
||||
// negative value of the type T (the -1 overflows).
|
||||
template <typename T>
|
||||
inline bool IsPowerOf2(T x) {
|
||||
return IS_POWER_OF_TWO(x);
|
||||
@ -56,7 +56,6 @@ inline bool IsPowerOf2(T x) {
|
||||
// X must be a power of 2. Returns the number of trailing zeros.
|
||||
inline int WhichPowerOf2(uint32_t x) {
|
||||
ASSERT(IsPowerOf2(x));
|
||||
ASSERT(x != 0);
|
||||
int bits = 0;
|
||||
#ifdef DEBUG
|
||||
int original_x = x;
|
||||
|
@ -1209,7 +1209,7 @@ void LCodeGen::DoDivByPowerOf2I(LDivByPowerOf2I* instr) {
|
||||
Register dividend = ToRegister(instr->dividend());
|
||||
int32_t divisor = instr->divisor();
|
||||
Register result = ToRegister(instr->result());
|
||||
ASSERT(divisor == kMinInt || (divisor != 0 && IsPowerOf2(Abs(divisor))));
|
||||
ASSERT(divisor == kMinInt || IsPowerOf2(Abs(divisor)));
|
||||
ASSERT(!result.is(dividend));
|
||||
|
||||
// Check for (0 / -x) that will produce negative zero.
|
||||
|
Loading…
Reference in New Issue
Block a user