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

Side by Side Diff: src/hydrogen-instructions.cc

Issue 769263002: Add support for enabling DCHECKs in release mode (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: updates Created 6 years 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
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 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/base/bits.h" 7 #include "src/base/bits.h"
8 #include "src/double.h" 8 #include "src/double.h"
9 #include "src/factory.h" 9 #include "src/factory.h"
10 #include "src/hydrogen-infer-representation.h" 10 #include "src/hydrogen-infer-representation.h"
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 return 0xffffffff; 193 return 0xffffffff;
194 } 194 }
195 195
196 196
197 void Range::AddConstant(int32_t value) { 197 void Range::AddConstant(int32_t value) {
198 if (value == 0) return; 198 if (value == 0) return;
199 bool may_overflow = false; // Overflow is ignored here. 199 bool may_overflow = false; // Overflow is ignored here.
200 Representation r = Representation::Integer32(); 200 Representation r = Representation::Integer32();
201 lower_ = AddWithoutOverflow(r, lower_, value, &may_overflow); 201 lower_ = AddWithoutOverflow(r, lower_, value, &may_overflow);
202 upper_ = AddWithoutOverflow(r, upper_, value, &may_overflow); 202 upper_ = AddWithoutOverflow(r, upper_, value, &may_overflow);
203 #ifdef DEBUG 203 #if DCHECK_IS_ON
204 Verify(); 204 Verify();
205 #endif 205 #endif
206 } 206 }
207 207
208 208
209 void Range::Intersect(Range* other) { 209 void Range::Intersect(Range* other) {
210 upper_ = Min(upper_, other->upper_); 210 upper_ = Min(upper_, other->upper_);
211 lower_ = Max(lower_, other->lower_); 211 lower_ = Max(lower_, other->lower_);
212 bool b = CanBeMinusZero() && other->CanBeMinusZero(); 212 bool b = CanBeMinusZero() && other->CanBeMinusZero();
213 set_can_be_minus_zero(b); 213 set_can_be_minus_zero(b);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 } 256 }
257 set_can_be_minus_zero(false); 257 set_can_be_minus_zero(false);
258 } 258 }
259 259
260 260
261 bool Range::AddAndCheckOverflow(const Representation& r, Range* other) { 261 bool Range::AddAndCheckOverflow(const Representation& r, Range* other) {
262 bool may_overflow = false; 262 bool may_overflow = false;
263 lower_ = AddWithoutOverflow(r, lower_, other->lower(), &may_overflow); 263 lower_ = AddWithoutOverflow(r, lower_, other->lower(), &may_overflow);
264 upper_ = AddWithoutOverflow(r, upper_, other->upper(), &may_overflow); 264 upper_ = AddWithoutOverflow(r, upper_, other->upper(), &may_overflow);
265 KeepOrder(); 265 KeepOrder();
266 #ifdef DEBUG 266 #if DCHECK_IS_ON
267 Verify(); 267 Verify();
268 #endif 268 #endif
269 return may_overflow; 269 return may_overflow;
270 } 270 }
271 271
272 272
273 bool Range::SubAndCheckOverflow(const Representation& r, Range* other) { 273 bool Range::SubAndCheckOverflow(const Representation& r, Range* other) {
274 bool may_overflow = false; 274 bool may_overflow = false;
275 lower_ = SubWithoutOverflow(r, lower_, other->upper(), &may_overflow); 275 lower_ = SubWithoutOverflow(r, lower_, other->upper(), &may_overflow);
276 upper_ = SubWithoutOverflow(r, upper_, other->lower(), &may_overflow); 276 upper_ = SubWithoutOverflow(r, upper_, other->lower(), &may_overflow);
277 KeepOrder(); 277 KeepOrder();
278 #ifdef DEBUG 278 #if DCHECK_IS_ON
279 Verify(); 279 Verify();
280 #endif 280 #endif
281 return may_overflow; 281 return may_overflow;
282 } 282 }
283 283
284 284
285 void Range::KeepOrder() { 285 void Range::KeepOrder() {
286 if (lower_ > upper_) { 286 if (lower_ > upper_) {
287 int32_t tmp = lower_; 287 int32_t tmp = lower_;
288 lower_ = upper_; 288 lower_ = upper_;
289 upper_ = tmp; 289 upper_ = tmp;
290 } 290 }
291 } 291 }
292 292
293 293
294 #ifdef DEBUG 294 #if DCHECK_IS_ON
295 void Range::Verify() const { 295 void Range::Verify() const {
296 DCHECK(lower_ <= upper_); 296 DCHECK(lower_ <= upper_);
297 } 297 }
298 #endif 298 #endif
299 299
300 300
301 bool Range::MulAndCheckOverflow(const Representation& r, Range* other) { 301 bool Range::MulAndCheckOverflow(const Representation& r, Range* other) {
302 bool may_overflow = false; 302 bool may_overflow = false;
303 int v1 = MulWithoutOverflow(r, lower_, other->lower(), &may_overflow); 303 int v1 = MulWithoutOverflow(r, lower_, other->lower(), &may_overflow);
304 int v2 = MulWithoutOverflow(r, lower_, other->upper(), &may_overflow); 304 int v2 = MulWithoutOverflow(r, lower_, other->upper(), &may_overflow);
305 int v3 = MulWithoutOverflow(r, upper_, other->lower(), &may_overflow); 305 int v3 = MulWithoutOverflow(r, upper_, other->lower(), &may_overflow);
306 int v4 = MulWithoutOverflow(r, upper_, other->upper(), &may_overflow); 306 int v4 = MulWithoutOverflow(r, upper_, other->upper(), &may_overflow);
307 lower_ = Min(Min(v1, v2), Min(v3, v4)); 307 lower_ = Min(Min(v1, v2), Min(v3, v4));
308 upper_ = Max(Max(v1, v2), Max(v3, v4)); 308 upper_ = Max(Max(v1, v2), Max(v3, v4));
309 #ifdef DEBUG 309 #if DCHECK_IS_ON
310 Verify(); 310 Verify();
311 #endif 311 #endif
312 return may_overflow; 312 return may_overflow;
313 } 313 }
314 314
315 315
316 bool HValue::IsDefinedAfter(HBasicBlock* other) const { 316 bool HValue::IsDefinedAfter(HBasicBlock* other) const {
317 return block()->block_id() > other->block_id(); 317 return block()->block_id() > other->block_id();
318 } 318 }
319 319
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after
728 // should precede the other one in order to dominate it. 728 // should precede the other one in order to dominate it.
729 for (HInstruction* instr = next(); instr != NULL; instr = instr->next()) { 729 for (HInstruction* instr = next(); instr != NULL; instr = instr->next()) {
730 if (instr == other) { 730 if (instr == other) {
731 return true; 731 return true;
732 } 732 }
733 } 733 }
734 return false; 734 return false;
735 } 735 }
736 736
737 737
738 #ifdef DEBUG 738 #if DCHECK_IS_ON
739 void HInstruction::Verify() { 739 void HInstruction::Verify() {
740 // Verify that input operands are defined before use. 740 // Verify that input operands are defined before use.
741 HBasicBlock* cur_block = block(); 741 HBasicBlock* cur_block = block();
742 for (int i = 0; i < OperandCount(); ++i) { 742 for (int i = 0; i < OperandCount(); ++i) {
743 HValue* other_operand = OperandAt(i); 743 HValue* other_operand = OperandAt(i);
744 if (other_operand == NULL) continue; 744 if (other_operand == NULL) continue;
745 HBasicBlock* other_block = other_operand->block(); 745 HBasicBlock* other_block = other_operand->block();
746 if (cur_block == other_block) { 746 if (cur_block == other_block) {
747 if (!other_operand->IsPhi()) { 747 if (!other_operand->IsPhi()) {
748 HInstruction* cur = this->previous(); 748 HInstruction* cur = this->previous();
(...skipping 3793 matching lines...) Expand 10 before | Expand all | Expand 10 after
4542 if (!use_rep.IsNone() && 4542 if (!use_rep.IsNone() &&
4543 !use_rep.IsSmi() && 4543 !use_rep.IsSmi() &&
4544 !use_rep.IsTagged()) { 4544 !use_rep.IsTagged()) {
4545 return true; 4545 return true;
4546 } 4546 }
4547 } 4547 }
4548 return false; 4548 return false;
4549 } 4549 }
4550 4550
4551 4551
4552 // Node-specific verification code is only included in debug mode. 4552 // Node-specific verification code is only included when DCHECKs are enabled.
4553 #ifdef DEBUG 4553 #if DCHECK_IS_ON
4554 4554
4555 void HPhi::Verify() { 4555 void HPhi::Verify() {
4556 DCHECK(OperandCount() == block()->predecessors()->length()); 4556 DCHECK(OperandCount() == block()->predecessors()->length());
4557 for (int i = 0; i < OperandCount(); ++i) { 4557 for (int i = 0; i < OperandCount(); ++i) {
4558 HValue* value = OperandAt(i); 4558 HValue* value = OperandAt(i);
4559 HBasicBlock* defining_block = value->block(); 4559 HBasicBlock* defining_block = value->block();
4560 HBasicBlock* predecessor_block = block()->predecessors()->at(i); 4560 HBasicBlock* predecessor_block = block()->predecessors()->at(i);
4561 DCHECK(defining_block == predecessor_block || 4561 DCHECK(defining_block == predecessor_block ||
4562 defining_block->Dominates(predecessor_block)); 4562 defining_block->Dominates(predecessor_block));
4563 } 4563 }
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
4798 break; 4798 break;
4799 case HObjectAccess::kExternalMemory: 4799 case HObjectAccess::kExternalMemory:
4800 os << "[external-memory]"; 4800 os << "[external-memory]";
4801 break; 4801 break;
4802 } 4802 }
4803 4803
4804 return os << "@" << access.offset(); 4804 return os << "@" << access.offset();
4805 } 4805 }
4806 4806
4807 } } // namespace v8::internal 4807 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698