From b066d43b1d9184899aff32b1f243d092611ad9c6 Mon Sep 17 00:00:00 2001 From: Vladimir Marko Date: Wed, 3 Jan 2018 13:14:37 +0000 Subject: Load ArtMethod* from .data.bimg.rel.ro entries. Introduce a new .data.bimg.rel.ro section in oat files where we store offsets of boot image objects from the beginning of the boot image. At runtime we relocate these entries using the actual boot image address to turn offsets to pointers. Use the .data.bimg.rel.ro to prepare the boot image methods used by HInvokeStaticOrDirect for PIC AOT app compilation. Loading the ArtMethod* from .data.bimg.rel.ro instead of the .bss avoids the initial call to the resolution trampoline. Test: Additional test in 522-checker-sharpening Test: m test-art-host-gtest Test: testrunner.py --host --optimizing --pictest --npictest Test: Pixel 2 XL boots. Test: testrunner.py --target --optimizing --pictest --npictest Bug: 71526895 Change-Id: Ie5f5b1f622704877b36730377146e59092e46c0c --- compiler/optimizing/sharpening.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'compiler/optimizing/sharpening.cc') diff --git a/compiler/optimizing/sharpening.cc b/compiler/optimizing/sharpening.cc index 1e49411c72..b65628e441 100644 --- a/compiler/optimizing/sharpening.cc +++ b/compiler/optimizing/sharpening.cc @@ -125,8 +125,14 @@ void HSharpening::SharpenInvokeStaticOrDirect(HInvokeStaticOrDirect* invoke, BootImageAOTCanEmbedMethod(callee, compiler_driver)) { method_load_kind = HInvokeStaticOrDirect::MethodLoadKind::kBootImageLinkTimePcRelative; code_ptr_location = HInvokeStaticOrDirect::CodePtrLocation::kCallArtMethod; + } else if (IsInBootImage(callee)) { + // Use PC-relative access to the .data.bimg.rel.ro methods array. + method_load_kind = HInvokeStaticOrDirect::MethodLoadKind::kBootImageRelRo; + uint8_t* begin = Runtime::Current()->GetHeap()->GetBootImageSpaces().front()->Begin(); + method_load_data = reinterpret_cast(callee) - reinterpret_cast(begin); + code_ptr_location = HInvokeStaticOrDirect::CodePtrLocation::kCallArtMethod; } else { - // Use PC-relative access to the .bss methods arrays. + // Use PC-relative access to the .bss methods array. method_load_kind = HInvokeStaticOrDirect::MethodLoadKind::kBssEntry; code_ptr_location = HInvokeStaticOrDirect::CodePtrLocation::kCallArtMethod; } -- cgit v1.2.3-59-g8ed1b