Fix cdex bugs to enable ART_DEFAULT_COMPACT_DEX_LEVEL=fast tests passing
Compute dex checksum for compact dex generation. Handle input vdex
by not aborting in oat_writer, instead just avoid generating compact
dex for the input vdex case.
Re-enabled some compact dex tests.
Bug: 63756964
Test: ART_DEFAULT_COMPACT_DEX_LEVEL=fast test-art-host
Change-Id: Ic9b4e4e59e6cd22b66ee2fc0d32c9b4a15f13497
diff --git a/runtime/common_runtime_test.h b/runtime/common_runtime_test.h
index 0f931e3..625884d 100644
--- a/runtime/common_runtime_test.h
+++ b/runtime/common_runtime_test.h
@@ -26,6 +26,7 @@
#include "arch/instruction_set.h"
#include "base/mutex.h"
+#include "cdex/compact_dex_level.h"
#include "globals.h"
// TODO: Add inl file and avoid including inl.
#include "obj_ptr-inl.h"
@@ -305,6 +306,11 @@
return; \
}
+#define TEST_DISABLED_FOR_COMPACT_DEX() \
+ if (kDefaultCompactDexLevel != CompactDexLevel::kCompactDexLevelNone) { \
+ printf("WARNING: TEST DISABLED FOR COMPACT DEX\n"); \
+ return; \
+ }
} // namespace art
#endif // ART_RUNTIME_COMMON_RUNTIME_TEST_H_
diff --git a/runtime/dex_file.cc b/runtime/dex_file.cc
index 2d02415..4aed402 100644
--- a/runtime/dex_file.cc
+++ b/runtime/dex_file.cc
@@ -46,9 +46,13 @@
static_assert(std::is_trivially_copyable<dex::TypeIndex>::value, "TypeIndex not trivial");
uint32_t DexFile::CalculateChecksum() const {
+ return CalculateChecksum(Begin(), Size());
+}
+
+uint32_t DexFile::CalculateChecksum(const uint8_t* begin, size_t size) {
const uint32_t non_sum = OFFSETOF_MEMBER(DexFile::Header, signature_);
- const uint8_t* non_sum_ptr = Begin() + non_sum;
- return adler32(adler32(0L, Z_NULL, 0), non_sum_ptr, Size() - non_sum);
+ const uint8_t* non_sum_ptr = begin + non_sum;
+ return adler32(adler32(0L, Z_NULL, 0), non_sum_ptr, size - non_sum);
}
int DexFile::GetPermissions() const {
diff --git a/runtime/dex_file.h b/runtime/dex_file.h
index de3af8a..76110f2 100644
--- a/runtime/dex_file.h
+++ b/runtime/dex_file.h
@@ -1017,6 +1017,7 @@
// Recalculates the checksum of the dex file. Does not use the current value in the header.
uint32_t CalculateChecksum() const;
+ static uint32_t CalculateChecksum(const uint8_t* begin, size_t size);
// Returns a human-readable form of the method at an index.
std::string PrettyMethod(uint32_t method_idx, bool with_signature = true) const;