In Script::ToJSVal<IComponent*>, we currently do not cache the JS wrappers around C++ objects (e.g. components such as CCmpPosition, CCmpOwnership, CCmpRangeManager, etc).
This means we create objects every time we call QueryInterface. This means that all QueryInterface calls to those objects are un-necessarily slow (also, we query an std::map right now, which happens to be slow enough to show up in my profile run).
This is an inefficient approach, as we do query those components rather often.
In general, this reduces GC pressure considerably, particularly in the Nursery, and improves performance regardless.
Furthermore, this swaps out our usage of PersistentRooted for JS::Heap. This has good performance implications, see https://code.wildfiregames.com/D5004#213715 for details.
Overall, this results in faster JS-C++ interop.
Proper profiling results coming soon™