<div dir="ltr">Hi,<div class="gmail_extra"><br><div class="gmail_quote">On Thu, Dec 8, 2016 at 5:05 AM, Ben Coman <span dir="ltr"><<a href="mailto:btc@openinworld.com" target="_blank">btc@openinworld.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
I've just bumped into WebAssembly and am curious what opportunities<br>
(or not) it might offer us.<br>
* <a href="https://medium.com/javascript-scene/what-is-webassembly-the-dawn-of-a-new-era-61256ec5a8f6#.60dghpaek" rel="noreferrer" target="_blank">https://medium.com/javascript-<wbr>scene/what-is-webassembly-the-<wbr>dawn-of-a-new-era-<wbr>61256ec5a8f6#.60dghpaek</a> <br></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
One approach could be to just compile our currently generated C code<br>
to WevAssembly via LLVM. Ronie's recent effort to produce a<br>
non-display minimal VM should help proof of concept here.<br>
* <a href="http://webassembly.org/docs/c-and-c++/" rel="noreferrer" target="_blank">http://webassembly.org/docs/c-<wbr>and-c++/</a><br>
* <a href="https://hacks.mozilla.org/2015/12/compiling-to-webassembly-its-happening/" rel="noreferrer" target="_blank">https://hacks.mozilla.org/<wbr>2015/12/compiling-to-<wbr>webassembly-its-happening/</a><br>
* <a href="http://cultureofdevelopment.com/blog/build-your-first-thing-with-web-assembly/" rel="noreferrer" target="_blank">http://cultureofdevelopment.<wbr>com/blog/build-your-first-<wbr>thing-with-web-assembly/</a><br>
<br></blockquote><div><br></div><div><br class="gmail-Apple-interchange-newline">It should be possible to port the StackVM to WebAssembly through LLVM, but many plugins have to be rewritten. Some people worked on making an easy to bind interface for files, display and other plugin features already, but it needs to be done. FFI plugin needs to be reimplemented too.</div><div><br class="gmail-Apple-interchange-newline">WebAssembly is an abstract assembly, so running the VM on it kind of makes sense. It's not really running on top of a VM, it's running on top of an abstract assembler to avoid assembly back-end dependencies.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
An obvious downside would be having a VM running on a VM.  But<br>
WebAssembly doesn't do garbage collection so at least it wouldn't<br>
double up on that.  Possibly there would be some double-up/conflict on<br>
JIT-ing, but there seems like there will be a facility for adding JIT<br>
and optimisation libraries, so possibly past investment in Cog is not<br>
lost.  Also perhaps(??) while WebAssembly is in its formative stage<br>
right now some primitives can be added to facilitate how Cog operates.<br>
* <a href="http://webassembly.org/docs/future-features/#platform-independent-just-in-time-jit-compilation" rel="noreferrer" target="_blank">http://webassembly.org/docs/<wbr>future-features/#platform-<wbr>independent-just-in-time-jit-<wbr>compilation</a><br>
* <a href="http://webassembly.org/docs/jit-library/" rel="noreferrer" target="_blank">http://webassembly.org/docs/<wbr>jit-library/</a><br>
<br></blockquote><div><br></div><div>It's possible. You need the JIT to have a back-end to web assembly, which is some work.<br></div><div><br></div><div>However, stack introspection is not possible currently (though it may be added in the future). This means that the VM needs to maintain a shadow stack for the GC to scan it with the current implementation. It requires changes in the VM that are non trivial. It would be better to wait for stack introspection to be available.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Another approach may be to start with SqueakJS, and work out how the<br>
Cog JIT could be plugged into WebAssembly as a library that SqueakJS<br>
(and others?) could use.  If its architecturally possible this might<br>
broaden the exposure of Cog(??). What would WebAssembly require to<br>
facilitate using Cog?<br></blockquote><div><br></div><div>I believe it's easier to use directly the Cog compiled to web assembly. The most difficult part is to make the JIT compliant anyway.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
Of course all plates are full, but now seems the ideal time time to<br>
get involved.<br>
WebAssembly browser preview seeking community feedback concluding Q1 2017.<br>
<a href="https://www.infoq.com/news/2016/11/webassembly-browser-preview" rel="noreferrer" target="_blank">https://www.infoq.com/news/<wbr>2016/11/webassembly-browser-<wbr>preview</a><br>
<a href="http://webassembly.org/roadmap/" rel="noreferrer" target="_blank">http://webassembly.org/<wbr>roadmap/</a><br>
<a href="https://github.com/WebAssembly/design" rel="noreferrer" target="_blank">https://github.com/<wbr>WebAssembly/design</a><br>
<br>
Chrome nightly builds available to test it<br>
<a href="http://thenextweb.com/dd/2016/03/15/webassembly-lands-chrome-canary-offering-glimpse-future-web/" rel="noreferrer" target="_blank">http://thenextweb.com/dd/2016/<wbr>03/15/webassembly-lands-<wbr>chrome-canary-offering-<wbr>glimpse-future-web/</a><br>
<br>
It would be amazing to run Cog in a web browser, and thus facilitate<br>
all our favourite Smalltalk dialects. </blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
Side thought: Craig's work to incrementally download a running image<br>
could be useful to reducing web page startup time.<br></blockquote><div><br></div><div>There's already multiple things like Amber, PharoJS, SqueakJS, Craig's work.</div><div><br></div><div>Another thing we could do: now that the JIT supports 4 sets of unsafe operations, like Ronie's lowcode or the sista instructions, we could support a DSL similar to webAssembly in Squeak/Pharo that compiles to machine code though Cog's JIT...</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
cheers -ben<br>
</blockquote></div><br></div></div>