summaryrefslogtreecommitdiff
path: root/runtime/transaction_test.cc
Commit message (Collapse)AuthorAgeFilesLines
* Abort transaction when Class.forName() fails.Vladimir Marko2021-03-301-1/+13
| | | | | | | | | | | | | | | | And update VmClassLoader.findLoadedClass implementation in UnstartedRuntime which has erroneously diverged since https://android-review.googlesource.com/145075 . Also prevent transactional interpreter from transfering control to a catch handler for aborted transactions. Also clean up Transaction::kAbortExceptionDescriptor naming and some unused parameters. Test: TransactionTest.CatchClassForNameAbortClass Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Change-Id: Ibfc544283f5434efbaab238d11a6152ed2578050
* Explictly pass VerifierDeps when asking for class verification.Nicolas Geoffray2021-03-221-4/+4
| | | | | | | | | | This will simplify creating and populating VerifierDeps at runtime, which is needed for doing and saving background verifcation of secondary dex files. Test: test.py Bug: 158463186 Change-Id: Ic17913ebd173700e866ba9309bf6ae131fcbc423
* Fix transaction_test after libcore changes.Vladimir Marko2020-08-171-19/+23
| | | | | | | | Compensate for long[][].class being in the boot image. Test: m test-art-host-gtest Bug: 164435690 Change-Id: I900a53b3d40fbd9d5696065e099c43b17121601a
* Fix Transaction constraint validation...Vladimir Marko2020-01-201-25/+91
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ... for boot image extensions. Add WriteConstraint checks to APUT instructions and add necessary WriteConstraint and WriteValueConstraint checks to UnstartedRuntime. For strict transactions (app compilation), prevent writing to boot image objects. However, more work is required for this use case as the UnstartedRuntime needs a review for missing ReadConstraint checks and the WriteValueConstraint may need to be more restrictive. While the transaction_test is improved to test Transaction constraints more thoroughly, no regression tests are provided for the previously missing checks. Such tests are difficult to write as they would require compilation of a custom boot image. Test: Manual; include java.lang.Locale[] in primary boot image by patching CompilerDriver::LoadImageClasses(), + if (GetCompilerOptions().IsBootImage()) { + image_classes->insert("[Ljava/util/Locale;"); + } , and build. This previously aborted in ImageWriter: Image object without assigned bin slot: \ java.util.concurrent.ConcurrentHashMap$Node Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Bug: 119800099 Bug: 147596904 Change-Id: Ibfe1b24b10dbd982b4e4ae4d98289e587a842812
* Check stored references in transactional interpreter.Vladimir Marko2019-11-131-4/+20
| | | | | | | | | | | | | For boot image extension, we need to reject references to classes that are defined in a dex file belonging to the boot image we're compiling against but not actually in the boot image. Allowing such references could yield duplicate class objects from multiple extensions. Test: Additional tests in transaction_test. Test: m test-art-host-gtest Test: testrunner.py --host --interp-ac Change-Id: I99eaec331f6d992dba60aeb98a88c268edac11ac
* Update Transaction for boot image extension.Vladimir Marko2019-07-291-22/+79
| | | | | | | | | | | And clean up transaction-related code to keep test code out of the production binaries. Test: Add TransactionTest#Constraints to transaction_test. Test: m test-art-host-gtest Test: testrunner.py --host Test: aosp_taimen-userdebug boots. Change-Id: Iefe5f1cfde95f564069249148f9e7d71564d7a10
* Add default argument kIsInstrumented=true.Vladimir Marko2019-05-171-5/+6
| | | | | | | | | | | kIsInstrumented=false is reserved for use by specialized entrypoints which are used only when we can ensure that the code is not instrumented. So add the default argument to simplify all other callers. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Change-Id: I3419795794fec9a1733ab3ad698b6415dbac679d
* Partially ObjPtr<>-ify Object, fix stale ref in test.Vladimir Marko2019-04-021-7/+7
| | | | | | | Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Bug: 31113334 Change-Id: I0c0bc669c0ab8d99185e662a2fec16f32a42a0a2
* ObjPtr<>-ify mirror::Object::As*(), fix stale refs in test.Vladimir Marko2019-03-291-13/+21
| | | | | | | Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Bug: 31113334 Change-Id: Ia04c4996f5cbfa1f26acbadcd747342c57b1aac3
* ART: Move dex structs into own headerAndreas Gampe2019-01-021-1/+1
| | | | | | | | | Separating out the structs from DexFile allows them to be forward- declared, which reduces the need to include the dex_file header. Bug: 119869270 Test: m Change-Id: I32dde5a632884bca7435cd584b4a81883de2e7b4
* ART: Add class-alloc-inl.hAndreas Gampe2018-10-261-0/+1
| | | | | | | | | | In an effort to reduce the (transitive) proliferation of heap-inl add a specific inline header for class instance allocation. Bug: 118385392 Test: mmma art Test: m test-art-host Change-Id: I32529f0221a836452c58687330a91ac0d5fde162
* ART: Add array-alloc-inl.hAndreas Gampe2018-10-251-1/+1
| | | | | | | | | | In an effort to reduce the (transitive) proliferation of heap-inl add a specific inline header for array allocation. Bug: 118385392 Test: mmma art Test: m test-art-host Change-Id: Id3378f40c52fa7ef4297af08cb7509e0c04b94d1
* ObjPtr<>-ify array allocations.Vladimir Marko2018-06-011-1/+1
| | | | | | | | | And remove some unnecessary calls to ObjPtr<>::Ptr(). Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Bug: 31113334 Change-Id: Ie313980f7f23b33b0ccea4fa8d5131d643c59080
* Create dex subdirectoryDavid Sehr2018-01-051-1/+1
| | | | | | | | | Move all the DexFile related source to a common subdirectory dex/ of runtime. Bug: 71361973 Test: make -j 50 test-art-host Change-Id: I59e984ed660b93e0776556308be3d653722f5223
* Change ClassStatus to fit into 4 bits.Vladimir Marko2018-01-051-1/+1
| | | | | | | | | | | | | | | | | In preparation for extending the type check bit string from 24 to 28 bits, rewrite ClassStatus to fit into 4 bits. Also perform a proper cleanup of the ClassStatus, i.e. change it to an enum class, remove the "Status" word from enumerator names, replace "Max" with "Last" in line with other enumerations and remove aliases from mirror::Class. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Test: Pixel 2 XL boots. Test: testrunner.py --target --optimizing Bug: 64692057 Bug: 65318848 Change-Id: Iec1610ba5dac2c527b36c12819f132e1a77f2d45
* Do not pass DexFile to ClassLinker::Lookup/ResolveString().Vladimir Marko2017-12-111-3/+3
| | | | | | | | | The DexFile can be easily retrieved from the DexCache, so reduce the number of arguments that need to be passed. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Change-Id: I8c4cec43b31b27de7e4e94374fdd69c6d6ca6c13
* Determine HLoadClass/String load kind early.Vladimir Marko2017-12-081-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | This helps save memory by avoiding the allocation of HEnvironment and related objects for AOT references to boot image strings and classes (kBootImage* load kinds) and also for JIT references (kJitTableAddress). Compiling aosp_taimen-userdebug boot image, the most memory hungry method BatteryStats.dumpLocked() needs - before: Used 55105384 bytes of arena memory... ... UseListNode 10009704 Environment 423248 EnvVRegs 20676560 ... - after: Used 50559176 bytes of arena memory... ... UseListNode 8568936 Environment 365680 EnvVRegs 17628704 ... Test: m test-art-host-gtest Test: testrunner.py --host --optimizing --jit Bug: 34053922 Change-Id: I68e73a438e6ac8e8908e6fccf53bbeea8a64a077
* Move transaction creation to runtimeChang Xing2017-07-221-39/+20
| | | | | | | | | | Move the transaction creation to runtime instead of passing a pointer to runtime when EnterTransactionMode. Because later there will be more places to create transaction so this makes the code cleaner and more compact. Test: make test-art-host -j64 Change-Id: I971edf3110eb6634b6e0f7f56256be04517a5281
* Deterministic DexCache in heap images.Vladimir Marko2017-03-231-3/+3
| | | | | | | | | | | | | | | | Preload each slot in dex cache arrays with the candidate entry with the lowest index. Also fix a discrepancy where we used to keep an ArtField* in the DexCache if we kept the declaring class rather than based on the class referenced in the corresponding FieldId. This can result in accessing a field through a FieldId with an unresolved class as demonstrated by the regression test. Test: 159-app-image-fields Test: testrunner.py --host Bug: 30627598 Change-Id: I34735047cb064ff462cd9859e86a61ddf8615ecd
* ART: Add operator == and != with nullptr to HandleAndreas Gampe2017-02-141-31/+31
| | | | | | | Get it in line with ObjPtr and prettify our code. Test: m Change-Id: I1322e2a9bc7a85d7f2441034a19bf4d807b81a0e
* ART: Add dex::StringIndexAndreas Gampe2016-11-291-4/+2
| | | | | | | Add abstraction for uint32_t string index. Test: m test-art-host Change-Id: I917c2881702fe3df112c713f06980f2278ced7ed
* Clean up ScopedThreadStateChange to use ObjPtrMathieu Chartier2016-09-291-8/+8
| | | | | | | | | | | | | | | Also fixed inclusion of -inl.h files in .h files by adding scoped_object_access-inl.h and scoped_fast_natvie_object_access-inl.h Changed AddLocalReference / Decode to use ObjPtr. Changed libartbenchmark to be debug to avoid linkage errors. Bug: 31113334 Test: test-art-host Change-Id: I4d2e160483a29d21e1e0e440585ed328b9811483
* Add transactions for string resolveMathieu Chartier2016-09-081-0/+52
| | | | | | | | | | | | | | Fixes a bug where resolved strings can be left in the dex cache after a transaction is rolled back even though the interned string was removed. Added test in transaction_test. Bug: 31239436 Test: test-art-host Change-Id: I42c67bcefeae8db134cde34c480261f52db4102e
* Move mirror::ArtMethod to nativeMathieu Chartier2015-05-291-1/+1
| | | | | | | | | | | | | Optimizing + quick tests are passing, devices boot. TODO: Test and fix bugs in mips64. Saves 16 bytes per most ArtMethod, 7.5MB reduction in system PSS. Some of the savings are from removal of virtual methods and direct methods object arrays. Bug: 19264997 Change-Id: I622469a0cfa0e7082a2119f3d6a9491eb61e3f3d
* ART: Clean up includes.Vladimir Marko2015-04-131-0/+1
| | | | | | | Reduce dependencies to improve incremental build times. Break up circular dependency involving class_linker-inl.h. Change-Id: I4be742c5c2b5cd9855beea86630fd68aab76b0db
* Move ArtField to nativeMathieu Chartier2015-04-101-28/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add linear alloc. Moved ArtField to be native object. Changed image writer to put ArtFields after the mirror section. Savings: 2MB on low ram devices 4MB on normal devices Total PSS measurements before (normal N5, 95s after shell start): Image size: 7729152 bytes 23112 kB: .NonMoving 23212 kB: .NonMoving 22868 kB: .NonMoving 23072 kB: .NonMoving 22836 kB: .NonMoving 19618 kB: .Zygote 19850 kB: .Zygote 19623 kB: .Zygote 19924 kB: .Zygote 19612 kB: .Zygote Avg: 42745.4 kB After: Image size: 7462912 bytes 17440 kB: .NonMoving 16776 kB: .NonMoving 16804 kB: .NonMoving 17812 kB: .NonMoving 16820 kB: .NonMoving 18788 kB: .Zygote 18856 kB: .Zygote 19064 kB: .Zygote 18841 kB: .Zygote 18629 kB: .Zygote 3499 kB: .LinearAlloc 3408 kB: .LinearAlloc 3424 kB: .LinearAlloc 3600 kB: .LinearAlloc 3436 kB: .LinearAlloc Avg: 39439.4 kB No reflection performance changes. Bug: 19264997 Bug: 17643507 Change-Id: I10c73a37913332080aeb978c7c94713bdfe4fe1c
* Use specific exception class to abort transactionSebastien Hertz2015-04-031-3/+5
| | | | | | | | | | | | | | | We used to throw a java.lang.InternalError when aborting a transaction (when preinitializing image classes at compilation time). We now use dedicated class dalvik.system.TransactionAbortError that is only thrown by the compiler to abort a transaction. This class has constructors taking a java.lang.Throwable "cause" so we can wrap exceptions causing the transaction to abort (for instance class java.lang.ClassNotFoundException) and give more information about the cause of the transaction abort. Bug: 20019689 Change-Id: I019a72a1c754d8bba6a7ad6bb0f02e4fd6668622
* Reserve bits in the lock word for read barriers.Hiroshi Yamauchi2015-03-031-8/+8
| | | | | | | | | This prepares for the CC collector to use the standard object header model by storing the read barrier state in the lock word. Bug: 19355854 Bug: 12687968 Change-Id: Ia7585662dd2cebf0479a3e74f734afe5059fb70f
* Fix transaction abortingSebastien Hertz2015-02-051-59/+120
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | During compilation, a java.lang.InternalError is used to indicate that class initialization failed and the enclosing transaction should be aborted and the changes rolled back. However there is nothing preventing the code executed from a class initializer from catching that exception (like catching Throwable and ignore it). Therefore we may return from the class initializer with no pending exception, even if the transaction was aborted, and not rollback the changes properly. To fix this, we now rely on the new Transaction::aborted_ field to know whether a transaction aborted. When returning from the class initializer without pending exception, we now check wether we aborted the enclosing transaction. If that's the case, we set the status of the class to kStatusError and throw a new java.lang.InternalError with the original abort message. This CL also contains some cleanup: - Renames Transaction::Abort to Transaction::Rollback which is less ambiguous and more reflect what is done. - Moves the code throwing the java.lang.InternalError exception into the Transaction::ThrowInternalError method so we do not duplicate code. Now we may abort transaction more than once (because we may have caught the java.lang.InternalError then execute code causing new transaction abort), we only keep the first abort message to throw the exception. - Updates transaction_test with more cases and more checks. - Bumps oat version to force recompilation with this fix. Bug: 19202032 Change-Id: Iedc6969528a68bbdf3123146e990df4dbc57834b
* Fix 2 new sets of clang compiler warnings.Ian Rogers2014-10-101-12/+12
| | | | | | | | | | | Fix issues that are flagged by -Wfloat-equal and -Wmissing-noreturn. In the case of -Wfloat-equal the current cases in regular code are deliberate, so the change is to silence the warning. For gtest code the appropriate fix is to switch from EXPECT_EQ to EXPECT_(FLOAT|DOUBLE)_EQ. The -Wmissing-noreturn warning isn't enabled due to a missing noreturn in gtest. This issue has been reported to gtest. Change-Id: Id84c70c21c542716c9ee0c41492e8ff8788c4ef8
* Some optimizations for the array alloc path.Hiroshi Yamauchi2014-09-251-1/+1
| | | | | | | | | | | | | | | | | - 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
* ART: Rename Handle hierarchyAndreas Gampe2014-09-151-1/+1
| | | | | | | Bring the names in line with normal OO principles: ConstHandle becomes Handle, and Handle becomes MutableHandle. Change-Id: I0f018eb7ba28bc422e3a23dd73a6cbe6fc2d2044
* Compile time performance improvements focusing on interpret-only.Ian Rogers2014-09-121-12/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Break apart header files.Ian Rogers2014-07-151-0/+1
| | | | | | | | Create libart-gtest for common runtime and compiler gtest routines. Rename CompilerCallbacksImpl that is quick compiler specific. Rename trace clock source constants to not use the overloaded profiler term. Change-Id: I4aac4bdc7e7850c68335f81e59a390133b54e933
* Change FieldHelper to use a handle.Mathieu Chartier2014-06-061-18/+18
| | | | | | | | | | | | | | | | Fixed compaction bugs related to FieldHelper::GetType in: artSet32InstanceFromCode SetFieldValueImpl CheckReceiver Field_set interpreter::DoFieldPut MethodVerifier::VerifyISGet MethodVerifier::VerifyISPut MethodVerifier::VerifyIGetQuick Bug: 13077697 Change-Id: I7de9ded2893b5568d43e4daa86fd135bf5508b72
* Add Handle/HandleScope and delete SirtRef.Mathieu Chartier2014-05-131-221/+219
| | | | | | | | | | | | | | | | 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
* Use non volatile lock words in semispace collector.Mathieu Chartier2014-04-171-3/+3
| | | | | | | | | | GSS FormulaEvaluationActions.EvaluateAndApplyChanges: Before GC time: 9.1s After GC time: 7.98s Fixed timing logger errors. Change-Id: I4193c6ccbbbe7a7220dfaabbf3472a5dcebae616
* 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 valgrind gtests and memory leaks.Mathieu Chartier2014-03-051-4/+4
| | | | | | | All tests pass other than image_test which passes if some bad reads are disabled (buzbee working on this). Change-Id: Ifd6b6e3aed0bc867703b6e818353a9f296609422
* Make allocations report usable size.Ian Rogers2014-02-261-1/+4
| | | | | | | | | | | | | | | 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
* Split up CommonTest into CommonRuntimeTest and CommonCompilerTestBrian Carlstrom2014-02-261-4/+4
| | | | Change-Id: I8dcf6b29a5aecd445f1a3ddb06386cf81dbc9c70
* Avoid std::string allocations for finding an array class.Ian Rogers2014-02-241-19/+41
| | | | | | | | | | | | 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
* Remove blacklistSebastien Hertz2014-02-171-0/+472
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