From 017b26a04a5a53a36225271ce4a33cbb9ad72b4c Mon Sep 17 00:00:00 2001 From: dzaima Date: Fri, 11 Jun 2021 04:59:31 +0300 Subject: [PATCH] fix gcc, more readme changes --- README.md | 14 +++++++------- src/jit/nvm.c | 7 ++++--- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 8842eaed..c0b1d54a 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ -build/run: +Build & run (tl;dr: `make; rlwrap ./BQN`): -1. (optional) run `./genRuntime path/to/mlochbaum/BQN`; Otherwise, the necessary precompiled bytecode will be retrieved from `remotes/origin/bytecode` -2. If needed, customize settings in `src/h.h` +1. (optional) Run `./genRuntime path/to/mlochbaum/BQN`; Otherwise, the necessary precompiled bytecode will be retrieved from `remotes/origin/bytecode` +2. If wanted, customize settings in `src/h.h` 3. `make` - - Options: `make o3`, `make debug` (`make rtperf`, `make heapverify` and `make rtverify` also exist for further testing/debugging) - - Do `make clean` or `make [o3|debug|…]-clean` before to force recompile - - `./build` and `./debugBuild` compile everything at once and allow specifying extra compiler arguments, but may be slower -4. `./BQN` (or `rlwrap ./BQN` for a fancier interface) + - Options: `make o3`, `make debug` (`make rtperf`, `make heapverify` and `make rtverify` also exist for further testing/debugging) + - Do `make clean` or `make [o3|debug|…]-clean` beforehand to force recompile + - `./build` and `./debugBuild` compile everything at once and allow specifying extra compiler arguments, but may be slower +4. `./BQN` (or `rlwrap ./BQN` for a better REPL) Run tests with `./BQN mlochbaum/BQN/test/this.bqn` (with `-noerr` for a heapverify build). diff --git a/src/jit/nvm.c b/src/jit/nvm.c index e09944bd..ac8889d6 100644 --- a/src/jit/nvm.c +++ b/src/jit/nvm.c @@ -221,8 +221,9 @@ u8* m_nvm(Body* body) { ASM(PUSH, r_CS, -); ASM(MOV, r_CS , REG_ARG0); ASM(MOV, r_PSCS, REG_ARG1); + if ((u64)i_SETN != (u32)(u64)i_SETN) thrM("JIT: Refusing to run with CBQN code outside of the 32-bit address range"); // #define CCALL(F) { IMM(r_TMP, F); ASM(CALL, r_TMP, -); } - #define CCALL(F) { TSADD(rel, ASM_SIZE); ASM(CALLI, (u32)F, -); } + #define CCALL(F) { TSADD(rel, ASM_SIZE); ASM(CALLI, (u32)(u64)F, -); } u32* bc = body->bc; Block** blocks = body->blocks->a; i32 depth = 0; @@ -259,7 +260,7 @@ u8* m_nvm(Body* body) { case FN2C: TOPp; IMM(REG_ARG1, s); INV(2,0,i_FN2C); break; // (B, u32* bc, S) case FN1O: TOPp; IMM(REG_ARG1, s); INV(2,0,i_FN1O); break; // (B, u32* bc, S) case FN2O: TOPp; IMM(REG_ARG1, s); INV(2,0,i_FN2O); break; // (B, u32* bc, S) - case ARRM: case ARRO: + case ARRM: case ARRO:; u32 sz = *bc++; if (sz) { TOPp; IMM(REG_ARG1, sz); INV(2,0,i_ARR_p); } // (B, i64 sz, S) else { TOPs; CCALL(i_ARR_0); } // (S) @@ -326,7 +327,7 @@ u8* m_nvm(Body* body) { for (u64 i = 0; i < relAm; i++) { u8* ins = binEx+rel[i]; u32 o = readBytes4(ins+1); - u32 n = o-(u32)ins-5; + u32 n = o-(u32)(u64)ins-5; memcpy(ins+1, (u8[]){BYTES4(n)}, 4); } // write_asm(binEx, sz);