History log of /art/runtime/native/java_lang_Thread.cc
Revision Date Author Comments
55256cb60e11d4fac71affb4b9760a2931a3598d 22-Dec-2017 Ian Rogers <irogers@google.com> Extensions to check JNI.

Ensure critical lock isn't held when returning from a down-call.
Log a warning if the critical lock is held for a significant period of
time.
Refactor JNIEnvExt to be a class rather than a struct.

Test: mma test-art-host

Change-Id: I4d149cb04d3a7308a22b92b196e51e2f1ae17ede
373a9b5c718a45ac484afcf4fe6ce84f4bb562b3 18-Oct-2017 Andreas Gampe <agampe@google.com> ART: Depend on libnativehelper headers only

Depend on header-only versions where possible. Move projects
excluding libart to libnativehelper_header_only.

Bug: 65522645
Test: mmma art
Change-Id: I53dd3b2a97e94ee685f72de007ed3858f7f5c6b6
77fee87b262e969b29a9ac121a8bcbf87b68d9ce 05-Sep-2017 Alex Light <allight@google.com> Add support for JVMTI monitor events.

Adds support for the JVMTI can_generate_monitor_events capability and
all associated events. This adds support for the
JVMTI_EVENT_MONITOR_WAIT, JVMTI_EVENT_MONITOR_WAITED,
JVMTI_EVENT_MONITOR_CONTENDED_ENTER, and
JVMTI_EVENT_MONITOR_CONTENDED_ENTERED events.

Bug: 65558434
Bug: 62821960
Bug: 34415266

Test: ./test.py --host -j50

Change-Id: I0fe8038e6c4249e77d37a67e5056b5d2a94b6f48
e431e2758d62cf56f7f347f5a8c9d79e41b6dcd7 19-Jul-2017 Steven Moreland <smoreland@google.com> art: use proper nativehelper headers

libnativeheader exports headers under nativeheader. These were
available before incorrectly as global headers in order to give
access to jni.h.

Test: modules using art find headers
Bug: 63762847
Change-Id: I5c820d677e94e07b2859e78610bc997fe51b41dc
88fd720b6799184c8ad61e766a6d37af33ed30ef 30-Jun-2017 Alex Light <allight@google.com> Add Jvmti Suspend/ResumeThread functions

Enable the can_suspend jvmti capability and implement all required
functionality associated with it.

Test: ./test.py --host -j40
Bug: 34415266
Bug: 62821960
Bug: 63579748

Change-Id: I83b92de7f81622e1658114b034918e8295805b6e
46f9340f2a055a8fdfebbfbb739c697c20d83e7c 29-Jun-2017 Alex Light <allight@google.com> Add SuspendReason enum and change Suspension functions.

More self-documenting and more type safe.

Bug: 62821960
Test: ./test.py
Change-Id: Ic7a1ae6a25e687d65f5aa10c1aad54a7b80dd086
87583b3de6e811e141f8c97c1f796eb516e8a751 25-May-2017 Andreas Gampe <agampe@google.com> ART: Move RegisterNatives helper

Move the helper closer to the users.

Test: m test-art-host
Change-Id: Id05ce5f60af54d0c5aef0c7d8932706c4602fc94
a14100ccf51cc63a5c472188d1e2d337627e49eb 25-Apr-2017 Andreas Gampe <agampe@google.com> ART: More header cleanup - jni_internal.h

Move jni_macros.h to the clients (users of RegisterNativeMethods).

Test: mmma art
Change-Id: I052ac9f703ec69f0a2df1efcaf9f4a450eb7be1c
3b6f440dbd066f03a737da6d292074f47b3fbc29 17-Feb-2017 Igor Murashkin <iam@google.com> jni: Switch to @FastNative for all JNI functions. Deprecate !bang JNI.

Switches all (248) methods that previously used !bang JNI in art/libcore
to all use @FastNative.

Also deprecate !bang JNI since nothing in Android seems to (or should
be) using it anymore.

This measures to be a 3% startup time improvement in system_server.

Test: make test-art-host
Bug: 34955272
Change-Id: I0881f401c7660c79f275235362777bfa58241deb
90b936ddda63139ff46a6755c3b83ad6e4ab4ac5 31-Jan-2017 Andreas Gampe <agampe@google.com> ART: Refactor verify_object.h

