1 /** 2 * Copyright (c) 2023 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_PLUGINS_ETS_RUNTIME_MEM_ETS_REFERENCE_PROCESSOR_H 17 #define PANDA_PLUGINS_ETS_RUNTIME_MEM_ETS_REFERENCE_PROCESSOR_H 18 19 #include "runtime/mem/gc/reference-processor/reference_processor.h" 20 21 namespace panda::mem::ets { 22 23 class EtsReferenceProcessor final : public ReferenceProcessor { 24 public: 25 explicit EtsReferenceProcessor(GC *gc); 26 NO_COPY_SEMANTIC(EtsReferenceProcessor); 27 NO_MOVE_SEMANTIC(EtsReferenceProcessor); 28 ~EtsReferenceProcessor() final = default; 29 30 bool IsReference(const BaseClass *baseCls, const ObjectHeader *ref, 31 const ReferenceCheckPredicateT &pred) const final; 32 33 void HandleReference(GC *gc, GCMarkingStackType *objectsStack, const BaseClass *cls, const ObjectHeader *object, 34 const ReferenceProcessPredicateT &pred) final; 35 36 void ProcessReferences(bool concurrent, bool clearSoftReferences, GCPhase gcPhase, 37 const mem::GC::ReferenceClearPredicateT &pred) final; 38 CollectClearedReferences()39 panda::mem::Reference *CollectClearedReferences() final 40 { 41 return nullptr; 42 } 43 ScheduleForEnqueue(Reference * clearedReferences)44 void ScheduleForEnqueue([[maybe_unused]] Reference *clearedReferences) final 45 { 46 UNREACHABLE(); 47 } 48 Enqueue(panda::mem::Reference * clearedReferences)49 void Enqueue([[maybe_unused]] panda::mem::Reference *clearedReferences) final 50 { 51 UNREACHABLE(); 52 } 53 54 /// @return size of the queue of weak references 55 size_t GetReferenceQueueSize() const final; 56 57 private: 58 mutable os::memory::Mutex weakRefLock_; 59 PandaUnorderedSet<ObjectHeader *> weakReferences_ GUARDED_BY(weakRefLock_); 60 GC *gc_; 61 }; 62 63 } // namespace panda::mem::ets 64 65 #endif // PANDA_PLUGINS_ETS_RUNTIME_MEM_ETS_REFERENCE_PROCESSOR_H 66