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 COMMON_INTERFACES_OBJECTS_BASE_OBJECT_OPERATOR_H 17 #define COMMON_INTERFACES_OBJECTS_BASE_OBJECT_OPERATOR_H 18 19 #include <cstddef> 20 #include <cstdint> 21 22 #include "heap/heap_visitor.h" 23 #include "objects/field.h" 24 #include "objects/ref_field.h" 25 #include "objects/base_state_word.h" 26 27 namespace common { 28 class BaseObject; 29 30 class BaseObjectOperatorInterfaces { 31 public: 32 // Get Object size. 33 virtual size_t GetSize(const BaseObject *object) const = 0; 34 // Check is valid object. 35 virtual bool IsValidObject(const BaseObject *object) const = 0; 36 // Iterate object field. 37 virtual void ForEachRefField(const BaseObject *object, const RefFieldVisitor &visitor) const = 0; 38 // Get forwarding pointer. 39 virtual BaseObject *GetForwardingPointer(const BaseObject *object) const = 0; 40 // Set forwarding pointer. 41 virtual void SetForwardingPointerAfterExclusive(BaseObject *object, BaseObject *fwdPtr) = 0; 42 43 virtual ~BaseObjectOperatorInterfaces() = default; 44 }; 45 46 class BaseObjectOperator { 47 private: 48 BaseObjectOperatorInterfaces *dynamicObjOp_; 49 BaseObjectOperatorInterfaces *staticObjOp_; 50 friend BaseObject; 51 }; 52 } // namespace common 53 #endif // COMMON_INTERFACES_OBJECTS_BASE_OBJECT_OPERATOR_H 54