summaryrefslogtreecommitdiffstats
path: root/runtime/reflection.cc
Commit message (Collapse)AuthorAgeFilesLines
* ART: Add missing GetInterfaceMethodIfProxyAndreas Gampe2015-10-121-4/+4
| | | | | | | | | | | | | Add missing uses of GetInterfaceMethodIfProxy in reflection code. Add a test case for a JNI call to a proxy method. Bug: https://code.google.com/p/android-developer-preview/issues/detail?id=2973 Bug: 23886441 (cherry picked from commit e80673245c0433a71a4930e460be5dc0920885b2) Change-Id: I5b66b64b5561fcee15d0314707d67e8abc02ce5b
* Move mirror::ArtMethod to nativeMathieu Chartier2015-06-021-35/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 (cherry picked from commit e401d146407d61eeb99f8d6176b2ac13c4df1e33) Change-Id: I622469a0cfa0e7082a2119f3d6a9491eb61e3f3d Fix some ArtMethod related bugs Added root visiting for runtime methods, not currently required since the GcRoots in these methods are null. Added missing GetInterfaceMethodIfProxy in GetMethodLine, fixes --trace run-tests 005, 044. Fixed optimizing compiler bug where we used a normal stack location instead of double on ARM64, this fixes the debuggable tests. TODO: Fix JDWP tests. Bug: 19264997 Change-Id: I7c55f69c61d1b45351fd0dc7185ffe5efad82bd3 ART: Fix casts for 64-bit pointers on 32-bit compiler. Bug: 19264997 Change-Id: Ief45cdd4bae5a43fc8bfdfa7cf744e2c57529457 Fix JDWP tests after ArtMethod change Fixes Throwable::GetStackDepth for exception event detection after internal stack trace representation change. Adds missing ArtMethod::GetInterfaceMethodIfProxy call in case of proxy method. Bug: 19264997 Change-Id: I363e293796848c3ec491c963813f62d868da44d2 Fix accidental IMT and root marking regression Was always using the conflict trampoline. Also included fix for regression in GC time caused by extra roots. Most of the regression was IMT. Fixed bug in DumpGcPerformanceInfo where we would get SIGABRT due to detached thread. EvaluateAndApplyChanges: From ~2500 -> ~1980 GC time: 8.2s -> 7.2s due to 1s less of MarkConcurrentRoots Bug: 19264997 Change-Id: I4333e80a8268c2ed1284f87f25b9f113d4f2c7e0 Fix bogus image test assert Previously we were comparing the size of the non moving space to size of the image file. Now we properly compare the size of the image space against the size of the image file. Bug: 19264997 Change-Id: I7359f1f73ae3df60c5147245935a24431c04808a [MIPS64] Fix art_quick_invoke_stub argument offsets. ArtMethod reference's size got bigger, so we need to move other args and leave enough space for ArtMethod* and 'this' pointer. This fixes mips64 boot. Bug: 19264997 Change-Id: I47198d5f39a4caab30b3b77479d5eedaad5006ab
* Fix updating of JNI references for String.<init>.Jeff Hao2015-05-271-4/+21
| | | | | | | | Was missing updates to globals and weak globals. Bug: 21288130 Bug: 21440428 Change-Id: I5f801f68b61f6b066b441b92ace367e6ba434789
* Intercept JNI invocation of String.<init> methods.Jeff Hao2015-05-201-3/+44
| | | | | | | | | | | 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 Change-Id: Ib4db402c178bc37188d5c5faf30b6e4fdc747b17
* Remove unused InvokeWithShadowFrameSebastien Hertz2015-05-071-17/+0
| | | | | | | This is an artifact of the Portable compiler, probably left after its removal https://android-review.googlesource.com/119049. Change-Id: I7f6caa008e37e7a93792840c79713e90d0c7e1e1
* Replace String CharArray with internal uint16_t array.Jeff Hao2015-04-271-7/+14
| | | | | | | | | | | | Summary of high level changes: - Adds compiler inliner support to identify string init methods - Adds compiler support (quick & optimizing) with new invoke code path that calls method off the thread pointer - Adds thread entrypoints for all string init methods - Adds map to verifier to log when receiver of string init has been copied to other registers. used by compiler and interpreter Change-Id: I797b992a8feb566f9ad73060011ab6f51eb7ce01
* Move Class.newInstance to nativeMathieu Chartier2015-04-251-12/+20
| | | | | | | | | | | | | | 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
* Fix reflection handling and test flakinessMathieu Chartier2015-04-231-1/+11
| | | | | | | | | | | | Fixed reflection invoke to handle exceptions which occur from FindClass or NewObject by throwing these instead of the expected InvocationTargetException. Added test case to 080 for this reflection invoke. Fixed println throwing OOM in 104-growth-limit. Change-Id: I65766e7c3478e299da06fdc3a521fe3f3e8fdba9
* Add AbstractMethod, Constructor, MethodMathieu Chartier2015-04-211-5/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-9/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-3/+3
| | | | | | | | 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-16/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-25/+18
| | | | | | | Note that this is a cleanup change, and has no functionality change. The ThrowLocation had no use anymore. Change-Id: I3d2126af1dc673cec3a0453ff3d56a172663a5f6
* Compute the right catch location for the debugger.Nicolas Geoffray2015-03-091-1/+1
| | | | | | Also remove tls ThrowLocation, it is not needed anymore. Change-Id: I78fddf09ce968ca475e39c17fa76d699c589c8d9
* Remove portable.Elliott Hughes2014-12-121-6/+0
| | | | Change-Id: I3bf3250fa866fd2265f1b115d52fa5dedc48a7fc
* Move GetClassFromTypeIdx to ArtMethod.Ian Rogers2014-12-021-20/+19
| | | | | | | Move GetClassFromTypeIdx out of MethodHelper into ArtMethod in preparation for the removal of MethodHelper. Change-Id: I9c03dd8c821944c606ea08cdf92afc80c4275247
* Remove MethodHelper from the interpreter.Ian Rogers2014-12-021-4/+5
| | | | | | | | | 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
* Remove -Wno-unused-parameter and -Wno-sign-promo from base cflags.Ian Rogers2014-11-031-3/+2
| | | | | | | | | | | 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
* Move MethodHelper::GetReturnType to mirror::ArtMethod.Ian Rogers2014-10-281-2/+2
| | | | | | Also, fix missing handle in HasSameSignatureWithDifferentClassLoaders. Change-Id: I9e1ffd09be950ecc8346fc3c485760d82d9ecab3
* Make ART compile with GCC -O0 again.Ian Rogers2014-10-161-3/+4
| | | | | | | | | | | | | 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-4/+14
| | | | | | Bug: 17618578 Bug: 17614623 Change-Id: I0e3f15e676acd6ed5844fc86e136f75cc335372d
* Optimize get/set reflection performanceMathieu Chartier2014-09-261-85/+10
| | | | | | | | | | | | | | 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
* Compile time performance improvements focusing on interpret-only.Ian Rogers2014-09-121-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Reduce virtual method dispatch in the method verifier and make more code inline-able. Add a StringPiece with const char* equality operator to avoid redundant StringPieces and strlens. Remove back link from register line to verifier and pass as argument to reduce size of RegisterLine. Remove instruction length from instruction flags and compute from the instruction, again to reduce size. Add suspend checks to resolve and verify to allow for more easy monitor inflation and reduce contention on Locks::thread_list_suspend_thread_lock_. Change ThrowEarlierClassFailure to throw pre-allocated exception. Avoid calls to Thread::Current() by passing self. Template specialize IsValidClassName. Make ANR reporting with SIGQUIT run using checkpoints rather than suspending all threads. This makes the stack/lock analysis less lock error prone. Extra Barrier assertions and condition variable time out is now returned as a boolean both from Barrier and ConditionVariable::Wait. 2 threaded host x86-64 interpret-only numbers from 341 samples: Before change: Avg 176.137ms 99% CI 3.468ms to 1060.770ms After change: Avg 139.163% 99% CI 3.027ms to 838.257ms Reduction in average compile time after change is 20.9%. Slow-down without change is 26.5%. Bug: 17471626 - Fix bug where RegTypeCache::JavaLangObject/String/Class/Throwable could return unresolved type when class loading is disabled. Bug: 17398101 Change-Id: Id59ce3cc520701c6ecf612f7152498107bc40684
* Merge "Reduce stack usage for overflow checks"Dave Allison2014-08-121-0/+49
|\
| * Reduce stack usage for overflow checksDave Allison2014-08-131-0/+49
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reduces the stack space reserved for overflow checks to 12K, split into an 8K gap and a 4K protected region. GC needs over 8K when running in a stack overflow situation. Also prevents signal runaway by detecting a signal inside code that resulted from a signal handler invokation. And adds a max signal count to the SignalTest to prevent it running forever. Also reduces the number of iterations for the InterfaceTest as this was taking (almost) forever with the --trace option on run-test. Bug: 15435566 Change-Id: Id4fd46f22d52d42a9eb431ca07948673e8fda694
* | Avoid use of std::string where we have const char*.Ian Rogers2014-08-121-7/+8
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | Removing the ClassHelper caused std::string creation for all calls to Class::GetDescriptor and a significant performance regression. Make the std::string an out argument so the caller can maintain it and its life time while allowing GetDescriptor to return the common const char* case. Don't generate GC maps when compilation is disabled. Remove other uses of std::string that are occuring on critical paths. Use the cheaper SkipClass in CompileMethod in CompilerDriver. Specialize the utf8 as utf16 comparison code for the common shorter byte encoding. Force a bit of inlining, remove some UNLIKELYs (they are prone to pessimizing code), add some LIKELYs. x86-64 host 1-thread interpret-only of 57 apks: Before: 29.539s After: 23.467s Regular compile: Before: 1m35.347s After: 1m20.056s Bug: 16853450 Change-Id: Ic705ea24784bee24ab80084d06174cbf87d557ad
* Wire up check JNI force copy mode.Ian Rogers2014-08-081-12/+34
| | | | | | | | | | | | 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
* Fix x86 build.Ian Rogers2014-07-161-1/+1
| | | | | | | Also fix attributes/annotalysis on entrypoint_utils functions now we have clang that is smarter wrt warnings than GCC. Change-Id: I69257b4ad9a27d07acbc973d21a1cfa4260a8ed6
* Remove object_utils.h.Ian Rogers2014-07-161-3/+3
| | | | | | | | | 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
* Break apart header files.Ian Rogers2014-07-151-0/+5
| | | | | | | | 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
* Fix reflection access check for attached native threads.Vladimir Marko2014-06-121-0/+4
| | | | | Bug: 15539150 Change-Id: Ie580cad1c0169d550162bcc878b07643259323c4
* Change MethodHelper to use a Handle.Mathieu Chartier2014-06-091-23/+37
| | | | | | | | | | | Added ConstHandle to help prevent errors where you modify the value stored in the handle of the caller. Also fixed compaction bugs related to not knowing MethodHelper::GetReturnType can resolve types. This bug was present in interpreter RETURN_OBJECT. Bug: 13077697 Change-Id: I71f964d4d810ab4debda1a09bc968af8f3c874a3
* Merge "Now we have a proper C++ library, use std::unique_ptr."Ian Rogers2014-05-201-1/+1
|\
| * Now we have a proper C++ library, use std::unique_ptr.Ian Rogers2014-05-191-1/+1
| | | | | | | | | | | | | | Also remove the Android.libcxx.mk and other bits of stlport compatibility mechanics. Change-Id: Icdf7188ba3c79cdf5617672c1cfd0a68ae596a61
* | Don't get and restore thread state for ScopedFastNativeObjectAccess.Mathieu Chartier2014-05-191-11/+15
|/ | | | | | | 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
* Delete ClassHelper and fix compaction bug in GetDirectInterfaceMathieu Chartier2014-05-181-16/+15
| | | | | | | | | | | Cleanup helps to prevent compaction bugs. Fixed a fairly serious compaction error caused by calling ClassHelper::GetDirectInterface without handling the case where it causes thread suspension due to ResolveType. Bug: 8981901 Change-Id: I82b3bb6dd48d21eb6ece7aae0733c4a23c2bc408
* Add Handle/HandleScope and delete SirtRef.Mathieu Chartier2014-05-131-3/+4
| | | | | | | | | | | | | | | | 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
* Fix reflection access checks for app compatibility.Jeff Hao2014-04-011-2/+1
| | | | | | | | Also updates field access test. Bug: 13740995 Change-Id: I224712cfcb0c05429b831c26980cabad7bdef49a
* Revert "Fix access checks for app compatibility."Jeff Hao2014-04-011-1/+2
| | | | | | This reverts commit b59b2c8dbdea2a6a3086378f2cf65adc9bc282cd. Change-Id: I718658b8450a5ce6249df317b635f63356b1ce3c
* Fix access checks for app compatibility.Jeff Hao2014-04-011-2/+1
| | | | Change-Id: I3191e5e92d30e9bee24051fd305296ddcf143e18
* Some fixes for comments and implied conversions.Jeff Hao2014-03-281-6/+6
| | | | | | | 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/+35
| | | | | | | Art side of this change. Has a corresponding libcore change. Bug: 13620925 Change-Id: Ie67f802a2a400e8212b489b9a261b7028422d8ba
* Reflection tidying.Ian Rogers2014-03-261-67/+39
| | | | | | | | 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
* Improvements to Field.get/set.Ian Rogers2014-03-211-2/+1
| | | | | | | | | | | | Avoid unnecessary repeated computation in Field.get/set. Refactor FromReflectedField and FromReflectedMethod into common helpers in mirror::ArtField and mirror::ArtMethod, and make use of thereby avoiding transitions through JNI. Avoid JNI use from within FromReflectedField and FromReflectedMethod. Tidy up Field.get/set wrt moving collector support. Bug: 12189533 Change-Id: I643ab3474bade4abac3a3ae2b6e373b2bb0891c8
* Work-around GCC polymorphism problems.Ian Rogers2014-03-141-10/+10
| | | | Change-Id: Ica1d8e6840cdd9ba493405e66c1728b5da9540a2
* 64bit build fix.Ian Rogers2014-03-141-2/+2
| | | | Change-Id: I8c597217955d12b215bdcf1d92ca5fab9a7ed6e0
* Refactor reflective method invocation.Ian Rogers2014-03-141-31/+450
| | | | | | | | | | 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
* Work in the direction of hard float quick ABIs.Ian Rogers2014-02-111-3/+13
| | | | | | | | | | Pass a shorty to ArtMethod::Invoke so that register setup can use it. Document x86-64 ABI. Add extra debug output for one JNI native method registration fails, namely a dump of the Class and its dex file's location. Add hack to get testing of OatMethod's without GC maps working in 64bit. Change-Id: Ic06b68e18eac33637df2caf5e7e775ff95ae70f3
* Enable moving classes.Mathieu Chartier2013-12-101-2/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | Slight reduction in Zygote size, memory savings are in the noise. Before: Zygote size: 8739224 After: Zygote size: 8733568 Fixed a bug where we didn't set the concurrent start bytes after switching the allocator from bump pointer to ROSAlloc in the zygote. This caused excessive memory usage. Added the method verifiers as roots to fix an issue caused by RegTypes holding a Class*. Added logic to clear card table in the SemiSpace collector, this reduces DalvikOther from ~2400k -> ~1760k when using the SemiSpace collector. Added a missing lock to the timing loggers which caused a rare one time crash in std::set. Bug: 11771255 Bug: 8499494 Bug: 10802951 Change-Id: I99d2b528cd51c1c5ed7012e3220b3aefded680ae
* Don't use UTF16 length as length for MUTF8.Ian Rogers2013-10-301-1/+1
| | | | | | Bug 11367555. Change-Id: Ia0b07072a1a49d435c3b71ed9a668b316b7ff5d8