diff options
| -rw-r--r-- | runtime/interpreter/mterp/nterp.cc | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/runtime/interpreter/mterp/nterp.cc b/runtime/interpreter/mterp/nterp.cc index 81e80ed885..f46091b20f 100644 --- a/runtime/interpreter/mterp/nterp.cc +++ b/runtime/interpreter/mterp/nterp.cc @@ -29,6 +29,7 @@ #include "interpreter/shadow_frame-inl.h" #include "mirror/string-alloc-inl.h" #include "nterp_helpers.h" +#include "verify_object-inl.h" namespace art { namespace interpreter { @@ -231,9 +232,39 @@ static constexpr std::array<uint8_t, 256u> GenerateOpcodeInvokeTypes() { static constexpr std::array<uint8_t, 256u> kOpcodeInvokeTypes = GenerateOpcodeInvokeTypes(); +// Temporary dumping output for helping diagnose b/261719949. +static std::string DumpInformation( + Thread* self, ArtMethod* caller, const uint16_t* dex_pc_ptr) { + return android::base::StringPrintf( + "b/261719949: self=%p, caller=%p, dex_pc_ptr=%p", self, caller, dex_pc_ptr); +} + +NO_INLINE static void CheckParameters(Thread* self, ArtMethod* caller, const uint16_t* dex_pc_ptr) + REQUIRES_SHARED(Locks::mutator_lock_) { + CHECK_EQ(self, Thread::Current()) << DumpInformation(self, caller, dex_pc_ptr); + // AOT compiler cross-compiles 64bits to 32bits, so for simplicity, don't + // check. + if (!Runtime::Current()->IsAotCompiler()) { + CHECK(IsAligned<sizeof(void*)>(caller)) << DumpInformation(self, caller, dex_pc_ptr); + } + ObjPtr<mirror::Class> cls = caller->GetDeclaringClass(); + CHECK(IsAligned<kObjectAlignment>(cls.Ptr())) << DumpInformation(self, caller, dex_pc_ptr); + CHECK(VerifyClassClass(cls)) << DumpInformation(self, caller, dex_pc_ptr); + const DexFile& dex_file = cls->GetDexFile(); + if (!caller->IsObsolete()) { + CHECK_LT(reinterpret_cast<uintptr_t>(dex_pc_ptr), + reinterpret_cast<uintptr_t>(dex_file.DataBegin() + dex_file.DataSize())) + << DumpInformation(self, caller, dex_pc_ptr); + CHECK_GT(reinterpret_cast<uintptr_t>(dex_pc_ptr), + reinterpret_cast<uintptr_t>(dex_file.DataBegin())) + << DumpInformation(self, caller, dex_pc_ptr); + } +} + FLATTEN extern "C" size_t NterpGetMethod(Thread* self, ArtMethod* caller, const uint16_t* dex_pc_ptr) REQUIRES_SHARED(Locks::mutator_lock_) { + CheckParameters(self, caller, dex_pc_ptr); UpdateHotness(caller); const Instruction* inst = Instruction::At(dex_pc_ptr); Instruction::Code opcode = inst->Opcode(); @@ -309,6 +340,7 @@ extern "C" size_t NterpGetStaticField(Thread* self, const uint16_t* dex_pc_ptr, size_t resolve_field_type) // Resolve if not zero REQUIRES_SHARED(Locks::mutator_lock_) { + CheckParameters(self, caller, dex_pc_ptr); UpdateHotness(caller); const Instruction* inst = Instruction::At(dex_pc_ptr); uint16_t field_index = inst->VRegB_21c(); @@ -364,6 +396,7 @@ extern "C" uint32_t NterpGetInstanceFieldOffset(Thread* self, const uint16_t* dex_pc_ptr, size_t resolve_field_type) // Resolve if not zero REQUIRES_SHARED(Locks::mutator_lock_) { + CheckParameters(self, caller, dex_pc_ptr); UpdateHotness(caller); const Instruction* inst = Instruction::At(dex_pc_ptr); uint16_t field_index = inst->VRegC_22c(); @@ -468,6 +501,7 @@ extern "C" mirror::Object* NterpAllocateObject(Thread* self, extern "C" mirror::Object* NterpLoadObject(Thread* self, ArtMethod* caller, uint16_t* dex_pc_ptr) REQUIRES_SHARED(Locks::mutator_lock_) { + CheckParameters(self, caller, dex_pc_ptr); const Instruction* inst = Instruction::At(dex_pc_ptr); ClassLinker* const class_linker = Runtime::Current()->GetClassLinker(); switch (inst->Opcode()) { |