summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Vladimir Marko <vmarko@google.com> 2015-11-12 10:16:29 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2015-11-12 10:16:29 +0000
commit9b71e9c702df1b65ea658cd5fc856e5a6d80669c (patch)
tree65e3df5b836d5bff9498d3a6c980075bc64653ee
parent11a4c96a7f8268a94cbdcbc2771d03bc4f2ce065 (diff)
parentfda043241caada72fbf1215ac8c6eb5ad1ad44e7 (diff)
Merge "ART: Add comments to Scoped-/ArenaAllocator."
-rw-r--r--runtime/base/arena_allocator.h5
-rw-r--r--runtime/base/scoped_arena_allocator.h7
2 files changed, 12 insertions, 0 deletions
diff --git a/runtime/base/arena_allocator.h b/runtime/base/arena_allocator.h
index ace6c388af..36334c4129 100644
--- a/runtime/base/arena_allocator.h
+++ b/runtime/base/arena_allocator.h
@@ -288,6 +288,11 @@ class ArenaPool {
DISALLOW_COPY_AND_ASSIGN(ArenaPool);
};
+// Fast single-threaded allocator for zero-initialized memory chunks.
+//
+// Memory is allocated from ArenaPool in large chunks and then rationed through
+// the ArenaAllocator. It's returned to the ArenaPool only when the ArenaAllocator
+// is destroyed.
class ArenaAllocator
: private DebugStackRefCounter, private ArenaAllocatorStats, private ArenaAllocatorMemoryTool {
public:
diff --git a/runtime/base/scoped_arena_allocator.h b/runtime/base/scoped_arena_allocator.h
index a30c73d749..a87153bd77 100644
--- a/runtime/base/scoped_arena_allocator.h
+++ b/runtime/base/scoped_arena_allocator.h
@@ -42,6 +42,7 @@ enum class ArenaFreeTag : uint8_t {
static constexpr size_t kArenaAlignment = 8;
// Holds a list of Arenas for use by ScopedArenaAllocator stack.
+// The memory is returned to the ArenaPool when the ArenaStack is destroyed.
class ArenaStack : private DebugStackRefCounter, private ArenaAllocatorMemoryTool {
public:
explicit ArenaStack(ArenaPool* arena_pool);
@@ -121,6 +122,12 @@ class ArenaStack : private DebugStackRefCounter, private ArenaAllocatorMemoryToo
DISALLOW_COPY_AND_ASSIGN(ArenaStack);
};
+// Fast single-threaded allocator. Allocated chunks are _not_ guaranteed to be zero-initialized.
+//
+// Unlike the ArenaAllocator, ScopedArenaAllocator is intended for relatively short-lived
+// objects and allows nesting multiple allocators. Only the top allocator can be used but
+// once it's destroyed, its memory can be reused by the next ScopedArenaAllocator on the
+// stack. This is facilitated by returning the memory to the ArenaStack.
class ScopedArenaAllocator
: private DebugStackReference, private DebugStackRefCounter, private ArenaAllocatorStats {
public: