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

Side by Side Diff: runtime/vm/bit_vector.h

Issue 10657044: Fix a bug in liveness analysis code and add more comments. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 6 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 | « no previous file | runtime/vm/bit_vector.cc » ('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 (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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 // Add all elements that are in the bitvector from. 66 // Add all elements that are in the bitvector from.
67 bool AddAll(BitVector* from) { 67 bool AddAll(BitVector* from);
68 ASSERT(data_length_ == from->data_length_);
69 bool changed = false;
70 for (intptr_t i = 0; i < data_length_; i++) {
71 const uword before = data_[i];
72 const uword after = data_[i] | from->data_[i];
73 if (before != after) changed = true;
74 data_[i] = after;
75 }
76 return changed;
77 }
78 68
79 // From the bitvector gen add those elements that are not in the 69 // From the bitvector gen add those elements that are not in the
80 // bitvector kill. 70 // bitvector kill.
81 bool KillAndAdd(BitVector* kill, BitVector* gen) { 71 bool KillAndAdd(BitVector* kill, BitVector* gen);
82 ASSERT(data_length_ == kill->data_length_);
83 ASSERT(data_length_ == gen->data_length_);
84 bool changed = false;
85 for (intptr_t i = 0; i < data_length_; i++) {
86 const uword before = data_[i];
87 const uword after = data_[i] | (gen->data_[i] & ~kill->data_[i]);
88 if (before != after) changed = true;
89 data_[i] = after;
90 }
91 return changed;
92 }
93 72
94 bool Contains(int i) const { 73 bool Contains(int i) const {
95 ASSERT(i >= 0 && i < length()); 74 ASSERT(i >= 0 && i < length());
96 uword block = data_[i / kBitsPerWord]; 75 uword block = data_[i / kBitsPerWord];
97 return (block & (static_cast<uword>(1) << (i % kBitsPerWord))) != 0; 76 return (block & (static_cast<uword>(1) << (i % kBitsPerWord))) != 0;
98 } 77 }
99 78
100 void Clear() { 79 void Clear() {
101 for (intptr_t i = 0; i < data_length_; i++) { 80 for (intptr_t i = 0; i < data_length_; i++) {
102 data_[i] = 0; 81 data_[i] = 0;
103 } 82 }
104 } 83 }
105 84
106 intptr_t length() const { return length_; } 85 intptr_t length() const { return length_; }
107 86
108 private: 87 private:
109 intptr_t length_; 88 intptr_t length_;
110 intptr_t data_length_; 89 intptr_t data_length_;
111 uword* data_; 90 uword* data_;
112 91
113 DISALLOW_COPY_AND_ASSIGN(BitVector); 92 DISALLOW_COPY_AND_ASSIGN(BitVector);
114 }; 93 };
115 94
116 } // namespace dart 95 } // namespace dart
117 96
118 #endif // VM_BIT_VECTOR_H_ 97 #endif // VM_BIT_VECTOR_H_
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/bit_vector.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698