From 3449d7809ec734f4960a0caf96b1d5ab6694bc40 Mon Sep 17 00:00:00 2001 From: Sarychev Konstantin Date: Tue, 28 Nov 2023 19:36:22 +0300 Subject: [PATCH] [MM] Moved GetObjectAllocator method of HeapManager class to private Issue:#I8JWV9 Signed-off-by:Sarychev Konstantin --- runtime/builtins/builtins_global.cpp | 9 ++++----- runtime/ecma_vm.cpp | 4 ++-- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/runtime/builtins/builtins_global.cpp b/runtime/builtins/builtins_global.cpp index 766db2308..241649277 100644 --- a/runtime/builtins/builtins_global.cpp +++ b/runtime/builtins/builtins_global.cpp @@ -1157,8 +1157,8 @@ JSHandle GCSpecialisedObjectSpaceType(JSThread *thread, const JSH return global_constants->GetHandledObjectSpaceString(); } - auto object_allocator = thread->GetEcmaVM()->GetHeapManager()->GetObjectAllocator().AsObjectAllocator(); - if (object_allocator->IsObjectInYoungSpace(obj_handle.GetTaggedValue().GetHeapObject())) { + auto heap_manager = thread->GetEcmaVM()->GetHeapManager(); + if (heap_manager->IsObjectInYoungSpace(obj_handle.GetTaggedValue().GetHeapObject())) { return global_constants->GetHandledYoungSpaceString(); } return global_constants->GetHandledTenuredSpaceString(); @@ -1171,7 +1171,6 @@ JSTaggedValue global::PinObject(EcmaRuntimeCallInfo *argv) EcmaVM *vm = thread->GetEcmaVM(); JSHandle arg = builtins_common::GetCallArg(argv, 0); if (arg->IsHeapObject()) { - auto *obj_allocator = vm->GetHeapManager()->GetObjectAllocator().AsObjectAllocator(); auto *gc = vm->GetGC(); if (!gc->IsPinningSupported()) { [[maybe_unused]] EcmaHandleScope handle_scope(thread); @@ -1179,7 +1178,7 @@ JSTaggedValue global::PinObject(EcmaRuntimeCallInfo *argv) vm->GetFactory()->GetJSError(ErrorType::TYPE_ERROR, "Current GC does not support pinning"); THROW_NEW_ERROR_AND_RETURN_VALUE(thread, err.GetTaggedValue(), JSTaggedValue::Exception()); } - obj_allocator->PinObject(arg->GetHeapObject()); + vm->GetHeapManager()->PinObject(arg->GetHeapObject()); } else { [[maybe_unused]] EcmaHandleScope handle_scope(thread); JSHandle err = vm->GetFactory()->GetJSError(ErrorType::TYPE_ERROR, "The value must be an object"); @@ -1195,7 +1194,7 @@ JSTaggedValue global::UnpinObject(EcmaRuntimeCallInfo *argv) EcmaVM *vm = thread->GetEcmaVM(); JSHandle arg = builtins_common::GetCallArg(argv, 0); if (arg->IsHeapObject()) { - vm->GetHeapManager()->GetObjectAllocator().AsObjectAllocator()->UnpinObject(arg->GetHeapObject()); + vm->GetHeapManager()->UnpinObject(arg->GetHeapObject()); } else { [[maybe_unused]] EcmaHandleScope handle_scope(thread); JSHandle err = vm->GetFactory()->GetJSError(ErrorType::TYPE_ERROR, "The value must be an object"); diff --git a/runtime/ecma_vm.cpp b/runtime/ecma_vm.cpp index 90ef32fb0..9bc11af0a 100644 --- a/runtime/ecma_vm.cpp +++ b/runtime/ecma_vm.cpp @@ -480,7 +480,7 @@ void EcmaVM::DumpHeap(PandaOStringStream *o_str) const { size_t obj_cnt = 0; *o_str << "Dumping heap" << std::endl; - GetHeapManager()->GetObjectAllocator()->IterateOverObjects([&obj_cnt, &o_str](ObjectHeader *mem) { + GetHeapManager()->IterateOverObjects([&obj_cnt, &o_str](ObjectHeader *mem) { JSTaggedValue(mem).Dump(nullptr, *o_str); obj_cnt++; }); @@ -491,7 +491,7 @@ PandaString EcmaVM::GetClassesFootprint() const { PandaUnorderedMap classes_footprint; PandaStringStream result; - GetHeapManager()->GetObjectAllocator()->IterateOverObjects([&classes_footprint](ObjectHeader *mem) { + GetHeapManager()->IterateOverObjects([&classes_footprint](ObjectHeader *mem) { auto obj_type = JSTaggedValue(mem).GetTaggedObject()->GetClass()->GetObjectType(); classes_footprint[obj_type] += mem->ObjectSize(); }); -- Gitee