summaryrefslogtreecommitdiff
path: root/runtime/thread_state.h
AgeCommit message (Collapse)Author
2024-03-16Do not handle suspension request in StartGC Hans Boehm
Switching back to kRunnable state while appearing to be running a collection can lead to deadlock. Don't do that. Unfortunately, StartGC is one of several functions in this area that can be called with or without the mutator lock, complicating matters. We implement this by adding a ThreadState value, so we don't need two clones of TransitionFromRunnableToSuspended. This required trivial updates to various unrelated switch statements to handle the new case. Add some checking for kSuspensionImmune abuses. (An earlier attempt tried to use that here.) Bug: 304929145 Test: Treehugger Change-Id: Id5e16fef3255ff243c4e7e306762ababd8cf2f70
2024-02-01Add visibility attributes in runtime/t* Dmitrii Ishcheikin
Bug: 260881207 Test: presubmit Test: abtd app_compat_drm Test: abtd app_compat_top_100 Test: abtd app_compat_banking Change-Id: I6fbc1fac734c772b28bef6258cbd90982a344d6f
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
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-05-15Add thread state descriptive comment Hans Boehm
I would have found this comment helpful while investigating the bug below. Bug: 113361290 Test: Treehugger Change-Id: Ibb4299f4e9c08f9561db42ffeeec296b869fb416
2019-03-27Revert "Revert "Change state to waiting during aborting the VM"" Koji Fukui
This reverts commit ebb481d070e3fdbb7950580e6f6886c3231a1ad9. Dex2oatWatchdogTest.TestWatchdogTrigger passed. Apply the change again. Test: ART_HEAP_POISONING=true make test-art-host-gtest-dex2oat_test64 Bug: 127875380 Change-Id: If4326990cd612815ffe1511490712ca8babfec55
2019-03-19Revert "Change state to waiting during aborting the VM" Nicolas Geoffray
This reverts commit 97b964960123d5f215a1cebbce548c8a5322c307. Bug: 127875380 Reason for revert: Broke Dex2oatWatchdogTest.TestWatchdogTrigger on host x86_64 and heap poisoning. Change-Id: Iaebfc4a03543bff4e7239d711dd7ad8c7f880d52
2019-03-18Change state to waiting during aborting the VM Koji Fukui
Symptom: Process freeze when multiple runtime error happen on runnable threads. Root cause: When multiple runtime error happen, only one thread locks abort_lock_ and other threads are blocked even if they are runnable state. If an other thread tries to suspend blocked threads at the same time, blocked threads can't be suspended until abort_lock_ is unlocked from owner thread. But owner thread can be suspended even if it locks abort_lock_. Thus, these threads causes dead lock. Solution: Change state to waiting when locking abort_lock_. Bug: 127875380 Change-Id: I7e914924690bb30d6d0490cf5f8afdb1c3cd4e4a
2019-01-09ART: Use iosfwd more Andreas Gampe
Use iosfwd where an include of ostream is unnecessary. Also move callee_save_type.h to runtime. Bug: 119869270 Test: mmma art Change-Id: Id8995d6f524e4c491eb6f57fdffb940cf35d291f
2017-09-14Add support for JVMTI monitor events. Alex Light
Adds support for the JVMTI can_generate_monitor_events capability and all associated events. This adds support for the JVMTI_EVENT_MONITOR_WAIT, JVMTI_EVENT_MONITOR_WAITED, JVMTI_EVENT_MONITOR_CONTENDED_ENTER, and JVMTI_EVENT_MONITOR_CONTENDED_ENTERED events. Bug: 65558434 Bug: 62821960 Bug: 34415266 Test: ./test.py --host -j50 Change-Id: I0fe8038e6c4249e77d37a67e5056b5d2a94b6f48
2015-08-27Synchronize JNI critical calls with the CC collector thread flip. Hiroshi Yamauchi
JNI critical calls (like GetArrayElementsCritical) would need to block for the whole GC run to finish if the CC collector GC is ongoing. This CL changes it so that they don't need to block for the GC run, but only for the duration of the thread flip operation, which is much shorter. This is valid due to the to-space invariant. Bug: 12687968 Bug: 19235243 Change-Id: I1b6b4ae4fa539ddc0ec50b10ae8c8709f2a12fe8
2015-08-04Address some comments and clean up Mathieu Chartier
Change-Id: I538cf204f1c89d5fc81f8fc5e5800fcf1cf87359
2015-07-17Change intern table to not use WaitHoldingLocks Mathieu Chartier
Bug: 22423014 Change-Id: I9e16b8cb4def72fff73f1783a182877105feb7aa
2015-05-12Hold heap bitmap lock in Heap::GetObjectsAllocated Mathieu Chartier
Fixes a race condition where add and remove space could cause a crash when we iterated over the spaces. TODO: Add a spaces lock or something to guard against this. (cherry picked from commit a395c0a492079d86b312c9edc796d63001576954) Bug: 21031927 Change-Id: I7f0d558316f8e9d9f22ffd182e8666355bf50d47
2015-01-20Clean up the locks around Heap::VisitObjects(). Hiroshi Yamauchi
This is so that we could support suspending all threads when visiting objects in the presence of a concurrent, moving collector. Bug: 12687968 Change-Id: Icc8e60630465afde948ebc6ea91d4ebaff5d7837
2014-11-03Remove -Wno-unused-parameter and -Wno-sign-promo from base cflags. Ian Rogers
Fix associated errors about unused paramenters and implict sign conversions. For sign conversion this was largely in the area of enums, so add ostream operators for the effected enums and fix tools/generate-operator-out.py. Tidy arena allocation code and arena allocated data types, rather than fixing new and delete operators. Remove dead code. Change-Id: I5b433e722d2f75baacfacae4d32aef4a828bfe1b
2014-07-09Fix method tracing from command-line Sebastien Hertz
Transitions current thread to the new kWaitingForMethodTracingStart thread state when starting method tracing. Ensures there is a current thread when method tracing is stopped due to runtime shutdown. If the current thread has been detached, we now re-attach it. Note: we only do this if method tracing has been activated from command-line. Fixes instrumentation when forcing interpreter mode (-Xint) with method tracing enabled. Removes unused parameter from UnsafeLogFatalForThreadSuspendAllTimeout. Bug: https://code.google.com/p/android/issues/detail?id=72094 Bug: 11683397 Change-Id: I70f000fb46ddd95d6ad51ea0a8eee77697a045e9
2014-01-13Selective deoptimization. Sebastien Hertz
Update the instrumentation to allow selective deoptimization. Separate instrumentation listener registration from stubs configuration. A listener is now responsible for configuring the appropriate stubs. - The method tracing listener installs instrumentation entry/exit stubs or the interpreter depending on the accuracy of events we want (controlled by kDeoptimizeForAccurateMethodEntryExitListeners). - The debugger registers itself as an instrumentation listener but does not modify methods entrypoints. It only does this on demand when deoptimizing one method or all the methods. The selective deoptimization is used for breakpoint only. When a breakpoint is requested, the debugger deoptimizes this method by setting its entrypoint to the interpreter stub. As several breakpoints can be set on the same method, we deoptimize only once. When the last breakpoint on a method is removed, we reoptimize it by restoring the original entrypoints. The full deoptimization is used for method entry, method exit and single-step events. When one of these events is requested, we force eveything to run with the interpreter (except native and proxy methods). When the last of these events is removed, we restore all methods entrypoints except those which are currently deoptimized. Deoptimizing a method requires all mutator threads be suspended in order to walk each thread's stack and ensure no code is actually executing while we modify methods entrypoints. Suspending all the threads requires to not hold any lock. In the debugger, we deoptimize/undeoptimize when the JDWP event list changes (add or remove a breakpoint for instance). During the update, we need to hold the JDWP event list lock. This means we cannot suspend all the threads at this time. In order to deal with these constraints, we support a queue of deoptimization requests. When an event needs selective/full deoptimization/undeoptimization, we save its request in the queue. Once we release the JDWP event list lock, we suspend all the threads, process this queue and finally resume all the threads. This is done in Dbg::ManageDeoptimization. Note: threads already suspended before doing this remain suspended so we don't "break" debugger suspensions. When we deoptimize one method or every method, we need to browse each thread's stack to install instrumentation exit PC as return PC and save information in the instrumentation stack frame. Now we can deoptimize multiple times during the execution of an application, we need to preserve exisiting instrumentation frames (which is the result of a previous deoptimization). This require to push new instrumentation frames before existing ones so we don't corrupt the instrumentation stack frame while walking the stack. Bug: 11538162 Change-Id: I477142df17edf2dab8ac5d879daacc5c08a67c39
2014-01-07Add sampling profiler Dave Allison
This adds a sampling profiler thread that runs every so often, gathering profiling data and writing the results to a file in /data/data (specific to app running). The intention is to use these files as input to the compiler so that it can determine the best methods to compile. Bug: 11539952 Change-Id: I0bfbb4146fb7966673c792f017ffac8107b6272d
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