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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/bit_vector.h ('k') | runtime/vm/bit_vector_test.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 #include "vm/bit_vector.h" 5 #include "vm/bit_vector.h"
6 6
7 #include "vm/os.h" 7 #include "vm/os.h"
8 8
9 namespace dart { 9 namespace dart {
10 10
(...skipping 15 matching lines...) Expand all
26 } 26 }
27 // Skip zero bits. 27 // Skip zero bits.
28 while ((current_word_ & 0x1) == 0) { 28 while ((current_word_ & 0x1) == 0) {
29 current_word_ >>= 1; 29 current_word_ >>= 1;
30 ++bit_index_; 30 ++bit_index_;
31 } 31 }
32 current_word_ = current_word_ >> 1; 32 current_word_ = current_word_ >> 1;
33 } 33 }
34 34
35 35
36 bool BitVector::AddAll(BitVector* from) { 36 bool BitVector::Equals(const BitVector& other) const {
37 if (length_ != other.length_) return false;
38 intptr_t i = 0;
39 for (; i < data_length_ - 1; i++) {
40 if (data_[i] != other.data_[i]) return false;
41 }
42 if (i < data_length_) {
43 // Don't compare bits beyond length_.
44 uword mask =
45 static_cast<uword>(-1) >> (kBitsPerWord - (length_ % kBitsPerWord));
46 if ((data_[i] & mask) != (other.data_[i] & mask)) return false;
47 }
48 return true;
49 }
50
51
52 bool BitVector::AddAll(const BitVector* from) {
37 ASSERT(data_length_ == from->data_length_); 53 ASSERT(data_length_ == from->data_length_);
38 bool changed = false; 54 bool changed = false;
39 for (intptr_t i = 0; i < data_length_; i++) { 55 for (intptr_t i = 0; i < data_length_; i++) {
40 const uword before = data_[i]; 56 const uword before = data_[i];
41 const uword after = data_[i] | from->data_[i]; 57 const uword after = data_[i] | from->data_[i];
42 if (before != after) changed = true; 58 if (before != after) changed = true;
43 data_[i] = after; 59 data_[i] = after;
44 } 60 }
45 return changed; 61 return changed;
46 } 62 }
47 63
48 64
49 bool BitVector::KillAndAdd(BitVector* kill, BitVector* gen) { 65 bool BitVector::KillAndAdd(BitVector* kill, BitVector* gen) {
50 ASSERT(data_length_ == kill->data_length_); 66 ASSERT(data_length_ == kill->data_length_);
51 ASSERT(data_length_ == gen->data_length_); 67 ASSERT(data_length_ == gen->data_length_);
52 bool changed = false; 68 bool changed = false;
53 for (intptr_t i = 0; i < data_length_; i++) { 69 for (intptr_t i = 0; i < data_length_; i++) {
54 const uword before = data_[i]; 70 const uword before = data_[i];
55 const uword after = data_[i] | (gen->data_[i] & ~kill->data_[i]); 71 const uword after = data_[i] | (gen->data_[i] & ~kill->data_[i]);
56 if (before != after) changed = true; 72 if (before != after) changed = true;
57 data_[i] = after; 73 data_[i] = after;
58 } 74 }
59 return changed; 75 return changed;
60 } 76 }
61 77
62 78
79 void BitVector::Intersect(const BitVector& other) {
80 ASSERT(other.length() == length());
81 for (int i = 0; i < data_length_; i++) {
82 data_[i] = data_[i] & other.data_[i];
83 }
84 }
85
86
87 void BitVector::Print() const {
88 OS::Print("[");
89 for (intptr_t i = 0; i < length_; i++) {
90 OS::Print(Contains(i) ? "1" : "0");
91 }
92 OS::Print("]");
93 }
94
63 } // namespace dart 95 } // namespace dart
OLDNEW
« 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