[Vm-dev] implementing atomic operator
eliot.miranda at gmail.com
Fri Nov 6 15:22:02 UTC 2015
> On Nov 4, 2015, at 2:34 PM, Sebastián Krynski <skrynski at gmail.com> wrote:
> Hello, as I mentioned before I'm starting to implement an atomic operator (a swap between two variables).
> I have compiled the StackVM (at least to get started) in Ubuntu 32bits.
> A few questions:
> - Should I be working on generation.image while doing the implementation? If so, should I be running the simulated VM running another image while doing my tests?
I like to use the simulator on an image that starts up a read-eval-print-loop so I can type expressions into the simulation without having to drive the simulated gui, which is slooooow. If Pharo requires a command line arg to start the REPL then you can add this when you launch the simulation.
> - Do you think it is possible to implement the operations in Slang or using #cCode:inSmalltalk:? Otherwise I will need to do it in assembler and inline it
Please do /not/ use #cCode:inSmalltalk:, it's a horrible hack. Instead use the pattern used for strcmp et al. Define a selector, say compare:swap: and implement its simulation up in VMClass. Mark the method with the <doNotGenerate> pragma. Slang will then output it as compareswap(a,b). Then implement this with a macro in platforms/Cross/vm/sqAtomic.h, eg in terms of the gcc intrinsics.
When it comes to the Cog JIT you can add either an abstract instruction or a generated runtime routine, depending on complexity. Don't worry about this now, but there is already support for CAS in the JIT.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Vm-dev