summaryrefslogtreecommitdiff
path: root/runtime/reflection.h
Commit message (Collapse)AuthorAgeFilesLines
* Fix incorrect image pointer size for unstarted runtimeliulvping2020-12-221-0/+2
| | | | | | | | | | | | | | | In unstarted runtime, we should use image pointer size from current runtime, not kRuntimePointerSize for invoke method. Because in host dex2oat, the kRuntimePointerSize is always k64, and then invoke method could get a null ArtMethod object in compiling boot image for arch 32, such cause a native crash issue. Bug: 176012754 Test: m test-art-host-gtest-unstarted_runtime_test Signed-off-by: liulvping <liulvping@xiaomi.com> Change-Id: I8ff4cf013cbe94114c38edfdf30ff509a047a761
* Avoid useless EncodeArtMethod followed by DecodeArtMethodAlex Light2019-06-281-4/+16
| | | | | | | | | | | | | | | In a handful of places we would perform an EncodeArtMethod to call a reflection invoke function which would immediately Decode the method. This could cause issues when using opaque-jni-ids:true since the Encode can cause an OOM exception. To avoid this (and because Encode and Decode are perfect inverses) we changed the Invoke* reflection functions to also accept ArtMethod*s directly and changed callers to use these functions when appropriate. Test: (with child CL) ./test.py --host --jit --debuggable Bug: 134162467 Change-Id: Id2f5b0f49a99405e238ce5b61a22ef9245e523a5
* ART: Move to using locks.h instead of mutex.hAndreas Gampe2018-12-061-1/+1
| | | | | | | | When only annotating lock requirements, use locks.h. Bug: 119869270 Test: mmma art Change-Id: I1608b03254712feff0072ebad012c3af0cc3dda4
* ART: Improve Constructor.newInstanceAndreas Gampe2018-06-281-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | Special-case InvokeMethod to be constructor-specific so as to avoid unnecessary and duplicate checks. Refactor for some code sharing. Reduces Constructor.newInstance for Integer by approximately 15% (ten runs of 10000000 invocations, reporting mean per invocation, host x86-64 optimizing, perf stat numbers are for complete run and do not exclude, for example, setup and prologue GC): Before After (perf stat) Instructions 2503.4 2149.8 Branches 450.8 384.4 Branch-misses 1.83 0.85 (time) Time (ns) 335.17 278.58 Bug: 20269715 Test: mmma art Test: m test-art-host Change-Id: Id105e542a19d72efaace60ad39fcef5e42dde006
* Add const to match <jni.h>.Elliott Hughes2018-06-151-2/+2
| | | | | | Bug: http://b/29104801 Test: builds, booots Change-Id: I4fd157c4f9df0f99968863f467815fb2bdd9bf6a
* Header library to remove dependence on runtime/David Sehr2018-02-281-1/+1
| | | | | | | | | | | | Add a new header library to remove libdexfile and others' dependence on runtime (typically runtime/base) includes in libdexfile. Also a small step to tease dexlayout and profman away from relying on these as well. Bug: 22322814 Test: make -j 50 checkbuild make -j 50 test-art-host-gtest Change-Id: I38e2fe399a75f4bc6318c77a71954c00ea73ec2b
* cpplint: Cleanup errorsIgor Murashkin2017-11-081-2/+2
| | | | | | | | | Cleanup errors from upstream cpplint in preparation for moving art's cpplint fork to upstream tip-of-tree cpplint. Test: cd art && mm Bug: 68951293 Change-Id: I15faed4594cbcb8399850f8bdee39d42c0c5b956
* Argument conversions for setter/getter MethodHandles.Orion Hodson2016-11-081-0/+6
| | | | | | | Test: m test-art-host-run-test-959-invoke-polymorphic-accessors Bug: 30550796 Change-Id: I9898605fc9f9f8a80f47f9559f3ccb99b02b07c8
* Use ObjPtr for reflection.cc/h/inlMathieu Chartier2016-09-271-20/+44
| | | | | | | | | | | | | | Changed Pretty helpers to use this to reduce usage of Decode. The eventual goal is not have almost any calls to ObjPtr::Decode. Moved ObjPtr out of mirror namespace for convenience. Added more PoisonObjectPointers calls in class linker, thread suspension. Bug: 31113334 Test: test-art-host Change-Id: I44d08db5143d95ed1b65e2f00f9749ef5cf379f7
* Make ScopedAssertNoThreadSuspension no overhead for non-debugMathieu Chartier2016-09-131-2/+4
| | | | | | | | | | | Previously it required Thread::Current() which may not be free. The plan is to add a lot more ScopedAssertNoThreadSuspension in the codebase. Also cleaned up callers. Bug: 31458474 Change-Id: I5a1621a5435476504d22266cc01a9bf26aab7568
* ART: SHARED_REQUIRES to REQUIRES_SHAREDAndreas Gampe2016-08-301-15/+15
| | | | | | | | | 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
* Move to newer clang annotationsMathieu Chartier2015-07-221-15/+15
| | | | | | | | | | | | | | | 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
* Move mirror::ArtMethod to nativeMathieu Chartier2015-05-291-1/+1
| | | | | | | | | | | | | 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
* Fix updating of JNI references for String.<init>.Jeff Hao2015-05-271-0/+3
| | | | | | | | | | | Was missing updates to globals and weak globals. Bug: 21288130 Bug: 21440428 (cherry picked from commit 1a302fb4f84525289c1cf7a437f5be1999a75251) Change-Id: I41b64e8aae906f5986de483db096d8191e45f260
* Intercept JNI invocation of String.<init> methods.Jeff Hao2015-05-201-3/+3
| | | | | | | | | | | | | | libmono uses JNI AllocObject and CallNonvirtualVoidMethod to create and initialize a string instead of using the recommended NewObject. This change adds an intercept to change the String.<init> call to a StringFactory call instead. Then, it uses the object id of the original string object referrer and maps it to the result of the StringFactory. Bug: 21288130 (cherry picked from commit 15e9ad1d028d7f12cb598b075453173532a00d91) Change-Id: I3421c43722c07397da4a398c2ca9110e1d40bcfa
* Remove unused InvokeWithShadowFrameSebastien Hertz2015-05-071-4/+0
| | | | | | | This is an artifact of the Portable compiler, probably left after its removal https://android-review.googlesource.com/119049. Change-Id: I7f6caa008e37e7a93792840c79713e90d0c7e1e1
* Move Class.newInstance to nativeMathieu Chartier2015-04-251-0/+9
| | | | | | | | | | | | | | Avoids 1 allocation and several JNI transitions. Before: Class_classNewInstance: 4462.39 ns; σ=39.42 ns @ 3 trials After: Class_classNewInstance: 1073.39 ns; σ=24.14 ns @ 10 trials Bug: 20269715 Bug: 20566996 Change-Id: Icd52155ce79a978a4d869855bfdfd7735abd8187
* Add AbstractMethod, Constructor, MethodMathieu Chartier2015-04-211-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Moves functionality to ART from libcore. Precursor to moving ArtMethods to native. Mostly performance improvements. N5 perf before (irrelevant results removed): Class_getConstructor 962.87 =========== Class_getDeclaredMethod 2394.37 ============================ Class_getMethod 2509.20 ============================== Class_newInstance 1999.81 ======================= Method_invokeI 1439.02 ================= Method_invokePreBoxedI 1415.82 ================ Method_invokeStaticI 1456.24 ================= Method_invokeStaticPreBoxedI 1427.32 ================= Method_invokeStaticV 814.47 ========= Method_invokeV 816.56 ========= After: benchmark ns linear runtime Class_getConstructor 1302.04 ================ Class_getDeclaredMethod 1459.01 ================== Class_getMethod 1560.40 =================== Class_newInstance 2029.94 ========================= Method_invokeI 1312.89 ================ Method_invokePreBoxedI 1255.01 =============== Method_invokeStaticI 1289.13 =============== Method_invokeStaticPreBoxedI 1196.52 ============== Method_invokeStaticV 790.82 ========= Method_invokeV 791.73 ========= Performance improvements are more than just fixing regressions introduced in: http://android-review.googlesource.com/#/c/146069/ Bug: 19264997 Change-Id: Ife79c469fdb09f30e3aefcfc3e0ce5ed32303fce
* Move ArtField to nativeMathieu Chartier2015-04-101-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add linear alloc. Moved ArtField to be native object. Changed image writer to put ArtFields after the mirror section. Savings: 2MB on low ram devices 4MB on normal devices Total PSS measurements before (normal N5, 95s after shell start): Image size: 7729152 bytes 23112 kB: .NonMoving 23212 kB: .NonMoving 22868 kB: .NonMoving 23072 kB: .NonMoving 22836 kB: .NonMoving 19618 kB: .Zygote 19850 kB: .Zygote 19623 kB: .Zygote 19924 kB: .Zygote 19612 kB: .Zygote Avg: 42745.4 kB After: Image size: 7462912 bytes 17440 kB: .NonMoving 16776 kB: .NonMoving 16804 kB: .NonMoving 17812 kB: .NonMoving 16820 kB: .NonMoving 18788 kB: .Zygote 18856 kB: .Zygote 19064 kB: .Zygote 18841 kB: .Zygote 18629 kB: .Zygote 3499 kB: .LinearAlloc 3408 kB: .LinearAlloc 3424 kB: .LinearAlloc 3600 kB: .LinearAlloc 3436 kB: .LinearAlloc Avg: 39439.4 kB No reflection performance changes. Bug: 19264997 Bug: 17643507 Change-Id: I10c73a37913332080aeb978c7c94713bdfe4fe1c
* Fix some reflection errorsMathieu Chartier2015-03-291-1/+1
| | | | | | | | Fixed incorrectly using 2nd frame instead of 1st in VerifyAccess. Added regression test to ART. Fixed broken setShort, getDeclaredFieldInternal. Change-Id: I4b21d52d998cb768fe9503b8bccec506b7b972e5
* Add AccessibleObject and Field to mirrorMathieu Chartier2015-03-291-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Main motivation is to remove all the functionality / field access on java side to ArtField. Also comes with some reflection speedups / slowdowns. Summary results: getDeclaredField/getField are slower mostly due to JNI overhead. However, there is a large speedup in getInt, setInt, GetInstanceField, and GetStaticField. Before timings (N5 --compiler-filter=everything): benchmark ns linear runtime Class_getDeclaredField 782.86 === Class_getField 832.77 === Field_getInt 160.17 = Field_setInt 195.88 = GetInstanceField 3214.38 ============== GetStaticField 6809.49 ============================== After: Class_getDeclaredField 1068.15 ============ Class_getField 1180.00 ============== Field_getInt 121.85 = Field_setInt 139.98 = GetInstanceField 1986.15 ======================= GetStaticField 2523.63 ============================== Bug: 19264997 Change-Id: Ic0d0fc1b56b95cd6d60f8e76f19caeaa23045c77
* Remove ThrowLocation.Nicolas Geoffray2015-03-101-4/+2
| | | | | | | Note that this is a cleanup change, and has no functionality change. The ThrowLocation had no use anymore. Change-Id: I3d2126af1dc673cec3a0453ff3d56a172663a5f6
* Remove MethodHelper.Ian Rogers2014-12-021-1/+0
| | | | | | | Move use as a shorty processor to only use in portable. Move GetNumberOfReferenceArgsWithoutReceiver to mirror::ArtMethod. Change-Id: I7ded3d05315c84bce4ab19cb330ef74289da4bb3
* Remove MethodHelper from the interpreter.Ian Rogers2014-12-021-1/+1
| | | | | | | | | Use ShadowFrame to get the executing method to avoid a handle for the current method. Various associated bits of header file clean-up and removal of an unnecessary use of MethodHelper in CompilerDriver. Change-Id: I3b6f4413701e8fc6b0c58b0041a0dd15472bedaa
* Make ART compile with GCC -O0 again.Ian Rogers2014-10-161-1/+1
| | | | | | | | | | | | | Tidy up InstructionSetFeatures so that it has a type hierarchy dependent on architecture. Add to instruction_set_test to warn when InstructionSetFeatures don't agree with ones from system properties, AT_HWCAP and /proc/cpuinfo. Clean-up class linker entry point logic to not return entry points but to test whether the passed code is the particular entrypoint. This works around image trampolines that replicate entrypoints. Bug: 17993736 Change-Id: I5f4b49e88c3b02a79f9bee04f83395146ed7be23
* ART: Better IllegalAccessException messageAndreas Gampe2014-09-291-1/+1
| | | | | | Bug: 17618578 Bug: 17614623 Change-Id: I0e3f15e676acd6ed5844fc86e136f75cc335372d
* Optimize get/set reflection performanceMathieu Chartier2014-09-261-4/+5
| | | | | | | | | | | | | | Speedups mostly from reducing how often access checks are needed, and adding more inlining, and adding templates. Field_getInt from ~850ns -> 350ns. Field_setInt from ~900ns -> 370ns. Bug: 14063288 (cherry picked from commit ffc788cb7b5b9f53734d7bb8af2d5e45d885546b) Change-Id: I2441581ff3478c6ae43b6aa49939ff3f07555ec8
* Wire up check JNI force copy mode.Ian Rogers2014-08-081-0/+1
| | | | | | | | | | | | Increase check JNI checks. Break apart jni_internal.h in to jni_env_ext.h and java_vm_ext.h. Fix the abuse of ScopedObjectAccess/annotalysis by ScopedCheck in the case of VM routines. Make class loader override and shared library class loader JNI global references rather than mirror pointers. Clean-ups to native bridge. Change-Id: If7c6110b5aade7a402bfb67534af86a7b2cdeb55
* Don't get and restore thread state for ScopedFastNativeObjectAccess.Mathieu Chartier2014-05-191-7/+7
| | | | | | | Before we would ensure that we were runnable for fast native object access. However, these are done when you are already runnable. Change-Id: Ia4c6e4c83d146fe2a988b37b3133ca46b0f0fa42
* Some fixes for comments and implied conversions.Jeff Hao2014-03-281-1/+1
| | | | | | | Addresses comments in: https://android-review.googlesource.com/#/c/89148/3 Change-Id: If21cfaa541210c8702371efd1e6d4f071a7b9ec3
* Add access checks to Method and Field reflection.Jeff Hao2014-03-281-1/+4
| | | | | | | Art side of this change. Has a corresponding libcore change. Bug: 13620925 Change-Id: Ie67f802a2a400e8212b489b9a261b7028422d8ba
* Reflection tidying.Ian Rogers2014-03-261-7/+4
| | | | | | | | Move out arguments to the right and make pointer not reference types. Remove unused unbox for argument routine. Simplify convert primitive routine for the case of identical types. Change-Id: I6456331b0f3f3e5f0b2c361a9f50b4ed1c9462a3
* Refactor reflective method invocation.Ian Rogers2014-03-141-2/+25
| | | | | | | | | | Move invocation code out of JNI internal into reflection, including ArgArray code. Make reflective invocation use the ArgArray to build arguments rather than allocating a jvalue[] and unboxing arguments into that. Move reflection part of jni_internal_test into reflection_test. Make greater use of fast JNI. Change-Id: Ib381372df5f9a83679e30e7275de24fa0e6b1057
* Refactor java.lang.reflect implementationBrian Carlstrom2013-08-131-6/+6
| | | | | | | | | | | Cherry-picked from commit ed41d5c44299ec5d44b8514f6e17f802f48094d1. Move to ArtMethod/Field instead of AbstractMethod/Field and have java.lang.reflect APIs delegate to ArtMethod/ArtField. Bug: 10014286. Change-Id: Iafc1d8c5b62562c9af8fb9fd8c5e1d61270536e7
* Fix multiple inclusion guards to match new pathnamesBrian Carlstrom2013-07-171-3/+3
| | | | Change-Id: Id7735be1d75bc315733b1773fba45c1deb8ace43
* Create separate Android.mk for main build targetsBrian Carlstrom2013-07-121-0/+59
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