Re: Include in standard library or build in?
- Posted by CChris <christian.cuvier at ag??culture.gouv.fr> Apr 28, 2008
- 623 views
Jeremy Cowgar wrote: > > If I understand the interpreter correctly (and I probably do not), it's a > large > switch statement? Doesn't a switch statement like this have a large % of jump > offset errors, thus, the more items you add to the switch the slower the > switch > actually gets? > The backend, once the code is properly converted and formatted, is a big switch that executes VM opcodes sequentially. If threaded code is enabled (works with some compilers only), then there is no penalty in having a bigger switch, because all switch branches jump to the branch corresponding to the next opcode. Which "jump offset errors" are you talking about? * Stack offset errors my be caused by a change of compiler version, and affect c_func() and friends. You told us about such an issue with gcc 4.3 recently. * Cache misses because of jumping too much around may increase with the size of the switch statement. However, the most frequently executed statements will be properly predicted and cached pretty often, so that the net effect will be very much dampened. The CPU instruction cache size obviously matters too. CChris > Now... after saying that, let me prefix it with, I've only done very minimal > reading about how internals of interpreters work. I've written some very small > domain specific interpreters, but nothing at all even close to as advanced as > Euphoria. Therefore, what I understand above may be totally off base. > > -- > Jeremy Cowgar > <a href="http://jeremy.cowgar.com">http://jeremy.cowgar.com</a>