* Added checks for when an incorrect number of arguments is passed to a
function
* Added checks for when an argument of object type has mismatching type
(arguments of numeric and string types were already checked for type
mismatches before this commit)
* Added checks for trying to read certain properties of a disposed
object
Follow-up to 9b3240f7b3.
This allows us to choose whether or not to run the destructor when
destroying the coroutines in a way that doesn't cause memory leaks.
We need to call `delete` on the coroutines to actually deallocate their
memory. Calling `->~T()` only runs the destructor without deallocating
the memory afterwards.
This commit moves some of the initialization around so that the core can
handle save states immediately after initialization instead of needing
to run for one frame before save states will work.
I've changed the sandbox fibers in libretro builds to be stored in a
linked list, with an unordered map mapping fiber keys to linked list
nodes for efficient lookup. The original implementation was just having
all the fibers in an unordered map.
The new implementation has the benefit that fibers are always iterated
in the same order on every platform, which allows save state creation to
be more deterministic.
If there are two Ruby objects, A and B, that are both no longer used
(i.e. they're able to be freed by the Ruby garbage collector), and A
references B, then it's possible for the Ruby garbage collector to free
B but not also free A in the same garbage collection cycle.
The pointer unswizzling algorithm currently crashes when the garbage
collector does this because the object A will still be in
`sb()->objects` but B will not be, and so save state serialization will
still try to serialize A. When the pointer unswizzling algorithm tries
to serialize all the other objects A references and cannot find the
referenced object B, the program crashes.
Save states in libretro builds now also contain the state of the
pseudorandom number generator used to implement the WASI `random_get`
function for better save state determinism.
I've also changed the PRNG from MT19937 to PCG.
Libretro provides a way to detect when the OpenGL context is destroyed,
like on Android and possibly also iOS when switching between apps. This
commit implements reinitializing all OpenGL objects when this happens so
that the graphics continue to function in this case.
This is for consistency with standalone builds, which report locale
names without the encoding and with an underscore between the language
and region, e.g. "en_US".