Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef VM_BIT_VECTOR_H_ | 5 #ifndef VM_BIT_VECTOR_H_ |
| 6 #define VM_BIT_VECTOR_H_ | 6 #define VM_BIT_VECTOR_H_ |
| 7 | 7 |
| 8 #include "vm/allocation.h" | 8 #include "vm/allocation.h" |
| 9 #include "vm/isolate.h" | 9 #include "vm/isolate.h" |
| 10 #include "vm/zone.h" | 10 #include "vm/zone.h" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 56 | 56 |
| 57 static intptr_t SizeFor(intptr_t length) { | 57 static intptr_t SizeFor(intptr_t length) { |
| 58 return 1 + ((length - 1) / kBitsPerWord); | 58 return 1 + ((length - 1) / kBitsPerWord); |
| 59 } | 59 } |
| 60 | 60 |
| 61 void Add(intptr_t i) { | 61 void Add(intptr_t i) { |
| 62 ASSERT(i >= 0 && i < length()); | 62 ASSERT(i >= 0 && i < length()); |
| 63 data_[i / kBitsPerWord] |= (static_cast<uword>(1) << (i % kBitsPerWord)); | 63 data_[i / kBitsPerWord] |= (static_cast<uword>(1) << (i % kBitsPerWord)); |
| 64 } | 64 } |
| 65 | 65 |
| 66 bool AddAll(BitVector* from) { | |
|
Florian Schneider
2012/06/25 14:38:29
Maybe add a test to bit_vector_test.cc that covers
Vyacheslav Egorov (Google)
2012/06/25 16:58:26
Done.
srdjan
2012/06/25 17:30:05
The two methods seem to complex for header file, I
| |
| 67 ASSERT(data_length_ == from->data_length_); | |
| 68 bool changed = false; | |
| 69 for (intptr_t i = 0; i < data_length_; i++) { | |
| 70 const uword before = data_[i]; | |
| 71 const uword after = data_[i] | from->data_[i]; | |
| 72 if (before != after) changed = true; | |
| 73 data_[i] = after; | |
| 74 } | |
| 75 return changed; | |
| 76 } | |
| 77 | |
| 78 bool KillAndAdd(BitVector* kill, BitVector* gen) { | |
|
Florian Schneider
2012/06/25 14:38:29
Add a comment what this computes: sth like
this +
Vyacheslav Egorov (Google)
2012/06/25 16:58:26
Done.
| |
| 79 ASSERT(data_length_ == kill->data_length_); | |
| 80 ASSERT(data_length_ == gen->data_length_); | |
|
srdjan
2012/06/25 17:30:05
It may be clearer to have Kill without Add, do you
Vyacheslav Egorov (Google)
2012/06/25 17:42:23
It's not easy to have Kill without Add because we
| |
| 81 bool changed = false; | |
| 82 for (intptr_t i = 0; i < data_length_; i++) { | |
| 83 const uword before = data_[i]; | |
| 84 const uword after = data_[i] | (gen->data_[i] & ~kill->data_[i]); | |
| 85 if (before != after) changed = true; | |
| 86 data_[i] = after; | |
| 87 } | |
| 88 return changed; | |
| 89 } | |
| 90 | |
| 66 bool Contains(int i) const { | 91 bool Contains(int i) const { |
| 67 ASSERT(i >= 0 && i < length()); | 92 ASSERT(i >= 0 && i < length()); |
| 68 uword block = data_[i / kBitsPerWord]; | 93 uword block = data_[i / kBitsPerWord]; |
| 69 return (block & (static_cast<uword>(1) << (i % kBitsPerWord))) != 0; | 94 return (block & (static_cast<uword>(1) << (i % kBitsPerWord))) != 0; |
| 70 } | 95 } |
| 71 | 96 |
| 72 void Clear() { | 97 void Clear() { |
| 73 for (intptr_t i = 0; i < data_length_; i++) { | 98 for (intptr_t i = 0; i < data_length_; i++) { |
| 74 data_[i] = 0; | 99 data_[i] = 0; |
| 75 } | 100 } |
| 76 } | 101 } |
| 77 | 102 |
| 78 intptr_t length() const { return length_; } | 103 intptr_t length() const { return length_; } |
| 79 | 104 |
| 80 private: | 105 private: |
| 81 intptr_t length_; | 106 intptr_t length_; |
| 82 intptr_t data_length_; | 107 intptr_t data_length_; |
| 83 uword* data_; | 108 uword* data_; |
| 84 | 109 |
| 85 DISALLOW_COPY_AND_ASSIGN(BitVector); | 110 DISALLOW_COPY_AND_ASSIGN(BitVector); |
| 86 }; | 111 }; |
| 87 | 112 |
| 88 } // namespace dart | 113 } // namespace dart |
| 89 | 114 |
| 90 #endif // VM_BIT_VECTOR_H_ | 115 #endif // VM_BIT_VECTOR_H_ |
| OLD | NEW |