summaryrefslogtreecommitdiffstats
path: root/dalvik
diff options
context:
space:
mode:
authorCarl Shapiro <cshapiro@google.com>2011-03-21 13:36:30 -0700
committerCarl Shapiro <cshapiro@google.com>2011-03-21 13:36:30 -0700
commitbbfadc8ae01454abba5335fccceaa1c80123ae49 (patch)
treeb8cebef77d9ac2e5d762bddd5b1c8b9aa5b0b415 /dalvik
parent5aafac4db69e6d087c512cdfa5c7c0e2f1611681 (diff)
downloadlibcore-bbfadc8ae01454abba5335fccceaa1c80123ae49.zip
libcore-bbfadc8ae01454abba5335fccceaa1c80123ae49.tar.gz
libcore-bbfadc8ae01454abba5335fccceaa1c80123ae49.tar.bz2
Move finalization into the core library.
Change-Id: I969ecc25f2a7e655e1093855514102662846dfe1
Diffstat (limited to 'dalvik')
-rw-r--r--dalvik/src/main/java/dalvik/bytecode/OpcodeInfo.java2
-rw-r--r--dalvik/src/main/java/dalvik/system/SamplingProfiler.java1
-rw-r--r--dalvik/src/main/java/dalvik/system/VMRuntime.java10
-rw-r--r--dalvik/src/main/java/dalvik/system/Zygote.java48
4 files changed, 49 insertions, 12 deletions
diff --git a/dalvik/src/main/java/dalvik/bytecode/OpcodeInfo.java b/dalvik/src/main/java/dalvik/bytecode/OpcodeInfo.java
index 1209b2e..f253ee7 100644
--- a/dalvik/src/main/java/dalvik/bytecode/OpcodeInfo.java
+++ b/dalvik/src/main/java/dalvik/bytecode/OpcodeInfo.java
@@ -55,7 +55,7 @@ public final class OpcodeInfo {
*/
// BEGIN(libcore-maximum-values); GENERATED AUTOMATICALLY BY opcode-gen
MAXIMUM_VALUE = 65535;
- MAXIMUM_PACKED_VALUE = 255;
+ MAXIMUM_PACKED_VALUE = 511;
// END(libcore-maximum-values)
}
diff --git a/dalvik/src/main/java/dalvik/system/SamplingProfiler.java b/dalvik/src/main/java/dalvik/system/SamplingProfiler.java
index 1a95b16..60d07ca 100644
--- a/dalvik/src/main/java/dalvik/system/SamplingProfiler.java
+++ b/dalvik/src/main/java/dalvik/system/SamplingProfiler.java
@@ -1359,7 +1359,6 @@ public final class SamplingProfiler {
/**
* Timer that is used for the lifetime of the profiler
*/
- // note that dalvik/vm/Thread.c depends on this name
private final Timer timer = new Timer("SamplingProfiler", true);
/**
diff --git a/dalvik/src/main/java/dalvik/system/VMRuntime.java b/dalvik/src/main/java/dalvik/system/VMRuntime.java
index f570197..3e35ecf 100644
--- a/dalvik/src/main/java/dalvik/system/VMRuntime.java
+++ b/dalvik/src/main/java/dalvik/system/VMRuntime.java
@@ -132,11 +132,13 @@ public final class VMRuntime {
public void gcSoftReferences() {}
/**
- * Does not return until any pending finalizers have been called.
- * This may or may not happen in the context of the calling thread.
- * No exceptions will escape.
+ * This method exists for binary compatibility. It is equivalent
+ * to {@link System#runFinalization}.
*/
- public native void runFinalizationSync();
+ @Deprecated
+ public void runFinalizationSync() {
+ System.runFinalization();
+ }
/**
* Implements setTargetHeapUtilization().
diff --git a/dalvik/src/main/java/dalvik/system/Zygote.java b/dalvik/src/main/java/dalvik/system/Zygote.java
index 96928c8..791460b 100644
--- a/dalvik/src/main/java/dalvik/system/Zygote.java
+++ b/dalvik/src/main/java/dalvik/system/Zygote.java
@@ -16,6 +16,8 @@
package dalvik.system;
+import java.lang.FinalizerThread;
+
/**
* Provides access to the Dalvik "zygote" feature, which allows a VM instance to
* be partially initialized and then fork()'d from the partially initialized
@@ -45,6 +47,14 @@ public class Zygote {
private Zygote() {}
+ private static void preFork() {
+ FinalizerThread.stopFinalizer();
+ }
+
+ private static void postFork() {
+ FinalizerThread.startFinalizer();
+ }
+
/**
* Forks a new Zygote instance, but does not leave the zygote mode.
* The current VM must have been started with the -Xzygote flag. The
@@ -53,7 +63,14 @@ public class Zygote {
* @return 0 if this is the child, pid of the child
* if this is the parent, or -1 on error
*/
- native public static int fork();
+ public static int fork() {
+ preFork();
+ int pid = nativeFork();
+ postFork();
+ return pid;
+ }
+
+ native public static int nativeFork();
/**
* Forks a new VM instance. The current VM must have been started
@@ -75,8 +92,16 @@ public class Zygote {
* @return 0 if this is the child, pid of the child
* if this is the parent, or -1 on error.
*/
- native public static int forkAndSpecialize(int uid, int gid, int[] gids,
- int debugFlags, int[][] rlimits);
+ public static int forkAndSpecialize(int uid, int gid, int[] gids,
+ int debugFlags, int[][] rlimits) {
+ preFork();
+ int pid = nativeForkAndSpecialize(uid, gid, gids, debugFlags, rlimits);
+ postFork();
+ return pid;
+ }
+
+ native public static int nativeForkAndSpecialize(int uid, int gid,
+ int[] gids, int debugFlags, int[][] rlimits);
/**
* Forks a new VM instance.
@@ -112,9 +137,16 @@ public class Zygote {
* @return 0 if this is the child, pid of the child
* if this is the parent, or -1 on error.
*/
- native public static int forkSystemServer(int uid, int gid,
- int[] gids, int debugFlags, int[][] rlimits,
- long permittedCapabilities, long effectiveCapabilities);
+ public static int forkSystemServer(int uid, int gid, int[] gids,
+ int debugFlags, int[][] rlimits,
+ long permittedCapabilities, long effectiveCapabilities) {
+ preFork();
+ int pid = nativeForkSystemServer(uid, gid, gids, debugFlags, rlimits,
+ permittedCapabilities,
+ effectiveCapabilities);
+ postFork();
+ return pid;
+ }
/**
* Special method to start the system server process.
@@ -126,4 +158,8 @@ public class Zygote {
int debugFlags = enableDebugger ? DEBUG_ENABLE_DEBUGGER : 0;
return forkAndSpecialize(uid, gid, gids, debugFlags, rlimits);
}
+
+ native public static int nativeForkSystemServer(int uid, int gid,
+ int[] gids, int debugFlags, int[][] rlimits,
+ long permittedCapabilities, long effectiveCapabilities);
}