/* * Copyright (c) 2018-2021, Andreas Kling * * SPDX-License-Identifier: BSD-2-Clause */ #include #include #include namespace Kernel::Memory { static Singleton> s_all_instances; SpinlockProtected& VMObject::all_instances() { return s_all_instances; } VMObject::VMObject(VMObject const& other) : m_physical_pages(other.m_physical_pages.must_clone_but_fixme_should_propagate_errors()) { all_instances().with([&](auto& list) { list.append(*this); }); } VMObject::VMObject(size_t size) : m_physical_pages(FixedArray>::must_create_but_fixme_should_propagate_errors(ceil_div(size, static_cast(PAGE_SIZE)))) { all_instances().with([&](auto& list) { list.append(*this); }); } VMObject::~VMObject() { VERIFY(m_regions.is_empty()); } }