Move the actual VerifyObject check into a new cc file, as we
commonly don't enable the check at all. This allows to cut the
-inl include from almost all current users.

This also exposes missing -inl includes. Also fix up some of our old
mess where .h defined functions require -inl.h defined functions.

Test: m

Change-Id: I3dd821bbe2015564a29bf1ed9be00f7a7276ad61
1cc62e4ea24828fdb3f3da0b8603f0b107d09a04 04-Oct-2016 Mathieu Chartier <mathieuc@google.com> Rename ObjPtr::Decode to ObjPtr::Ptr

Done to prevent ambiguity with ScopedObjectAccess::Decode.

Bug: 31113334

Test: test-art-host
Change-Id: I07a2497cc9cf66386311798933547471987fc316
0795f23920ee9aabf28e45c63cd592dcccf00216 28-Sep-2016 Mathieu Chartier <mathieuc@google.com> Clean up ScopedThreadStateChange to use ObjPtr

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
f38a6618b453b76a3370bbf6b351971687099388 11-Apr-2016 Andreas Gampe <agampe@google.com> ART: Flag to fail thread creation

Add a flag to mark when the zygote is not allowed to create threads.

Bug: 27248115
Bug: 28149511

(cherry picked from commit 415d8070e37c20dfb7e6dc37e74fdb5fffc2022e)

Change-Id: I1dc3620d9e7d0054c672b993d89459fc4b353dfc
415d8070e37c20dfb7e6dc37e74fdb5fffc2022e 11-Apr-2016 Andreas Gampe <agampe@google.com> ART: Flag to fail thread creation

Add a flag to mark when the zygote is not allowed to create threads.

Bug: 27248115
Bug: 28149511
Change-Id: I1dc3620d9e7d0054c672b993d89459fc4b353dfc
2ddc6bf88a1c49ebc78bf35b46d486078fe9051a 21-Dec-2015 Hiroshi Yamauchi <yamauchi@google.com> Treat thread state kWaitingWeakGcRootRead as kJavaRunnable.

Like kSuspended, kWaitingWeakGcRootRead means temporarily waiting for
GC's purpose rather than the thread is waiting on a monitor.

This may fix some jsr166 test failures.

Bug: 25883050
Bug: 12687968

Change-Id: Ib53e18c0fb2ff95aa0491b1531201e583288684e
76f55b030d2517d434f227bee2363c3fb760e5c6 22-Aug-2015 Hiroshi Yamauchi <yamauchi@google.com> Synchronize JNI critical calls with the CC collector thread flip.

JNI critical calls (like GetArrayElementsCritical) would need to block
for the whole GC run to finish if the CC collector GC is ongoing. This
CL changes it so that they don't need to block for the GC run, but
only for the duration of the thread flip operation, which is much
shorter. This is valid due to the to-space invariant.

Bug: 12687968
Bug: 19235243

Change-Id: I1b6b4ae4fa539ddc0ec50b10ae8c8709f2a12fe8
2a5c4681ba19411c1cb22e9a7ab446dab910af1c 14-Aug-2015 Andreas Gampe <agampe@google.com> ART: Some header cleaning around bit-utils

Try to remove dependencies where they are not necessary.

Change-Id: I5ff35cb17aea369bed3725b1610b50d7eb05b81e
90ef3db4bd1d4865f5f9cb95c8e7d9afb46994f9 05-Aug-2015 Mathieu Chartier <mathieuc@google.com> Address some comments and clean up

Change-Id: I538cf204f1c89d5fc81f8fc5e5800fcf1cf87359
14c3bf91b2ec434295ec84d6446f495fb7de6d5c 13-Jul-2015 Mathieu Chartier <mathieuc@google.com> Change intern table to not use WaitHoldingLocks

Bug: 22423014
Change-Id: I9e16b8cb4def72fff73f1783a182877105feb7aa
b43390cb87eace4a017f672d66cfb20fb9e76aa1 12-May-2015 Mathieu Chartier <mathieuc@google.com> Hold heap bitmap lock in Heap::GetObjectsAllocated

Fixes a race condition where add and remove space could cause a crash
when we iterated over the spaces.

TODO: Add a spaces lock or something to guard against this.

(cherry picked from commit a395c0a492079d86b312c9edc796d63001576954)

