Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Make object repossession respect STable changes.
  • Loading branch information
jnthn committed Mar 12, 2015
1 parent 6d19df1 commit 92223a6
Showing 1 changed file with 23 additions and 11 deletions.
34 changes: 23 additions & 11 deletions src/vm/jvm/runtime/org/perl6/nqp/sixmodel/SerializationReader.java
Expand Up @@ -101,14 +101,16 @@ public void deserialize() {
sc.addCodeRef(cr[i]);
}

// Handle any reposessions.
// Handle any STable repossessions, then stub STables.
sc.initSTableList(stTableEntries);
sc.initObjectList(objTableEntries);
if (reposTableEntries > 0)
repossess();

// Stub all of the STables and objects.
repossess(1);
stubSTables();

// Handle any object repossessions, then stub objects.
sc.initObjectList(objTableEntries);
if (reposTableEntries > 0)
repossess(0);
stubObjects();

// Do first step of deserializing any closures.
Expand Down Expand Up @@ -241,13 +243,15 @@ private void resolveDependencies() {
}

/* Repossess an object or STable. */
private void repossess() {
private void repossess(int chosenType) {
for (int i = 0; i < reposTableEntries; i++) {
/* Go to table row. */
orig.position(reposTableOffset + i * REPOS_TABLE_ENTRY_SIZE);

/* Do appropriate type of repossession. */
int repoType = orig.getInt();
if (repoType != chosenType)
continue;
int objIdx = orig.getInt();
int origSCIdx = orig.getInt();
int origObjIdx = orig.getInt();
Expand All @@ -256,22 +260,30 @@ private void repossess() {
SerializationContext origSC = locateSC(origSCIdx);
SixModelObject origObj = origSC.getObject(origObjIdx);

/* Ensure we aren't already trying to repossess the object. */
/* XXX TODO */

/* Put it into objects root set at the apporpriate slot. */
sc.addObject(origObj, objIdx);
origObj.sc = sc;

/* Ensure we aren't already trying to repossess the object. */
/* XXX TODO */
/* The object's STable may have changed as a result of the
* repossession (perhaps due to mixing in to it), so put the
* STable it should now have in place. */
orig.position(objTableOffset + objIdx * OBJECTS_TABLE_ENTRY_SIZE);
origObj.st = lookupSTable(orig.getInt(), orig.getInt());
}
else if (repoType == 1) {
/* Get STable to repossess. */
SerializationContext origSC = locateSC(origSCIdx);
STable origST = origSC.getSTable(origObjIdx);

/* Put it into STables root set at the apporpriate slot. */
sc.setSTable(objIdx, origST);

/* Ensure we aren't already trying to repossess the STable. */
/* XXX TODO */

/* Put it into STables root set at the apporpriate slot. */
sc.setSTable(objIdx, origST);
origST.sc = sc;
}
else {
throw new RuntimeException("Unknown repossession type");
Expand Down

0 comments on commit 92223a6

Please sign in to comment.