summaryrefslogtreecommitdiff
path: root/runtime/gc_root.h
AgeCommit message (Collapse)Author
2024-06-26Better document GcRoot Hans Boehm
Based on discussion with Nicolas and Lokesh. Test: Treehugger; comment-only change Change-Id: Ic58b2a3baf9c264174d1ee4aee7b409c16ea9f18
2024-01-17Add visibility attributes in runtime/g* Dmitrii Ishcheikin
Bug: 260881207 Test: presubmit Test: abtd app_compat_drm Test: abtd app_compat_top_100 Test: abtd app_compat_banking Change-Id: I88e6dbbd2d8f23fb211988df212749033d83313d
2023-02-09Fix mutator lock annotations for `nodes.cc`. Vladimir Marko
Allow constructing `GcRoot<>` and `ObjPtr<>` from null without holding the mutator lock. Mark `Object::GetLockOwnerThreadId()` as requiring the mutator lock. This allows compiling `nodes.cc` with a new version of clang++ with improved `-Wthread-safety-analysis`. Bug: 265153643 Test: Presubmit Change-Id: I186120216c7176d918ade0e55d77b481b6c70622
2023-01-16Clean up `ObjectReference<>` use with vreg values. Vladimir Marko
Clean up the object reference costructors and move the `AsVRegValue()` to the `CompressedReference<>`. Add `CompressedReference::FromVRegValue()` that can be used to convert vreg values back to references. Test: testrunner.py --host Test: m test-art-host-gtest Bug: 172332525 Change-Id: Id60618c0922b51591d0180bbe93e7ffabb598f56
2020-06-11Clean up generated operator<<(os, enum). Vladimir Marko
Pass enums by value instead of const reference. Do not generate operator<< sources for headers that have no enums or no declarations of operator<<. Do not define the operator<< for flag enums; these were unused anyway. Add generated operator<< for some enums in nodes.h . Change the operator<< for ComparisonBias so that the graph visualizer can use it but do not use the generated operator<< yet as that would require changing checker tests. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Change-Id: Ifd4c455c2fa921a9668c966a13068d43b9c6e173
2019-10-11Make bitmap constants more explicit. Florian Mayer
Test: build Change-Id: Iea6844929f10fd08fe1290ab67473e9134a20d10
2018-12-06ART: Move to using locks.h instead of mutex.h Andreas Gampe
When only annotating lock requirements, use locks.h. Bug: 119869270 Test: mmma art Change-Id: I1608b03254712feff0072ebad012c3af0cc3dda4
2018-08-28Use 'final' and 'override' specifiers directly in ART. Roland Levillain
Remove all uses of macros 'FINAL' and 'OVERRIDE' and replace them with 'final' and 'override' specifiers. Remove all definitions of these macros as well, which were located in these files: - libartbase/base/macros.h - test/913-heaps/heaps.cc - test/ti-agent/ti_macros.h ART is now using C++14; the 'final' and 'override' specifiers have been introduced in C++11. Test: mmma art Change-Id: I256c7758155a71a2940ef2574925a44076feeebf
2017-09-18ART: Move read barrier config out of globals Andreas Gampe
Reduce the global dependencies by refactoring where the read barrier constants are defined. Rename read_barier_c.h to read_barier_config.h and ifdef the C++ parts to have a common header for both C/asm and C++. Put heap poisoning configuration into its own minimal header. Fix up transitive includes. Test: m Change-Id: I159669ec61e3d1c4c7ddcd79e63b023a0519717a
2017-05-11Revert "Use IsMarked instead of Mark for profiling info." Nicolas Geoffray
Crashes in some configs. bug: 37693252 This reverts commit a30183dfe048cac0d53a0f07608c5f6fc516119a. Change-Id: I356d397a3f3e29fbef510f48c1c7633677ca5e78
2017-05-10Use IsMarked instead of Mark for profiling info. Nicolas Geoffray
The profiling info contains weak roots to classes, so don't Mark them in case a class gets unloaded. bug: 37693252 Test: test.py --jit Change-Id: Ida785ed49054f02f43474aebc780ec5b85371860
2017-02-22ART: Remove ObjPtr kPoison template parameter Andreas Gampe
Move to a global constexpr, so that object pointer poisoning can be explicitly turned off for lower debug build overhead. Bug: 35644797 Test: m Test: m test-art-host Change-Id: I2412b67cbec144f2aee206fb48591abe581fd00a
2016-12-12ART: Add precise root visiting Andreas Gampe
Add VisitRootFlags::kVisitRootFlagPrecise to signal a request for precise RootInfo objects. Move VisitRootFlags to gc_root.h. Refactor VisitRoot functions to pass flags. Add code in Thread visiting to decode vregs in compiled code. Bug: 31385354 Test: m test-art-host Change-Id: I8e7280f0ab682871f729f2a1c6b18670cf2dbf82
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-10-03Move ArtField to ObjPtr Mathieu Chartier
Added EXPECT_OBJ_PTR_EQ and variants to gtests. Fixed moving GC bugs in: ClassLinker::CreatePathClassLoader ClassLinkerTest: StaticFields ObjPtr Decode call sites: 186 -> 181. Some tests fail due to ResolvedFieldAccessTest, will fix in follow up CL. Bug: 31113334 Test: test-art-host CC baker Change-Id: I8b266ad00f3c20c8cbe7cfdf280d175083df0b88
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-08-09Card mark holding class instead of declaring class Mathieu Chartier
For profiling info, we need to mark the card of the holding class instead of declaring class. This is required for GC correctness since the GC relies on the card table to track cross space references. Test: test-art-host ART_TEST_JIT=true Bug: 30655270 Change-Id: Ia4690219ded0df38032b644440273e06bc303956
2015-11-15x86/x86-64 read barrier support for concurrent GC in Optimizing. Roland Levillain
This first implementation uses slow paths to instrument heap reference loads and GC root loads for the concurrent copying collector, respectively calling the artReadBarrierSlow and artReadBarrierForRootSlow (new) runtime entry points. Notes: - This implementation does not instrument HInvokeVirtual nor HInvokeInterface instructions (for class reference loads), as the corresponding read barriers are not stricly required with the current concurrent copying collector. - Intrinsics which may eventually call (on slow path) are disabled when read barriers are enabled, as the current slow path infrastructure does not support this case. - When read barriers are enabled, the code generated for a HArraySet instruction always go into the array set slow path for object arrays (delegating the operation to the runtime), as we are lacking a mechanism to keep a temporary register live accross a runtime call (needed for the instrumentation of type checking code, which requires two successive read barriers). Bug: 12687968 Change-Id: I14cd6107233c326389120336f93955b28ffbb329
2015-09-04Make class loaders weak roots Mathieu Chartier
Making the class loaders weak roots in the class linker prevents them from keeping the classes as live. However we currently do mark them as strong roots to make sure no accidental class unloading occurs until the logic to free from linear alloc is complete. Bug: 22720414 Change-Id: I57466236d9ce6fd064dda9a30ce8ab68094fb8b0
2015-07-22Move to newer clang annotations Mathieu Chartier
Also enable -Wthread-safety-negative. Changes: Switch to capabilities and negative capabilities. Future work: Use capabilities to implement uninterruptible annotations to work with AssertNoThreadSuspension. Bug: 20072211 Change-Id: I42fcbe0300d98a831c89d1eff3ecd5a7e99ebf33
2015-06-22Restore DDMS recent allocation tracking's behavior Man Cao
Make the allocation tracker mark recently allocated objects as roots, so the allocation records are not swept. Because DDMS needs recent allocation tracking records even for dead objects. This should fix the flaky failures for 098-ddmc test, but it cannot pass GC stress test (OOM). Re-enabled 098-ddmc for other tests. There should be an option to not mark them as roots, when user only needs HPROF dump with traces but not DDMS's recent allocation tracking. Probably need to add a new JNI API function for this option. There could be another way to keep a second list of recent allocation records and maintain a type cache for them, so not to make the objects roots. But it's more complex, and not sure which is better. Also reduce memory usage for AllocRecordStackTrace objects, and change default stack depth to 16. Rename the property that controls the stack depth to "debug.allocTracker.maxStackDepth" so developer can change it. Bug:20037135 Change-Id: Ic6b9ae87bdcda558be6f14ded8057e763439881c
2015-06-15Print more diagnosis info on to-space invariant violation. Hiroshi Yamauchi
Pass the method/field (in GcRootSource) to the read barrier to print more info when a to-space invariant violation is detected on a method/field GC root access. Refactor ConcurrentCopying::AssertToSpaceInvariant(). Bug: 12687968 Bug: 21564728 Change-Id: I3a5fde1f41969349b0fee6cd9217b948d5241a7c
2015-04-14Fix valgrind tests Mathieu Chartier
Delete large objects in space destructor. Also some cleanup. Change-Id: I4c4e90149841a156b7a3236201b37683e14890fb
2015-04-13Fix DCHECK failures from Class::VisitFieldRoots Mathieu Chartier
We now use GetDeclaringClassUnchecked when marking roots to fix flaky test failures. Fixed a race condition in root marking where we could have non zero field array length with a null pointer. Fixed a race condition where we could be marking roots before FixupTemporaryDeclaringClass had finished. The solution is to only do the declaring class CHECK if we are at least resolved. Fixed JDWP tests by changing FieldId / MethodId to be 64 bits. Also some cleanup. Change-Id: Ibac09519860d93c3f68a5cc964bbc91dc10a279a
2015-04-07Fix CC root visiting bug Mathieu Chartier
Also some cleanup. Change-Id: Ia3de8f2d409770be3619ec116e8b06ecd82338fe
2015-04-06ART: Enable Clang's -Wdeprecated Andreas Gampe
Replace throw() with noexcept. Add default copy constructors and copy assignment constructors for cases with destructors, as the implicit definition is deprecated. Change-Id: Ice306a3f510b072b00bec4d4360f7c8055135c9d
2015-04-06Refactor and improve GC root handling Mathieu Chartier
Changed GcRoot to use compressed references. Changed root visiting to use virtual functions instead of function pointers. Changed root visting interface to be an array of roots instead of a single root at a time. Added buffered root marking helper to avoid dispatch overhead. Root marking seems a bit faster on EvaluateAndApplyChanges due to batch marking. Pause times unaffected. Mips64 is untested but might work, maybe. Before: MarkConcurrentRoots: Sum: 67.678ms 99% C.I. 2us-664.999us Avg: 161.138us Max: 671us After: MarkConcurrentRoots: Sum: 54.806ms 99% C.I. 2us-499.986us Avg: 136.333us Max: 602us Bug: 19264997 Change-Id: I0a71ebb5928f205b9b3f7945b25db6489d5657ca
2015-02-23Avoid unaligned accesses (SIGBUG/BUS_ADRALN) in IRT. Hiroshi Yamauchi
Pointers in IrtEntry aren't currently aligned under 64 bit builds. But unaligned atomic stores (store exclusive) do not work on arm64 (causes SIGBUG/BUS_ADRALN). Fix CC collector crashes caused by this. Bug: 12687968 Change-Id: I1d2f5376778a9a1e5cfea876f1f57d7a88ad5445
2015-01-15Print more info in MarkSweep::VerifyRoot Mathieu Chartier
Refactored old root callback to use a new class called RootInfo. RootInfo contains all the relevant info related to the root associated with the callback. The MarkSweep::VerifyRoot function now uses this info to print the StackVisitor's described location if the GC root is of the type kRootJavaFrame. Some other cleanup. Example output: E/art (12167): Tried to mark 0x123 not contained by any spaces E/art (12167): Attempting see if it's a bad root E/art (12167): Found invalid root: 0x123 with type RootJavaFrame E/art (12167): Location=Visiting method 'void java.lang.Runtime.gc()' at dex PC 0xffffffff (native PC 0x0) vreg=0 (cherry picked from commit 12f7423a2bb4bfab76700d84eb6d4338d211983a) Bug: 18588862 Change-Id: Ic5a2781f704e931265ffb3621c2eab4b2e25f60f
2014-11-06Add hash set Mathieu Chartier
More memory efficient than libcxx since we do not box the values. Change intern table to use new hash set. Clean up intern table by removing const casts and deleting unnecessary code. Changed the class linker to use a hash set, also added a pre-zygote class table. 5 samples of: adb shell stop && adb shell start && sleep 60 && adb shell dumpsys meminfo Before: 165929 kB: Native 175859 kB: Native 168434 kB: Native 166559 kB: Native 169958 kB: Native After: 160972 kB: Native 159439 kB: Native 157204 kB: Native 165093 kB: Native 163039 kB: Native TODO: Add HashTable which is implemented by using a HashSet. TODO: Use for DexFile::find_class_def_misses_. TODO: Investigate using mem maps instead of native heap. Bug: 17808975 Change-Id: I93e376cf6eb9628cf52f4aefdadb6157acfb799a (cherry picked from commit e05d1d5fd86867afc7513b1c546375dba11eee50)
2014-11-03Add image strings to intern table Mathieu Chartier
When we create the runtime, we now add the image strings to the intern table if we are the zygote. This caused some memory bloat, so I added an extra unordered set to the intern table. There is now two unordered sets (hash talbe). One for pre-zygote interns and one for post-zygote interns. This helps since the pre-zygote hash table doesn't get dirtied. Even with adding the image strings, we get total memory savings of around 5-7 MB native PSS after device boot. FB launch Before: 2.20% art::DexFile::FindStringId(char const*) const TotalTime: 2069 TotalTime: 1985 TotalTime: 2088 TotalTime: 2003 TotalTime: 2034 TotalTime: 2049 After boot native PSS: 175585 kB: Native After: 0.27% art::DexFile::FindStringId(char const*) const TotalTime: 1682 TotalTime: 1756 TotalTime: 1825 TotalTime: 1751 TotalTime: 1666 TotalTime: 1813 After boot native PSS: 167089 kB: Native Bug: 18054905 Bug: 16828525 Bug: 17808975 (cherry picked from commit b6e292bf7eac9d73c6b79b1e9b7b87beb02436c9) Change-Id: Ie367f3222f8c4db409ec49c3845276908b51e9c9
2014-09-02Add missing read barriers to intern table. Mathieu Chartier
Also deleted GcRoot::Assign. Change-Id: Ib1ea739cf79c72fc92a8628cd9095c11b660e018
2014-09-02Change intern table to unordered set. Mathieu Chartier
Intern table active used bytes goes from 430k to 317k on system server. Similar %wise savings on other apps. Bug: 16238192 (cherry picked from commit d910fcef539e12ab181e56ec80684f39c4e95733) Change-Id: Ic70395124435c6f420a77e6d8639404a160f395a
2014-08-29Add native memory accounting through custom allocator. Mathieu Chartier
Added a custom allocator that lets you pass in a special tag which specifices where the allocation came from. This is used when dumping. The performance overhead is low since each allocation only does a atomic add/sub for each allocation/free. The measurements are dumped to traces.txt during SIGQUIT. Example output: I/art (27274): AllocatorTagHeap active=120 max=120 total=168 I/art (27274): AllocatorTagMonitorList active=1572 max=6240 total=11724 I/art (27274): AllocatorTagClassTable active=185208 max=185208 total=268608 I/art (27274): AllocatorTagInternTable active=430368 max=430368 total=436080 I/art (27274): AllocatorTagMaps active=5616 max=6168 total=34392 I/art (27274): AllocatorTagLOS active=1024 max=1536 total=2044 I/art (27274): AllocatorTagSafeMap active=0 max=51936 total=533688 I/art (27274): AllocatorTagLOSMaps active=144 max=1248 total=5760 I/art (27274): AllocatorTagReferenceTable active=10944 max=11840 total=19136 I/art (27274): AllocatorTagHeapBitmap active=32 max=40 total=56 I/art (27274): AllocatorTagHeapBitmapLOS active=8 max=8 total=8 I/art (27274): AllocatorTagVerifier active=0 max=18844 total=1073156 I/art (27274): AllocatorTagModUnionCardSet active=5300 max=5920 total=56020 I/art (27274): AllocatorTagModUnionReferenceArray active=24864 max=24864 total=24864 I/art (27274): AllocatorTagJNILibrarires active=320 max=320 total=320 I/art (27274): AllocatorTagOatFile active=1400 max=1400 total=5852 Change-Id: Ibb470ef2e9c9a24563bb46422d46a55799704d82 (cherry picked from commit 5369c40f75fdcb1be7a7c06db212ce965c83a164)
2014-07-29Add GcRoot to clean up and enforce read barriers. Hiroshi Yamauchi
Introduce a value-type wrapper around Object* for GC roots so that 1) we won't have to directly add the read barrier code in many places and 2) we can avoid accidentally bypassing/missing read barriers on GC roots (the GcRoot interface ensures that the read barrier is executed on a read). The jdwp test passed. Bug: 12687968 Change-Id: Ib167c7c325b3c7e3900133578815f04d219972a1