With Task.spawn, regular expressions in Zotero.DB were causing "too much
recursion" errors on Windows with JIT enabled.
This requires a change to Q to allow async() to take a generator instead
of a generator-maker (which is the reason it was using Task.spawn to
begin with).
Task.jsm allows not only generators but also iterators to be yielded,
using ``typeof yielded == 'Function'`` as the test for an iterator, but
since the Q promise includes a send() method, yielding a Q promise
instead of a Mozilla promise results in an infinite loop. To fix this,
we disable Q's send() method, which is just an outdated synonym for
invoke() anyway.
This will have to be done every time we update Q until send() is
removed, Task.jsm is changed, or we stop using Task.jsm with Q promises.
It appears that this flag can no longer be set in new-ish Nightlies.
This patch switches code that used nsITimers with the
Components.utils.methodjit hack to use setTimeout on the hidden DOM
window instead, so that we still get the JIT. (See
https://bugzilla.mozilla.org/show_bug.cgi?id=776798)
This might also mean that callbacks from doGet etc. no longer get JITed.
At some point, we should test this with the JIT profiler.