Move and rewrite bit loading/storing methods.
Move bit loading/storing methods to BitMemoryRegion and rewrite them.
Enforce natural alignment of the data pointer in BitMemoryRegion.
This probably would not be reasonable in MemoryRegion, but it is
fine here since the BitMemoryRegion already has extra bit offset.
The alignment makes it possible to simplify and optimize the methods.
This makes the stackmap reading code 33% faster.
(measured by the time needed to verify all stackmap fields on ARM).
Test: m -j40 test-art-host-gtest
Change-Id: I00be8052969a6056b262df4cd2066ffd86043196
diff --git a/libartbase/base/bit_utils.h b/libartbase/base/bit_utils.h
index 04f0e85..58cc78c 100644
--- a/libartbase/base/bit_utils.h
+++ b/libartbase/base/bit_utils.h
@@ -22,6 +22,7 @@
#include <android-base/logging.h>
+#include "globals.h"
#include "stl_util_identity.h"
namespace art {
@@ -499,6 +500,10 @@
return bitfield_unsigned;
}
+inline static constexpr size_t BitsToBytesRoundUp(size_t num_bits) {
+ return RoundUp(num_bits, kBitsPerByte) / kBitsPerByte;
+}
+
} // namespace art
#endif // ART_LIBARTBASE_BASE_BIT_UTILS_H_