<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div dir="ltr"><span style="background-color: rgba(255, 255, 255, 0);">Hi Ben, Hi All,</span></div><div dir="ltr"><br>On Oct 30, 2018, at 7:34 AM, Eliot Miranda <<a href="mailto:eliot.miranda@gmail.com">eliot.miranda@gmail.com</a>> wrote:<br><br></div><blockquote type="cite"><div dir="ltr"><meta http-equiv="content-type" content="text/html; charset=utf-8"><div dir="ltr"><span></span></div><div dir="ltr"><meta http-equiv="content-type" content="text/html; charset=utf-8">Hi Ben,<div dir="ltr"><br>On Oct 30, 2018, at 6:26 AM, Ben Coman <<a href="mailto:btc@openinworld.com">btc@openinworld.com</a>> wrote:<br></div><blockquote type="cite"><div dir="ltr"><div dir="ltr"><br><div class="gmail_quote"><div dir="ltr">On Tue, 30 Oct 2018 at 20:22, Eliot Miranda <<a href="mailto:eliot.miranda@gmail.com">eliot.miranda@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> <div dir="auto">Hi Ben,<div dir="ltr"><br>On Oct 30, 2018, at 4:57 AM, Ben Coman <<a href="mailto:btc@openinworld.com" target="_blank">btc@openinworld.com</a>> wrote:<br><br></div><blockquote type="cite"><div dir="ltr"><span></span></div></blockquote><blockquote type="cite"><div dir="ltr"><div dir="ltr"><div dir="ltr">I'm sure this was explained somewhere before (even recently), <div>but I forget, and can't find anything in my usual search places.<div><br><div class="gmail_quote"><div dir="ltr">On Tue, 30 Oct 2018 at 09:02, <<a href="mailto:commits@source.squeak.org" target="_blank">commits@source.squeak.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"> <br>
Eliot Miranda uploaded a new version of VMMaker to project VM Maker:<br>
<a href="http://source.squeak.org/VMMaker/VMMaker.oscog-eem.2479.mcz" rel="noreferrer" target="_blank">http://source.squeak.org/VMMaker/VMMaker.oscog-eem.2479.mcz</a><br>
<br>
==================== Summary ====================<br>
<br>
Name: VMMaker.oscog-eem.2479<br>
Author: eem<br>
Time: 29 October 2018, 6:00:57.748695 pm<br>
UUID: b191888c-6777-483b-82b4-121103743ebf<br>
Ancestors: VMMaker.oscog-eem.2478<br>
<br>
Plugins:<br>
Fix slip in primitiveDirectoryDelimitor.<br>
Eliminate cCode:inSmalltalk:'s from the B3DAcceleratorPlugin<br>
<br>
=============== Diff against VMMaker.oscog-eem.2478 ===============<br><snip><br>
Item was changed:<br>
  ----- Method: B3DAcceleratorPlugin>>primitiveAllocateTexture (in category 'primitives-textures') -----<br>
  primitiveAllocateTexture<br>
        | h w d result renderer |<br>
        <export: true><br>
        interpreterProxy methodArgumentCount = 4<br>
                ifFalse:[^interpreterProxy primitiveFail].<br>
        h := interpreterProxy stackIntegerValue: 0.<br>
        w := interpreterProxy stackIntegerValue: 1.<br>
        d := interpreterProxy stackIntegerValue: 2.<br>
        renderer := interpreterProxy stackIntegerValue: 3.<br>
        interpreterProxy failed ifTrue:[^nil].<br>
