Skip to content

Commit

Permalink
Merge pull request #529 from MatthewMerrill/engine_jit_options
Browse files Browse the repository at this point in the history
Migrate `-Djit=true` option to `-Dengine=jit`.
  • Loading branch information
tbodt committed Oct 20, 2019
2 parents a87eb33 + a8a88b7 commit 556d54e
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -19,7 +19,7 @@ matrix:
include:
- <<: *linux
env:
- MESON_OPTS=-Djit=true
- MESON_OPTS=-Dengine=jit
- NINJA_TARGET=test
- language: objective-c
osx_image: xcode11
Expand Down
8 changes: 4 additions & 4 deletions emu/memory.c
Expand Up @@ -22,7 +22,7 @@ void mem_init(struct mem *mem) {
mem->pgdir = calloc(MEM_PGDIR_SIZE, sizeof(struct pt_entry *));
mem->pgdir_used = 0;
mem->changes = 0;
#if JIT
#if ENGINE_JIT
mem->jit = jit_new(mem);
#endif
wrlock_init(&mem->lock);
Expand All @@ -31,7 +31,7 @@ void mem_init(struct mem *mem) {
void mem_destroy(struct mem *mem) {
write_wrlock(&mem->lock);
pt_unmap_always(mem, 0, MEM_PAGES);
#if JIT
#if ENGINE_JIT
jit_free(mem->jit);
#endif
for (int i = 0; i < MEM_PGDIR_SIZE; i++) {
Expand Down Expand Up @@ -146,7 +146,7 @@ int pt_unmap_always(struct mem *mem, page_t start, pages_t pages) {
struct pt_entry *pt = mem_pt(mem, page);
if (pt == NULL)
continue;
#if JIT
#if ENGINE_JIT
jit_invalidate_page(mem->jit, page);
#endif
struct data *data = pt->data;
Expand Down Expand Up @@ -250,7 +250,7 @@ void *mem_ptr(struct mem *mem, addr_t addr, int type) {
memcpy(copy, data, PAGE_SIZE);
pt_map(mem, page, 1, copy, 0, entry->flags &~ P_COW);
}
#if JIT
#if ENGINE_JIT
// get rid of any compiled blocks in this page
jit_invalidate_page(mem->jit, page);
#endif
Expand Down
6 changes: 3 additions & 3 deletions emu/memory.h
Expand Up @@ -6,7 +6,7 @@
#include "util/list.h"
#include "util/sync.h"
#include "misc.h"
#if JIT
#if ENGINE_JIT
struct jit;
#endif

Expand All @@ -20,7 +20,7 @@ struct mem {
int pgdir_used;

// TODO put these in their own mm struct maybe
#if JIT
#if ENGINE_JIT
struct jit *jit;
#endif

Expand Down Expand Up @@ -62,7 +62,7 @@ struct pt_entry {
struct data *data;
size_t offset;
unsigned flags;
#if JIT
#if ENGINE_JIT
struct list blocks[2];
#endif
};
Expand Down
2 changes: 1 addition & 1 deletion jit/jit.h
Expand Up @@ -4,7 +4,7 @@
#include "emu/memory.h"
#include "util/list.h"

#if JIT
#if ENGINE_JIT

#define JIT_INITIAL_HASH_SIZE (1 << 10)
#define JIT_CACHE_SIZE (1 << 10)
Expand Down
9 changes: 3 additions & 6 deletions meson.build
@@ -1,5 +1,5 @@
project('ish', 'c',
default_options: ['default_library=static', 'c_std=gnu11', 'jit=true', 'warning_level=2'])
default_options: ['default_library=static', 'c_std=gnu11', 'warning_level=2'])

log_on = get_option('log').split()
log_off = get_option('nolog').split()
Expand All @@ -11,15 +11,12 @@ foreach channel : log_on + log_off
endif
endforeach
add_project_arguments('-DLOG_HANDLER_' + get_option('log_handler').to_upper() + '=1', language: 'c')
add_project_arguments('-DENGINE_' + get_option('engine').to_upper() + '=1', language: 'c')

if get_option('no_crlf')
add_project_arguments('-DNO_CRLF', language: 'c')
endif

if get_option('jit')
add_project_arguments('-DJIT=1', language: 'c')
endif

add_project_arguments('-Wno-switch', language: 'c')

includes = [include_directories('.')]
Expand Down Expand Up @@ -111,7 +108,7 @@ src = [

'platform/' + host_machine.system() + '.c',
]
if get_option('jit')
if get_option('engine') == 'jit'
gadgets = 'jit/gadgets-' + host_machine.cpu_family()
src += [
'jit/jit.c',
Expand Down
2 changes: 1 addition & 1 deletion meson_options.txt
Expand Up @@ -2,7 +2,7 @@ option('log', type: 'string', value: '')
option('nolog', type: 'string', value: '')
option('log_handler', type: 'string', value: 'dprintf')

option('jit', type: 'boolean', value: false)
option('engine', type: 'combo', choices: ['jit', 'interp'], value: 'jit')

option('vdso_c_args', type: 'string', value: '')

Expand Down

0 comments on commit 556d54e

Please sign in to comment.