Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why use JavaScriptCore and not v8 like nodejs does? #6

Closed
maticrivo opened this issue Dec 10, 2017 · 7 comments
Closed

Why use JavaScriptCore and not v8 like nodejs does? #6

maticrivo opened this issue Dec 10, 2017 · 7 comments

Comments

@maticrivo
Copy link

No description provided.

@voodooattack
Copy link
Owner

Hi! Thanks for your interest in the project!

V8 uses something called Isolates to lock the entire virtual machine during code execution on any thread. This essentially means that there is no way for multiple threads to concurrently call into a JavaScript context with V8.

JavaScriptCore locks specific contexts on the other hand (where a context is a part of the virtual machine, and consists of a stack pointer and packaged closure variables). If two contexts don’t share a closure, they can both run in parallel with no contention on different threads.

In the case where two contexts share a global/closure variable, one will acquire the lock and the other thread will have to wait, thus introducing atomic behaviour.

So, to summarise: V8 is simply not capable of supporting shared mutable state with its current approach and design philosophy. It would have to be rewritten from scratch to support such a use case.

JavaScriptCore’s design provides a granular approach when it comes to concurrent locking, and this is why we’re using it for Nexus.js.

@maticrivo
Copy link
Author

great! thanks so much for the answer! i'm gonna play around with it and see if i can run some of my projects on it :)

@voodooattack
Copy link
Owner

You're welcome.

@dou4cc
Copy link

dou4cc commented Dec 19, 2017

How about rust-mozjs? It is brand new and maybe faster?

@voodooattack
Copy link
Owner

@dou4cc Why? WebKit is perfect for our use case and is already heavily ingrained into the code. Why would I want to switch engines now?

@dou4cc
Copy link

dou4cc commented Dec 19, 2017

@voodooattack I was just asking your opinion on rust-mozjs, since it seems not easy to unbind the JS engine from Nexus.js.

@voodooattack
Copy link
Owner

@dou4cc I see. Well, I have no qualms about it. I just have no desire to rewrite everything from scratch just to find out if it is multi-threading compatible or not.

My first attempt with SpiderMoney (that was before I tried WebKit) was disastrous. I'm not sure if Firefox Quantum brought multi-threading support to SpiderMonkey or not, but I'm not going to test it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants