blob: 175ad7dd945af6ed86772cf0cb134153ca4eb462 [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
17#ifndef ART_RUNTIME_CATCH_BLOCK_STACK_VISITOR_H_
18#define ART_RUNTIME_CATCH_BLOCK_STACK_VISITOR_H_
19
20#include "mirror/throwable.h"
21#include "thread.h"
22
23namespace art {
24class CatchFinder;
25class ThrowLocation;
26
27// Finds catch handler or prepares deoptimization.
28class CatchBlockStackVisitor : public StackVisitor {
29 public:
30 CatchBlockStackVisitor(Thread* self, Context* context, mirror::Throwable* exception,
31 bool is_deoptimization, CatchFinder* catch_finder)
32 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_)
33 : StackVisitor(self, context),
34 self_(self), is_deoptimization_(is_deoptimization),
35 to_find_(is_deoptimization ? nullptr : exception->GetClass()),
36 catch_finder_(catch_finder), native_method_count_(0), prev_shadow_frame_(nullptr) {
37 }
38
39 bool VisitFrame() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
40
41 private:
42 bool HandleTryItems(mirror::ArtMethod* method) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
43 bool HandleDeoptimization(mirror::ArtMethod* m) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
44
45 Thread* const self_;
46 const bool is_deoptimization_;
47 // The type of the exception catch block to find.
48 mirror::Class* const to_find_;
49 CatchFinder* const catch_finder_;
50 // Number of native methods passed in crawl (equates to number of SIRTs to pop)
51 uint32_t native_method_count_;
52 ShadowFrame* prev_shadow_frame_;
53
54 DISALLOW_COPY_AND_ASSIGN(CatchBlockStackVisitor);
55};
56
57} // namespace art
58#endif // ART_RUNTIME_CATCH_BLOCK_STACK_VISITOR_H_