summaryrefslogtreecommitdiff
path: root/runtime/class_linker.cc
diff options
context:
space:
mode:
author Lokesh Gidra <lokeshgidra@google.com> 2024-07-17 21:14:29 +0000
committer Lokesh Gidra <lokeshgidra@google.com> 2024-07-22 15:53:08 +0000
commitb2f1766aeb7b442a1cc821f8dcda44a06fab7f85 (patch)
tree14c20ac6fa8d81275bb0660f85e077868eecfcc6 /runtime/class_linker.cc
parent841e48f39dad0e560ec45df0d5ff805a74ddb3fe (diff)
Embed component-size shift in class-flags
This helps by eliminating the need to dereference component_type_ reference in Class each time we need to compute the array's size. Bug: 304325190 Test: art/test/testrunner/testrunner.py --host Change-Id: I745b794066fa24787800f0e0baaf5c4188842bc1
Diffstat (limited to 'runtime/class_linker.cc')
-rw-r--r--runtime/class_linker.cc10
1 files changed, 7 insertions, 3 deletions
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc
index 585e2b3818..d0fdcf0c25 100644
--- a/runtime/class_linker.cc
+++ b/runtime/class_linker.cc
@@ -2825,9 +2825,13 @@ void ClassLinker::FinishArrayClassSetup(ObjPtr<mirror::Class> array_class) {
array_class->SetVTable(java_lang_Object->GetVTable());
array_class->SetPrimitiveType(Primitive::kPrimNot);
ObjPtr<mirror::Class> component_type = array_class->GetComponentType();
- array_class->SetClassFlags(component_type->IsPrimitive()
- ? mirror::kClassFlagNoReferenceFields
- : mirror::kClassFlagObjectArray);
+ DCHECK_LT(component_type->GetPrimitiveTypeSizeShift(), 4u);
+ uint32_t class_flags =
+ component_type->GetPrimitiveTypeSizeShift() << mirror::kArrayComponentSizeShiftShift;
+ class_flags |= component_type->IsPrimitive()
+ ? (mirror::kClassFlagNoReferenceFields | mirror::kClassFlagPrimitiveArray)
+ : mirror::kClassFlagObjectArray;
+ array_class->SetClassFlags(class_flags);
array_class->SetClassLoader(component_type->GetClassLoader());
array_class->SetStatusForPrimitiveOrArray(ClassStatus::kLoaded);
array_class->PopulateEmbeddedVTable(image_pointer_size_);