I am looking for the most suitable JIT JS engine to replace existing JS interpreter.
I am looking right now at V8 and SpiderMonkey. Specifically I am interested in the way SpiderMonkey handles memory limits. I want to control memory which is allowed per context and the ability to gracefully handling the memory limits in my code (no about()), unlike V8 which does exactly that https://chromium.googlesource.com/v8/v8.git/+/HEAD/include/v8-isolate.h#82, NearHeapLimitCallback() gives some help, but not enough for me.
What are available mechanisms in SpiderMonkey I could use to handle memory limits gracefully in my code?
To clarify, I have a single-threaded C application with its own even loop with unknown number of JS contexts running asynchronously. In case if a JS context is out of predefined memory limit I want to destroy/close that context, without disrupting my process.