blob: 5da446e9c5211c6d9b65a67d62adace7541236d9 [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
20#include "base/macros.h"
21#include "root_visitor.h"
22
23#include <stdint.h>
24#include <string>
25
26namespace art {
27
28namespace mirror {
Brian Carlstromea46f952013-07-30 01:26:50 -070029class ArtMethod;
Ian Rogers62d6c772013-02-27 08:32:07 -080030class Object;
31} // mirror
32
33class PACKED(4) ThrowLocation {
34 public:
35 ThrowLocation() {
36 Clear();
37 }
38
Brian Carlstromea46f952013-07-30 01:26:50 -070039 ThrowLocation(mirror::Object* throw_this_object, mirror::ArtMethod* throw_method,
Ian Rogers62d6c772013-02-27 08:32:07 -080040 uint32_t throw_dex_pc) :
41 this_object_(throw_this_object),
42 method_(throw_method),
43 dex_pc_(throw_dex_pc) {}
44
45 mirror::Object* GetThis() const {
46 return this_object_;
47 }
48
Brian Carlstromea46f952013-07-30 01:26:50 -070049 mirror::ArtMethod* GetMethod() const {
Ian Rogers62d6c772013-02-27 08:32:07 -080050 return method_;
51 }
52
53 uint32_t GetDexPc() const {
54 return dex_pc_;
55 }
56
57 void Clear() {
58 this_object_ = NULL;
59 method_ = NULL;
60 dex_pc_ = -1;
61 }
62
63 std::string Dump() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
64
65 void VisitRoots(RootVisitor* visitor, void* arg);
66
67 private:
68 // The 'this' reference of the throwing method.
69 mirror::Object* this_object_;
70 // The throwing method.
Brian Carlstromea46f952013-07-30 01:26:50 -070071 mirror::ArtMethod* method_;
Ian Rogers62d6c772013-02-27 08:32:07 -080072 // The instruction within the throwing method.
73 uint32_t dex_pc_;
74};
75
76} // namespace art
77
Brian Carlstromfc0e3212013-07-17 14:40:12 -070078#endif // ART_RUNTIME_THROW_LOCATION_H_