summaryrefslogtreecommitdiffstats
path: root/dalvik/src
diff options
context:
space:
mode:
authorNarayan Kamath <narayan@google.com>2014-11-14 11:14:37 +0000
committerNarayan Kamath <narayan@google.com>2014-11-17 13:51:11 +0000
commit7c22337691326a03386e42a32becbeb2c2dc7f06 (patch)
tree81b33f235d41c97f0db44256240271c5f58da3f8 /dalvik/src
parent5dbbe8317afd79d21bdbe931fe476ccf9a4bf269 (diff)
downloadlibcore-7c22337691326a03386e42a32becbeb2c2dc7f06.zip
libcore-7c22337691326a03386e42a32becbeb2c2dc7f06.tar.gz
libcore-7c22337691326a03386e42a32becbeb2c2dc7f06.tar.bz2
Set random seeds post fork.
Gets rid of static Random objects from various classes and makes them use Math.random instead. Also add hidden APIs to set the random seed post fork (where we're single threaded). This has the nice side effect of fixing a performance bug related to linpack (11388705) where threads were serializing on Math.class while calling Math.random. bug: https://code.google.com/p/android/issues/detail?id=79143 bug: 11388705 Change-Id: Ide3a7d17fe855a8086601348be87a890e4c42ab4
Diffstat (limited to 'dalvik/src')
-rw-r--r--dalvik/src/main/java/dalvik/system/ZygoteHooks.java4
1 files changed, 3 insertions, 1 deletions
diff --git a/dalvik/src/main/java/dalvik/system/ZygoteHooks.java b/dalvik/src/main/java/dalvik/system/ZygoteHooks.java
index 11ea286..59d8820 100644
--- a/dalvik/src/main/java/dalvik/system/ZygoteHooks.java
+++ b/dalvik/src/main/java/dalvik/system/ZygoteHooks.java
@@ -29,7 +29,7 @@ public final class ZygoteHooks {
/**
* Called by the zygote prior to every fork. Each call to {@code preFork}
- * is followed by a matching call to {@link #postForkChild(int)} on the child
+ * is followed by a matching call to {@link #postForkChild(int, String)} on the child
* process and {@link #postForkCommon()} on both the parent and the child
* process. {@code postForkCommon} is called after {@code postForkChild} in
* the child process.
@@ -47,6 +47,8 @@ public final class ZygoteHooks {
*/
public void postForkChild(int debugFlags, String instructionSet) {
nativePostForkChild(token, debugFlags, instructionSet);
+
+ Math.setRandomSeedInternal(System.currentTimeMillis());
}
/**