Bug: 21031927

Change-Id: I7f0d558316f8e9d9f22ffd182e8666355bf50d47
a395c0a492079d86b312c9edc796d63001576954 12-May-2015 Mathieu Chartier <mathieuc@google.com> Hold heap bitmap lock in Heap::GetObjectsAllocated

Fixes a race condition where add and remove space could cause a crash
when we iterated over the spaces.

TODO: Add a spaces lock or something to guard against this.

Bug: 21031927

Change-Id: I7f0d558316f8e9d9f22ffd182e8666355bf50d47
2cebb24bfc3247d3e9be138a3350106737455918 22-Apr-2015 Mathieu Chartier <mathieuc@google.com> Replace NULL with nullptr

Also fixed some lines that were too long, and a few other minor
details.

Change-Id: I6efba5fb6e03eb5d0a300fddb2a75bf8e2f175cb
0aa50ce2fb75bfc2e815a0c33adf9b049561923b 10-Mar-2015 Nicolas Geoffray <ngeoffray@google.com> Remove ThrowLocation.

Note that this is a cleanup change, and has no functionality change.
The ThrowLocation had no use anymore.

Change-Id: I3d2126af1dc673cec3a0453ff3d56a172663a5f6
0c8c303c20cdaaf54d26e45cc17dc5afb820d8ef 17-Jan-2015 Hiroshi Yamauchi <yamauchi@google.com> Clean up the locks around Heap::VisitObjects().

This is so that we could support suspending all threads when visiting
objects in the presence of a concurrent, moving collector.

Bug: 12687968
Change-Id: Icc8e60630465afde948ebc6ea91d4ebaff5d7837
9f612ffab2b188d80027d961d7118eb2c461b5ad 24-Nov-2014 Andreas Gampe <agampe@google.com> ART: Fix unused variables and functions

Change-Id: Icbab884d2dfd71656347368b424cb35cbf524051
4ad5cd3e7d519484559ef778d96fb3f0be8919fa 12-Nov-2014 Ian Rogers <irogers@google.com> Modify the behavior of thread suspend shootouts.

The thread doing the suspension doesn't attempt to suspend the other thread
unless it knows another thread isn't trying to suspend it. Use the suspend
count, and its lock, for this purpose.
Re-enable ThreadStress test.
Bug: 15446488

Change-Id: Idd34410c7b89d8abd6973e5699a15ca699472c78
277ccbd200ea43590dfc06a93ae184a765327ad0 04-Nov-2014 Andreas Gampe <agampe@google.com> ART: More warnings

Enable -Wno-conversion-null, -Wredundant-decls and -Wshadow in general,
and -Wunused-but-set-parameter for GCC builds.

Change-Id: I81bbdd762213444673c65d85edae594a523836e5
ba32de47e32f436d7c11cb4a2e78bdd4ad4dc5d2 28-Aug-2014 Brian Carlstrom <bdc@google.com> Fix issue with Thread.setName hanging after Thread.start

When suspending a thread by peer the invariant that only attached threads are
suspended must be maintained. Add a ThreadList::Contains check which requires
making this method non-static.
Add some extra thread logging.

Bug: 17302037

(cherry picked from commit 37c16453a92bbf1a47f042000318a1b60381017d)

Change-Id: I51832785d4b4b431e035318e75635f442e89a1fb
37c16453a92bbf1a47f042000318a1b60381017d 28-Aug-2014 Brian Carlstrom <bdc@google.com> Fix issue with Thread.setName hanging after Thread.start

When suspending a thread by peer the invariant that only attached threads are
suspended must be maintained. Add a ThreadList::Contains check which requires
making this method non-static.
Add some extra thread logging.

Bug: 17302037
Change-Id: I89af9840e398c2ceadeb736c431dfe3be8f3ba06
f3d874c60ee3ada19ce26a5c4e532312b6f3a9e9 18-Jul-2014 Ian Rogers <irogers@google.com> Avoid race in single thread suspension.

Don't allow more than one concurrent single thread suspension to avoid
potential cycles and deadlocks where threads try to suspend each other.
Bug: 16364458, 16354227

Change-Id: I907f1d5591a6aa5c241d37d6b4a34f968f98df77
6093a5c277e54bcd949dd6fac7b3856e5f371d06 18-Jul-2014 Ian Rogers <irogers@google.com> Avoid race in single thread suspension.

