<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office"><head><!--[if gte mso 9]><xml><o:OfficeDocumentSettings><o:AllowPNG/><o:PixelsPerInch>96</o:PixelsPerInch></o:OfficeDocumentSettings></xml><![endif]--></head><body><div style="color:#000; background-color:#fff; font-family:Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:13px"><div id="yui_3_16_0_ym19_1_1491976323382_20833"><span id="yui_3_16_0_ym19_1_1491976323382_20993">PS: There is a small proof-of-concept for a *generic* heap allocation routine New(ptr, size) that accepts a 'size' argument:</span></div><div id="yui_3_16_0_ym19_1_1491976323382_20833"><span><br></span></div><div id="yui_3_16_0_ym19_1_1491976323382_20833"><span><br></span></div><div id="yui_3_16_0_ym19_1_1491976323382_20833" dir="ltr"><span id="yui_3_16_0_ym19_1_1491976323382_21043"><a href="https://github.com/andreaspirklbauer/Oberon-generic-heap-allocation" class="enhancr2_0588d8eb-77cc-2bb9-a10b-a4aa8c71f912" id="yui_3_16_0_ym19_1_1491976323382_21042">andreaspirklbauer/Oberon-generic-heap-allocation</a> <br></span></div><div id="yui_3_16_0_ym19_1_1491976323382_21070"><br></div><div id="yui_3_16_0_ym19_1_1491976323382_21144"><br></div><div class="qtdSeparateBR" id="yui_3_16_0_ym19_1_1491976323382_20834" dir="ltr">It resembles the code in Bitmaps.Mod (and could be used within it).</div><div class="qtdSeparateBR" id="yui_3_16_0_ym19_1_1491976323382_20834" dir="ltr"><br></div><div class="qtdSeparateBR" id="yui_3_16_0_ym19_1_1491976323382_20834" dir="ltr">Andreas</div><div class="qtdSeparateBR" id="yui_3_16_0_ym19_1_1491976323382_20834" dir="ltr"><br></div><div class="qtdSeparateBR" id="yui_3_16_0_ym19_1_1491976323382_20834" dir="ltr"><br></div><div class="yahoo_quoted" id="yui_3_16_0_ym19_1_1491976323382_21110" style="display: block;">  <div style="font-family: Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-size: 13px;" id="yui_3_16_0_ym19_1_1491976323382_21109"> <div style="font-family: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-size: 16px;" id="yui_3_16_0_ym19_1_1491976323382_21108"> <div dir="ltr" id="yui_3_16_0_ym19_1_1491976323382_21107"> <font size="2" face="Arial" id="yui_3_16_0_ym19_1_1491976323382_21111"> <hr size="1" id="yui_3_16_0_ym19_1_1491976323382_21145"> <b id="yui_3_16_0_ym19_1_1491976323382_22044"><span style="font-weight:bold;" id="yui_3_16_0_ym19_1_1491976323382_22043">From:</span></b> Jörg Straube <joerg.straube@iaeth.ch><br> <b><span style="font-weight: bold;">To:</span></b> Andreas Pirklbauer <andreas_pirklbauer@yahoo.com>; ETH Oberon and related systems <oberon@lists.inf.ethz.ch> <br> <b><span style="font-weight: bold;">Sent:</span></b> Wednesday, April 12, 2017 8:05 AM<br> <b><span style="font-weight: bold;">Subject:</span></b> Re: [Oberon] Fw: FPGA - Bitmaps.Mod<br> </font> </div> <div class="y_msg_container" id="yui_3_16_0_ym19_1_1491976323382_21921"><br><div id="yiv9721617853"><div id="yui_3_16_0_ym19_1_1491976323382_21920"><div dir="ltr" id="yui_3_16_0_ym19_1_1491976323382_21919"><div id="yui_3_16_0_ym19_1_1491976323382_22002">Hi Tomas</div><div id="yui_3_16_0_ym19_1_1491976323382_22197"><br clear="none"></div><div id="yui_3_16_0_ym19_1_1491976323382_21918">I refined the module "Bitmaps" a little bit. This code allocates variably sized bitmaps and makes sure the garbage collector collects them if no longer referenced. As Andreas pointed out: it is the responsibility of the module using "Bitmaps" to make the bitmaps globally reachable. If not, the allocated memory gets freed up more or less immediately...</div><div id="yui_3_16_0_ym19_1_1491976323382_22139"><br clear="none"></div><div>I compiled the code with the emulator on a Mac</div><div><br clear="none"></div><div id="yui_3_16_0_ym19_1_1491976323382_21922">MODULE Bitmaps; (* jr/11apr17 *)</div><div id="yui_3_16_0_ym19_1_1491976323382_22141"><br clear="none"></div><div>IMPORT SYSTEM, Kernel := KernelOSX;</div><div id="yui_3_16_0_ym19_1_1491976323382_22143"><br clear="none"></div><div id="yui_3_16_0_ym19_1_1491976323382_21924">TYPE</div><div id="yui_3_16_0_ym19_1_1491976323382_21926"><span class="yiv9721617853gmail-Apple-tab-span" style="white-space:pre;">  </span>TypeTag = RECORD size, ext1, ext2, ext3, offset: INTEGER END;<span style="white-space:pre;"> </span>(* see Project Oberon, figure 8.8 *)</div><div id="yui_3_16_0_ym19_1_1491976323382_21928"><span class="yiv9721617853gmail-Apple-tab-span" style="white-space:pre;"> </span>Address = POINTER TO RECORD END;<span class="yiv9721617853gmail-Apple-tab-span" style="white-space:pre;">                           </span>(* this pointer will be redefined by TypeTag *)</div><div id="yui_3_16_0_ym19_1_1491976323382_22145"><span class="yiv9721617853gmail-Apple-tab-span" style="white-space:pre;">  </span>Bitmap* = POINTER TO RECORD</div><div id="yui_3_16_0_ym19_1_1491976323382_22147"><span class="yiv9721617853gmail-Apple-tab-span" style="white-space:pre;">         </span>width, height: INTEGER;</div><div id="yui_3_16_0_ym19_1_1491976323382_21931"><span class="yiv9721617853gmail-Apple-tab-span" style="white-space:pre;">             </span>tag: TypeTag;<span class="yiv9721617853gmail-Apple-tab-span" style="white-space:pre;" id="yui_3_16_0_ym19_1_1491976323382_21930">                                                      </span><span style="white-space:pre;">    </span><span class="yiv9721617853gmail-Apple-tab-span" style="white-space:pre;">          </span>(* type descriptor of the pointer "base" *)</div><div id="yui_3_16_0_ym19_1_1491976323382_22149"><span class="yiv9721617853gmail-Apple-tab-span" style="white-space:pre;">             </span>base: Address</div><div><span class="yiv9721617853gmail-Apple-tab-span" style="white-space:pre;">    </span>END;</div><div id="yui_3_16_0_ym19_1_1491976323382_21933"><br clear="none"></div><div><br clear="none"></div><div id="yui_3_16_0_ym19_1_1491976323382_22151">PROCEDURE New*(w, h: INTEGER): Bitmap;</div><div><span class="yiv9721617853gmail-Apple-tab-span" style="white-space:pre;">      </span>VAR b: Bitmap;</div><div><span class="yiv9721617853gmail-Apple-tab-span" style="white-space:pre;">   </span>BEGIN</div><div><span class="yiv9721617853gmail-Apple-tab-span" style="white-space:pre;">            </span>NEW(b);</div><div><span class="yiv9721617853gmail-Apple-tab-span" style="white-space:pre;">          </span>IF b # NIL THEN</div><div id="yui_3_16_0_ym19_1_1491976323382_21935"><span class="yiv9721617853gmail-Apple-tab-span" style="white-space:pre;">                     </span>b.width := w; b.height := h;</div><div><br clear="none"></div><div id="yui_3_16_0_ym19_1_1491976323382_22153"><span class="yiv9721617853gmail-Apple-tab-span" style="white-space:pre;">                        </span>(* the following code defines a type tag corresponding to ARRAY size OF BYTE *)</div><div id="yui_3_16_0_ym19_1_1491976323382_21937"><br clear="none"></div><div id="yui_3_16_0_ym19_1_1491976323382_22156"><span class="yiv9721617853gmail-Apple-tab-span" style="white-space:pre;">                        </span>b.tag.size := (w+7) DIV 8 * h;<span class="yiv9721617853gmail-Apple-tab-span" style="white-space:pre;" id="yui_3_16_0_ym19_1_1491976323382_22155">                                               </span>(* size of the bitmap in BYTEs *)</div><div><span class="yiv9721617853gmail-Apple-tab-span" style="white-space:pre;">                      </span>b.tag.offset := -1;<span class="yiv9721617853gmail-Apple-tab-span" style="white-space:pre;">                                             </span>  (* type has no pointers, important for GC *)</div><div><span class="yiv9721617853gmail-Apple-tab-span" style="white-space:pre;">                      </span>(* allocate memory and define its type *)</div><div id="yui_3_16_0_ym19_1_1491976323382_22179"><span style="white-space:pre;">                       </span>Kernel.New(SYSTEM.VAL(INTEGER, b.base), SYSTEM.ADR(b.tag));  </div><div><br clear="none"></div><div id="yui_3_16_0_ym19_1_1491976323382_21939"><span class="yiv9721617853gmail-Apple-tab-span" style="white-space:pre;">                  </span>IF b.base = NIL THEN b := NIL END</div><div><span class="yiv9721617853gmail-Apple-tab-span" style="white-space:pre;">                </span>END</div><div><span class="yiv9721617853gmail-Apple-tab-span" style="white-space:pre;">      </span>RETURN b</div><div><span class="yiv9721617853gmail-Apple-tab-span" style="white-space:pre;"> </span>END New;</div><div><br clear="none"></div><div>END Bitmaps.</div><div><br clear="none"></div><div id="yui_3_16_0_ym19_1_1491976323382_22178">System.Free Bitmaps ~</div><div id="yui_3_16_0_ym19_1_1491976323382_22177">ORP.Compile Bitmaps.Mod ~</div><div id="yui_3_16_0_ym19_1_1491976323382_22176"><br clear="none"></div></div><div class="yiv9721617853gmail_extra" id="yui_3_16_0_ym19_1_1491976323382_22175"><br clear="none"><div class="yiv9721617853gmail_quote">2017-04-07 17:41 GMT+02:00 Andreas Pirklbauer <span dir="ltr"><<a rel="nofollow" shape="rect" ymailto="mailto:andreas_pirklbauer@yahoo.com" target="_blank" href="mailto:andreas_pirklbauer@yahoo.com">andreas_pirklbauer@yahoo.com</a>></span>:<br clear="none"><blockquote class="yiv9721617853gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="yiv9721617853yqt5219242860" id="yiv9721617853yqt66539"><div><div style="color:#000;background-color:#fff;font-family:Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:13px;"><div dir="ltr" id="yiv9721617853m_6372015898147730019yui_3_16_0_ym19_1_1491579440053_2868"><span id="yiv9721617853m_6372015898147730019yui_3_16_0_ym19_1_1491579440053_2983">To be precise:</span></div><div dir="ltr" id="yiv9721617853m_6372015898147730019yui_3_16_0_ym19_1_1491579440053_2868"><span><br clear="none"></span></div><div dir="ltr" id="yiv9721617853m_6372015898147730019yui_3_16_0_ym19_1_1491579440053_2868"><span id="yiv9721617853m_6372015898147730019yui_3_16_0_ym19_1_1491579440053_3116">If you don't make dynamically allocated objects reachable via at least one global pointer variable, they simply won't be marked during the mark phase of the garbage collector, which means that they *will* be collected during the subsequent scan phase. That's the whole point of garbage collection...</span></div><div class="yiv9721617853m_6372015898147730019qtdSeparateBR" id="yiv9721617853m_6372015898147730019yui_3_16_0_ym19_1_1491579440053_2931"><br clear="none"><br clear="none"></div><div class="yiv9721617853m_6372015898147730019qtdSeparateBR" id="yiv9721617853m_6372015898147730019yui_3_16_0_ym19_1_1491579440053_2931"><br clear="none"></div><div class="yiv9721617853m_6372015898147730019yahoo_quoted" id="yiv9721617853m_6372015898147730019yui_3_16_0_ym19_1_1491579440053_2872" style="display:block;">  <div id="yiv9721617853m_6372015898147730019yui_3_16_0_ym19_1_1491579440053_2871" style="font-family:Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:13px;"> <div id="yiv9721617853m_6372015898147730019yui_3_16_0_ym19_1_1491579440053_2870" style="font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:16px;"> <div dir="ltr" id="yiv9721617853m_6372015898147730019yui_3_16_0_ym19_1_1491579440053_2869"> <font id="yiv9721617853m_6372015898147730019yui_3_16_0_ym19_1_1491579440053_2873" size="2" face="Arial"> </font><hr id="yiv9721617853m_6372015898147730019yui_3_16_0_ym19_1_1491579440053_2909" size="1"> <b><span style="font-weight:bold;">From:</span></b> Andreas Pirklbauer <<a rel="nofollow" shape="rect" ymailto="mailto:andreas_pirklbauer@yahoo.com" target="_blank" href="mailto:andreas_pirklbauer@yahoo.com">andreas_pirklbauer@yahoo.com</a>><br clear="none"> <b><span style="font-weight:bold;">To:</span></b> ETH Oberon and Related Systems <<a rel="nofollow" shape="rect" ymailto="mailto:oberon@lists.inf.ethz.ch" target="_blank" href="mailto:oberon@lists.inf.ethz.ch">oberon@lists.inf.ethz.ch</a>> <br clear="none"><b><span style="font-weight:bold;">Cc:</span></b> Andreas Pirklbauer <<a rel="nofollow" shape="rect" ymailto="mailto:andreas_pirklbauer@yahoo.com" target="_blank" href="mailto:andreas_pirklbauer@yahoo.com">andreas_pirklbauer@yahoo.com</a>><br clear="none"> <b><span style="font-weight:bold;">Sent:</span></b> Friday, April 7, 2017 5:35 PM<br clear="none"> <b><span style="font-weight:bold;">Subject:</span></b> [Oberon] Fw: FPGA - Bitmaps.Mod<br clear="none">  </div> <div class="yiv9721617853m_6372015898147730019y_msg_container" id="yiv9721617853m_6372015898147730019yui_3_16_0_ym19_1_1491579440053_2932"><br clear="none"><div id="yiv9721617853m_6372015898147730019yiv0560424603"><div id="yiv9721617853m_6372015898147730019yui_3_16_0_ym19_1_1491579440053_2934"><div id="yiv9721617853m_6372015898147730019yui_3_16_0_ym19_1_1491579440053_2933" style="color:#000;background-color:#fff;font-family:Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:13px;"><div id="yiv9721617853m_6372015898147730019yiv0560424603yui_3_16_0_ym19_1_1491577030619_2588">...</div><span class="yiv9721617853"></span><div dir="ltr" id="yiv9721617853m_6372015898147730019yiv0560424603yui_3_16_0_ym19_1_1491577030619_2588"><br clear="none"></div><div dir="ltr" id="yiv9721617853m_6372015898147730019yiv0560424603yui_3_16_0_ym19_1_1491577030619_2588">4. If you want your objects to be automatically collected by the Oberon garbage collector, you must make it globally reachable via a global pointer. Then they will appear in mod.ptr in the module block which are used as roots for the garbage collector. (Oberon uses all named pointer variables in existence as roots<font id="yiv9721617853m_6372015898147730019yiv0560424603yui_3_16_0_ym19_1_1491577030619_5223" face="ArialMT" size="2"> for the mark phase of the garbage collector. See Oberon.GC for the details. It simply calls Kernel.Mark(mod.ptr) for each loaded module mod.</font></div><div dir="ltr" id="yiv9721617853m_6372015898147730019yiv0560424603yui_3_16_0_ym19_1_1491577030619_2588"><font face="ArialMT" size="2"><br clear="none"></font></div><div dir="ltr" id="yiv9721617853m_6372015898147730019yiv0560424603yui_3_16_0_ym19_1_1491577030619_2588"><br clear="none"></div><div id="yiv9721617853m_6372015898147730019yiv0560424603yui_3_16_0_ym19_1_1491577030619_4475" title="Page 106" title-off=""><div id="yiv9721617853m_6372015898147730019yiv0560424603yui_3_16_0_ym19_1_1491577030619_4476"><div id="yiv9721617853m_6372015898147730019yiv0560424603yui_3_16_0_ym19_1_1491577030619_4477"><div id="yiv9721617853m_6372015898147730019yiv0560424603yui_3_16_0_ym19_1_1491577030619_4496" title="Page 106" title-off=""><div id="yiv9721617853m_6372015898147730019yiv0560424603yui_3_16_0_ym19_1_1491577030619_4497"><div id="yiv9721617853m_6372015898147730019yiv0560424603yui_3_16_0_ym19_1_1491577030619_4498"><div id="yiv9721617853m_6372015898147730019yiv0560424603yui_3_16_0_ym19_1_1491577030619_4517" title="Page 106" title-off=""><div id="yiv9721617853m_6372015898147730019yiv0560424603yui_3_16_0_ym19_1_1491577030619_4518"><div id="yiv9721617853m_6372015898147730019yiv0560424603yui_3_16_0_ym19_1_1491577030619_4519">
                
        
        
                <div id="yiv9721617853m_6372015898147730019yiv0560424603yui_3_16_0_ym19_1_1491577030619_4538" title="Page 106" title-off="">
                        <div id="yiv9721617853m_6372015898147730019yiv0560424603yui_3_16_0_ym19_1_1491577030619_4539">
                                <div id="yiv9721617853m_6372015898147730019yiv0560424603yui_3_16_0_ym19_1_1491577030619_4540">
                                        <div dir="ltr" id="yiv9721617853m_6372015898147730019yiv0560424603yui_3_16_0_ym19_1_1491577030619_4541"><span id="yiv9721617853m_6372015898147730019yiv0560424603yui_3_16_0_ym19_1_1491577030619_4542" style="font-size:10.000000pt;font-family:'ArialMT';"> <br clear="none" id="yiv9721617853m_6372015898147730019yiv0560424603yui_3_16_0_ym19_1_1491577030619_4543"></span></div>
                                </div>
                        </div>
                </div>
                                </div>
                        </div>
                </div>
                                </div>
                        </div>
                </div>
                                </div>
                        </div>
                </div></div></div></div><br clear="none"><br clear="none"></div> </div> </div>  </div></div></div></div><br clear="none">--<br clear="none">
<a rel="nofollow" shape="rect" ymailto="mailto:Oberon@lists.inf.ethz.ch" target="_blank" href="mailto:Oberon@lists.inf.ethz.ch">Oberon@lists.inf.ethz.ch</a> mailing list for ETH Oberon and related systems<br clear="none">
<a rel="nofollow" shape="rect" target="_blank" href="https://lists.inf.ethz.ch/mailman/listinfo/oberon">https://lists.inf.ethz.ch/ mailman/listinfo/oberon</a><br clear="none">
<br clear="none"></blockquote></div><br clear="none"></div></div></div><br><br></div> </div> </div>  </div></div></body></html>