summaryrefslogtreecommitdiff
path: root/runtime/base/bit_vector.h
diff options
context:
space:
mode:
author David Brazdil <dbrazdil@google.com> 2015-05-29 16:33:09 +0100
committer David Brazdil <dbrazdil@google.com> 2015-06-02 12:30:46 +0100
commit6b10c9b2c0e62193ab9df4d63aedea1d0798e742 (patch)
tree9930b839777184008b38e5504f1274c4cbfd87e1 /runtime/base/bit_vector.h
parentf86808b55b550962c627b50511b98f4de8cd0e60 (diff)
ART: Fast copy stack mask
StackMap::SetStackMask will currently copy a BitVector into a Memory- Region bit by bit. This patch adds a new function for copying the data with memcpy. Change-Id: I28d45a590b35a4a854cca2f57db864cf8a081487
Diffstat (limited to 'runtime/base/bit_vector.h')
-rw-r--r--runtime/base/bit_vector.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/runtime/base/bit_vector.h b/runtime/base/bit_vector.h
index 17835f5610..afa8dc187e 100644
--- a/runtime/base/bit_vector.h
+++ b/runtime/base/bit_vector.h
@@ -21,6 +21,7 @@
#include <iterator>
#include "base/bit_utils.h"
+#include "globals.h"
namespace art {
@@ -229,6 +230,19 @@ class BitVector {
// Number of bits set in range [0, end) in storage. (No range check.)
static uint32_t NumSetBits(const uint32_t* storage, uint32_t end);
+ // Fill given memory region with the contents of the vector and zero padding.
+ void CopyTo(void* dst, size_t len) const {
+ DCHECK_LE(static_cast<size_t>(GetHighestBitSet() + 1), len * kBitsPerByte);
+ size_t vec_len = GetSizeOf();
+ if (vec_len < len) {
+ void* dst_padding = reinterpret_cast<uint8_t*>(dst) + vec_len;
+ memcpy(dst, storage_, vec_len);
+ memset(dst_padding, 0, len - vec_len);
+ } else {
+ memcpy(dst, storage_, len);
+ }
+ }
+
void Dump(std::ostream& os, const char* prefix) const;
private: