summaryrefslogtreecommitdiffstats
path: root/runtime/interpreter/interpreter.cc
Commit message (Collapse)AuthorAgeFilesLines
* 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
* Cleanup invoke in interpreter.Sebastien Hertz2013-09-301-8/+10
| | | | | | | | | | | | | | | | | | | | | | Some cleanup in invocation stuff: - Get the number of invoke arguments from instruction (vA) rather than get it from its code item. This benefits to native invoke since we no longer need to parse the method's shorty. Also pass the low 16 bits of instructions to avoid fetching it twice when reading vA. - Remove "is_static" tests by taking advantage of invoke type template argument rather than testing method's access flags. - Ensure Instruction::GetArgs is inlined. - Check exception when initializing method's class when transitioning from interpreter to compiled code (artInterpreterToCompiledCodeBridge). - Move UnstartedRuntimeInvoke function to interpreter_common.cc and make it static as it's only used by DoInvoke and DoInvokeVirtualQuick functions. - Avoid duplicating code in ShadowFrame::Create. Performance remains the same according to benchmarks. Hopefully, this should be addressed in next CLs, especially by improving new shadow frame initialization. Bug: 10668955 Change-Id: I514b8f098d0ef3e35921ceb770383aac1a9c7902
* StringPiece clean up.Ian Rogers2013-09-241-1/+1
| | | | | | | | | | | Profile guided clean up. Try to avoid creating StringPieces with the contents of a dex file where the length is known. Try to avoid RegTypeCache::FromDescriptor when there's a class available. Make ConstantType::ConstantValue inlinable. Saving of about 50ms from a 2 threaded ThinkFree compile on host. Change-Id: I47a12c3c76f46e2c9805be1c3a3e3870fe1f5d85
* Add an interpreter using computed goto table.Sebastien Hertz2013-09-091-2780/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This CL adds a new implementation of the interpreter using computed goto table. In order to keep the switch-based implementation, it reorders things as the following: - Keep interpreter entrypoints into interpreter.h/.cc files. - Move common interpreter parts to interpreter_common.h/.cc files. - Separate both implementations to their own modules. The interpreter implementation can be selected by changing the value of the kInterpreterImplKind global variable (see interpreter.cc file). The default one remains the switch-based implementation. Also updates the exception handling (FindNextInstructionFollowingException) and SPARSE_SWITCH switch handling (DoSparseSwitch) routines to share code between both implementations. Finally, adds a PACKED_SWITCH handling routine (DoPackedSwitch) so we are consistent with SPARSE_SWITCH handling. The computed goto implementation use two handlers table: one for normal instruction handling and one for instrumentation handling. The current handlers table to be used is updated on backward branch depending on whether there is listener to DEX pc change. Bug: 10602809 Change-Id: Ibb53bcc68be75c473fe5440835e78fc9a74381b3
* A char array copy optimization.Hiroshi Yamauchi2013-08-231-1/+2
| | | | | | | | | | | - Based on measurements, copy char by char for arrays of length <= 64. - With this change, the Ritz MemAllocBench got ~25% faster on Nexus 4 and ~20% faster on host. - This change only handles arraycopy calls in the core libraries and char arrays with the rest future work. Bug: 7103825 Change-Id: Ie88890eb65f011ca052b1f253f1b0e078ec24b6b
* Refactor java.lang.reflect implementationBrian Carlstrom2013-08-131-31/+39
| | | | | | | | | | | 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
* Entry point clean up.Ian Rogers2013-08-071-7/+9
| | | | | | | | | | | | | | | | | | Create set of entry points needed for image methods to avoid fix-up at load time: - interpreter - bridge to interpreter, bridge to compiled code - jni - dlsym lookup - quick - resolution and bridge to interpreter - portable - resolution and bridge to interpreter Fix JNI work around to use JNI work around argument rewriting code that'd been accidentally disabled. Remove abstact method error stub, use interpreter bridge instead. Consolidate trampoline (previously stub) generation in generic helper. Simplify trampolines to jump directly into assembly code, keeps stack crawlable. Dex: replace use of int with ThreadOffset for values that are thread offsets. Tidy entry point routines between interpreter, jni, quick and portable. Change-Id: I52a7c2bbb1b7e0ff8a3c3100b774212309d0828e
* Portable refactorings.Ian Rogers2013-07-301-1/+1
| | | | | | | Separate quick from portable entrypoints. Move architectural dependencies into arch. Change-Id: I9adbc0a9782e2959fdc3308215f01e3107632b7c
* Clear exception if catch block doesn't have move-exception.Ian Rogers2013-07-291-1/+6
| | | | | | Bug: 10040419 Change-Id: Icc7a55cb3cdfbc3efd2b161bbe22b3e5007de35f
* Avoid unnecessary exception checks.Sebastien Hertz2013-07-291-229/+290
| | | | | | | | | | | | While we have inlined some handling functions in interpreter, we still have conditional exception check in them. For instance, field access doesn't need to check for a pending exception. To help the compiler, these handling functions now return a boolean indicating if an exception is pending. Also updates macro POSSIBLY_HANDLE_PENDING_EXCEPTION to check against this boolean. Change-Id: I5e323e2ca0e06f43ad89871b124dd28c8d4a47fc
* resolved conflicts for merge of 7934ac28 to dalvik-devBrian Carlstrom2013-07-261-3/+3
|\ | | | | | | Change-Id: I8798a6f154463d3f92f6aca62f14130aec82d273
| * Fix cpplint whitespace/comments issuesBrian Carlstrom2013-07-261-3/+3
| | | | | | | | Change-Id: Iae286862c85fb8fd8901eae1204cd6d271d69496
* | Merge "Update DEX pc before thread suspension." into dalvik-devSebastien Hertz2013-07-261-45/+46
|\ \ | |/ |/|
| * Update DEX pc before thread suspension.Sebastien Hertz2013-07-251-45/+46
| | | | | | | | | | | | | | This CL moves the DEX pc update before thread suspension for correctness. It also update local variable declarations to use appropriate types. Change-Id: Ia2a54b17d3dae1370bb84f0b24109f109473bea2
* | Fix cpplint readability/fn_size issuesBrian Carlstrom2013-07-181-1/+1
| | | | | | | | Change-Id: I1efdb07a948a2af49db1a9d21ccab16dacc03a54
* | Fix cpplint build/namespaces issuesBrian Carlstrom2013-07-181-1/+15
| | | | | | | | Change-Id: I19c68703270c1482d6c6aad8cdf97d3d2924360a
* | Fix cpplint whitespace/parens issuesBrian Carlstrom2013-07-181-5/+5
|/ | | | Change-Id: Ifc678d59a8bed24ffddde5a0e543620b17b0aba9
* Fix cpplint whitespace/blank_line issuesBrian Carlstrom2013-07-181-1/+0
| | | | Change-Id: Ice937e95e23dd622c17054551d4ae4cebd0ef8a2
* Fix cpplint whitespace/braces issuesBrian Carlstrom2013-07-171-1/+1
| | | | Change-Id: Ide80939faf8e8690d8842dde8133902ac725ed1a
* Create separate Android.mk for main build targetsBrian Carlstrom2013-07-121-0/+3121
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