• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef PANDA_RUNTIME_INCLUDE_THREAD_INL_H_
17 #define PANDA_RUNTIME_INCLUDE_THREAD_INL_H_
18 
19 #include "runtime/handle_base.h"
20 #include "runtime/global_handle_storage-inl.h"
21 #include "runtime/handle_storage-inl.h"
22 #include "runtime/include/thread.h"
23 
24 namespace panda {
25 
26 template <>
27 inline void ManagedThread::PushHandleScope<coretypes::TaggedType>(HandleScope<coretypes::TaggedType> *handle_scope)
28 {
29     tagged_handle_scopes_.push_back(handle_scope);
30 }
31 
32 template <>
33 inline HandleScope<coretypes::TaggedType> *ManagedThread::PopHandleScope<coretypes::TaggedType>()
34 {
35     HandleScope<coretypes::TaggedType> *scope = tagged_handle_scopes_.back();
36     tagged_handle_scopes_.pop_back();
37     return scope;
38 }
39 
40 template <>
41 inline HandleScope<coretypes::TaggedType> *ManagedThread::GetTopScope<coretypes::TaggedType>() const
42 {
43     if (tagged_handle_scopes_.empty()) {
44         return nullptr;
45     }
46     return tagged_handle_scopes_.back();
47 }
48 
49 template <>
50 inline HandleStorage<coretypes::TaggedType> *ManagedThread::GetHandleStorage<coretypes::TaggedType>() const
51 {
52     return tagged_handle_storage_;
53 }
54 
55 template <>
56 inline GlobalHandleStorage<coretypes::TaggedType> *ManagedThread::GetGlobalHandleStorage<coretypes::TaggedType>() const
57 {
58     return tagged_global_handle_storage_;
59 }
60 
61 template <>
62 inline void ManagedThread::PushHandleScope<ObjectHeader *>(HandleScope<ObjectHeader *> *handle_scope)
63 {
64     object_header_handle_scopes_.push_back(handle_scope);
65 }
66 
67 template <>
68 inline HandleScope<ObjectHeader *> *ManagedThread::PopHandleScope<ObjectHeader *>()
69 {
70     HandleScope<ObjectHeader *> *scope = object_header_handle_scopes_.back();
71     object_header_handle_scopes_.pop_back();
72     return scope;
73 }
74 
75 template <>
76 inline HandleScope<ObjectHeader *> *ManagedThread::GetTopScope<ObjectHeader *>() const
77 {
78     if (object_header_handle_scopes_.empty()) {
79         return nullptr;
80     }
81     return object_header_handle_scopes_.back();
82 }
83 
84 template <>
85 inline HandleStorage<ObjectHeader *> *ManagedThread::GetHandleStorage<ObjectHeader *>() const
86 {
87     return object_header_handle_storage_;
88 }
89 
90 }  // namespace panda
91 
92 #endif  // PANDA_RUNTIME_INCLUDE_THREAD_INL_H_
93