[fpc-pascal] WebAssembly Target

Karoly Balogh (Charlie/SGR) charlie at scenergy.dfmk.hu
Wed Mar 15 17:58:08 CET 2017


Hi,

On Sun, 12 Mar 2017, Michael Van Canneyt wrote:

> >   Is there something planned in this matter for FPC?
> >
> >   I was reading about the new Firefox making WebAssembly publicly
> > available ("On Tuesday Firefox 52 became the first browser to support
> > WebAssembly
> >
> <https://www.bleepingcomputer.com/news/software/mozilla-releases-firefox-52-the-first-browser-to-support-webassembly/>")
> > [1] .
>
> Karoly Balogh (Charlie/SGR) is working on this, and as far as I know has
> already some degree of success. There is a bounty for initial
> webassembly support..

Well, "degree of success" is relative, I have added WASM target to the
compiler so it compiles at least. I even made it output 1 single
instruction... :)

It's based largely on gutted JVM codegenerator code, although since
WebAssembly itself is still a moving target, many things are still
uncertain. There's also the problem, that despite it's name, WebAssembly
is not really an assembly format, but just a stack based bytecode (much
like JVM), and the official textual representation is not yet accepted,
plus the reference compiler LLVM outputs something entirely different to
the semi-official textual formats. And these official textual formats are
quite painful for the traditional structured compiler layers like FPC has.

But the LLVM-style output would be good, but it's undocumented, and as
they say it will go away, and LLVM will output the binary bytecode
directly... (Which is stupid IMO, but hey, a comittee decided, so it must
be right.)

Also, any "assembler" or toolchain is still in its infancy. (I made both
binaryen and wabt segfault in several funny ways already.) So I wouldn't
expect fast results with this whole target. But I will keep working on it
as time allows, so "eventually"... Of course if someone thinks he can
proceed faster and wants to jump in, it's very welcomed.

It's now committed to the webassembly branch in FPC SVN, the compiler
itself should build at least as "wasm" target, but don't expect much.

Charlie



More information about the fpc-pascal mailing list