summaryrefslogtreecommitdiffstats
path: root/runtime/interpreter/interpreter_goto_table_impl.cc
Commit message (Collapse)AuthorAgeFilesLines
* Remove blacklistSebastien Hertz2014-02-171-35/+48
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-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
* Refactor array access for the interpreter.Sebastien Hertz2014-01-281-26/+26
| | | | | | | | | | | | | | | | Adds GetWithoutChecks and SetWithoutChecks methods in PrimitiveArray and use them in the interpreter. Updates Get and Set methods to rely on them and adds some DCHECK to control exception flow. Renames IsValidIndex into CheckIsValidIndex to reflect it can throw an exception. It's also more consistent with ObjectArray::CheckIsAssignable. Make ThrowArrayIndexOutOfBoundsException private in Array since it's only used by Array::CheckIsValidIndex. Updates DoFilledNewArray to use SetWithoutChecks rather than Set. Change-Id: I2fd314d77a67cf969843d499b86d04ca7b7a43e6
* Tidy up memory barriers.Ian Rogers2013-12-201-2/+2
| | | | Change-Id: I937ea93e6df1835ecfe2d4bb7d84c24fe7fc097b
* Refactor allocation entrypoints.Mathieu Chartier2013-11-201-4/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | Adds support for switching entrypoints during runtime. Enables addition of new allocators with out requiring significant copy paste. Slight speedup on ritzperf probably due to more inlining. TODO: Ensuring that the entire allocation path is inlined so that the switch statement in the allocation code is optimized out. Rosalloc measurements: 4583 4453 4439 4434 4751 After change: 4184 4287 4131 4335 4097 Change-Id: I1352a3cbcdf6dae93921582726324d91312df5c9
* Merge "Improve interpreter handler table management." into dalvik-devSebastien Hertz2013-10-171-54/+108
|\
| * Improve interpreter handler table management.Sebastien Hertz2013-10-171-54/+108
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We still have two handlers table: - the "main" table which holds execution handlers of each instruction, - the "alternative" table which holds handlers supporting instrumentation before jumping to the corresponding instruction handler from the "main" table. Instrumentation holds the index of the handler table the interpreter must use. This index is represented by the InterpreterHandlerTable enum and is stored in the Instrumentation::interpreter_handler_table_ field. Interpreter's current handler table update happens: - on backward branch - after invoke - when throwing exception. In the case of the backward branch and exception, we only update the table if any thread's flags is set. This allows to only do one test for handling thread suspension and handler table update. This CL also removes the local variable "instrumentation". Every handler which needs it will get it from Runtime::Current()->GetInstrumentation(). Change-Id: Id886ea7ebf3dac1285f0ca701c098aee7ebaab8d
* | Fix interpreter bugs.Mathieu Chartier2013-10-091-3/+3
|/ | | | | | These showed up in compaction work. Change-Id: Iac8eb0a1395c25aabba9f2e0ff6b01fc6180bdca
* Fix an Art debug build boot failure.Hiroshi Yamauchi2013-10-021-4/+4
| | | | | | | | (The original change is 3b4c18933c24b8a33f38573c2ebcdb9aa16efeb5.) Bug: 11003273 Bug: 9986565 Change-Id: Iaaf6395f171eb6e6b8c99386c20c4970c53ee00d
* Enable thread analysis on template functions.Sebastien Hertz2013-09-301-6/+8
| | | | | | | | | | | 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-13/+12
| | | | | | | | | | | | | | | | | | | | | | 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-1/+25
| | | | | | | | | | 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
* Improve float to integral conversion.Ian Rogers2013-09-201-40/+4
| | | | Change-Id: I1597083cb2c04084ce825fe2e3c753fde8309cd8
* Optimize instruction data fetch in interpreter.Sebastien Hertz2013-09-181-270/+273
| | | | | | | | | | | | | | | | | 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-21/+15
| | | | | | | | | | | | | | | | | | 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
* Update interpreter handler table after invoke.Sebastien Hertz2013-09-131-90/+39
| | | | | | And introduce UPDATE_HANDLER_TABLE macro to reduce copy & paste. Change-Id: I9ea7565df0db2b44581d0e6bcefb5f104e76ed01
* Add missing memory barrier.Sebastien Hertz2013-09-091-0/+6
| | | | | | | | | | When DEX-to-DEX compiler is not run onto a method (because it's not preverified at the time of compilation), we do not replace RETURN where a barrier is needed into RETURN_VOID_BARRIER. This CL fixes this by placing a barrier on RETURN instruction only when the checks are enabled (non-preverified method). Change-Id: I4eb4cf79bb4a74684579c578318e27f62f4d9e8a
* Move thread suspend check at safepoints.Sebastien Hertz2013-09-091-7/+69
| | | | | | | 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/+2343
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