[Oberon] PO2013 - Show Heap Blocks

Tomas Kral thomas.kral at email.cz
Tue Jun 23 09:35:26 CEST 2020


Hi,

Trying to read heap allocation code, this bit allocates 32-bytes block, i.e.
32-8 bytes available to the user.

PROCEDURE GetBlock32(VAR p: LONGINT);
    VAR q: LONGINT;
  BEGIN
    IF list3 # 0 THEN p := list3; SYSTEM.GET(list3+8, list3)
    ELSE (*GetBlock64 and halve it*)
  END
END GetBlock32;

list3 points to the last free 32-block, it is a chain of 32-blocks going back to HeapOrg(60000H), third word storing list3 to one block earlier. -1 marking free block. 

32 -1 (previous list3) {byte#0}

Procedure above returns address of list3, and updates list3 to point to one block earlier, this ends when no other free block, list3 := 0.

Allocated block is zeroed incl. mark, storing tag.

32 (tag) (mark:=0) {0}

I do not see yet, which part of the code terminates the list with 0, where, when?

Peeking memory after boot.

 00060000 org
 0009FEF0 limit
 0006CBA0 0006CBC0 00000000 0006CC00
 list 3        2        1        0

dumping list3
0006CBA0   000146F0 00000000 00000001 00000006 00000001 000672E8 00000000 00000000

points to allocated block ???

with descriptor size 20H -1 -1 -1 0CH (offset) -1 (sentinel)
000146E0   0001A188 0001A18C 0001A244 F5B393A8 00000020 FFFFFFFF FFFFFFFF FFFFFFFF
00014700   0000000C FFFFFFFF

next alloc would read list3 with incorrect value!!!

NOTE 146E0H is part of TextFrames, and 146F0H descriptor is frequently reused.

Heap is initialised, entire free mem
60000H  (lim-org), -1, (list0 := 0)

-- 
Tomas Kral <thomas.kral at email.cz>


More information about the Oberon mailing list