Bug 41765
Summary: | JavaScriptCore C API should have a notification mechanism to facilitate long-running scripts | ||
---|---|---|---|
Product: | WebKit | Reporter: | Kent Hansen <kent.hansen> |
Component: | JavaScriptCore | Assignee: | Nobody <webkit-unassigned> |
Status: | NEW | ||
Severity: | Normal | CC: | barraclough, cmarcelo, james.su, wingo |
Priority: | P2 | ||
Version: | 528+ (Nightly build) | ||
Hardware: | PC | ||
OS: | All | ||
Bug Depends on: | |||
Bug Blocks: | 41598 |
Kent Hansen
For a long-running script, JSEvaluateScript() will eventually throw a timeout error.
There's no way to control how long should pass before the script times out.
There's no way to receive notifications while the script is running (e.g. whether it should be aborted or not).
It would be nice to be able install a callback that the runtime would invoke, say, every N milliseconds to query whether evaluation should be aborted.
Attachments | ||
---|---|---|
Add attachment proposed patch, testcase, etc. |
Gavin Barraclough
I think the key question here would be whether we want this to be push or pull – whether JSC should be responsible for yielding after a period of execution, or whether there should be the ability to message JSC asynchronously to request a callback be made. The latter might be be more useful in a shell debugger (e.g. to handle ctrl-C), and may or may not also be useful for a profiler (depending on how close to the point a signal is received we'd be able to handle it).
It is also possible that we could support both, and it is possible the two mechanisms might not be unrelated.
Gavin Barraclough
*** Bug 24478 has been marked as a duplicate of this bug. ***
Andy Wingo
FWIW what V8 does is to insert stack-bounds checks at function calls and backwards branches. The stack limit is read from the heap. If the stack pointer is beyond the limit, the code executes some trap handler. The code is in a known safe place, suitable to throw exceptions or do OSR. Timeouts and asynchronous interrupts set various state flags, then reset the stack limit so that the next limit check invokes the handler.