Avoid VarHandle checks for boot image field VarHandles.
And use the field offset as seen at compile time.
Implemented for x86-64, arm and arm64 but not for x86
with incomplete set of `VarHandle` intrinsics.
Test: m test-art-host-gtest
Test: testrunner.py --host --optimizing
Test: run-gtests.sh
Test: testrunner.py --target --optimizing
Bug: 191765508
Change-Id: If68b0287c8823e69c493dcefb7e61dc34d69fb4f
diff --git a/compiler/optimizing/code_generator_arm64.cc b/compiler/optimizing/code_generator_arm64.cc
index 76d2a6d..2a0b481 100644
--- a/compiler/optimizing/code_generator_arm64.cc
+++ b/compiler/optimizing/code_generator_arm64.cc
@@ -4622,14 +4622,9 @@
break;
}
case MethodLoadKind::kBootImageRelRo: {
- // Add ADRP with its PC-relative .data.bimg.rel.ro patch.
- uint32_t boot_image_offset = GetBootImageOffset(invoke);
- vixl::aarch64::Label* adrp_label = NewBootImageRelRoPatch(boot_image_offset);
- EmitAdrpPlaceholder(adrp_label, XRegisterFrom(temp));
- // Add LDR with its PC-relative .data.bimg.rel.ro patch.
- vixl::aarch64::Label* ldr_label = NewBootImageRelRoPatch(boot_image_offset, adrp_label);
// Note: Boot image is in the low 4GiB and the entry is 32-bit, so emit a 32-bit load.
- EmitLdrOffsetPlaceholder(ldr_label, WRegisterFrom(temp), XRegisterFrom(temp));
+ uint32_t boot_image_offset = GetBootImageOffset(invoke);
+ LoadBootImageRelRoEntry(WRegisterFrom(temp), boot_image_offset);
break;
}
case MethodLoadKind::kBssEntry: {
@@ -5035,6 +5030,17 @@
__ ldr(out, MemOperand(base, /* offset placeholder */ 0));
}
+void CodeGeneratorARM64::LoadBootImageRelRoEntry(vixl::aarch64::Register reg,
+ uint32_t boot_image_offset) {
+ DCHECK(reg.IsW());
+ // Add ADRP with its PC-relative .data.bimg.rel.ro patch.
+ vixl::aarch64::Label* adrp_label = NewBootImageRelRoPatch(boot_image_offset);
+ EmitAdrpPlaceholder(adrp_label, reg.X());
+ // Add LDR with its PC-relative .data.bimg.rel.ro patch.
+ vixl::aarch64::Label* ldr_label = NewBootImageRelRoPatch(boot_image_offset, adrp_label);
+ EmitLdrOffsetPlaceholder(ldr_label, reg.W(), reg.X());
+}
+
void CodeGeneratorARM64::LoadBootImageAddress(vixl::aarch64::Register reg,
uint32_t boot_image_reference) {
if (GetCompilerOptions().IsBootImage()) {
@@ -5045,12 +5051,7 @@
vixl::aarch64::Label* add_label = NewBootImageIntrinsicPatch(boot_image_reference, adrp_label);
EmitAddPlaceholder(add_label, reg.X(), reg.X());
} else if (GetCompilerOptions().GetCompilePic()) {
- // Add ADRP with its PC-relative .data.bimg.rel.ro patch.
- vixl::aarch64::Label* adrp_label = NewBootImageRelRoPatch(boot_image_reference);
- EmitAdrpPlaceholder(adrp_label, reg.X());
- // Add LDR with its PC-relative .data.bimg.rel.ro patch.
- vixl::aarch64::Label* ldr_label = NewBootImageRelRoPatch(boot_image_reference, adrp_label);
- EmitLdrOffsetPlaceholder(ldr_label, reg.W(), reg.X());
+ LoadBootImageRelRoEntry(reg, boot_image_reference);
} else {
DCHECK(GetCompilerOptions().IsJitCompiler());
gc::Heap* heap = Runtime::Current()->GetHeap();
@@ -5063,7 +5064,7 @@
void CodeGeneratorARM64::LoadTypeForBootImageIntrinsic(vixl::aarch64::Register reg,
TypeReference target_type) {
// Load the class the same way as for HLoadClass::LoadKind::kBootImageLinkTimePcRelative.
- DCHECK(GetCompilerOptions().IsBootImage());
+ DCHECK(GetCompilerOptions().IsBootImage() || GetCompilerOptions().IsBootImageExtension());
// Add ADRP with its PC-relative type patch.
vixl::aarch64::Label* adrp_label =
NewBootImageTypePatch(*target_type.dex_file, target_type.TypeIndex());
@@ -5387,13 +5388,7 @@
case HLoadClass::LoadKind::kBootImageRelRo: {
DCHECK(!codegen_->GetCompilerOptions().IsBootImage());
uint32_t boot_image_offset = CodeGenerator::GetBootImageOffset(cls);
- // Add ADRP with its PC-relative .data.bimg.rel.ro patch.
- vixl::aarch64::Label* adrp_label = codegen_->NewBootImageRelRoPatch(boot_image_offset);
- codegen_->EmitAdrpPlaceholder(adrp_label, out.X());
- // Add LDR with its PC-relative .data.bimg.rel.ro patch.
- vixl::aarch64::Label* ldr_label =
- codegen_->NewBootImageRelRoPatch(boot_image_offset, adrp_label);
- codegen_->EmitLdrOffsetPlaceholder(ldr_label, out.W(), out.X());
+ codegen_->LoadBootImageRelRoEntry(out.W(), boot_image_offset);
break;
}
case HLoadClass::LoadKind::kBssEntry:
@@ -5561,14 +5556,8 @@
}
case HLoadString::LoadKind::kBootImageRelRo: {
DCHECK(!codegen_->GetCompilerOptions().IsBootImage());
- // Add ADRP with its PC-relative .data.bimg.rel.ro patch.
uint32_t boot_image_offset = CodeGenerator::GetBootImageOffset(load);
- vixl::aarch64::Label* adrp_label = codegen_->NewBootImageRelRoPatch(boot_image_offset);
- codegen_->EmitAdrpPlaceholder(adrp_label, out.X());
- // Add LDR with its PC-relative .data.bimg.rel.ro patch.
- vixl::aarch64::Label* ldr_label =
- codegen_->NewBootImageRelRoPatch(boot_image_offset, adrp_label);
- codegen_->EmitLdrOffsetPlaceholder(ldr_label, out.W(), out.X());
+ codegen_->LoadBootImageRelRoEntry(out.W(), boot_image_offset);
return;
}
case HLoadString::LoadKind::kBssEntry: {