1
0
mirror of https://github.com/dschmenk/PLASMA.git synced 2024-10-18 22:24:28 +00:00

Speed up module loading (remove unused features, too)

This commit is contained in:
David Schmenk 2018-01-09 18:12:30 -08:00
parent e48d3cc112
commit 72fbb94dd1
3 changed files with 116 additions and 102 deletions

View File

@ -769,15 +769,15 @@ def lookupextern(esd, index)#1
byte str[16]
while ^esd
sym = esd
esd = esd + dcitos(esd, @str)
esd = sym + dcitos(sym, @str)
if esd->0 & $10 and esd->1 == index
addr = lookuptbl(sym, symtbl)
if !addr
if !addr
perr = $81
cout('?')
prstr(@str)
crout
fin
cout('?')
prstr(@str)
crout
fin
return addr
fin
esd = esd + 3
@ -808,7 +808,7 @@ def loadmod(mod)#1
word addr, modaddr, modfix, modofst, modend
word deftbl, deflast
word moddep, rld, esd, sym
byte str[17], filename[17]
byte type, str[17], filename[17]
byte header[128]
//
// Read the RELocatable module header (first 128 bytes)
@ -875,6 +875,7 @@ def loadmod(mod)#1
modofst = modfix - MODADDR
modend = modaddr + modsize
bytecode = defofst + modofst
defofst = bytecode - defofst
rld = modend // Re-Locatable Directory
esd = rld // Extern+Entry Symbol Directory
while ^esd // Scan to end of ESD
@ -882,40 +883,43 @@ def loadmod(mod)#1
loop
esd = esd + 1
//
// Run through the DeFinition Dictionary.
//
while ^rld == $02
//
// This is a bytcode def entry - add it to the def directory.
//
adddef(rld=>1 + defofst, @deflast)
rld = rld + 4
loop
//
// Run through the Re-Location Dictionary.
//
while ^rld
if ^rld == $02
//
// This is a bytcode def entry - add it to the def directory.
//
adddef(rld=>1 - defofst + bytecode, @deflast)
else
addr = rld=>1 + modfix
if uword_isge(addr, modaddr) // Skip fixups to header
if ^rld & $80 // WORD sized fixup.
fixup = *addr
else // BYTE sized fixup.
fixup = ^addr
fin
if ^rld & $10 // EXTERN reference.
fixup = fixup + lookupextern(esd, rld->3)
else // INTERN fixup.
fixup = fixup + modofst
if uword_isge(fixup, bytecode)
//
// Bytecode address - replace with call def directory.
//
fixup = lookupdef(fixup - bytecode + bytecode, deftbl)
fin
fin
if ^rld & $80 // WORD sized fixup.
*addr = fixup
else // BYTE sized fixup.
^addr = fixup
addr = rld=>1 + modfix
//if uword_isge(addr, modaddr) // Skip fixups to header
//if type & $80 // WORD sized fixup.
// fixup = *addr
//else // BYTE sized fixup.
fixup = ^addr
//fin
if ^rld & $10 // EXTERN reference.
fixup = fixup + lookupextern(esd, rld->3)
else // INTERN fixup.
fixup = fixup + modofst
if uword_isge(fixup, bytecode)
//
// Bytecode address - replace with call def directory.
//
fixup = lookupdef(fixup + defofst, deftbl)
fin
fin
fin
//if type & $80 // WORD sized fixup.
*addr = fixup
//else // BYTE sized fixup.
// ^addr = fixup
//fin
//fin
rld = rld + 4
loop
//
@ -933,7 +937,7 @@ def loadmod(mod)#1
//
// Use the def directory address for bytecode.
//
addr = lookupdef(addr - bytecode + bytecode, deftbl)
addr = lookupdef(addr + defofst, deftbl)
fin
addsym(sym, addr)
fin

View File

