SkylerLipthay / mini-v8

A minimal embedded V8 JavaScript engine wrapper for Rust
MIT License
104 stars 11 forks source link

create bindings for isolates #8

Open tusharmath opened 6 months ago

tusharmath commented 6 months ago

Hey! Thanks for this amazing library!

There are a few use cases where we are using mini-v8 and have reached a dead end when it comes to using isolates. mini-v8 doesn't have support for it, and it's quite a useful feature, especially for us where we are embedding v8 into our Rust application. We need to fire and run js in multiple contexts, moreover we also need to integrate it with https://crates.io/crates/serde_v8

SkylerLipthay commented 6 months ago

Hi there. In what way do you mean using isolates? Each MiniV8 instance is backed by its own V8 isolate, and there's no problem with creating multiple MiniV8s side-by-side. Do you mean exposing the internal v8::Isolate in some way? I fear this would lead introduce many complications.

Instead of trying to match the interfaces of serde_v8 and mini-v8, I would recommend creating a serde layer specifically suited to mini-v8. This should only amount to a few hundred lines of code; I did something similar a while ago for my ducc library.

tusharmath commented 6 months ago

@SkylerLipthay How would it perform if we create MiniV8 instance in hot code, in comparison just running a mini_v8::Function in that path? From what I could gather, we need to pass the script for each instance, which could take sometime to execute.