Skip to content

Instantly share code, notes, and snippets.

@FROGGS

FROGGS/foo.diff Secret

Last active January 4, 2016 14:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FROGGS/cc7e4db40bd18c1aec66 to your computer and use it in GitHub Desktop.
Save FROGGS/cc7e4db40bd18c1aec66 to your computer and use it in GitHub Desktop.
diff --git a/src/6model/serialization.c b/src/6model/serialization.c
index 2fda6c0..c932f10 100644
--- a/src/6model/serialization.c
+++ b/src/6model/serialization.c
@@ -1869,11 +1869,26 @@ static void repossess(MVMThreadContext *tc, MVMSerializationReader *reader, MVMi
/* Put it into objects root set at the apporpriate slot. */
MVM_sc_set_object(tc, reader->root.sc, read_int32(table_row, 4), orig_obj);
- /* Ensure we aren't already trying to repossess the object. */
- if (orig_obj->header.sc != orig_sc)
- fail_deserialize(tc, reader,
- "Object conflict detected during deserialization.\n"
- "(Probable attempt to load two modules that cannot be loaded together).");
+ /* If we have a reposession conflict, make a copy of the original object
+ * and reference it from the conflicts list. Push the original (about to
+ * be overwritten) object reference too. */
+ if (orig_obj->header.sc != orig_sc) {
+ MVMROOT(tc, orig_obj, {
+ MVMObject *backup = NULL;
+ MVMROOT(tc, backup, {
+ if (IS_CONCRETE(orig_obj)) {
+ backup = REPR(orig_obj)->allocate(tc, STABLE(orig_obj));
+ REPR(orig_obj)->copy_to(tc, STABLE(orig_obj), OBJECT_BODY(orig_obj), backup, OBJECT_BODY(backup));
+ }
+ else
+ backup = MVM_gc_allocate_type_object(tc, STABLE(orig_obj));
+ });
+
+ MVM_SC_WB_OBJ(tc, backup);
+ MVM_repr_push_o(tc, reader->repo_conflicts_list, backup);
+ MVM_repr_push_o(tc, reader->repo_conflicts_list, orig_obj);
+ });
+ }
/* Clear it up, since we'll re-allocate all the bits inside
* it on deserialization. */
@@ -1931,6 +1946,8 @@ void MVM_serialization_deserialize(MVMThreadContext *tc, MVMSerializationContext
reader->codes_list = codes_static;
scodes = (MVMint32)MVM_repr_elems(tc, codes_static);
+ reader->repo_conflicts_list = repo_conflicts;
+
/* Mark all the static code refs we've been provided with as static. */
for (i = 0; i < scodes; i++) {
MVMObject *scr = MVM_repr_at_pos_o(tc, reader->codes_list, i);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment