blob: c171b0783afa35fad0375c4de4faa339dde72764 [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),
44 dex_pc_(throw_dex_pc) {}
45
46 mirror::Object* GetThis() const {
47 return this_object_;
48 }
49
Brian Carlstromea46f952013-07-30 01:26:50 -070050 mirror::ArtMethod* GetMethod() const {
Ian Rogers62d6c772013-02-27 08:32:07 -080051 return method_;
52 }
53
54 uint32_t GetDexPc() const {
55 return dex_pc_;
56 }
57
58 void Clear() {
59 this_object_ = NULL;
60 method_ = NULL;
61 dex_pc_ = -1;
62 }
63
64 std::string Dump() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
65
Mathieu Chartier83c8ee02014-01-28 14:50:23 -080066 void VisitRoots(RootCallback* visitor, void* arg);
Ian Rogers62d6c772013-02-27 08:32:07 -080067
68 private:
69 // The 'this' reference of the throwing method.
70 mirror::Object* this_object_;
71 // The throwing method.
Brian Carlstromea46f952013-07-30 01:26:50 -070072 mirror::ArtMethod* method_;
Ian Rogers62d6c772013-02-27 08:32:07 -080073 // The instruction within the throwing method.
74 uint32_t dex_pc_;
75};
76
77} // namespace art
78
Brian Carlstromfc0e3212013-07-17 14:40:12 -070079#endif // ART_RUNTIME_THROW_LOCATION_H_