From: Ralph Ronnquist Date: Tue, 15 Jun 2021 04:29:48 +0000 (+1000) Subject: introduced a hold area for temp space X-Git-Url: https://git.rrq.au/?a=commitdiff_plain;h=6234f75b32f6113896d6b15c79fb29d5c7ccb79c;p=rrq%2Frrqforth.git introduced a hold area for temp space --- diff --git a/adoc/p_tempheld.adoc b/adoc/p_tempheld.adoc new file mode 100644 index 0000000..4233b2c --- /dev/null +++ b/adoc/p_tempheld.adoc @@ -0,0 +1,15 @@ +// temp.asm: WORD p_tempheld,'TEMPHELD',dovariable + +anchor:p_tempheld[] + +=== Word: TEMPHELD + +.... +Data stack: ( -- a ) +.... + +"TEMPHELD" is a variable word that keeps the lowest offset of the +<> space to reuse upon cycling. The space +below TEMPHELD is "held" in the sense of not being reused upon +cycling. An application may change the TEMPSPACE offset as needed to +dynamically preserve memory longer term. diff --git a/reference.adoc b/reference.adoc index 1d9f60e..e48dbd7 100644 --- a/reference.adoc +++ b/reference.adoc @@ -293,6 +293,8 @@ include::adoc/p_tell.adoc[] include::separator.adoc[] include::adoc/p_temp.adoc[] include::separator.adoc[] +include::adoc/p_tempheld.adoc[] +include::separator.adoc[] include::adoc/p_tempspace.adoc[] include::separator.adoc[] include::adoc/p_terminate0.adoc[] diff --git a/temp.asm b/temp.asm index 8e0be25..7ece590 100644 --- a/temp.asm +++ b/temp.asm @@ -1,16 +1,23 @@ -;;; Managing a memory area for temporary objects -;;; -;;; A temporary object space is allocated from the current usage -;;; level, or cycling back to be from the lowest space address when -;;; the requested size exceeds the space edge. +;;; Managing a memory area for temporary "objects". ;;; +;;; Object space is allocated cyclically, starting subsequent to prior +;;; allocation and cycling back when requested object size exceeds +;;; the space edge. The "inital" part, which starts as empty, is +;;; considered "held" space that is not reused when cycling back, and +;;; apart from allowing for this, the space management is left open. + WORD p_objectspace,'TEMPSPACE',dovariable ;; Holds size and address of the object space. - dq 104857600 ; [0] Total object space size (request size) - dq 0 ; [8] Object space base address + dq 1073741824 ; [0] Total object space size (request size) + dq 0 ; [8] Object space base address. dq 0 ; [16] Currently used. + WORD p_tempheld,'TEMPHELD',dovariable + ;; ( -- a ) + ;; Marks the barrier for "held space" + dq 0 ; [24] Currently held. + WORD p_temp,'TEMP',fasm ;; ( size -- addr ) ;; Allocate an object of given size @@ -26,14 +33,15 @@ p_objecthole_initialized: add rax,qword [p_objectspace_DFA+16] cmp rax,qword [p_objectspace_DFA] jl p_objecthole_from_tail - mov qword [p_objectspace_DFA+16],0 - mov rax,qword [rsp] + mov rax,qword [p_tempheld_DFA] ; cycling back to here + mov qword [p_objectspace_DFA+16],rax + add rax,qword [rsp] p_objecthole_from_tail: ;; rax = new usage count mov rbx,qword [p_objectspace_DFA+16] - mov qword [p_objectspace_DFA+16],rax add rbx,qword [p_objectspace_DFA+8] mov qword [rsp],rbx + mov qword [p_objectspace_DFA+16],rax popr rsi next diff --git a/wordindex.adoc b/wordindex.adoc index e59bfaa..c30b9bf 100644 --- a/wordindex.adoc +++ b/wordindex.adoc @@ -167,6 +167,7 @@ xref:p_system[SYSTEM] {nbsp} xref:p_tell[TELL] {nbsp} xref:p_dot_temp[.TEMP] {nbsp} xref:p_temp.adoc[TEMP] {nbsp} +xref:p_tempheld.adoc[TEMPHELD] {nbsp} xref:p_tempspace[TEMPSPACE] {nbsp} xref:p_terminate0[TERMINATE0] {nbsp} xref:p_tfa2cfa[TFA>CFA] {nbsp}