[squeak-dev] java interpreter/compiler hosted with Spur?

Eliot Miranda eliot.miranda at gmail.com
Wed Jan 29 19:36:09 UTC 2014


On Wed, Jan 29, 2014 at 12:14 PM, Jecel Assumpcao Jr.
<jecel at merlintec.com>wrote:

> Frank Shearar wrote:
>
> > A little bit of digging reveals this:
> >
> https://web.archive.org/web/20090122105548/http://talklikeaduck.denhaven2.com/articles/2008/10/15/will-it-go-round-in-circles
> > which looks like it was written by Rick DeNatale (judging by the "I
> > served as the secretary of X3J20." sentence.)
>
> Thanks for the information! I was aware of Smalltalk/X using dual
> bytecode sets but didn't know it had been done previously. Allowing
> multiple bytecodes is one of the features planned for Cog, right?


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).

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'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


> My own
> design allows multiple bytecodes but it is very costly to switch between
> them.
>

Why is it costly?

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'm grateful to Claus Gittinger for this
technique.

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

fetchNextBytecode
"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."

self cppIf: MULTIPLEBYTECODESETS
ifTrue: [currentBytecode := self fetchByte + bytecodeSetSelector]
ifFalse: [currentBytecode := self fetchByte]

setMethod: aMethodObj
"Set the method and determine the bytecode set based on the method header's
sign.
 If MULTIPLEBYTECODESETS then a negative header selects the alternate
bytecode set.
 Conditionalizing the code on MULTIPLEBYTECODESETS allows the header sign
bit to be
 used for other experiments."
<inline: true>
method := aMethodObj.
self assert: (objectMemory isOopCompiledMethod: method).
self cppIf: MULTIPLEBYTECODESETS
ifTrue: [bytecodeSetSelector := (self methodUsesAlternateBytecodeSet:
method)
ifTrue: [256]
ifFalse: [0]]

where setMethod: is called on return, and its close twin
setMethod:methodHeader: is called on frame build.
-- 
best,
Eliot
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20140129/552d5e8c/attachment.htm


More information about the Squeak-dev mailing list