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 #include "stack_frame_info.h"
18
19 #include "class-alloc-inl.h"
20 #include "class.h"
21 #include "class_root-inl.h"
22 #include "gc/accounting/card_table-inl.h"
23 #include "handle_scope-inl.h"
24 #include "object-inl.h"
25 #include "string.h"
26
27 namespace art HIDDEN {
28 namespace mirror {
29
AssignFields(Handle<Class> declaring_class,Handle<MethodType> method_type,Handle<String> method_name,Handle<String> file_name,int32_t line_number,int32_t dex_pc)30 void StackFrameInfo::AssignFields(Handle<Class> declaring_class,
31 Handle<MethodType> method_type,
32 Handle<String> method_name,
33 Handle<String> file_name,
34 int32_t line_number,
35 int32_t dex_pc) {
36 if (Runtime::Current()->IsActiveTransaction()) {
37 SetFields<true>(declaring_class.Get(), method_type.Get(), method_name.Get(),
38 file_name.Get(), line_number, dex_pc);
39 } else {
40 SetFields<false>(declaring_class.Get(), method_type.Get(), method_name.Get(),
41 file_name.Get(), line_number, dex_pc);
42 }
43 }
44
45 template<bool kTransactionActive>
SetFields(ObjPtr<Class> declaring_class,ObjPtr<MethodType> method_type,ObjPtr<String> method_name,ObjPtr<String> file_name,int32_t line_number,int32_t bci)46 void StackFrameInfo::SetFields(ObjPtr<Class> declaring_class,
47 ObjPtr<MethodType> method_type,
48 ObjPtr<String> method_name,
49 ObjPtr<String> file_name,
50 int32_t line_number,
51 int32_t bci) {
52 SetFieldObject<kTransactionActive>(OFFSET_OF_OBJECT_MEMBER(StackFrameInfo, declaring_class_),
53 declaring_class);
54 SetFieldObject<kTransactionActive>(OFFSET_OF_OBJECT_MEMBER(StackFrameInfo, method_type_),
55 method_type);
56 SetFieldObject<kTransactionActive>(OFFSET_OF_OBJECT_MEMBER(StackFrameInfo, method_name_),
57 method_name);
58 SetFieldObject<kTransactionActive>(OFFSET_OF_OBJECT_MEMBER(StackFrameInfo, file_name_),
59 file_name);
60 SetField32<kTransactionActive>(OFFSET_OF_OBJECT_MEMBER(StackFrameInfo, line_number_),
61 line_number);
62 SetField32<kTransactionActive>(OFFSET_OF_OBJECT_MEMBER(StackFrameInfo, bci_),
63 bci);
64 }
65
66 } // namespace mirror
67 } // namespace art
68