jump tables and cases
Stephen Weeks
MLton@sourcelight.com
Mon, 4 Dec 2000 10:09:33 -0800 (PST)
> Were the changes to preserve big integer case statements ever added to
> MLton?
Yes. Although I'm not sure they're getting used. It's near the top of my todo
list to look into mlyacc and make sure they are.
> I went ahead and added support to generate jump tables to the
> x86-backend. That was the last feature I really wanted to get into the
> backend, and it should also help with compile times (in particular, the
> datatype representing x86 instructions has 50 variants, and I crawl over
> this a lot).
For datatypes, the backend has always generated switch statements. The only
new thing is handling of source level integer cases.
> I recall that Steve pointed out that mlyacc generated
> parsers have big integer case statements, so it might also improve the
> parse phase.
Yep.
> One other point: I know at some point I told Stephen to change the generated
> code (in C) for switching over things that had a single tag bit at the bottom
> to first shift the quantity right by 1 so that the jump table would be dense.
> I don't remember what was being switched over, but it was definitely a win in
> my tests.
Yes, this was for datatypes which have value and nonvalue carrying variants,
where the value carrying variants are represented as odd integers. The right
place to do this is the backend. It's still on the todo list.
> O.k. We might consider doing the same thing for cases on words.
OKOK. It's on the todo list too. I had only done source level integer cases.
Now that I've done that, words should be easy.