<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div>Tomas,</div><div><br></div><div>The "size" of the heap record, as specified in the type descriptor, needs to satisfy certain criteria, in order for Kernel.New to work:</div><div>a) it must include 8 bytes for the two hidden fields 'mk' and 'tag'</div><div>b) the total must be 32, 64, 128 or n*256 bytes long.</div><div><br></div><div><br></div><div>See module Memory.Mod on </div><div><br></div><div><a href="https://github.com/andreaspirklbauer/Oberon-generic-heap-allocation/blob/master/Sources/OriginalOberon2013/Memory.Mod">https://github.com/andreaspirklbauer/Oberon-generic-heap-allocation</a></div><div><br></div><div>to see how this can be done (first three lines of procedures Memory.New).</div><div><br></div><div>It's essential (!) to set size correctly, otherwise the garbage collector gets confused, as becomes evident when studying the code for procedures Kernel.Mark and Kernel.Scan (which obtains the size if a heap record by inspecting the size field in the type descriptor). If it's not a valid size, Kernel.Scan will insert it in the "n*256" list without the record actually being a multiple of 256. Bad!</div><div><br></div><div><br></div><div><h1><font size="3"><span style="background-color: rgba(255, 255, 255, 0);">[Oberon] Fw: FPGA - Bitmaps.Mod</span></font></h1><span style="background-color: rgba(255, 255, 255, 0);"><b>Tomas Kral</b> <a href="mailto:oberon%40lists.inf.ethz.ch?Subject=Re:%20Re%3A%20%5BOberon%5D%20Fw%3A%20FPGA%20-%20Bitmaps.Mod&In-Reply-To=%3C20170419125309.3a4aa4d3%40raspberrypi%3E" title="[Oberon] Fw: FPGA - Bitmaps.Mod">thomas.kral at email.cz </a><br><i>Wed Apr 19 12:53:09 CEST 2017</i></span><p></p><ul><li><span style="background-color: rgba(255, 255, 255, 0);">Previous message: <a href="http://lists.inf.ethz.ch/pipermail/oberon/2017/010478.html">[Oberon] Fw: FPGA - Bitmaps.Mod</a></span></li><li><span style="background-color: rgba(255, 255, 255, 0);">Next message: <a href="http://lists.inf.ethz.ch/pipermail/oberon/2017/010480.html">[Oberon] FPGA - Naming Conventions</a></span></li><li><span style="background-color: rgba(255, 255, 255, 0);"><b>Messages sorted by:</b> <a href="http://lists.inf.ethz.ch/pipermail/oberon/2017/date.html#10510">[ date ]</a> <a href="http://lists.inf.ethz.ch/pipermail/oberon/2017/thread.html#10510">[ thread ]</a> <a href="http://lists.inf.ethz.ch/pipermail/oberon/2017/subject.html#10510">[ subject ]</a> <a href="http://lists.inf.ethz.ch/pipermail/oberon/2017/author.html#10510">[ author ]</a></span></li></ul><hr><pre><font face="UICTFontTextStyleBody"><span style="white-space: normal; background-color: rgba(255, 255, 255, 0);">Hi Andreas, Joerg,
I have tried both methods suggested here.
(a) without tag declaration, simply calling
Kernel.New(b.base, SYSTEM.ADR(b.size));
(b) with tag declaration and persistence
tag.size := <size of your object to be allocated>;
tag.ext[0] := 0; tag.ext[1] := 0; tag.ext[2] := 0;
tag.ptr := -1;
Kernel.New(b.base, SYSTEM.ADR(tag.size))
They both seem to allocate a block of requested size, however when GC is
run, sometimes heap is inconsistent and `System.Watch' reports strange</span></font></pre></div><div><br><div>Sent from my iPhone</div></div></body></html>