michael@0: /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- michael@0: * vim: set ts=8 sts=4 et sw=4 tw=99: michael@0: * This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef gc_Memory_h michael@0: #define gc_Memory_h michael@0: michael@0: #include michael@0: michael@0: struct JSRuntime; michael@0: michael@0: namespace js { michael@0: namespace gc { michael@0: michael@0: // Sanity check that our compiled configuration matches the currently running michael@0: // instance and initialize any runtime data needed for allocation. michael@0: void michael@0: InitMemorySubsystem(JSRuntime *rt); michael@0: michael@0: // Allocate or deallocate pages from the system with the given alignment. michael@0: void * michael@0: MapAlignedPages(JSRuntime *rt, size_t size, size_t alignment); michael@0: michael@0: void michael@0: UnmapPages(JSRuntime *rt, void *p, size_t size); michael@0: michael@0: // Tell the OS that the given pages are not in use, so they should not michael@0: // be written to a paging file. This may be a no-op on some platforms. michael@0: bool michael@0: MarkPagesUnused(JSRuntime *rt, void *p, size_t size); michael@0: michael@0: // Undo |MarkPagesUnused|: tell the OS that the given pages are of interest michael@0: // and should be paged in and out normally. This may be a no-op on some michael@0: // platforms. michael@0: bool michael@0: MarkPagesInUse(JSRuntime *rt, void *p, size_t size); michael@0: michael@0: // Returns #(hard faults) + #(soft faults) michael@0: size_t michael@0: GetPageFaultCount(); michael@0: michael@0: // Allocate memory mapped content. michael@0: // The offset must be aligned according to alignment requirement. michael@0: void * michael@0: AllocateMappedContent(int fd, size_t offset, size_t length, size_t alignment); michael@0: michael@0: // Deallocate memory mapped content. michael@0: void michael@0: DeallocateMappedContent(void *p, size_t length); michael@0: michael@0: } // namespace gc michael@0: } // namespace js michael@0: michael@0: #endif /* gc_Memory_h */