OSDN Git Service

merge in klp-release history after reset to klp-dev
[android-x86/dalvik.git] / vm / Misc.cpp
index d13a9e5..057b90d 100644 (file)
@@ -184,7 +184,7 @@ void dvmPrintDebugMessage(const DebugOutputTarget* target, const char* format,
         vfprintf(target->data.file.fp, format, args);
         break;
     default:
-        LOGE("unexpected 'which' %d", target->which);
+        ALOGE("unexpected 'which' %d", target->which);
         break;
     }
 
@@ -512,7 +512,12 @@ u8 dvmGetOtherThreadCpuTimeNsec(pthread_t thread)
  */
 bool dvmIterativeSleep(int iteration, int maxTotalSleep, u8 relStartTime)
 {
-    const int minSleep = 10000;
+    /*
+     * Minimum sleep is one millisecond, it is important to keep this value
+     * low to ensure short GC pauses since dvmSuspendAllThreads() uses this
+     * function.
+     */
+    const int minSleep = 1000;
     u8 curTime;
     int curDelay;
 
@@ -570,11 +575,11 @@ bool dvmSetCloseOnExec(int fd)
      */
     flags = fcntl(fd, F_GETFD);
     if (flags < 0) {
-        LOGW("Unable to get fd flags for fd %d", fd);
+        ALOGW("Unable to get fd flags for fd %d", fd);
         return false;
     }
     if (fcntl(fd, F_SETFD, flags | FD_CLOEXEC) < 0) {
-        LOGW("Unable to set close-on-exec for fd %d", fd);
+        ALOGW("Unable to set close-on-exec for fd %d", fd);
         return false;
     }
     return true;
@@ -619,6 +624,7 @@ void *dvmAllocRegion(size_t byteCount, int prot, const char *name) {
         return NULL;
     }
     if (ret == -1) {
+        munmap(base, byteCount);
         return NULL;
     }
     return base;
@@ -678,7 +684,7 @@ bool dvmGetThreadStats(ProcStatData* pData, pid_t tid)
     int cc = read(fd, lineBuf, sizeof(lineBuf)-1);
     if (cc <= 0) {
         const char* msg = (cc == 0) ? "unexpected EOF" : strerror(errno);
-        LOGI("Unable to read '%s': %s", nameBuf, msg);
+        ALOGI("Unable to read '%s': %s", nameBuf, msg);
         close(fd);
         return false;
     }
@@ -694,8 +700,10 @@ bool dvmGetThreadStats(ProcStatData* pData, pid_t tid)
     char* cp = strchr(lineBuf, ')');
     if (cp == NULL)
         goto parse_fail;
-    cp++;
-    for (i = 2; i < 13; i++) {
+    cp += 2;
+    pData->state = *cp++;
+
+    for (i = 3; i < 13; i++) {
         cp = strchr(cp+1, ' ');
         if (cp == NULL)
             goto parse_fail;
@@ -707,7 +715,7 @@ bool dvmGetThreadStats(ProcStatData* pData, pid_t tid)
     char* endp;
     pData->utime = strtoul(cp+1, &endp, 10);
     if (endp == cp+1)
-        LOGI("Warning: strtoul failed on utime ('%.30s...')", cp);
+        ALOGI("Warning: strtoul failed on utime ('%.30s...')", cp);
 
     cp = strchr(cp+1, ' ');
     if (cp == NULL)
@@ -715,7 +723,7 @@ bool dvmGetThreadStats(ProcStatData* pData, pid_t tid)
 
     pData->stime = strtoul(cp+1, &endp, 10);
     if (endp == cp+1)
-        LOGI("Warning: strtoul failed on stime ('%.30s...')", cp);
+        ALOGI("Warning: strtoul failed on stime ('%.30s...')", cp);
 
     /*
      * Skip more stuff we don't care about.
@@ -731,12 +739,12 @@ bool dvmGetThreadStats(ProcStatData* pData, pid_t tid)
      */
     pData->processor = strtol(cp+1, &endp, 10);
     if (endp == cp+1)
-        LOGI("Warning: strtoul failed on processor ('%.30s...')", cp);
+        ALOGI("Warning: strtoul failed on processor ('%.30s...')", cp);
 
     return true;
 
 parse_fail:
-    LOGI("stat parse failed (%s)", lineBuf);
+    ALOGI("stat parse failed (%s)", lineBuf);
     return false;
 }