Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(13)

Unified Diff: src/utils.h

Issue 430503007: Rename ASSERT* to DCHECK*. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: REBASE and fixes Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/uri.h ('k') | src/utils.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/utils.h
diff --git a/src/utils.h b/src/utils.h
index d7967e7f0e20a49c4768ce9cedff3c5e9ad65581..d9e0e4c33e391ebb9120d95ee1aa2906076546a1 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -27,7 +27,7 @@ namespace internal {
// X must be a power of 2. Returns the number of trailing zeros.
inline int WhichPowerOf2(uint32_t x) {
- ASSERT(IsPowerOf2(x));
+ DCHECK(IsPowerOf2(x));
int bits = 0;
#ifdef DEBUG
int original_x = x;
@@ -51,7 +51,7 @@ inline int WhichPowerOf2(uint32_t x) {
case 2: bits++; // Fall through.
case 1: break;
}
- ASSERT_EQ(1 << bits, original_x);
+ DCHECK_EQ(1 << bits, original_x);
return bits;
return 0;
}
@@ -201,7 +201,7 @@ class BitFieldBase {
// Returns a type U with the bit field value encoded.
static U encode(T value) {
- ASSERT(is_valid(value));
+ DCHECK(is_valid(value));
return static_cast<U>(value) << shift;
}
@@ -368,7 +368,7 @@ class Access {
explicit Access(StaticResource<T>* resource)
: resource_(resource)
, instance_(&resource->instance_) {
- ASSERT(!resource->is_reserved_);
+ DCHECK(!resource->is_reserved_);
resource->is_reserved_ = true;
}
@@ -396,12 +396,12 @@ class SetOncePointer {
bool is_set() const { return pointer_ != NULL; }
T* get() const {
- ASSERT(pointer_ != NULL);
+ DCHECK(pointer_ != NULL);
return pointer_;
}
void set(T* value) {
- ASSERT(pointer_ == NULL && value != NULL);
+ DCHECK(pointer_ == NULL && value != NULL);
pointer_ = value;
}
@@ -481,7 +481,7 @@ class Collector {
// A basic Collector will keep this vector valid as long as the Collector
// is alive.
inline Vector<T> AddBlock(int size, T initial_value) {
- ASSERT(size > 0);
+ DCHECK(size > 0);
if (size > current_chunk_.length() - index_) {
Grow(size);
}
@@ -515,7 +515,7 @@ class Collector {
// Write the contents of the collector into the provided vector.
void WriteTo(Vector<T> destination) {
- ASSERT(size_ <= destination.length());
+ DCHECK(size_ <= destination.length());
int position = 0;
for (int i = 0; i < chunks_.length(); i++) {
Vector<T> chunk = chunks_.at(i);
@@ -555,7 +555,7 @@ class Collector {
// Creates a new current chunk, and stores the old chunk in the chunks_ list.
void Grow(int min_capacity) {
- ASSERT(growth_factor > 1);
+ DCHECK(growth_factor > 1);
int new_capacity;
int current_length = current_chunk_.length();
if (current_length < kMinCapacity) {
@@ -573,7 +573,7 @@ class Collector {
}
}
NewChunk(new_capacity);
- ASSERT(index_ + min_capacity <= current_chunk_.length());
+ DCHECK(index_ + min_capacity <= current_chunk_.length());
}
// Before replacing the current chunk, give a subclass the option to move
@@ -612,12 +612,12 @@ class SequenceCollector : public Collector<T, growth_factor, max_growth> {
virtual ~SequenceCollector() {}
void StartSequence() {
- ASSERT(sequence_start_ == kNoSequence);
+ DCHECK(sequence_start_ == kNoSequence);
sequence_start_ = this->index_;
}
Vector<T> EndSequence() {
- ASSERT(sequence_start_ != kNoSequence);
+ DCHECK(sequence_start_ != kNoSequence);
int sequence_start = sequence_start_;
sequence_start_ = kNoSequence;
if (sequence_start == this->index_) return Vector<T>();
@@ -626,7 +626,7 @@ class SequenceCollector : public Collector<T, growth_factor, max_growth> {
// Drops the currently added sequence, and all collected elements in it.
void DropSequence() {
- ASSERT(sequence_start_ != kNoSequence);
+ DCHECK(sequence_start_ != kNoSequence);
int sequence_length = this->index_ - sequence_start_;
this->index_ = sequence_start_;
this->size_ -= sequence_length;
@@ -651,7 +651,7 @@ class SequenceCollector : public Collector<T, growth_factor, max_growth> {
}
int sequence_length = this->index_ - sequence_start_;
Vector<T> new_chunk = Vector<T>::New(sequence_length + new_capacity);
- ASSERT(sequence_length < new_chunk.length());
+ DCHECK(sequence_length < new_chunk.length());
for (int i = 0; i < sequence_length; i++) {
new_chunk[i] = this->current_chunk_[sequence_start_ + i];
}
@@ -698,8 +698,8 @@ inline int CompareCharsUnsigned(const lchar* lhs,
template<typename lchar, typename rchar>
inline int CompareChars(const lchar* lhs, const rchar* rhs, int chars) {
- ASSERT(sizeof(lchar) <= 2);
- ASSERT(sizeof(rchar) <= 2);
+ DCHECK(sizeof(lchar) <= 2);
+ DCHECK(sizeof(rchar) <= 2);
if (sizeof(lchar) == 1) {
if (sizeof(rchar) == 1) {
return CompareCharsUnsigned(reinterpret_cast<const uint8_t*>(lhs),
@@ -726,8 +726,8 @@ inline int CompareChars(const lchar* lhs, const rchar* rhs, int chars) {
// Calculate 10^exponent.
inline int TenToThe(int exponent) {
- ASSERT(exponent <= 9);
- ASSERT(exponent >= 1);
+ DCHECK(exponent <= 9);
+ DCHECK(exponent >= 1);
int answer = 10;
for (int i = 1; i < exponent; i++) answer *= 10;
return answer;
@@ -797,11 +797,11 @@ class EmbeddedContainer {
int length() const { return NumElements; }
const ElementType& operator[](int i) const {
- ASSERT(i < length());
+ DCHECK(i < length());
return elems_[i];
}
ElementType& operator[](int i) {
- ASSERT(i < length());
+ DCHECK(i < length());
return elems_[i];
}
@@ -847,7 +847,7 @@ class SimpleStringBuilder {
// Get the current position in the builder.
int position() const {
- ASSERT(!is_finalized());
+ DCHECK(!is_finalized());
return position_;
}
@@ -858,8 +858,8 @@ class SimpleStringBuilder {
// 0-characters; use the Finalize() method to terminate the string
// instead.
void AddCharacter(char c) {
- ASSERT(c != '\0');
- ASSERT(!is_finalized() && position_ < buffer_.length());
+ DCHECK(c != '\0');
+ DCHECK(!is_finalized() && position_ < buffer_.length());
buffer_[position_++] = c;
}
@@ -918,9 +918,9 @@ class EnumSet {
private:
T Mask(E element) const {
- // The strange typing in ASSERT is necessary to avoid stupid warnings, see:
+ // The strange typing in DCHECK is necessary to avoid stupid warnings, see:
// http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43680
- ASSERT(static_cast<int>(element) < static_cast<int>(sizeof(T) * CHAR_BIT));
+ DCHECK(static_cast<int>(element) < static_cast<int>(sizeof(T) * CHAR_BIT));
return static_cast<T>(1) << element;
}
@@ -947,19 +947,19 @@ inline int signed_bitextract_64(int msb, int lsb, int x) {
// Check number width.
inline bool is_intn(int64_t x, unsigned n) {
- ASSERT((0 < n) && (n < 64));
+ DCHECK((0 < n) && (n < 64));
int64_t limit = static_cast<int64_t>(1) << (n - 1);
return (-limit <= x) && (x < limit);
}
inline bool is_uintn(int64_t x, unsigned n) {
- ASSERT((0 < n) && (n < (sizeof(x) * kBitsPerByte)));
+ DCHECK((0 < n) && (n < (sizeof(x) * kBitsPerByte)));
return !(x >> n);
}
template <class T>
inline T truncate_to_intn(T x, unsigned n) {
- ASSERT((0 < n) && (n < (sizeof(x) * kBitsPerByte)));
+ DCHECK((0 < n) && (n < (sizeof(x) * kBitsPerByte)));
return (x & ((static_cast<T>(1) << n) - 1));
}
@@ -1165,9 +1165,9 @@ inline void CopyWords(T* dst, const T* src, size_t num_words) {
// TODO(mvstanton): disabled because mac builds are bogus failing on this
// assert. They are doing a signed comparison. Investigate in
// the morning.
- // ASSERT(Min(dst, const_cast<T*>(src)) + num_words <=
+ // DCHECK(Min(dst, const_cast<T*>(src)) + num_words <=
// Max(dst, const_cast<T*>(src)));
- ASSERT(num_words > 0);
+ DCHECK(num_words > 0);
// Use block copying MemCopy if the segment we're copying is
// enough to justify the extra call/setup overhead.
@@ -1188,7 +1188,7 @@ inline void CopyWords(T* dst, const T* src, size_t num_words) {
template <typename T>
inline void MoveWords(T* dst, const T* src, size_t num_words) {
STATIC_ASSERT(sizeof(T) == kPointerSize);
- ASSERT(num_words > 0);
+ DCHECK(num_words > 0);
// Use block copying MemCopy if the segment we're copying is
// enough to justify the extra call/setup overhead.
@@ -1211,7 +1211,7 @@ inline void MoveWords(T* dst, const T* src, size_t num_words) {
template <typename T>
inline void CopyBytes(T* dst, const T* src, size_t num_bytes) {
STATIC_ASSERT(sizeof(T) == 1);
- ASSERT(Min(dst, const_cast<T*>(src)) + num_bytes <=
+ DCHECK(Min(dst, const_cast<T*>(src)) + num_bytes <=
Max(dst, const_cast<T*>(src)));
if (num_bytes == 0) return;
@@ -1322,8 +1322,8 @@ INLINE(void CopyChars(sinkchar* dest, const sourcechar* src, int chars));
template<typename sourcechar, typename sinkchar>
void CopyChars(sinkchar* dest, const sourcechar* src, int chars) {
- ASSERT(sizeof(sourcechar) <= 2);
- ASSERT(sizeof(sinkchar) <= 2);
+ DCHECK(sizeof(sourcechar) <= 2);
+ DCHECK(sizeof(sinkchar) <= 2);
if (sizeof(sinkchar) == 1) {
if (sizeof(sourcechar) == 1) {
CopyCharsUnsigned(reinterpret_cast<uint8_t*>(dest),
@@ -1358,7 +1358,7 @@ void CopyCharsUnsigned(sinkchar* dest, const sourcechar* src, int chars) {
}
// Number of characters in a uintptr_t.
static const int kStepSize = sizeof(uintptr_t) / sizeof(*dest); // NOLINT
- ASSERT(dest + kStepSize > dest); // Check for overflow.
+ DCHECK(dest + kStepSize > dest); // Check for overflow.
while (dest + kStepSize <= limit) {
*reinterpret_cast<uintptr_t*>(dest) =
*reinterpret_cast<const uintptr_t*>(src);
« no previous file with comments | « src/uri.h ('k') | src/utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698