Sebastien Hertz | d45a1f5 | 2014-01-09 14:56:54 +0100 | [diff] [blame] | 1 | /* |
| 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 Hertz | fd3077e | 2014-04-23 10:32:43 +0200 | [diff] [blame] | 17 | #ifndef ART_RUNTIME_QUICK_EXCEPTION_HANDLER_H_ |
| 18 | #define ART_RUNTIME_QUICK_EXCEPTION_HANDLER_H_ |
Sebastien Hertz | d45a1f5 | 2014-01-09 14:56:54 +0100 | [diff] [blame] | 19 | |
Sebastien Hertz | fd3077e | 2014-04-23 10:32:43 +0200 | [diff] [blame] | 20 | #include "base/logging.h" |
| 21 | #include "base/mutex.h" |
Sebastien Hertz | d45a1f5 | 2014-01-09 14:56:54 +0100 | [diff] [blame] | 22 | |
| 23 | namespace art { |
| 24 | |
Sebastien Hertz | fd3077e | 2014-04-23 10:32:43 +0200 | [diff] [blame] | 25 | namespace mirror { |
| 26 | class ArtMethod; |
| 27 | class Throwable; |
| 28 | } // namespace mirror |
| 29 | class Context; |
| 30 | class Thread; |
| 31 | class ThrowLocation; |
| 32 | class ShadowFrame; |
| 33 | |
Sebastien Hertz | d45a1f5 | 2014-01-09 14:56:54 +0100 | [diff] [blame] | 34 | static constexpr bool kDebugExceptionDelivery = false; |
| 35 | static constexpr size_t kInvalidFrameId = 0xffffffff; |
| 36 | |
| 37 | // Manages exception delivery for Quick backend. Not used by Portable backend. |
Sebastien Hertz | fd3077e | 2014-04-23 10:32:43 +0200 | [diff] [blame] | 38 | class QuickExceptionHandler { |
Sebastien Hertz | d45a1f5 | 2014-01-09 14:56:54 +0100 | [diff] [blame] | 39 | public: |
Sebastien Hertz | fd3077e | 2014-04-23 10:32:43 +0200 | [diff] [blame] | 40 | QuickExceptionHandler(Thread* self, bool is_deoptimization) |
Sebastien Hertz | d45a1f5 | 2014-01-09 14:56:54 +0100 | [diff] [blame] | 41 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 42 | |
Sebastien Hertz | fd3077e | 2014-04-23 10:32:43 +0200 | [diff] [blame] | 43 | ~QuickExceptionHandler() { |
Sebastien Hertz | d45a1f5 | 2014-01-09 14:56:54 +0100 | [diff] [blame] | 44 | LOG(FATAL) << "UNREACHABLE"; // Expected to take long jump. |
| 45 | } |
| 46 | |
Sebastien Hertz | fd3077e | 2014-04-23 10:32:43 +0200 | [diff] [blame] | 47 | void FindCatch(const ThrowLocation& throw_location, mirror::Throwable* exception) |
| 48 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 49 | void DeoptimizeStack() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Sebastien Hertz | d45a1f5 | 2014-01-09 14:56:54 +0100 | [diff] [blame] | 50 | void UpdateInstrumentationStack() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 51 | void DoLongJump() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 52 | |
| 53 | void SetHandlerQuickFrame(mirror::ArtMethod** handler_quick_frame) { |
| 54 | handler_quick_frame_ = handler_quick_frame; |
| 55 | } |
| 56 | |
| 57 | void SetHandlerQuickFramePc(uintptr_t handler_quick_frame_pc) { |
| 58 | handler_quick_frame_pc_ = handler_quick_frame_pc; |
| 59 | } |
| 60 | |
| 61 | void SetHandlerDexPc(uint32_t dex_pc) { |
| 62 | handler_dex_pc_ = dex_pc; |
| 63 | } |
| 64 | |
| 65 | void SetClearException(bool clear_exception) { |
| 66 | clear_exception_ = clear_exception; |
| 67 | } |
| 68 | |
Sebastien Hertz | d45a1f5 | 2014-01-09 14:56:54 +0100 | [diff] [blame] | 69 | void SetHandlerFrameId(size_t frame_id) { |
| 70 | handler_frame_id_ = frame_id; |
| 71 | } |
| 72 | |
| 73 | private: |
| 74 | Thread* const self_; |
| 75 | Context* const context_; |
Sebastien Hertz | d45a1f5 | 2014-01-09 14:56:54 +0100 | [diff] [blame] | 76 | const bool is_deoptimization_; |
Sebastien Hertz | d45a1f5 | 2014-01-09 14:56:54 +0100 | [diff] [blame] | 77 | // Is method tracing active? |
| 78 | const bool method_tracing_active_; |
Sebastien Hertz | d45a1f5 | 2014-01-09 14:56:54 +0100 | [diff] [blame] | 79 | // Quick frame with found handler or last frame if no handler found. |
| 80 | mirror::ArtMethod** handler_quick_frame_; |
| 81 | // PC to branch to for the handler. |
| 82 | uintptr_t handler_quick_frame_pc_; |
| 83 | // Associated dex PC. |
| 84 | uint32_t handler_dex_pc_; |
| 85 | // Should the exception be cleared as the catch block has no move-exception? |
| 86 | bool clear_exception_; |
Sebastien Hertz | d45a1f5 | 2014-01-09 14:56:54 +0100 | [diff] [blame] | 87 | // Frame id of the catch handler or the upcall. |
| 88 | size_t handler_frame_id_; |
| 89 | |
Sebastien Hertz | fd3077e | 2014-04-23 10:32:43 +0200 | [diff] [blame] | 90 | DISALLOW_COPY_AND_ASSIGN(QuickExceptionHandler); |
Sebastien Hertz | d45a1f5 | 2014-01-09 14:56:54 +0100 | [diff] [blame] | 91 | }; |
| 92 | |
| 93 | } // namespace art |
Sebastien Hertz | fd3077e | 2014-04-23 10:32:43 +0200 | [diff] [blame] | 94 | #endif // ART_RUNTIME_QUICK_EXCEPTION_HANDLER_H_ |