Align BitMemoryRegion down by sizeof(uint64_t)

The page size can now be a static global non-constexpr value, which
means that references to this value can incur an additional overhead.
An overhead is especially observed during exception throwing,
corresponding to BitMemoryRegion's usage of the page size variable.

The maximum data type in a single load from the BitMemoryRegion is
uint64_t (via LoadBits), during which the region's data is indexed into
as a uint64_t array. This array must be naturally aligned for efficient
accesses to its elements, which will occur when the region's data
pointer is aligned down by any non-zero multiple of sizeof(uint64_t).

Therefore, it is unnecessary to align down the region's data pointer by
the page size, and the overhead can instead be avoided simply by
aligning down by sizeof(uint64_t). As the actual location of data is
unaffected, this change has no impact on memory usage.

To provide clarity on the usage of sizeof(uint64_t) in the code, define
a type alias MaxSingleLoadType and corresponding constant
kMaxSingleLoadBytes, and add a compile-time check that this is greater
than or equal to the data type size requested from LoadBits.

The tests were run for legacy 4K, page size agnostic 4K and 16K.

Test: art/tools/run-gtests.sh
Test: art/test/testrunner/testrunner.py --target --64
Test: art/tools/run-libcore-tests.sh --mode=device --variant=X64
Test: art/tools/run-libjdwp-tests.sh --mode=device --variant=X64

Change-Id: I9ee90e41e22a63e3693356f79cc8df90d03d6b20
1 file changed