diff options
author | Sebastien Hertz <shertz@google.com> | 2013-07-26 08:03:13 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2013-07-26 08:03:17 +0000 |
commit | a6dd03ff8003d459ec8607d5449340c4b00fd8cb (patch) | |
tree | 08dfa1991905bd07be786ff085cc8e8f618cd66d /runtime/interpreter/interpreter.cc | |
parent | fd840e7dc6c187bf7960ff30c574fc3e5c5bf829 (diff) | |
parent | 5fde12abafdcd3523ffd7d71f86e3b9e28f78065 (diff) | |
download | art-a6dd03ff8003d459ec8607d5449340c4b00fd8cb.zip art-a6dd03ff8003d459ec8607d5449340c4b00fd8cb.tar.gz art-a6dd03ff8003d459ec8607d5449340c4b00fd8cb.tar.bz2 |
Merge "Update DEX pc before thread suspension." into dalvik-dev
Diffstat (limited to 'runtime/interpreter/interpreter.cc')
-rw-r--r-- | runtime/interpreter/interpreter.cc | 91 |
1 files changed, 46 insertions, 45 deletions
diff --git a/runtime/interpreter/interpreter.cc b/runtime/interpreter/interpreter.cc index 09a0fc7..57e9dbf 100644 --- a/runtime/interpreter/interpreter.cc +++ b/runtime/interpreter/interpreter.cc @@ -1013,28 +1013,29 @@ static JValue ExecuteImpl(Thread* self, MethodHelper& mh, const DexFile::CodeIte return JValue(); } self->VerifyStack(); - instrumentation::Instrumentation* instrumentation = Runtime::Current()->GetInstrumentation(); - const uint16_t* const insns = code_item->insns_; + instrumentation::Instrumentation* const instrumentation = Runtime::Current()->GetInstrumentation(); // As the 'this' object won't change during the execution of current code, we // want to cache it in local variables. Nevertheless, in order to let the // garbage collector access it, we store it into sirt references. SirtRef<Object> this_object_ref(self, shadow_frame.GetThisObject(code_item->ins_size_)); - const Instruction* inst = Instruction::At(insns + shadow_frame.GetDexPC()); - if (inst->GetDexPc(insns) == 0) { // We are entering the method as opposed to deoptimizing.. + uint32_t dex_pc = shadow_frame.GetDexPC(); + if (LIKELY(dex_pc == 0)) { // We are entering the method as opposed to deoptimizing.. if (UNLIKELY(instrumentation->HasMethodEntryListeners())) { instrumentation->MethodEnterEvent(self, this_object_ref.get(), shadow_frame.GetMethod(), 0); } } + const uint16_t* const insns = code_item->insns_; + const Instruction* inst = Instruction::At(insns + dex_pc); while (true) { + dex_pc = inst->GetDexPc(insns); + shadow_frame.SetDexPC(dex_pc); if (UNLIKELY(self->TestAllFlags())) { CheckSuspend(self); } - const uint32_t dex_pc = inst->GetDexPc(insns); - shadow_frame.SetDexPC(dex_pc); - if (instrumentation->HasDexPcListeners()) { + if (UNLIKELY(instrumentation->HasDexPcListeners())) { instrumentation->DexPcMovedEvent(self, this_object_ref.get(), shadow_frame.GetMethod(), dex_pc); } @@ -1200,8 +1201,8 @@ static JValue ExecuteImpl(Thread* self, MethodHelper& mh, const DexFile::CodeIte } case Instruction::CONST_4: { PREAMBLE(); - uint32_t dst = inst->VRegA_11n(); - int32_t val = inst->VRegB_11n(); + uint4_t dst = inst->VRegA_11n(); + int4_t val = inst->VRegB_11n(); shadow_frame.SetVReg(dst, val); if (val == 0) { shadow_frame.SetVRegReference(dst, NULL); @@ -1211,8 +1212,8 @@ static JValue ExecuteImpl(Thread* self, MethodHelper& mh, const DexFile::CodeIte } case Instruction::CONST_16: { PREAMBLE(); - uint32_t dst = inst->VRegA_21s(); - int32_t val = inst->VRegB_21s(); + uint8_t dst = inst->VRegA_21s(); + int16_t val = inst->VRegB_21s(); shadow_frame.SetVReg(dst, val); if (val == 0) { shadow_frame.SetVRegReference(dst, NULL); @@ -1222,7 +1223,7 @@ static JValue ExecuteImpl(Thread* self, MethodHelper& mh, const DexFile::CodeIte } case Instruction::CONST: { PREAMBLE(); - uint32_t dst = inst->VRegA_31i(); + uint8_t dst = inst->VRegA_31i(); int32_t val = inst->VRegB_31i(); shadow_frame.SetVReg(dst, val); if (val == 0) { @@ -1233,7 +1234,7 @@ static JValue ExecuteImpl(Thread* self, MethodHelper& mh, const DexFile::CodeIte } case Instruction::CONST_HIGH16: { PREAMBLE(); - uint32_t dst = inst->VRegA_21h(); + uint8_t dst = inst->VRegA_21h(); int32_t val = static_cast<int32_t>(inst->VRegB_21h() << 16); shadow_frame.SetVReg(dst, val); if (val == 0) { @@ -2546,7 +2547,7 @@ static JValue ExecuteImpl(Thread* self, MethodHelper& mh, const DexFile::CodeIte break; case Instruction::ADD_INT_2ADDR: { PREAMBLE(); - uint32_t vregA = inst->VRegA_12x(); + uint4_t vregA = inst->VRegA_12x(); shadow_frame.SetVReg(vregA, shadow_frame.GetVReg(vregA) + shadow_frame.GetVReg(inst->VRegB_12x())); @@ -2555,7 +2556,7 @@ static JValue ExecuteImpl(Thread* self, MethodHelper& mh, const DexFile::CodeIte } case Instruction::SUB_INT_2ADDR: { PREAMBLE(); - uint32_t vregA = inst->VRegA_12x(); + uint4_t vregA = inst->VRegA_12x(); shadow_frame.SetVReg(vregA, shadow_frame.GetVReg(vregA) - shadow_frame.GetVReg(inst->VRegB_12x())); @@ -2564,7 +2565,7 @@ static JValue ExecuteImpl(Thread* self, MethodHelper& mh, const DexFile::CodeIte } case Instruction::MUL_INT_2ADDR: { PREAMBLE(); - uint32_t vregA = inst->VRegA_12x(); + uint4_t vregA = inst->VRegA_12x(); shadow_frame.SetVReg(vregA, shadow_frame.GetVReg(vregA) * shadow_frame.GetVReg(inst->VRegB_12x())); @@ -2573,7 +2574,7 @@ static JValue ExecuteImpl(Thread* self, MethodHelper& mh, const DexFile::CodeIte } case Instruction::DIV_INT_2ADDR: { PREAMBLE(); - uint32_t vregA = inst->VRegA_12x(); + uint4_t vregA = inst->VRegA_12x(); DoIntDivide(shadow_frame, vregA, shadow_frame.GetVReg(vregA), shadow_frame.GetVReg(inst->VRegB_12x())); inst = inst->Next_1xx(); @@ -2581,7 +2582,7 @@ static JValue ExecuteImpl(Thread* self, MethodHelper& mh, const DexFile::CodeIte } case Instruction::REM_INT_2ADDR: { PREAMBLE(); - uint32_t vregA = inst->VRegA_12x(); + uint4_t vregA = inst->VRegA_12x(); DoIntRemainder(shadow_frame, vregA, shadow_frame.GetVReg(vregA), shadow_frame.GetVReg(inst->VRegB_12x())); POSSIBLY_HANDLE_PENDING_EXCEPTION(Next_1xx); @@ -2589,7 +2590,7 @@ static JValue ExecuteImpl(Thread* self, MethodHelper& mh, const DexFile::CodeIte } case Instruction::SHL_INT_2ADDR: { PREAMBLE(); - uint32_t vregA = inst->VRegA_12x(); + uint4_t vregA = inst->VRegA_12x(); shadow_frame.SetVReg(vregA, shadow_frame.GetVReg(vregA) << (shadow_frame.GetVReg(inst->VRegB_12x()) & 0x1f)); @@ -2598,7 +2599,7 @@ static JValue ExecuteImpl(Thread* self, MethodHelper& mh, const DexFile::CodeIte } case Instruction::SHR_INT_2ADDR: { PREAMBLE(); - uint32_t vregA = inst->VRegA_12x(); + uint4_t vregA = inst->VRegA_12x(); shadow_frame.SetVReg(vregA, shadow_frame.GetVReg(vregA) >> (shadow_frame.GetVReg(inst->VRegB_12x()) & 0x1f)); @@ -2607,7 +2608,7 @@ static JValue ExecuteImpl(Thread* self, MethodHelper& mh, const DexFile::CodeIte } case Instruction::USHR_INT_2ADDR: { PREAMBLE(); - uint32_t vregA = inst->VRegA_12x(); + uint4_t vregA = inst->VRegA_12x(); shadow_frame.SetVReg(vregA, static_cast<uint32_t>(shadow_frame.GetVReg(vregA)) >> (shadow_frame.GetVReg(inst->VRegB_12x()) & 0x1f)); @@ -2616,7 +2617,7 @@ static JValue ExecuteImpl(Thread* self, MethodHelper& mh, const DexFile::CodeIte } case Instruction::AND_INT_2ADDR: { PREAMBLE(); - uint32_t vregA = inst->VRegA_12x(); + uint4_t vregA = inst->VRegA_12x(); shadow_frame.SetVReg(vregA, shadow_frame.GetVReg(vregA) & shadow_frame.GetVReg(inst->VRegB_12x())); @@ -2625,7 +2626,7 @@ static JValue ExecuteImpl(Thread* self, MethodHelper& mh, const DexFile::CodeIte } case Instruction::OR_INT_2ADDR: { PREAMBLE(); - uint32_t vregA = inst->VRegA_12x(); + uint4_t vregA = inst->VRegA_12x(); shadow_frame.SetVReg(vregA, shadow_frame.GetVReg(vregA) | shadow_frame.GetVReg(inst->VRegB_12x())); @@ -2634,7 +2635,7 @@ static JValue ExecuteImpl(Thread* self, MethodHelper& mh, const DexFile::CodeIte } case Instruction::XOR_INT_2ADDR: { PREAMBLE(); - uint32_t vregA = inst->VRegA_12x(); + uint4_t vregA = inst->VRegA_12x(); shadow_frame.SetVReg(vregA, shadow_frame.GetVReg(vregA) ^ shadow_frame.GetVReg(inst->VRegB_12x())); @@ -2643,7 +2644,7 @@ static JValue ExecuteImpl(Thread* self, MethodHelper& mh, const DexFile::CodeIte } case Instruction::ADD_LONG_2ADDR: { PREAMBLE(); - uint32_t vregA = inst->VRegA_12x(); + uint4_t vregA = inst->VRegA_12x(); shadow_frame.SetVRegLong(vregA, shadow_frame.GetVRegLong(vregA) + shadow_frame.GetVRegLong(inst->VRegB_12x())); @@ -2652,7 +2653,7 @@ static JValue ExecuteImpl(Thread* self, MethodHelper& mh, const DexFile::CodeIte } case Instruction::SUB_LONG_2ADDR: { PREAMBLE(); - uint32_t vregA = inst->VRegA_12x(); + uint4_t vregA = inst->VRegA_12x(); shadow_frame.SetVRegLong(vregA, shadow_frame.GetVRegLong(vregA) - shadow_frame.GetVRegLong(inst->VRegB_12x())); @@ -2661,7 +2662,7 @@ static JValue ExecuteImpl(Thread* self, MethodHelper& mh, const DexFile::CodeIte } case Instruction::MUL_LONG_2ADDR: { PREAMBLE(); - uint32_t vregA = inst->VRegA_12x(); + uint4_t vregA = inst->VRegA_12x(); shadow_frame.SetVRegLong(vregA, shadow_frame.GetVRegLong(vregA) * shadow_frame.GetVRegLong(inst->VRegB_12x())); @@ -2670,7 +2671,7 @@ static JValue ExecuteImpl(Thread* self, MethodHelper& mh, const DexFile::CodeIte } case Instruction::DIV_LONG_2ADDR: { PREAMBLE(); - uint32_t vregA = inst->VRegA_12x(); + uint4_t vregA = inst->VRegA_12x(); DoLongDivide(shadow_frame, vregA, shadow_frame.GetVRegLong(vregA), shadow_frame.GetVRegLong(inst->VRegB_12x())); POSSIBLY_HANDLE_PENDING_EXCEPTION(Next_1xx); @@ -2678,7 +2679,7 @@ static JValue ExecuteImpl(Thread* self, MethodHelper& mh, const DexFile::CodeIte } case Instruction::REM_LONG_2ADDR: { PREAMBLE(); - uint32_t vregA = inst->VRegA_12x(); + uint4_t vregA = inst->VRegA_12x(); DoLongRemainder(shadow_frame, vregA, shadow_frame.GetVRegLong(vregA), shadow_frame.GetVRegLong(inst->VRegB_12x())); POSSIBLY_HANDLE_PENDING_EXCEPTION(Next_1xx); @@ -2686,7 +2687,7 @@ static JValue ExecuteImpl(Thread* self, MethodHelper& mh, const DexFile::CodeIte } case Instruction::AND_LONG_2ADDR: { PREAMBLE(); - uint32_t vregA = inst->VRegA_12x(); + uint4_t vregA = inst->VRegA_12x(); shadow_frame.SetVRegLong(vregA, shadow_frame.GetVRegLong(vregA) & shadow_frame.GetVRegLong(inst->VRegB_12x())); @@ -2695,7 +2696,7 @@ static JValue ExecuteImpl(Thread* self, MethodHelper& mh, const DexFile::CodeIte } case Instruction::OR_LONG_2ADDR: { PREAMBLE(); - uint32_t vregA = inst->VRegA_12x(); + uint4_t vregA = inst->VRegA_12x(); shadow_frame.SetVRegLong(vregA, shadow_frame.GetVRegLong(vregA) | shadow_frame.GetVRegLong(inst->VRegB_12x())); @@ -2704,7 +2705,7 @@ static JValue ExecuteImpl(Thread* self, MethodHelper& mh, const DexFile::CodeIte } case Instruction::XOR_LONG_2ADDR: { PREAMBLE(); - uint32_t vregA = inst->VRegA_12x(); + uint4_t vregA = inst->VRegA_12x(); shadow_frame.SetVRegLong(vregA, shadow_frame.GetVRegLong(vregA) ^ shadow_frame.GetVRegLong(inst->VRegB_12x())); @@ -2713,7 +2714,7 @@ static JValue ExecuteImpl(Thread* self, MethodHelper& mh, const DexFile::CodeIte } case Instruction::SHL_LONG_2ADDR: { PREAMBLE(); - uint32_t vregA = inst->VRegA_12x(); + uint4_t vregA = inst->VRegA_12x(); shadow_frame.SetVRegLong(vregA, shadow_frame.GetVRegLong(vregA) << (shadow_frame.GetVReg(inst->VRegB_12x()) & 0x3f)); @@ -2722,7 +2723,7 @@ static JValue ExecuteImpl(Thread* self, MethodHelper& mh, const DexFile::CodeIte } case Instruction::SHR_LONG_2ADDR: { PREAMBLE(); - uint32_t vregA = inst->VRegA_12x(); + uint4_t vregA = inst->VRegA_12x(); shadow_frame.SetVRegLong(vregA, shadow_frame.GetVRegLong(vregA) >> (shadow_frame.GetVReg(inst->VRegB_12x()) & 0x3f)); @@ -2731,7 +2732,7 @@ static JValue ExecuteImpl(Thread* self, MethodHelper& mh, const DexFile::CodeIte } case Instruction::USHR_LONG_2ADDR: { PREAMBLE(); - uint32_t vregA = inst->VRegA_12x(); + uint4_t vregA = inst->VRegA_12x(); shadow_frame.SetVRegLong(vregA, static_cast<uint64_t>(shadow_frame.GetVRegLong(vregA)) >> (shadow_frame.GetVReg(inst->VRegB_12x()) & 0x3f)); @@ -2740,7 +2741,7 @@ static JValue ExecuteImpl(Thread* self, MethodHelper& mh, const DexFile::CodeIte } case Instruction::ADD_FLOAT_2ADDR: { PREAMBLE(); - uint32_t vregA = inst->VRegA_12x(); + uint4_t vregA = inst->VRegA_12x(); shadow_frame.SetVRegFloat(vregA, shadow_frame.GetVRegFloat(vregA) + shadow_frame.GetVRegFloat(inst->VRegB_12x())); @@ -2749,7 +2750,7 @@ static JValue ExecuteImpl(Thread* self, MethodHelper& mh, const DexFile::CodeIte } case Instruction::SUB_FLOAT_2ADDR: { PREAMBLE(); - uint32_t vregA = inst->VRegA_12x(); + uint4_t vregA = inst->VRegA_12x(); shadow_frame.SetVRegFloat(vregA, shadow_frame.GetVRegFloat(vregA) - shadow_frame.GetVRegFloat(inst->VRegB_12x())); @@ -2758,7 +2759,7 @@ static JValue ExecuteImpl(Thread* self, MethodHelper& mh, const DexFile::CodeIte } case Instruction::MUL_FLOAT_2ADDR: { PREAMBLE(); - uint32_t vregA = inst->VRegA_12x(); + uint4_t vregA = inst->VRegA_12x(); shadow_frame.SetVRegFloat(vregA, shadow_frame.GetVRegFloat(vregA) * shadow_frame.GetVRegFloat(inst->VRegB_12x())); @@ -2767,7 +2768,7 @@ static JValue ExecuteImpl(Thread* self, MethodHelper& mh, const DexFile::CodeIte } case Instruction::DIV_FLOAT_2ADDR: { PREAMBLE(); - uint32_t vregA = inst->VRegA_12x(); + uint4_t vregA = inst->VRegA_12x(); shadow_frame.SetVRegFloat(vregA, shadow_frame.GetVRegFloat(vregA) / shadow_frame.GetVRegFloat(inst->VRegB_12x())); @@ -2776,7 +2777,7 @@ static JValue ExecuteImpl(Thread* self, MethodHelper& mh, const DexFile::CodeIte } case Instruction::REM_FLOAT_2ADDR: { PREAMBLE(); - uint32_t vregA = inst->VRegA_12x(); + uint4_t vregA = inst->VRegA_12x(); shadow_frame.SetVRegFloat(vregA, fmodf(shadow_frame.GetVRegFloat(vregA), shadow_frame.GetVRegFloat(inst->VRegB_12x()))); @@ -2785,7 +2786,7 @@ static JValue ExecuteImpl(Thread* self, MethodHelper& mh, const DexFile::CodeIte } case Instruction::ADD_DOUBLE_2ADDR: { PREAMBLE(); - uint32_t vregA = inst->VRegA_12x(); + uint4_t vregA = inst->VRegA_12x(); shadow_frame.SetVRegDouble(vregA, shadow_frame.GetVRegDouble(vregA) + shadow_frame.GetVRegDouble(inst->VRegB_12x())); @@ -2794,7 +2795,7 @@ static JValue ExecuteImpl(Thread* self, MethodHelper& mh, const DexFile::CodeIte } case Instruction::SUB_DOUBLE_2ADDR: { PREAMBLE(); - uint32_t vregA = inst->VRegA_12x(); + uint4_t vregA = inst->VRegA_12x(); shadow_frame.SetVRegDouble(vregA, shadow_frame.GetVRegDouble(vregA) - shadow_frame.GetVRegDouble(inst->VRegB_12x())); @@ -2803,7 +2804,7 @@ static JValue ExecuteImpl(Thread* self, MethodHelper& mh, const DexFile::CodeIte } case Instruction::MUL_DOUBLE_2ADDR: { PREAMBLE(); - uint32_t vregA = inst->VRegA_12x(); + uint4_t vregA = inst->VRegA_12x(); shadow_frame.SetVRegDouble(vregA, shadow_frame.GetVRegDouble(vregA) * shadow_frame.GetVRegDouble(inst->VRegB_12x())); @@ -2812,7 +2813,7 @@ static JValue ExecuteImpl(Thread* self, MethodHelper& mh, const DexFile::CodeIte } case Instruction::DIV_DOUBLE_2ADDR: { PREAMBLE(); - uint32_t vregA = inst->VRegA_12x(); + uint4_t vregA = inst->VRegA_12x(); shadow_frame.SetVRegDouble(vregA, shadow_frame.GetVRegDouble(vregA) / shadow_frame.GetVRegDouble(inst->VRegB_12x())); @@ -2821,7 +2822,7 @@ static JValue ExecuteImpl(Thread* self, MethodHelper& mh, const DexFile::CodeIte } case Instruction::REM_DOUBLE_2ADDR: { PREAMBLE(); - uint32_t vregA = inst->VRegA_12x(); + uint4_t vregA = inst->VRegA_12x(); shadow_frame.SetVRegDouble(vregA, fmod(shadow_frame.GetVRegDouble(vregA), shadow_frame.GetVRegDouble(inst->VRegB_12x()))); |