Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2013 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 | |
Brian Carlstrom | fc0e321 | 2013-07-17 14:40:12 -0700 | [diff] [blame] | 17 | #ifndef ART_RUNTIME_THROW_LOCATION_H_ |
| 18 | #define ART_RUNTIME_THROW_LOCATION_H_ |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 19 | |
Mathieu Chartier | 83c8ee0 | 2014-01-28 14:50:23 -0800 | [diff] [blame] | 20 | #include "object_callbacks.h" |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 21 | #include "base/macros.h" |
Ian Rogers | 719d1a3 | 2014-03-06 12:13:39 -0800 | [diff] [blame] | 22 | #include "base/mutex.h" |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 23 | |
| 24 | #include <stdint.h> |
| 25 | #include <string> |
| 26 | |
| 27 | namespace art { |
| 28 | |
| 29 | namespace mirror { |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 30 | class ArtMethod; |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 31 | class Object; |
| 32 | } // mirror |
| 33 | |
| 34 | class PACKED(4) ThrowLocation { |
| 35 | public: |
| 36 | ThrowLocation() { |
| 37 | Clear(); |
| 38 | } |
| 39 | |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 40 | ThrowLocation(mirror::Object* throw_this_object, mirror::ArtMethod* throw_method, |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 41 | uint32_t throw_dex_pc) : |
| 42 | this_object_(throw_this_object), |
| 43 | method_(throw_method), |
Ian Rogers | dd7624d | 2014-03-14 17:43:00 -0700 | [diff] [blame] | 44 | dex_pc_(throw_dex_pc) |
| 45 | #ifdef __LP64__ |
| 46 | , pad_(0) |
| 47 | #endif |
| 48 | |
| 49 | { |
| 50 | #ifdef __LP64__ |
| 51 | UNUSED(pad_); |
| 52 | #endif |
| 53 | } |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 54 | |
| 55 | mirror::Object* GetThis() const { |
| 56 | return this_object_; |
| 57 | } |
| 58 | |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 59 | mirror::ArtMethod* GetMethod() const { |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 60 | return method_; |
| 61 | } |
| 62 | |
| 63 | uint32_t GetDexPc() const { |
| 64 | return dex_pc_; |
| 65 | } |
| 66 | |
| 67 | void Clear() { |
| 68 | this_object_ = NULL; |
| 69 | method_ = NULL; |
| 70 | dex_pc_ = -1; |
| 71 | } |
| 72 | |
| 73 | std::string Dump() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 74 | |
Mathieu Chartier | 83c8ee0 | 2014-01-28 14:50:23 -0800 | [diff] [blame] | 75 | void VisitRoots(RootCallback* visitor, void* arg); |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 76 | |
| 77 | private: |
| 78 | // The 'this' reference of the throwing method. |
| 79 | mirror::Object* this_object_; |
| 80 | // The throwing method. |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 81 | mirror::ArtMethod* method_; |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 82 | // The instruction within the throwing method. |
| 83 | uint32_t dex_pc_; |
Ian Rogers | dd7624d | 2014-03-14 17:43:00 -0700 | [diff] [blame] | 84 | // Ensure 8byte alignment on 64bit. |
| 85 | #ifdef __LP64__ |
| 86 | uint32_t pad_; |
| 87 | #endif |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 88 | }; |
| 89 | |
| 90 | } // namespace art |
| 91 | |
Brian Carlstrom | fc0e321 | 2013-07-17 14:40:12 -0700 | [diff] [blame] | 92 | #endif // ART_RUNTIME_THROW_LOCATION_H_ |