summaryrefslogtreecommitdiff
path: root/runtime/scoped_thread_state_change.h
AgeCommit message (Collapse)Author
2024-01-31Add visibility attributes in runtime/s* Dmitrii Ishcheikin
Bug: 260881207 Test: presubmit Test: abtd app_compat_drm Test: abtd app_compat_top_100 Test: abtd app_compat_banking Change-Id: Ib074e7b5ab0725fea5640ed7deaac3452fc27864
2021-11-25Always access Thread state and flags as 32-bit location. Vladimir Marko
Rewrite access to Thread's state and flags to use 32-bit atomic operations. Avoid `volatile` accesses that prevent compiler optimizations. Change `ThreadState` and `ThreadFlag` to `enum class`es. Golem results for art-opt-cc (higher is better): linux-ia32 before after NativeDowncallStaticNormal 28.162 35.323 (+25.43%) NativeDowncallStaticNormal6 26.447 32.951 (+24.59%) NativeDowncallStaticNormalRefs6 NativeDowncallVirtualNormal 27.972 35.027 (+25.22%) NativeDowncallVirtualNormal6 26.096 32.131 (+23.13%) NativeDowncallVirtualNormalRefs6 25.922 31.873 (+22.95%) linux-x64 before after NativeDowncallStaticNormal 26.987 34.380 (+27.40%) NativeDowncallStaticNormal6 25.424 31.096 (+22.31%) NativeDowncallStaticNormalRefs6 25.086 30.602 (+21.99%) NativeDowncallVirtualNormal 26.812 33.234 (+23.95%) NativeDowncallVirtualNormal6 25.086 30.617 (+22.05%) NativeDowncallVirtualNormalRefs6 25.086 30.602 (+21.99%) linux-armv7 before after NativeDowncallStaticNormal 7.2394 7.9523 (+9.848%) NativeDowncallStaticNormal6 6.8527 7.4888 (+9.283%) NativeDowncallStaticNormalRefs6 6.3976 6.9444 (+8.547%) NativeDowncallVirtualNormal 7.2081 7.9130 (+9.779%) NativeDowncallVirtualNormal6 6.8527 7.4888 (+9.283%) NativeDowncallVirtualNormalRefs6 6.3168 6.8527 (+8.483%) linux-armv8 before after NativeDowncallStaticNormal 7.0389 7.5973 (+7.933%) NativeDowncallStaticNormal6 6.8527 7.3783 (+7.670%) NativeDowncallStaticNormalRefs6 6.2924 6.8226 (+8.427%) NativeDowncallVirtualNormal 6.8527 7.3783 (+7.670%) NativeDowncallVirtualNormal6 6.5604 7.0423 (+7.344%) NativeDowncallVirtualNormalRefs6 6.1408 6.5329 (+6.386%) Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Test: run-gtests.sh Test: testrunner.py --target --optimizing --interpreter Bug: 172332525 Bug: 143299880 Change-Id: Ib55d457ad8f5d9e1159b681dfd279d1f9cfb2af7
2019-07-24ART: Fix ScopedThreadStateChange assert Andreas Gampe
Ensure that an early abort will not trigger a nested (infinite) failure. Also move the check into the body to avoid polluting the header with a very uncommon case. Test: mmma art Test: manual (run-test with 1.5GB heap) Change-Id: I85e7a5ba2e01d1762ffc5c264eee20a0c81c0b7f
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
2017-12-22Extensions to check JNI. Ian Rogers
Ensure critical lock isn't held when returning from a down-call. Log a warning if the critical lock is held for a significant period of time. Refactor JNIEnvExt to be a class rather than a struct. Test: mma test-art-host Change-Id: I4d149cb04d3a7308a22b92b196e51e2f1ae17ede
2017-04-21ART: Add object-readbarrier-inl.h Andreas Gampe
Move some read-barrier code into a new header. This prunes the include tree for the concurrent-copying collector. Clean up other related includes. Test: mmma art Change-Id: I40ce4e74f2e5d4c692529ffb4df933230b6fd73e
2017-03-08Inlining a few small methods based on profiling dex2oat with perf. Mingyao Yang
Test: m test-art-host Change-Id: I6313158e59592d8d132154523be9c82dda3c7eb8
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
2017-02-03ART: Refactor verify_object.h Andreas Gampe
Move the actual VerifyObject check into a new cc file, as we commonly don't enable the check at all. This allows to cut the -inl include from almost all current users. This also exposes missing -inl includes. Also fix up some of our old mess where .h defined functions require -inl.h defined functions. Test: m Change-Id: I3dd821bbe2015564a29bf1ed9be00f7a7276ad61
2016-11-08ART: Refactor jfieldID handling Andreas Gampe
ArtField objects have been native since Marshmallow. Remove the dependency on being runnable. Refactor the code into the jni_internal header. Test: m test-art-host Change-Id: I46708c70f9b4b566d7e26e4c5ffc3f0cbadc43fa
2016-11-07ART: Refactor jmethodID handling Andreas Gampe
ArtMethod objects have been native since Marshmallow. Remove the dependency on being runnable. Refactor the code into the jni_internal header. Test: m test-art-host Change-Id: I1385fcd4c08981491701da55a87036b447aa2fc2
2016-10-05Change indirect reference table to use ObjPtr Mathieu Chartier
Bug: 31113334 Test: test-art-host Change-Id: I340fdf430897ebd790ea4e35f94bcee776e98445
2016-09-29Clean up ScopedThreadStateChange to use ObjPtr Mathieu Chartier
Also fixed inclusion of -inl.h files in .h files by adding scoped_object_access-inl.h and scoped_fast_natvie_object_access-inl.h Changed AddLocalReference / Decode to use ObjPtr. Changed libartbenchmark to be debug to avoid linkage errors. Bug: 31113334 Test: test-art-host Change-Id: I4d2e160483a29d21e1e0e440585ed328b9811483
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
2015-09-03Add ScopedThreadSuspension Mathieu Chartier
Fixes the TransitionFromRunnableToSuspended and TransitionFromSuspendedToRunnable pattern that was prone to errors. Change-Id: Ie6ae9c0357c83b4fc4899d05dfa0975553170267
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-05-29Move mirror::ArtMethod to native Mathieu Chartier
Optimizing + quick tests are passing, devices boot. TODO: Test and fix bugs in mips64. Saves 16 bytes per most ArtMethod, 7.5MB reduction in system PSS. Some of the savings are from removal of virtual methods and direct methods object arrays. Bug: 19264997 Change-Id: I622469a0cfa0e7082a2119f3d6a9491eb61e3f3d
2015-05-08Check IsReferenceVReg during deopt Mathieu Chartier
Required since the quick GC maps may not agree with the verifier ones. Without this check we may copy stale object references into the shadow frame. (cherry picked from commit f00baf56ef647684888a407dbb6adadd704a2039) Bug: 20736048 Change-Id: I7783c8a8ee45cf601b08b4c38f1dec7f7d11380c
2015-05-04Delete invalid DCHECK Mathieu Chartier
We can have large objects mapped at address 0xebad____. Change-Id: I9e27d4948e7e853b4af6eb1b36dbfec6d4d7a99a
2015-04-22Replace NULL with nullptr Mathieu Chartier
Also fixed some lines that were too long, and a few other minor details. Change-Id: I6efba5fb6e03eb5d0a300fddb2a75bf8e2f175cb
2015-04-10Move ArtField to native Mathieu Chartier
Add linear alloc. Moved ArtField to be native object. Changed image writer to put ArtFields after the mirror section. Savings: 2MB on low ram devices 4MB on normal devices Total PSS measurements before (normal N5, 95s after shell start): Image size: 7729152 bytes 23112 kB: .NonMoving 23212 kB: .NonMoving 22868 kB: .NonMoving 23072 kB: .NonMoving 22836 kB: .NonMoving 19618 kB: .Zygote 19850 kB: .Zygote 19623 kB: .Zygote 19924 kB: .Zygote 19612 kB: .Zygote Avg: 42745.4 kB After: Image size: 7462912 bytes 17440 kB: .NonMoving 16776 kB: .NonMoving 16804 kB: .NonMoving 17812 kB: .NonMoving 16820 kB: .NonMoving 18788 kB: .Zygote 18856 kB: .Zygote 19064 kB: .Zygote 18841 kB: .Zygote 18629 kB: .Zygote 3499 kB: .LinearAlloc 3408 kB: .LinearAlloc 3424 kB: .LinearAlloc 3600 kB: .LinearAlloc 3436 kB: .LinearAlloc Avg: 39439.4 kB No reflection performance changes. Bug: 19264997 Bug: 17643507 Change-Id: I10c73a37913332080aeb978c7c94713bdfe4fe1c
2015-01-23More of the concurrent copying collector. Hiroshi Yamauchi
Bug: 12687968 Change-Id: I62f70274d47df6d6cab714df95c518b750ce3105
2014-08-08Wire up check JNI force copy mode. Ian Rogers
Increase check JNI checks. Break apart jni_internal.h in to jni_env_ext.h and java_vm_ext.h. Fix the abuse of ScopedObjectAccess/annotalysis by ScopedCheck in the case of VM routines. Make class loader override and shared library class loader JNI global references rather than mirror pointers. Clean-ups to native bridge. Change-Id: If7c6110b5aade7a402bfb67534af86a7b2cdeb55
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
2014-06-20Add more read barriers for JNI roots. Hiroshi Yamauchi
To make it possible to concurrently scan the JNI global roots (that is, the roots visited by JavaVMExt::VisitRoots()), add read barriers to the indirect reference table and the reference table. Also, add read barriers to the jmethodID/jfieldID decode routines (ScopedObjectAccessAlreadyRunnable::DecodeField/DecodeMethod) so that we can concurrently handle (encoded) fields and methods. Bug: 12687968 Change-Id: I3df4e4e622a572ff0ea8d44b2dc70a4d6b3ba058
2014-06-06Reduce header files including header files. Ian Rogers
Main focus is getting heap.h out of runtime.h. Change-Id: I8d13dce8512816db2820a27b24f5866cc871a04b
2014-05-19Don't get and restore thread state for ScopedFastNativeObjectAccess. Mathieu Chartier
Before we would ensure that we were runnable for fast native object access. However, these are done when you are already runnable. Change-Id: Ia4c6e4c83d146fe2a988b37b3133ca46b0f0fa42
2014-05-13Add Handle/HandleScope and delete SirtRef. Mathieu Chartier
Delete SirtRef and replaced it with Handle. Handles are value types which wrap around StackReference*. Renamed StackIndirectReferenceTable to HandleScope. Added a scoped handle wrapper which wraps around an Object** and restores it in its destructor. Renamed Handle::get -> Get. Bug: 8473721 Change-Id: Idbfebd4f35af629f0f43931b7c5184b334822c7a
2014-04-24Clean up ScopedThreadStateChange + Get/SetPrimtiveArrayRegion Mathieu Chartier
Simplified code in ScopedThreadStateChange and fixed an incorrect name in Get/SetPrimitiveArrayRegion. Change-Id: Id71affec1d64911449d792911cd52104dd179840
2014-04-22Remove support for app JNI workarounds. Ian Rogers
Change-Id: I4396df7e93fcace4b5b19c2c387e5c30089182a6
2014-03-14Refactor reflective method invocation. Ian Rogers
Move invocation code out of JNI internal into reflection, including ArgArray code. Make reflective invocation use the ArgArray to build arguments rather than allocating a jvalue[] and unboxing arguments into that. Move reflection part of jni_internal_test into reflection_test. Make greater use of fast JNI. Change-Id: Ib381372df5f9a83679e30e7275de24fa0e6b1057
2014-03-07Add more VerifyObject calls. Mathieu Chartier
Added verify object calls to SirtRef, IndirectReferenceTable, ReferenceTable. Removed un-needed verify object in ScopedObjectAccess / DecodeJObject since object sources are handled. Bug: 12934910 Change-Id: I55a46a8ea61fed2a77526eda27fd2cce97a9b125
2014-02-24Avoid std::string allocations for finding an array class. Ian Rogers
Introduce ClassLinker::FindArrayClass which performs an array class lookup given the element/component class. This has a 16 element cache of recently looked up arrays. Pass the current thread to ClassLinker Find .. Class routines to avoid calls to Thread::Current(). Avoid some uses of FindClass in the debugger where WellKnownClasses is a faster and more compacting GC friendly alternative. Change-Id: I60e231820b349543a7edb3ceb9cf1ce92db3c843
2014-02-21Fix and optimize verify object. Mathieu Chartier
VerifyObject no longer resides in heap. You can now enable VerifyObject for non-debug builds. VerifyStack is still slow, so it is now guarded by its own flag. Fixed the image writer to not use verification at places where verification fails due to invalid reads. Fixed RosAlloc to use SizeOf which doesn't call verify object. Added a flag paremeter to some of the mirror getters / setters to be able to selectively disable VerifyObject on certain calls. Optimized the GC to not verify each object multiple times during object scanning if verify object is enabled. Added 3 verification options: verify reads, verify this, and verify writes so that you can select how much verification you want for mirror getters and setters. Removed some useless DCHECKs which would slow debug builds without providing any benefits. TODO: RosAlloc verification doesn't currently work with verify objects. Bug: 12934910 Bug: 12879358 Change-Id: Ic61033104dfc334543f89b0fc0ad8cd4f4015d69
2013-11-11Compacting collector. Mathieu Chartier
The compacting collector is currently similar to semispace. It works by copying objects back and forth between two bump pointer spaces. There are types of objects which are "non-movable" due to current runtime limitations. These are Classes, Methods, and Fields. Bump pointer spaces are a new type of continuous alloc space which have no lock in the allocation code path. When you allocate from these it uses atomic operations to increase an index. Traversing the objects in the bump pointer space relies on Object::SizeOf matching the allocated size exactly. Runtime changes: JNI::GetArrayElements returns copies objects if you attempt to get the backing data of a movable array. For GetArrayElementsCritical, we return direct backing storage for any types of arrays, but temporarily disable the GC until the critical region is completed. Added a new runtime call called VisitObjects, this is used in place of the old pattern which was flushing the allocation stack and walking the bitmaps. Changed image writer to be compaction safe and use object monitor word for forwarding addresses. Added a bunch of added SIRTs to ClassLinker, MethodLinker, etc.. TODO: Enable switching allocators, compacting on background, etc.. Bug: 8981901 Change-Id: I3c886fd322a6eef2b99388d19a765042ec26ab99
2013-10-20Fast JNI support. Ian Rogers
Use a modifier to signal a native method is a fast JNI method. If the modifier is set then don't perform runnable transitions. Change-Id: I7835b4d837bfdd1cb8e2d54b919c0d5e6cf90499
2013-09-20Re-enable concurrent system weak sweeping. Mathieu Chartier
Enabled by disallowing new system weaks during the pause and re-allowing it after the system weaks have been swept. Reduces GC pause by ~1ms. Fixes pause regression caused by fix for Bug: 10626133 Change-Id: If49d33e7ef19cb728ed3cef5187acfa53b9b05d8
2013-08-13Refactor java.lang.reflect implementation Brian Carlstrom
Cherry-picked from commit ed41d5c44299ec5d44b8514f6e17f802f48094d1. Move to ArtMethod/Field instead of AbstractMethod/Field and have java.lang.reflect APIs delegate to ArtMethod/ArtField. Bug: 10014286. Change-Id: Iafc1d8c5b62562c9af8fb9fd8c5e1d61270536e7
2013-07-29Fix NewLocalRef to use AddLocalReference. Elliott Hughes
Bug: 10026664 Change-Id: I06f8f75a92f73b3b58fa767c0d08d1b736f7d5b5
2013-07-26Fix cpplint whitespace/comments issues Brian Carlstrom
Change-Id: Iae286862c85fb8fd8901eae1204cd6d271d69496
2013-07-17Fix multiple inclusion guards to match new pathnames Brian Carlstrom
Change-Id: Id7735be1d75bc315733b1773fba45c1deb8ace43
2013-07-12Create separate Android.mk for main build targets Brian Carlstrom
The runtime, compiler, dex2oat, and oatdump now are in seperate trees to prevent dependency creep. They can now be individually built without rebuilding the rest of the art projects. dalvikvm and jdwpspy were already this way. Builds in the art directory should behave as before, building everything including tests. Change-Id: Ic6b1151e5ed0f823c3dd301afd2b13eb2d8feb81