blob: 533d92493c66bd036c4c88e134e7b34d48fb8864 [file] [log] [blame]
Logan Chienf7ad17e2012-03-15 03:10:03 +08001/*
2 * Copyright (C) 2012 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_SHADOW_FRAME_H_
18#define ART_SRC_SHADOW_FRAME_H_
19
20#include "logging.h"
21#include "macros.h"
22
23namespace art {
24
25class Object;
26
27class ShadowFrame {
28 public:
29 // Number of references contained within this shadow frame
30 uint32_t NumberOfReferences() const {
31 return number_of_references_;
32 }
33
34 // Link to previous shadow frame or NULL
35 ShadowFrame* GetLink() const {
36 return link_;
37 }
38
39 void SetLink(ShadowFrame* frame) {
40 DCHECK_NE(this, frame);
41 link_ = frame;
42 }
43
44 Object* GetReference(size_t i) const {
45 DCHECK_LT(i, number_of_references_);
46 return references_[i];
47 }
48
49 void SetReference(size_t i, Object* object) {
50 DCHECK_LT(i, number_of_references_);
51 references_[i] = object;
52 }
53
54 private:
55 // ShadowFrame should be allocated by the generated code directly.
56 // We should not create new shadow stack in the runtime support function.
57 ~ShadowFrame() {}
58
59 uint32_t number_of_references_;
60 ShadowFrame* link_;
61 Object* method_;
62 uint32_t line_num_;
63 Object* references_[];
64
65 DISALLOW_IMPLICIT_CONSTRUCTORS(ShadowFrame);
66};
67
68} // namespace art
69
70#endif // ART_SRC_SHADOW_FRAME_H_