summaryrefslogtreecommitdiff
path: root/deps/v8/src/bit-vector.cc
diff options
context:
space:
mode:
authorBen Noordhuis <info@bnoordhuis.nl>2014-11-14 00:52:27 +0100
committerBen Noordhuis <info@bnoordhuis.nl>2014-11-14 16:34:58 +0100
commit5d1b6d3e0fa4b97a490ef964be48aed9872e3ec1 (patch)
treeab5f510c4d83b175681de629395525bf7ec7cedb /deps/v8/src/bit-vector.cc
parent3b3d89bad26f5dfebe73fef6ae284ee78acbd5c9 (diff)
downloadandroid-node-v8-5d1b6d3e0fa4b97a490ef964be48aed9872e3ec1.tar.gz
android-node-v8-5d1b6d3e0fa4b97a490ef964be48aed9872e3ec1.tar.bz2
android-node-v8-5d1b6d3e0fa4b97a490ef964be48aed9872e3ec1.zip
deps: upgrade v8 to 3.30.37
Diffstat (limited to 'deps/v8/src/bit-vector.cc')
-rw-r--r--deps/v8/src/bit-vector.cc58
1 files changed, 58 insertions, 0 deletions
diff --git a/deps/v8/src/bit-vector.cc b/deps/v8/src/bit-vector.cc
new file mode 100644
index 0000000000..198b24273c
--- /dev/null
+++ b/deps/v8/src/bit-vector.cc
@@ -0,0 +1,58 @@
+// Copyright 2010 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "src/bit-vector.h"
+
+#include "src/base/bits.h"
+#include "src/scopes.h"
+
+namespace v8 {
+namespace internal {
+
+#ifdef DEBUG
+void BitVector::Print() {
+ bool first = true;
+ PrintF("{");
+ for (int i = 0; i < length(); i++) {
+ if (Contains(i)) {
+ if (!first) PrintF(",");
+ first = false;
+ PrintF("%d", i);
+ }
+ }
+ PrintF("}");
+}
+#endif
+
+
+void BitVector::Iterator::Advance() {
+ current_++;
+ uintptr_t val = current_value_;
+ while (val == 0) {
+ current_index_++;
+ if (Done()) return;
+ val = target_->data_[current_index_];
+ current_ = current_index_ << kDataBitShift;
+ }
+ val = SkipZeroBytes(val);
+ val = SkipZeroBits(val);
+ current_value_ = val >> 1;
+}
+
+
+int BitVector::Count() const {
+ int count = 0;
+ for (int i = 0; i < data_length_; i++) {
+ uintptr_t data = data_[i];
+ if (sizeof(data) == 8) {
+ count += base::bits::CountPopulation64(data);
+ } else {
+ count += base::bits::CountPopulation32(static_cast<uint32_t>(data));
+ }
+ }
+ return count;
+}
+
+} // namespace internal
+} // namespace v8