tag:blogger.com,1999:blog-20425712.post8691267368597122926..comments2023-06-27T14:20:37.054+02:00Comments on Constantly Changing: So, WebKit JS used an AST walker before?Attila Szegedihttp://www.blogger.com/profile/11586966395114113526noreply@blogger.comBlogger5125tag:blogger.com,1999:blog-20425712.post-14026432594506497252008-06-05T14:49:00.000+02:002008-06-05T14:49:00.000+02:00Well, yeah, visitor patterns over abstract tree no...Well, yeah, visitor patterns over abstract tree nodes leads to a virtual call galore, which is nicely replaced with a threaded interpreter. <BR/><BR/>JamVM (an altenative Java VM) used a threaded interpreter for a while, then I believed it switched over to a "template interpreter" - same that Sun's Java HotSpot uses as its "interpreter". I'm putting it in quote marks as it's rather a "non-optimizing compiler" really, where each bytecode instruction is replaced with a machine code sequence that implements it, and the resulting code run directly by the CPU. Of course, the code gains a larger memory footprint, but you even eliminate the GOTOs of the threaded interpreter :-) Of course, it's also possible to use a hybrid approach where you'd have pure machine code blocks and only optimize tight loops...<BR/><BR/>Just throwing ideas around :-)Attila Szegedihttps://www.blogger.com/profile/08179252447170860637noreply@blogger.comtag:blogger.com,1999:blog-20425712.post-84398494865134914332008-06-05T14:29:00.000+02:002008-06-05T14:29:00.000+02:00Ah, apologies for mistaking your tone (mistaking i...Ah, apologies for mistaking your tone (mistaking is the wrong word here.. miscomprehending? hmmm... unsure) then :D<BR/><BR/>Yes, it does seem kind of peculiar, and yes it had issues (very shallow recursion limit for instance) but it had many advantages, the code was simple and easily hackable (much more so than the main squirrelfish run loop), tools like profilers, debuggers could provide a huge amount of information just from the stack trace (because of all the accursed calls).<BR/><BR/>Squirrelfish obviously resolves a number of problems, like the recursion limit, and the accursed virtual function calls :D But there's a lot of complexity there now that wasn't there before, adn that is a fairly significant problem, especially if any new developers show up wanting to work on it. On the other hand, i shall repeat this, no more accursed virtual function calls.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-20425712.post-70232121393767958252008-06-05T14:02:00.000+02:002008-06-05T14:02:00.000+02:00Don't get me wrong - I did not mean to imply that ...Don't get me wrong - I did not mean to imply that using AST walker --> not professional. I was just genuinely surprised that WebKit - which I do consider to be a professional implementation - would utilize such a naive execution engine. I was just under the impression - without having investigated - that an AST walker would be slow and that no doubt modern day browsers are already using more sophisticated engines. That's all -- I was just very surprised to discover it was not the case.Attila Szegedihttps://www.blogger.com/profile/08179252447170860637noreply@blogger.comtag:blogger.com,1999:blog-20425712.post-17765916077342553862008-06-05T13:43:00.000+02:002008-06-05T13:43:00.000+02:00It also seemed kind of erroneous to imply that by ...It also seemed kind of erroneous to imply that by using an AST that it was not a "professional" implementation, especially given its performance :pAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-20425712.post-20565429875782948112008-06-05T13:00:00.000+02:002008-06-05T13:00:00.000+02:00It's important to realise the the old JSC AST inte...It's important to realise the the old JSC AST interpreter was very heavily optimised. At the point that the SquirrelFish branch merged the AST interpreter was the fastest browser implementation of JS (including pre-release versions of firefox, opera, etc).<BR/><BR/>The reason for switching to SquirrelFish was quite simply that there was no further room for improvement in the AST interpreter -- a fairly fundamental issue is that loading anything (even literals) requires a virtual call.Anonymousnoreply@blogger.com