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

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: 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
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::Equals(const BitVector& other) const {
37 for (int i = 0; i < data_length_; i++) {
38 if (data_[i] != other.data_[i]) return false;
39 }
40 return true;
41 }
42
43
36 bool BitVector::AddAll(BitVector* from) { 44 bool BitVector::AddAll(BitVector* from) {
37 ASSERT(data_length_ == from->data_length_); 45 ASSERT(data_length_ == from->data_length_);
38 bool changed = false; 46 bool changed = false;
39 for (intptr_t i = 0; i < data_length_; i++) { 47 for (intptr_t i = 0; i < data_length_; i++) {
40 const uword before = data_[i]; 48 const uword before = data_[i];
41 const uword after = data_[i] | from->data_[i]; 49 const uword after = data_[i] | from->data_[i];
42 if (before != after) changed = true; 50 if (before != after) changed = true;
43 data_[i] = after; 51 data_[i] = after;
44 } 52 }
45 return changed; 53 return changed;
46 } 54 }
47 55
48 56
49 bool BitVector::KillAndAdd(BitVector* kill, BitVector* gen) { 57 bool BitVector::KillAndAdd(BitVector* kill, BitVector* gen) {
50 ASSERT(data_length_ == kill->data_length_); 58 ASSERT(data_length_ == kill->data_length_);
51 ASSERT(data_length_ == gen->data_length_); 59 ASSERT(data_length_ == gen->data_length_);
52 bool changed = false; 60 bool changed = false;
53 for (intptr_t i = 0; i < data_length_; i++) { 61 for (intptr_t i = 0; i < data_length_; i++) {
54 const uword before = data_[i]; 62 const uword before = data_[i];
55 const uword after = data_[i] | (gen->data_[i] & ~kill->data_[i]); 63 const uword after = data_[i] | (gen->data_[i] & ~kill->data_[i]);
56 if (before != after) changed = true; 64 if (before != after) changed = true;
57 data_[i] = after; 65 data_[i] = after;
58 } 66 }
59 return changed; 67 return changed;
60 } 68 }
61 69
62 70
71 bool BitVector::Intersect(const BitVector& other) {
Kevin Millikin (Google) 2012/09/17 12:09:47 It doesn't look like you use the return value, so
Florian Schneider 2012/09/17 14:20:59 Done.
72 ASSERT(other.length() == length());
73 bool changed = false;
74 for (int i = 0; i < data_length_; i++) {
75 const uword before = data_[i];
76 const uword after = data_[i] & other.data_[i];
77 if (before != after) changed = true;
78 data_[i] = after;
79 }
80 return changed;
81 }
82
83
84 void BitVector::Print() const {
85 OS::Print("[");
86 for (intptr_t i = 0; i < length_; i++) {
87 OS::Print(Contains(i) ? "1" : "0");
88 }
89 OS::Print("]");
90 }
91
63 } // namespace dart 92 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698