Rewrite JS engine for speed and size (bug 923212)