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

Unified Diff: runtime/vm/bit_set.h

Issue 10806078: Improve the performance of bit set searches with a compiler intrinsic. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: address review comments Created 8 years, 5 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_win.h ('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
diff --git a/runtime/vm/bit_set.h b/runtime/vm/bit_set.h
index 7fba930d90300bb0ceff278dd699f9503c604eb9..98cc631bfc1eef268731fb96a784b1894b237844 100644
--- a/runtime/vm/bit_set.h
+++ b/runtime/vm/bit_set.h
@@ -5,6 +5,7 @@
#ifndef VM_BIT_SET_H_
#define VM_BIT_SET_H_
+#include "platform/utils.h"
#include "vm/globals.h"
namespace dart {
@@ -36,6 +37,23 @@ class BitSet {
return (data_[i / kBitsPerWord] & mask) != 0;
}
+ intptr_t Next(intptr_t i) {
+ ASSERT(i >= 0);
+ ASSERT(i < N);
+ intptr_t w = i / kBitsPerWord;
+ uword mask = ~static_cast<uword>(0) << i;
+ if ((data_[w] & mask) != 0) {
+ uword tz = Utils::CountTrailingZeros(data_[w] & mask);
+ return kBitsPerWord*w + tz;
+ }
+ while (++w < (1 + ((N - 1) / kBitsPerWord))) {
+ if (data_[w] != 0) {
+ return kBitsPerWord*w + Utils::CountTrailingZeros(data_[w]);
+ }
+ }
+ return -1;
+ }
+
void Reset() {
memset(data_, 0, sizeof(data_));
}
« no previous file with comments | « runtime/platform/utils_win.h ('k') | runtime/vm/freelist.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698