[sgen] Extract the handle array code for reuse
We add a new data structure which contains a bucket of entries, exponentially increasing in sizes. The structure is customizable through a few callbacks.
Setting is_slot_set_func enables us to also lookup empty slots, instead of only adding entries at the end of the list.
Setting set_slot_func enables the use of a customized function for setting the slot. If this function is not set, the slots and array fields will be set directly, therefore the structure won't be thread safe.