bert at freudenbergs.de
Fri Oct 10 07:27:47 UTC 2014
And then there's cCode:inSmalltalk:. Fun one. I ended up having a translation table with a JS snippet for every C snippet. And a bit of magic sprinkled on top. Don't judge, it serves its purpose, namely generating the plugins that do not depend on libraries or other external code. And that's actually not that few, 17 total:
But it works, and is almost as efficient as my hand-written code. I was able to get rid of 1200 lines of my own BitBlt code that almost worked, and use the actual BitBlt implementation with all its nooks and crannies. And having a LargeIntegersPlugin makes a real difference in performance. And ZipPlugin too. Etc.
The generated code even looks quite nice, modulo excessive parens.
However, the JS code generator remains ugly, and is less than general. I wonder if some of the C-isms should be replaced with more general patterns. The memory access functions are a step in the right direction I think. Although I think they always should use a base (oop+baseHeaderSize would be my preference) and offset. This would make it rather simple to map to JS, and with today's optimizing C compilers and modern CPUs, does it really make a difference to write ptr++ instead of ptr[i++]?
Anyway, I'm not really complaining, Slang was intended as just being C with, so it's no wonder people use it like that. The type declarations help immensely in figuring out what's going on automatically most of the time, and I kludged the rest. Without modifying a single line in the original plugins, so far. Of course, if the plugin code changes I may have to adjust the code generator.
Err, that turned out longer and more rambling than I intended. I really just wanted to know if I should copy it to the main VMMaker repo?
- Bert -
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 4142 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20141010/b872abc1/smime.bin
More information about the Vm-dev