News for hackers. Stuff that matters.
Re:Java Polyfill for the Browser by amelius on Sunday May 08, 2016 @05:21PM (#11655904)
The most difficult part (I think) of writing a JVM is the concurrent garbage collector. Is this making use of Javascript's garbage collector to do the heavy lifting? Or do they implement their own GC in Javascript? Also, I'm wondering how they are handling concurrency.
Re:Java Polyfill for the Browser by jvilk on Sunday May 08, 2016 @05:28PM (#11655942)
Doppio uses JavaScript's garbage collector. (As a result, it cannot support weak references.) As for concurrency, thread quanta are mapped to JavaScript events, so Doppio can emulate preemptive multithreading. Doppio potentially preempts a "thread" at each function call.

The nitty gritty details are in the PLDI 2014 paper [0]. Some details have slightly changed, though (e.g. DoppioJVM supports JDK8 now).

[0] https://plasma-umass.github.io/doppio-demo/paper.pdf

Re:Java Polyfill for the Browser by TheAceOfHearts on Sunday May 08, 2016 @05:54PM (#11656110)
Once ES6 support is everywhere, you should be able to use WeakMap and WeakSet.

[0] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...

Re:Java Polyfill for the Browser by jvilk on Sunday May 08, 2016 @06:02PM (#11656166)
Actually, those are not sufficient to implement weak references, and have a much different use case! With WeakMap and WeakSet, the keys are weakly referenced, hence the names. If you have a WeakMap, you can't produce a value stored in the map without a strong reference to a key.

You can actually polyfill WeakMap and WeakSet. You can't do the same for weak references.

Re:Java Polyfill for the Browser by jvilk on Sunday May 08, 2016 @06:13PM (#11656231)
I misspoke -- you can polyfill WeakSet, but you cannot polyfill WeakMap, since you do not know when you can shrink the map. (But you still cannot use it to emulate weak references, since you need a strong reference to get data out of the map.)