Reputation:
I'm interested to find out how the JavaScript interpreter (engine if you like) works. I'm aware that JavaScript isn't compiled.I have looked at the ECMA specification, but it doesn't explain how the actual engine works.
The main reason why I'm asking this is because I'd like to understand why IE7 behaves slightly differently to IE8 or Firefox 3.5+.
I suspect that certain function calls get handled in a different order, but I'd like to know for sure.
I have also watched few videos by Google talks on JavaScript optimization along with the JavaScript: Good Parts video. These touched on the topic briefly.
Upvotes: 6
Views: 6807
Reputation: 353
I have exactly the same problem - Execution Contexts in the ECMA spec. does provide some obscure! insight. Idiosyncrasies though are rampant amongst even a single platform's versions.
Generally, topics on Automata, Recursive Function Theory, Formal Language Theory and Compiler Design provide a solid background for "understanding" an interpreter.
In the abstraction, if the semantics are exhaustively well-defined, without requiring "disambiguation", then the formal function results will be identical regardless of implementation. In practice, there is a lot of wriggle room, as seen by the extras such as .toSource(), that one engine might have and another not.
stackoverflow ref: What are Gecko's operational semantics?
Upvotes: 4
Reputation: 13438
If you can deal with low-level languages, look at the sources of V8 or TraceMonkey and research them. It is a bit difficult way to understand the internals of the JavaScript engines, but it is quite interesting.
Upvotes: 1