summaryrefslogtreecommitdiffstats
path: root/runtime/interpreter/interpreter_common.cc
Commit message (Collapse)AuthorAgeFilesLines
* Fix sign problem, implement low-mem mmap wraparoundAndreas Gampe2014-03-211-2/+3
| | | | | | | | | | A signed value comparison meant that on 64b systems comparisons were false when pointers > 2GB were in use (as happens in long-running tests). Fix this to be uint. Implement a simple wrap-around in the MAP_32BIT emulation code. Change-Id: I09870b4755f2dca676e42e701fbb6f6eb4bb95d0
* Fix the bug that some compiled code was invoked with -Xint.Hiroshi Yamauchi2014-02-281-0/+5
| | | | | | | | Some compiled code (probably static methods) is still being invoked with -Xint. Added an assert to detect this case. Bug: 13250375 Change-Id: Iecfe8ef40c6c326962593db78e6e1d9f1c93842e
* Make allocations report usable size.Ian Rogers2014-02-261-1/+2
| | | | | | | | | | | | | | | Work-in-progress to allow arrays to fill usable size. Bug: 13028925. Use C++11's override keyword on GCC >= 2.7 to ensure that we override GC and allocator methods. Move initial mirror::Class set up into a Functor so that all allocated objects have non-zero sizes. Use this property to assert that all objects are never larger than their usable size. Other bits of GC related clean-up, missing initialization, missing use of const, hot methods in .cc files, "unimplemented" functions that fail at runtime in header files, reducing header file includes, move valgrind's space into its own files, reduce number of array allocation routines. Change-Id: Id5760041a2d7f94dcaf17ec760f6095ec75dadaa
* Avoid std::string allocations for finding an array class.Ian Rogers2014-02-241-2/+2
| | | | | | | | | | | | Introduce ClassLinker::FindArrayClass which performs an array class lookup given the element/component class. This has a 16 element cache of recently looked up arrays. Pass the current thread to ClassLinker Find .. Class routines to avoid calls to Thread::Current(). Avoid some uses of FindClass in the debugger where WellKnownClasses is a faster and more compacting GC friendly alternative. Change-Id: I60e231820b349543a7edb3ceb9cf1ce92db3c843
* Fix and optimize verify object.Mathieu Chartier2014-02-211-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | VerifyObject no longer resides in heap. You can now enable VerifyObject for non-debug builds. VerifyStack is still slow, so it is now guarded by its own flag. Fixed the image writer to not use verification at places where verification fails due to invalid reads. Fixed RosAlloc to use SizeOf which doesn't call verify object. Added a flag paremeter to some of the mirror getters / setters to be able to selectively disable VerifyObject on certain calls. Optimized the GC to not verify each object multiple times during object scanning if verify object is enabled. Added 3 verification options: verify reads, verify this, and verify writes so that you can select how much verification you want for mirror getters and setters. Removed some useless DCHECKs which would slow debug builds without providing any benefits. TODO: RosAlloc verification doesn't currently work with verify objects. Bug: 12934910 Bug: 12879358 Change-Id: Ic61033104dfc334543f89b0fc0ad8cd4f4015d69
* Remove blacklistSebastien Hertz2014-02-171-12/+61
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-10/+11
| | | | | | | | | | | | | | | | | | | | | | | 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-17/+11
| | | | | | | | | | | | | | | | 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
* Merge "Cleanup invoke's receiver handling in interpreter."Sebastien Hertz2014-01-071-14/+13
|\
| * Cleanup invoke's receiver handling in interpreter.Sebastien Hertz2013-12-171-14/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | Disallow JNI NewObjectArray of primitive types.Ian Rogers2014-01-031-0/+3
|/ | | | | | | | | | | | Also, make jni_internal_test execute via the interpreter rather than compile methods. Add tests for passing negative array sizes to JNI routines new functions. Re-enable the tests NewStringNullCharsNonzeroLength and NewDirectBuffer_GetDirectBufferAddress_GetDirectBufferCapacity. Test and explicitly fail if the initial value argument to NewObjectArray isn't assignable to that type of array. Use unchecked ObjectArray::Set with NewObjectArray with an initial value. Change-Id: If3491cb5f974b42cf70c1b850819265f9963ee48
* Remove unneeded quotingBrian Carlstrom2013-12-101-1/+1
| | | | Change-Id: I87f452e338bd4ff0587e3fc7b0bec3f08a1e7fe6
* Add some functions to the unitialized VM handlingKenny Root2013-12-091-1/+11
| | | | | | | | | | | | | | | | | Only the Class#forName(String) call was handled during the compilation stage, but VMClassLoader#loadClass and VMClassLoader#findLoadedClass gets called through various other channels. Add these so we cover most of the use cases without going too far up the call stack. This was encountered during compilation of code that did: MyClass.class.getClassLoader().loadClass(...) during an attempt to avoid class initialization. Note that the existing Class#forName handling doesn't appear to ensure the class is initialized like would normally happen when Class#forName is called in the running VM. This is a correctness issue, but is left for another change to correct. Change-Id: I14628a1d1d5a5dd1a885cbd24455a73bb0531489
* Refactor allocation entrypoints.Mathieu Chartier2013-11-201-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Compacting collector.Mathieu Chartier2013-11-111-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Fix interpreter bugs.Mathieu Chartier2013-10-091-0/+4
| | | | | | These showed up in compaction work. Change-Id: Iac8eb0a1395c25aabba9f2e0ff6b01fc6180bdca
* 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
* Optimize shadow frame initialization during invoke.Sebastien Hertz2013-09-301-57/+93
| | | | | | | | | | | | | | | | | | | | This CL improves the initialization of the new shadow frame (callee) from the current shadow frame (caller) following invoke format (non-range or range). This also removes the use of Instruction::GetArgs for non-range invoke when we can go the fast route (no use of shorty). This avoids decoding arguments into the stack from the instruction and then read these arguments from the stack. We now do both at once. Note the slow path (doing runtime checks) is not modified since it should be rarely used. Performance improved by 3% in average on our benchmarks. Good news it is more important on benchmark doing lots of invokes: - Dhrystone: +11% - DeltaBlue: +7% - CaffeineMark Method: +16% Bug: 10668955 Change-Id: I5c230777b2388a78dca7b3a88189e007c1c2bb7a
* Cleanup invoke in interpreter.Sebastien Hertz2013-09-301-150/+45
| | | | | | | | | | | | | | | | | | | | | | 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-0/+22
| | | | | | | | | | 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
* Add an interpreter using computed goto table.Sebastien Hertz2013-09-091-0/+389
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