blob: b36eb67f9c4696fa7e886c5e28520d034e946108 [file] [log] [blame]
Ian Rogers62d6c772013-02-27 08:32:07 -08001/*
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 Carlstromfc0e3212013-07-17 14:40:12 -070017#ifndef ART_RUNTIME_THROW_LOCATION_H_
18#define ART_RUNTIME_THROW_LOCATION_H_
Ian Rogers62d6c772013-02-27 08:32:07 -080019
Mathieu Chartier83c8ee02014-01-28 14:50:23 -080020#include "object_callbacks.h"
Ian Rogers62d6c772013-02-27 08:32:07 -080021#include "base/macros.h"
Ian Rogers719d1a32014-03-06 12:13:39 -080022#include "base/mutex.h"
Ian Rogers62d6c772013-02-27 08:32:07 -080023
24#include <stdint.h>
25#include <string>
26
27namespace art {
28
29namespace mirror {
Brian Carlstromea46f952013-07-30 01:26:50 -070030class ArtMethod;
Ian Rogers62d6c772013-02-27 08:32:07 -080031class Object;
32} // mirror
33
34class PACKED(4) ThrowLocation {
35 public:
36 ThrowLocation() {
37 Clear();
38 }
39
Brian Carlstromea46f952013-07-30 01:26:50 -070040 ThrowLocation(mirror::Object* throw_this_object, mirror::ArtMethod* throw_method,
Ian Rogers62d6c772013-02-27 08:32:07 -080041 uint32_t throw_dex_pc) :
42 this_object_(throw_this_object),
43 method_(throw_method),
Ian Rogersdd7624d2014-03-14 17:43:00 -070044 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 Rogers62d6c772013-02-27 08:32:07 -080054
55 mirror::Object* GetThis() const {
56 return this_object_;
57 }
58
Brian Carlstromea46f952013-07-30 01:26:50 -070059 mirror::ArtMethod* GetMethod() const {
Ian Rogers62d6c772013-02-27 08:32:07 -080060 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 Chartier83c8ee02014-01-28 14:50:23 -080075 void VisitRoots(RootCallback* visitor, void* arg);
Ian Rogers62d6c772013-02-27 08:32:07 -080076
77 private:
78 // The 'this' reference of the throwing method.
79 mirror::Object* this_object_;
80 // The throwing method.
Brian Carlstromea46f952013-07-30 01:26:50 -070081 mirror::ArtMethod* method_;
Ian Rogers62d6c772013-02-27 08:32:07 -080082 // The instruction within the throwing method.
83 uint32_t dex_pc_;
Ian Rogersdd7624d2014-03-14 17:43:00 -070084 // Ensure 8byte alignment on 64bit.
85#ifdef __LP64__
86 uint32_t pad_;
87#endif
Ian Rogers62d6c772013-02-27 08:32:07 -080088};
89
90} // namespace art
91
Brian Carlstromfc0e3212013-07-17 14:40:12 -070092#endif // ART_RUNTIME_THROW_LOCATION_H_