workaround for huge heap scanner slowdown in recent spidermonkey in some situations
only run main loop when required