summaryrefslogtreecommitdiff
path: root/runtime/runtime_callbacks.cc
AgeCommit message (Collapse)Author
2024-05-30Appinfo: Make adb the app debug source of truth Fabien Sanglard
Design doc: go/adb_app_info Test: Tested in adb repo Change-Id: Ia20d570b0d3154fcff686c7fd6135281e0bc8d5f
2024-02-06Add visibility attributes in runtime/r* Dmitrii Ishcheikin
Bug: 260881207 Test: presubmit Test: abtd app_compat_drm Test: abtd app_compat_top_100 Test: abtd app_compat_banking Change-Id: I9a12fe4d7c47090631415e813a00c2a2fdcaca62
2022-06-22Cleanup around method inspection callbacks Mythri Alle
IsMethodBeingInspected callback was used to prevent moving to compiled code (JIT / OSR / Nterp) while a method has breakpoints or other debugger related events enabled. We also use Instrumentation::IsDeoptimized for similar purpose in some places (for ex: when determining if a method needs to be deoptimized). Deoptimized methods list is a super set of methods that have breakpoints on them. So we can replace most method inspection callbacks to use IsDeoptimized check instead. The one exception is when we decide if we need to OSR a method. Here we need to check if the frame has any locals changed which isn't covered by IsDeoptimized check and requires a runtime callback to see if any locals have changed. This CL: 1. Adds a new runtime callback called HaveLocalsChanged to check if any locals have changed and uses it to prevent OSRing such frames. 2. Removes IsMethodBeingInspected and replaces it with IsDeoptimized / HaveLocalsChanged as required. Bug: 206029744 Test: art/test.py Change-Id: Ie649cffaeba3d31746527e0ee326abe81284978d
2022-01-18Cleanup method inspection callbacks from jvmti Mythri Alle
We used to use three different inspection callbacks for kind of similar checks. - IsMethodBeingInspected - returns true if method has breakpoints or if we need to observe any locals (ideally for only this method but current implementation is not ideal). This is used to check if we can JIT code. - IsMethodSafeToJit - returns true if method has breakpoints. Though we also check if a method is being inspected making this check redundant. - IsMethodNeedsDebugVersion - this is used to check if we need to use switch interpreter. This was always returning true forcing us to use switch interpreter when debugger is attached. We should use IsMethodBeingInspected instead. This CL merges all these into IsMethodBeingInspected callback. Bug: 206029744 Test: test.py --gtest --run-test Change-Id: Idcde354f39775092be5ddb79f09a92f81e07b1ee
2019-12-11Revert^4 "Allow structural redefinition on non-final classes." Alex Light
This reverts commit 664999a12d6fc8a8ef5c0519b12ec1e8a51bb085. Fixed issues with GC and quickened instructions in parent CLs. Reason for revert: Fixed issues with GC CHECK fail and device SEGVs. Test: ./test.py --host Test: ./test.py --target Bug: 134162467 Bug: 144168550 Change-Id: Ibacddaf45beb72184f97d53d5d048bd442578658
2019-12-03Revert "Revert^2 "Allow structural redefinition on non-final classes."" Nicolas Geoffray
This reverts commit f1b809ce611e943f926fff97cefe0930226ffcc2. Reason for revert: Tests still fail Bug: 134162467 Bug: 144168550 Change-Id: Icdebc826b8630920b716afbfd6f338a29669fcc2
2019-12-02Revert^2 "Allow structural redefinition on non-final classes." Alex Light
We were incorrectly racing with the rest of the runtime in a couple of places. First we would return an ObjPtr of a newly defined class after holding it over a suspend point. This could lead to DefineClass returning an obsolete class in some cases. We also failed to ensure the class-status was synchronized between the old and new classes during structural redefinition. This could lead to a class appearing to go backwards in status. This reverts commit 88b1c83080afcb2bfb6f781ded1c90fe8f9eab4d. Reason for revert: Fixed issues causing test failures. Test: ./test.py --host Bug: 134162467 Bug: 144168550 Change-Id: I4d0f7718490532f0ef14a9561b8e7000ef292b12
2019-11-26Revert "Allow structural redefinition on non-final classes." Roland Levillain
This reverts commit c47040d31cbcd8cddd5fadb552b4f0f6c94b5bd0. Reason for revert: Breaks ART tests (see e.g. b/145197371). Bug: 145197371 Bug: 134162467 Bug: 144168550 Change-Id: Ia8e5788655057e380fc723a38900d26d69cda938
2019-11-26Allow structural redefinition on non-final classes. Alex Light
This adds support for structurally redefining non-final, non-finalizable classes. The only restriction is that one cannot redefine a class at the same time as any of its supertypes, if a structural redefinition is occurring. The structural redefinition may not remove any fields or methods, change the superclass or change the implemented interfaces. Adding new methods or fields, both static or non-static, public, private, protected, or package-private, is supported. Test: ./test.py --host Bug: 134162467 Bug: 144168550 Change-Id: I32e9e854b3e56270170b10e8f5aba9de8f6bfdfa
2019-09-27Consolidate updating of reflective Field/Method references Alex Light
Previously we used several different visitors to update Field & Method references for structural redefinition. We also did not visit or update JVMTI based references. This consolidates all the visitors to a single Runtime::VisitReflectiveTargets function with a single ReflectiveTargetVisitor type. This simplifies the code around structural redefinition and ensures that the reflective value holders are in charge of the actual replacement. Support was also added for walking internal openjdkjvmti references for things like field-read/modification events. Test: ./test.py --host Bug: 134162467 Change-Id: Ic5fc1db7db0a30f947a1a67259dc024e149ebd57
2019-04-09Use unique mutex to synchronize runtime_callbacks Alex Light
Initially we would use the mutator_lock_ to manage changes to the runtime_callbacks list. Over time this stopped being sufficent. This changes to using an explicit r/w mutex to manage these lists. Since these callbacks are not modified very often we use a single mutex for all of them. Test: ./test.py --host Test: ./art/tools/run-libjdwp-tests.sh --mode=host Bug: 121052811 Change-Id: I3ca44402a5f6290701fa8e28d18e6afe8786214c
2019-01-02ART: Move dex structs into own header Andreas Gampe
Separating out the structs from DexFile allows them to be forward- declared, which reduces the need to include the dex_file header. Bug: 119869270 Test: m Change-Id: I32dde5a632884bca7435cd584b4a81883de2e7b4
2018-11-12Emit JVMTI events for LockSupport.park Charles Munger
This restores the behavior from when park was implemented with wait/notify, except that the blocker object is used as the monitor rather than the Thread that is parking. Bug: 28845097 Tested: ./test/run-test --jvm 1931 Change-Id: I523d719ca3e49a538c06f48f032b322fb91e147e
2018-04-03Revert^6 "Ensure that OSR still is possible with jvmti" Alex Light
The instrumentation uninstall could set methods to non-debuggable boot.oat code. This could cause events to be missed due to methods being inlined. We needed to change the path so that we would only have the JIT/interpreter replace methods. We do this by adding a new callback that can be used to determine if a method needs to be debuggable and being more careful about replacing code when this is true. This reverts commit 5f3005c8844d851d7d218b88b5f90d6c9083ce24. This unreverts commit b9ad26d1ed9146b89555d4333021f44eeb831f05. Reason for revert: Fixed issue causing CTS version of test 993 failure. Test: cts-tradefed run cts-dev CtsJvmtiRunTest993HostTestCases Test: ./test.py --host -j50 --all -t 993 Test: ./test.py --host Test: while ./test/run-test --host --jit 1935; do; done Test: while ./test/run-test --host --jit --jvmti-redefine-stress 1935; do; done Test: am start --attach-agent -n com.example.android.displayingbitmaps/.ui.ImageGridActivity Run blur filter. Bug: 76226464 Bug: 77306669 Change-Id: I5068201a03f7613787c66981405499b6499c24e1
2017-12-19Add support for selecting alternate JDWP implementations Alex Light
Change JDWP options parsing to take place later and add a -XjdwpProvider:_ option that can be used by the runtime to select an appropriate JDWP provider. The argument is a string. If 'none' is given JDWP will be totally disabled. If 'internal' is given the current internal JDWP implementation is used. If 'default' is given the 'internal' JDWP implementation will currently be used. Other values will be added in the future. Also adds a runtime callback that will be invoked when the runtime wants to start or stop the debugger (namely at the post-zygote fork and just before exit) and check if a debugger is availible. Also add '-XjdwpOptions:_' in preparation for the eventual removal of the existing -Xrunjdwp=_ and -Xagentlib:jdwp=_ as top-level options. All of these options now store their arguments as a std::string to be interpreted by the JDWP implementation as it sees fit. Also change the jdwpOptions to default to transport=dt_android_adb if there is not one specified and it is available. This will make changing the default transport based on the JDWP provider easier. These new options are needed to allow us to support both the old, internal, JDWP implementation as its replacement is tested and verified. This lets us switch between them with little difficulty. We will probably remove one or both of these options once we have confidence that the new jdwp implementation has stuck. Test: ./test.py --host -j50 Test: ./test/run-test --host --debug 001-HelloWorld Test: Manual, flash walleye, debug app Bug: 62821960 Change-Id: Ie31db6b6f7d76a03d4ab8e178fcf298ed0eec203
2017-11-14Add JVMTI DDMS extension method and event. Alex Light
Add a new jvmti extension method 'com.android.art.internal.ddm.process_chunk' that can be used to request that the system process a DDMS chunk with a given type and data payload. It returns the processed chunk type and data. Agents can use this to interact with DDMS. Also add a new jvmti extension event 'com.android.art.internal.ddm.publish_chunk' that will be called whenever the system wishes to send an unrequested chunk of data to be processed. This is triggered by code executing 'DdmServer#sendChunk' or by other internal mechanisms. Both of these extensions are provided mainly to aid in the maintenence of backwards compatibility with existing DDMS applications. Generally agents should prefer to use the normal JVMTI events and controls over interpreting DDMS data or calling DDMS functions. Bug: 62821960 Test: ./test.py --host -j50 Test: ./art/tools/run-jdwp-tests.sh --mode=host \ --test org.apache.harmony.jpda.tests.jdwp.DDM.DDMTest Change-Id: I39f22d3d096d12b59713ec7b8b0c08d0d68ff422
2017-10-30Avoid JVMTI global deoptimization when possible Alex Light
This changes the openjdkjvmti plugin to be more controlled about the situations that it will deoptimize everything. Most notably this makes the plugin deoptimize only individual methods for breakpoints instead of doing a full deoptimization. It also doesn't deoptimize for the JVMTI_EVENT_EXCEPTION method, since our throwing code will always send the appropriate event. Impact: Exoplayer benchmark with breakpointlogger setting a breakpoint on a method that is never called. The agent is the tools/breakpoint-logger agent. 'art' options are for all runs were: --64 -Xusejit:true -Xcompiler-option --debuggable 'art' options for 'Pre change' and 'Post change' runs included: -Xplugin:libopenjdkjvmti.so '-agentpath:libbreakpointlogger.so=Lbenchmarks/common/java/BenchmarkBase;->run()V@0' Clean run (no agent loaded): Running FMP4 x 1 : 53 Running TS x 1 : 144 Running FMP4 x 2500 : 3309 Running TS x 100 : 3584 ExoPlayerBench(RunTime): 6977000.0 us. Pre change: Running FMP4 x 1 : 159 Running TS x 1 : 9395 Running FMP4 x 2500 : 298591 Running TS x 100 : 944447 ExoPlayerBench(RunTime): 1.243226E9 us. Post change: Running FMP4 x 1 : 87 Running TS x 1 : 495 Running FMP4 x 2500 : 2939 Running TS x 100 : 3947 ExoPlayerBench(RunTime): 6979000.0 us. Post change vs clean run is well within margin of error for this benchmark. Test: ./test.py --host -j50 Test: ./art/tools/run-prebuild-libjdwp-tests.sh Bug: 62821960 Bug: 67958496 Change-Id: I63ef04f71c36c34d8534651d0c075921a836ec08
2017-09-27Ensure that OSR doesn't break local-variable get/set Alex Light
We had a bug where we would on-stack replace a method with a modified local variable. Thanks to inlining & load-store elimination of local variable values this could cause the change to the variable to be lost. We fixed this by giving plugins a way to notify the runtime they are interested in a particular method. Bug: 66959663 Bug: 66933582 Test: while ./test/run-test --host --prebuild -O --jit 1935; do; done Test: ./test.py --host -j50 Change-Id: Ic001b8a9d8d0bd9ce292e807752c86a505f85d36
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
2017-04-19Implement can_generate_native_method_bind capability Alex Light
This capability lets one observe and even replace the implementations of native methods when they are bound. Test: ./test.py --host -j40 Bug: 37432636 Change-Id: I2432a8e4da1a677e8011ce495296f4ab9f42eb3e
2017-01-23Add ClassPreDefine hook. Alex Light
This hook is called prior to defining a class for the first time. It allows callbacks to modify the dex-file used to load the class if they wish. The event handler is responsible for ensuring that the returned dex-file is set-up correctly. Bug: 31684920 Test: mma -j40 test-art-host Change-Id: Iaed79c1597913148ead795e033a0a10a4ebe6b2b
2017-01-19ART: Add runtime phase callback Andreas Gampe
Add callback that describes the current runtime phase, one of starting, initialized and death. Add test. Bug: 31684920 Test: m test-art-host-gtest-runtime_callbacks_test Change-Id: I08ae7c45851572f8b3e446c07f0498f66bb032d3
2017-01-19ART: Add SigQuit Callback Andreas Gampe
Add callback being triggered when the runtime handles SigQuit. Bug: 31684920 Test: m test-art-host-gtest-runtime_callbacks_test Change-Id: I23e3b256c654b6078c79b3897439d893ea79d96e
2017-01-19ART: Add ClassLoadCallback Andreas Gampe
Add callback for class-load and class-prepare events. Move Dbg over. Add tests. Bug: 31684920 Test: m test-art-host-gtest-runtime_callbacks_test Test: art/tools/run-jdwp-tests.sh --mode=host Change-Id: I871f6b3c54448fd6ece8d9a7571b2042be50d525
2017-01-19Revert "Revert "ART: Start RuntimeCallbacks"" Andreas Gampe
This reverts commit bf6331a45f730e1f1044af2ce43bceda660ae6fc. Switch to using the mutator lock. Bug: 31684920 Test: m test-art-host-gtest-runtime_callbacks_test Test: art/tools/run-jdwp-tests.sh --mode=host --debug Change-Id: I6ce0f71de2aa9f90cd23cfca7723a793b560b16b
2017-01-19Revert "ART: Start RuntimeCallbacks" Nicolas Geoffray
jdwp tests failing with: STDERR> dalvikvm32 E 01-18 23:14:50 12180 12198 thread-inl.h:137] holding "runtime callbacks lock" at point where thread suspension is expected Bug: 31684920 This reverts commit 13093d455b8266338fd713b04261c58e9dc2b164. Change-Id: I94e4154e273d006eecdd485607dcfd96392d6a00
2017-01-18ART: Start RuntimeCallbacks Andreas Gampe
Add a central RuntimeCallbacks structure to handle certain interesting runtime events. In a first iteration, add ThreadLifecycleCallback with ThreadStart and ThreadStop. Move Dbg over to ThreadLifecycleCallback. Add a test. Bug: 31684920 Test: m test-art-host-gtest-runtime_callbacks_test Test: art/tools/run-jdwp-tests.sh --mode=host Change-Id: Ie0f77739a563207bfb4f04374e72dc6935c40b4f