The array for script runners could use AutoTArray so that we don't end up allocating and releasing it all the time and a commonly used script runner could be cached. My microbenchmark for this has been https://bug1275755.bmoattachments.org/attachment.cgi?id=8757475 Patch coming.
Created attachment 8757655 [details] [diff] [review] patch helps 5-10% locally on opt (but not pgo) build with that test case. Changes to nsContentUtils reduce allocation/deallocation and changes to nsDocument reduce both allocation/deallocation and AddRef/Release of nsDocument. https://treeherder.mozilla.org/#/jobs?repo=try&revision=b612524f332cdd4f105364cd233f94f8b347d198