Don't allow more than one concurrent single thread suspension to avoid
potential cycles and deadlocks where threads try to suspend each other.
Bug: 16364458, 16354227

(cherry picked from commit f3d874c60ee3ada19ce26a5c4e532312b6f3a9e9)

Change-Id: I907f1d5591a6aa5c241d37d6b4a34f968f98df77
bae182cbc6adc8796154162a87fc54ae804e0469 17-Dec-2013 Sebastien Hertz <shertz@google.com> Fix method tracing from command-line

Transitions current thread to the new kWaitingForMethodTracingStart thread
state when starting method tracing.

Ensures there is a current thread when method tracing is stopped due to runtime
shutdown. If the current thread has been detached, we now re-attach it.
Note: we only do this if method tracing has been activated from command-line.

Fixes instrumentation when forcing interpreter mode (-Xint) with method tracing
enabled.

Removes unused parameter from UnsafeLogFatalForThreadSuspendAllTimeout.

Bug: https://code.google.com/p/android/issues/detail?id=72094
Bug: 11683397
Change-Id: I70f000fb46ddd95d6ad51ea0a8eee77697a045e9
0ec77d6df72ad9c352e23d8a2257530328f64a4b 22-Apr-2014 Ian Rogers <irogers@google.com> Warn when thread state lookup fails.

Change-Id: I06781caddcade26148921bc225f28db8b3a63a35
dd7624d2b9e599d57762d12031b10b89defc9807 15-Mar-2014 Ian Rogers <irogers@google.com> Allow mixing of thread offsets between 32 and 64bit architectures.

Begin a more full implementation x86-64 REX prefixes.
Doesn't implement 64bit thread offset support for the JNI compiler.

Change-Id: If9af2f08a1833c21ddb4b4077f9b03add1a05147
53b8b09fc80329539585dcf43657bc5f4ecefdff 14-Mar-2014 Ian Rogers <irogers@google.com> Refactor reflective method invocation.

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
4e30541a92381fb280cd0be9a1763b713ee4d64c 19-Feb-2014 Mathieu Chartier <mathieuc@google.com> Fix and optimize verify object.

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
138dbfc3336e379d74d157086f69a0fbe830089b 04-Dec-2013 Sebastien Hertz <shertz@google.com> Selective deoptimization.

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
1eb512d33f94d1dd7ea38263307ba0f7a0dfa653 19-Oct-2013 Ian Rogers <irogers@google.com> Fast JNI support.

Use a modifier to signal a native method is a fast JNI method. If the
modifier is set then don't perform runnable transitions.

Change-Id: I7835b4d837bfdd1cb8e2d54b919c0d5e6cf90499
d9c4fc94fa618617f94e1de9af5f034549100753 02-Oct-2013 Ian Rogers <irogers@google.com> Inflate contended lock word by suspending owner.

Bug 6961405.
Don't inflate monitors for Notify and NotifyAll.
Tidy lock word, handle recursive lock case alongside unlocked case and move
assembly out of line (except for ARM quick). Also handle null in out-of-line
assembly as the test is quick and the enter/exit code is already a safepoint.
To gain ownership of a monitor on behalf of another thread, monitor contenders
must not hold the monitor_lock_, so they wait on a condition variable.
Reduce size of per mutex contention log.
Be consistent in calling thin lock thread ids just thread ids.
Fix potential thread death races caused by the use of FindThreadByThreadId,
make it invariant that returned threads are either self or suspended now.

Code size reduction on ARM boot.oat 0.2%.
Old nexus 7 speedup 0.25%, new nexus 7 speedup 1.4%, nexus 10 speedup 2.24%,
nexus 4 speedup 2.09% on DeltaBlue.

Change-Id: Id52558b914f160d9c8578fdd7fc8199a9598576a
7934ac288acfb2552bb0b06ec1f61e5820d924a4 26-Jul-2013 Brian Carlstrom <bdc@google.com> Fix cpplint whitespace/comments issues

Change-Id: Iae286862c85fb8fd8901eae1204cd6d271d69496
7940e44f4517de5e2634a7e07d58d0fb26160513 12-Jul-2013 Brian Carlstrom <bdc@google.com> Create separate Android.mk for main build targets

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