summaryrefslogtreecommitdiff
path: root/runtime/class_table.h
AgeCommit message (Collapse)Author
2024-11-05Use `std::string_view` for `ClassTable` operations. Vladimir Marko
Use `std::string_view` instead of `const char*` descriptor. This uses faster `memcmp` instead of the slower`strcmp` for descriptor comparison. Note that the `ScopedTrace` passes `const char*` across the `libartpalette` boundary, so we cannot easily replace the `const char* descriptor` with `std::string_view descriptor` in certain `ClassLinker` functions because we actually need to pass a null-terminated string and the `string_view` API does not technically guarantee null-terminated data. Therefore we resort to explicitly passing around the descriptor and its length as separate arguments. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Bug: 181943478 Bug: 338123769 Change-Id: Ie3fa251390acc582c54b4686d18696eb89b32361
2024-05-13Faster `ClassTable::UpdateClass()`. Vladimir Marko
In the `ClassTable::UpdateClass()`, both the old and the new `Class` objects reference the same dex file and type index. Therefore it's better to do the lookup with the new `Class` object as the `Class:DescriptorEquals(ObjPtr<Class>)` can avoid the string comparison for the descriptor match in this case and we compare descriptors only for hash conflicts. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Bug: 338123769 Change-Id: I23960c9c3b34b7f7fdd2fce6b191fd9c4efe7320
2024-01-24Add visibility attributes in runtime/c* Dmitrii Ishcheikin
Bug: 260881207 Test: presubmit Test: abtd app_compat_drm Test: abtd app_compat_top_100 Test: abtd app_compat_banking Change-Id: Id729aca1d8b6d003ff3e9755112f3283e9f2b507
2023-10-17Revert^2 "Update class-table and intern-table concurrently with uffd GC" Lokesh Gidra
This reverts commit 9faffd5c4e062ca45bd6f29a3b6d1b276e6c9839. Reason for revert: Reland after fixing null-pointer dereference Bug: 160737021 Test: art/testrunner/testrunner.py Change-Id: I80d3eda827ea805efc5a0e0eb0b80a9d8ceb9dd5
2023-10-17Revert "Update class-table and intern-table concurrently with uffd GC" Lokesh Gidra
This reverts commit 97a6f7cd191cde0abaaf6323ae2f67d8e42a1236. Reason for revert: LUCI failure in libcore test Change-Id: I381b261ae0f67103bf1d096d8f64c84ba3f3e19c
2023-10-17Update class-table and intern-table concurrently with uffd GC Lokesh Gidra
Bug: 160737021 Test: art/testrunner/testrunner.py Change-Id: I4413ead05947f3f865116ae8dc7d67d860106b37
2023-02-01Reland "Write classes in runtime-generated app image." Nicolas Geoffray
This reverts commit 24b3d648ff6c2c200003f55ac63fc910d7bfd40f. Bug: 260557058 Reason for revert: - Encode class loader context in image, and check it at load time. - Set nterp entrypoint to methods that can. Test: test.py Test: atest com.android.bluetooth.opp.BluetoothOppObexServerSessionTest#onPut_withUnsupportedMimeTypeInHeader_returnsHttpBadRequest Change-Id: Ibf4a8604c4a226d1acc021103668e211446bb53c
2023-01-29Revert "Write classes in runtime-generated app image." Sam Saccone
This reverts commit df68c0a6f0d36728fa728049e5bcec20de2d0d5e. Reason for revert: b/267084527 Change-Id: I2eacf89c23db00c46d56e78009efa11bed31af60
2023-01-28Write classes in runtime-generated app image. Nicolas Geoffray
Test: 845-data-image Bug: 260557058 Change-Id: I640b78942984ac3d3f8d24abda619d78154acd86
2022-08-10Update native gc-roots separately in compaction pause Lokesh Gidra
The concurrent compaction algorithm requires all GC roots to be updated to post-compact addresses before resuming mutators for concurrent compaction. Therefore, unlike CC, we cannot update native roots in classes/dex-caches/class-loaders while visiting references (VisitReferences) on heap objects. This CL separates the two and updates all the gc-roots in the compaction pause. Bug: 160737021 Test: art/test/testrunner/testrunner.py Change-Id: I8a57472ba49b9dc30bc0f41a7db3f5efa7eafd9a
2022-04-21Move descriptor hashing to `mirror::Class`. Vladimir Marko
We may want to reuse the hashing for image classes which are not closely related with the `ClassTable` where the hashing was previously. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Bug: 181943478 Change-Id: Icf1b51085829509f58e7685dc1e9cf2b0583d107
2022-04-12dex2oat: Faster class pruning. Vladimir Marko
Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Bug: 181943478 Change-Id: I0f4facc13ded5e5a5755fe9bec1c32449049129a
2022-04-04Faster class descriptor hashing. Vladimir Marko
Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Bug: 181943478 Change-Id: I94612e8229b6d21abd51ade36ed88c1b5db77764
2022-02-17Avoid unnecessary read barriers in `ImageWriter`. Vladimir Marko
Also avoid visiting native roots during the same stages, namely layout and writing (including copy-and-fixup). Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Bug: 181943478 Change-Id: I0d62d67556109dbcbd8a04fd0e8408733dacce33
2021-07-14Modernize typedefs with `using`. Vladimir Marko
Replace many occurences of `typedef` with `using`. For now, do not update typedefs for function types and aligned types and do not touch some parts such as jvmti or dmtracedump. Test: m Change-Id: Ie97ecbc5abf7e7109ef4b01f208752e2dc26c36d
2021-06-22ART: Fix for no-opt debug (-O0) builds Stelios Ioannou
Currently, the build process of debug builds with no optimization fails due to missing symbol definitions. For example, it throws errors like the following one: ld.lld: error: undefined symbol: art::gc::collector::MarkSweep::MarkStackTask<false>::kMaxSize This patch changes the missing symbols from constants to constant expressions as a way to fix those issues. The optimized builds get away with this issue because the values are optimized to be inlined and not referenced. The code at https://godbolt.org/z/3oYKoPzGj depicts similar behaviour. Additionally, there are comments describing why this issue occurs. Test: ART_DEBUG_OPT_FLAG="-O0" art/tools/buildbot-build.sh --host Change-Id: I66b5cfc885dfdfc82e3e4008b1e40fd68c19c999
2021-04-28Remove some dead code around ClassTable. Vladimir Marko
Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Bug: 175869411 Change-Id: Ifb3ac102129470aff6eb228e5523b240c113818f
2021-02-08Avoid an unnecessary ComputeModifiedUtf8Hash(). Vladimir Marko
The DescriptorHashPair already has the hash as the member `second`, so avoid recalculating it in release mode. Also split "HashEquals" classes into separate "Hash" and "Equals" classes to disambiguate their operators in traces. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Bug: 175869411 Change-Id: I87cbe613778c7d310ba5c2bf437729244780472c
2021-01-19Rewrite class table construction in ImageWriter. Vladimir Marko
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
2019-05-08ObjPtr<>-ify ClassTable. Vladimir Marko
Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Bug: 31113334 Change-Id: Ieced7a452d381e5cacbafc91fd5d7672d9d92c30
2019-05-08Avoid some read barriers in ClassTable. Vladimir Marko
And clean up ClassTable. Test: m test-art-host-gtest Test: testrunner.py --host --interpreter Bug: 119486698 Change-Id: Ie413bc5a56eb548352ae1fed0976b75c44e0c0d4
2018-03-23ART: Simplify atomic.h Orion Hodson
Prefer std::atomic operations over wrappers in atomic.h. Exceptions are cases that relate to the Java data memory operations and CAS operations. Bug: 71621075 Test: art/test.py --host -j32 Test: art/test.py --target --64 -j4 Change-Id: I9a157e9dede852c1b2aa67d22e3e604a68a9ef1c
2018-03-13Fix dangling SingleImplementations left after class unloading Alexey Grebenkin
Test: make test-art-host, manual using sample code bug: 73143991 Change-Id: I4d56b39c69d4ed60266a8b90b9e9d18fba7b8227
2018-03-08Retrieve String/Class references from .data.bimg.rel.ro. Vladimir Marko
For PIC AOT-compiled app, use the .data.bimg.rel.ro to load the boot image String/Class references instead of using the mmapped boot image ClassTable and InternTable. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing --pictest --npictest Test: Pixel 2 XL boots. Test: testrunner.py --target --optimizing --pictest --npictest Bug: 71526895 Change-Id: Id5703229777aecb589a933a41f92e44d3ec02a3d
2017-11-08cpplint: Cleanup errors Igor Murashkin
Cleanup errors from upstream cpplint in preparation for moving art's cpplint fork to upstream tip-of-tree cpplint. Test: cd art && mm Bug: 68951293 Change-Id: I15faed4594cbcb8399850f8bdee39d42c0c5b956
2017-09-20Refactor linker files from compiler/ to dex2oat/. Vladimir Marko
This shifts some code from the libart-compiler.so to dex2oat and reduces memory needed for JIT. We also avoid loading the libart-dexlayout.so for JIT but the memory savings are minimal (one shared clean page, two shared dirty pages and some per-app kernel mmap data) as the code has never been needed in memory by JIT. aosp_angler-userdebug file sizes (stripped): lib64/libart-compiler.so: 2989112 -> 2671888 (-310KiB) lib/libart-compiler.so: 2160816 -> 1939276 (-216KiB) bin/dex2oat: 141868 -> 368808 (+222KiB) LOAD/executable elf mapping sizes: lib64/libart-compiler.so: 2866308 -> 2555500 (-304KiB) lib/libart-compiler.so: 2050960 -> 1834836 (-211KiB) bin/dex2oat: 129316 -> 345916 (+212KiB) Test: m test-art-host-gtest Test: testrunner.py --host Test: cd art/; mma; cd - Change-Id: If62f02847a6cbb208eaf7e1f3e91af4663fa4a5f
2017-09-11Use mmapped boot image class table for PIC app HLoadClass. Vladimir Marko
Implement new HLoadClass load kind for boot image classes referenced by PIC-compiled apps (i.e. prebuilts) that uses PC-relative load from a boot image ClassTable mmapped into the apps .bss. This reduces the size of the PIC prebuilts that reference boot image classes compared to the kBssEntry as we can completely avoid the slow path and stack map unless we need to do the class initialization check. Prebuilt services.odex for aosp_angler-userdebug (arm64): - before: 20312800 - after: 19775352 (-525KiB) Test: m test-art-host-gtest Test: testrunner.py --host Test: testrunner.py --host --pictest Test: testrunner.py --target on Nexus 6P. Test: testrunner.py --target --pictest on Nexus 6P. Test: Nexus 6P boots. Bug: 31951624 Change-Id: I13adb19a1fa7d095a72a41f09daa6101876e77a8
2017-07-28Use class unloading in dex2oat for verify and extract Mathieu Chartier
Unload the main classloader in between each dex file compilation to reduce RAM. This frees the whole java heap and associated linear allocs. This is only used for quickening since filters that do compilation may require loaded classes in the compiler and oat writer. This reduces dex2oat peak PSS for compiling a large app from 196MB to 135MB. Only works for verify and extract since the current approach is incompatible with oat writer patching. b/63911263 Added a verification override that reads the compiled class status to avoid ever verifying classes that were quickened (since this is not supported and causes failures). There is still some duplicated verification for some class with superclasses in other dex files. Support for quicken will be added in a follow up CL. Bug: 63467744 Test: test-art-host Test: test/testrunner/testrunner.py --interpreter --host -j40 Change-Id: Id0e4f84eb5db91d6143f752b498f4832a5b25b6e
2017-05-30ART: More header cleanup - runtime.h Andreas Gampe
Remove unnecessary runtime.h includes. Refactor other headers (move to forward declarations) to make this possible. Test: mmma art Change-Id: I297f0ad444ba92169edd16d8c7cbe95bb6dbb800
2017-03-29Refactor image writer Mathieu Chartier
Aim to have common functions for copying references and pointers. Required for adding support for faster image fixups. Test: test-art-host -j32 Bug: 34927277 Bug: 34928633 Change-Id: Ia654efc483b332eea3535570496bfeccd7c635ee
2017-03-14Revert^6 "Hash-based dex cache type array." Vladimir Marko
Fixed ImageWriter to write class table also if it contains only boot class loader classes. Added a regression test and added extra checks for debug-build to verify that dex cache types from app image are also in the class table. Removed some unnecessary debug output. Test: 158-app-image-class-table Bug: 34839984 Bug: 30627598 Bug: 34659969 This reverts commit 0b66d6174bf1f6023f9d36dda8538490b79c2e9f. Change-Id: I6a747904940c6ebc297f4946feef99dc0adf930c
2017-02-09Fix dex cache resolved types and class table mismatch. Vladimir Marko
Record class table in ClassLinker::DexCacheData and use it in DexCache.setResolvedType() to store the type also in the initiating loader's class table if the dex file has been registered. Also throw InternalError when trying to register the same DexFile with multiple class loaders. (Different DexFile instances referencing the same file are OK.) Test: 155-java-set-resolved-type Test: m test-art-host Bug: 30627598 Bug: 34193123 Bug: 34839984 Change-Id: Ia48acb300337c45880ea1459d2d32789546d67f4
2017-01-20Fix inserting classes to initiating loader's class table. Vladimir Marko
Fix two cases that were missed in https://android-review.googlesource.com/312285 First, copy all class references to app image class table, including boot image classes where the class loader used for AOT is only the initiating loader, not the defining loader. Second, add array classes to the initiating loader's class table. Without these fixes, ClassLinker::LookupResolvedType() was actually relying on the type being in the dex cache because in some cases the slow path would not be able to find it. Add a test for ClassLinker::LookupResolvedType() with an array type and fix that function to avoid null pointer dereference. Test: m test-art-host Bug: 30627598 Change-Id: I7cb14788700e6a22d16c364f8a35e2b6b3d954e4
2016-12-13Address some review comments Mathieu Chartier
Addressed comments in dex cache and class table. Added class table test. Test: mm test-art-host-gtest-class_table_test -j20 Change-Id: I3ec0282247187acb1ec7af25b309501f001a1c3e
2016-12-09Revert^8 "Make sure that const-class linkage is preserved." Vladimir Marko
Replaced two ReaderMutexLocks with WriterMutexLocks. Removed some unnecessary debugging output. Test: m test-art-host Bug: 30627598 Original-Change-Id: Ie9b721464b4e9a5dcce8df8095548e983bba1fe8 This reverts commit 2c8c6b63da6ecb2ac701cc30f9b4fa4a8eea5cc8. Change-Id: I3a1aeecf64e4b202cef61cceb248d48106a2f4a6
2016-12-06Reduce calls to DescriptorEquals Mathieu Chartier
Store the low 3 bits of the descriptor hash inside of class set entries. Compare these bits before comparing descriptors. Simpleperf interpret-only compile of facebook: mirror::Class::DescriptorEquals(char const*): 3.66% -> 1.03% Bug: 32641252 Test: test-art-host Change-Id: I8d898d4ac7c95383c49401fbcd85bfde226e026c
2016-12-01Revert "Make sure that const-class linkage is preserved, try again." Vladimir Marko
Reverting due to test failures as expected. Bug: 30627598 Bug: 33231647 This reverts commit cb5ab35980a86b05586c402924d2e7ca9df25758. Squashed revert "Additional debug logging for bug 33231647." This reverts commit 00a441033db28d243fc33692d30eb2755fa81728. Change-Id: I0c0ee1f70d47540fec99f8a797ce13571c16147c
2016-12-01Make sure that const-class linkage is preserved, try again. Vladimir Marko
This CL causes occasional test failures on the build servers which we were not able to reproduce locally. So we add some some additional debug output to help pinpoint the cause. Bug: 30627598 Bug: 33231647 Test: m test-art-host This reverts commit 171cf811a1cdf8b1cbc5151505d8630741ce4cf3. Change-Id: Id56a3f0e86e8212fd547e09c61794401bff47fb0
2016-11-29Revert "Revert "Revert "Revert "Revert "Make sure that const-class linkage ↵ Vladimir Marko
is preserved.""""" Bug: 30627598 This reverts commit e47172b75b8b04a450d235cf72bdc4e223a29cb5. Change-Id: I038029c71195a80f041982e82ae556d3157db7b8
2016-11-29Revert "Revert "Revert "Revert "Make sure that const-class linkage is ↵ Vladimir Marko
preserved."""" Avoid class loading triggered by verification in the 626-const-class-linking test. Expect spurious wakeups. Add extra debugging output for a very strange failure image_writer.cc:1144] Check failed: !IsBootClassLoaderClass(as_klass) java.lang.Class<java.lang.NoSuchMethodError> That class is supposed to be in the boot image (core.art for tests), so the failing check should not be reached at all. Test: m test-art-host Test: m ART_TEST_OPTIMIZING=true \ ART_TEST_JIT=true \ ART_TEST_INTERPRETER=true \ ART_TEST_INTERPRETER_ACCESS_CHECKS=true \ test-art-host-run-test-626-const-class-linking Bug: 30627598 This reverts commit 09ded9201fbeec605b12741ae255663c14bda225. Change-Id: I65a68cb53f0707b8abb3555ac3dc44c82907aef5
2016-11-24Revert "Revert "Revert "Make sure that const-class linkage is preserved.""" Vladimir Marko
626-const-class-linking is failing (spurious wakeups?) 970-iface-super-resolution-gen is failing: dex2oatd F 11-24 10:57:16 6410 6410 image_writer.cc:1144] Check failed: !IsBootClassLoaderClass(as_klass) java.lang.Class<java.lang.NoSuchMethodError> Bug: 30627598 This reverts commit 25dcbad4462ea7279ee2bbe0884abc25bdfac77a. Change-Id: Ie010169bdde45e6ccf2e04a521da4682bd817114
2016-11-23Revert "Revert "Make sure that const-class linkage is preserved."" Vladimir Marko
Fix jdwp getting multiple instances of the same class. Fix counting "zygote"/"non-zygote" classes in class table. Fix FindClass() to EnsureResolved() classes added by a racing thread to the class table. Test: m test-art-host Test: art/tools/run-jdwp-tests.sh --mode=host --variant=X64 --debug Bug: 30627598 This reverts commit ecffc67068a28d55d131553bf915fdb9fafbbc03. Change-Id: I15807949da4f163c2693fac2fbfc274f17685f8a
2016-11-16Change iftable to never be null Mathieu Chartier
Simplifies code generation by removing a null check. The null case is rare. Ritzperf code size: 13107624 -> 13095336 Also addressed comments from previous CL. Bug: 32577579 Test: test-art-host, run ritzperf both with CC Change-Id: I2b31e800867112869d7f0643e16c08826296979e
2016-10-25Revert "Disable kBssEntry LoadString sharpening." Vladimir Marko
Fix .bss GC root walking by registering the oat file with the class loader's class table. Also fix potentially outdated ObjPtr<> use in debug build. This reverts commit b55fdbb30b3bc4e334c241153b98c0a6ea4a4a2b. Test: m test-art-host Bug: 32124939 Change-Id: I0b7e3b93cb53c7b22408aa10a04eaf5582c69ee8
2016-10-19Move most of class linker to ObjPtr Mathieu Chartier
Return values are still mirror pointer. Fix some failing asserts in compiler driver and tests. Bug: 31113334 Test: test-art-host Change-Id: I4450bf9dfb2541749496b8388616e8aae8488919
2016-10-17Move art/native to ObjPtr Mathieu Chartier
Bug: 31113334 Test: test-art-host Change-Id: I67eb89cf042c762c6dcd5eb8b008b9a28e9b3319
2016-10-04Revert "Revert "Store resolved Strings for AOT code in .bss."" Vladimir Marko
Fixed oat_test to keep dex files alive. Fixed mips build. Rewritten the .bss GC root visiting and added write barrier to the artResolveStringFromCode(). Test: build aosp_mips-eng Test: m ART_DEFAULT_GC_TYPE=SS test-art-target-host-gtest-oat_test Test: Run ART test suite on host and Nexus 9. Bug: 20323084 Bug: 30627598 This reverts commit 5f926055cb88089d8ca27243f35a9dfd89d981f0. Change-Id: I07fa2278d82b8eb64964c9a4b66cb93726ccda6b
2016-09-23Smarter image layout Mathieu Chartier
Put strings in the dex file that resolves them. Depth first traversal with overrides for class and dex cache. The work list keeps track of what oat_index with each pushed item. This means the static fields of a class will usually be in the same image. Added layout test to image_test to make sure things are somewhat reasonably attributed. Bug: 28640955 Test: test-art-host (cherry picked from commit 4e9c4e746617bad6a012d799d2f5cf9e01d24ea2) Change-Id: I67a536c33aeed603b252d8e0f75622c9efbf2559
2016-08-30ART: SHARED_REQUIRES to REQUIRES_SHARED Andreas Gampe
This coincides with the actual attribute name and upstream usage. Preparation for deferring to libbase. Test: m Test: m test-art-host Change-Id: Ia8986b5dfd926ba772bf00b0a35eaf83596d8518
2016-06-06Revert "Revert "Hold dex caches live in class table"" Mathieu Chartier
Bug: 29083330 This reverts commit f102faf1bcbdb2149e3e7bf27b1819f621b7894b. Change-Id: Ibc6d260247b3113beec7d33552061512a36c9ce8