<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Jan 29, 2014 at 12:14 PM, Jecel Assumpcao Jr. <span dir="ltr">&lt;<a href="mailto:jecel@merlintec.com" target="_blank">jecel@merlintec.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div class="im">Frank Shearar wrote:<br>
<br>
&gt; A little bit of digging reveals this:<br>
&gt; <a href="https://web.archive.org/web/20090122105548/http://talklikeaduck.denhaven2.com/articles/2008/10/15/will-it-go-round-in-circles" target="_blank">https://web.archive.org/web/20090122105548/http://talklikeaduck.denhaven2.com/articles/2008/10/15/will-it-go-round-in-circles</a><br>

&gt; which looks like it was written by Rick DeNatale (judging by the &quot;I<br>
&gt; served as the secretary of X3J20.&quot; sentence.)<br>
<br>
</div>Thanks for the information! I was aware of Smalltalk/X using dual<br>
bytecode sets but didn&#39;t know it had been done previously. Allowing<br>
multiple bytecodes is one of the features planned for Cog, right? </blockquote><div><br></div><div>Cog already supports multiple bytecode sets.  The current compiled method header format has only space for a single bit so Cog currently supprts two bytecode sets.  The Squeak VMs support only the current Squeak V3 + closures bytecode set (see EncoderForV3PlusClosures).</div>
<div><br></div><div>Teh Newspeak VMs support that, extended with two bytecodes for the old Newspeak implementation, and a new bytecode set that I designed for Newspeak that supports absent receiver sends.  It&#39;s very much a first cut and we may do more bytecode sets.  In a Newspeak image look for EncoderForNewsqueakV4, and in the VMMaker package look for initializeBytecodeTableForNewspeakV4</div>
<div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">My own<br>
design allows multiple bytecodes but it is very costly to switch between<br>
them.<br></blockquote><div><br></div><div>Why is it costly?</div><div><br></div><div>In Cog it is essentially free in the JIT, and in the interpreter it is a matter of testing a flag on method activation and return and setting the bytecode set offset as a result.  I&#39;m grateful to Claus Gittinger for this technique.</div>
<div><br></div><div>So in the Cog Newspeak Interpreter the bytecode dispatch case statement has 512 entries, 256 for the Squeak V3 + Closures + Newspeak set, and 256 for the NewsqueakV4 set.  The dispatch looks like</div>
<div><br></div><div><div>fetchNextBytecode</div><div><span class="" style="white-space:pre">        </span>&quot;This method fetches the next instruction (bytecode). Each bytecode method is responsible for fetching the next bytecode, preferably as early as possible to allow the memory system time to process the request before the next dispatch.&quot;</div>
<div><br></div><div><span class="" style="white-space:pre">        </span>self cppIf: MULTIPLEBYTECODESETS</div><div><span class="" style="white-space:pre">                </span>ifTrue: [currentBytecode := self fetchByte + bytecodeSetSelector]</div>
<div><span class="" style="white-space:pre">                </span>ifFalse: [currentBytecode := self fetchByte]</div></div><div><br></div><div><div>setMethod: aMethodObj</div><div><span class="" style="white-space:pre">        </span>&quot;Set the method and determine the bytecode set based on the method header&#39;s sign.</div>
<div><span class="" style="white-space:pre">        </span> If MULTIPLEBYTECODESETS then a negative header selects the alternate bytecode set.</div><div><span class="" style="white-space:pre">        </span> Conditionalizing the code on MULTIPLEBYTECODESETS allows the header sign bit to be</div>
<div><span class="" style="white-space:pre">        </span> used for other experiments.&quot;</div><div><span class="" style="white-space:pre">        </span>&lt;inline: true&gt;</div><div><span class="" style="white-space:pre">        </span>method := aMethodObj.</div>
<div><span class="" style="white-space:pre">        </span>self assert: (objectMemory isOopCompiledMethod: method).</div><div><span class="" style="white-space:pre">        </span>self cppIf: MULTIPLEBYTECODESETS</div><div><span class="" style="white-space:pre">                </span>ifTrue: [bytecodeSetSelector := (self methodUsesAlternateBytecodeSet: method)</div>
<div><span class="" style="white-space:pre">                                                                                        </span>ifTrue: [256]</div><div><span class="" style="white-space:pre">                                                                                        </span>ifFalse: [0]]</div></div><div><br></div><div>where setMethod: is called on return, and its close twin setMethod:methodHeader: is called on frame build.</div>
</div>-- <br>best,<div>Eliot</div>
</div></div>