--disable-jit flag

will be less efficient than if compiled with -DJIT_ENABLED=0, but better than nothing
This commit is contained in:
dzaima 2025-05-28 02:12:44 +03:00
parent 0f5e3c354d
commit 2adb0a3586
3 changed files with 8 additions and 1 deletions

View File

@ -963,6 +963,9 @@ int main(int argc, char* argv[]) {
} else if (!strcmp(carg, "--replxx-read-only")) {
replxx_read_only = true;
continue;
} else if (!strcmp(carg, "--disable-jit")) {
jit_enabled = false;
continue;
#endif
} else {
printf("%s: Unknown option: %s\n", argv[0], carg);

View File

@ -985,8 +985,10 @@ NOINLINE Scope* m_scope(Body* body, Scope* psc, u16 varAm, i32 initVarAm, B* ini
B execBlockInplaceImpl(Body* body, Scope* sc, Block* block) { return execBodyInplaceI(block->bodies[0], sc, block); }
bool jit_enabled = true;
#if JIT_START != -1
B mnvmExecBodyInplace(Body* body, Scope* sc) {
if (!jit_enabled) return evalBC(body, sc, body->bl);
Nvm_res r = m_nvm(body);
body->nvm = r.p;
body->nvmRefs = r.refs;

View File

@ -177,12 +177,14 @@ static B execBlockInplace(Block* block, Scope* sc) { // doesn't consume; execute
#if JIT_START != -1
NOINLINE B mnvmExecBodyInplace(Body* body, Scope* sc);
#endif
extern bool jit_enabled;
FORCE_INLINE B execBodyInplaceI(Body* body, Scope* sc, Block* block) { // consumes sc, unlike execBlockInplace
debug_assert(body->bl == block);
#if JIT_START != -1
if (LIKELY(body->nvm != NULL)) return evalJIT(body, sc, body->nvm);
bool jit = true;
#if JIT_START > 0
jit = body->callCount++ >= JIT_START;
jit = body->callCount++ == JIT_START;
#endif
// jit = body->bc[2]==m_f64(123456).u>>32; // enable JIT for blocks starting with `123456⋄`
if (jit) return mnvmExecBodyInplace(body, sc);