summaryrefslogtreecommitdiff
path: root/runtime/class_table_test.cc
diff options
context:
space:
mode:
author Vladimir Marko <vmarko@google.com> 2021-01-15 10:04:45 +0000
committer Vladimir Marko <vmarko@google.com> 2021-01-19 09:11:51 +0000
commit4c796aad94ecf594d3e792da4e5d2424638791da (patch)
tree466b796ded30a136713b7b2756e8fa6d5db6dafb /runtime/class_table_test.cc
parentdd732cc38f57844bfcedc5687d4b66df7102f31f (diff)
Rewrite class table construction in ImageWriter.
Make sure that class tables in images are at maximum load factor (full) and make that maximum load factor independent of runtime parameters. As we pre-allocate a class table buffer of the right size in ImageWriter, we also avoid unnecessary resizing of the temporary class table. Make sure that app image class tables are deterministic. We previously just copied the class table from the app class loader even though some entries may have been inserted there during multi-threaded phases of the compilation, causing non-deterministic contents based on insertion order. Remove obsolete comment related to patchoat relocations. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Test: boots. Bug: 175869411 Change-Id: I605048b639f67a5ed4b03eb8888cbaafa9ba4091
Diffstat (limited to 'runtime/class_table_test.cc')
-rw-r--r--runtime/class_table_test.cc11
1 files changed, 8 insertions, 3 deletions
diff --git a/runtime/class_table_test.cc b/runtime/class_table_test.cc
index 5275c7ea95..642e10ac46 100644
--- a/runtime/class_table_test.cc
+++ b/runtime/class_table_test.cc
@@ -144,11 +144,16 @@ TEST_F(ClassTableTest, ClassTable) {
table.Remove(descriptor_x);
EXPECT_FALSE(table.Contains(h_X.Get()));
- // Test that WriteToMemory and ReadFromMemory work.
+ // Test that reading a class set from memory works.
table.Insert(h_X.Get());
- const size_t count = table.WriteToMemory(nullptr);
+ ClassTable::ClassSet temp_set;
+ table.Visit([&temp_set](ObjPtr<mirror::Class> klass) REQUIRES_SHARED(Locks::mutator_lock_) {
+ temp_set.insert(ClassTable::TableSlot(klass));
+ return true;
+ });
+ const size_t count = temp_set.WriteToMemory(nullptr);
std::unique_ptr<uint8_t[]> buffer(new uint8_t[count]());
- ASSERT_EQ(table.WriteToMemory(&buffer[0]), count);
+ ASSERT_EQ(temp_set.WriteToMemory(&buffer[0]), count);
ClassTable table2;
size_t count2 = table2.ReadFromMemory(&buffer[0]);
EXPECT_EQ(count, count2);