summaryrefslogtreecommitdiffstats
path: root/libart
diff options
context:
space:
mode:
authorAndreas Gampe <agampe@google.com>2015-03-03 09:11:57 -0800
committerAndreas Gampe <agampe@google.com>2015-03-03 15:39:25 -0800
commita92ad71a13dc2df8fdc8e6fba33d1221bcc8dafe (patch)
tree8bfebcb7908a941868e116519c250a82ffb8dcd1 /libart
parentf94993c756f36e2b4b1f776264bb6aca4e799a7b (diff)
downloadlibcore-a92ad71a13dc2df8fdc8e6fba33d1221bcc8dafe.zip
libcore-a92ad71a13dc2df8fdc8e6fba33d1221bcc8dafe.tar.gz
libcore-a92ad71a13dc2df8fdc8e6fba33d1221bcc8dafe.tar.bz2
Libcore: Use explicit names for Daemons
getSimpleName is an expensive operation that needs to check the dex file. Avoid for the standard daemons. Bug: 19498458 Change-Id: I034aceabc9358ac6277b3ff8182df5cde681e66f
Diffstat (limited to 'libart')
-rw-r--r--libart/src/main/java/java/lang/Daemons.java27
1 files changed, 26 insertions, 1 deletions
diff --git a/libart/src/main/java/java/lang/Daemons.java b/libart/src/main/java/java/lang/Daemons.java
index 76f4ea9..72ba387 100644
--- a/libart/src/main/java/java/lang/Daemons.java
+++ b/libart/src/main/java/java/lang/Daemons.java
@@ -57,12 +57,21 @@ public final class Daemons {
*/
private static abstract class Daemon implements Runnable {
private Thread thread;
+ private String name;
+
+ public Daemon(String name) {
+ this.name = name;
+ }
+
+ public Daemon() {
+ this.name = getClass().getSimpleName();
+ }
public synchronized void start() {
if (thread != null) {
throw new IllegalStateException("already running");
}
- thread = new Thread(ThreadGroup.systemThreadGroup, this, getClass().getSimpleName());
+ thread = new Thread(ThreadGroup.systemThreadGroup, this, name);
thread.setDaemon(true);
thread.start();
}
@@ -127,6 +136,10 @@ public final class Daemons {
private static class ReferenceQueueDaemon extends Daemon {
private static final ReferenceQueueDaemon INSTANCE = new ReferenceQueueDaemon();
+ ReferenceQueueDaemon() {
+ super("ReferenceQueueDaemon");
+ }
+
@Override public void run() {
while (isRunning()) {
Reference<?> list;
@@ -163,6 +176,10 @@ public final class Daemons {
private volatile Object finalizingObject;
private volatile long finalizingStartedNanos;
+ FinalizerDaemon() {
+ super("FinalizerDaemon");
+ }
+
@Override public void run() {
while (isRunning()) {
// Take a reference, blocking until one is ready or the thread should stop
@@ -203,6 +220,10 @@ public final class Daemons {
private static class FinalizerWatchdogDaemon extends Daemon {
private static final FinalizerWatchdogDaemon INSTANCE = new FinalizerWatchdogDaemon();
+ FinalizerWatchdogDaemon() {
+ super("FinalizerWatchdogDaemon");
+ }
+
@Override public void run() {
while (isRunning()) {
boolean waitSuccessful = waitForObject();
@@ -305,6 +326,10 @@ public final class Daemons {
private static class HeapTaskDaemon extends Daemon {
private static final HeapTaskDaemon INSTANCE = new HeapTaskDaemon();
+ HeapTaskDaemon() {
+ super("HeapTaskDaemon");
+ }
+
// Overrides the Daemon.interupt method which is called from Daemons.stop.
public synchronized void interrupt(Thread thread) {
VMRuntime.getRuntime().stopHeapTaskProcessor();