Search code examples
c++v8

How do I get an `Isolate` from a `Local<Object>` handle?


I don't have much knowledge of V8, but I know that Local<Object> is a light-weight stack-allocated object handle for an Object. How do I get an Isolate wherein a Local<Object>'s referee (the Object object) exists?


Solution

  • It's intended to work the other way round: you start by creating the Isolate, then a HandleScope, then Locals in the latter. Just keep track of the Isolate you created, and use that when needed.

    (For completeness' sake: for the time being, you can also get an Object's Isolate, but that function is deprecated, so you shouldn't rely on it. Proactively thinking about which Isolate you want to use at any given point helps prevent nasty, subtle bugs.)