summaryrefslogtreecommitdiff
path: root/rts/ExecPage.c
blob: 0f83c8e1f597cbdbcefb25b2020d8bad5c602ff6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/*
 * Utilities for managing dynamically-allocated executable pages.
 *
 * These are primarily used to back the adjustor code produced by the native
 * adjustor implementations.
 */

#include "Rts.h"
#include "sm/OSMem.h"
#include "linker/MMap.h"

ExecPage *allocateExecPage() {
    ExecPage *page = (ExecPage *) mmapAnonForLinker(getPageSize());
    return page;
}

void freezeExecPage(ExecPage *page) {
    mprotectForLinker(page, getPageSize(), MEM_READ_EXECUTE);
    flushExec(getPageSize(), page);
}

void freeExecPage(ExecPage *page) {
    munmapForLinker(page, getPageSize(), "freeExecPage");
}