blob: c21eee1b326136916f661020364f0c5ac4063ce0 [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;
44 // The maximum precise vreg number
45 static constexpr size_t kMaxVReg = std::numeric_limits<uint16_t>::max();
46
Andreas Gampe36a296f2017-06-13 14:11:11 -070047 JavaFrameRootInfo(uint32_t thread_id, const StackVisitor* stack_visitor, size_t vreg)
48 : RootInfo(kRootJavaFrame, thread_id), stack_visitor_(stack_visitor), vreg_(vreg) {
49 }
Roland Levillainbbc6e7e2018-08-24 16:58:47 +010050 void Describe(std::ostream& os) const override
Andreas Gampe36a296f2017-06-13 14:11:11 -070051 REQUIRES_SHARED(Locks::mutator_lock_);
52
53 size_t GetVReg() const {
54 return vreg_;
55 }
56 const StackVisitor* GetVisitor() const {
57 return stack_visitor_;
58 }
59
60 private:
61 const StackVisitor* const stack_visitor_;
62 const size_t vreg_;
63};
64
65} // namespace art
66
67#endif // ART_RUNTIME_JAVA_FRAME_ROOT_INFO_H_