From b2f1766aeb7b442a1cc821f8dcda44a06fab7f85 Mon Sep 17 00:00:00 2001 From: Lokesh Gidra Date: Wed, 17 Jul 2024 21:14:29 +0000 Subject: 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 --- runtime/class_linker.cc | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'runtime/class_linker.cc') 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 array_class) { array_class->SetVTable(java_lang_Object->GetVTable()); array_class->SetPrimitiveType(Primitive::kPrimNot); ObjPtr 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_); -- cgit v1.2.3-59-g8ed1b