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

Unified Diff: runtime/vm/bit_vector.cc

Issue 10914314: Simple redundant load elimination. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: addressed comments Created 8 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/bit_vector.h ('k') | runtime/vm/bit_vector_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/bit_vector.cc
===================================================================
--- runtime/vm/bit_vector.cc (revision 12420)
+++ runtime/vm/bit_vector.cc (working copy)
@@ -33,7 +33,23 @@
}
-bool BitVector::AddAll(BitVector* from) {
+bool BitVector::Equals(const BitVector& other) const {
+ if (length_ != other.length_) return false;
+ intptr_t i = 0;
+ for (; i < data_length_ - 1; i++) {
+ if (data_[i] != other.data_[i]) return false;
+ }
+ if (i < data_length_) {
+ // Don't compare bits beyond length_.
+ uword mask =
+ static_cast<uword>(-1) >> (kBitsPerWord - (length_ % kBitsPerWord));
+ if ((data_[i] & mask) != (other.data_[i] & mask)) return false;
+ }
+ return true;
+}
+
+
+bool BitVector::AddAll(const BitVector* from) {
ASSERT(data_length_ == from->data_length_);
bool changed = false;
for (intptr_t i = 0; i < data_length_; i++) {
@@ -60,4 +76,20 @@
}
+void BitVector::Intersect(const BitVector& other) {
+ ASSERT(other.length() == length());
+ for (int i = 0; i < data_length_; i++) {
+ data_[i] = data_[i] & other.data_[i];
+ }
+}
+
+
+void BitVector::Print() const {
+ OS::Print("[");
+ for (intptr_t i = 0; i < length_; i++) {
+ OS::Print(Contains(i) ? "1" : "0");
+ }
+ OS::Print("]");
+}
+
} // namespace dart
« no previous file with comments | « runtime/vm/bit_vector.h ('k') | runtime/vm/bit_vector_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698