This project has moved and is read-only. For the latest updates, please go here.

Compiled script caching in the v8 engine

Mar 26, 2013 at 12:54 AM

One of the cool things about the v8 engine is the possibility of essentially precompiling scripts for later execution in different contexts. It looks as if the ClearScript v8 implementation in its current form does not leverage this possibility too well, essentially enforcing script (re)compilation on every execution. Is this correct? And if so, is this something that would be possible to implement?
Mar 26, 2013 at 2:07 PM
Hi MrIze,

When you say that ClearScript "does not leverage this possibility too well", you're being too kind, as it doesn't leverage it at all :)

V8 support is actually a recent addition to ClearScript. It originally supported only the old JScript and VBScript interpreters, where compilation was not an issue. Now that it supports V8, it definitely would benefit from a way to re-execute scripts without recompilation.

Implementing only that would be fairly straightforward. However, because compiled scripts are isolate-bound, and ClearScript implements one isolate per context, cross-context compiled script reuse would still not be possible. For full-blown support, ClearScript also needs a way to create multiple contexts per isolate, something else that's been on our radar for a while now.

Please see here and here.

Thank you for your input!
May 22, 2013 at 2:19 PM
ClearScript 5.3 has been released with support for both features. You can use the new Compile() method to create compiled scripts, and a new Evaluate() overload to execute them. The new V8Runtime class enables isolate and compiled script sharing among contexts. Please see the updated API reference. Thanks again for your input!