1
0
mirror of https://github.com/dschmenk/PLASMA.git synced 2025-04-05 03:37:43 +00:00

Fix premature restore of jitcodeptr in modexec

This commit is contained in:
Dave Schmenk 2019-12-12 01:13:05 -08:00
parent f5236f2a1d
commit 8364f5c631
4 changed files with 15 additions and 26 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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