Hi guys,
I work on NativeScript project and my team uses V8 to access Android APIs from JavaScript. In order to orchestrate V8/Dalvik garbage collectors dance I need to know whether a function creates a closure over an object. For example:
var x = {
f: function () { }
}
var y = {
g: function () {
x.f()
}
}
In the example about I have weak callbacks (WeakCallbackData<T, P>::Callback) for both x and y object and during GC I need to know whether object x is reachable from object y. My current approach is built around v8::internal::ScopeInfo and v8::internal::Context::Lookup which played well until recently when we start observing app crashes mostly when we try to access the objects which we concluded belong to a closure.
So far my approach is flawed and I am wondering is there a recommended way that I can use during GC so I can detect whether object x is reachable from object y. Any ideas are appreciated.
TIA,
Mihail