summaryrefslogtreecommitdiff
path: root/runtime/stack.cc
AgeCommit message (Collapse)Author
2019-09-26Correctly perform read-barriers on cross-thread reg access Alex Light
For debug workloads we will sometimes read stack registers on other threads. This generally only happens when the target thread is suspended due to a running GC and the debugger thread tries to access stack registers from a compiled method. This could lead to a missed read-barrier and a From-Space reference being returned. To fix this we manually perform a read-barrier after pulling the reference out of the compiled stack. Test: ./test.py --host Test: ./art/tools/run-libjdwp-tests.sh --mode=host Test: ./test.py --host --all-compiler --all-gc -t 1966 Bug: 141590021 Change-Id: I5540c03bfdaecddbc1329ff6c7c58c6f18d6a090
2019-07-22Add fast path for exception vreg copying. David Srbecky
It is not necessary to decode CodeInfo in GetVReg since the caller already did it. Test: ./art/test.py -b --host --64 --interpreter Change-Id: I0f8941f43acdc0f2c43b78ef87d3e796e320c959
2019-06-30Stack maps: Refactor constructors. David Srbecky
Create dedicated static methods instead of passing flags. This creates dedicated methods for the purpose and merges constructor and decoding into single optimized method. This speeds up CodeInfo by 10%, and maps startup by 0.1%. Test: ./art/test.py -b --host Change-Id: Ic7d43e22bca0be9fb13bc2c7544ebfdf46798cfe
2019-06-25Stack walk: Cache CodeInfo and StackMap for current PC. David Srbecky
This speeds maps startup by 0.15%. Test: test.py -b --host --64 --optimizing Change-Id: Ic37eeba727148b877f21fdfacfa9f55558db88a7
2019-05-26Optimize stack maps: add fast path for no inline info. David Srbecky
Consumers of CodeInfo can skip significant chunks of work if they can quickly determine that method has no inlining. Store this fact as a flag bit at the start of code info. This changes binary format and adds <0.1% to oat size. I added the extra flag field as the simplest solution for now, although I would like to use it for more things in the future. (e.g. store the special cases of empty/deduped tables in it) This improves app startup by 0.4% (maps,speed). PMD on golem seems to gets around 15% faster. Bug: 133257467 Test: ./art/test.py -b --host --64 Change-Id: Ia498a31bafc74b51cc95b8c70cf1da4b0e3d894e
2019-05-24Partially ObjPtr<>-ify HandleScope. Vladimir Marko
Test: m test-art-host-gtest Test: testrunner.py --host --optimizing --interpreter Bug: 31113334 Change-Id: I560683b5345bda9df4b22903d032b593d6c2dd4f
2019-05-08Add StackVisitor::SetVRegReference(). Vladimir Marko
Avoid converting ObjPtr<>s to uint32_t and back. Test: m test-art-host-gtest Test: testrunner.py --host --interpreter Test: run-jdwp-tests.sh --mode=host --variant=X64 Test: run-jdwp-tests.sh --mode=host --variant=X64 --debug Bug: 31113334 Change-Id: I4e5c1577930de58772b35179aa4281ae4bbca300
2019-01-17Extend lifetime of CodeInfo in StackVisitor. David Srbecky
Users of the visitor may use the API after WalkStack is finished. Test: test.py -b --host Bug: 120844051 Change-Id: Ia445d3b4c5c338402c92f1d29b522a33cd5baa14
2018-12-19Deoptimize zygote compiled methods in DeoptimizeBootImage. Nicolas Geoffray
Those methods don't get compiled with the "debuggable" flag, so we need to deoptimize them. Also fix a bug revealed by the new test where a concurrent JIT collection happens when trying to disable it. Also make DeoptimizeBootImage truly mutator lock exclusive. Test: 689-zygote-jit-deopt Change-Id: I00607dbe100350c5328293c35c87946fa97924b8
2018-10-12Remove CHECK that GetThis() must always work. Nicolas Geoffray
Ensures GetVReg of a reference on compiled code checks that the value is indeed a reference from the stack maps. bug: 116683601 bug: 117452149 Test: 686-get-this Change-Id: I3a370c45786a4892c7888491bec6d5ae64672f6c
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
2018-08-01Move MethodInfo to CodeInfo. David Srbecky
There is no need to treat it specially any more, because of the de-duplication at BitTable level. This saves 0.6% of oat file size. Test: test-art-host-gtest Change-Id: Ife7927d736243879a41d6f325d49ebf6930a63f6
2018-07-26Decode only the needed tables from CodeInfo. David Srbecky
Most use cases need only the first two bit tables from CodeInfo. Add flag to the decode method so that only those two are loaded. We only touched the table header but that still made difference. This speeds up pmd by over 10%. Test: test-art-host-gtest Change-Id: I7740081bf18205dd69864503b5bcec7de5e1a901
2018-07-19ObjPtr<>-ify ArtMethod and mirror::Method. Vladimir Marko
And clean up some forgotten things after old CLs. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Bug: 31113334 Change-Id: I8af0e845c24d674d0efab21d80c29949b1cc0593
2018-07-06Merge "Revert^2 "Add CodeInfo to JNI methods."" David Srbecky
2018-07-05Revert^2 "Add CodeInfo to JNI methods." David Srbecky
It has no stack maps. We only store the frame info there. As a consequence of having CodeInfo, the JNI methods are now classified as IsOptimized(). This does not have any real effect on .oat file size. This reverts commit 564fa8a1f3e3c39793c9b146ed5f21650617dc3f. Test: test-art-host-gtest Test: test-art-target-gtest-jni_compiler_test32 Change-Id: Ic7a1949027d89ba97cfedfc8ea453f041193b6a7
2018-07-05Merge "Use iterators to access stack map data." David Srbecky
2018-07-04Use iterators to access stack map data. David Srbecky
Try to simplify the code using the recently added iterators. Test: test-art-host-gtest-stack_map_test Change-Id: I0b9f54df01749ee6ec3a67cfb07ba636a2489c89
2018-07-03ART: Do not use std::<container>::at(). Vladimir Marko
These functions are specified as throwing std::out_of_range and we do not use exceptions. Test: m Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Change-Id: I67c365ed6d779c101a18b9f386c751c48ca76e16
2018-06-14Merge "Move some helper methods to DexRegisterLocation." David Srbecky
2018-06-14Move some helper methods to DexRegisterLocation. David Srbecky
Test: test-art-host-gtest-stack_map_test Change-Id: I0abab008159db023d531df69214cd3bb8c0639bd
2018-06-12Removing instrumentation trampolines doesn't remove exit stubs Alex Light
It is possible for tracing to be turned off (and instrumentation trampolines removed) at any time so long as all threads are suspended. Our stack walking code assumed that once the trampolines have been removed from the method entrypoints there will be no more exit stubs on the stack. This is not true and can cause crashes. NB Test requires several other patches to actually run far enough to hit this issue. Test: ./test/testrunner/testrunner.py --host --runtime-option=-Xplugin:libtracefast-trampolined.so Change-Id: I1bc55bc180bf4605028cae4f070e6c8e2c65f034
2018-06-07Remove unused GetDexRegisterMap arguments. David Srbecky
They are no longer needed in the new encoding. I reuse the local variables in most places to DCHECK the size of the decoded register map. This has one catch though: We sometimes omit all dex registers, so the DCHECK should be done only after checking if the map is empty (if applicable). Test: test-art-host-gtest-stack_map_test Change-Id: I94b67029842374bc8eb7c9e5eac76fc93a651f24
2018-06-07Delta-compress register maps in stack maps. David Srbecky
The register maps tend to be similar from stack map to stack map, so instead of encoding them again, store only the modified ones. The dex register bitmap stores the delta now - if register has been modified since the previous stack map, the bit will be set. The decoding logic scans backwards through stack maps until it eventfully finds the most recent value of each register. This CL saves ~2.5% of .oat file size (~10% of stackmap size). Due to the scan, this makes dex register decoding slower by factor of 2.5, but that still beats the old algorithm before refactoring. Test: test-art-host-gtest-stack_map_test Change-Id: Id5217a329eb757954e0c9447f38b05ec34118f84
2018-06-05Remove depth argument from InlineInfo accessors in stack maps. David Srbecky
The InlineInfo class actually represented a list of inlining information for a given stack map, and the depth argument was used everywhere to select to desired element from the list. This was verbose and inconsistent with the other classes. Change the InlineInfo class to represent a single inlining, and select the desired depth when getting it from CodeInfo. Test: test-art-host-gtest-stack_map_test Change-Id: I35b73e6704854f0203f51d4dbdbed5b1d1cd5a3b
2018-05-30Simplify DexRegisterMap API. David Srbecky
Store some of the needed decoding state explicitly to avoid passing it around all the time. The DexRegisterMap class is rewritten in next CL. Test: test-art-host-gtest-stack_map_test Change-Id: Ie268dff2a1c1da2e08f0e6799ae51c30e11f350b
2018-05-23Merge "ObjPtr<>-ify UnstartedRuntime, fix 2 stale reference uses." Vladimir Marko
2018-05-23ObjPtr<>-ify UnstartedRuntime, fix 2 stale reference uses. Vladimir Marko
Test: Rely on TreeHugger. Bug: 31113334 Change-Id: I35f76c3e3b94dfca18dbe67aba065a1270f4e5ee
2018-05-22Merge "Refactor runtime callee save frame info." Vladimir Marko
2018-05-22Refactor runtime callee save frame info. Vladimir Marko
And avoid storing the info in Runtime. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing --jit Test: Pixel 2 XL boots. Test: testrunner.py --target --optimizing --jit Change-Id: Ib14853fc06c420753993e1f9e82a1b01f5e35e8c
2018-05-21Rewrite stackmap encoding code. David Srbecky
Remove most of the code related to handling of bit encodings. The design is still same; the encodings are just more implicit. Most of the complexity is replaced with a single BitTable class, which is a generic purpose table of tightly bit-packed integers. It has its own header which stores the bit-encoding of columns, and that removes the need to handle the encodings explicitly. Other classes, like StackMap, are accessors into the BitTable, with named getter methods for the individual columns. This CL saves ~1% of .oat file size (~4% of stackmap size). Test: test-art-host-gtest Change-Id: I7e92683753b0cc376300e3b23d892feac3670890
2018-01-31Revert "Revert "Make libdexfile build independent of runtime dir"" David Sehr
This reverts commit 787784f9effb126b5d0d3dc97d544c4a477b5daf. Reason for revert: Bot configuration issue. Change-Id: I6a10bb4a9571f89c7e4dd095f9157e830a44e2de Bug: 22322814 Test: make -j 50 checkbuild
2018-01-30Revert "Make libdexfile build independent of runtime dir" David Sehr
This reverts commit b40b7e73469339a6b667b4a2e2b8690112a74dc9. Reason for revert: on device libdexfile.so missing Change-Id: I9bd61a98bef870400580e8c991cb061d3f57fa72
2018-01-30Make libdexfile build independent of runtime dir David Sehr
Remove libdexfile's dependency on utils.cc and move utf.cc into /dex. Remove libdexfile's constituent sources from libart and use libdexfile wherever libart is. Also remove some ART-specific interfaces. Libdexfile's tests remain to be converted, plus moving the files to a new directory peer to runtime/. Bug: 22322814 Test: make -j 50 test-art-host Change-Id: Ifaf695216e4a0e43d3aa377984d933f7a2a243c2
2018-01-05Create dex subdirectory David Sehr
Move all the DexFile related source to a common subdirectory dex/ of runtime. Bug: 71361973 Test: make -j 50 test-art-host Change-Id: I59e984ed660b93e0776556308be3d653722f5223
2017-12-22Make CodeItem fields private Mathieu Chartier
Make code item fields private and use accessors. Added a hand full of friend classes to reduce the size of the change. Changed default to be nullable and removed CreateNullable. CreateNullable was a bad API since it defaulted to the unsafe, may add a CreateNonNullable if it's important for performance. Motivation: Have a different layout for code items in cdex. Bug: 63756964 Test: test-art-host-gtest Test: test/testrunner/testrunner.py --host Test: art/tools/run-jdwp-tests.sh '--mode=host' '--variant=X32' --debug Change-Id: I42bc7435e20358682075cb6de52713b595f95bf9
2017-11-30Revert^4 "JIT JNI stubs." Vladimir Marko
The original CL, https://android-review.googlesource.com/513417 , has a bug fixed in the Revert^2, https://android-review.googlesource.com/550579 , and this Revert^4 adds two more fixes: - fix obsolete native method getting interpreter entrypoint in 980-redefine-object, - fix random JIT GC flakiness in 667-jit-jni-stub. Test: testrunner.py --host --prebuild --no-relocate \ --no-image --jit -t 980-redefine-object Bug: 65574695 Bug: 69843562 This reverts commit 056d7756152bb3ced81dd57781be5028428ce2bd. Change-Id: Ic778686168b90e29816fd526e23141dcbe5ea880
2017-11-30Revert "Revert "Revert "JIT JNI stubs.""" Nicolas Geoffray
Still seeing occasional failures on 667-jit-jni-stub Bug: 65574695 Bug: 69843562 This reverts commit e7441631a11e2e07ce863255a59ee4de29c6a56f. Change-Id: I3db751679ef7bdf31c933208aaffe4fac749a14b
2017-11-29Revert "Revert "JIT JNI stubs."" Vladimir Marko
The original CL, https://android-review.googlesource.com/513417 , had a bug for class unloading where a read barrier was executed at the wrong time from ConcurrentCopying::MarkingPhase() -> ClassLinker::CleanupClassLoaders() -> ClassLinker::DeleteClassLoader() -> JitCodeCache::RemoveMethodsIn() -> JitCodeCache::JniStubKey::UpdateShorty() -> ArtMethod::GetShorty(). This has been fixed by removing sources of the read barrier from ArtMethod::GetShorty(). Test: testrunner.py --host --prebuild --jit --no-relocate \ --no-image -t 998-redefine-use-after-free Bug: 65574695 Bug: 69843562 This reverts commit 47d31853e16a95393d760e6be2ffeeb0193f94a1. Change-Id: I06e7a15b09d9ff11cde15a7d1529644bfeca15e0
2017-11-28Revert "JIT JNI stubs." Vladimir Marko
Seems to break 998-redefine-use-after-free in some --no-image configuration. Bug: 65574695 Bug: 69843562 This reverts commit 3417eaefe4e714c489a6fb0cb89b4810d81bdf4d. Change-Id: I2dd157b931c17c791522ea2544c1982ed3519b86
2017-11-28JIT JNI stubs. Vladimir Marko
Allow the JIT compiler to compile JNI stubs and make sure they can be collected once they are not in use anymore. Test: 667-jit-jni-stub Test: Pixel 2 XL boots. Test: m test-art-host-gtest Test: testrunner.py --host --jit Test: testrunner.py --target --jit Bug: 65574695 Change-Id: Idf81f50bcfa68c0c403ad2b49058be62b21b7b1f
2017-09-18ART: Move kDexNoIndex to dex_file_types.h Andreas Gampe
Define the constant with the types to allow lowering the dependency on DexFile. Test: m Change-Id: I3c61421db45be96d2057e01b1a7825883d8bd178
2017-08-07Use the right class loader allocator in ReallocMethods. Nicolas Geoffray
Otherwise we would leak memory. Also complies with the JitCodeCache assumption that ArtMethods are allocated with the classloader that loaded the class where those ArtMethods hang. bug: 64241268 Test: 661-classloader-allocator Change-Id: I9e4ddbf8f40547084a1a4983459db48f68743cc7
2017-06-19ART: Refactor stack.h Andreas Gampe
Factor out LockCountData, ShadowFrame and JavaFrameRootInfo and leave stack.h for the StackVisitor. Move single-use function to user to remove DexFile dependency. Test: m test-art-host Change-Id: I53d2880917bdf6782856fd2b16f38a0293f3aefc
2017-06-08ART: Move CalleeSaveType to callee_save_type.h Andreas Gampe
Move the type out of runtime to decrease dependencies. Make it a proper enum class. Fix up usage. Test: m test-art-host Change-Id: Id84c44bf3c59f37c8a43548e720c5fb65707b198
2017-06-05Merge "Relax an assert in AssertPcIsWithinQuickCode()" Mingyao Yang
2017-06-01ART: Clean up thread.h and thread_list.h Andreas Gampe
Remove dependency on stack.h and gc_root.h. Remove unused object callbacks include. Factor out ManagedStack into its own set of files. Fix up users of transitive includes. Test: m test-art-host Change-Id: I01286c43d8c7710948c161b1348faabb05922e59
2017-05-30Relax an assert in AssertPcIsWithinQuickCode() Mingyao Yang
Skip the case when pc is jitted code. Bug: 36467228 Test: m -j20 test-art-host-run-test Test: test/run-test --host --prebuild --jit --no-relocate --runtime-option -Xcheck:jni --no-image --64 597-deopt-new-string Change-Id: Ie9c325e2eaf7c81f1769abacc2d2615b1c1c97cb
2017-04-14ART: Tentative fix for stack count issue in test 913 Andreas Gampe
Use kCountTransition == kNo to also skip runtime methods in the cur_depth_ count of a StackVisitor. Currently this is only used in the VisitRoots function of Thread. If the additional load is too expensive, we can make this dependent on the requested precision (and thus revert "regular" visits to the old scheme of also counting transitions between managed stack frames and shadow frames, which is only an increment of a field). Bug: 31385354 Bug: 32072923 Test: m test-art-host Change-Id: Ief951585407dd6e03f8050774fe612e7b204247e
2017-04-04Ensure invoking obsolete methods throws errors. Alex Light
This sets the entrypoint for obsolete methods to a special stub that will ensure that calling them results in an Error being thrown. Previously we were allowing obsolete methods to be run if they could reach the appropriate places in the runtime. Getting into the state where this is possible is extremely difficult since one can only get an jmethodID to an obsolete method by snatching it off the stack (or by inspecting internal runtime data). From there normally invoking it will do lookup on the receiver which will get you the original version. Bug: 36867251 Bug: 31455788 Test: ./test.py --host -j40 Test: (with aosp_marlin-userdebug device) ./test.py --target -j4 Change-Id: I2ca0503966a4e3de18dd89cb7ff224eba1459b49