The existing JSC watchdog mechanism relies on the fact that no JS code can run for long before hitting a loop hint. The only exception to that would be infinitely recursing code, but that would hit a stack overflow eventually and terminate. With the support for tail calls added, we can now have a JS script hang by doing infinite recursion without every hitting a stack overflow. We should teach the watchdog to handle this as well. Fun!
I plan to implement this by having the watchdog timer simulate a stack overflow, and teaching the existing stack check slow path code in function prologues to discern between a stack overflow and a watchdog timer check request. Unlike with stack overflows, the stack check slow path can return without throwing an exception. This is because the watchdog timer firing only means that we need to check the watchdog's deadlines. It doesn't necessarily mean that the watchdog fired. We will only throw the TerminatedExecutionException if the watchdog deadlines have been reached. Hence, I'll also have to teach the function prologues to not expect that the stack check slow path will throw unconditionally.
I spoke with Geoff offline. Per our discussion, we won't overload the stack check. Instead, will add a watchdog check to the tail call opcode. The DFG and FTL can optimize these away if appropriate.
*** This bug has been marked as a duplicate of bug 151972 ***