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

Side by Side Diff: src/data-flow.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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/d8.cc ('k') | src/date.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_DATAFLOW_H_ 5 #ifndef V8_DATAFLOW_H_
6 #define V8_DATAFLOW_H_ 6 #define V8_DATAFLOW_H_
7 7
8 #include "src/v8.h" 8 #include "src/v8.h"
9 9
10 #include "src/allocation.h" 10 #include "src/allocation.h"
11 #include "src/ast.h" 11 #include "src/ast.h"
12 #include "src/compiler.h" 12 #include "src/compiler.h"
13 #include "src/zone-inl.h" 13 #include "src/zone-inl.h"
14 14
15 namespace v8 { 15 namespace v8 {
16 namespace internal { 16 namespace internal {
17 17
18 class BitVector: public ZoneObject { 18 class BitVector: public ZoneObject {
19 public: 19 public:
20 // Iterator for the elements of this BitVector. 20 // Iterator for the elements of this BitVector.
21 class Iterator BASE_EMBEDDED { 21 class Iterator BASE_EMBEDDED {
22 public: 22 public:
23 explicit Iterator(BitVector* target) 23 explicit Iterator(BitVector* target)
24 : target_(target), 24 : target_(target),
25 current_index_(0), 25 current_index_(0),
26 current_value_(target->data_[0]), 26 current_value_(target->data_[0]),
27 current_(-1) { 27 current_(-1) {
28 ASSERT(target->data_length_ > 0); 28 DCHECK(target->data_length_ > 0);
29 Advance(); 29 Advance();
30 } 30 }
31 ~Iterator() { } 31 ~Iterator() { }
32 32
33 bool Done() const { return current_index_ >= target_->data_length_; } 33 bool Done() const { return current_index_ >= target_->data_length_; }
34 void Advance(); 34 void Advance();
35 35
36 int Current() const { 36 int Current() const {
37 ASSERT(!Done()); 37 DCHECK(!Done());
38 return current_; 38 return current_;
39 } 39 }
40 40
41 private: 41 private:
42 uint32_t SkipZeroBytes(uint32_t val) { 42 uint32_t SkipZeroBytes(uint32_t val) {
43 while ((val & 0xFF) == 0) { 43 while ((val & 0xFF) == 0) {
44 val >>= 8; 44 val >>= 8;
45 current_ += 8; 45 current_ += 8;
46 } 46 }
47 return val; 47 return val;
(...skipping 11 matching lines...) Expand all
59 uint32_t current_value_; 59 uint32_t current_value_;
60 int current_; 60 int current_;
61 61
62 friend class BitVector; 62 friend class BitVector;
63 }; 63 };
64 64
65 BitVector(int length, Zone* zone) 65 BitVector(int length, Zone* zone)
66 : length_(length), 66 : length_(length),
67 data_length_(SizeFor(length)), 67 data_length_(SizeFor(length)),
68 data_(zone->NewArray<uint32_t>(data_length_)) { 68 data_(zone->NewArray<uint32_t>(data_length_)) {
69 ASSERT(length > 0); 69 DCHECK(length > 0);
70 Clear(); 70 Clear();
71 } 71 }
72 72
73 BitVector(const BitVector& other, Zone* zone) 73 BitVector(const BitVector& other, Zone* zone)
74 : length_(other.length()), 74 : length_(other.length()),
75 data_length_(SizeFor(length_)), 75 data_length_(SizeFor(length_)),
76 data_(zone->NewArray<uint32_t>(data_length_)) { 76 data_(zone->NewArray<uint32_t>(data_length_)) {
77 CopyFrom(other); 77 CopyFrom(other);
78 } 78 }
79 79
80 static int SizeFor(int length) { 80 static int SizeFor(int length) {
81 return 1 + ((length - 1) / 32); 81 return 1 + ((length - 1) / 32);
82 } 82 }
83 83
84 BitVector& operator=(const BitVector& rhs) { 84 BitVector& operator=(const BitVector& rhs) {
85 if (this != &rhs) CopyFrom(rhs); 85 if (this != &rhs) CopyFrom(rhs);
86 return *this; 86 return *this;
87 } 87 }
88 88
89 void CopyFrom(const BitVector& other) { 89 void CopyFrom(const BitVector& other) {
90 ASSERT(other.length() <= length()); 90 DCHECK(other.length() <= length());
91 for (int i = 0; i < other.data_length_; i++) { 91 for (int i = 0; i < other.data_length_; i++) {
92 data_[i] = other.data_[i]; 92 data_[i] = other.data_[i];
93 } 93 }
94 for (int i = other.data_length_; i < data_length_; i++) { 94 for (int i = other.data_length_; i < data_length_; i++) {
95 data_[i] = 0; 95 data_[i] = 0;
96 } 96 }
97 } 97 }
98 98
99 bool Contains(int i) const { 99 bool Contains(int i) const {
100 ASSERT(i >= 0 && i < length()); 100 DCHECK(i >= 0 && i < length());
101 uint32_t block = data_[i / 32]; 101 uint32_t block = data_[i / 32];
102 return (block & (1U << (i % 32))) != 0; 102 return (block & (1U << (i % 32))) != 0;
103 } 103 }
104 104
105 void Add(int i) { 105 void Add(int i) {
106 ASSERT(i >= 0 && i < length()); 106 DCHECK(i >= 0 && i < length());
107 data_[i / 32] |= (1U << (i % 32)); 107 data_[i / 32] |= (1U << (i % 32));
108 } 108 }
109 109
110 void Remove(int i) { 110 void Remove(int i) {
111 ASSERT(i >= 0 && i < length()); 111 DCHECK(i >= 0 && i < length());
112 data_[i / 32] &= ~(1U << (i % 32)); 112 data_[i / 32] &= ~(1U << (i % 32));
113 } 113 }
114 114
115 void Union(const BitVector& other) { 115 void Union(const BitVector& other) {
116 ASSERT(other.length() == length()); 116 DCHECK(other.length() == length());
117 for (int i = 0; i < data_length_; i++) { 117 for (int i = 0; i < data_length_; i++) {
118 data_[i] |= other.data_[i]; 118 data_[i] |= other.data_[i];
119 } 119 }
120 } 120 }
121 121
122 bool UnionIsChanged(const BitVector& other) { 122 bool UnionIsChanged(const BitVector& other) {
123 ASSERT(other.length() == length()); 123 DCHECK(other.length() == length());
124 bool changed = false; 124 bool changed = false;
125 for (int i = 0; i < data_length_; i++) { 125 for (int i = 0; i < data_length_; i++) {
126 uint32_t old_data = data_[i]; 126 uint32_t old_data = data_[i];
127 data_[i] |= other.data_[i]; 127 data_[i] |= other.data_[i];
128 if (data_[i] != old_data) changed = true; 128 if (data_[i] != old_data) changed = true;
129 } 129 }
130 return changed; 130 return changed;
131 } 131 }
132 132
133 void Intersect(const BitVector& other) { 133 void Intersect(const BitVector& other) {
134 ASSERT(other.length() == length()); 134 DCHECK(other.length() == length());
135 for (int i = 0; i < data_length_; i++) { 135 for (int i = 0; i < data_length_; i++) {
136 data_[i] &= other.data_[i]; 136 data_[i] &= other.data_[i];
137 } 137 }
138 } 138 }
139 139
140 void Subtract(const BitVector& other) { 140 void Subtract(const BitVector& other) {
141 ASSERT(other.length() == length()); 141 DCHECK(other.length() == length());
142 for (int i = 0; i < data_length_; i++) { 142 for (int i = 0; i < data_length_; i++) {
143 data_[i] &= ~other.data_[i]; 143 data_[i] &= ~other.data_[i];
144 } 144 }
145 } 145 }
146 146
147 void Clear() { 147 void Clear() {
148 for (int i = 0; i < data_length_; i++) { 148 for (int i = 0; i < data_length_; i++) {
149 data_[i] = 0; 149 data_[i] = 0;
150 } 150 }
151 } 151 }
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 } 239 }
240 240
241 BitVector* bits_; 241 BitVector* bits_;
242 }; 242 };
243 243
244 244
245 } } // namespace v8::internal 245 } } // namespace v8::internal
246 246
247 247
248 #endif // V8_DATAFLOW_H_ 248 #endif // V8_DATAFLOW_H_
OLDNEW
« no previous file with comments | « src/d8.cc ('k') | src/date.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698