In addition to what the other replies said, feel free to eyeball the code required to embed SpiderMonkey in Firefox at https://github.com/mozilla/gecko-dev/tree/master/dom/binding.... It's rather large and complex.
The interface between SpiderMonkey and the rest of Firefox is here: https://searchfox.org/mozilla-central/source/js/src/jsapi.h.