diff options
author | Vladimir Marko <vmarko@google.com> | 2015-05-19 18:08:00 +0100 |
---|---|---|
committer | Vladimir Marko <vmarko@google.com> | 2015-05-26 19:33:33 +0100 |
commit | 41b175aba41c9365a1c53b8a1afbd17129c87c14 (patch) | |
tree | 5c82606d39543fb932ddc0674694fc0758b1a866 /cmdline | |
parent | 54d65738eecc1fa79ed528ff2f6b9b4f7a4743be (diff) | |
download | art-41b175aba41c9365a1c53b8a1afbd17129c87c14.zip art-41b175aba41c9365a1c53b8a1afbd17129c87c14.tar.gz art-41b175aba41c9365a1c53b8a1afbd17129c87c14.tar.bz2 |
ART: Clean up arm64 kNumberOfXRegisters usage.
Avoid undefined behavior for arm64 stemming from 1u << 32 in
loops with upper bound kNumberOfXRegisters.
Create iterators for enumerating bits in an integer either
from high to low or from low to high and use them for
<arch>Context::FillCalleeSaves() on all architectures.
Refactor runtime/utils.{h,cc} by moving all bit-fiddling
functions to runtime/base/bit_utils.{h,cc} (together with
the new bit iterators) and all time-related functions to
runtime/base/time_utils.{h,cc}. Improve test coverage and
fix some corner cases for the bit-fiddling functions.
Bug: 13925192
(cherry picked from commit 80afd02024d20e60b197d3adfbb43cc303cf29e0)
Change-Id: I905257a21de90b5860ebe1e39563758f721eab82
Diffstat (limited to 'cmdline')
-rw-r--r-- | cmdline/cmdline_parser.h | 1 | ||||
-rw-r--r-- | cmdline/cmdline_types.h | 1 | ||||
-rw-r--r-- | cmdline/memory_representation.h | 25 |
3 files changed, 13 insertions, 14 deletions
diff --git a/cmdline/cmdline_parser.h b/cmdline/cmdline_parser.h index e4af4f9..cebba65 100644 --- a/cmdline/cmdline_parser.h +++ b/cmdline/cmdline_parser.h @@ -30,7 +30,6 @@ #include "cmdline_parse_result.h" #include "runtime/base/variant_map.h" -#include "utils.h" #include <vector> #include <memory> diff --git a/cmdline/cmdline_types.h b/cmdline/cmdline_types.h index 03165ed..f38478c 100644 --- a/cmdline/cmdline_types.h +++ b/cmdline/cmdline_types.h @@ -27,6 +27,7 @@ #include "unit.h" #include "jdwp/jdwp.h" #include "runtime/base/logging.h" +#include "runtime/base/time_utils.h" #include "gc/collector_type.h" #include "gc/space/large_object_space.h" #include "profiler_options.h" diff --git a/cmdline/memory_representation.h b/cmdline/memory_representation.h index 93387de..2619c31 100644 --- a/cmdline/memory_representation.h +++ b/cmdline/memory_representation.h @@ -20,24 +20,25 @@ #include <string> #include <assert.h> #include <ostream> -#include "utils.h" + +#include "base/bit_utils.h" namespace art { // An integral representation of bytes of memory. // The underlying runtime size_t value is guaranteed to be a multiple of Divisor. -template <size_t Divisor = 1024> +template <size_t kDivisor = 1024> struct Memory { - static_assert(IsPowerOfTwo(Divisor), "Divisor must be a power of 2"); + static_assert(IsPowerOfTwo(kDivisor), "Divisor must be a power of 2"); - static Memory<Divisor> FromBytes(size_t bytes) { - assert(bytes % Divisor == 0); - return Memory<Divisor>(bytes); + static Memory<kDivisor> FromBytes(size_t bytes) { + assert(bytes % kDivisor == 0); + return Memory<kDivisor>(bytes); } Memory() : Value(0u) {} Memory(size_t value) : Value(value) { // NOLINT [runtime/explicit] [5] - assert(value % Divisor == 0); + assert(value % kDivisor == 0); } operator size_t() const { return Value; } @@ -45,12 +46,10 @@ struct Memory { return Value; } - static constexpr size_t kDivisor = Divisor; - static const char* Name() { static std::string str; if (str.empty()) { - str = "Memory<" + std::to_string(Divisor) + '>'; + str = "Memory<" + std::to_string(kDivisor) + '>'; } return str.c_str(); @@ -59,9 +58,9 @@ struct Memory { size_t Value; }; -template <size_t Divisor> -std::ostream& operator<<(std::ostream& stream, Memory<Divisor> memory) { - return stream << memory.Value << '*' << Divisor; +template <size_t kDivisor> +std::ostream& operator<<(std::ostream& stream, Memory<kDivisor> memory) { + return stream << memory.Value << '*' << kDivisor; } using MemoryKiB = Memory<1024>; |