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

Unified Diff: runtime/vm/bit_set.h

Issue 534653002: Bump allocation for promotion (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 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/platform/utils.cc ('k') | runtime/vm/freelist.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/bit_set.h
===================================================================
--- runtime/vm/bit_set.h (revision 39806)
+++ runtime/vm/bit_set.h (working copy)
@@ -22,38 +22,49 @@
void Set(intptr_t i, bool value) {
ASSERT(i >= 0);
ASSERT(i < N);
- uword mask = (static_cast<uword>(1) << (i % kBitsPerWord));
+ uword mask = (static_cast<uword>(1) << (i & (kBitsPerWord - 1)));
if (value) {
- data_[i / kBitsPerWord] |= mask;
+ data_[i >> kBitsPerWordLog2] |= mask;
} else {
- data_[i / kBitsPerWord] &= ~mask;
+ data_[i >> kBitsPerWordLog2] &= ~mask;
}
}
- bool Test(intptr_t i) {
+ bool Test(intptr_t i) const {
ASSERT(i >= 0);
ASSERT(i < N);
- uword mask = (static_cast<uword>(1) << (i % kBitsPerWord));
- return (data_[i / kBitsPerWord] & mask) != 0;
+ uword mask = (static_cast<uword>(1) << (i & (kBitsPerWord - 1)));
+ return (data_[i >> kBitsPerWordLog2] & mask) != 0;
}
- intptr_t Next(intptr_t i) {
+ intptr_t Next(intptr_t i) const {
ASSERT(i >= 0);
ASSERT(i < N);
- intptr_t w = i / kBitsPerWord;
+ intptr_t w = i >> kBitsPerWordLog2;
uword mask = ~static_cast<uword>(0) << i;
if ((data_[w] & mask) != 0) {
uword tz = Utils::CountTrailingZeros(data_[w] & mask);
- return kBitsPerWord*w + tz;
+ return (w << kBitsPerWordLog2) + tz;
}
- while (++w < (1 + ((N - 1) / kBitsPerWord))) {
+ while (++w < kLengthInWords) {
if (data_[w] != 0) {
- return kBitsPerWord*w + Utils::CountTrailingZeros(data_[w]);
+ return (w << kBitsPerWordLog2) + Utils::CountTrailingZeros(data_[w]);
}
}
return -1;
}
+ intptr_t Last() const {
+ for (int w = kLengthInWords - 1; w >= 0; --w) {
+ uword d = data_[w];
+ if (d != 0) {
+ // TODO(koda): Define HighestBit(uword) or use uint64_t[] for data_.
+ return (w << kBitsPerWordLog2) + Utils::HighestBit(d);
+ }
+ }
+ return -1;
+ }
+
void Reset() {
memset(data_, 0, sizeof(data_));
}
@@ -63,7 +74,8 @@
}
private:
- uword data_[1 + ((N - 1) / kBitsPerWord)];
+ static const int kLengthInWords = 1 + ((N - 1) / kBitsPerWord);
+ uword data_[kLengthInWords];
};
} // namespace dart
« no previous file with comments | « runtime/platform/utils.cc ('k') | runtime/vm/freelist.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698