Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
daumayr committed Feb 13, 2019
1 parent 893920f commit 5693642
Show file tree
Hide file tree
Showing 15 changed files with 30 additions and 69 deletions.
2 changes: 1 addition & 1 deletion src/som/interpreter/actors/Actor.java
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ public Actor getCurrentActor() {
return currentlyExecutingActor;
}

public void setCurrentActorSnapshot(final Actor current) {
public void setCurrentActorForSnapshot(final Actor current) {
this.currentlyExecutingActor = current;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/som/interpreter/actors/ReceivedRootNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
8 changes: 1 addition & 7 deletions src/som/vm/ObjectSystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -172,10 +170,6 @@ public MixinDefinition loadModule(final Source source) throws IOException {
}
}

public EconomicMap<URI, MixinDefinition> getLoadedModulesForSnapshot() {
return loadedModules;
}

private SObjectWithoutFields constructVmMirror() {
EconomicMap<SSymbol, Dispatchable> vmMirrorMethods = primitives.takeVmMirrorPrimitives();
SClass vmMirrorClass = constructPrimitiveClass(vmMirrorMethods);
Expand Down
6 changes: 0 additions & 6 deletions src/som/vmobjects/SClass.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -156,7 +155,6 @@ public EconomicSet<SlotDefinition> 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;
}
Expand Down Expand Up @@ -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);
Expand Down
1 change: 0 additions & 1 deletion src/tools/concurrency/TracingActivityThread.java
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,6 @@ private void newSnapshot() {
extIndex = 0;
}
}

this.snapshotId = SnapshotBackend.getSnapshotVersion();

// get net snapshotbuffer
Expand Down
2 changes: 1 addition & 1 deletion src/tools/concurrency/TracingActors.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<EventualMessage> todo = determineNextMessages(a.leftovers);

for (EventualMessage msg : todo) {
Expand Down
5 changes: 4 additions & 1 deletion src/tools/snapshot/SnapshotBackend.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -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);
}
Expand Down
23 changes: 0 additions & 23 deletions src/tools/snapshot/SnapshotBuffer.java
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
14 changes: 0 additions & 14 deletions src/tools/snapshot/SnapshotRecord.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<DeferredFarRefSerialization> 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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -147,6 +147,7 @@ public Object deserializeWithoutContext(final long current) {

/**
* This causes the lastRef to stay overwritten for fixup purposes!
*
* @return
*/
public Object getReference() {
Expand Down
9 changes: 8 additions & 1 deletion src/tools/snapshot/nodes/CachedSerializationNode.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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
Expand Down
4 changes: 0 additions & 4 deletions src/tools/snapshot/nodes/MessageSerializationNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down
6 changes: 5 additions & 1 deletion src/tools/snapshot/nodes/ObjectSerializationNodes.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -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++) {
Expand Down
2 changes: 1 addition & 1 deletion src/tools/snapshot/nodes/PromiseSerializationNodes.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
12 changes: 6 additions & 6 deletions tests/snapshot-replay/test.sh
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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++))
Expand Down

0 comments on commit 5693642

Please sign in to comment.