summaryrefslogtreecommitdiffstats
path: root/runtime/thread-inl.h
diff options
context:
space:
mode:
authorHiroshi Yamauchi <yamauchi@google.com>2014-02-11 17:02:22 -0800
committerHiroshi Yamauchi <yamauchi@google.com>2014-02-13 13:43:43 -0800
commitf5b0e20b5b31f5f5465784adcf2a204dcd69c7fd (patch)
tree9e1b211414c1dcb34f19a7b509e72aee2153a3cf /runtime/thread-inl.h
parent68bb649b128cd8760732524bd7ba58b49780d9d3 (diff)
downloadart-f5b0e20b5b31f5f5465784adcf2a204dcd69c7fd.zip
art-f5b0e20b5b31f5f5465784adcf2a204dcd69c7fd.tar.gz
art-f5b0e20b5b31f5f5465784adcf2a204dcd69c7fd.tar.bz2
Thread-local allocation stack.
With this change, Ritz MemAllocTest gets ~14% faster on N4. Bug: 9986565 Change-Id: I2fb7d6f7c5daa63dd4fc73ba739e6ae4ed820617
Diffstat (limited to 'runtime/thread-inl.h')
-rw-r--r--runtime/thread-inl.h36
1 files changed, 36 insertions, 0 deletions
diff --git a/runtime/thread-inl.h b/runtime/thread-inl.h
index 9420e7b..c0bf377 100644
--- a/runtime/thread-inl.h
+++ b/runtime/thread-inl.h
@@ -170,6 +170,42 @@ inline mirror::Object* Thread::AllocTlab(size_t bytes) {
return ret;
}
+inline bool Thread::PushOnThreadLocalAllocationStack(mirror::Object* obj) {
+ DCHECK_LE(thread_local_alloc_stack_top_, thread_local_alloc_stack_end_);
+ if (thread_local_alloc_stack_top_ < thread_local_alloc_stack_end_) {
+ // There's room.
+ DCHECK_LE(reinterpret_cast<byte*>(thread_local_alloc_stack_top_) + sizeof(mirror::Object*),
+ reinterpret_cast<byte*>(thread_local_alloc_stack_end_));
+ DCHECK(*thread_local_alloc_stack_top_ == nullptr);
+ *thread_local_alloc_stack_top_ = obj;
+ ++thread_local_alloc_stack_top_;
+ return true;
+ }
+ return false;
+}
+
+inline void Thread::SetThreadLocalAllocationStack(mirror::Object** start, mirror::Object** end) {
+ DCHECK(Thread::Current() == this) << "Should be called by self";
+ DCHECK(start != nullptr);
+ DCHECK(end != nullptr);
+ DCHECK_ALIGNED(start, sizeof(mirror::Object*));
+ DCHECK_ALIGNED(end, sizeof(mirror::Object*));
+ DCHECK_LT(start, end);
+ thread_local_alloc_stack_end_ = end;
+ thread_local_alloc_stack_top_ = start;
+}
+
+inline void Thread::RevokeThreadLocalAllocationStack() {
+ if (kIsDebugBuild) {
+ // Note: self is not necessarily equal to this thread since thread may be suspended.
+ Thread* self = Thread::Current();
+ DCHECK(this == self || IsSuspended() || GetState() == kWaitingPerformingGc)
+ << GetState() << " thread " << this << " self " << self;
+ }
+ thread_local_alloc_stack_end_ = nullptr;
+ thread_local_alloc_stack_top_ = nullptr;
+}
+
} // namespace art
#endif // ART_RUNTIME_THREAD_INL_H_