• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright (c) 2021-2022 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 #ifndef PANDA_RUNTIME_MEM_GC_GC_DYNAMIC_DATA_H
16 #define PANDA_RUNTIME_MEM_GC_GC_DYNAMIC_DATA_H
17 
18 #include "runtime/include/mem/panda_containers.h"
19 #include "runtime/include/coretypes/tagged_value.h"
20 #include "runtime/mem/gc/gc_extension_data.h"
21 
22 namespace panda::mem {
23 class GCDynamicData : public GCExtensionData {
24 public:
GCDynamicData(InternalAllocatorPtr a)25     explicit GCDynamicData(InternalAllocatorPtr a) : allocator(a)
26     {
27         dyn_weak_references_ = a->New<PandaStack<coretypes::TaggedType *>>(a->Adapter());
28 
29 #ifndef NDEBUG
30         SetLangType(LANG_TYPE_DYNAMIC);
31 #endif  // NDEBUG
32     }
33 
~GCDynamicData()34     ~GCDynamicData() override
35     {
36         allocator->Delete(dyn_weak_references_);
37     }
38 
GetDynWeakReferences()39     PandaStack<coretypes::TaggedType *> *GetDynWeakReferences()
40     {
41         return dyn_weak_references_;
42     }
43 
44 private:
45     PandaStack<coretypes::TaggedType *> *dyn_weak_references_;
46     InternalAllocatorPtr allocator;
47 
48     NO_COPY_SEMANTIC(GCDynamicData);
49     NO_MOVE_SEMANTIC(GCDynamicData);
50 };
51 
52 }  // namespace panda::mem
53 
54 #endif  // PANDA_RUNTIME_MEM_GC_GC_DYNAMIC_DATA_H
55