summaryrefslogtreecommitdiff
path: root/runtime/handle_scope.h
AgeCommit message (Collapse)Author
2024-03-26Rename enums.h/.cc to pointer_size.h/.cc. Santiago Aboy Solanes
It was the only enum in the file Bug: 329378408 Test: art/test/testrunner/testrunner.py --host --64 --optimizing -b Change-Id: If0e385324afa3685f648135ba9b60e6bc79ba0ed
2024-01-18Add visibility attributes in runtime/h* Dmitrii Ishcheikin
Bug: 260881207 Test: presubmit Test: abtd app_compat_drm Test: abtd app_compat_top_100 Test: abtd app_compat_banking Change-Id: I80d3813691880564c1e7b641db0af3372f41e8e6
2023-11-20Do not create `MethodType` during early init... Vladimir Marko
... when interpreting `VarHandle` invoke-polymorphic. Use `VariableSizedHandleScope` as a raw method type that can be converted to the managed `MethodType` when desires but can also be used directly without the conversion. Add helper templates that facilitate using either the raw method type or the managed `MethodType` easily by templated code. Change `VarHandleInvokeAccessorWithConversions()` to avoid allocating the `MethodType` (avoid unnecessary work). Change `VarHandle` invokes in the interpreter to avoid allocating the `MethodType` when the `ThreadLocalRandom` is not initialized. This can avoid circular initialization when we reland https://android-review.googlesource.com/2769639 . Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Bug: 297147201 Change-Id: I6a9372543a547366b28e5bf49d15d6140a75f770
2023-11-13Clean up `HandleScope`. Vladimir Marko
Implement `Size()` and rename `NumberOfReferences()` to `Capacity()`. Replace `Capacity()` with `Size()` where appropriate, for example to avoid visiting unused slots. Remove some obsolete dead code and move some functions from `FixedSizeHandleScope<.>` to `HandleScope`. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Change-Id: I1e49fb6144f77692ff22c6fbd0578d995b5a01f1
2023-05-22Use C++17's [[maybe_unused]] attribute in ART Stefano Cianciulli
Bug: 169680875 Test: mmm art Change-Id: Ic0cc320891c42b07a2b5520a584d2b62052e7235
2023-02-01Reland "Write classes in runtime-generated app image." Nicolas Geoffray
This reverts commit 24b3d648ff6c2c200003f55ac63fc910d7bfd40f. Bug: 260557058 Reason for revert: - Encode class loader context in image, and check it at load time. - Set nterp entrypoint to methods that can. Test: test.py Test: atest com.android.bluetooth.opp.BluetoothOppObexServerSessionTest#onPut_withUnsupportedMimeTypeInHeader_returnsHttpBadRequest Change-Id: Ibf4a8604c4a226d1acc021103668e211446bb53c
2023-01-29Revert "Write classes in runtime-generated app image." Sam Saccone
This reverts commit df68c0a6f0d36728fa728049e5bcec20de2d0d5e. Reason for revert: b/267084527 Change-Id: I2eacf89c23db00c46d56e78009efa11bed31af60
2023-01-28Write classes in runtime-generated app image. Nicolas Geoffray
Test: 845-data-image Bug: 260557058 Change-Id: I640b78942984ac3d3f8d24abda619d78154acd86
2022-02-23Revert "Make VariableHandleScope consistent between 32 & 64 bit" Vladimir Marko
This reverts commit de7718db5a54cd0f67c650f12d0b757c9a9079f8. Reason for revert: The change is not needed anymore since https://android-review.googlesource.com/983105 . Reverting to the old code that has a little lower memory usage on 32-bit targets. Change-Id: I95437c53c1a219a19923d4912b34c2641e54220f Test: Boot image compiled with dex2oat32 is unchanged. Bug: 122373634
2021-06-01Avoid race on Thread::tlsPtr_::top_handle_scope. Vladimir Marko
Require mutator lock for that field and update tests to hold the mutator lock when needed. This prevents GC thread that executes a thread roots flip on behalf of suspended threads from racing against construction or destruction of handle scopes by those threads and possibly seeing invalid values. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Bug: 189439174 Change-Id: I268a0ef6e5aa838347956febca0d3b6e02fe3ae5
2021-01-12Support null-filled HandleScopes without mutator_lock_ Alex Light
Creating a HandleScope used to always require (via assert) the mutator_lock_ be held. When the scope is filled with null (as it normally is) this is not needed however. Test: ./test.py --host Change-Id: I47acbcaeafc7617f264233a5ab869eded6a22473
2020-02-12Use stack for first scope in VariableSizedHandleScope Mathieu Chartier
VariableSizedHandleScope commonly doesn't have that many handles, avoid doing an allocation for those cases. Test: test-art-host Change-Id: Iaf6c502723a239b1a2e861152efa37f4ef66431b
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-01-17ART: Some more iwyu Andreas Gampe
Bug: 119869270 Test: mmma art Change-Id: Ie67b57c7173986009fdc7b4aa01563846d30f25f
2019-01-15Merge "Make VariableHandleScope consistent between 32 & 64 bit" Alex Light
2019-01-14Make VariableHandleScope consistent between 32 & 64 bit Alex Light
The number of handles kept in a single bucket by VariableSizedHandleScope varied between 32bit and 64bit hosts. On 32 bit hosts the bucket size was 13 elements and on 64bit it was 12 elements. This could affect the order objects are visited during heap walks since they are visited in reverse-bucket order (last bucket first, then next to last, etc). This could cause the output of dex2oat to change depending on what type of executable dex2oat is, breaking consistency requirements. In order to fix this issue we lock the bucket size at 12 elements. Test: ./test.py --host -j72 Bug: 122373634 Change-Id: I689392d0eb68ff8b8ebc85d155014b5bd3bb3a6b
2019-01-09ART: IWYU handle_scope Andreas Gampe
Move wrappers to their own header. Forward-declare handles. Bug: 119869270 Test: m Change-Id: I9fba4df9b589cec07c7f687791ddbed81d188410
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
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
2017-12-07ART: Replace base/logging with android-base/logging Andreas Gampe
Replace wherever possible. ART's base/logging is now mainly VLOG and initialization code that is unnecessary to pull in and makes changes to verbose logging more painful than they have to be. Test: m test-art-host Change-Id: I3e3a4672ba5b621e57590a526c7d1c8b749e4f6e
2017-05-30ART: Add missing namespace comments Andreas Gampe
Add closing namespace comments. Bug: 32619234 Test: m Change-Id: I1f50e09dcd1038c4b540b87e5c19e319c1f592e4
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-21Reduce dex2oat memory usage from VariableHandleScope. Vladimir Marko
Pack more handles in FixedSizeHandleScope<>s to reduce the per-Handle<> overhead. Measured compilation of a big app using heaptrack: before: 3571397 calls to allocation functions with 2.59MB peak consumption from art::MutableHandle<> art::ReferenceTypePropagation::HandleCache::NewHandle<>(art::ObjPtr<>) after: 1139808 calls to allocation functions with 1.54MB peak consumption from art::MutableHandle<> art::ReferenceTypePropagation::HandleCache::NewHandle<>(art::ObjPtr<>) Test: Rely on TreeHugger. Bug: 34053922 Change-Id: I160990f3a89aadffc9e6753da30b448937f8eaf0
2016-11-03ART: Add "explicit" to constructors Andreas Gampe
Add explicit to two constructors with single argument. Bug: 32619234 Test: m Change-Id: I6ee6c8264d76017247e2236170c776c801719a0a
2016-10-12Replace StackHandleScopeCollection with VariableSizedHandleScope Mathieu Chartier
VariableSizedHandleScope's internal handle scopes are not pushed directly on the thread. This means that it is safe to intermix with other types of handle scopes. Added test. Test: clean-oat-host && test-art-host Change-Id: Id2fd1155788428f394d49615d337d9134824c8f0
2016-10-03Move ArtField to ObjPtr Mathieu Chartier
Added EXPECT_OBJ_PTR_EQ and variants to gtests. Fixed moving GC bugs in: ClassLinker::CreatePathClassLoader ClassLinkerTest: StaticFields ObjPtr Decode call sites: 186 -> 181. Some tests fail due to ResolvedFieldAccessTest, will fix in follow up CL. Bug: 31113334 Test: test-art-host CC baker Change-Id: I8b266ad00f3c20c8cbe7cfdf280d175083df0b88
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-09-02Clean up some includes. Vladimir Marko
Remove some unnecessary includes from header files, replace others with forward references and add includes to source files as needed. Reduce dependency on stack.h by pulling StackReference<> out to its own file. Test: m test-art-host Change-Id: I0fb182145e328870cbd918b0ef6ae2950223c1b2
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
2016-08-01ART: Convert pointer size to enum Andreas Gampe
Move away from size_t to dedicated enum (class). Bug: 30373134 Bug: 30419309 Test: m test-art-host Change-Id: Id453c330f1065012e7d4f9fc24ac477cc9bb9269
2016-01-26ART: Remove some unnecessary mutator lock annotations. Vladimir Marko
The StackReference<> pointer held by a Handle<> can be used without holding the mutator lock. We already do that when we copy Handle<>s around. Only accessing the actual content of the pointed-to StackReference<> needs to be done while holding the mutator lock. Change-Id: I5f93bd7e277383192f1f16dff6883ecb26387414
2015-08-12Remove unnecessary `explicit` qualifiers on constructors. Roland Levillain
Change-Id: Id12e392ad50f66a6e2251a68662b7959315dc567
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-26ART: Clean up arm64 kNumberOfXRegisters usage. Vladimir Marko
Avoid undefined behavior for arm64 stemming from 1u << 32 in loops with upper bound kNumberOfXRegisters. Create iterators for enumerating bits in an integer either from high to low or from low to high and use them for <arch>Context::FillCalleeSaves() on all architectures. Refactor runtime/utils.{h,cc} by moving all bit-fiddling functions to runtime/base/bit_utils.{h,cc} (together with the new bit iterators) and all time-related functions to runtime/base/time_utils.{h,cc}. Improve test coverage and fix some corner cases for the bit-fiddling functions. Bug: 13925192 Change-Id: I704884dab15b41ecf7a1c47d397ab1c3fc7ee0f7
2015-04-06ART: Enable Clang's -Wdeprecated Andreas Gampe
Replace throw() with noexcept. Add default copy constructors and copy assignment constructors for cases with destructors, as the implicit definition is deprecated. Change-Id: Ice306a3f510b072b00bec4d4360f7c8055135c9d
2015-02-19Reference type propagation Calin Juravle
- propagate reference types between instructions - remove checked casts when possible - add StackHandleScopeCollection to manage an arbitrary number of stack handles (see comments) Change-Id: I31200067c5e7375a5ea8e2f873c4374ebdb5ee60
2015-01-08Add VerifyObject to StackHandleScope::SetReference Mathieu Chartier
Helps catch GC bugs. Also moved some of the HandleScope logic to the inl file. Bug: 13054004 Change-Id: I81b9dd717092b6a467fcd28b4df0089ec075dd44
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-10-27Fix 64 bit build Mathieu Chartier
Buggy compiler. (cherry picked from commit 7989d22642415e1e4d608e210284834951bd0a39) Change-Id: Id16c83fc7963ca89fd7fae32dd15ae342cc7f064
2014-10-27Optimize method linking Mathieu Chartier
Added more inlining, removed imt array allocation and replaced it with a handle scope. Removed some un-necessary handle scopes. Added logic to base interface method tables from the superclass so that we dont need to reconstruct for every interface (large win). Facebook launch Dalvik KK MR2: TotalTime: 3165 TotalTime: 3652 TotalTime: 3143 TotalTime: 3298 TotalTime: 3212 TotalTime: 3211 Facebook launch TOT before: WaitTime: 3702 WaitTime: 3616 WaitTime: 3616 WaitTime: 3687 WaitTime: 3742 WaitTime: 3767 After optimizations: WaitTime: 2903 WaitTime: 2953 WaitTime: 2918 WaitTime: 2940 WaitTime: 2879 WaitTime: 2792 LinkInterfaceMethods no longer one of the hottest methods, new list: 4.73% art::ClassLinker::LinkVirtualMethods(art::Thread*, art::Handle<art::mirror::Class>) 3.07% art::DexFile::FindClassDef(char const*) const 2.94% art::mirror::Class::FindDeclaredStaticField(art::mirror::DexCache const*, unsigned int) 2.90% art::DexFile::FindStringId(char const*) const Bug: 18054905 Bug: 16828525 (cherry picked from commit 1fb463e42cf1d67595cff66d19c0f99e3046f4c4) Change-Id: I27cc70178fd3655fbe5a3178887fcba189d21321
2014-10-21Avoid strict-aliasing problems with Handles. Ian Rogers
Replace use of reinterpret_cast with down_cast. Bug: 18074773 Change-Id: Id42d462f2798f69a2210e5912f441c868b8b5812
2014-10-10Work around ICE bugs with MIPS GCC and O1. Ian Rogers
Also, work around GCC warning bugs where array accesses with explicit bounds checks are flagged as being out-of-bounds. Significantly, clean-up the HandleScope so the array accesses don't appear out-of-bounds at compile time. Change-Id: I5d66567559cc1f97cd0aa02c0df8575ebadbfe3d
2014-09-15ART: Rename Handle hierarchy Andreas Gampe
Bring the names in line with normal OO principles: ConstHandle becomes Handle, and Handle becomes MutableHandle. Change-Id: I0f018eb7ba28bc422e3a23dd73a6cbe6fc2d2044
2014-07-16Remove object_utils.h. Ian Rogers
Break into object_lock, field_helper and method_helper. Clean up header files following this. Also tidy some of the Handle code in response to compiler errors when resolving the changes in this CL. Change-Id: I73e63015a0f02a754d0866bfaf58208aebcaa295
2014-07-15Break apart header files. Ian Rogers
Create libart-gtest for common runtime and compiler gtest routines. Rename CompilerCallbacksImpl that is quick compiler specific. Rename trace clock source constants to not use the overloaded profiler term. Change-Id: I4aac4bdc7e7850c68335f81e59a390133b54e933
2014-06-04Fix compiler warnings. Mathieu Chartier
Added GetReference, GetHandle to StackHandleScope to prevent the compiler from optimizing away these loads/stores from inline functions. Change-Id: I4db02dd3194665d844292e74e3a7d7c80e730e06
2014-05-29ART: Use StackReference in Quick Stack Frame Andreas Gampe
The method reference at the bottom of a quick frame is a stack reference and not a native pointer. This is important for 64b architectures, where the notions do not coincide. Change key methods to have StackReference<mirror::ArtMethod>* parameter instead of mirror::ArtMethod**. Make changes to invoke stubs for 64b archs, change the frame setup for JNI code (both generic JNI and compilers), tie up loose ends. Tested on x86 and x86-64 with host tests. On x86-64, tests succeed with jni compiler activated. x86-64 QCG was not tested. Tested on ARM32 with device tests. Fix ARM64 not saving x19 (used for wSUSPEND) on upcalls. Tested on ARM64 in interpreter-only + generic-jni mode. Fix ARM64 JNI Compiler to work with the CL. Tested on ARM64 in interpreter-only + jni compiler. Change-Id: I77931a0cbadd04d163b3eb8d6f6a6f8740578f13
2014-05-16Change ObjectLock to take Handle instead of Handle pointer. Mathieu Chartier
Change-Id: I9abdcdc5c9c9174634336b9250ab24c6aee434ec
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