To use the alternate bytecode set in Pharo 7 use: CompilationContext bytecodeBackend: EncoderForSistaV1. OpalCompiler recompileAll. based on:
https://clementbera.wordpress.com/2017/07/19/sista-open-alpha-release/ Currently in Pharo SqueakV3PlusClosure and SistaV1 are installed in CompiledCode. You need to install another set if you want to use it using #installSecondaryBytecodeSet: or similar methods. CompiledMethod installSecondaryBytecodeSet: EncoderForMyBytecodeSet. Then you can just use the first code snippet to use it: CompilationContext bytecodeBackend: EncoderForMyBytecodeSet. OpalCompiler recompileAll. On Mon, Dec 4, 2017 at 3:48 AM, 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. > > * 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. > > For (a.) I guess an exciting opportunity is facilitating an Ethereum >> virtual machine >> running as a Process inside a Pharo image, managed by tools written in >> Pharo. >> Other languages are already getting in a party which would be good for >> Pharo to join. >> In such a revolutionary domain I expect people are more willing to >> experiment >> with alternative systems like Pharo, and I bet Pharo could excel in that >> domain. >> * https://github.com/ethereum/go-ethereum/blob/master/core/vm/opcodes.go >> * https://medium.com/@jeff.ethereum/optimising-the-ethereum- >> virtual-machine-58457e61ca15 >> * https://github.com/pirapira/awesome-ethereum-virtual-machi >> ne#evm-implementations >> >> >> 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 sim,letter. > > >> >> (a calculator demo could be an interesting adjunct to Sven's calculator >> tutorial...) >> https://medium.com/concerning-pharo/rediscovering-the-ux-of- >> the-legendary-hp-35-scientific-pocket-calculator-d1d497ece999 >> >> >> cheers -ben >> > > > > -- > _,,,^..^,,,_ > best, Eliot > -- Clément Béra Pharo consortium engineer https://clementbera.wordpress.com/ Bâtiment B 40, avenue Halley 59650 Villeneuve d'Ascq
