2006-05-07
Why the Scheme->Javascript JIT doesn't work on Firefox
After doing some digging I've found a bug in the Scheme-in-Javascript implementation that seems to be the reason the JIT doesn't work on Firefox.
The system uses Javascript objects as associate arrays (hashtables), mapping symbols names to definitions. For example:
TopEnv['eval'] = function(list) { return doEval(list.car); }
There is a problem with using Javascript objects for this type of thing and that is that "TopEnv['eval']" is really syntactic sugar for 'TopEnv.eval' in Javascript. In firefox this actually returns the 'eval' standard function. You can see this by evaluating the following in a Javascript shell in Firefox:
var x = new Object()
x["eval"]
=> function eval() { [native code] }
In Internet Explorer this returns nothing. The JIT process does a lookup on 'eval' at some point and on Firefox it returns the native 'eval' function which breaks the JIT process. On IO it returns the Scheme 'eval' function.
The fix is relatively easy but finding all uses of this type of lookup in the code is time consuming. But JIT will work once I've done this.