blob: 243260345ee37aeb97847f79c630758ced6160a5 [file] [log] [blame]
Sebastien Hertzd45a1f52014-01-09 14:56:54 +01001/*
2 * Copyright (C) 2014 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
Sebastien Hertzfd3077e2014-04-23 10:32:43 +020017#include "quick_exception_handler.h"
18
Ian Rogerse63db272014-07-15 15:36:11 -070019#include "arch/context.h"
Ian Rogers5cf98192014-05-29 21:31:50 -070020#include "dex_instruction.h"
Sebastien Hertzfd3077e2014-04-23 10:32:43 +020021#include "entrypoints/entrypoint_utils.h"
Ian Rogers6f3dbba2014-10-14 17:41:57 -070022#include "entrypoints/runtime_asm_entrypoints.h"
Mathieu Chartiereb8167a2014-05-07 15:43:14 -070023#include "handle_scope-inl.h"
Ian Rogers5cf98192014-05-29 21:31:50 -070024#include "mirror/art_method-inl.h"
Mingyao Yang98d1cc82014-05-15 17:02:16 -070025#include "mirror/class-inl.h"
26#include "mirror/class_loader.h"
27#include "mirror/throwable.h"
Ian Rogers5cf98192014-05-29 21:31:50 -070028#include "verifier/method_verifier.h"
Sebastien Hertzd45a1f52014-01-09 14:56:54 +010029
30namespace art {
31
Ian Rogers5cf98192014-05-29 21:31:50 -070032static constexpr bool kDebugExceptionDelivery = false;
Hiroshi Yamauchi649278c2014-08-13 11:12:22 -070033static constexpr size_t kInvalidFrameDepth = 0xffffffff;
Ian Rogers5cf98192014-05-29 21:31:50 -070034
Sebastien Hertzfd3077e2014-04-23 10:32:43 +020035QuickExceptionHandler::QuickExceptionHandler(Thread* self, bool is_deoptimization)
36 : self_(self), context_(self->GetLongJumpContext()), is_deoptimization_(is_deoptimization),
Sebastien Hertzd45a1f52014-01-09 14:56:54 +010037 method_tracing_active_(is_deoptimization ||
38 Runtime::Current()->GetInstrumentation()->AreExitStubsInstalled()),
Ian Rogers5cf98192014-05-29 21:31:50 -070039 handler_quick_frame_(nullptr), handler_quick_frame_pc_(0), handler_method_(nullptr),
Hiroshi Yamauchi649278c2014-08-13 11:12:22 -070040 handler_dex_pc_(0), clear_exception_(false), handler_frame_depth_(kInvalidFrameDepth) {
Sebastien Hertzd45a1f52014-01-09 14:56:54 +010041}
42
Ian Rogers5cf98192014-05-29 21:31:50 -070043// Finds catch handler or prepares for deoptimization.
44class CatchBlockStackVisitor FINAL : public StackVisitor {
45 public:
46 CatchBlockStackVisitor(Thread* self, Context* context, Handle<mirror::Throwable>* exception,
47 QuickExceptionHandler* exception_handler)
48 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_)
49 : StackVisitor(self, context), self_(self), exception_(exception),
50 exception_handler_(exception_handler) {
51 }
52
53 bool VisitFrame() OVERRIDE SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
54 mirror::ArtMethod* method = GetMethod();
Hiroshi Yamauchi649278c2014-08-13 11:12:22 -070055 exception_handler_->SetHandlerFrameDepth(GetFrameDepth());
Ian Rogers5cf98192014-05-29 21:31:50 -070056 if (method == nullptr) {
57 // This is the upcall, we remember the frame and last pc so that we may long jump to them.
58 exception_handler_->SetHandlerQuickFramePc(GetCurrentQuickFramePc());
59 exception_handler_->SetHandlerQuickFrame(GetCurrentQuickFrame());
60 uint32_t next_dex_pc;
61 mirror::ArtMethod* next_art_method;
62 bool has_next = GetNextMethodAndDexPc(&next_art_method, &next_dex_pc);
63 // Report the method that did the down call as the handler.
64 exception_handler_->SetHandlerDexPc(next_dex_pc);
65 exception_handler_->SetHandlerMethod(next_art_method);
66 if (!has_next) {
67 // No next method? Check exception handler is set up for the unhandled exception handler
68 // case.
69 DCHECK_EQ(0U, exception_handler_->GetHandlerDexPc());
70 DCHECK(nullptr == exception_handler_->GetHandlerMethod());
71 }
72 return false; // End stack walk.
73 }
74 if (method->IsRuntimeMethod()) {
75 // Ignore callee save method.
76 DCHECK(method->IsCalleeSaveMethod());
77 return true;
78 }
Mathieu Chartierbfd9a432014-05-21 17:43:44 -070079 StackHandleScope<1> hs(self_);
80 return HandleTryItems(hs.NewHandle(method));
Ian Rogers5cf98192014-05-29 21:31:50 -070081 }
82
83 private:
Mathieu Chartierbfd9a432014-05-21 17:43:44 -070084 bool HandleTryItems(Handle<mirror::ArtMethod> method)
85 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
Ian Rogers5cf98192014-05-29 21:31:50 -070086 uint32_t dex_pc = DexFile::kDexNoIndex;
87 if (!method->IsNative()) {
88 dex_pc = GetDexPc();
89 }
90 if (dex_pc != DexFile::kDexNoIndex) {
91 bool clear_exception = false;
92 StackHandleScope<1> hs(Thread::Current());
93 Handle<mirror::Class> to_find(hs.NewHandle((*exception_)->GetClass()));
Mathieu Chartierbfd9a432014-05-21 17:43:44 -070094 uint32_t found_dex_pc = mirror::ArtMethod::FindCatchBlock(method, to_find, dex_pc,
95 &clear_exception);
Ian Rogers5cf98192014-05-29 21:31:50 -070096 exception_handler_->SetClearException(clear_exception);
97 if (found_dex_pc != DexFile::kDexNoIndex) {
Mathieu Chartierbfd9a432014-05-21 17:43:44 -070098 exception_handler_->SetHandlerMethod(method.Get());
Ian Rogers5cf98192014-05-29 21:31:50 -070099 exception_handler_->SetHandlerDexPc(found_dex_pc);
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700100 exception_handler_->SetHandlerQuickFramePc(method->ToNativeQuickPc(found_dex_pc));
Ian Rogers5cf98192014-05-29 21:31:50 -0700101 exception_handler_->SetHandlerQuickFrame(GetCurrentQuickFrame());
102 return false; // End stack walk.
103 }
104 }
105 return true; // Continue stack walk.
106 }
107
108 Thread* const self_;
109 // The exception we're looking for the catch block of.
110 Handle<mirror::Throwable>* exception_;
111 // The quick exception handler we're visiting for.
112 QuickExceptionHandler* const exception_handler_;
113
114 DISALLOW_COPY_AND_ASSIGN(CatchBlockStackVisitor);
115};
116
Nicolas Geoffray14691c52015-03-05 10:40:17 +0000117void QuickExceptionHandler::FindCatch(mirror::Throwable* exception) {
Sebastien Hertzfd3077e2014-04-23 10:32:43 +0200118 DCHECK(!is_deoptimization_);
Ian Rogers5cf98192014-05-29 21:31:50 -0700119 if (kDebugExceptionDelivery) {
120 mirror::String* msg = exception->GetDetailMessage();
121 std::string str_msg(msg != nullptr ? msg->ToModifiedUtf8() : "");
122 self_->DumpStack(LOG(INFO) << "Delivering exception: " << PrettyTypeOf(exception)
123 << ": " << str_msg << "\n");
124 }
Mathieu Chartiereb8167a2014-05-07 15:43:14 -0700125 StackHandleScope<1> hs(self_);
126 Handle<mirror::Throwable> exception_ref(hs.NewHandle(exception));
Sebastien Hertzfd3077e2014-04-23 10:32:43 +0200127
Sebastien Hertzd45a1f52014-01-09 14:56:54 +0100128 // Walk the stack to find catch handler or prepare for deoptimization.
Mathieu Chartiereb8167a2014-05-07 15:43:14 -0700129 CatchBlockStackVisitor visitor(self_, context_, &exception_ref, this);
Sebastien Hertzd45a1f52014-01-09 14:56:54 +0100130 visitor.WalkStack(true);
131
Sebastien Hertzfd3077e2014-04-23 10:32:43 +0200132 if (kDebugExceptionDelivery) {
Ian Rogers5cf98192014-05-29 21:31:50 -0700133 if (handler_quick_frame_->AsMirrorPtr() == nullptr) {
Sebastien Hertzd45a1f52014-01-09 14:56:54 +0100134 LOG(INFO) << "Handler is upcall";
Ian Rogers5cf98192014-05-29 21:31:50 -0700135 }
136 if (handler_method_ != nullptr) {
137 const DexFile& dex_file = *handler_method_->GetDeclaringClass()->GetDexCache()->GetDexFile();
138 int line_number = dex_file.GetLineNumFromPC(handler_method_, handler_dex_pc_);
139 LOG(INFO) << "Handler: " << PrettyMethod(handler_method_) << " (line: " << line_number << ")";
Sebastien Hertzd45a1f52014-01-09 14:56:54 +0100140 }
141 }
142 if (clear_exception_) {
143 // Exception was cleared as part of delivery.
144 DCHECK(!self_->IsExceptionPending());
145 } else {
146 // Put exception back in root set with clear throw location.
Nicolas Geoffray14691c52015-03-05 10:40:17 +0000147 self_->SetException(exception_ref.Get());
Sebastien Hertzd45a1f52014-01-09 14:56:54 +0100148 }
Sebastien Hertzfd3077e2014-04-23 10:32:43 +0200149 // The debugger may suspend this thread and walk its stack. Let's do this before popping
150 // instrumentation frames.
Nicolas Geoffray7642cfc2015-02-26 10:56:09 +0000151 instrumentation::Instrumentation* instrumentation = Runtime::Current()->GetInstrumentation();
152 if (instrumentation->HasExceptionCaughtListeners()
153 && self_->IsExceptionThrownByCurrentMethod(exception)) {
Nicolas Geoffray14691c52015-03-05 10:40:17 +0000154 instrumentation->ExceptionCaughtEvent(self_, exception_ref.Get());
Sebastien Hertz9f102032014-05-23 08:59:42 +0200155 }
Sebastien Hertzfd3077e2014-04-23 10:32:43 +0200156}
157
Ian Rogers5cf98192014-05-29 21:31:50 -0700158// Prepares deoptimization.
159class DeoptimizeStackVisitor FINAL : public StackVisitor {
160 public:
161 DeoptimizeStackVisitor(Thread* self, Context* context, QuickExceptionHandler* exception_handler)
162 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_)
163 : StackVisitor(self, context), self_(self), exception_handler_(exception_handler),
164 prev_shadow_frame_(nullptr) {
165 CHECK(!self_->HasDeoptimizationShadowFrame());
166 }
167
168 bool VisitFrame() OVERRIDE SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
Hiroshi Yamauchi649278c2014-08-13 11:12:22 -0700169 exception_handler_->SetHandlerFrameDepth(GetFrameDepth());
Ian Rogers5cf98192014-05-29 21:31:50 -0700170 mirror::ArtMethod* method = GetMethod();
171 if (method == nullptr) {
172 // This is the upcall, we remember the frame and last pc so that we may long jump to them.
173 exception_handler_->SetHandlerQuickFramePc(GetCurrentQuickFramePc());
174 exception_handler_->SetHandlerQuickFrame(GetCurrentQuickFrame());
175 return false; // End stack walk.
176 } else if (method->IsRuntimeMethod()) {
177 // Ignore callee save method.
178 DCHECK(method->IsCalleeSaveMethod());
179 return true;
180 } else {
181 return HandleDeoptimization(method);
182 }
183 }
184
185 private:
Sebastien Hertzc901dd72014-07-16 11:56:07 +0200186 static VRegKind GetVRegKind(uint16_t reg, const std::vector<int32_t>& kinds) {
187 return static_cast<VRegKind>(kinds.at(reg * 2));
188 }
189
Ian Rogers5cf98192014-05-29 21:31:50 -0700190 bool HandleDeoptimization(mirror::ArtMethod* m) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
Mathieu Chartierbfd9a432014-05-21 17:43:44 -0700191 const DexFile::CodeItem* code_item = m->GetCodeItem();
Ian Rogers5cf98192014-05-29 21:31:50 -0700192 CHECK(code_item != nullptr);
193 uint16_t num_regs = code_item->registers_size_;
194 uint32_t dex_pc = GetDexPc();
Andreas Gampe2e04bb22015-02-10 15:37:27 -0800195 StackHandleScope<3> hs(self_); // Dex cache, class loader and method.
Mathieu Chartierbfd9a432014-05-21 17:43:44 -0700196 mirror::Class* declaring_class = m->GetDeclaringClass();
197 Handle<mirror::DexCache> h_dex_cache(hs.NewHandle(declaring_class->GetDexCache()));
198 Handle<mirror::ClassLoader> h_class_loader(hs.NewHandle(declaring_class->GetClassLoader()));
Hiroshi Yamauchidc376172014-08-22 11:13:12 -0700199 Handle<mirror::ArtMethod> h_method(hs.NewHandle(m));
Ian Rogers7b078e82014-09-10 14:44:24 -0700200 verifier::MethodVerifier verifier(self_, h_dex_cache->GetDexFile(), h_dex_cache, h_class_loader,
Mathieu Chartierbf99f772014-08-23 16:37:27 -0700201 &m->GetClassDef(), code_item, m->GetDexMethodIndex(),
Andreas Gampe2e04bb22015-02-10 15:37:27 -0800202 h_method, m->GetAccessFlags(), true, true, true, true);
203 bool verifier_success = verifier.Verify();
204 CHECK(verifier_success) << PrettyMethod(h_method.Get());
205 ShadowFrame* new_frame = ShadowFrame::Create(num_regs, nullptr, h_method.Get(), dex_pc);
206 self_->SetShadowFrameUnderConstruction(new_frame);
Sebastien Hertzc901dd72014-07-16 11:56:07 +0200207 const std::vector<int32_t> kinds(verifier.DescribeVRegs(dex_pc));
Nicolas Geoffray15b9d522015-03-12 15:05:13 +0000208
209 // Markers for dead values, used when the verifier knows a Dex register is undefined,
210 // or when the compiler knows the register has not been initialized, or is not used
211 // anymore in the method.
212 static constexpr uint32_t kDeadValue = 0xEBADDE09;
213 static constexpr uint64_t kLongDeadValue = 0xEBADDE09EBADDE09;
Ian Rogers5cf98192014-05-29 21:31:50 -0700214 for (uint16_t reg = 0; reg < num_regs; ++reg) {
Sebastien Hertzc901dd72014-07-16 11:56:07 +0200215 VRegKind kind = GetVRegKind(reg, kinds);
Ian Rogers5cf98192014-05-29 21:31:50 -0700216 switch (kind) {
217 case kUndefined:
Nicolas Geoffray15b9d522015-03-12 15:05:13 +0000218 new_frame->SetVReg(reg, kDeadValue);
Ian Rogers5cf98192014-05-29 21:31:50 -0700219 break;
220 case kConstant:
221 new_frame->SetVReg(reg, kinds.at((reg * 2) + 1));
222 break;
Nicolas Geoffray15b9d522015-03-12 15:05:13 +0000223 case kReferenceVReg: {
224 uint32_t value = 0;
225 if (GetVReg(h_method.Get(), reg, kind, &value)) {
226 new_frame->SetVRegReference(reg, reinterpret_cast<mirror::Object*>(value));
227 } else {
228 new_frame->SetVReg(reg, kDeadValue);
229 }
Ian Rogers5cf98192014-05-29 21:31:50 -0700230 break;
Nicolas Geoffray15b9d522015-03-12 15:05:13 +0000231 }
Sebastien Hertzc901dd72014-07-16 11:56:07 +0200232 case kLongLoVReg:
Ian Rogers07140832014-09-30 15:43:59 -0700233 if (GetVRegKind(reg + 1, kinds) == kLongHiVReg) {
Sebastien Hertzc901dd72014-07-16 11:56:07 +0200234 // Treat it as a "long" register pair.
Nicolas Geoffray15b9d522015-03-12 15:05:13 +0000235 uint64_t value = 0;
236 if (GetVRegPair(h_method.Get(), reg, kLongLoVReg, kLongHiVReg, &value)) {
237 new_frame->SetVRegLong(reg, value);
238 } else {
239 new_frame->SetVRegLong(reg, kLongDeadValue);
240 }
Sebastien Hertzc901dd72014-07-16 11:56:07 +0200241 } else {
Nicolas Geoffray15b9d522015-03-12 15:05:13 +0000242 uint32_t value = 0;
243 if (GetVReg(h_method.Get(), reg, kind, &value)) {
244 new_frame->SetVReg(reg, value);
245 } else {
246 new_frame->SetVReg(reg, kDeadValue);
247 }
Sebastien Hertzc901dd72014-07-16 11:56:07 +0200248 }
249 break;
250 case kLongHiVReg:
Ian Rogers07140832014-09-30 15:43:59 -0700251 if (GetVRegKind(reg - 1, kinds) == kLongLoVReg) {
Sebastien Hertzc901dd72014-07-16 11:56:07 +0200252 // Nothing to do: we treated it as a "long" register pair.
253 } else {
Nicolas Geoffray15b9d522015-03-12 15:05:13 +0000254 uint32_t value = 0;
255 if (GetVReg(h_method.Get(), reg, kind, &value)) {
256 new_frame->SetVReg(reg, value);
257 } else {
258 new_frame->SetVReg(reg, kDeadValue);
259 }
Sebastien Hertzc901dd72014-07-16 11:56:07 +0200260 }
261 break;
262 case kDoubleLoVReg:
Ian Rogers07140832014-09-30 15:43:59 -0700263 if (GetVRegKind(reg + 1, kinds) == kDoubleHiVReg) {
Nicolas Geoffray15b9d522015-03-12 15:05:13 +0000264 uint64_t value = 0;
265 if (GetVRegPair(h_method.Get(), reg, kDoubleLoVReg, kDoubleHiVReg, &value)) {
266 // Treat it as a "double" register pair.
267 new_frame->SetVRegLong(reg, value);
268 } else {
269 new_frame->SetVRegLong(reg, kLongDeadValue);
270 }
Sebastien Hertzc901dd72014-07-16 11:56:07 +0200271 } else {
Nicolas Geoffray15b9d522015-03-12 15:05:13 +0000272 uint32_t value = 0;
273 if (GetVReg(h_method.Get(), reg, kind, &value)) {
274 new_frame->SetVReg(reg, value);
275 } else {
276 new_frame->SetVReg(reg, kDeadValue);
277 }
Sebastien Hertzc901dd72014-07-16 11:56:07 +0200278 }
279 break;
280 case kDoubleHiVReg:
Ian Rogers07140832014-09-30 15:43:59 -0700281 if (GetVRegKind(reg - 1, kinds) == kDoubleLoVReg) {
Sebastien Hertzc901dd72014-07-16 11:56:07 +0200282 // Nothing to do: we treated it as a "double" register pair.
283 } else {
Nicolas Geoffray15b9d522015-03-12 15:05:13 +0000284 uint32_t value = 0;
285 if (GetVReg(h_method.Get(), reg, kind, &value)) {
286 new_frame->SetVReg(reg, value);
287 } else {
288 new_frame->SetVReg(reg, kDeadValue);
289 }
Sebastien Hertzc901dd72014-07-16 11:56:07 +0200290 }
291 break;
Ian Rogers5cf98192014-05-29 21:31:50 -0700292 default:
Nicolas Geoffray15b9d522015-03-12 15:05:13 +0000293 uint32_t value = 0;
294 if (GetVReg(h_method.Get(), reg, kind, &value)) {
295 new_frame->SetVReg(reg, value);
296 } else {
297 new_frame->SetVReg(reg, kDeadValue);
298 }
Ian Rogers5cf98192014-05-29 21:31:50 -0700299 break;
300 }
301 }
302 if (prev_shadow_frame_ != nullptr) {
303 prev_shadow_frame_->SetLink(new_frame);
304 } else {
305 self_->SetDeoptimizationShadowFrame(new_frame);
306 }
Andreas Gampe2e04bb22015-02-10 15:37:27 -0800307 self_->ClearShadowFrameUnderConstruction();
Ian Rogers5cf98192014-05-29 21:31:50 -0700308 prev_shadow_frame_ = new_frame;
309 return true;
310 }
311
312 Thread* const self_;
313 QuickExceptionHandler* const exception_handler_;
314 ShadowFrame* prev_shadow_frame_;
315
316 DISALLOW_COPY_AND_ASSIGN(DeoptimizeStackVisitor);
317};
318
Sebastien Hertzfd3077e2014-04-23 10:32:43 +0200319void QuickExceptionHandler::DeoptimizeStack() {
320 DCHECK(is_deoptimization_);
Ian Rogers5cf98192014-05-29 21:31:50 -0700321 if (kDebugExceptionDelivery) {
322 self_->DumpStack(LOG(INFO) << "Deoptimizing: ");
323 }
Sebastien Hertzfd3077e2014-04-23 10:32:43 +0200324
325 DeoptimizeStackVisitor visitor(self_, context_, this);
326 visitor.WalkStack(true);
327
328 // Restore deoptimization exception
Nicolas Geoffray14691c52015-03-05 10:40:17 +0000329 self_->SetException(Thread::GetDeoptimizationException());
Sebastien Hertzd45a1f52014-01-09 14:56:54 +0100330}
331
332// Unwinds all instrumentation stack frame prior to catch handler or upcall.
333class InstrumentationStackVisitor : public StackVisitor {
334 public:
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700335 InstrumentationStackVisitor(Thread* self, size_t frame_depth)
Sebastien Hertzd45a1f52014-01-09 14:56:54 +0100336 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_)
337 : StackVisitor(self, nullptr),
Ian Rogerscf7f1912014-10-22 22:06:39 -0700338 frame_depth_(frame_depth),
Sebastien Hertzd45a1f52014-01-09 14:56:54 +0100339 instrumentation_frames_to_pop_(0) {
Hiroshi Yamauchi649278c2014-08-13 11:12:22 -0700340 CHECK_NE(frame_depth_, kInvalidFrameDepth);
Sebastien Hertzd45a1f52014-01-09 14:56:54 +0100341 }
342
343 bool VisitFrame() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
Hiroshi Yamauchi649278c2014-08-13 11:12:22 -0700344 size_t current_frame_depth = GetFrameDepth();
345 if (current_frame_depth < frame_depth_) {
Sebastien Hertzd45a1f52014-01-09 14:56:54 +0100346 CHECK(GetMethod() != nullptr);
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700347 if (UNLIKELY(reinterpret_cast<uintptr_t>(GetQuickInstrumentationExitPc()) == GetReturnPc())) {
Sebastien Hertzd45a1f52014-01-09 14:56:54 +0100348 ++instrumentation_frames_to_pop_;
349 }
350 return true;
351 } else {
352 // We reached the frame of the catch handler or the upcall.
353 return false;
354 }
355 }
356
357 size_t GetInstrumentationFramesToPop() const {
358 return instrumentation_frames_to_pop_;
359 }
360
361 private:
Hiroshi Yamauchi649278c2014-08-13 11:12:22 -0700362 const size_t frame_depth_;
Sebastien Hertzd45a1f52014-01-09 14:56:54 +0100363 size_t instrumentation_frames_to_pop_;
364
365 DISALLOW_COPY_AND_ASSIGN(InstrumentationStackVisitor);
366};
367
Sebastien Hertzfd3077e2014-04-23 10:32:43 +0200368void QuickExceptionHandler::UpdateInstrumentationStack() {
Sebastien Hertzd45a1f52014-01-09 14:56:54 +0100369 if (method_tracing_active_) {
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700370 InstrumentationStackVisitor visitor(self_, handler_frame_depth_);
Sebastien Hertzd45a1f52014-01-09 14:56:54 +0100371 visitor.WalkStack(true);
372
373 size_t instrumentation_frames_to_pop = visitor.GetInstrumentationFramesToPop();
374 instrumentation::Instrumentation* instrumentation = Runtime::Current()->GetInstrumentation();
375 for (size_t i = 0; i < instrumentation_frames_to_pop; ++i) {
376 instrumentation->PopMethodForUnwind(self_, is_deoptimization_);
377 }
378 }
379}
380
Sebastien Hertzfd3077e2014-04-23 10:32:43 +0200381void QuickExceptionHandler::DoLongJump() {
Sebastien Hertzd45a1f52014-01-09 14:56:54 +0100382 // Place context back on thread so it will be available when we continue.
383 self_->ReleaseLongJumpContext(context_);
384 context_->SetSP(reinterpret_cast<uintptr_t>(handler_quick_frame_));
385 CHECK_NE(handler_quick_frame_pc_, 0u);
386 context_->SetPC(handler_quick_frame_pc_);
387 context_->SmashCallerSaves();
388 context_->DoLongJump();
Andreas Gampe794ad762015-02-23 08:12:24 -0800389 UNREACHABLE();
Sebastien Hertzd45a1f52014-01-09 14:56:54 +0100390}
391
392} // namespace art