Move runtime errors from ThreadState to FunctionState, and maintain a list of
all produced runtime errors during the function call's lifetime.

The runtime errors are held in a RuntimeErrorState object, which also records
the index of the instruction that caused the error.