• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
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>
21 #include <limits>
22 
23 #include "base/locks.h"
24 #include "base/macros.h"
25 #include "gc_root.h"
26 
27 namespace art {
28 
29 class StackVisitor;
30 
31 class JavaFrameRootInfo final : public RootInfo {
32  public:
33   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 root is from the argument to a native invoke.
45   static constexpr size_t kNativeReferenceArgument = -5;
46   // The maximum precise vreg number
47   static constexpr size_t kMaxVReg = std::numeric_limits<uint16_t>::max();
48 
JavaFrameRootInfo(uint32_t thread_id,const StackVisitor * stack_visitor,size_t vreg)49   JavaFrameRootInfo(uint32_t thread_id, const StackVisitor* stack_visitor, size_t vreg)
50      : RootInfo(kRootJavaFrame, thread_id), stack_visitor_(stack_visitor), vreg_(vreg) {
51   }
52   void Describe(std::ostream& os) const override
53       REQUIRES_SHARED(Locks::mutator_lock_);
54 
GetVReg()55   size_t GetVReg() const {
56     return vreg_;
57   }
GetVisitor()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_
70