diff options
author | 2020-09-28 12:10:28 +0100 | |
---|---|---|
committer | 2020-09-30 13:58:32 +0000 | |
commit | 8f63f1084b013a129f66cf8a7ed8ab1cae9f02aa (patch) | |
tree | 6e9bbf5ad71a55f701f740e2995e0b84e9b87307 /compiler/linker | |
parent | 7aa2bfc09541ea5d2516738de84c24cd0269fed0 (diff) |
Faster access to unresolved classes from compiled code.
Add two new load kinds to LoadClass, similar to kBssEntry
but using the access-checking entrypoint on the slow-path.
One is used for classes that are in the literal package and
the other for classes outside the literal package of the
compiling class. Associate new .bss entries with these load
kinds and update them from entrypoints based on the resolved
class properties. If the resolved class is public, both
types of entries can be updated, otherwise only the package
local entry can be updated and only if the defining class
loader of the class is the same as the caller's defining
class loader (which is identical for all code in an oat
file) because the run time access check for same package
requires both class loader and literal package name match.
Test: Additional tests in 727-checker-unresolved-class.
Test: m test-art-host-gtest
Test: testrunner.py --host --optimizing
Test: aosp_blueline-userdebug boots.
Test: run-gtests.sh
Test: testrunner.py --target --optimizing
Bug: 161898207
Change-Id: I281e06ac2825caf81c6d7ee3128af833abd39992
Diffstat (limited to 'compiler/linker')
-rw-r--r-- | compiler/linker/linker_patch.h | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/compiler/linker/linker_patch.h b/compiler/linker/linker_patch.h index 7fedf2e86e..4000fc2523 100644 --- a/compiler/linker/linker_patch.h +++ b/compiler/linker/linker_patch.h @@ -50,6 +50,8 @@ class LinkerPatch { kCallRelative, kTypeRelative, kTypeBssEntry, + kPublicTypeBssEntry, + kPackageTypeBssEntry, kStringRelative, kStringBssEntry, kCallEntrypoint, @@ -122,6 +124,26 @@ class LinkerPatch { return patch; } + static LinkerPatch PublicTypeBssEntryPatch(size_t literal_offset, + const DexFile* target_dex_file, + uint32_t pc_insn_offset, + uint32_t target_type_idx) { + LinkerPatch patch(literal_offset, Type::kPublicTypeBssEntry, target_dex_file); + patch.type_idx_ = target_type_idx; + patch.pc_insn_offset_ = pc_insn_offset; + return patch; + } + + static LinkerPatch PackageTypeBssEntryPatch(size_t literal_offset, + const DexFile* target_dex_file, + uint32_t pc_insn_offset, + uint32_t target_type_idx) { + LinkerPatch patch(literal_offset, Type::kPackageTypeBssEntry, target_dex_file); + patch.type_idx_ = target_type_idx; + patch.pc_insn_offset_ = pc_insn_offset; + return patch; + } + static LinkerPatch RelativeStringPatch(size_t literal_offset, const DexFile* target_dex_file, uint32_t pc_insn_offset, @@ -192,13 +214,17 @@ class LinkerPatch { const DexFile* TargetTypeDexFile() const { DCHECK(patch_type_ == Type::kTypeRelative || - patch_type_ == Type::kTypeBssEntry); + patch_type_ == Type::kTypeBssEntry || + patch_type_ == Type::kPublicTypeBssEntry || + patch_type_ == Type::kPackageTypeBssEntry); return target_dex_file_; } dex::TypeIndex TargetTypeIndex() const { DCHECK(patch_type_ == Type::kTypeRelative || - patch_type_ == Type::kTypeBssEntry); + patch_type_ == Type::kTypeBssEntry || + patch_type_ == Type::kPublicTypeBssEntry || + patch_type_ == Type::kPackageTypeBssEntry); return dex::TypeIndex(type_idx_); } @@ -221,6 +247,8 @@ class LinkerPatch { patch_type_ == Type::kMethodBssEntry || patch_type_ == Type::kTypeRelative || patch_type_ == Type::kTypeBssEntry || + patch_type_ == Type::kPublicTypeBssEntry || + patch_type_ == Type::kPackageTypeBssEntry || patch_type_ == Type::kStringRelative || patch_type_ == Type::kStringBssEntry); return pc_insn_offset_; |