From: Ralph Ronnquist Date: Mon, 29 Dec 2025 22:27:44 +0000 (+1100) Subject: BUG fix: avoid cycling unless needed X-Git-Url: https://git.rrq.au/?a=commitdiff_plain;h=refs%2Fheads%2Fmaster;p=rrq%2Frrqforth.git BUG fix: avoid cycling unless needed --- diff --git a/temp.asm b/temp.asm index 932b1bb..8931fd4 100644 --- a/temp.asm +++ b/temp.asm @@ -21,31 +21,36 @@ dq 0 ; [24] Currently held. WORD p_temp,'TEMP',fasm - ;; ( size -- addr ) - ;; Allocate an object of given size + ;; ( n -- a ; allocate a temp region of given size ) pushr rsi cmp qword [p_objectspace_DFA+8],0 - jg p_objecthole_initialized - ;; initialize object space + jg p_temp_initialized push qword [p_objectspace_DFA] DOFORTH p_malloc pop qword [p_objectspace_DFA+8] -p_objecthole_initialized: +p_temp_initialized: + ;;-- temp space is initialised (allocated) + ;;---- first test for a possible "forced cycling", in case + ;;---- TEMPHELD@ has been moved above TEMPUSED@. mov rax,qword [p_tempheld_DFA] cmp rax,qword [p_tempused_DFA] - jl p_objecthole_recycle + jg p_temp_cycle +p_temp_checklimit: + ;;-- consider using object at TEMPUSED@ mov rax,qword [rsp] add rax,qword [p_tempused_DFA] cmp rax,qword [p_objectspace_DFA] - jl p_objecthole_from_tail + jl p_temp_from_tail ; jmp = tail is large enough +p_temp_cycle: + ;;-- recycle temp space from TEMPHELD@ mov rax,qword [p_tempheld_DFA] ; cycling back to here -p_objecthole_recycle: mov qword [p_tempused_DFA],rax add rax,qword [rsp] -p_objecthole_from_tail: + ;;-- note that possible tail overflow is ignored here!! +p_temp_from_tail: ;; rax = new usage count mov rbx,qword [p_tempused_DFA] - add rbx,qword [p_objectspace_DFA+8] + add rbx,qword [p_objectspace_DFA+8] ; form actual pointer mov qword [rsp],rbx mov qword [p_tempused_DFA],rax popr rsi