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