• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 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 PLUGINS_ETS_RUNTIME_HYBRID_MEM_STATIC_OBJECT_OPERATOR_H
17 #define PLUGINS_ETS_RUNTIME_HYBRID_MEM_STATIC_OBJECT_OPERATOR_H
18 
19 #if defined(ARK_HYBRID)
20 #include "objects/base_object.h"
21 #include "objects/base_object_operator.h"
22 #include "runtime/include/object_header.h"
23 
24 namespace ark::mem {
25 
26 class StaticObjectOperator : public panda::BaseObjectOperatorInterfaces {
27 public:
28     static void Initialize();
29 
IsValidObject(const panda::BaseObject * object)30     bool IsValidObject([[maybe_unused]] const panda::BaseObject *object) const override
31     {
32         return true;
33     }
34 
35     void ForEachRefField(const panda::BaseObject *object, const panda::RefFieldVisitor &visitor) const override;
36 
GetSize(const panda::BaseObject * object)37     size_t GetSize(const panda::BaseObject *object) const override
38     {
39         // ObjectHeader must be binary compatible with BaseObject
40         auto *hdr = reinterpret_cast<const ObjectHeader *>(object);
41         return hdr->ObjectSize();
42     }
43 
44     panda::BaseObject *GetForwardingPointer(const panda::BaseObject *object) const override;
45 
46     void SetForwardingPointerAfterExclusive(panda::BaseObject *object, panda::BaseObject *fwdPtr) override;
47 
48 private:
49     static StaticObjectOperator instance_;
50 };
51 
52 }  // namespace ark::mem
53 
54 #else
55 
56 namespace ark::mem {
57 class StaticObjectOperator {
58 public:
Initialize()59     static void Initialize() {}
60 };
61 }  // namespace ark::mem
62 
63 #endif  // ARK_HYBRID
64 #endif  // PLUGINS_ETS_RUNTIME_HYBRID_MEM_STATIC_OBJECT_OPERATOR_H
65