diff --git a/src/som/interpreter/actors/Actor.java b/src/som/interpreter/actors/Actor.java index 10a9e5f81..ed16085a0 100644 --- a/src/som/interpreter/actors/Actor.java +++ b/src/som/interpreter/actors/Actor.java @@ -404,7 +404,7 @@ public Actor getCurrentActor() { return currentlyExecutingActor; } - public void setCurrentActorSnapshot(final Actor current) { + public void setCurrentActorForSnapshot(final Actor current) { this.currentlyExecutingActor = current; } } diff --git a/src/som/interpreter/actors/ReceivedRootNode.java b/src/som/interpreter/actors/ReceivedRootNode.java index 5a274c7f4..e1847292d 100644 --- a/src/som/interpreter/actors/ReceivedRootNode.java +++ b/src/som/interpreter/actors/ReceivedRootNode.java @@ -145,7 +145,7 @@ public SourceSection getSourceSection() { return sourceSection; } - private final long serializeMessageIfNecessary(final EventualMessage msg, + private long serializeMessageIfNecessary(final EventualMessage msg, final SnapshotBuffer sb) { if (sb.getRecord().containsObject(msg)) { diff --git a/src/som/vm/ObjectSystem.java b/src/som/vm/ObjectSystem.java index a9d8b43d9..f99fdb0e4 100644 --- a/src/som/vm/ObjectSystem.java +++ b/src/som/vm/ObjectSystem.java @@ -102,9 +102,7 @@ public ObjectSystem(final SourcecodeCompiler compiler, this.compiler = compiler; structuralProbe = probe; loadedModules = EconomicMap.create(); - if (VmSettings.SNAPSHOTS_ENABLED) { - // List is not modified, only used at program termination to know which modules need to - // be loaded in replay + if (VmSettings.SNAPSHOT_REPLAY) { SnapshotBackend.registerLoadedModules(loadedModules); } this.vm = vm; @@ -172,10 +170,6 @@ public MixinDefinition loadModule(final Source source) throws IOException { } } - public EconomicMap getLoadedModulesForSnapshot() { - return loadedModules; - } - private SObjectWithoutFields constructVmMirror() { EconomicMap vmMirrorMethods = primitives.takeVmMirrorPrimitives(); SClass vmMirrorClass = constructPrimitiveClass(vmMirrorMethods); diff --git a/src/som/vmobjects/SClass.java b/src/som/vmobjects/SClass.java index 1a2ecfbe0..d27c23875 100644 --- a/src/som/vmobjects/SClass.java +++ b/src/som/vmobjects/SClass.java @@ -35,7 +35,6 @@ import com.oracle.truffle.api.frame.MaterializedFrame; import com.oracle.truffle.api.nodes.ExplodeLoop; -import som.Output; import som.VM; import som.compiler.AccessModifier; import som.compiler.MixinBuilder.MixinDefinitionId; @@ -156,7 +155,6 @@ public EconomicSet getInstanceSlots() { public void initializeClass(final SSymbol name, final SClass superclass) { assert (this.name == null || this.name == name) && (this.superclass == null || this.superclass == superclass) : "Should only be initialized once"; - this.name = name; this.superclass = superclass; } @@ -387,10 +385,6 @@ public MaterializedFrame getContext() { } public void serialize(final Object o, final SnapshotBuffer sb) { - if (instanceClassGroup == null) { - Output.errorPrintln(this.toString()); - } - assert instanceClassGroup != null; if (!sb.getRecord().containsObjectUnsync(o)) { instanceClassGroup.serialize(o, sb); diff --git a/src/tools/concurrency/TracingActivityThread.java b/src/tools/concurrency/TracingActivityThread.java index 72f78b050..6782a82ad 100644 --- a/src/tools/concurrency/TracingActivityThread.java +++ b/src/tools/concurrency/TracingActivityThread.java @@ -244,7 +244,6 @@ private void newSnapshot() { extIndex = 0; } } - this.snapshotId = SnapshotBackend.getSnapshotVersion(); // get net snapshotbuffer diff --git a/src/tools/concurrency/TracingActors.java b/src/tools/concurrency/TracingActors.java index 15d4704dd..ff3e54108 100644 --- a/src/tools/concurrency/TracingActors.java +++ b/src/tools/concurrency/TracingActors.java @@ -432,8 +432,8 @@ protected void processCurrentMessages(final ActorProcessingThread currentThread, final WebDebugger dbg) { assert actor instanceof ReplayActor; assert size > 0; - final ReplayActor a = (ReplayActor) actor; + final ReplayActor a = (ReplayActor) actor; Queue todo = determineNextMessages(a.leftovers); for (EventualMessage msg : todo) { diff --git a/src/tools/snapshot/SnapshotBackend.java b/src/tools/snapshot/SnapshotBackend.java index bf480c663..cfb75b920 100644 --- a/src/tools/snapshot/SnapshotBackend.java +++ b/src/tools/snapshot/SnapshotBackend.java @@ -359,7 +359,7 @@ public static void writeSnapshot() { for (SnapshotRecord sr : deferredSerializations.keySet()) { assert sr.owner != null; deferredSerializations.remove(sr); - buffer.owner.setCurrentActorSnapshot(sr.owner); + buffer.owner.setCurrentActorForSnapshot(sr.owner); sr.handleObjectsReferencedFromFarRefs(buffer, classPrim); } } @@ -532,6 +532,9 @@ public static void registerLostResolution(final SResolver resolver, } public static void registerClassLocation(final int identity, final long classLocation) { + if (VmSettings.TEST_SNAPSHOTS) { + return; + } synchronized (classLocations) { classLocations.put(identity, classLocation); } diff --git a/src/tools/snapshot/SnapshotBuffer.java b/src/tools/snapshot/SnapshotBuffer.java index 50c78756b..883263514 100644 --- a/src/tools/snapshot/SnapshotBuffer.java +++ b/src/tools/snapshot/SnapshotBuffer.java @@ -69,29 +69,6 @@ public int addObject(final Object o, final SClass clazz, final int payload) { return oldPos + CLASS_ID_SIZE; } - public int addObjectWithFields(final Object o, final SClass clazz, - final int fieldCnt) { - assert fieldCnt < MAX_FIELD_CNT; - assert !getRecord().containsObjectUnsync(o) : "Object serialized multiple times"; - - int oldPos = this.position; - getRecord().addObjectEntry(o, calculateReference(oldPos)); - - if (clazz.getSOMClass() == Classes.classClass) { - TracingActor owner = clazz.getOwnerOfOuter(); - if (owner == null) { - owner = (TracingActor) SomLanguage.getCurrent().getVM().getMainActor(); - } - - assert owner != null; - owner.getSnapshotRecord().farReference(clazz, null, 0); - } - - this.putIntAt(this.position, clazz.getIdentity()); - this.position += CLASS_ID_SIZE + (FIELD_SIZE * fieldCnt); - return oldPos + CLASS_ID_SIZE; - } - public int addMessage(final int payload, final EventualMessage msg) { // we dont put messages into our lookup table as there should be only one reference to it // (either from a promise or a mailbox) diff --git a/src/tools/snapshot/SnapshotRecord.java b/src/tools/snapshot/SnapshotRecord.java index 8e2953c7d..6b1639368 100644 --- a/src/tools/snapshot/SnapshotRecord.java +++ b/src/tools/snapshot/SnapshotRecord.java @@ -113,20 +113,6 @@ public void handleObjectsReferencedFromFarRefs(final SnapshotBuffer sb, */ public void farReference(final Object o, final SnapshotBuffer other, final int destination) { - - // Have to do this to avoid a memory leak, actors that are inactive for a long time, but - // farReffed by others ended up keeping alive a large number of SnapshotBuffers. - - /* - * ConcurrentLinkedQueue oldReferences = externalReferences; - * externalReferences = new ConcurrentLinkedQueue<>(); - * for (DeferredFarRefSerialization deffered : oldReferences) { - * if (deffered.referer.snapshotVersion == this.snapshotVersion) { - * externalReferences.add(deffered); - * } - * } - */ - Long l = getEntrySynced(o); if (l != null && other != null) { diff --git a/src/tools/snapshot/deserialization/DeserializationBuffer.java b/src/tools/snapshot/deserialization/DeserializationBuffer.java index fe4e748c5..577ea10fe 100644 --- a/src/tools/snapshot/deserialization/DeserializationBuffer.java +++ b/src/tools/snapshot/deserialization/DeserializationBuffer.java @@ -103,7 +103,7 @@ public Object deserialize(final long current) { public long readOuterForClass(final long classLocation) { long previous = this.position(); this.position(classLocation); - this.getInt();// consume the classclass information + this.getInt(); // consume the classclass information long result = ClassSerializationNode.readOuterLocation(this); this.position(previous); return result; @@ -147,6 +147,7 @@ public Object deserializeWithoutContext(final long current) { /** * This causes the lastRef to stay overwritten for fixup purposes! + * * @return */ public Object getReference() { diff --git a/src/tools/snapshot/nodes/CachedSerializationNode.java b/src/tools/snapshot/nodes/CachedSerializationNode.java index 7c3f6f3f2..9c3eb4d06 100644 --- a/src/tools/snapshot/nodes/CachedSerializationNode.java +++ b/src/tools/snapshot/nodes/CachedSerializationNode.java @@ -1,6 +1,7 @@ package tools.snapshot.nodes; import com.oracle.truffle.api.Assumption; +import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.GenerateNodeFactory; import com.oracle.truffle.api.dsl.NodeFactory; @@ -10,6 +11,7 @@ import som.interpreter.Types; import som.interpreter.nodes.dispatch.DispatchGuard; import som.primitives.ObjectPrims.ClassPrim; +import som.primitives.ObjectPrimsFactory.ClassPrimFactory; import som.vm.VmSettings; import som.vmobjects.SClass; import tools.snapshot.SnapshotBuffer; @@ -64,7 +66,12 @@ public void serialize(final Object o, final SnapshotBuffer sb, @Specialization public void fallback(final Object o, final SnapshotBuffer sb) { - Types.getClassOf(o).serialize(o, sb); + if (classprim == null) { + CompilerDirectives.transferToInterpreter(); + classprim = ClassPrimFactory.create(null); + } + + classprim.executeEvaluated(o).serialize(o, sb); } @Override diff --git a/src/tools/snapshot/nodes/MessageSerializationNode.java b/src/tools/snapshot/nodes/MessageSerializationNode.java index 1015e613e..9e152d3d7 100644 --- a/src/tools/snapshot/nodes/MessageSerializationNode.java +++ b/src/tools/snapshot/nodes/MessageSerializationNode.java @@ -7,7 +7,6 @@ import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.nodes.ExplodeLoop; -import som.Output; import som.interpreter.SomLanguage; import som.interpreter.actors.Actor; import som.interpreter.actors.EventualMessage; @@ -547,9 +546,6 @@ public void setMessage(final PromiseMessage pm) { @Override public void fixUp(final Object o) { - if (o == null) { - Output.println("Test"); - } assert pm != null && o != null; this.pm.setPromise((SPromise) o); } diff --git a/src/tools/snapshot/nodes/ObjectSerializationNodes.java b/src/tools/snapshot/nodes/ObjectSerializationNodes.java index b6927ba39..b24afa98f 100644 --- a/src/tools/snapshot/nodes/ObjectSerializationNodes.java +++ b/src/tools/snapshot/nodes/ObjectSerializationNodes.java @@ -35,6 +35,8 @@ public abstract class ObjectSerializationNodes { + public static final int FIELD_SIZE = 8; + public static final int MAX_FIELD_CNT = Byte.MAX_VALUE; public abstract static class ObjectSerializationNode extends AbstractSerializationNode { @@ -186,7 +188,9 @@ public void serialize(final SObject so, final SnapshotBuffer sb) { @ExplodeLoop public void doCached(final SObject o, final SnapshotBuffer sb) { - int base = sb.addObjectWithFields(o, o.getSOMClass(), fieldCnt); + int base = sb.addObject(o, o.getSOMClass(), FIELD_SIZE * fieldCnt); + + assert fieldCnt < MAX_FIELD_CNT; SnapshotRecord record = sb.getRecord(); for (int i = 0; i < fieldCnt; i++) { diff --git a/src/tools/snapshot/nodes/PromiseSerializationNodes.java b/src/tools/snapshot/nodes/PromiseSerializationNodes.java index dfc8823af..e87ab36f6 100644 --- a/src/tools/snapshot/nodes/PromiseSerializationNodes.java +++ b/src/tools/snapshot/nodes/PromiseSerializationNodes.java @@ -292,7 +292,7 @@ private SPromise deserializeUnresolvedPromise(final DeserializationBuffer sb) { return promise; } - private static final void initialiseChainedPromise(final STracingPromise p, + private static void initialiseChainedPromise(final STracingPromise p, final SPromise remote) { boolean complete = remote.isCompleted(); int resolver = p.getResolvingActor(); diff --git a/tests/snapshot-replay/test.sh b/tests/snapshot-replay/test.sh index b3e9b2fc9..4f543ca40 100755 --- a/tests/snapshot-replay/test.sh +++ b/tests/snapshot-replay/test.sh @@ -1,12 +1,12 @@ #!/bin/bash # quit on first error set -e -iterations=100 +iterations=1 if [ "$1" = "1" ] then declare -a Savina=( - #"PingPong $iterations 0 40000" + "PingPong $iterations 0 40000" "Counting $iterations 0 50000" "ForkJoinThroughput $iterations 0 300:60" "ForkJoinActorCreation $iterations 0 4000" @@ -43,16 +43,16 @@ SOM_DIR=$SCRIPT_PATH/../.. for args in "${Savina[@]}" do counter=1 - while [ $counter -le 1 ] + while [ $counter -le 10 ] do echo "$counter. $args" echo "Tracing:" $SOM_DIR/som -EG -as -at -JXmx3000m -JXss8192k core-lib/Benchmarks/AsyncHarness.ns SavinaSnap.$args echo "" - #echo "Replay:" - #$SOM_DIR/som -EG -as -r -JXmx2000m -JXss8192k -vmd core-lib/Benchmarks/AsyncHarness.ns SavinaSnap.$args - #echo "" + echo "Replay:" + $SOM_DIR/som -EG -as -r -JXmx2000m -JXss8192k -vmd core-lib/Benchmarks/AsyncHarness.ns SavinaSnap.$args + echo "" echo "========================================================" echo "" ((counter++))