+       result := self b3dxAllocateTexture: renderer _: w _: h _: d.<br>
-       result := self cCode:'b3dxAllocateTexture(renderer, w, h, d)' inSmalltalk:[-1].<br>
        result = -1 ifTrue:[^interpreterProxy primitiveFail].<br>
        interpreterProxy pop: 5. "args+rcvr"<br>
        ^interpreterProxy pushInteger: result.!<br></blockquote><div><br></div><div><br class="m_8335347200747766042gmail-Apple-interchange-newline">What is the mechanism that allows cCode:inSmalltalk:'s to be replaced like above?</div><div>I half expected  "b3dxAllocateTexture:_:_:_:"</div><div>to be newly defined somewhere else in that commit.</div></div></div></div></div></div></div></blockquote><div><br></div>Those implementations can come later.  Right now the plugin doesn’t simulate anyway.  You’re right I could have written them then and there, but I would rather do real o es than simple failing stubs.  If I find that I can’t simulate without stubs I’ll add them.  Feel free to provide them if you’re motivated.  I should have just fixed the digitCompare: issue but got carried away...</div></blockquote><div><br></div><div>I'm still missing something basic, but guessing... the "inSmalltalk:" part is what is performed by the simulator?</div></div></div></div></blockquote><div><br></div><span style="background-color: rgba(255, 255, 255, 0);">I’m sorry; yes.  Given</span><div><span style="background-color: rgba(255, 255, 255, 0);">    self cCode: stringOrBlock inSmalltalk: block</span></div><div><span style="background-color: rgba(255, 255, 255, 0);">the C translator will either emit stringOrBlock verbatim if stringOrBlock is a string, or emit the translation of stringOrBlock’s statements if it is a block.  The simulator simply evaluates block.  And the value of the expression is, effectively, the value of either block.</span></div><div><br></div><div><blockquote type="cite"><div dir="ltr"><div dir="ltr"><div class="gmail_quote"><div>and the "cCode:" is generated into a C-code-call that expects that function linked in from a library?</div></div></div></div></blockquote><div><br></div>More accurately <span style="background-color: rgba(255, 255, 255, 0);">stringOrBlock is arbitrary code.  Look for uses in BirBltSimulation and you’ll see the code for invoking the fast bitblt code for the Raspberry Pi.  This assigns parameters for a bitblt invocation to a struct.  One can define a struct in Smalltalk (VMStructType ? an approach I take for Cog method headers, stack pages, spur memory segments, etc) but Tim took the short cut of merely writing the verbatim C.</span></div><div><span style="background-color: rgba(255, 255, 255, 0);"><br></span></div><div><span style="background-color: rgba(255, 255, 255, 0);">One stereotypical use was to write the invocation of some platform support function and have the inSmalltalk: either simulate or answer a default value, and sometimes to reference variables used in the call but unused elsewhere, to avoid Smalltalk compiler earnings.  This is what we see here in the </span><span style="background-color: rgba(255, 255, 255, 0);">B3DAcceleratorPlugin.  But using a default value precludes simulation, and the code is ugly.  So I’ve started replacing as many cCode:inSmalltalk:’s with a message send where stringOrBlock is simply a call.  This is dependent on _: keyword support and the <doNotGenerate> pragma to instruct Slang not to generate the simulator implementation.  I added <doNotGenerate> several years ago; I added _: support a few weeks ago.</span></div><div><br><blockquote type="cite"><div dir="ltr"><div dir="ltr"><div class="gmail_quote"><div><br></div><div>and now there is no simulation and "b3dxAllocateTexture:_:_:_:" is generated to C-code-call?</div></div></div></div></blockquote><div><br></div>That would generate a call of <span style="background-color: rgba(255, 255, 255, 0);">b3dxAllocateTexture with the given arguments.</span></div><div><br><blockquote type="cite"><div dir="ltr"><div dir="ltr"><div class="gmail_quote"><div>So is there a mechanism that any unknown message (i.e. "b3dxAllocateTexture:_:_:_:") is generated to a C-code-call?</div></div></div></div></blockquote><div><br></div>Yes.  Look for <span style="background-color: rgba(255, 255, 255, 0);">VMMaker.oscog-eem.2440 and VMMaker.oscog-eem.2452.  And in general one can use </span></div><div><span style="background-color: rgba(255, 255, 255, 0);">    self foo: expr bar: rpxe </span></div><div><span style="background-color: rgba(255, 255, 255, 0);">to generate a call of foobar.  I simply added stripping out of _:, which means not having to split a call across several keywords; much more readable.</span></div></div></div></blockquote><div><br></div>It might be useful to capture this “documentation” and the <span style="background-color: rgba(255, 255, 255, 0);">documentation</span> elsewhere (eg on the Squeak wiki) and include it in help in the package.  Anyone who has energy for this is very welcome to help.<div><br><blockquote type="cite"><div dir="ltr"><div dir="ltr"><div><blockquote type="cite"><div dir="ltr"><div dir="ltr"><div class="gmail_quote"><div>cheers -ben</div></div></div>
</div></blockquote></div></div></div></blockquote></div></body></html>