For the runtime optimizer (Sista) I am working on, Eliot Miranda and I added new operations (we call them unsafe operations) in Cog’s interpreter and JIT compiler. Before testing them directly by running the optimizer and looking for crashes, I wrote tests to check that each unsafe operation works as expected. I’d like to discuss a bit the design of those tests in this post.
I’ll discuss a specific operation in the post, but all the unsafe operations are handled in a similar way. The operation I chose to described is called USmiLessOrEqual. This operation corresponds to <= but assumes the 2 operands are SmallIntegers, else the behavior of the instruction is undefined. The optimizer uses it only when it can ensure that the two operands are SmallIntegers.
What to test
To test USmiLessOrEqual, one could think I’m going to take an important range of integers and…
View original post 2,352 more words