From 4c796aad94ecf594d3e792da4e5d2424638791da Mon Sep 17 00:00:00 2001 From: Vladimir Marko Date: Fri, 15 Jan 2021 10:04:45 +0000 Subject: 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 --- runtime/class_table.cc | 38 -------------------------------------- 1 file changed, 38 deletions(-) (limited to 'runtime/class_table.cc') diff --git a/runtime/class_table.cc b/runtime/class_table.cc index cb87ee2f8a..65d976828d 100644 --- a/runtime/class_table.cc +++ b/runtime/class_table.cc @@ -146,24 +146,6 @@ void ClassTable::Insert(ObjPtr klass) { classes_.back().InsertWithHash(TableSlot(klass, hash), hash); } -void ClassTable::CopyWithoutLocks(const ClassTable& source_table) { - if (kIsDebugBuild) { - for (ClassSet& class_set : classes_) { - CHECK(class_set.empty()); - } - } - for (const ClassSet& class_set : source_table.classes_) { - for (const TableSlot& slot : class_set) { - classes_.back().insert(slot); - } - } -} - -void ClassTable::InsertWithoutLocks(ObjPtr klass) { - const uint32_t hash = TableSlot::HashDescriptor(klass); - classes_.back().InsertWithHash(TableSlot(klass, hash), hash); -} - void ClassTable::InsertWithHash(ObjPtr klass, size_t hash) { WriterMutexLock mu(Thread::Current(), lock_); classes_.back().InsertWithHash(TableSlot(klass, hash), hash); @@ -255,26 +237,6 @@ bool ClassTable::InsertOatFileLocked(const OatFile* oat_file) { return true; } -size_t ClassTable::WriteToMemory(uint8_t* ptr) const { - ReaderMutexLock mu(Thread::Current(), lock_); - ClassSet combined; - // Combine all the class sets in case there are multiple, also adjusts load factor back to - // default in case classes were pruned. - for (const ClassSet& class_set : classes_) { - for (const TableSlot& root : class_set) { - combined.insert(root); - } - } - const size_t ret = combined.WriteToMemory(ptr); - // Validity check - if (kIsDebugBuild && ptr != nullptr) { - size_t read_count; - ClassSet class_set(ptr, /*make copy*/false, &read_count); - class_set.Verify(); - } - return ret; -} - size_t ClassTable::ReadFromMemory(uint8_t* ptr) { size_t read_count = 0; AddClassSet(ClassSet(ptr, /*make copy*/false, &read_count)); -- cgit v1.2.3-59-g8ed1b