Log in

No account? Create an account
MIPS, I forgive you. - brad's life — LiveJournal [entries|archive|friends|userinfo]
Brad Fitzpatrick

[ website | bradfitz.com ]
[ userinfo | livejournal userinfo ]
[ archive | journal archive ]

MIPS, I forgive you. [Dec. 5th, 2000|01:58 pm]
Brad Fitzpatrick
Now that I understand you, I no longer hate you.
Most everything's working now.
I added runtime array index bounds checking too.
3 extra instructions per array access. Bleh.

I'm convinced that a lot of bounds checking can be done at compile time... if you wanted to write a language that was safe, i'm sure you could get a compiler to remove a lot of the instructions to check array access and only leave in the ones where the index was unknown (like if it was coming from user input).

you'd just need to make a data structure to represent sets efficiently (easy) and then for each variable used, figure out what values it can take on at any point in the program. For a loop (the place you'd like to remove array bounds checking the most) the set's easy if the loop iterator is your array index... the set is usually [start, finish] (in a language with a for statment like for StartExpr to EndExpr). it gets more complicated if the language lets you do stuff like C and specify code to run on every loop iteration to keep going or not. hrm.. there's a trade-off between writing in a low level language like C that's fast but the compiler can't tell what you're doing and thus can't optimize much and writing in a higher level language that's slower (at least for the naive implementation) but where it really good optimizations could potentially be made since it's obvious what you're doing.

hm. i'm rambling. the above makes little sense.

back to homework.

[User Picture]From: sylvie
2000-12-05 02:33 pm (UTC)
yoooou should update your journal more often. because i'm sick and i'm dying of boredom. and it seems like nobody else updates more than once or twice a day.
that made sense, really it did.
i guess i'll go back to my multivar. multivar is funner than calc. ( :
(Reply) (Thread)