summaryrefslogtreecommitdiff
path: root/runtime/class_linker.cc
diff options
context:
space:
mode:
author Santiago Aboy Solanes <solanes@google.com> 2024-03-19 13:58:44 +0000
committer Treehugger Robot <android-test-infra-autosubmit@system.gserviceaccount.com> 2024-03-21 10:57:16 +0000
commit1e78696010ab61314b29802e1772c3bba8ad9b00 (patch)
tree13655f55565d6ebc9d5680ab87d1beb703232f28 /runtime/class_linker.cc
parentc8d6e3b523f31baa548934f822c6e36adc2a52e8 (diff)
Improve PointerSize in ImageHeader
We were saving it as a raw uint32 which meant that we were having unnecessary conversion and checks. Bug: 329379384 Bug: 329378408 Test: art/test/testrunner/testrunner.py --host --64 --optimizing -b Test: m test-art-host-gtest Change-Id: Ib6d9a9abfec7588dad4ff345cc6b569df7144782
Diffstat (limited to 'runtime/class_linker.cc')
-rw-r--r--runtime/class_linker.cc11
1 files changed, 7 insertions, 4 deletions
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc
index ff5803e69f..ecd15ba8f0 100644
--- a/runtime/class_linker.cc
+++ b/runtime/class_linker.cc
@@ -32,6 +32,7 @@
#include <utility>
#include <vector>
+#include "android-base/macros.h"
#include "android-base/stringprintf.h"
#include "android-base/strings.h"
#include "art_field-inl.h"
@@ -40,6 +41,7 @@
#include "base/arena_allocator.h"
#include "base/arena_bit_vector.h"
#include "base/casts.h"
+#include "base/enums.h"
#include "base/file_utils.h"
#include "base/hash_map.h"
#include "base/hash_set.h"
@@ -1301,12 +1303,13 @@ bool ClassLinker::InitFromBootImage(std::string* error_msg) {
std::vector<gc::space::ImageSpace*> spaces = heap->GetBootImageSpaces();
CHECK(!spaces.empty());
const ImageHeader& image_header = spaces[0]->GetImageHeader();
- uint32_t pointer_size_unchecked = image_header.GetPointerSizeUnchecked();
- if (!ValidPointerSize(pointer_size_unchecked)) {
- *error_msg = StringPrintf("Invalid image pointer size: %u", pointer_size_unchecked);
+ image_pointer_size_ = image_header.GetPointerSize();
+ if (UNLIKELY(image_pointer_size_ != PointerSize::k32 &&
+ image_pointer_size_ != PointerSize::k64)) {
+ *error_msg =
+ StringPrintf("Invalid image pointer size: %u", static_cast<uint32_t>(image_pointer_size_));
return false;
}
- image_pointer_size_ = image_header.GetPointerSize();
if (!runtime->IsAotCompiler()) {
// Only the Aot compiler supports having an image with a different pointer size than the
// runtime. This happens on the host for compiling 32 bit tests since we use a 64 bit libart