Faster allocation fast path
Added a new object size field to class, this field contains the
aligned object size if the object is not finalizable and is
initialized. If the object is finalizable or uninitialized the field
is set to some large value that forces the ASM allocators to go slow
path.
Only implemented for region/normal TLAB for now, will add the to
RosAlloc stubs soon.
CC N6P MemAllocTest: 1067 -> 1039 (25 samples)
CC N6P EAAC: 1281 -> 1260 (25 samples)
RAM overhead technically 0 since mirror::Class was not 8 byte aligned
previously. Since the allocators require 8 byte allignment, there
would have been 1 word of padding at the end of the class. If there
was actually 4 extra bytes per class, the system overhead would be
36000 * 4 = 120KB based on old N6P numbers for the number of loaded
classes after boot.
Bug: 9986565
Test: test-art-host CC baker, N6P phone boot and EAAC runs.
Change-Id: I119a87b8cc6c980bff980a0c62f42610dab5e531
diff --git a/runtime/mirror/class.h b/runtime/mirror/class.h
index 1751f32..f8f414b 100644
--- a/runtime/mirror/class.h
+++ b/runtime/mirror/class.h
@@ -586,6 +586,9 @@
static MemberOffset ObjectSizeOffset() {
return OFFSET_OF_OBJECT_MEMBER(Class, object_size_);
}
+ static MemberOffset ObjectSizeAllocFastPathOffset() {
+ return OFFSET_OF_OBJECT_MEMBER(Class, object_size_alloc_fast_path_);
+ }
void SetObjectSize(uint32_t new_object_size) REQUIRES_SHARED(Locks::mutator_lock_) {
DCHECK(!IsVariableSize());
@@ -593,6 +596,8 @@
return SetField32<false>(OFFSET_OF_OBJECT_MEMBER(Class, object_size_), new_object_size);
}
+ void SetObjectSizeAllocFastPath(uint32_t new_object_size) REQUIRES_SHARED(Locks::mutator_lock_);
+
void SetObjectSizeWithoutChecks(uint32_t new_object_size)
REQUIRES_SHARED(Locks::mutator_lock_) {
// Not called within a transaction.
@@ -1457,6 +1462,10 @@
// See also class_size_.
uint32_t object_size_;
+ // Aligned object size for allocation fast path. The value is max int if the object is
+ // uninitialized or finalizable. Not currently used for variable sized objects.
+ uint32_t object_size_alloc_fast_path_;
+
// The lower 16 bits contains a Primitive::Type value. The upper 16
// bits contains the size shift of the primitive type.
uint32_t primitive_type_;