summaryrefslogtreecommitdiffstats
path: root/runtime/stack.cc
Commit message (Collapse)AuthorAgeFilesLines
* Implement implicit stack overflow checksDave Allison2014-03-311-4/+57
| | | | | | | | | | | | | This also fixes some failing run tests due to missing null pointer markers. The implementation of the implicit stack overflow checks introduces the ability to have a gap in the stack that is skipped during stack walk backs. This gap is protected against read/write and is used to trigger a SIGSEGV at function entry if the stack will overflow. Change-Id: I0c3e214c8b87dc250cf886472c6d327b5d58653e
* Fix test-art 083-compiler-regressions with work aroundBrian Carlstrom2014-03-191-1/+3
| | | | | | (cherry picked from commit cac04f21b35152c3f6e5c09b6699685255491b4a) Change-Id: I99f66c7531a61f36328db607a961137a6345cbe0
* Implicit null/suspend checks (oat version bump)Dave Allison2014-03-131-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This adds the ability to use SEGV signals to throw NullPointerException exceptions from Java code rather than having the compiler generate explicit comparisons and branches. It does this by using sigaction to trap SIGSEGV and when triggered makes sure it's in compiled code and if so, sets the return address to the entry point to throw the exception. It also uses this signal mechanism to determine whether to check for thread suspension. Instead of the compiler generating calls to a function to check for threads being suspended, the compiler will now load indirect via an address in the TLS area. To trigger a suspend, the contents of this address are changed from something valid to 0. A SIGSEGV will occur and the handler will check for a valid instruction pattern before invoking the thread suspension check code. If a user program taps SIGSEGV it will prevent our signal handler working. This will cause a failure in the runtime. There are two signal handlers at present. You can control them individually using the flags -implicit-checks: on the runtime command line. This takes a string parameter, a comma separated set of strings. Each can be one of: none switch off null null pointer checks suspend suspend checks all all checks So to switch only suspend checks on, pass: -implicit-checks:suspend There is also -explicit-checks to provide the reverse once we change the default. For dalvikvm, pass --runtime-arg -implicit-checks:foo,bar The default is -implicit-checks:none There is also a property 'dalvik.vm.implicit_checks' whose value is the same string as the command option. The default is 'none'. For example to switch on null checks using the option: setprop dalvik.vm.implicit_checks null It only works for ARM right now. Bumps OAT version number due to change to Thread offsets. Bug: 13121132 Change-Id: If743849138162f3c7c44a523247e413785677370
* Fixing structure of native frame for Generic JNIAndreas Gampe2014-03-121-11/+5
| | | | | | | | | This changes the layout of the callee-save frame used in generic JNI to be consistent with the JNI compiler, that is, the SIRT is inline (above the method reference). Now the location of the "this" object is consistent. Change-Id: Ibad0882680712cb640b4c70ada0229ef7cf4e62c
* Fix old stack frame size checkAndreas Gampe2014-03-101-4/+6
| | | | | | | | | The test underestimates the frame size for JNI frames, as not enough overhead is accounted for. Cherry-picked from commit 291088a2983ff954c137dddcc2ba7cb1c4cc95d2 Change-Id: I6ad96bc9b8eaecd6c888b91b3ffcfc4aeddc5eb8
* JNI down call fixes.Ian Rogers2014-03-091-7/+13
| | | | | | | Ensure SIRT isn't accessed via quick callee save frame. Some tidying of code. Change-Id: I8fec3e89aa6d2e86789c60a07550db2e92478ca7
* Fix and optimize verify object.Mathieu Chartier2014-02-211-4/+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
* Change root visitor to use Object**.Mathieu Chartier2014-02-181-0/+5
| | | | | | | Simplifies code and improves the performance of root visiting since we usually don't need to check to see if the object moved. Change-Id: Iba998f5a15ae1fa1b53ca5226dd2168a411196cf
* Object model changes to support 64bit.Ian Rogers2014-02-061-18/+18
| | | | | | | | | | | | | | | | | | | | | | | 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
* Selective deoptimization.Sebastien Hertz2014-01-131-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Update the instrumentation to allow selective deoptimization. Separate instrumentation listener registration from stubs configuration. A listener is now responsible for configuring the appropriate stubs. - The method tracing listener installs instrumentation entry/exit stubs or the interpreter depending on the accuracy of events we want (controlled by kDeoptimizeForAccurateMethodEntryExitListeners). - The debugger registers itself as an instrumentation listener but does not modify methods entrypoints. It only does this on demand when deoptimizing one method or all the methods. The selective deoptimization is used for breakpoint only. When a breakpoint is requested, the debugger deoptimizes this method by setting its entrypoint to the interpreter stub. As several breakpoints can be set on the same method, we deoptimize only once. When the last breakpoint on a method is removed, we reoptimize it by restoring the original entrypoints. The full deoptimization is used for method entry, method exit and single-step events. When one of these events is requested, we force eveything to run with the interpreter (except native and proxy methods). When the last of these events is removed, we restore all methods entrypoints except those which are currently deoptimized. Deoptimizing a method requires all mutator threads be suspended in order to walk each thread's stack and ensure no code is actually executing while we modify methods entrypoints. Suspending all the threads requires to not hold any lock. In the debugger, we deoptimize/undeoptimize when the JDWP event list changes (add or remove a breakpoint for instance). During the update, we need to hold the JDWP event list lock. This means we cannot suspend all the threads at this time. In order to deal with these constraints, we support a queue of deoptimization requests. When an event needs selective/full deoptimization/undeoptimization, we save its request in the queue. Once we release the JDWP event list lock, we suspend all the threads, process this queue and finally resume all the threads. This is done in Dbg::ManageDeoptimization. Note: threads already suspended before doing this remain suspended so we don't "break" debugger suspensions. When we deoptimize one method or every method, we need to browse each thread's stack to install instrumentation exit PC as return PC and save information in the instrumentation stack frame. Now we can deoptimize multiple times during the execution of an application, we need to preserve exisiting instrumentation frames (which is the result of a previous deoptimization). This require to push new instrumentation frames before existing ones so we don't corrupt the instrumentation stack frame while walking the stack. Bug: 11538162 Change-Id: I477142df17edf2dab8ac5d879daacc5c08a67c39
* Fix JDWP class-only modifier.Sebastien Hertz2013-12-051-0/+1
| | | | | | | | | | | Fix Dbg::MatchType which is used for class-only and exception-only modifiers. Also fix crash happening when notifying an exception. A debugger may walk the stack of the current thread so we need to keep the instrumentation stack frame synced with the native stack. Bug: 11856587 Change-Id: Ibf95f8a83ce9ee640abf945e498b42cc88ea92a0
* Compacting collector.Mathieu Chartier2013-11-111-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Add missing references.Sebastien Hertz2013-10-091-2/+2
| | | | | | This mainly avoids implicit copies when extracting an object from a container. Change-Id: If4d0e6153e8c2b48345fde5bb546b4c65649fcf3
* Add support for changing roots through the root visitor callback.Mathieu Chartier2013-09-131-2/+2
| | | | | | Needed for copying collectors. Change-Id: Icc4a342a57e0cfb79587edb02ef8c85e08808877
* Refactor java.lang.reflect implementationBrian Carlstrom2013-08-131-15/+14
| | | | | | | | | | | 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
* Uleb128 compression of vmap and mapping table.Ian Rogers2013-08-091-4/+5
| | | | | | Bug 9437697. Change-Id: I30bcb97d12cd8b46d3b2cdcbdd358f08fbb9947a
* Entry point clean up.Ian Rogers2013-08-071-1/+1
| | | | | | | | | | | | | | | | | | 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
* Make verifier allow integral types to be put in integral type arrays.Jeff Hao2013-08-011-1/+5
| | | | | | | | | | | This fixes a problem where the verifier was rejecting when an integer is put into a byte array. This also more closely matches the RI. Also fixes various issues with debugging checks caught by cts. Bug 10097083 Change-Id: Ie816fcdd85d6dc898feffa1e3fea8cfc2c6946ff
* Move assembler out of runtime into compiler/utils.Ian Rogers2013-07-291-1/+0
| | | | | | | Other directory layout bits of clean up. There is still work to separate quick and portable in some files (e.g. argument visitor, proxy..). Change-Id: If8fecffda8ba5c4c47a035f0c622c538c6b58351
* Fix cpplint whitespace/comments issuesBrian Carlstrom2013-07-261-4/+4
| | | | Change-Id: Iae286862c85fb8fd8901eae1204cd6d271d69496
* Fixes to instrumentation and quick to interpreter entry.Jeff Hao2013-07-241-2/+5
| | | | | | | | | - Interpreter entry was missing check that a static method is initialized. - Fixed instrumentation stack unwinding to not pop off the handler frame only if it actually exists on the instrumentation stack. Change-Id: I05a96ea7c0aea4dc6552da0edf485856cd004d85
* resolved conflicts for merge of df62950e to dalvik-devBrian Carlstrom2013-07-181-3/+3
|\ | | | | | | Change-Id: I78fbcfc7a2dcbeccb7557ca27302928d7d00debd
| * Fix cpplint whitespace/parens issuesBrian Carlstrom2013-07-181-3/+3
| | | | | | | | Change-Id: Ifc678d59a8bed24ffddde5a0e543620b17b0aba9
* | Fixes to instrumentation for debug build and interpreter.Jeff Hao2013-07-171-4/+1
|/ | | | | | | | | | | | - Stub uninstall will put back the interpreter entry point if Xint mode is specified. - Copy method entry and exit listeners before iterating over them to prevent problems that occur when they are modified during iteration. - Corrected checks from WalkStack and AssertPcIsWithinCode to handle instrumented code since they are used to remove the stubs. Change-Id: Ib0e2b421e6b56d520e4643699624dd80ee5148e3
* Create separate Android.mk for main build targetsBrian Carlstrom2013-07-121-0/+362
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