1 /*
2  * Copyright (C) 2022 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_MIRROR_STACK_FRAME_INFO_H_
18 #define ART_RUNTIME_MIRROR_STACK_FRAME_INFO_H_
19 
20 #include "base/macros.h"
21 #include "method_type.h"
22 #include "object.h"
23 #include "stack_trace_element.h"
24 
25 namespace art HIDDEN {
26 
27 template<class T> class Handle;
28 struct StackFrameInfoOffsets;
29 
30 namespace mirror {
31 
32 // C++ mirror of java.lang.StackFrameInfo
33 class MANAGED StackFrameInfo final : public Object {
34  public:
35   MIRROR_CLASS("Ljava/lang/StackFrameInfo;");
36 
37   void AssignFields(Handle<Class> declaring_class,
38                     Handle<MethodType> method_type,
39                     Handle<String> method_name,
40                     Handle<String> file_name,
41                     int32_t line_number,
42                     int32_t dex_pc)
43       REQUIRES_SHARED(Locks::mutator_lock_);
44 
45  private:
46   // Field order required by test "ValidateFieldOrderOfJavaCppUnionClasses".
47   HeapReference<Class> declaring_class_;
48   HeapReference<String> file_name_;
49   HeapReference<String> method_name_;
50   HeapReference<MethodType> method_type_;
51   HeapReference<StackTraceElement> ste_;
52   int32_t bci_;
53   int32_t line_number_;
54   bool retain_class_ref_;
55 
56   template<bool kTransactionActive>
57   void SetFields(ObjPtr<Class> declaring_class,
58                  ObjPtr<MethodType> method_type,
59                  ObjPtr<String> method_name,
60                  ObjPtr<String> file_name,
61                  int32_t line_number,
62                  int32_t bci)
63       REQUIRES_SHARED(Locks::mutator_lock_);
64 
65   friend struct art::StackFrameInfoOffsets;  // for verifying offset information
66   DISALLOW_IMPLICIT_CONSTRUCTORS(StackFrameInfo);
67 };
68 
69 }  // namespace mirror
70 }  // namespace art
71 
72 #endif  // ART_RUNTIME_MIRROR_STACK_FRAME_INFO_H_
73