summaryrefslogtreecommitdiffstats
path: root/core/jni
diff options
context:
space:
mode:
Diffstat (limited to 'core/jni')
-rw-r--r--core/jni/Android.mk8
-rw-r--r--core/jni/AndroidRuntime.cpp2
-rw-r--r--core/jni/android_net_LocalSocketImpl.cpp44
-rw-r--r--core/jni/android_os_MessageQueue.cpp4
-rw-r--r--core/jni/android_os_SELinux.cpp2
-rw-r--r--core/jni/android_server_NetworkManagementSocketTagger.cpp4
-rw-r--r--core/jni/android_util_Binder.cpp27
-rw-r--r--core/jni/android_util_Process.cpp6
-rw-r--r--core/jni/com_android_internal_os_Zygote.cpp25
-rw-r--r--core/jni/com_android_internal_os_ZygoteInit.cpp18
10 files changed, 53 insertions, 87 deletions
diff --git a/core/jni/Android.mk b/core/jni/Android.mk
index dbaa4b8..0cb0ea0 100644
--- a/core/jni/Android.mk
+++ b/core/jni/Android.mk
@@ -1,5 +1,6 @@
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
+LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
LOCAL_CFLAGS += -DHAVE_CONFIG_H -DKHTML_NO_EXCEPTIONS -DGKWQ_NO_JAVA
LOCAL_CFLAGS += -DNO_SUPPORT_JS_BINDING -DQT_NO_WHEELEVENT -DKHTML_NO_XBL
@@ -255,13 +256,10 @@ endif
LOCAL_SHARED_LIBRARIES += \
libdl
+
# we need to access the private Bionic header
# <bionic_tls.h> in com_google_android_gles_jni_GLImpl.cpp
-LOCAL_CFLAGS += -I$(LOCAL_PATH)/../../../../bionic/libc/private
-
-ifeq ($(WITH_MALLOC_LEAK_CHECK),true)
- LOCAL_CFLAGS += -DMALLOC_LEAK_CHECK
-endif
+LOCAL_C_INCLUDES += bionic/libc/private
LOCAL_MODULE:= libandroid_runtime
diff --git a/core/jni/AndroidRuntime.cpp b/core/jni/AndroidRuntime.cpp
index 1f4105f..4159792 100644
--- a/core/jni/AndroidRuntime.cpp
+++ b/core/jni/AndroidRuntime.cpp
@@ -856,7 +856,7 @@ int AndroidRuntime::startVm(JavaVM** pJavaVM, JNIEnv** pEnv)
parseRuntimeOption("dalvik.vm.profiler.type", profileType, "-Xprofile-type:");
// Depth of bounded stack data
- parseRuntimeOption("dalvik.vm.profile.max-stack-depth",
+ parseRuntimeOption("dalvik.vm.profile.stack-depth",
profileMaxStackDepth,
"-Xprofile-max-stack-depth:");
diff --git a/core/jni/android_net_LocalSocketImpl.cpp b/core/jni/android_net_LocalSocketImpl.cpp
index 98f4bed..a408a96 100644
--- a/core/jni/android_net_LocalSocketImpl.cpp
+++ b/core/jni/android_net_LocalSocketImpl.cpp
@@ -57,7 +57,7 @@ socket_connect_local(JNIEnv *env, jobject object,
fd = jniGetFDFromFileDescriptor(env, fileDescriptor);
- if (env->ExceptionOccurred() != NULL) {
+ if (env->ExceptionCheck()) {
return;
}
@@ -95,7 +95,7 @@ socket_bind_local (JNIEnv *env, jobject object, jobject fileDescriptor,
fd = jniGetFDFromFileDescriptor(env, fileDescriptor);
- if (env->ExceptionOccurred() != NULL) {
+ if (env->ExceptionCheck()) {
return;
}
@@ -118,7 +118,7 @@ socket_listen (JNIEnv *env, jobject object, jobject fileDescriptor, jint backlog
fd = jniGetFDFromFileDescriptor(env, fileDescriptor);
- if (env->ExceptionOccurred() != NULL) {
+ if (env->ExceptionCheck()) {
return;
}
@@ -154,7 +154,7 @@ socket_accept (JNIEnv *env, jobject object, jobject fileDescriptor, jobject s)
fd = jniGetFDFromFileDescriptor(env, fileDescriptor);
- if (env->ExceptionOccurred() != NULL) {
+ if (env->ExceptionCheck()) {
return NULL;
}
@@ -184,7 +184,7 @@ socket_shutdown (JNIEnv *env, jobject object, jobject fileDescriptor,
fd = jniGetFDFromFileDescriptor(env, fileDescriptor);
- if (env->ExceptionOccurred() != NULL) {
+ if (env->ExceptionCheck()) {
return;
}
@@ -246,7 +246,7 @@ socket_getOption(JNIEnv *env, jobject object, jobject fileDescriptor, jint optID
fd = jniGetFDFromFileDescriptor(env, fileDescriptor);
- if (env->ExceptionOccurred() != NULL) {
+ if (env->ExceptionCheck()) {
return 0;
}
@@ -293,7 +293,7 @@ static void socket_setOption(
fd = jniGetFDFromFileDescriptor(env, fileDescriptor);
- if (env->ExceptionOccurred() != NULL) {
+ if (env->ExceptionCheck()) {
return;
}
@@ -353,7 +353,7 @@ static jint socket_pending (JNIEnv *env, jobject object,
fd = jniGetFDFromFileDescriptor(env, fileDescriptor);
- if (env->ExceptionOccurred() != NULL) {
+ if (env->ExceptionCheck()) {
return (jint)-1;
}
@@ -378,7 +378,7 @@ static jint socket_available (JNIEnv *env, jobject object,
fd = jniGetFDFromFileDescriptor(env, fileDescriptor);
- if (env->ExceptionOccurred() != NULL) {
+ if (env->ExceptionCheck()) {
return (jint)-1;
}
@@ -459,20 +459,20 @@ static int socket_process_cmsg(JNIEnv *env, jobject thisJ, struct msghdr * pMsg)
jobject fdObject
= jniCreateFileDescriptor(env, pDescriptors[i]);
- if (env->ExceptionOccurred() != NULL) {
+ if (env->ExceptionCheck()) {
return -1;
}
env->SetObjectArrayElement(fdArray, i, fdObject);
- if (env->ExceptionOccurred() != NULL) {
+ if (env->ExceptionCheck()) {
return -1;
}
}
env->SetObjectField(thisJ, field_inboundFileDescriptors, fdArray);
- if (env->ExceptionOccurred() != NULL) {
+ if (env->ExceptionCheck()) {
return -1;
}
}
@@ -558,7 +558,7 @@ static int socket_write_all(JNIEnv *env, jobject object, int fd,
= (jobjectArray)env->GetObjectField(
object, field_outboundFileDescriptors);
- if (env->ExceptionOccurred() != NULL) {
+ if (env->ExceptionCheck()) {
return -1;
}
@@ -570,18 +570,18 @@ static int socket_write_all(JNIEnv *env, jobject object, int fd,
// Add any pending outbound file descriptors to the message
if (outboundFds != NULL) {
- if (env->ExceptionOccurred() != NULL) {
+ if (env->ExceptionCheck()) {
return -1;
}
for (int i = 0; i < countFds; i++) {
jobject fdObject = env->GetObjectArrayElement(outboundFds, i);
- if (env->ExceptionOccurred() != NULL) {
+ if (env->ExceptionCheck()) {
return -1;
}
fds[i] = jniGetFDFromFileDescriptor(env, fdObject);
- if (env->ExceptionOccurred() != NULL) {
+ if (env->ExceptionCheck()) {
return -1;
}
}
@@ -638,7 +638,7 @@ static jint socket_read (JNIEnv *env, jobject object, jobject fileDescriptor)
fd = jniGetFDFromFileDescriptor(env, fileDescriptor);
- if (env->ExceptionOccurred() != NULL) {
+ if (env->ExceptionCheck()) {
return (jint)0;
}
@@ -683,7 +683,7 @@ static jint socket_readba (JNIEnv *env, jobject object,
fd = jniGetFDFromFileDescriptor(env, fileDescriptor);
- if (env->ExceptionOccurred() != NULL) {
+ if (env->ExceptionCheck()) {
return (jint)-1;
}
@@ -717,7 +717,7 @@ static void socket_write (JNIEnv *env, jobject object,
fd = jniGetFDFromFileDescriptor(env, fileDescriptor);
- if (env->ExceptionOccurred() != NULL) {
+ if (env->ExceptionCheck()) {
return;
}
@@ -745,7 +745,7 @@ static void socket_writeba (JNIEnv *env, jobject object,
fd = jniGetFDFromFileDescriptor(env, fileDescriptor);
- if (env->ExceptionOccurred() != NULL) {
+ if (env->ExceptionCheck()) {
return;
}
@@ -777,7 +777,7 @@ static jobject socket_get_peer_credentials(JNIEnv *env,
fd = jniGetFDFromFileDescriptor(env, fileDescriptor);
- if (env->ExceptionOccurred() != NULL) {
+ if (env->ExceptionCheck()) {
return NULL;
}
@@ -816,7 +816,7 @@ static jobject socket_getSockName(JNIEnv *env,
fd = jniGetFDFromFileDescriptor(env, fileDescriptor);
- if (env->ExceptionOccurred() != NULL) {
+ if (env->ExceptionCheck()) {
return NULL;
}
diff --git a/core/jni/android_os_MessageQueue.cpp b/core/jni/android_os_MessageQueue.cpp
index a8ed895..15d62a2 100644
--- a/core/jni/android_os_MessageQueue.cpp
+++ b/core/jni/android_os_MessageQueue.cpp
@@ -54,8 +54,8 @@ MessageQueue::~MessageQueue() {
}
bool MessageQueue::raiseAndClearException(JNIEnv* env, const char* msg) {
- jthrowable exceptionObj = env->ExceptionOccurred();
- if (exceptionObj) {
+ if (env->ExceptionCheck()) {
+ jthrowable exceptionObj = env->ExceptionOccurred();
env->ExceptionClear();
raiseException(env, msg, exceptionObj);
env->DeleteLocalRef(exceptionObj);
diff --git a/core/jni/android_os_SELinux.cpp b/core/jni/android_os_SELinux.cpp
index ffa569e..c282549 100644
--- a/core/jni/android_os_SELinux.cpp
+++ b/core/jni/android_os_SELinux.cpp
@@ -97,7 +97,7 @@ static jstring getPeerCon(JNIEnv *env, jobject, jobject fileDescriptor) {
}
int fd = jniGetFDFromFileDescriptor(env, fileDescriptor);
- if (env->ExceptionOccurred() != NULL) {
+ if (env->ExceptionCheck()) {
ALOGE("getPeerCon => getFD for %p failed", fileDescriptor);
return NULL;
}
diff --git a/core/jni/android_server_NetworkManagementSocketTagger.cpp b/core/jni/android_server_NetworkManagementSocketTagger.cpp
index 7e12b1e..ca21fd7 100644
--- a/core/jni/android_server_NetworkManagementSocketTagger.cpp
+++ b/core/jni/android_server_NetworkManagementSocketTagger.cpp
@@ -35,7 +35,7 @@ static jint QTagUid_tagSocketFd(JNIEnv* env, jclass,
jint tagNum, jint uid) {
int userFd = jniGetFDFromFileDescriptor(env, fileDescriptor);
- if (env->ExceptionOccurred() != NULL) {
+ if (env->ExceptionCheck()) {
ALOGE("Can't get FileDescriptor num");
return (jint)-1;
}
@@ -51,7 +51,7 @@ static jint QTagUid_untagSocketFd(JNIEnv* env, jclass,
jobject fileDescriptor) {
int userFd = jniGetFDFromFileDescriptor(env, fileDescriptor);
- if (env->ExceptionOccurred() != NULL) {
+ if (env->ExceptionCheck()) {
ALOGE("Can't get FileDescriptor num");
return (jint)-1;
}
diff --git a/core/jni/android_util_Binder.cpp b/core/jni/android_util_Binder.cpp
index e400698..a78c386 100644
--- a/core/jni/android_util_Binder.cpp
+++ b/core/jni/android_util_Binder.cpp
@@ -271,9 +271,9 @@ protected:
//printf("\n");
jboolean res = env->CallBooleanMethod(mObject, gBinderOffsets.mExecTransact,
code, reinterpret_cast<jlong>(&data), reinterpret_cast<jlong>(reply), flags);
- jthrowable excep = env->ExceptionOccurred();
- if (excep) {
+ if (env->ExceptionCheck()) {
+ jthrowable excep = env->ExceptionOccurred();
report_exception(env, excep,
"*** Uncaught remote exception! "
"(Exceptions are not yet supported across processes.)");
@@ -291,12 +291,12 @@ protected:
set_dalvik_blockguard_policy(env, strict_policy_before);
}
- jthrowable excep2 = env->ExceptionOccurred();
- if (excep2) {
- report_exception(env, excep2,
+ if (env->ExceptionCheck()) {
+ jthrowable excep = env->ExceptionOccurred();
+ report_exception(env, excep,
"*** Uncaught exception in onBinderStrictModePolicyChange");
/* clean up JNI local ref -- we don't return to Java code */
- env->DeleteLocalRef(excep2);
+ env->DeleteLocalRef(excep);
}
// Need to always call through the native implementation of
@@ -398,8 +398,8 @@ public:
env->CallStaticVoidMethod(gBinderProxyOffsets.mClass,
gBinderProxyOffsets.mSendDeathNotice, mObject);
- jthrowable excep = env->ExceptionOccurred();
- if (excep) {
+ if (env->ExceptionCheck()) {
+ jthrowable excep = env->ExceptionOccurred();
report_exception(env, excep,
"*** Uncaught exception returned from death notification!");
}
@@ -1063,16 +1063,9 @@ static void conditionally_log_binder_call(int64_t start_millis,
}
// We only measure binder call durations to potentially log them if
-// we're on the main thread. Unfortunately sim-eng doesn't seem to
-// have gettid, so we just ignore this and don't log if we can't
-// get the thread id.
+// we're on the main thread.
static bool should_time_binder_calls() {
-#ifdef HAVE_GETTID
- return (getpid() == androidGetTid());
-#else
-#warning no gettid(), so not logging Binder calls...
- return false;
-#endif
+ return (getpid() == gettid());
}
static jboolean android_os_BinderProxy_transact(JNIEnv* env, jobject obj,
diff --git a/core/jni/android_util_Process.cpp b/core/jni/android_util_Process.cpp
index aaa680f..6506190 100644
--- a/core/jni/android_util_Process.cpp
+++ b/core/jni/android_util_Process.cpp
@@ -271,7 +271,7 @@ static void android_os_Process_setCanSelfBackground(JNIEnv* env, jobject clazz,
// Establishes the calling thread as illegal to put into the background.
// Typically used only for the system process's main looper.
#if GUARD_THREAD_PRIORITY
- ALOGV("Process.setCanSelfBackground(%d) : tid=%d", bgOk, androidGetTid());
+ ALOGV("Process.setCanSelfBackground(%d) : tid=%d", bgOk, gettid());
{
Mutex::Autolock _l(gKeyCreateMutex);
if (gBgKey == -1) {
@@ -306,7 +306,7 @@ void android_os_Process_setThreadPriority(JNIEnv* env, jobject clazz,
// if we're putting the current thread into the background, check the TLS
// to make sure this thread isn't guarded. If it is, raise an exception.
if (pri >= ANDROID_PRIORITY_BACKGROUND) {
- if (pid == androidGetTid()) {
+ if (pid == gettid()) {
void* bgOk = pthread_getspecific(gBgKey);
if (bgOk == ((void*)0xbaad)) {
ALOGE("Thread marked fg-only put self in background!");
@@ -333,7 +333,7 @@ void android_os_Process_setThreadPriority(JNIEnv* env, jobject clazz,
void android_os_Process_setCallingThreadPriority(JNIEnv* env, jobject clazz,
jint pri)
{
- android_os_Process_setThreadPriority(env, clazz, androidGetTid(), pri);
+ android_os_Process_setThreadPriority(env, clazz, gettid(), pri);
}
jint android_os_Process_getThreadPriority(JNIEnv* env, jobject clazz,
diff --git a/core/jni/com_android_internal_os_Zygote.cpp b/core/jni/com_android_internal_os_Zygote.cpp
index 7ca9374..d622fdb 100644
--- a/core/jni/com_android_internal_os_Zygote.cpp
+++ b/core/jni/com_android_internal_os_Zygote.cpp
@@ -43,7 +43,6 @@
#include <utils/String8.h>
#include <selinux/android.h>
#include <processgroup/processgroup.h>
-#include <inttypes.h>
#include "android_runtime/AndroidRuntime.h"
#include "JNIHelp.h"
@@ -405,22 +404,6 @@ void SetThreadName(const char* thread_name) {
}
}
- // Temporary timing check.
-uint64_t MsTime() {
- timespec now;
- clock_gettime(CLOCK_MONOTONIC, &now);
- return static_cast<uint64_t>(now.tv_sec) * UINT64_C(1000) + now.tv_nsec / UINT64_C(1000000);
-}
-
-
-void ckTime(uint64_t start, const char* where) {
- uint64_t now = MsTime();
- if ((now-start) > 1000) {
- // If we are taking more than a second, log about it.
- ALOGW("Slow operation: %"PRIu64" ms in %s", (uint64_t)(now-start), where);
- }
-}
-
// Utility routine to fork zygote and specialize the child process.
static pid_t ForkAndSpecializeCommon(JNIEnv* env, uid_t uid, gid_t gid, jintArray javaGids,
jint debug_flags, jobjectArray javaRlimits,
@@ -429,9 +412,7 @@ static pid_t ForkAndSpecializeCommon(JNIEnv* env, uid_t uid, gid_t gid, jintArra
jstring java_se_info, jstring java_se_name,
bool is_system_server, jintArray fdsToClose,
jstring instructionSet, jstring dataDir) {
- uint64_t start = MsTime();
SetSigChldHandler();
- ckTime(start, "ForkAndSpecializeCommon:SetSigChldHandler");
pid_t pid = fork();
@@ -439,12 +420,9 @@ static pid_t ForkAndSpecializeCommon(JNIEnv* env, uid_t uid, gid_t gid, jintArra
// The child process.
gMallocLeakZygoteChild = 1;
-
// Clean up any descriptors which must be closed immediately
DetachDescriptors(env, fdsToClose);
- ckTime(start, "ForkAndSpecializeCommon:Fork and detach");
-
// Keep capabilities across UID change, unless we're staying root.
if (uid != 0) {
EnableKeepCapabilities(env);
@@ -564,11 +542,8 @@ static pid_t ForkAndSpecializeCommon(JNIEnv* env, uid_t uid, gid_t gid, jintArra
UnsetSigChldHandler();
- ckTime(start, "ForkAndSpecializeCommon:child process setup");
-
env->CallStaticVoidMethod(gZygoteClass, gCallPostForkChildHooks, debug_flags,
is_system_server ? NULL : instructionSet);
- ckTime(start, "ForkAndSpecializeCommon:PostForkChildHooks returns");
if (env->ExceptionCheck()) {
ALOGE("Error calling post fork hooks.");
RuntimeAbort(env);
diff --git a/core/jni/com_android_internal_os_ZygoteInit.cpp b/core/jni/com_android_internal_os_ZygoteInit.cpp
index 2233ee3..10c6e2ce 100644
--- a/core/jni/com_android_internal_os_ZygoteInit.cpp
+++ b/core/jni/com_android_internal_os_ZygoteInit.cpp
@@ -96,7 +96,7 @@ static void com_android_internal_os_ZygoteInit_reopenStdio(JNIEnv* env,
fd = jniGetFDFromFileDescriptor(env, in);
- if (env->ExceptionOccurred() != NULL) {
+ if (env->ExceptionCheck()) {
return;
}
@@ -106,7 +106,7 @@ static void com_android_internal_os_ZygoteInit_reopenStdio(JNIEnv* env,
fd = jniGetFDFromFileDescriptor(env, out);
- if (env->ExceptionOccurred() != NULL) {
+ if (env->ExceptionCheck()) {
return;
}
@@ -116,7 +116,7 @@ static void com_android_internal_os_ZygoteInit_reopenStdio(JNIEnv* env,
fd = jniGetFDFromFileDescriptor(env, errfd);
- if (env->ExceptionOccurred() != NULL) {
+ if (env->ExceptionCheck()) {
return;
}
@@ -134,7 +134,7 @@ static void com_android_internal_os_ZygoteInit_setCloseOnExec (JNIEnv *env,
fd = jniGetFDFromFileDescriptor(env, descriptor);
- if (env->ExceptionOccurred() != NULL) {
+ if (env->ExceptionCheck()) {
return;
}
@@ -170,7 +170,7 @@ static jint com_android_internal_os_ZygoteInit_selectReadable (
jsize length = env->GetArrayLength(fds);
fd_set fdset;
- if (env->ExceptionOccurred() != NULL) {
+ if (env->ExceptionCheck()) {
return -1;
}
@@ -179,14 +179,14 @@ static jint com_android_internal_os_ZygoteInit_selectReadable (
int nfds = 0;
for (jsize i = 0; i < length; i++) {
jobject fdObj = env->GetObjectArrayElement(fds, i);
- if (env->ExceptionOccurred() != NULL) {
+ if (env->ExceptionCheck()) {
return -1;
}
if (fdObj == NULL) {
continue;
}
int fd = jniGetFDFromFileDescriptor(env, fdObj);
- if (env->ExceptionOccurred() != NULL) {
+ if (env->ExceptionCheck()) {
return -1;
}
@@ -209,14 +209,14 @@ static jint com_android_internal_os_ZygoteInit_selectReadable (
for (jsize i = 0; i < length; i++) {
jobject fdObj = env->GetObjectArrayElement(fds, i);
- if (env->ExceptionOccurred() != NULL) {
+ if (env->ExceptionCheck()) {
return -1;
}
if (fdObj == NULL) {
continue;
}
int fd = jniGetFDFromFileDescriptor(env, fdObj);
- if (env->ExceptionOccurred() != NULL) {
+ if (env->ExceptionCheck()) {
return -1;
}
if (FD_ISSET(fd, &fdset)) {