summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Treehugger Robot <treehugger-gerrit@google.com> 2017-02-21 21:52:52 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2017-02-21 21:52:53 +0000
commit81f0753719e0734b543900489041ad2f9f3695e4 (patch)
treeb48b6f13f17734abc1ec9e7d813df1b0aa1ffcf6
parent88837a783d8c700f597da55b8e0e091b4d44f87c (diff)
parent26248c7168b79e8ee83b509a904f9bf31030be92 (diff)
Merge "Reduce dex2oat memory usage from VariableHandleScope."
-rw-r--r--runtime/handle_scope.h12
1 files changed, 10 insertions, 2 deletions
diff --git a/runtime/handle_scope.h b/runtime/handle_scope.h
index adb7d8a10c..f6720bd3b2 100644
--- a/runtime/handle_scope.h
+++ b/runtime/handle_scope.h
@@ -250,7 +250,7 @@ class PACKED(4) FixedSizeHandleScope : public HandleScope {
StackReference<mirror::Object> storage_[kNumReferences];
// Position new handles will be created.
- size_t pos_ = 0;
+ uint32_t pos_ = 0;
template<size_t kNumRefs> friend class StackHandleScope;
friend class VariableSizedHandleScope;
@@ -299,12 +299,20 @@ class VariableSizedHandleScope : public BaseHandleScope {
void VisitRoots(Visitor& visitor) REQUIRES_SHARED(Locks::mutator_lock_);
private:
- static constexpr size_t kNumReferencesPerScope = 4;
+ static constexpr size_t kLocalScopeSize = 64u;
+ static constexpr size_t kSizeOfReferencesPerScope =
+ kLocalScopeSize
+ - /* BaseHandleScope::link_ */ sizeof(BaseHandleScope*)
+ - /* BaseHandleScope::number_of_references_ */ sizeof(int32_t)
+ - /* FixedSizeHandleScope<>::pos_ */ sizeof(uint32_t);
+ static constexpr size_t kNumReferencesPerScope =
+ kSizeOfReferencesPerScope / sizeof(StackReference<mirror::Object>);
Thread* const self_;
// Linked list of fixed size handle scopes.
using LocalScopeType = FixedSizeHandleScope<kNumReferencesPerScope>;
+ static_assert(sizeof(LocalScopeType) == kLocalScopeSize, "Unexpected size of LocalScopeType");
LocalScopeType* current_scope_;
DISALLOW_COPY_AND_ASSIGN(VariableSizedHandleScope);