blob: c2b44938141832b34040e3d7641bee89b00b8d67 [file] [log] [blame]
Andreas Gampe36a296f2017-06-13 14:11:11 -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_RUNTIME_JAVA_FRAME_ROOT_INFO_H_
18#define ART_RUNTIME_JAVA_FRAME_ROOT_INFO_H_
19
20#include <iosfwd>
Alex Light0054aa52019-09-10 16:46:48 -070021#include <limits>
Andreas Gampe36a296f2017-06-13 14:11:11 -070022
Andreas Gampe7fbc4a52018-11-28 08:26:47 -080023#include "base/locks.h"
Andreas Gampe36a296f2017-06-13 14:11:11 -070024#include "base/macros.h"
Andreas Gampe36a296f2017-06-13 14:11:11 -070025#include "gc_root.h"
26
27namespace art {
28
29class StackVisitor;
30
Roland Levillainbbc6e7e2018-08-24 16:58:47 +010031class JavaFrameRootInfo final : public RootInfo {
Andreas Gampe36a296f2017-06-13 14:11:11 -070032 public:
Alex Light0054aa52019-09-10 16:46:48 -070033 static_assert(std::numeric_limits<size_t>::max() > std::numeric_limits<uint16_t>::max(),
34 "No extra space in vreg to store meta-data");
35 // Unable to determine what register number the root is from.
36 static constexpr size_t kUnknownVreg = -1;
37 // The register number for the root might be determinable but we did not attempt to find that
38 // information.
39 static constexpr size_t kImpreciseVreg = -2;
40 // The root is from the declaring class of the current method.
41 static constexpr size_t kMethodDeclaringClass = -3;
42 // The root is from the argument to a Proxy invoke.
43 static constexpr size_t kProxyReferenceArgument = -4;
Vladimir Markocedec9d2021-02-08 16:16:13 +000044 // The root is from the argument to a native invoke.
45 static constexpr size_t kNativeReferenceArgument = -5;
Alex Light0054aa52019-09-10 16:46:48 -070046 // The maximum precise vreg number
47 static constexpr size_t kMaxVReg = std::numeric_limits<uint16_t>::max();
48
Andreas Gampe36a296f2017-06-13 14:11:11 -070049 JavaFrameRootInfo(uint32_t thread_id, const StackVisitor* stack_visitor, size_t vreg)
50 : RootInfo(kRootJavaFrame, thread_id), stack_visitor_(stack_visitor), vreg_(vreg) {
51 }
Roland Levillainbbc6e7e2018-08-24 16:58:47 +010052 void Describe(std::ostream& os) const override
Andreas Gampe36a296f2017-06-13 14:11:11 -070053 REQUIRES_SHARED(Locks::mutator_lock_);
54
55 size_t GetVReg() const {
56 return vreg_;
57 }
58 const StackVisitor* GetVisitor() const {
59 return stack_visitor_;
60 }
61
62 private:
63 const StackVisitor* const stack_visitor_;
64 const size_t vreg_;
65};
66
67} // namespace art
68
69#endif // ART_RUNTIME_JAVA_FRAME_ROOT_INFO_H_