blob: ae413d21e57e905ea1d1abaace72f0990c77c2d2 [file] [log] [blame]
Elliott Hughes68e76522011-10-05 13:22:16 -07001/*
2 * Copyright (C) 2011 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_SRC_STACK_H_
18#define ART_SRC_STACK_H_
19
20#include "macros.h"
21
22#include <stdint.h>
23
24namespace art {
25
26class Method;
27class Thread;
28
29struct NativeToManagedRecord {
30 NativeToManagedRecord* link_;
31 void* last_top_of_managed_stack_;
32 uintptr_t last_top_of_managed_stack_pc_;
33};
34
35// Iterator over managed frames up to the first native-to-managed transition.
36class PACKED Frame {
37 public:
38 Frame() : sp_(NULL) {}
39
40 Method* GetMethod() const {
41 return (sp_ != NULL) ? *sp_ : NULL;
42 }
43
44 bool HasNext() const {
45 return NextMethod() != NULL;
46 }
47
48 void Next();
49
50 uintptr_t GetReturnPC() const;
51
52 uintptr_t LoadCalleeSave(int num) const;
53
54 uintptr_t GetVReg(Method* method, int vreg) const;
55
56 Method** GetSP() const {
57 return sp_;
58 }
59
60 // TODO: this is here for testing, remove when we have exception unit tests
61 // that use the real stack
62 void SetSP(Method** sp) {
63 sp_ = sp;
64 }
65
66 // Is this a frame for a real method (native or with dex code)
67 bool HasMethod() const;
68
69 private:
70 Method* NextMethod() const;
71
72 friend class Thread;
73
74 Method** sp_;
75};
76
77} // namespace art
78
79#endif // ART_SRC_STACK_H_