summaryrefslogtreecommitdiffstats
path: root/runtime/interpreter/interpreter.cc
Commit message (Collapse)AuthorAgeFilesLines
* ART: Refactor UnstartedRuntime for testingAndreas Gampe2015-05-211-2/+2
| | | | | | | | | | | | Expose the UnstartedRuntime implementation functions as private static methods of a class. Add a gtest that can invoke these functions. Add sample tests for String and Memory. Bug: 21173514 (cherry picked from commit 799681b176ad25437ce2849639f54f610dcbf684) Change-Id: Ib5bde6347fafaf7607c642542ea7d5938ff4b1df
* Fix mismatched new[]/delete.Christopher Ferris2015-05-041-1/+1
| | | | | | | Another two cases where a new[] is used but only a delete occurs. Bug: 18202869 Change-Id: If68264807150f3a9783e44ef8823cc366bff8df2
* Replace NULL with nullptrMathieu Chartier2015-04-221-16/+28
| | | | | | | Also fixed some lines that were too long, and a few other minor details. Change-Id: I6efba5fb6e03eb5d0a300fddb2a75bf8e2f175cb
* Revert "Revert "Deoptimization-based bce.""Mingyao Yang2015-04-011-1/+3
| | | | | | This reverts commit 0ba627337274ccfb8c9cb9bf23fffb1e1b9d1430. Change-Id: I1ca10d15bbb49897a0cf541ab160431ec180a006
* Revert "Deoptimization-based bce."Andreas Gampe2015-03-241-3/+1
| | | | | | | | | | This breaks compiling the core image: Error after BCE: art::SSAChecker: Instruction 219 in block 1 does not dominate use 221 in block 1. This reverts commit e295e6ec5beaea31be5d7d3c996cd8cfa2053129. Change-Id: Ieeb48797d451836ed506ccb940872f1443942e4e
* Deoptimization-based bce.Mingyao Yang2015-03-231-1/+3
| | | | | | | | | | | | | | | | | | | A mechanism is introduced that a runtime method can be called from code compiled with optimizing compiler to deoptimize into interpreter. This can be used to establish invariants in the managed code If the invariant does not hold at runtime, we will deoptimize and continue execution in the interpreter. This allows to optimize the managed code as if the invariant was proven during compile time. However, the exception will be thrown according to the semantics demanded by the spec. The invariant and optimization included in this patch are based on the length of an array. Given a set of array accesses with constant indices {c1, ..., cn}, we can optimize away all bounds checks iff all 0 <= min(ci) and max(ci) < array-length. The first can be proven statically. The second can be established with a deoptimization-based invariant. This replaces n bounds checks with one invariant check (plus slow-path code). Change-Id: I8c6e34b56c85d25b91074832d13dba1db0a81569
* ART: Refactor unstarted runtimeAndreas Gampe2015-03-111-106/+3
| | | | | | | Refactor and clean up unstarted runtime. Bug: 19542228 Change-Id: Ib3e4b3517e06e8242d4fed32ca59419fef553a47
* Fix exception handling during deoptimizationSebastien Hertz2015-01-231-1/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When interpreting a deoptimized shadow frame, we may start with a pending exception thrown by a previous deoptimized shadow frame (from a previous invoke). Therefore, we need to handle it before executing any instruction, otherwise we execute incorrect code. Because we need the DEX pc of the throwing instruction to find a matching catch handler, we initialize deoptimized shadow frames with the current DEX pc at the time the stack is deoptimized. When we are about to interpret a deoptimized shadow frame, we need to update the shadow frame with the DEX pc of the next instruction to interpret. There are three cases: - if there is no pending exception, this is the instruction following the current one. - if there is a pending exception and we found a matching catch handler, this is the first instruction of this handler. - if there is a pending exception but there is no matching catch handler, we do not execute the deoptimized shadow frame and continue to its caller. The verifier now fails when a method starts with a move-exception instruction. Indeed we cannot start executing a method with a pending exception. Bug: 19057915 Bug: 19041195 Bug: 18607595 Change-Id: I355ac81e6ac098edc7e3cc8c13dbfa24a2969ab2
* Remove MethodHelper from the interpreter.Ian Rogers2014-12-021-44/+32
| | | | | | | | | 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
* Change 64 bit ArtMethod fields to be pointer sizedMathieu Chartier2014-11-181-18/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | Changed the 64 bit entrypoint and gc map fields in ArtMethod to be pointer sized. This saves a large amount of memory on 32 bit systems. Reduces ArtMethod size by 16 bytes on 32 bit. Total number of ArtMethod on low memory mako: 169957 Image size: 49203 methods -> 787248 image size reduction. Zygote space size: 1070 methods -> 17120 size reduction. App methods: ~120k -> 2 MB savings. Savings per app on low memory mako: 125K+ per app (less active apps -> more image methods per app). Savings depend on how often the shared methods are on dirty pages vs shared. TODO in another CL, delete gc map field from ArtMethod since we should be able to get it from the Oat method header. Bug: 17643507 Change-Id: Ie9508f05907a9f693882d4d32a564460bf273ee8 (cherry picked from commit e832e64a7e82d7f72aedbd7d798fb929d458ee8f)
* ART: More warningsAndreas Gampe2014-11-041-1/+1
| | | | | | | Enable -Wno-conversion-null, -Wredundant-decls and -Wshadow in general, and -Wunused-but-set-parameter for GCC builds. Change-Id: I81bbdd762213444673c65d85edae594a523836e5
* Remove -Wno-unused-parameter and -Wno-sign-promo from base cflags.Ian Rogers2014-11-031-2/+5
| | | | | | | | | | | 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
* Tidy logging code not using UNIMPLEMENTED.Ian Rogers2014-10-241-1/+1
| | | | Change-Id: I7a79c1671a6ff8b2040887133b3e0925ef9a3cfe
* Make ART compile with GCC -O0 again.Ian Rogers2014-10-161-12/+13
| | | | | | | | | | | | | 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
* Handlerize methods across some GC points.Hiroshi Yamauchi2014-10-061-7/+7
| | | | | Bug: 12687968 Change-Id: I0d5b0a78488ba76db4d25991d8db95b24bb624e9
* Revert "Enable computed goto interpreter on the host"Sebastien Hertz2014-09-301-0/+28
| | | | | | This reverts commit 66d9bdb94f21106aaaa31a8fd686098672075e04. Bug: 17716550 Change-Id: Ib404242c86e96e8edf019a2dcc14f0f8294b79e8
* Some optimizations for the array alloc path.Hiroshi Yamauchi2014-09-251-2/+2
| | | | | | | | | | | | | | | | | - Force Array::Alloc() to be inlined. - Simplify the array size overflow check. - Turn fill_usable into a template parameter. - Remove a branch in Array::DataOffset() and avoid Primitive::ComponentSize(), which has a switch, in the array alloc path. - Strength reductions in the array size computation by using component size shifts instead of component sizes. Store component size shift in the upper 16 bits of primitive_type field. - Speedup: ~4% (3435->3284) in MemAllocTest on N4. Bug: 9986565 Change-Id: I4b142ffac4ab8b5b915836f1660a949d6442344c
* Enable computed goto interpreter on the hostSebastien Hertz2014-09-231-28/+0
| | | | | | | | | | | We disabled the computed goto interpreter when compiling with clang because of compilation issues. Since we compile with clang on the host, we used the switch-based interpreter. Now clang is able to compile the computed goto interpreter, we can use it by default on the host. Change-Id: Ifa2a2d3c171b1116ecd3b3f213382c3c85e93f66
* Compile time performance improvements focusing on interpret-only.Ian Rogers2014-09-121-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Interpreter can kick in even when implicit checks are enabled.Nicolas Geoffray2014-07-221-3/+6
| | | | | | Add a GetStackEndForInterpreter for its stack overfow check. Change-Id: I2d4fc229a8eb727fda509ff778e16d60d96ecc28
* Call strong CAS from unsafe. Add more CAS versions.Hans Boehm2014-07-111-4/+4
| | | | | | | | Adds a number of additional CAS versions. Calls the correct one from sun.misc.unsafe, fixing a recently introduced bug. Avoid unnecessary ordering constraint when installing hash code. Change-Id: I7c09d0c95ceb2a549ec28ee34084198ab3107946
* Merge "Add missing class initialization during compilation and tests"Sebastien Hertz2014-07-101-0/+1
|\
| * Add missing class initialization during compilation and testsSebastien Hertz2014-07-101-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Adds missing class initialization during compilation and tests, especially java.lang.Class. Otherwise, we'd be able to execute code while the referring class is not initialized or initializing. Also adds mirror::Class::AssertInitializedOrInitializingInThread method to check class initialization when entering the interpreter: the called method's declaring class must either be initialized or be initializing by the current thread (other threads must be waiting for the class initialization to complete holding its lock). Note we only do this check in debug build. Bump oat version to force compilation. Bug: 15899971 Change-Id: I9a4edd3739a3ca4cf1c4929dcbb44cdf7a1ca1fe
* | Make CAS operations in Object use art::Atomic.Ian Rogers2014-07-101-2/+4
|/ | | | | | Make naming consistent with art::Atomic. Change-Id: If3abdb019ef8b53bd809e3fef3fd5248aeb27e9a
* Ensure classes are initialized rather than initializing.Ian Rogers2014-06-181-2/+2
| | | | | | | | | | | A class can be being initialized on a different thread, in that case other threads should block trying to access the class. The initializing state shows the class is being initialized but not that its safe for other threads to access. Change occurances of IsInitializing to IsInitialized primarily in slow-path code. Bug: 15347354 Change-Id: Ib586d0a385be6086a890dfbf8868d76f16767fac
* Change MethodHelper to use a Handle.Mathieu Chartier2014-06-091-8/+10
| | | | | | | | | | | 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
* Compaction cleanup for FindArrayClass.Mathieu Chartier2014-05-301-1/+1
| | | | | | | | We now pass double pointer in to signify that it can cause thread suspension, this double pointer gets wrapped by a handle if don't find the array class in the cache. Change-Id: I43436b6c35597c7252b65d1180baddb5ac4caabb
* Revert "Revert "Fix an outstanding compaction bug in interpreter.""Mathieu Chartier2014-05-231-7/+8
| | | | | | | | | | Fixed the generic trampoline to not use ToJObject when unnecessary. Bug: 15167269 This reverts commit 3bdb873122964da7937eb070cbcf2ef638a8e459. Change-Id: I0525d0e0f3afb753c770e1572070a0fa22b02271
* Revert "Fix an outstanding compaction bug in interpreter."Mathieu Chartier2014-05-221-8/+7
| | | | | | This reverts commit e09ae0920be57760fb390b6944bce420fa0b5582. Change-Id: I48036306130d5ccfec683d0dc3e9a642a02ee9c1
* Fix an outstanding compaction bug in interpreter.Mathieu Chartier2014-05-221-7/+8
| | | | | | | | | | | | | | | | Fixed a bug in DoFieldPut where the FieldHelper GetType could cause thread suspension which would result in a stale obj. Added more handles in the class linker to facilitate moving fiels and methods in the future. Removed un-necessarly passing handle references since these are value types and don't need to be passed by reference. Added a special NullHandle type which allows null handles without a handle scope. Change-Id: I1b51723920a2e4f4f8b2907066f578a3e879fd5b
* Delete ClassHelper and fix compaction bug in GetDirectInterfaceMathieu Chartier2014-05-181-1/+2
| | | | | | | | | | | 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-7/+9
| | | | | | | | | | | | | | | | 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
* Allow VMRuntime.newUnpaddedArray allocations in unstarted runtime.Ian Rogers2014-05-061-1/+11
| | | | Change-Id: I15e9110718a553d7ca98b64e6e545055036ea20c
* Allow ArtMethod::Invoke in unstarted runtimes.Ian Rogers2014-05-021-8/+21
| | | | Change-Id: I0141f4daef4751589d03d27484eb65c811b14f27
* Don't allow allocating finalizable objects during transactions.Mathieu Chartier2014-04-301-5/+2
| | | | | | | | | | | | | It doesn't make sense to allocate finalizable objects during a transcation since they will never get finalized without a started runtime. Before StatusInitialized in core.host.oatdump.txt: 3564 After StatusInitialized in core.host.oatdump.txt: 3564 Bug: 14078487 Change-Id: I7070536f7bb87bfc691d4268bd39a3eca492f48e
* Force inlining on trivial accessors.Ian Rogers2014-04-291-1/+4
| | | | | | | | | Make volatility for GetFieldObject a template parameter. Move some trivial mirror::String routines to a -inl.h. Bug: 14285442 Change-Id: Ie23b11d4f18cb15a62c3bbb42837a8aaf6b68f92
* Fix ART compilation for Clang 3.5.Stephen Hines2014-04-241-4/+4
| | | | | | | | | This change adds required <> to some template instantiations, which Clang was complaining about (and ignoring otherwise). It also updates the integrated assembler defines, since Clang 3.5 now supports named arguments. Change-Id: I878b8c96bcbc29415582c18a2df678b7f9a9d4ad
* Cleanup transaction supportSebastien Hertz2014-04-021-2/+2
| | | | | | | | | | | | | | | | | | | Updates Thread::CreateInternalStackTrace to support both transactional and non-transactional modes using template. Generalizes non-transactional mode for invariant fields (which are set only once). Removes ArrayLog::VisitRoots as we never create Array logs of ObjectArray. As ObjectArray elements are set using Object::SetFieldObject, they are already recorded in the object logs: the object is the array itself and the offset corresponds to the element index in this array. And also checks we never log ObjectArray in array logs. Fixes location of thrown exception when calling native method during class initialization. Change-Id: Idbc368d3b8292b85ff40bc8a7c559e085477bf89
* Fix clang to compile and run host tests.Ian Rogers2014-02-281-3/+31
| | | | | | | | | | | | | | Don't use the computed goto interpreter with clang 3.4 as it causes compilation to hang. Avoid inclusion of LLVM_(HOST|DEVICE)_BUILD_MK except for with portable as it sets clang incompatible cflags. Most fixes are self-evident, for the quick dex file method inliner the enums were being used with ostreams, so fix the enums and operator out python script to allow this. Note this change effects portable but this is untestable as portable was broken by ELF file and mc linker changes. Change-Id: Ia54348f6b1bd3f76d3b71c6e8c5f97626386b903
* Fix moving GC bugs in EnterInterpreterFromInvoke.Mathieu Chartier2014-02-251-10/+14
| | | | | | | Calling EnterInterpreterFromInvoke on a static method could cause class initialization and trash the args before calling the method. Change-Id: If053d46dd6db403c8ebd1a816c20635194dd0e99
* Update native methods whitelist.Sebastien Hertz2014-02-181-12/+8
| | | | | | | | Adds System.identityHashCode to native methods whitelist and updates Unsafe.compareAndSwapInt to use mirror::Object::CasField32. Bug: 12999675 Change-Id: I177015777927b2d2180cbfd0f3a646948e7557b3
* Remove blacklistSebastien Hertz2014-02-171-6/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Removes the class initialization blacklist and use transaction to detect and revert class initialization attempting to invoke native method. This only concerns class initialization happening at compilation time when generating an image (like boot.art for the system). In transactional mode, we log every object's field assignment and array update. Therefore we're able to abort a transaction to restore values of fields and array as they were before the transaction starts. We also log changes to the intern string table so we can restore its state prior to transaction start. Since transactional mode only happens at compilation time, we don't need to log all these changes at runtime. In order to reduce the overhead of testing if transactional mode is on/off, we templatize interfaces of mirror::Object and mirror::Array, respectively responsible for setting a field and setting an array element. For various reasons, we skip some specific fields from transaction: - Object's class and array's length must remain unchanged so garbage collector can compute object's size. - Immutable fields only set during class loading: list of fields, method, dex caches, vtables, ... as all classes have been loaded and verified before a transaction occurs. - Object's monitor for performance reason. Before generating the image, we browse the heap to collect objects that need to be written into it. Since the heap may still holds references to unreachable objects due to aborted transactions, we trigger one collection at the end of the class preinitialization phase. Since the transaction is held by the runtime and all compilation threads share the same runtime, we need to ensure only one compilation thread has exclusive access to the runtime. To workaround this issue, we force class initialization phase to run with only one thread. Note this is only done when generating image so application compilation is not impacted. This issue will be addressed in a separate CL. Bug: 9676614 Change-Id: I221910a9183a5ba6c2b99a277f5a5a68bc69b5f9
* Don't hardcode object layout in Unsafe and space_test.Hiroshi Yamauchi2014-02-111-0/+8
| | | | | | Add a test for Unsafe.arrayBaseOffset() and Unsafe.arrayIndexScale(). Change-Id: I9cbdb79a4a7ee055129f41811a117910c8b2febd
* Fix CreateMultiArray to be compaction safe.Mathieu Chartier2014-02-081-1/+4
| | | | | | | It used to be compaction safe before moving classes was enabled. Added missing SIRTs. Change-Id: I92963ed71fa6d2a20d16ec0e400b8fa0e41ac196
* Object model changes to support 64bit.Ian Rogers2014-02-061-1/+1
| | | | | | | | | | | | | | | | | | | | | | | Modify mirror objects so that references between them use an ObjectReference value type rather than an Object* so that functionality to compress larger references can be captured in the ObjectRefererence implementation. ObjectReferences are 32bit and all other aspects of object layout remain as they are currently. Expand fields in objects holding pointers so they can hold 64bit pointers. Its expected the size of these will come down by improving where we hold compiler meta-data. Stub out x86_64 architecture specific runtime implementation. Modify OutputStream so that reads and writes are of unsigned quantities. Make the use of portable or quick code more explicit. Templatize AtomicInteger to support more than just int32_t as a type. Add missing, and fix issues relating to, missing annotalysis information on the mutator lock. Refactor and share implementations for array copy between System and uses elsewhere in the runtime. Fix numerous 64bit build issues. Change-Id: I1a5694c251a42c9eff71084dfdd4b51fff716822
* Don't rely on gcc extensionsBernhard Rosenkränzer2013-12-121-36/+36
| | | | | | | | | | | | | | Make the code more compatible with different compilers. clang doesn't allow extra static qualifiers on template specializations, const qualifiers on function types, or inline attributes on lambda functions, and is more picky about casting away constness with reinterpret_cast. These modifications are compatible with both gcc and clang. Change-Id: I739b10df2780bec537827a13679fd2bcc2cc7188 Signed-off-by: Bernhard Rosenkränzer <Bernhard.Rosenkranzer@linaro.org>
* Enable moving classes.Mathieu Chartier2013-12-101-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Compacting collector.Mathieu Chartier2013-11-111-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The compacting collector is currently similar to semispace. It works by copying objects back and forth between two bump pointer spaces. There are types of objects which are "non-movable" due to current runtime limitations. These are Classes, Methods, and Fields. Bump pointer spaces are a new type of continuous alloc space which have no lock in the allocation code path. When you allocate from these it uses atomic operations to increase an index. Traversing the objects in the bump pointer space relies on Object::SizeOf matching the allocated size exactly. Runtime changes: JNI::GetArrayElements returns copies objects if you attempt to get the backing data of a movable array. For GetArrayElementsCritical, we return direct backing storage for any types of arrays, but temporarily disable the GC until the critical region is completed. Added a new runtime call called VisitObjects, this is used in place of the old pattern which was flushing the allocation stack and walking the bitmaps. Changed image writer to be compaction safe and use object monitor word for forwarding addresses. Added a bunch of added SIRTs to ClassLinker, MethodLinker, etc.. TODO: Enable switching allocators, compacting on background, etc.. Bug: 8981901 Change-Id: I3c886fd322a6eef2b99388d19a765042ec26ab99
* Make goto-based interpreter the default interpreter.Sebastien Hertz2013-10-181-1/+1
| | | | Change-Id: Id21b57893864a72b77a78ef7df874c2c06209dc9
* Fix interpreter bugs.Mathieu Chartier2013-10-091-4/+8
| | | | | | These showed up in compaction work. Change-Id: Iac8eb0a1395c25aabba9f2e0ff6b01fc6180bdca