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

Side by Side Diff: src/bit-vector.h

Issue 1124223006: [clusterfuzz] Length 0 is perfectly fine for BitVector. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 7 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
« no previous file with comments | « no previous file | no next file » | 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/allocation.h" 8 #include "src/allocation.h"
9 #include "src/zone.h" 9 #include "src/zone.h"
10 10
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 }; 59 };
60 60
61 static const int kDataBits = kPointerSize * 8; 61 static const int kDataBits = kPointerSize * 8;
62 static const int kDataBitShift = kPointerSize == 8 ? 6 : 5; 62 static const int kDataBitShift = kPointerSize == 8 ? 6 : 5;
63 static const uintptr_t kOne = 1; // This saves some static_casts. 63 static const uintptr_t kOne = 1; // This saves some static_casts.
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<uintptr_t>(data_length_)) { 68 data_(zone->NewArray<uintptr_t>(data_length_)) {
69 DCHECK(length > 0); 69 DCHECK_LE(0, length);
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<uintptr_t>(data_length_)) { 76 data_(zone->NewArray<uintptr_t>(data_length_)) {
77 CopyFrom(other); 77 CopyFrom(other);
78 } 78 }
79 79
80 static int SizeFor(int length) { return 1 + ((length - 1) / kDataBits); } 80 static int SizeFor(int length) {
81 if (length == 0) return 1;
82 return 1 + ((length - 1) / kDataBits);
83 }
81 84
82 void CopyFrom(const BitVector& other) { 85 void CopyFrom(const BitVector& other) {
83 DCHECK(other.length() <= length()); 86 DCHECK(other.length() <= length());
84 for (int i = 0; i < other.data_length_; i++) { 87 for (int i = 0; i < other.data_length_; i++) {
85 data_[i] = other.data_[i]; 88 data_[i] = other.data_[i];
86 } 89 }
87 for (int i = other.data_length_; i < data_length_; i++) { 90 for (int i = other.data_length_; i < data_length_; i++) {
88 data_[i] = 0; 91 data_[i] = 0;
89 } 92 }
90 } 93 }
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 bits_ = new_bits; 245 bits_ = new_bits;
243 } 246 }
244 247
245 BitVector* bits_; 248 BitVector* bits_;
246 }; 249 };
247 250
248 } // namespace internal 251 } // namespace internal
249 } // namespace v8 252 } // namespace v8
250 253
251 #endif // V8_DATAFLOW_H_ 254 #endif // V8_DATAFLOW_H_
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698