@ -902,7 +902,7 @@ def lookupextern(esd, index)#1
byte str[16]
while ^esd
sym = esd
esd = esd + dcitos(esd, @str)
esd = sym + dcitos(sym, @str)
if esd->0 & $10 and esd->1 == index
addr = lookuptbl(sym, symtbl)
if !addr
@ -939,7 +939,7 @@ def lookupdef(addr, deftbl)#1
return 0
end
def loadmod(mod)#1
word refnum, rdlen, modsize, bytecode, defofst, defcnt, init, fixup
word refnum, rdlen, modsize, bytecode, codefix, defofst, defcnt, init, fixup
word addr, defaddr, modaddr, modfix, modofst, modend
word deftbl, deflast
word moddep, rld, esd, sym
@ -1038,41 +1038,46 @@ def loadmod(mod)#1
defbank = 0
defaddr = bytecode
fin
codefix = defaddr - bytecode
defofst = defaddr - defofst
//
// Run through the DeFinition Dictionary.
//
while ^rld == $02
//
// This is a bytcode def entry - add it to the def directory.
//
adddef(defbank, rld=>1 + defofst, @deflast)
rld = rld + 4
loop
//
// Run through the Re-Location Dictionary.
//
while ^rld
if ^rld == $02
//
// This is a bytcode def entry - add it to the def directory.
//
adddef(defbank, rld=>1 - defofst + defaddr, @deflast)
else
addr = rld=>1 + modfix
if uword_isge(addr, modaddr) // Skip fixups to header
if ^rld & $80 // WORD sized fixup.
fixup = *addr
else // BYTE sized fixup.
fixup = ^addr
fin
if ^rld & $10 // EXTERN reference.
fixup = fixup + lookupextern(esd, rld->3)
else // INTERN fixup.
fixup = fixup + modofst
if uword_isge(fixup, bytecode)
//
// Bytecode address - replace with call def directory.
//
fixup = lookupdef(fixup - bytecode + defaddr, deftbl)
fin
fin
if ^rld & $80 // WORD sized fixup.
*addr = fixup
else // BYTE sized fixup.
^addr = fixup
addr = rld=>1 + modfix
//if uword_isge(addr, modaddr) // Skip fixups to header
//if type & $80 // WORD sized fixup.
fixup = *addr
//else // BYTE sized fixup.
// fixup = ^addr
//fin
if ^rld & $10 // EXTERN reference.
fixup = fixup + lookupextern(esd, rld->3)
else // INTERN fixup.
fixup = fixup + modofst
if uword_isge(fixup, bytecode)
//
// Bytecode address - replace with call def directory.
//
fixup = lookupdef(fixup + codefix, deftbl)
fin
fin
fin
//if type & $80 // WORD sized fixup.
*addr = fixup
//else // BYTE sized fixup.
// ^addr = fixup
//fin
//fin
rld = rld + 4
loop
//
@ -1090,7 +1095,7 @@ def loadmod(mod)#1
//
// Use the def directory address for bytecode.
//
addr = lookupdef(addr - bytecode + defaddr, deftbl)
addr = lookupdef(addr + codefix, deftbl)
fin
addsym(sym, addr)
fin
@ -1115,7 +1120,7 @@ def loadmod(mod)#1
//
fixup = 0 // This is repurposed for the return code
if init
init = init - defofst + defaddr
init = init + defofst
fixup = adddef(defbank, init, @deflast)()
if fixup < modinitkeep
//

View File

@ -933,7 +933,7 @@ def lookupextern(esd, index)#1
byte str[16]
while ^esd
sym = esd
esd = esd + dcitos(esd, @str)
esd = sym + dcitos(sym, @str)
if esd->0 & $10 and esd->1 == index
addr = lookuptbl(sym, symtbl)
if !addr
@ -968,7 +968,7 @@ def lookupdef(addr, deftbl)#1
return 0
end
def loadmod(mod)#1
word refnum, rdlen, modsize, bytecode, defofst, defcnt, init, fixup
word refnum, rdlen, modsize, bytecode, codefix, defofst, defcnt, init, fixup
word addr, defaddr, modaddr, modfix, modofst, modend
word deftbl, deflast, codeseg
word moddep, rld, esd, sym
@ -1069,40 +1069,45 @@ def loadmod(mod)#1
modid = modid + 1
defext = (codeseg.0 | $80) - 1
defaddr = (codeseg & $FF00) + $6000
codefix = defaddr - bytecode
defofst = defaddr - defofst
//
// Run through the DeFinition Dictionary.
//
while ^rld == $02
//
// This is a bytcode def entry - add it to the def directory.
//
adddef(defext, rld=>1 + defofst, @deflast)
rld = rld + 4
loop
//
// Run through the Re-Location Dictionary.
//
while ^rld
if ^rld == $02
//
// This is a bytcode def entry - add it to the def directory.
//
adddef(defext, rld=>1 - defofst + defaddr, @deflast)
else
addr = rld=>1 + modfix
if uword_isge(addr, modaddr) // Skip fixups to header
if ^rld & $80 // WORD sized fixup.
fixup = *addr
else // BYTE sized fixup.
fixup = ^addr
fin
if ^rld & $10 // EXTERN reference.
fixup = fixup + lookupextern(esd, rld->3)
else // INTERN fixup.
fixup = fixup + modofst
if uword_isge(fixup, bytecode)
//
// Bytecode address - replace with call def directory.
//
fixup = lookupdef(fixup - bytecode + defaddr, deftbl)
fin
fin
if ^rld & $80 // WORD sized fixup.
*addr = fixup
else // BYTE sized fixup.
^addr = fixup
addr = rld=>1 + modfix
if uword_isge(addr, modaddr) // Skip fixups to header
//if ^rld & $80 // WORD sized fixup.
fixup = *addr
//else // BYTE sized fixup.
// fixup = ^addr
//fin
if ^rld & $10 // EXTERN reference.
fixup = fixup + lookupextern(esd, rld->3)
else // INTERN fixup.
fixup = fixup + modofst
if uword_isge(fixup, bytecode)
//
// Bytecode address - replace with call def directory.
//
fixup = lookupdef(fixup + codefix, deftbl)
fin
fin
//if ^rld & $80 // WORD sized fixup.
*addr = fixup
//else // BYTE sized fixup.
// ^addr = fixup
//fin
fin
rld = rld + 4
loop
@ -1121,7 +1126,7 @@ def loadmod(mod)#1
//
// Use the def directory address for bytecode.
//
addr = lookupdef(addr - bytecode + defaddr, deftbl)
addr = lookupdef(addr + codefix, deftbl)
fin
addsym(sym, addr)
fin
@ -1148,7 +1153,7 @@ def loadmod(mod)#1
//
fixup = 0
if init
fixup = adddef(defext, init - defofst + defaddr, @deflast)()
fixup = adddef(defext, init + defofst, @deflast)()
if fixup < 0
perr = -fixup
fin