[MUD-Dev] byte-code anyone?

Chris Gray cg at ami-cg.GraySage.Edmonton.AB.CA
Fri Feb 20 18:01:28 CET 1998


[Jon Leonard:]

:Maybe I should have said "test with tiny cases first".  Whenever I've
:spent a long time tracking down a bug, it turns out that there's a simpler
:test that would have shown me the bug if I'd been more careful.
:Consequently, I test for correctness early and often.

Fully agreed here. I did in fact run some simple byte-code functions late
that weekend, but haven't done much since then. Most of my work gets done
on weekends. My main problems so far have been issues involving the
integration of the byte-code stuff with the rest of the system. Right
now the compiled byte-code gets saved in the DB, and loaded when the
function is referenced, but somewhere just after that, the byte-code
pointer seems to get NULL-ed. I'll get there eventually!

:That is the other option, controlling all the possible bytecode sources.
:Since my design calls for (eventually) passing code between servers that
:don't trust each other, I can't do that.

Ah yes, that'll do it. The same with Java, of course.

:It's a matter of taste, efficiency, and paranoia.
:
:I'm a little suprised that the default case slows it down a lot.  Maybe
:the C compiler doesn't know to just translate it as an index into a
:256-element jump table (I assume you switch() on a byte), and fill in
:all the unspecified ones with the default.

Well, I'm currently doing this with a non-C compiler of my own, so I'm
fully to blame for any inefficiencies. Currently, the compiler will omit
testing for range if the index type is an enumeration and all of the
enumeration values are explicitly mentioned in the case statement. The
choice between an index-case and a binary-search-case is based on the
density of the values. But you are right, I could likely note that the
index type is 1-byte, and just make a large enough table. I've also
thought about making the opcodes all be multiples of 2, so that the
case code doesn't have to do the shift to access the offsets (which
would also require hacking the compiler). The C version of my system
will be updated when the byte-code is done - I struggled with the choice
of which version to work in for this, and decided I prefer my own
language, and want to keep that version up-to-date anyway.

:File that under "Jon's advice to himself", then.  This stuff is taking
:me quite a while.  Maybe the fact that I keep working on other things
:is at fault.

Nod. I have even weaker excuses, actually :-(

--
Chris Gray   cg at ami-cg.GraySage.Edmonton.AB.CA



More information about the mud-dev-archive mailing list