blob: bec0da490a73e29303da27f1b7b4af8a4d43e23c [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"
Mathieu Chartiere34fa1d2015-01-14 14:55:47 -080023#include "gc_root.h"
Ian Rogers62d6c772013-02-27 08:32:07 -080024
25#include <stdint.h>
26#include <string>
27
28namespace art {
29
30namespace mirror {
Brian Carlstromea46f952013-07-30 01:26:50 -070031class ArtMethod;
Ian Rogers62d6c772013-02-27 08:32:07 -080032class Object;
33} // mirror
34
35class PACKED(4) ThrowLocation {
36 public:
37 ThrowLocation() {
38 Clear();
39 }
40
Brian Carlstromea46f952013-07-30 01:26:50 -070041 ThrowLocation(mirror::Object* throw_this_object, mirror::ArtMethod* throw_method,
Ian Rogers62d6c772013-02-27 08:32:07 -080042 uint32_t throw_dex_pc) :
43 this_object_(throw_this_object),
44 method_(throw_method),
Ian Rogersdd7624d2014-03-14 17:43:00 -070045 dex_pc_(throw_dex_pc)
46#ifdef __LP64__
47 , pad_(0)
48#endif
49
50 {
51#ifdef __LP64__
52 UNUSED(pad_);
53#endif
54 }
Ian Rogers62d6c772013-02-27 08:32:07 -080055
56 mirror::Object* GetThis() const {
57 return this_object_;
58 }
59
Brian Carlstromea46f952013-07-30 01:26:50 -070060 mirror::ArtMethod* GetMethod() const {
Ian Rogers62d6c772013-02-27 08:32:07 -080061 return method_;
62 }
63
64 uint32_t GetDexPc() const {
65 return dex_pc_;
66 }
67
68 void Clear() {
69 this_object_ = NULL;
70 method_ = NULL;
71 dex_pc_ = -1;
72 }
73
74 std::string Dump() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
75
Mathieu Chartier83c8ee02014-01-28 14:50:23 -080076 void VisitRoots(RootCallback* visitor, void* arg);
Ian Rogers62d6c772013-02-27 08:32:07 -080077
78 private:
79 // The 'this' reference of the throwing method.
80 mirror::Object* this_object_;
81 // The throwing method.
Brian Carlstromea46f952013-07-30 01:26:50 -070082 mirror::ArtMethod* method_;
Ian Rogers62d6c772013-02-27 08:32:07 -080083 // The instruction within the throwing method.
84 uint32_t dex_pc_;
Ian Rogersdd7624d2014-03-14 17:43:00 -070085 // Ensure 8byte alignment on 64bit.
86#ifdef __LP64__
87 uint32_t pad_;
88#endif
Ian Rogers62d6c772013-02-27 08:32:07 -080089};
90
91} // namespace art
92
Brian Carlstromfc0e3212013-07-17 14:40:12 -070093#endif // ART_RUNTIME_THROW_LOCATION_H_