js/src/gc/Memory.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/gc/Memory.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,56 @@
     1.4 +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
     1.5 + * vim: set ts=8 sts=4 et sw=4 tw=99:
     1.6 + * This Source Code Form is subject to the terms of the Mozilla Public
     1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.9 +
    1.10 +#ifndef gc_Memory_h
    1.11 +#define gc_Memory_h
    1.12 +
    1.13 +#include <stddef.h>
    1.14 +
    1.15 +struct JSRuntime;
    1.16 +
    1.17 +namespace js {
    1.18 +namespace gc {
    1.19 +
    1.20 +// Sanity check that our compiled configuration matches the currently running
    1.21 +// instance and initialize any runtime data needed for allocation.
    1.22 +void
    1.23 +InitMemorySubsystem(JSRuntime *rt);
    1.24 +
    1.25 +// Allocate or deallocate pages from the system with the given alignment.
    1.26 +void *
    1.27 +MapAlignedPages(JSRuntime *rt, size_t size, size_t alignment);
    1.28 +
    1.29 +void
    1.30 +UnmapPages(JSRuntime *rt, void *p, size_t size);
    1.31 +
    1.32 +// Tell the OS that the given pages are not in use, so they should not
    1.33 +// be written to a paging file. This may be a no-op on some platforms.
    1.34 +bool
    1.35 +MarkPagesUnused(JSRuntime *rt, void *p, size_t size);
    1.36 +
    1.37 +// Undo |MarkPagesUnused|: tell the OS that the given pages are of interest
    1.38 +// and should be paged in and out normally. This may be a no-op on some
    1.39 +// platforms.
    1.40 +bool
    1.41 +MarkPagesInUse(JSRuntime *rt, void *p, size_t size);
    1.42 +
    1.43 +// Returns #(hard faults) + #(soft faults)
    1.44 +size_t
    1.45 +GetPageFaultCount();
    1.46 +
    1.47 +// Allocate memory mapped content.
    1.48 +// The offset must be aligned according to alignment requirement.
    1.49 +void *
    1.50 +AllocateMappedContent(int fd, size_t offset, size_t length, size_t alignment);
    1.51 +
    1.52 +// Deallocate memory mapped content.
    1.53 +void
    1.54 +DeallocateMappedContent(void *p, size_t length);
    1.55 +
    1.56 +} // namespace gc
    1.57 +} // namespace js
    1.58 +
    1.59 +#endif /* gc_Memory_h */

mercurial