Andreas Gampe | 36a296f | 2017-06-13 14:11:11 -0700 | [diff] [blame] | 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> |
Alex Light | 0054aa5 | 2019-09-10 16:46:48 -0700 | [diff] [blame] | 21 | #include <limits> |
Andreas Gampe | 36a296f | 2017-06-13 14:11:11 -0700 | [diff] [blame] | 22 | |
Andreas Gampe | 7fbc4a5 | 2018-11-28 08:26:47 -0800 | [diff] [blame] | 23 | #include "base/locks.h" |
Andreas Gampe | 36a296f | 2017-06-13 14:11:11 -0700 | [diff] [blame] | 24 | #include "base/macros.h" |
Andreas Gampe | 36a296f | 2017-06-13 14:11:11 -0700 | [diff] [blame] | 25 | #include "gc_root.h" |
| 26 | |
| 27 | namespace art { |
| 28 | |
| 29 | class StackVisitor; |
| 30 | |
Roland Levillain | bbc6e7e | 2018-08-24 16:58:47 +0100 | [diff] [blame] | 31 | class JavaFrameRootInfo final : public RootInfo { |
Andreas Gampe | 36a296f | 2017-06-13 14:11:11 -0700 | [diff] [blame] | 32 | public: |
Alex Light | 0054aa5 | 2019-09-10 16:46:48 -0700 | [diff] [blame] | 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 maximum precise vreg number |
| 45 | static constexpr size_t kMaxVReg = std::numeric_limits<uint16_t>::max(); |
| 46 | |
Andreas Gampe | 36a296f | 2017-06-13 14:11:11 -0700 | [diff] [blame] | 47 | 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 Levillain | bbc6e7e | 2018-08-24 16:58:47 +0100 | [diff] [blame] | 50 | void Describe(std::ostream& os) const override |
Andreas Gampe | 36a296f | 2017-06-13 14:11:11 -0700 | [diff] [blame] | 51 | 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_ |