summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--runtime/verifier/reg_type-inl.h4
-rw-r--r--runtime/verifier/reg_type.h6
-rw-r--r--runtime/verifier/reg_type_cache.cc10
-rw-r--r--runtime/verifier/reg_type_cache.h9
4 files changed, 15 insertions, 14 deletions
diff --git a/runtime/verifier/reg_type-inl.h b/runtime/verifier/reg_type-inl.h
index 5dc6ae44c9..c5311e6e62 100644
--- a/runtime/verifier/reg_type-inl.h
+++ b/runtime/verifier/reg_type-inl.h
@@ -19,8 +19,8 @@
#include "reg_type.h"
-#include "base/arena_allocator.h"
#include "base/casts.h"
+#include "base/scoped_arena_allocator.h"
#include "method_verifier.h"
#include "mirror/class.h"
#include "verifier_deps.h"
@@ -158,7 +158,7 @@ inline bool RegType::IsStrictlyAssignableFrom(const RegType& src, MethodVerifier
return AssignableFrom(*this, src, true, verifier);
}
-inline void* RegType::operator new(size_t size, ArenaAllocator* allocator) {
+inline void* RegType::operator new(size_t size, ScopedArenaAllocator* allocator) {
return allocator->Alloc(size, kArenaAllocMisc);
}
diff --git a/runtime/verifier/reg_type.h b/runtime/verifier/reg_type.h
index 6d52aafceb..0d5c819af6 100644
--- a/runtime/verifier/reg_type.h
+++ b/runtime/verifier/reg_type.h
@@ -39,8 +39,8 @@ class Class;
class ClassLoader;
} // namespace mirror
-class ArenaAllocator;
class ArenaBitVector;
+class ScopedArenaAllocator;
namespace verifier {
@@ -257,8 +257,8 @@ class RegType {
return ::operator new(size);
}
- static void* operator new(size_t size, ArenaAllocator* allocator);
- static void* operator new(size_t size, ScopedArenaAllocator* allocator) = delete;
+ static void* operator new(size_t size, ArenaAllocator* allocator) = delete;
+ static void* operator new(size_t size, ScopedArenaAllocator* allocator);
enum class AssignmentType {
kBoolean,
diff --git a/runtime/verifier/reg_type_cache.cc b/runtime/verifier/reg_type_cache.cc
index 98769fab44..64df3116eb 100644
--- a/runtime/verifier/reg_type_cache.cc
+++ b/runtime/verifier/reg_type_cache.cc
@@ -260,7 +260,8 @@ RegTypeCache::RegTypeCache(Thread* self,
const DexFile* dex_file,
bool can_load_classes,
bool can_suspend)
- : allocator_(arena_pool),
+ : arena_stack_(arena_pool),
+ allocator_(&arena_stack_),
entries_(allocator_.Adapter(kArenaAllocVerifier)),
klass_entries_(allocator_.Adapter(kArenaAllocVerifier)),
handles_(self),
@@ -274,10 +275,9 @@ RegTypeCache::RegTypeCache(Thread* self,
if (kIsDebugBuild && can_suspend) {
Thread::Current()->AssertThreadSuspensionIsAllowable(gAborting == 0);
}
- // `ArenaAllocator` guarantees zero-initialization.
- DCHECK(std::all_of(entries_for_type_index_,
- entries_for_type_index_ + dex_file->NumTypeIds(),
- [](const RegType* reg_type) { return reg_type == nullptr; }));
+ // TODO: Why are we using `ScopedArenaAllocator` here instead of the `ArenaAllocator` which
+ // guarantees zero-initialization? We could avoid this `fill_n()` with the `ArenaAllocator`.
+ std::fill_n(entries_for_type_index_, dex_file->NumTypeIds(), nullptr);
// The klass_entries_ array does not have primitives or small constants.
static constexpr size_t kNumReserveEntries = 32;
klass_entries_.reserve(kNumReserveEntries);
diff --git a/runtime/verifier/reg_type_cache.h b/runtime/verifier/reg_type_cache.h
index d977958afe..737dc39c8b 100644
--- a/runtime/verifier/reg_type_cache.h
+++ b/runtime/verifier/reg_type_cache.h
@@ -21,9 +21,9 @@
#include <string_view>
#include <vector>
-#include "base/arena_containers.h"
#include "base/casts.h"
#include "base/macros.h"
+#include "base/scoped_arena_containers.h"
#include "dex/primitive.h"
#include "gc_root.h"
#include "handle_scope.h"
@@ -211,13 +211,14 @@ class RegTypeCache {
std::string_view AddString(const std::string_view& str);
// Arena allocator.
- ArenaAllocator allocator_;
+ ArenaStack arena_stack_;
+ ScopedArenaAllocator allocator_;
// The actual storage for the RegTypes.
- ArenaVector<const RegType*> entries_;
+ ScopedArenaVector<const RegType*> entries_;
// Fast lookup for quickly finding entries that have a matching class.
- ArenaVector<std::pair<Handle<mirror::Class>, const RegType*>> klass_entries_;
+ ScopedArenaVector<std::pair<Handle<mirror::Class>, const RegType*>> klass_entries_;
// Handle scope containing classes.
VariableSizedHandleScope handles_;