<br><br><div class="gmail_quote">On Tue, Jul 1, 2008 at 12:49 PM, Bert Freudenberg &lt;<a href="mailto:bert@freudenbergs.de">bert@freudenbergs.de</a>&gt; wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Am 01.07.2008 um 21:25 schrieb Eliot Miranda:<div class="Ih2E3d"><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I would go further and rip out support for named primitives from the VM and put it up in the image where it belongs. &nbsp;I would build the machinery for looking up named primitives in the image and have a primitive that allowed one to slam a function address into a method.<br>

<br>
For me the VM should include an execution engine, a small and fast FFI and nothing else. &nbsp;One needs some VM support to bootstrap the FFI. &nbsp;i.e. the VM must include a primitive to load a platform library and another to lookup a name in it. &nbsp;But other than that everything can be up in the image. &nbsp;When one invokes a method with a primitive that has not been bound to a function yet then the primitive fails and the image&#39;s primitive failure code looks up the primitive&#39;s name and retries the call or reports an error if the library or name can&#39;t be found.<br>

</blockquote>
<br></div>
Well, until now FFI was intentionally optional. Making it mandatory would immensely widen the Smalltalk-System interface, in fact, there would be no clearly defined interface anymore. Until now, Squeak is a relatively safe place, bad crashes are rare etc. Whenever you deal with FFI the next crash is only minutes away. Also, you could expect that the image would soon fill up with lots of platform-specific code. But more importantly, it would make sand-boxing impossible, as any code in the image can do anything to your machine if it has access to FFI.<br>

<br>
So it would simplify the VM at the expense of added complexity in the image. Which may of course fit the bill for Croquet which already relies on FFI, and except for Etoys nobody really uses the sand boxing anyway.</blockquote>
<div><br><span class="Apple-style-span" style="border-collapse: collapse; "><div>One doesn&#39;t have to *use* the FFI. &nbsp; If the FFI isn&#39;t exposed via a primitive then no FFI. &nbsp;One can still have named primitives supported by the image and not by the VM and not use the FFI. &nbsp;To call a named primitive in a primitive plugin the following sequence occurs:</div>
<div><br></div><div>the method containing a named primitive spec is activated and the primitive call fails because its function pointer is null.</div><div>the failure code extracts the plugin name and invokes a primitive to load the plugin library</div>
<div>the failure code extracts the primitive name and uses the lookup primitive to find the function in the loaded plugin library</div><div>the failure code uses a primitive to slam the function pointer into the method</div>
<div>the failure code uses the executeMethodWithArgs primitive to retry the bound named primitive method</div><div><br></div><div>So the FFI is an optional extra. &nbsp;One needs four primitives, load library, lookup name in library, insert primitive function pointer. and executemethodWithArgs (thanks Tim!). &nbsp;Slamming the function into the method could also be done using, say, objectAt:.</div>
<div><br></div><div>So one can still have a nice small safe VM and have no direct support for named primitives in the VM.</div></span>&nbsp;</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br><font color="#888888">
<br>
- Bert -<br>
<br>
</font></blockquote></div><br>