Skip to content
This repository has been archived by the owner on Jun 1, 2023. It is now read-only.

Commit

Permalink
[Xposed] Evaluate QuickenedInfo in method verifier
Browse files Browse the repository at this point in the history
The original method/field index is encoded there, so we can reliably
dequicken the opcodes of dex code embedded in .oat files.
  • Loading branch information
rovo89 committed Oct 8, 2017
1 parent ddc5d18 commit 4231989
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
29 changes: 29 additions & 0 deletions runtime/verifier/method_verifier.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4119,13 +4119,36 @@ ArtMethod* MethodVerifier::VerifyInvocationArgs(
is_range, res_method);
}

uint16_t MethodVerifier::GetQuickenedInfo() const {
CHECK(mirror_method_ != nullptr);
const uint8_t* quickened_info = mirror_method_->GetQuickenedInfo();
CHECK(quickened_info != nullptr);
while (true) {
uint32_t dex_pc_in_map = DecodeUnsignedLeb128(&quickened_info);
uint16_t value_in_map = DecodeUnsignedLeb128(&quickened_info);
DCHECK_LE(dex_pc_in_map, work_insn_idx_);
if (dex_pc_in_map == work_insn_idx_) {
return value_in_map;
}
}
}

ArtMethod* MethodVerifier::GetQuickInvokedMethod(const Instruction* inst, RegisterLine* reg_line,
bool is_range, bool allow_failure) {
if (is_range) {
DCHECK_EQ(inst->Opcode(), Instruction::INVOKE_VIRTUAL_RANGE_QUICK);
} else {
DCHECK_EQ(inst->Opcode(), Instruction::INVOKE_VIRTUAL_QUICK);
}
if (Runtime::Current()->IsAotCompiler()) {
const OatDexFile* oat_dex_file = dex_file_->GetOatDexFile();
if (oat_dex_file != nullptr) {
ClassLinker* linker = Runtime::Current()->GetClassLinker();
ArtMethod* method = linker->ResolveMethod<ClassLinker::kNoICCECheckForCache>(
*dex_file_, GetQuickenedInfo(), dex_cache_, class_loader_, mirror_method_, InvokeType::kVirtual);
return method;
}
}
const RegType& actual_arg_type = reg_line->GetInvocationThis(this, inst, is_range, allow_failure);
if (!actual_arg_type.HasClass()) {
VLOG(verifier) << "Failed to get mirror::Class* from '" << actual_arg_type << "'";
Expand Down Expand Up @@ -4742,6 +4765,12 @@ ArtField* MethodVerifier::GetQuickFieldAccess(const Instruction* inst,
RegisterLine* reg_line) {
DCHECK(IsInstructionIGetQuickOrIPutQuick(inst->Opcode())) << inst->Opcode();
const RegType& object_type = reg_line->GetRegisterType(this, inst->VRegB_22c());
if (Runtime::Current()->IsAotCompiler()) {
const OatDexFile* oat_dex_file = dex_file_->GetOatDexFile();
if (oat_dex_file != nullptr) {
return GetInstanceField(object_type, GetQuickenedInfo());
}
}
if (!object_type.HasClass()) {
VLOG(verifier) << "Failed to get mirror::Class* from '" << object_type << "'";
return nullptr;
Expand Down
2 changes: 2 additions & 0 deletions runtime/verifier/method_verifier.h
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,8 @@ class MethodVerifier {
ArtField* GetQuickFieldAccess(const Instruction* inst, RegisterLine* reg_line)
SHARED_REQUIRES(Locks::mutator_lock_);

uint16_t GetQuickenedInfo() const SHARED_REQUIRES(Locks::mutator_lock_);

uint32_t GetEncounteredFailureTypes() {
return encountered_failure_types_;
}
Expand Down

0 comments on commit 4231989

Please sign in to comment.