On 4 December 2017 at 10:48, Eliot Miranda <[email protected]> wrote: > Hi Ben, > > On Sun, Dec 3, 2017 at 6:08 PM, Ben Coman <[email protected]> wrote: >> >> I'm shooting in the dark here since its a bit hard to grasp... >> a. The implications of support alternative bytecode sets >> * Do the alternative bytecode sets run in parallel to normal Pharo >> bytecodes? > > > Yes. There's a single bit in the header of a compiled method that selects > between two bytecode sets. In current Squeak and Pharoi VMs, if the bit is > unset then the normal bytecode set is used, and if the nit is set, the Sista > bytecode set is used.
That clarifies things a lot. So I guess the main advantage of this bit is making it easier to: a. incrementally develop and test new bytecodes? b. transition the Image between bytecode sets? >> * Can the bytecode sets be loaded adhoc/dynamically into an Image? >> or only compiled into the VM? > > > Only compiled into the VM. > >> >> b. How to implement/work with alternative bytecodes > > > In Squeak there are class-side accessors in CompiledCode. See CompiledCode > class>>installSecondaryBytecodeSet:. Note that the support isn't quite > finished yet. I hope to have the Sista vytecde set ready for the next > release of Squeak. Clément is providing it in Pharo. > > In Squeak the BytecodeEncoder hierarchy implements the necessary support for > multiple bytecode sets. Via CompiledCode > class>>installSecondaryBytecodeSet: the system is informed as to which > bytecode set to use. This must match the bytecode set(s) that are in the > VM. Classes beneath BytecodeEncoder, in particular EncoderForV3PlusClosures > and EncoderForSistaV1 (in package BytecodeSets at > http://source.squeak.org/VMMaker) encode the current and the Sista sets > respectively. Can more than two bytecode sets be compiled into the one VM? i.e. Is a bytecode-set hard coded into position, or is it more like a variable slot that can select between several bytecode sets compiled into the VM. For example, if someone wanted to experiment with implementing Ethereum bytecodes, would they first need to rip out either EncoderForV3PlusClosures or EncoderForSistaV1? Now I made the mistake once of thinking it was Sista introducing this bytecode-bit, (btw, how do you normally refer to it?) but IIUC Sista is just making use of the feature. So I'm curious historically when the bytecode-bit was introduced? cheers -ben > >> To help (b.), would it be feasible to blog a mini-demo showing how to >> install/use alternative bytecodes? maybe for something like this simple RPN >> calculator substitute for "arith.c"... >> * https://github.com/philipaconrad/mini-vm/tree/master/examples/arith >> * >> https://github.com/philipaconrad/mini-vm/blob/master/examples/arith/arith.c > > > That's not how this will work. Essentially it is transparent. Once the > bytecode set support is installed in the compiler one simply compiles > Smalltalk (or anything else that produces parse trees that can be output to > compiled methods via the BytecodeEncoder hierarchy) and the method will be > output in the currently selected bytecode set. So it's not something one > plays around with, unless that is, one is developing the bytecode set in the > Vm simulator.
