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 17 #ifndef ART_RUNTIME_THROW_LOCATION_H_ 18 #define ART_RUNTIME_THROW_LOCATION_H_ 19 20 #include "object_callbacks.h" 21 #include "base/macros.h" 22 #include "base/mutex.h" 23 24 #include <stdint.h> 25 #include <string> 26 27 namespace art { 28 29 namespace mirror { 30 class ArtMethod; 31 class Object; 32 } // mirror 33 34 class PACKED(4) ThrowLocation { 35 public: ThrowLocation()36 ThrowLocation() { 37 Clear(); 38 } 39 ThrowLocation(mirror::Object * throw_this_object,mirror::ArtMethod * throw_method,uint32_t throw_dex_pc)40 ThrowLocation(mirror::Object* throw_this_object, mirror::ArtMethod* throw_method, 41 uint32_t throw_dex_pc) : 42 this_object_(throw_this_object), 43 method_(throw_method), 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 } 54 GetThis()55 mirror::Object* GetThis() const { 56 return this_object_; 57 } 58 GetMethod()59 mirror::ArtMethod* GetMethod() const { 60 return method_; 61 } 62 GetDexPc()63 uint32_t GetDexPc() const { 64 return dex_pc_; 65 } 66 Clear()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 75 void VisitRoots(RootCallback* visitor, void* arg); 76 77 private: 78 // The 'this' reference of the throwing method. 79 mirror::Object* this_object_; 80 // The throwing method. 81 mirror::ArtMethod* method_; 82 // The instruction within the throwing method. 83 uint32_t dex_pc_; 84 // Ensure 8byte alignment on 64bit. 85 #ifdef __LP64__ 86 uint32_t pad_; 87 #endif 88 }; 89 90 } // namespace art 91 92 #endif // ART_RUNTIME_THROW_LOCATION_H_ 93