|
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- |
|
2 * vim: set ts=8 sts=4 et sw=4 tw=99: |
|
3 * This Source Code Form is subject to the terms of the Mozilla Public |
|
4 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
6 |
|
7 #ifndef gc_Memory_h |
|
8 #define gc_Memory_h |
|
9 |
|
10 #include <stddef.h> |
|
11 |
|
12 struct JSRuntime; |
|
13 |
|
14 namespace js { |
|
15 namespace gc { |
|
16 |
|
17 // Sanity check that our compiled configuration matches the currently running |
|
18 // instance and initialize any runtime data needed for allocation. |
|
19 void |
|
20 InitMemorySubsystem(JSRuntime *rt); |
|
21 |
|
22 // Allocate or deallocate pages from the system with the given alignment. |
|
23 void * |
|
24 MapAlignedPages(JSRuntime *rt, size_t size, size_t alignment); |
|
25 |
|
26 void |
|
27 UnmapPages(JSRuntime *rt, void *p, size_t size); |
|
28 |
|
29 // Tell the OS that the given pages are not in use, so they should not |
|
30 // be written to a paging file. This may be a no-op on some platforms. |
|
31 bool |
|
32 MarkPagesUnused(JSRuntime *rt, void *p, size_t size); |
|
33 |
|
34 // Undo |MarkPagesUnused|: tell the OS that the given pages are of interest |
|
35 // and should be paged in and out normally. This may be a no-op on some |
|
36 // platforms. |
|
37 bool |
|
38 MarkPagesInUse(JSRuntime *rt, void *p, size_t size); |
|
39 |
|
40 // Returns #(hard faults) + #(soft faults) |
|
41 size_t |
|
42 GetPageFaultCount(); |
|
43 |
|
44 // Allocate memory mapped content. |
|
45 // The offset must be aligned according to alignment requirement. |
|
46 void * |
|
47 AllocateMappedContent(int fd, size_t offset, size_t length, size_t alignment); |
|
48 |
|
49 // Deallocate memory mapped content. |
|
50 void |
|
51 DeallocateMappedContent(void *p, size_t length); |
|
52 |
|
53 } // namespace gc |
|
54 } // namespace js |
|
55 |
|
56 #endif /* gc_Memory_h */ |