From b5eb726b2563c979cb31859f26ea10a039ec23bd Mon Sep 17 00:00:00 2001 From: Martin Haye Date: Wed, 2 Sep 2015 10:16:39 -0700 Subject: [PATCH] Heap testing going well. --- Platform/Apple/virtual/src/core/mem.s | 18 ++++++++---------- Platform/Apple/virtual/src/plasma/gameloop.pla | 3 ++- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/Platform/Apple/virtual/src/core/mem.s b/Platform/Apple/virtual/src/core/mem.s index 2bec0df4..00764bb6 100644 --- a/Platform/Apple/virtual/src/core/mem.s +++ b/Platform/Apple/virtual/src/core/mem.s @@ -300,9 +300,9 @@ init: !zone sty tSegAdrHi+3 dey sty tSegAdrHi+7 - lda #paramsEnd + lda #>lastLoMem sta tSegAdrHi+4 lda #$40 sta tSegAdrHi+5 @@ -795,8 +795,6 @@ setMarkPos: !byte 0 ; mark position (3 byte integer) closeParams: !byte 1 ; param count closeFileRef: !byte 0 ; file ref to close -paramsEnd = * - ;------------------------------------------------------------------------------ ; Heap management variables MAX_TYPES = 16 @@ -810,7 +808,6 @@ heapStartPg !byte 0 heapEndPg !byte 0 heapTop !word 0 gcHash_top !byte 0 -nHeapBlks !byte 0 ;------------------------------------------------------------------------------ ; Heap management routines @@ -835,7 +832,6 @@ heapSet: !zone sta heapEndPg lda #0 sta heapTop - sta nHeapBlks sta nTypes ; fall through to: ; Zero memory heapTop.heapEnd @@ -1155,12 +1151,13 @@ gc2_sweep: !zone rts heapCollect: !zone - lda nHeapBlks - bne + ; edge case: if nothing on heap, skip collection - rts -+ jsr gc1_mark ; mark reachable blocks + +prStr : !text "Phase 1.",0 + jsr gc1_mark ; mark reachable blocks + +prStr : !text "Phase 2.",0 jsr gc2_sweep ; sweep them into one place + +prStr : !text "Phase 3.",0 jsr gc3_fix ; adjust all pointers + +prStr : !text "Phase 4.",0 jsr heapClr ; and clear newly freed space lda #0 ; heap end lo always 0 sec @@ -1171,6 +1168,7 @@ heapCollect: !zone tay ; free space to X=lo/Y=hi rts +lastLoMem = * } ; end of !pseodupc $800 loMemEnd = * diff --git a/Platform/Apple/virtual/src/plasma/gameloop.pla b/Platform/Apple/virtual/src/plasma/gameloop.pla index 4c5b711b..584bf41c 100644 --- a/Platform/Apple/virtual/src/plasma/gameloop.pla +++ b/Platform/Apple/virtual/src/plasma/gameloop.pla @@ -1661,7 +1661,8 @@ def collect() checkHeapCounts() puts("Collecting garbage.\n") nFree = mmgr(HEAP_COLLECT, 0) - puts(" heap avail=%d\n", nFree) + printf1(" heap avail=$%x\n", nFree) + getUpperKey() end ///////////////////////////////////////////////////////////////////////////////////////////////////