digitalmars.D - NaCl/Emscripten
- Manu via Digitalmars-d (9/9) Jan 09 2015 I'm looking at another potential opportunity to get D into the office,
- "Ola Fosheim =?UTF-8?B?R3LDuHN0YWQi?= (8/15) Jan 09 2015 I have read the standard on ASM.js and some on NaCl. I think you
- Manu via Digitalmars-d (5/18) Jan 09 2015 I can probably get by with @nogc. There's no threading in asm.js
- "Ola Fosheim =?UTF-8?B?R3LDuHN0YWQi?= (9/11) Jan 09 2015 You have worker threads, so you would have to use message
- Tobias Pankrath (2/6) Jan 09 2015 You could compile your D code to LLVM IR using ldc2 --output-ll
- deadalnix (5/18) Jan 09 2015 Both will need a special build of LDC, and runtime support. I
- Jacob Carlborg (5/14) Jan 09 2015 Don't know if there's any interest but Adam D. Ruppe has hacked DMD to
- Mengu (3/23) Jan 09 2015 guess you're talking about dtojs:
- Adam D. Ruppe (4/9) Jan 09 2015 I haven't updated that for a long time though, it probably won't
- "Ola Fosheim =?UTF-8?B?R3LDuHN0YWQi?= (11/11) Jan 10 2015 There are also other compilers from C++ to Javascript, Mandreel
- Manu via Digitalmars-d (8/17) Jan 10 2015 The thing about cheerp vs emscripten, is that while cheerp produces
- "Ola Fosheim =?UTF-8?B?R3LDuHN0YWQi?= (12/21) Jan 10 2015 You are probably right about throughput which I would expect to
- Janus (7/11) Jan 13 2015 The heap can grow now, see
- "Ola Fosheim =?UTF-8?B?R3LDuHN0YWQi?= (8/17) Jan 14 2015 Thanks, I've read the source code now. It involves creating a new
- Martin Nowak (4/13) Jan 10 2015 It would require some druntime work for the libc differences (newlib vs....
I'm looking at another potential opportunity to get D into the office, but the target's for this particular project are NaCL and/or Emscripten. I was gonna start hacking around to see what the limitations are with Emscripten on D code tonight. Has anyone done any serious investigation here? NaCl is a more useful target, but I think that will rely on a special build of LDC... has there been discussion about that before? Can any of the LDC guys chime in on the possibility?
Jan 09 2015
On Friday, 9 January 2015 at 09:28:22 UTC, Manu via Digitalmars-d wrote:I was gonna start hacking around to see what the limitations are with Emscripten on D code tonight. Has anyone done any serious investigation here? NaCl is a more useful target, but I think that will rely on a special build of LDC... has there been discussion about that before?I have read the standard on ASM.js and some on NaCl. I think you will run into trouble with the GC on both NaCl and ASM.js. If you don't target ASM.js, then you probably could a completely new backend for D that use the standard javascript collector and still get some of the benefits. Remember that only Firefox support ASM.js.
Jan 09 2015
On 9 January 2015 at 19:51, via Digitalmars-d <digitalmars-d puremagic.com> wrote:On Friday, 9 January 2015 at 09:28:22 UTC, Manu via Digitalmars-d wrote:I can probably get by with nogc. There's no threading in asm.js either, so that might be a spanner. Maybe -betterc would be usable out of the box...I was gonna start hacking around to see what the limitations are with Emscripten on D code tonight. Has anyone done any serious investigation here? NaCl is a more useful target, but I think that will rely on a special build of LDC... has there been discussion about that before?I have read the standard on ASM.js and some on NaCl. I think you will run into trouble with the GC on both NaCl and ASM.js. If you don't target ASM.js, then you probably could a completely new backend for D that use the standard javascript collector and still get some of the benefits. Remember that only Firefox support ASM.js.
Jan 09 2015
On Friday, 9 January 2015 at 10:10:36 UTC, Manu via Digitalmars-d wrote:I can probably get by with nogc. There's no threading in asm.js either, so that might be a spanner.You have worker threads, so you would have to use message passing, but I believe you can transfer "byte heaps" by reference between threads in a unique_ptr style (so only one thread can access it at the same time): https://developer.mozilla.org/en-US/docs/Web/API/Transferable Maybe it is possible to get the GC to work too, but it sounds like a lot of work for nothing IMO.
Jan 09 2015
I can probably get by with nogc. There's no threading in asm.js either, so that might be a spanner. Maybe -betterc would be usable out of the box...You could compile your D code to LLVM IR using ldc2 --output-ll and feed that to emcc to see how far you get.
Jan 09 2015
On Friday, 9 January 2015 at 09:28:22 UTC, Manu via Digitalmars-d wrote:I'm looking at another potential opportunity to get D into the office, but the target's for this particular project are NaCL and/or Emscripten. I was gonna start hacking around to see what the limitations are with Emscripten on D code tonight. Has anyone done any serious investigation here? NaCl is a more useful target, but I think that will rely on a special build of LDC... has there been discussion about that before? Can any of the LDC guys chime in on the possibility?Both will need a special build of LDC, and runtime support. I know people made that work in the past, but I wouldn't expect the support to be great.
Jan 09 2015
On 2015-01-09 10:28, Manu via Digitalmars-d wrote:I'm looking at another potential opportunity to get D into the office, but the target's for this particular project are NaCL and/or Emscripten. I was gonna start hacking around to see what the limitations are with Emscripten on D code tonight. Has anyone done any serious investigation here? NaCl is a more useful target, but I think that will rely on a special build of LDC... has there been discussion about that before? Can any of the LDC guys chime in on the possibility?Don't know if there's any interest but Adam D. Ruppe has hacked DMD to output JavaScript. You should be able to find it somewhere on the newsgroup. -- /Jacob Carlborg
Jan 09 2015
On Friday, 9 January 2015 at 12:46:41 UTC, Jacob Carlborg wrote:On 2015-01-09 10:28, Manu via Digitalmars-d wrote:guess you're talking about dtojs: https://github.com/adamdruppe/dtojs.I'm looking at another potential opportunity to get D into the office, but the target's for this particular project are NaCL and/or Emscripten. I was gonna start hacking around to see what the limitations are with Emscripten on D code tonight. Has anyone done any serious investigation here? NaCl is a more useful target, but I think that will rely on a special build of LDC... has there been discussion about that before? Can any of the LDC guys chime in on the possibility?Don't know if there's any interest but Adam D. Ruppe has hacked DMD to output JavaScript. You should be able to find it somewhere on the newsgroup.
Jan 09 2015
On Friday, 9 January 2015 at 15:27:08 UTC, Mengu wrote:I haven't updated that for a long time though, it probably won't work at all anymore and it was never really production ready. I wouldn't try it on a professional job.Don't know if there's any interest but Adam D. Ruppe has hacked DMD to output JavaScript. You should be able to find it somewhere on the newsgroup.guess you're talking about dtojs: https://github.com/adamdruppe/dtojs.
Jan 09 2015
There are also other compilers from C++ to Javascript, Mandreel and Cheerp. Cheerp claims to support the builtin Javascript garbage collector: «Dynamic memory management. C++ objects are translated directly to JS objects, without the proxy of an emulated, flat memory space. Allow your applications to exploit the JavaScript VM garbage collector and co-exist with fair, on-demand memory allocation.» http://www.leaningtech.com/cheerp/blog/ So if Cheerp is ready for production (I don't know if it is), it might be a better fit for D.
Jan 10 2015
On 11 January 2015 at 01:31, via Digitalmars-d <digitalmars-d puremagic.com> wrote:There are also other compilers from C++ to Javascript, Mandreel and Cheerp. Cheerp claims to support the builtin Javascript garbage collector: «Dynamic memory management. C++ objects are translated directly to JS objects, without the proxy of an emulated, flat memory space. Allow your applications to exploit the JavaScript VM garbage collector and co-exist with fair, on-demand memory allocation.» http://www.leaningtech.com/cheerp/blog/ So if Cheerp is ready for production (I don't know if it is), it might be a better fit for D.The thing about cheerp vs emscripten, is that while cheerp produces code that is more like javascript, emscripten produces asm.js, which is lightning fast by comparison. If there's actual work being done, then emscripten is the choice, if it's just as a substitute for writing js code, because it's a nightmare, then cheerp is probably better.
Jan 10 2015
On Sunday, 11 January 2015 at 01:05:59 UTC, Manu via Digitalmars-d wrote:The thing about cheerp vs emscripten, is that while cheerp produces code that is more like javascript, emscripten produces asm.js, which is lightning fast by comparison. If there's actual work being done, then emscripten is the choice, if it's just as a substitute for writing js code, because it's a nightmare, then cheerp is probably better.You are probably right about throughput which I would expect to be better with Emscripten than Cheerp, although keep in mind that only Firefox converts asm.js directly to asm without the regular JIT. IE and Chrome uses the regular JIT AFAIK. With asm.js you are also stuck with a fixed size heap and if you manage to implement GC on asm.js, you get the freeze... Then you have interop with JS. Not sure if you can interact with Worker-threads within asm.js? I had not heard of Cheerp until today, but it looks interesting to me.
Jan 10 2015
On Sunday, 11 January 2015 at 01:33:25 UTC, Ola Fosheim Grøstad wrote:On Sunday, 11 January 2015 at 01:05:59 UTC, Manu via Digitalmars-d wrote: With asm.js you are also stuck with a fixed size heapThe heap can grow now, see https://github.com/kripken/emscripten/blob/master/ChangeLog.markdown#v1251-1012014 On Friday, 9 January 2015 at 09:51:36 UTC, Ola Fosheim Grøstad wrote:Remember that only Firefox support ASM.js.Chrome runs it pretty fast though, sometimes faster than Firefox.
Jan 13 2015
On Wednesday, 14 January 2015 at 03:11:41 UTC, Janus wrote:On Sunday, 11 January 2015 at 01:33:25 UTC, Ola Fosheim Grøstad wrote:Thanks, I've read the source code now. It involves creating a new array, then copying the old array into the new one. And it probably needs the experimental Ecmascript 7 ArrayBuffer.transfer() function to be fast. So clearly something that only can run when waiting for something (like between levels in a game).On Sunday, 11 January 2015 at 01:05:59 UTC, Manu via Digitalmars-d wrote: With asm.js you are also stuck with a fixed size heapThe heap can grow now, see https://github.com/kripken/emscripten/blob/master/ChangeLog.markdown#v1251-1012014Chrome runs it pretty fast though, sometimes faster than Firefox.Yes, not if the code is ASM.js, but still good even then.
Jan 14 2015
On 01/09/2015 10:28 AM, Manu via Digitalmars-d wrote:I'm looking at another potential opportunity to get D into the office, but the target's for this particular project are NaCL and/or Emscripten. I was gonna start hacking around to see what the limitations are with Emscripten on D code tonight. Has anyone done any serious investigation here? NaCl is a more useful target, but I think that will rely on a special build of LDC... has there been discussion about that before? Can any of the LDC guys chime in on the possibility?It would require some druntime work for the libc differences (newlib vs. glibc). That's similar to the ongoing Android/X86 work https://github.com/D-Programming-Language/druntime/pull/1069.
Jan 10 2015