summaryrefslogtreecommitdiff
path: root/openjdkjvmti/alloc_manager.cc
AgeCommit message (Collapse)Author
2023-05-22Use C++17's [[maybe_unused]] attribute in ART Stefano Cianciulli
Bug: 169680875 Test: mmm art Change-Id: Ic0cc320891c42b07a2b5520a584d2b62052e7235
2019-12-18Fix ABA bug with PreObjectAlloc event being missed Alex Light
We prevent the PreObjectAlloc event from ever being disabled after being activated for allocation pausing the first time. This is to prevent an instance of the ABA problem where a thread can miss the fact that the size of the object it's allocating has changed if it was suspended within the allocation path during the redefinition. We need to make sure that every thread gets a chance to see the PreObjectAlloc event at least once or else it could miss the fact that the object its allocating had its size changed. Consider the following 2 threads. T1 is allocating an object of class K. It is suspended (by user code) somewhere in the AllocObjectWithAllocator function, perhaps while doing a GC to attempt to clear space. With that thread suspended on thread T2 we decide to structurally redefine 'K', changing its size. To do this we insert this PreObjectAlloc event to check and update the size of the class being allocated. This is done successfully. Now imagine if T2 removed the listener event then T1 subsequently resumes. T1 would see there is no PreObjectAlloc event and so allocate using the old object size. This leads to it not allocating enough. To prevent this we simply force every allocation after our first pause to go through the PreObjectAlloc event. Test: setup runit.sh to run test 2005. ./art/tools/parallel_run.py -j80 --out art/out.txt ./art/runit.sh Test: ./test.py --host Bug: 146436130 Change-Id: I7cdc1d133a7cbba7784b906b587e565072a453b2
2019-12-18Fix reversed compare_exchange check. Alex Light
We were incorrectly stopping a retry-loop when compare_exchange_strong returned true instead of false. This could lead to races if multiple threads tried to pause allocations simultaneously. Test: ./test.py --host Bug: 146436130 Change-Id: I46ab86010d24148d640af0c51a5268b3eef0d300
2019-12-18Fix alignment bug in PreObjectAlloc Alex Light
We were incorrectly setting the byte-count to a potentially unaligned value. This could cause CHECK failures in rare situations. Test: ./test.py --host Bug: 146436130 Change-Id: Ia8d650b085af875fc45e5408ed7b81f9ce69df1f
2019-11-19Revert^4 "Initial support for adding virtuals with structural redefinition" Alex Light
This reverts commit 2f8c1ac61b0c611d67badea70261c851ed19b82a. If there were pending tasks to jit compile a method which is made obsolete the JIT would CHECK fail, since the newly obsolete method is marked DontCompile. This didn't happen with non-structural redefinition since in that case the 'valid' ArtMethod always remains the same. To fix this we just have the JitTask check if the method it's compiling is compilable and fail if it's not. Reason for revert: Fixed JIT check failure. Test: ./test.py --host Bug: 134162467 Bug: 144168550 Bug: 144729319 Change-Id: Ib867b2de13bb4c2978b4538a5851c647caf0e1cc
2019-11-19Revert^3 "Initial support for adding virtuals with structural redefinition" Alex Light
This reverts commit 8ba9738d55c11dfb7f85a7de9b1d6a4e1225ad20. Reason for revert: Seems to be failing with `Check failed: method->IsCompilable()` Test: None Bug: 134162467 Bug: 144168550 Bug: 144729319 Change-Id: Ida9228fa171ae16d803b5ad4438e233a2ed4ffb2
2019-11-18Revert^2 "Initial support for adding virtuals with structural redefinition" Alex Light
This reverts commit d0e354e54da2f2e79b6fc2ff0e13d53c74976b08. We were incorrectly continuing to use an ObjPtr over a suspend point (in this case a CollectGarbageInternal). This led for the ObjPtr to be invalidated. Instead we should have been using a Handle (that already exists). Reason for revert: Fixed stale ObjPtr use. Test: ./test.py --host Test: ./test/testrunner/run_build_test_target.py -j80 art-debug-gc Bug: 134162467 Bug: 144168550 Bug: 144590579 Change-Id: Ied9856a707d377e97d34c7450376caf2a0b83255
2019-11-18Revert "Initial support for adding virtuals with structural redefinition" Nicolas Geoffray
This reverts commit 283bb322de84ac570b987c65a1015e2dbcbfad7c. Reason for revert: Test flakes Bug: 134162467 Bug: 144168550 Bug: 144590579 Change-Id: I2259c030f03a72f6b7bcda10288bd23cb3258164
2019-11-16Initial support for adding virtuals with structural redefinition Alex Light
Initial implementation of adding virtual methods and non-static fields using structural redefinition. Currently this is limited to 'final', non-finalizable classes. These restrictions will be removed or loosened in the future. All non-collected instances of the redefined class will be made obsolete and reallocated. This can cause significant GC load. This feature does not work with any of the -quick opcodes and should only be used with dex files that haven't undergone dex2dex compilation (that is --debuggable and BCP dex files). Test: ./test.py --host Bug: 134162467 Bug: 144168550 Change-Id: Ia401d97395cfe498eb849a661ea9a900dfaa6da3