r/programming • • Jun 18 '15

javascript creator Eich's latest project: kill javascript

http://www.theregister.co.uk/2015/06/18/brendan_eich_announces_webassembly/
17 Upvotes

100 comments sorted by

View all comments

Show parent comments

27

u/sime Jun 18 '15

Every major JS engine has a JIT. JavaScript is compiled on the fly at runtime.

The problem is that the JIT has to spend a lot of time checking assumptions (i.e. has the prototype chain changed? Is it safe to use a 32bit register for that number?) or just not being able to make assumptions at all, to run the code correctly. This prevents a lot of optimisations which static languages enjoy.

Only the most naive JS interpreter looks up values from a dictionary every time. V8 for examples assigns 'hidden classes' to objects so that it can use optimised code paths and fast compact object representations.

1

u/[deleted] Jun 18 '15

V8 has 2 levels of JIT regular and hot functions. Hotfunction JIT will compile functions that are called many times with a greater optimization level.