Revision: 20383
Author: [email protected]
Date: Tue Apr 1 09:20:28 2014 UTC
Log: Fixed power-of-2 predicates, excluding 0.
[email protected]
Review URL: https://codereview.chromium.org/219213003
http://code.google.com/p/v8/source/detail?r=20383
Modified:
/branches/bleeding_edge/src/arm/lithium-codegen-arm.cc
/branches/bleeding_edge/src/arm64/lithium-codegen-arm64.cc
/branches/bleeding_edge/src/arm64/macro-assembler-arm64-inl.h
/branches/bleeding_edge/src/gdb-jit.cc
/branches/bleeding_edge/src/hydrogen-instructions.h
/branches/bleeding_edge/src/ia32/lithium-codegen-ia32.cc
/branches/bleeding_edge/src/mips/lithium-codegen-mips.cc
/branches/bleeding_edge/src/objects.cc
/branches/bleeding_edge/src/objects.h
/branches/bleeding_edge/src/utils.h
/branches/bleeding_edge/src/x64/lithium-codegen-x64.cc
=======================================
--- /branches/bleeding_edge/src/arm/lithium-codegen-arm.cc Mon Mar 31
15:14:28 2014 UTC
+++ /branches/bleeding_edge/src/arm/lithium-codegen-arm.cc Tue Apr 1
09:20:28 2014 UTC
@@ -1293,7 +1293,7 @@
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.
=======================================
--- /branches/bleeding_edge/src/arm64/lithium-codegen-arm64.cc Mon Mar 31
14:21:04 2014 UTC
+++ /branches/bleeding_edge/src/arm64/lithium-codegen-arm64.cc Tue Apr 1
09:20:28 2014 UTC
@@ -2636,7 +2636,7 @@
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.
=======================================
--- /branches/bleeding_edge/src/arm64/macro-assembler-arm64-inl.h Mon Mar
31 14:06:42 2014 UTC
+++ /branches/bleeding_edge/src/arm64/macro-assembler-arm64-inl.h Tue Apr
1 09:20:28 2014 UTC
@@ -1513,12 +1513,9 @@
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(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);
=======================================
--- /branches/bleeding_edge/src/gdb-jit.cc Mon Dec 9 07:41:20 2013 UTC
+++ /branches/bleeding_edge/src/gdb-jit.cc Tue Apr 1 09:20:28 2014 UTC
@@ -252,8 +252,8 @@
segment_(segment),
align_(align),
flags_(flags) {
- ASSERT(IsPowerOf2(align));
if (align_ != 0) {
+ ASSERT(IsPowerOf2(align));
align_ = WhichPowerOf2(align_);
}
}
=======================================
--- /branches/bleeding_edge/src/hydrogen-instructions.h Mon Mar 31 14:21:04
2014 UTC
+++ /branches/bleeding_edge/src/hydrogen-instructions.h Tue Apr 1 09:20:28
2014 UTC
@@ -3761,7 +3761,7 @@
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)
=======================================
--- /branches/bleeding_edge/src/ia32/lithium-codegen-ia32.cc Mon Mar 31
14:21:04 2014 UTC
+++ /branches/bleeding_edge/src/ia32/lithium-codegen-ia32.cc Tue Apr 1
09:20:28 2014 UTC
@@ -1493,7 +1493,7 @@
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.
=======================================
--- /branches/bleeding_edge/src/mips/lithium-codegen-mips.cc Mon Mar 31
22:50:53 2014 UTC
+++ /branches/bleeding_edge/src/mips/lithium-codegen-mips.cc Tue Apr 1
09:20:28 2014 UTC
@@ -1174,7 +1174,7 @@
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.
=======================================
--- /branches/bleeding_edge/src/objects.cc Mon Mar 31 15:30:13 2014 UTC
+++ /branches/bleeding_edge/src/objects.cc Tue Apr 1 09:20:28 2014 UTC
@@ -13914,7 +13914,7 @@
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);
=======================================
--- /branches/bleeding_edge/src/objects.h Tue Apr 1 08:57:48 2014 UTC
+++ /branches/bleeding_edge/src/objects.h Tue Apr 1 09:20:28 2014 UTC
@@ -631,7 +631,7 @@
// 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.
=======================================
--- /branches/bleeding_edge/src/utils.h Mon Mar 10 10:39:17 2014 UTC
+++ /branches/bleeding_edge/src/utils.h Tue Apr 1 09:20:28 2014 UTC
@@ -43,10 +43,10 @@
//
----------------------------------------------------------------------------
// 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 @@
// 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;
=======================================
--- /branches/bleeding_edge/src/x64/lithium-codegen-x64.cc Mon Mar 31
14:21:04 2014 UTC
+++ /branches/bleeding_edge/src/x64/lithium-codegen-x64.cc Tue Apr 1
09:20:28 2014 UTC
@@ -1209,7 +1209,7 @@
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.
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.