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

Unified Diff: runtime/vm/bit_set.h

Issue 10810048: Revert "Revert "Favor free list allocation to bump pointer allocation."" (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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 | « no previous file | 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
new file mode 100644
index 0000000000000000000000000000000000000000..7fba930d90300bb0ceff278dd699f9503c604eb9
--- /dev/null
+++ b/runtime/vm/bit_set.h
@@ -0,0 +1,53 @@
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+#ifndef VM_BIT_SET_H_
+#define VM_BIT_SET_H_
+
+#include "vm/globals.h"
+
+namespace dart {
+
+// Just like its namesake in the STL, a BitSet object contains a fixed
+// length sequence of bits.
+template<intptr_t N>
+class BitSet {
+ public:
+ BitSet() {
+ Reset();
+ }
+
+ void Set(intptr_t i, bool value) {
+ ASSERT(i >= 0);
+ ASSERT(i < N);
+ uword mask = (static_cast<uword>(1) << (i % kBitsPerWord));
+ if (value) {
+ data_[i / kBitsPerWord] |= mask;
+ } else {
+ data_[i / kBitsPerWord] &= ~mask;
+ }
+ }
+
+ bool Test(intptr_t i) {
+ ASSERT(i >= 0);
+ ASSERT(i < N);
+ uword mask = (static_cast<uword>(1) << (i % kBitsPerWord));
+ return (data_[i / kBitsPerWord] & mask) != 0;
+ }
+
+ void Reset() {
+ memset(data_, 0, sizeof(data_));
+ }
+
+ intptr_t Size() const {
+ return N;
+ }
+
+ private:
+ uword data_[1 + ((N - 1) / kBitsPerWord)];
+};
+
+} // namespace dart
+
+#endif // VM_BIT_SET_H_
« no previous file with comments | « no previous file | runtime/vm/freelist.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698