summaryrefslogtreecommitdiffstats
path: root/runtime/interpreter/interpreter_common.h
Commit message (Collapse)AuthorAgeFilesLines
* Support field watchpoint in interpreterSebastien Hertz2014-04-251-1/+73
| | | | | | | | | | | | | | | | We report field read/write events to instrumentation from the interpreter. This allows it to send JDWP field access and field modification events to debugger. This completes CL https://android-review.googlesource.com/90390. We also fix the JDWP FieldOnly modifier by introducing ModBasket.fieldTypeID. We incorrectly used ModBasket.classId which is actually dedicated to ClassOnly modifier based on thread's location's class id. Finally, we now enable canWatchFieldModification and canWatchFieldAccess JDWP capabilities so a debugger can request these events to be reported. Bug: 8267708 Change-Id: I987852ad47abb27b2f7e78544a8189c7a4e2f462
* Fix FindCatchBlock to work in -Xverify:none mode.Jeff Hao2014-04-221-1/+2
| | | | | | | | FindCatchBlock now uses ResolveType to get the exception type, since it might not be able to find it in the dex cache. Bug: 13948502 Change-Id: Ia6f1c7dc743206ae1c8551bf6239f48ee4d3a784
* Refactor reflective method invocation.Ian Rogers2014-03-141-1/+0
| | | | | | | | | | 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
* Fix clang to compile and run host tests.Ian Rogers2014-02-281-4/+4
| | | | | | | | | | | | | | 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
* Remove blacklistSebastien Hertz2014-02-171-28/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Object model changes to support 64bit.Ian Rogers2014-02-061-3/+3
| | | | | | | | | | | | | | | | | | | | | | | 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
* Cleanup invoke's receiver handling in interpreter.Sebastien Hertz2013-12-171-8/+3
| | | | | | | | | | | | | | | | | | To comply with a moving collector, we used to load invoke's receiver (for non static methods only) from the caller shadow frame after resolving the method itself (in case the garbage collector is triggered inside) but before passing invoke arguments, including loading receiver from the caller's shadow frame into the callee's shadow frame. Therefore, we used to load the receiver 3 times in the fast path but only twice in the slow path. The slow path is rarely used (only in method requiring extra runtime checks) so we now move this extra reload to the slow path. Therefore an invoke using the fast path loads the receiver twice while the slow path loads it 3 times. I don't expect much improvement here. The main reason is to keep extra code in the slow path. Change-Id: I10e96b10de4b8c2992e276bd564bc3e2f191779c
* Don't rely on gcc extensionsBernhard Rosenkränzer2013-12-121-26/+26
| | | | | | | | | | | | | | 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
* Inline field and method resolution.Sebastien Hertz2013-10-281-22/+19
| | | | | | | | | | | | | | | According to profiling results, field and method resolutions are hot points during interpreter execution. This CL attempts to speed up these resolutions. Forces aggressive inlining of FindFieldFromCode and FindMethodFromCode. This allows to reduce the overhead of access check code when the interpreter runs without these checks. Templatize these functions to optimize inlining and their callers. Also spread the use of C++11 "nullptr" in place of "NULL" in field access and invoke helpers. Change-Id: Ic1a69834d8975b2cddcddaae32f08a7de146a951
* Fix interpreter bugs.Mathieu Chartier2013-10-091-9/+15
| | | | | | These showed up in compaction work. Change-Id: Iac8eb0a1395c25aabba9f2e0ff6b01fc6180bdca
* Enable thread analysis on template functions.Sebastien Hertz2013-09-301-58/+150
| | | | | | | | | | | All template functions using thread analysis must be explicitly instantiated with the thread analysis attributes to enable thread analysis. We use macros to do this since there are many variants of a same function depending the number of template arguments. Also add documentation of these functions. Change-Id: I3c79acc2f0a6a8dfb5c42924439145292dd68812
* Cleanup invoke in interpreter.Sebastien Hertz2013-09-301-14/+65
| | | | | | | | | | | | | | | | | | | | | | 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
* Fix handling of unresolved references in verifier.Jeff Hao2013-09-241-3/+20
| | | | | | | | | | The verifier should not treat use of unresolved references as a reason to reject the entire class. Instead, the verifier treats the instruction as a throw. If that class is run, the interpreter with extra checks will throw an exception. Bug: 10457426 Change-Id: I3799da843a7ffb3519bbf6dc13a6276519d9cb95
* Fix compiler warning in interpreter.Ian Rogers2013-09-231-6/+4
| | | | Change-Id: I320a8dbbd27bf7d20cf8b60a3e5d0aaebcda861e
* Optimize instruction data fetch in interpreter.Sebastien Hertz2013-09-181-27/+23
| | | | | | | | | | | | | | | | | The computed goto implementation prevents the compiler from detecting we are loading the first 16 bits of instruction twice: first one to get the opcode and second one to fetch first instruction's operand(s) like vA and vB. We now load the 16 bits into a local variable and decode opcode and operands from this variable. And do the same in the switch-based implementation for consistency. The performance improvement is 5% in average on benchmark applications suite. Also remove unused "Thread* self" parameter from DoIGetQuick and DoIPutQuick. Bug: 10703860 Change-Id: I83026ed6e78f642ac3dcdc6edbb6056fe012005f
* Load shadow frame's this object only upon instrumentation.Sebastien Hertz2013-09-171-6/+6
| | | | | | | | | | | | | | | | | | We used to load the shadow frame's this object when entering the interpreter and push it into thread's SIRT to make it visible to garbage collector. But it is only used by instrumentation listeners. We now move this load at each place an instrumentation listener is called. This avoids loading it when instrumentation is disabled. This also allows to remove the SIRT reference and the push/pop management it implies when entering/exiting the interpreter. The performance improvement is 6% in average on our benchmarks suite. This CL also makes method Instrumentation::ExceptionCaughtEvent const so we can use a "const instrumentation::Instrumentation*" object in interpreter. Change-Id: I2caccba9a906f244c8057b24031250f9824cc711
* Move thread suspend check at safepoints.Sebastien Hertz2013-09-091-0/+4
| | | | | | | Move CheckSuspend on backward branch, return and exception handling. Bug: 10603072 Change-Id: Ic6c2c5066f133a345323d46edca7afde350849d8
* Add an interpreter using computed goto table.Sebastien Hertz2013-09-091-0/+516
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