<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Jul 7, 2015, at 3:36 AM, Yusuke SUZUKI &lt;<a href="mailto:utatane.tea@gmail.com" class="">utatane.tea@gmail.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote">On Tue, Jul 7, 2015 at 8:54 AM, Geoffrey Garen <span dir="ltr" class="">&lt;<a href="mailto:ggaren@apple.com" target="_blank" class="">ggaren@apple.com</a>&gt;</span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class="">I’m suggesting a default runloop for non-web content.<div class=""><br class=""></div><div class="">I haven’t read through the details of integrating with the web content definition of micro task.</div><div class=""><br class=""></div><div class="">Geoff</div></div></blockquote><div class=""><br class=""></div><div class="">OK. Reinventing runloop each time is costly.</div><div class="">On the other hand, sometimes, users would like to use the other runloop such as libuv.</div><div class="">So what do you think about providing the both.</div><div class=""><br class=""></div><div class="">1. Provide default runloop in JSC</div><div class="">2. Provide the way to register callback for enqueueJob. If it's provided, (1) is disabled for this VM.</div><div class=""><br class=""></div><div class="">(1) would become the following (quick proposal)</div><div class=""><br class=""></div><div class="">void JSContextRunMicrotasks(JSContextRef, unsigned someFlags);</div><div class="">bool JSContextIsMicrotasksEmpty(JSContextRef);</div><div class=""><br class=""></div><div class="">In this case, if we would like to close the VM,</div><div class=""><br class=""></div><div class="">bool executed = false;</div><div class="">do {</div><div class="">&nbsp; &nbsp; executed = false;</div><div class="">&nbsp; &nbsp; for each context belongging to the given VM {</div><div class="">&nbsp; &nbsp; &nbsp; &nbsp; if (JSContxtIsMicrotasksEmpty(context)) {</div><div class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; executed = true;</div><div class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; JSContextRunMicrotasks(context, ...);</div><div class="">&nbsp; &nbsp; &nbsp; &nbsp; }</div><div class="">&nbsp; &nbsp; }</div><div class="">} while (executed);</div><div class="">Close(VM);</div></div></div></div></div></blockquote><div><br class=""></div><div>I think that Goeff's suggest would be that microtasks would normally run without the client having to make any special calls at all to account for them. Possibly this may imply a requirement of running a CFRunLoop on the relevant thread.</div><div><br class=""></div><div>I also think your API doesn't account for nesting very well - it requires the client app to know the VM nesting level. It would be better if that was tracked and micro tasks could run on exiting the outermost VM and/or&nbsp;</div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><div class=""><br class=""></div><div class="">(2) would become the original proposal.</div><div class="">&nbsp;</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class=""><div class=""><div class="h5"><div class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Jul 6, 2015, at 4:44 PM, Maciej Stachowiak &lt;<a href="mailto:mjs@apple.com" target="_blank" class="">mjs@apple.com</a>&gt; wrote:</div><br class=""><div class=""><div style="word-wrap:break-word" class=""><div class=""><br class=""></div><div class="">Should JS be defining an event loop abstraction that WebCore then uses? That would be weird, because the required behavior of the even loop in web content is chock full of issues that are not at all related to JavaScript. JSC doesn't even know enough to run microtasks at all the right times (from reading the spec it seems that way, at least) for the Web case. Or are you saying it would have a fallback runloop for non-Web contents?</div><div class=""><br class=""></div><div class="">Regards,</div><div class="">Maciej</div><div class=""><br class=""></div><div class=""><blockquote type="cite" class=""><div class="">On Jul 6, 2015, at 3:24 PM, Geoffrey Garen &lt;<a href="mailto:ggaren@apple.com" target="_blank" class="">ggaren@apple.com</a>&gt; wrote:</div><br class=""><div class=""><div style="word-wrap:break-word" class="">I think it would be better for JavaScriptCore to handle micro tasks natively.<div class=""><br class=""></div><div class="">It’s not so great for each client to need to reinvent the microtask runloop abstraction.<br class=""><div class=""><br class=""></div><div class="">Geoff</div><div class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Jul 6, 2015, at 10:05 AM, Yusuke SUZUKI &lt;<a href="mailto:utatane.tea@gmail.com" target="_blank" class="">utatane.tea@gmail.com</a>&gt; wrote:</div><br class=""><div class=""><div dir="ltr" class="">Hi WebKittens,
<div class=""><br class=""></div><div class="">I've landed the update of the ES6 Promise implementation.</div><div class="">Through this work, I've experimentally added the internal private function, @enqueueJob(JS function, JS array for arguments).</div><div class="">This is corresponding to the ES6 spec EnqueueJob[1].</div><div class=""><br class=""></div><div class="">This EnqueueJob handler is now tightly integrated with WebCore's microtask infrastructure. So in JSC framework side, we cannot use this function.</div><div class="">As a result, current JSC framework disables Promise because there's no event loop abstraction.</div><div class=""><br class=""></div><div class="">So I propose the API configuring euqueueJob handler into JSC VM (That corresponds to the Realm in ECMA spec).</div><div class=""><br class=""></div><div class="">Like,</div><div class=""><br class=""></div><div class="">void JSContextGroupSetEnqueueJobCallback(JSContextGroupRef, JSEnqueueJobCallback, void* callbackData);</div><div class=""><br class=""></div><div class="">What do you think about this?</div><div class=""><br class=""></div><div class="">[1]:&nbsp;<a href="http://ecma-international.org/ecma-262/6.0/#sec-enqueuejob" target="_blank" class="">http://ecma-international.org/ecma-262/6.0/#sec-enqueuejob</a></div><div class=""><br class=""></div><div class="">Best Regards,</div><div class="">Yusuke Suzuki</div></div>
_______________________________________________<br class="">webkit-dev mailing list<br class=""><a href="mailto:webkit-dev@lists.webkit.org" target="_blank" class="">webkit-dev@lists.webkit.org</a><br class=""><a href="https://lists.webkit.org/mailman/listinfo/webkit-dev" target="_blank" class="">https://lists.webkit.org/mailman/listinfo/webkit-dev</a><br class=""></div></blockquote></div><br class=""></div></div></div>_______________________________________________<br class="">webkit-dev mailing list<br class=""><a href="mailto:webkit-dev@lists.webkit.org" target="_blank" class="">webkit-dev@lists.webkit.org</a><br class=""><a href="https://lists.webkit.org/mailman/listinfo/webkit-dev" target="_blank" class="">https://lists.webkit.org/mailman/listinfo/webkit-dev</a><br class=""></div></blockquote></div><br class=""></div></div></blockquote></div><br class=""></div></div></div></div></blockquote></div><br class=""></div></div>
</div></blockquote></div><br class=""></body></html>