mirror of
https://github.com/dschmenk/PLASMA.git
synced 2025-02-21 08:29:13 +00:00
Free as much memory when calling module init as possible
This commit is contained in:
parent
c075197c6d
commit
85e76a74bb
@ -494,14 +494,19 @@ def init_idglobal#0
|
||||
word op
|
||||
byte i
|
||||
|
||||
puts("Mem free: "); puth(heapavail); putln
|
||||
tag_addr = heapalloc(TAGNUM*2)
|
||||
tag_type = heapalloc(TAGNUM)
|
||||
puts("Mem free after tag allocate: "); puth(heapavail); putln
|
||||
fixup_tag = heapalloc(FIXUPNUM*2)
|
||||
fixup_addr = heapalloc(FIXUPNUM*2)
|
||||
puts("Mem free after fixup allocate: "); puth(heapavail); putln
|
||||
idglobal_tbl = heapalloc(IDGLOBALSZ)
|
||||
idlocal_tbl = heapalloc(IDLOCALSZ)
|
||||
puts("Mem free after global allocate: "); puth(heapavail); putln
|
||||
codebufsz = heapavail - 4096
|
||||
codebuff = heapalloc(codebufsz)
|
||||
puts("Mem free after data+code allocate: "); puth(heapavail); putln
|
||||
codeptr = codebuff
|
||||
lastglobal = idglobal_tbl
|
||||
puts("Data+Code buffer size = "); puti(codebufsz); putln
|
||||
|
@ -231,11 +231,11 @@ end
|
||||
//
|
||||
// Generated code buffers
|
||||
//
|
||||
const OPSEQNUM = 300
|
||||
const TAGNUM = 1024
|
||||
const OPSEQNUM = 256
|
||||
const TAGNUM = 2048
|
||||
const FIXUPNUM = 2048
|
||||
const IDGLOBALSZ = 2048
|
||||
const IDLOCALSZ = 256
|
||||
const IDLOCALSZ = 512
|
||||
word fixup_cnt, tag_cnt = -1
|
||||
word fixup_tag, fixup_addr
|
||||
word tag_addr, tag_type
|
||||
|
@ -948,6 +948,10 @@ def loadmod(mod)#1
|
||||
return -perr
|
||||
fin
|
||||
//
|
||||
// Free up the end-of-module in main memory.
|
||||
//
|
||||
releaseheap(modend)
|
||||
//
|
||||
// Call init routine if it exists.
|
||||
//
|
||||
fixup = 0
|
||||
@ -957,13 +961,9 @@ def loadmod(mod)#1
|
||||
perr = -fixup
|
||||
fin
|
||||
if !(systemflags & modinitkeep)
|
||||
modend = init - defofst + bytecode
|
||||
releaseheap(init - defofst + bytecode)
|
||||
fin
|
||||
fin
|
||||
//
|
||||
// Free up the end-of-module in main memory.
|
||||
//
|
||||
releaseheap(modend)
|
||||
return fixup | (systemflags & modkeep)
|
||||
end
|
||||
//
|
||||
|
@ -1113,6 +1113,10 @@ def loadmod(mod)#1
|
||||
return -perr
|
||||
fin
|
||||
//
|
||||
// Free up rld+esd (and bytecode on 128K) in main memory.
|
||||
//
|
||||
releaseheap(modend)
|
||||
//
|
||||
// Call init routine if it exists.
|
||||
//
|
||||
fixup = 0 // This is repurposed for the return code
|
||||
@ -1125,7 +1129,10 @@ def loadmod(mod)#1
|
||||
if defbank
|
||||
xheap = init - defofst + defaddr
|
||||
else
|
||||
modend = init - defofst + defaddr
|
||||
//
|
||||
// Free up init code in main memory.
|
||||
//
|
||||
releaseheap(init - defofst + defaddr)
|
||||
fin
|
||||
if fixup < 0
|
||||
perr = -fixup
|
||||
@ -1134,10 +1141,6 @@ def loadmod(mod)#1
|
||||
fixup = fixup & ~modinitkeep
|
||||
fin
|
||||
fin
|
||||
//
|
||||
// Free up the end-of-module in main memory.
|
||||
//
|
||||
releaseheap(modend)
|
||||
return fixup
|
||||
end
|
||||
//
|
||||
@ -1378,7 +1381,11 @@ while 1
|
||||
is '+'
|
||||
saveX
|
||||
execmod(striptrail(@cmdln))
|
||||
//
|
||||
// Clean up
|
||||
//
|
||||
restoreX
|
||||
resetmemfiles
|
||||
break
|
||||
otherwise
|
||||
cout('?')
|
||||
|
Loading…
x
Reference in New Issue
Block a user