<div dir="ltr"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><span style="font-family:arial,sans-serif;font-size:12.666666984558105px">The garbage collector scans the C stack.</span></blockquote>
<div><br></div><div>Hm, let me make sure I understand this correctly.</div><div><br></div><div>Say, I created a context with JSGlobalContextCreate() and stored it in an instance variable. Then I ran some JS code which stored a JS function in some native C++ object (so the pointer to the JS function is stored somewhere on the heap).</div>
<div><br></div><div>Then my application continues to run and at some point needs to call the stored JS function. At this point there are no JSC API functions on the stack.</div><div><br></div><div>void MyClass::callJsFunction(JSObjectRef arg0) {</div>
<div> JSObjectRef arg1 = JSObjectMake(ctx_, ...);</div><div> JSObjectRef arg2 = JSObjectMake(ctx_, ...);</div><div> </div><div> JSGarbageCollect(ctx_);</div><div><br></div><div> // ...</div><div>}</div><div><br>
</div><div>Will JSC scan the current stack which arg1 and arg2 are on? Will it scan the stack even further back? Say</div><div><br></div><div>void MyClass::someOtherFunc() {</div><div> JSObjectRef arg = JSObjectMake(ctx_, ...); // does the GC sees this "arg" pointer on the stack?</div>
<div> callJsFunction(arg);</div><div>}</div><div><br></div><div>I'm asking because I've never previously dealt with a library that scans the host application's stack. So it sounds pretty incredible to me.</div>
<div><br></div><div>Thanks!</div><div> </div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Sat, Dec 7, 2013 at 9:37 PM, Geoffrey Garen <span dir="ltr"><<a href="mailto:ggaren@apple.com" target="_blank">ggaren@apple.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">> At this point, the code is not inside the JS stack, so is it possible for an object to be collected between the calls to JSObjectMake and JSObjectCallAsFunction?<br>
<br>
</div>The garbage collector scans the C stack.<br>
<br>
Geoff<br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br>Best regards<br>Alexei Sholik
</div>