From 8364f5c63139a1d6a512321975cf18ea9c358a18 Mon Sep 17 00:00:00 2001 From: Dave Schmenk Date: Thu, 12 Dec 2019 01:13:05 -0800 Subject: [PATCH] Fix premature restore of jitcodeptr in modexec --- src/libsrc/apple/jit.pla | 2 +- src/libsrc/jit16core.pla | 15 ++++----------- src/libsrc/jitcore.pla | 15 ++++----------- src/vmsrc/apple/cmdjit.pla | 9 ++++++--- 4 files changed, 15 insertions(+), 26 deletions(-) diff --git a/src/libsrc/apple/jit.pla b/src/libsrc/apple/jit.pla index 263d645..f0bd2e9 100644 --- a/src/libsrc/apple/jit.pla +++ b/src/libsrc/apple/jit.pla @@ -49,7 +49,7 @@ if *jitcomp return 0 fin *jitcomp = @compiler -cmdsys.jitcount = 44 +cmdsys.jitcount = 36 cmdsys.jitsize = 96 puts("JITC enabled\n") return modkeep diff --git a/src/libsrc/jit16core.pla b/src/libsrc/jit16core.pla index eb73f13..c036841 100644 --- a/src/libsrc/jit16core.pla +++ b/src/libsrc/jit16core.pla @@ -10,10 +10,8 @@ def compiler(defptr)#0 word codeptr, isdata[], addrxlate, bytecode, i, case, dest byte opcode, j, A_IS_TOS, X_IS_IFP - //puts("JIT compiler invoked for :$"); puth(defptr=>bytecodeaddr); putln defptr=>interpaddr = indirectentry // assume compile will fail addrxlate = heapmark // heapalloc(512 + defptr->bytecodesize) - //if not addrxlate if isult(heapavail, 512 + defptr->bytecodesize) // 256 * sizeof(word) address xlate // // Not enough heap available @@ -26,7 +24,8 @@ def compiler(defptr)#0 // bytecode = addrxlate + 512 // def bytecode defcpy(bytecode, defptr) - //puts("Addr Xlate: $"); puth(addrxlate); putln + //puts("JITC:$"); puth(defptr=>bytecodeaddr); puts("=>$"); puth(bytecode) + //puts(",$"); puth(defptr->bytecodesize); putln // // Find all branch targets and optimization fences. Tag the opcode with the LSB set // @@ -1308,11 +1307,8 @@ def compiler(defptr)#0 defptr->interpjsr = $4C // JMP defptr=>interpaddr = *jitcodeptr *jitcodeptr = codeptr - // - // Free working bufffers - // - //heaprelease(addrxlate) - //puts("Done compiling: $"); puth(defptr=>interpaddr); putln + //puts("Done compiling: $"); puth(defptr=>interpaddr) + //puts("->$"); puth(*jitcodeptr); putln //getc return fin @@ -1320,9 +1316,6 @@ def compiler(defptr)#0 // // If we got here we ran out of code buffer space. // - // Free working bufffers - // - //heaprelease(addrxlate) //puts("Ran out of code buffer\n") //getc end diff --git a/src/libsrc/jitcore.pla b/src/libsrc/jitcore.pla index 5286233..29f301d 100644 --- a/src/libsrc/jitcore.pla +++ b/src/libsrc/jitcore.pla @@ -28,10 +28,8 @@ def compiler(defptr)#0 word codeptr, isdata[], addrxlate, bytecode, i, case, dest, VX, VY byte opcode, j, A_IS_TOSL - //puts("JIT compiler invoked for :$"); puth(defptr=>bytecodeaddr); putln defptr=>interpaddr = indirectentry // assume compile will fail addrxlate = heapmark // heapalloc(512 + defptr->bytecodesize) - //if not addrxlate if isult(heapavail, 512 + defptr->bytecodesize) // 256 * sizeof(word) address xlate // // Not enough heap available @@ -44,7 +42,8 @@ def compiler(defptr)#0 // bytecode = addrxlate + 512 // def bytecode defcpy(bytecode, defptr) - //puts("Addr Xlate: $"); puth(addrxlate); putln + //puts("JITC:$"); puth(defptr=>bytecodeaddr); puts("=>$"); puth(bytecode) + //puts(",$"); puth(defptr->bytecodesize); putln // // Find all branch targets and optimization fences. Tag the opcode with the LSB set // @@ -1535,11 +1534,8 @@ def compiler(defptr)#0 defptr->interpjsr = $4C // JMP defptr=>interpaddr = *jitcodeptr *jitcodeptr = codeptr - // - // Free working bufffers - // - //heaprelease(addrxlate) - //puts("Done compiling: $"); puth(defptr=>interpaddr); putln + //puts("Done compiling: $"); puth(defptr=>interpaddr) + //puts("->$"); puth(*jitcodeptr); putln //getc return fin @@ -1547,9 +1543,6 @@ def compiler(defptr)#0 // // If we got here we ran out of code buffer space. // - // Free working bufffers - // - //heaprelease(addrxlate) //puts("Ran out of code buffer\n") //getc end diff --git a/src/vmsrc/apple/cmdjit.pla b/src/vmsrc/apple/cmdjit.pla index c3af10c..1f64fc9 100755 --- a/src/vmsrc/apple/cmdjit.pla +++ b/src/vmsrc/apple/cmdjit.pla @@ -39,6 +39,7 @@ end // // JIT compiler constants // +const jitcbuf = $AF00 const jitcomp = $03E2 const jitcodeptr = $03E4 const jitmod = $02F0 @@ -1343,6 +1344,10 @@ def resetmemfiles()#0 memset($BF58, 0, 24) ^$BF58 = $CF ^$BF6F = $01 + // + // Reset JIT code pointer + // + *jitcodeptr = jitcbuf perr = terr // Restore perr end def execsys(sysfile)#0 @@ -1372,7 +1377,7 @@ def execsys(sysfile)#0 end def execmod(modfile)#1 byte moddci[17] - word saveheap, savexheap, savesym, saveflags, savejit + word saveheap, savexheap, savesym, saveflags perr = 1 if stodci(modfile, @moddci) @@ -1380,12 +1385,10 @@ def execmod(modfile)#1 savexheap = xheap savesym = lastsym saveflags = systemflags - savejit = *jitcodeptr if loadmod(@moddci) < modkeep lastsym = savesym xheap = savexheap heap = saveheap - *jitcodeptr = savejit fin ^lastsym = 0 systemflags = saveflags