Merge "Fix portable sign/zero extension from JNI." into dalvik-dev
diff --git a/build/Android.common.mk b/build/Android.common.mk
index 786b1de..ac1be1e 100644
--- a/build/Android.common.mk
+++ b/build/Android.common.mk
@@ -109,7 +109,6 @@
art_cflags := \
-fno-rtti \
- -O2 \
-std=gnu++11 \
-ggdb3 \
-Wall \
@@ -131,8 +130,11 @@
-Wframe-larger-than=1728
endif
+art_non_debug_cflags := \
+ -O3
+
art_debug_cflags := \
- -fno-inline \
+ -O1 \
-DDYNAMIC_ANNOTATIONS_ENABLED=1 \
-UNDEBUG
diff --git a/runtime/thread.cc b/runtime/thread.cc
index 48e595f..c4077de 100644
--- a/runtime/thread.cc
+++ b/runtime/thread.cc
@@ -496,6 +496,19 @@
name.assign(*name_);
}
+uint64_t Thread::GetCpuMicroTime() const {
+#if defined(HAVE_POSIX_CLOCKS)
+ clockid_t cpu_clock_id;
+ pthread_getcpuclockid(pthread_self_, &cpu_clock_id);
+ timespec now;
+ clock_gettime(cpu_clock_id, &now);
+ return static_cast<uint64_t>(now.tv_sec) * 1000000LL + now.tv_nsec / 1000LL;
+#else
+ UNIMPLEMENTED(WARNING);
+ return -1;
+#endif
+}
+
void Thread::AtomicSetFlag(ThreadFlag flag) {
android_atomic_or(flag, &state_and_flags_.as_int);
}
diff --git a/runtime/thread.h b/runtime/thread.h
index b9b93dd..f16695d 100644
--- a/runtime/thread.h
+++ b/runtime/thread.h
@@ -267,6 +267,9 @@
// Sets the thread's name.
void SetThreadName(const char* name) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
+ // Returns the thread-specific CPU-time clock in microseconds or -1 if unavailable.
+ uint64_t GetCpuMicroTime() const;
+
mirror::Object* GetPeer() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
CHECK(jpeer_ == NULL);
return opeer_;
diff --git a/runtime/trace.cc b/runtime/trace.cc
index 13e2bf6..d435129 100644
--- a/runtime/trace.cc
+++ b/runtime/trace.cc
@@ -174,7 +174,7 @@
static void MeasureClockOverhead(Trace* trace) {
if (trace->UseThreadCpuClock()) {
- ThreadCpuMicroTime();
+ Thread::Current()->GetCpuMicroTime();
}
if (trace->UseWallClock()) {
MicroTime();
@@ -182,7 +182,8 @@
}
static uint32_t GetClockOverhead(Trace* trace) {
- uint64_t start = ThreadCpuMicroTime();
+ Thread* self = Thread::Current();
+ uint64_t start = self->GetCpuMicroTime();
for (int i = 4000; i > 0; i--) {
MeasureClockOverhead(trace);
@@ -195,7 +196,7 @@
MeasureClockOverhead(trace);
}
- uint64_t elapsed = ThreadCpuMicroTime() - start;
+ uint64_t elapsed = self->GetCpuMicroTime() - start;
return uint32_t (elapsed / 32);
}
@@ -582,11 +583,11 @@
uint32_t thread_clock_diff = 0;
if (UNLIKELY(it == thread_clock_base_map_.end())) {
// First event, the diff is 0, record the base time in the map.
- uint64_t time = ThreadCpuMicroTime();
+ uint64_t time = thread->GetCpuMicroTime();
thread_clock_base_map_.Put(thread, time);
} else {
uint64_t thread_clock_base = it->second;
- thread_clock_diff = ThreadCpuMicroTime() - thread_clock_base;
+ thread_clock_diff = thread->GetCpuMicroTime() - thread_clock_base;
}
Append4LE(ptr, thread_clock_diff);
ptr += 4;
diff --git a/runtime/utils.cc b/runtime/utils.cc
index 6856bb7..4c17914 100644
--- a/runtime/utils.cc
+++ b/runtime/utils.cc
@@ -164,17 +164,6 @@
#endif
}
-uint64_t ThreadCpuMicroTime() {
-#if defined(HAVE_POSIX_CLOCKS)
- timespec now;
- clock_gettime(CLOCK_THREAD_CPUTIME_ID, &now);
- return static_cast<uint64_t>(now.tv_sec) * 1000000LL + now.tv_nsec / 1000LL;
-#else
- UNIMPLEMENTED(WARNING);
- return -1;
-#endif
-}
-
uint64_t ThreadCpuNanoTime() {
#if defined(HAVE_POSIX_CLOCKS)
timespec now;
diff --git a/runtime/utils.h b/runtime/utils.h
index 9e724d0..bd81114 100644
--- a/runtime/utils.h
+++ b/runtime/utils.h
@@ -285,9 +285,6 @@
// Returns the monotonic time since some unspecified starting point in nanoseconds.
uint64_t NanoTime();
-// Returns the thread-specific CPU-time clock in microseconds or -1 if unavailable.
-uint64_t ThreadCpuMicroTime();
-
// Returns the thread-specific CPU-time clock in nanoseconds or -1 if unavailable.
uint64_t ThreadCpuNanoTime();
diff --git a/test/ReferenceMap/stack_walk_refmap_jni.cc b/test/ReferenceMap/stack_walk_refmap_jni.cc
index 1f6e307..180db4c 100644
--- a/test/ReferenceMap/stack_walk_refmap_jni.cc
+++ b/test/ReferenceMap/stack_walk_refmap_jni.cc
@@ -24,6 +24,7 @@
#include "mirror/art_method-inl.h"
#include "mirror/class-inl.h"
#include "mirror/object_array-inl.h"
+#include "mirror/object-inl.h"
#include "object_utils.h"
#include "scoped_thread_state_change.h"
#include "thread.h"