blob: f45cf037cf6edfa540b86abde6f6cb7c078609e0 [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
Sebastien Hertzfd3077e2014-04-23 10:32:43 +020020#include "mirror/object-inl.h"
21#include "stack.h"
Mathieu Chartiereb8167a2014-05-07 15:43:14 -070022#include "handle_scope-inl.h"
Sebastien Hertzd45a1f52014-01-09 14:56:54 +010023
24namespace art {
Sebastien Hertzfd3077e2014-04-23 10:32:43 +020025
26namespace mirror {
27class Throwable;
28} // namespace mirror
29class Context;
30class QuickExceptionHandler;
31class Thread;
Sebastien Hertzd45a1f52014-01-09 14:56:54 +010032class ThrowLocation;
33
34// Finds catch handler or prepares deoptimization.
Sebastien Hertzfd3077e2014-04-23 10:32:43 +020035class CatchBlockStackVisitor FINAL : public StackVisitor {
Sebastien Hertzd45a1f52014-01-09 14:56:54 +010036 public:
Mathieu Chartiereb8167a2014-05-07 15:43:14 -070037 CatchBlockStackVisitor(Thread* self, Context* context, Handle<mirror::Throwable>* exception,
Sebastien Hertzfd3077e2014-04-23 10:32:43 +020038 QuickExceptionHandler* exception_handler)
Sebastien Hertzd45a1f52014-01-09 14:56:54 +010039 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_)
Mathieu Chartiereb8167a2014-05-07 15:43:14 -070040 : StackVisitor(self, context), self_(self), exception_(exception),
Sebastien Hertzfd3077e2014-04-23 10:32:43 +020041 exception_handler_(exception_handler) {
Sebastien Hertzd45a1f52014-01-09 14:56:54 +010042 }
43
Sebastien Hertzfd3077e2014-04-23 10:32:43 +020044 bool VisitFrame() OVERRIDE SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Sebastien Hertzd45a1f52014-01-09 14:56:54 +010045
46 private:
47 bool HandleTryItems(mirror::ArtMethod* method) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Sebastien Hertzd45a1f52014-01-09 14:56:54 +010048
49 Thread* const self_;
Sebastien Hertzd45a1f52014-01-09 14:56:54 +010050 // The type of the exception catch block to find.
Mathieu Chartiereb8167a2014-05-07 15:43:14 -070051 Handle<mirror::Throwable>* exception_;
Sebastien Hertzfd3077e2014-04-23 10:32:43 +020052 QuickExceptionHandler* const exception_handler_;
Sebastien Hertzd45a1f52014-01-09 14:56:54 +010053
54 DISALLOW_COPY_AND_ASSIGN(CatchBlockStackVisitor);
55};
56
57} // namespace art
58#endif // ART_RUNTIME_CATCH_BLOCK_STACK_VISITOR_H_