Demand paging on Windows

This commit is contained in:
mio
2023-01-28 22:04:43 +01:00
parent 7e4754ad00
commit 12a79192ee
5 changed files with 49 additions and 0 deletions

View File

@@ -23,6 +23,8 @@
*/
/* define it to use liveness analysis (better code) */
#include "tcg/tcg.h"
#include <stdio.h>
#define USE_TCG_OPTIMIZATIONS
#include "qemu/osdep.h"
@@ -406,6 +408,13 @@ static void tcg_region_assign(TCGContext *s, size_t curr_region)
s->code_gen_buffer = start;
s->code_gen_ptr = start;
s->code_gen_buffer_size = (char *)end - (char *)start;
#if defined(WIN32) && !defined(USE_STATIC_CODE_GEN_BUFFER)
VirtualAlloc(
s->code_gen_buffer,
ROUND_UP(s->code_gen_buffer_size, s->uc->qemu_real_host_page_size),
MEM_COMMIT,
PAGE_EXECUTE_READWRITE);
#endif
memset(s->code_gen_buffer, 0x00, s->code_gen_buffer_size);
s->code_gen_highwater = (char *)end - TCG_HIGHWATER;
}
@@ -500,7 +509,11 @@ void tcg_region_init(TCGContext *tcg_ctx)
size_t n_regions;
size_t i;
#if defined(WIN32) && !defined(USE_STATIC_CODE_GEN_BUFFER)
n_regions = size / (tcg_ctx->uc->qemu_real_host_page_size * UC_TCG_REGION_PAGES_COUNT);
#else
n_regions = 1;
#endif
/* The first region will be 'aligned - buf' bytes larger than the others */
aligned = (void *)QEMU_ALIGN_PTR_UP(buf, page_size);
@@ -537,6 +550,11 @@ void tcg_region_init(TCGContext *tcg_ctx)
}
tcg_ctx->tree = g_tree_new(tb_tc_cmp);
#if defined(WIN32) && !defined(USE_STATIC_CODE_GEN_BUFFER)
// Allocate a region immediately, or the highwater is not set correctly.
tcg_region_alloc(tcg_ctx);
#endif
}
/*