summaryrefslogtreecommitdiffstats
path: root/runtime
diff options
context:
space:
mode:
authorMathieu Chartier <mathieuc@google.com>2014-04-24 16:14:43 -0700
committerMathieu Chartier <mathieuc@google.com>2014-04-24 16:16:23 -0700
commit92b7889dfbfb44e875ba46c4e9ec3235c37b7709 (patch)
treec95e28ad4b90d731fcffe159bf9f46d35772b7ad /runtime
parent17c50db442d2791d9c4d7d1e98060556c323ce9b (diff)
downloadart-92b7889dfbfb44e875ba46c4e9ec3235c37b7709.zip
art-92b7889dfbfb44e875ba46c4e9ec3235c37b7709.tar.gz
art-92b7889dfbfb44e875ba46c4e9ec3235c37b7709.tar.bz2
Clean up ScopedThreadStateChange + Get/SetPrimtiveArrayRegion
Simplified code in ScopedThreadStateChange and fixed an incorrect name in Get/SetPrimitiveArrayRegion. Change-Id: Id71affec1d64911449d792911cd52104dd179840
Diffstat (limited to 'runtime')
-rw-r--r--runtime/jni_internal.cc4
-rw-r--r--runtime/scoped_thread_state_change.h15
2 files changed, 7 insertions, 12 deletions
diff --git a/runtime/jni_internal.cc b/runtime/jni_internal.cc
index c04aabf..5decca7 100644
--- a/runtime/jni_internal.cc
+++ b/runtime/jni_internal.cc
@@ -2548,7 +2548,7 @@ class JNI {
if (start < 0 || length < 0 || start + length > array->GetLength()) {
ThrowAIOOBE(soa, array, start, length, "src");
} else {
- CHECK_NON_NULL_MEMCPY_ARGUMENT(GetStringRegion, length, buf);
+ CHECK_NON_NULL_MEMCPY_ARGUMENT(GetPrimitiveArrayRegion, length, buf);
JavaT* data = array->GetData();
memcpy(buf, data + start, length * sizeof(JavaT));
}
@@ -2563,7 +2563,7 @@ class JNI {
if (start < 0 || length < 0 || start + length > array->GetLength()) {
ThrowAIOOBE(soa, array, start, length, "dst");
} else {
- CHECK_NON_NULL_MEMCPY_ARGUMENT(GetStringRegion, length, buf);
+ CHECK_NON_NULL_MEMCPY_ARGUMENT(SetPrimitiveArrayRegion, length, buf);
JavaT* data = array->GetData();
memcpy(data + start, buf, length * sizeof(JavaT));
}
diff --git a/runtime/scoped_thread_state_change.h b/runtime/scoped_thread_state_change.h
index 404c616..7698d6a 100644
--- a/runtime/scoped_thread_state_change.h
+++ b/runtime/scoped_thread_state_change.h
@@ -38,23 +38,18 @@ class ScopedThreadStateChange {
Runtime* runtime = Runtime::Current();
CHECK(runtime == NULL || !runtime->IsStarted() || runtime->IsShuttingDown(self_));
} else {
- bool runnable_transition;
DCHECK_EQ(self, Thread::Current());
// Read state without locks, ok as state is effectively thread local and we're not interested
// in the suspend count (this will be handled in the runnable transitions).
old_thread_state_ = self->GetState();
- runnable_transition = old_thread_state_ == kRunnable || new_thread_state == kRunnable;
- if (!runnable_transition) {
- // A suspended transition to another effectively suspended transition, ok to use Unsafe.
- self_->SetState(new_thread_state);
- }
-
- if (runnable_transition && old_thread_state_ != new_thread_state) {
+ if (old_thread_state_ != new_thread_state) {
if (new_thread_state == kRunnable) {
self_->TransitionFromSuspendedToRunnable();
- } else {
- DCHECK_EQ(old_thread_state_, kRunnable);
+ } else if (old_thread_state_ == kRunnable) {
self_->TransitionFromRunnableToSuspended(new_thread_state);
+ } else {
+ // A suspended transition to another effectively suspended transition, ok to use Unsafe.
+ self_->SetState(new_thread_state);
}
}
}