Actually the javascript disaster of Firefox is an example of really poor management.
I can't remember how often the code-generation stage got completely rewritten in the last couple of yours, and now basically they end up with something similar to V8 (developed by google).
For me the big question actually is:
- Why not opt for a clean design in the first place? Compiling dynamically typed languages is not something that has not been there before...
- Why not use the code developed by google? V8 simply is the fastest javascript runtime, and its open-source

The same basically goes for gecko. Why develop everything by yourself, when you can get it for free elsewhere. Actually gecko's clumsy codebase is the reason why firefox still does not have features like process-per-tab, and why a heavy web-app in one thread can destrroy the browsing experience of another tab (as everything is strictly single-threaded).
However, I still use FireFox as its graphic rendering engine based on Cairo is painting web-pages at light velocity when using intel's SNA drivers =)