From 1b878ccdb60a840dd6cf6350cd220ff863a3d2a3 Mon Sep 17 00:00:00 2001 From: dzaima Date: Fri, 10 Dec 2021 22:49:04 +0200 Subject: [PATCH] better readme --- README.md | 42 ++++++++++++++++++++++++++++++------------ makefile | 2 ++ src/h.h | 5 +++++ src/rtwrap.c | 9 +++++---- 4 files changed, 42 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 3b3629b4..8dee0ecc 100644 --- a/README.md +++ b/README.md @@ -1,18 +1,36 @@ -Build & run (tl;dr: `make; rlwrap ./BQN`): +# A [BQN](https://github.com/mlochbaum/BQN) implementation in C -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` (the default), `make debug` (more presets exist for more specific debugging) - - `make CC=gcc` can be used to compile with gcc. Otherwise, `clang` is used. - - Do `make clean` or `make t=[o3|debug|…] clean` beforehand to force recompile - - `make single-(o3|o3g|debug|c)` compile everything as a single translation unit and thus will compile slower, but allows specifying extra compiler arguments with `make f='…' single-…` and allows the compiler to optimize more -4. `./BQN` (or `rlwrap ./BQN` for a better REPL; see `./BQN --help` for more options) +## Running -Run tests with `./BQN mlochbaum/BQN/test/this.bqn` (add `-noerr` for a heapverify build). +1. `make` + - `make CC=gcc` if you don't have clang installed + - `make PIE=""` on ARM CPUs (incl. Android & M1) + - `make clean` if anything goes bad and you want a clean slate +2. `./BQN somefile.bqn` to execute a file, or `rlwrap ./BQN` for a REPL -Time REPL-executed safe prim tests: `./test.bqn mlochbaum/BQN -s prim > SP; time ./BQN/dev/null` +## Configuration options -Test precompiled expression: `./precompiled.bqn mlochbaum/BQN "$PATH" '2+2'` +- `some-other-bqn-implementation ./genRuntime path/to/mlochbaum/BQN` can be used to avoid pulling precompiled bytecode with git from `remotes/origin/bytecode`. + This creates the dummy file `src/gen/customRuntime` and will disable automated bytecode retrieval whenever it's updated. + `make clean-runtime` (or just `make-clean`) can be used to reset to the default state. +- Different build types: + - `make o3` - `-O3`, the default build + - `make o3n` - `-O3 -march=native` + - `make o3g` - `-g -O3` + - `make debug` - unoptimized debug build + - `make debug1` - debug build without parallel compilation. Useful if everything errors, and you don't want error messages of multiple threads to be written at the same time. + - `make heapverify` - verify that refcounting is done correctly + - `make t=some_type clean` - clean only the specific build + - `make o3n-singeli` - a Singeli build, currently only for CPUs supporting AVX2 + - `make t=some_custom_type f='-O3 -DSOME_MACRO=whatever -some_other_cc_flag' c` - custom build + Macros that you may want to define are listed in `src/h.h`. + The `some_custom_type` is used as the key for caching/incremental compilation, so make sure to `make t=some_custom_type clean` if you want to change the flags without changing the `t=` value!! + - `make single-(o3|o3g|debug|c)` - compile everything as a single translation unit. Slower for optimized builds, but may allow some more optimizations + - ... and more; see `makefile` +- Tests can be run with `./BQN path/to/mlochbaum/BQN/test/this.bqn` (add `-noerr` if using `make heapverify`). +- Test precompiled expression: `some-other-bqn-impl ./precompiled.bqn path/to/mlochbaum/BQN "$PATH" '2+2'` +- [Some implementation docs](https://github.com/dzaima/CBQN/tree/master/src#readme) + +## License Any file without an explicit copyright message is copyright (c) 2021 dzaima, GNU GPLv3 - see LICENSE \ No newline at end of file diff --git a/makefile b/makefile index 68b58ddc..75fabff1 100644 --- a/makefile +++ b/makefile @@ -25,6 +25,8 @@ debugn-singeli: @${MAKE} singeli=1 t=debugn_si f="-g -DDEBUG -march=native" c heapverifyn-singeli: @${MAKE} singeli=1 t=heapverifyn_si f="-g -DDEBUG -DHEAP_VERIFY -march=native" c +rtverifyn-singeli: + @${MAKE} singeli=1 t=rtverifyn_si f="-O3 -DRT_VERIFY -DEEQUAL_NEGZERO -march=native" c diff --git a/src/h.h b/src/h.h index 8fd81234..771b5a7f 100644 --- a/src/h.h +++ b/src/h.h @@ -49,6 +49,11 @@ // #define ALL_R0 // use all of r0.bqn for runtime_0 // #define ALL_R1 // use all of r1.bqn for runtime +// #define JIT_START 2 // number of calls for when to start JITting (x86_64-only); default is 2, defined in vm.h +// -1: never JIT +// 0: JIT everything +// >0: JIT after n non-JIT invocations; max ¯1+2⋆16 + // #define LOG_GC // log GC stats // #define RT_PERF // time runtime primitives // #define RT_VERIFY // compare native and runtime versions of primitives diff --git a/src/rtwrap.c b/src/rtwrap.c index 6c876632..b99c78ff 100644 --- a/src/rtwrap.c +++ b/src/rtwrap.c @@ -27,13 +27,14 @@ B wf_identity(B x) { #define RT_VERIFY_ARGS 1 #endif +B info_c1(B t, B x); #define CHK(EXP,GOT,W,X) { if (!eequal(EXP,GOT)) { \ print(f); printf(": failed RT_VERIFY\n"); fflush(stdout); \ if (RT_VERIFY_ARGS) { \ - if(!q_N(W)){printf("𝕨:"); print(W); putchar('\n'); fflush(stdout); } \ - { printf("𝕩:"); print(X); putchar('\n'); fflush(stdout); } \ - { printf("got:"); print(GOT); putchar('\n'); fflush(stdout); } \ - { printf("exp:"); print(EXP); putchar('\n'); fflush(stdout); } \ + if(!q_N(W)){printf("𝕨:"); print(W); printf(" / "); printRaw(info_c1(bi_N, inc(W))); putchar('\n'); fflush(stdout); } \ + { printf("𝕩:"); print(X); printf(" / "); printRaw(info_c1(bi_N, inc(X))); putchar('\n'); fflush(stdout); } \ + { printf("got:"); print(GOT); printf(" / "); printRaw(info_c1(bi_N, inc(GOT))); putchar('\n'); fflush(stdout); } \ + { printf("exp:"); print(EXP); printf(" / "); printRaw(info_c1(bi_N, inc(EXP))); putchar('\n'); fflush(stdout); } \ } \ vm_pstLive(); exit(1); \ }}