Skip to content

Commit 0c9b1b6

Browse files
committed
cleanup
1 parent 893920f commit 0c9b1b6

17 files changed

+33
-74
lines changed

src/som/interpreter/actors/Actor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ public Actor getCurrentActor() {
404404
return currentlyExecutingActor;
405405
}
406406

407-
public void setCurrentActorSnapshot(final Actor current) {
407+
public void setCurrentActorForSnapshot(final Actor current) {
408408
this.currentlyExecutingActor = current;
409409
}
410410
}

src/som/interpreter/actors/ReceivedRootNode.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ public SourceSection getSourceSection() {
145145
return sourceSection;
146146
}
147147

148-
private final long serializeMessageIfNecessary(final EventualMessage msg,
148+
private long serializeMessageIfNecessary(final EventualMessage msg,
149149
final SnapshotBuffer sb) {
150150

151151
if (sb.getRecord().containsObject(msg)) {

src/som/primitives/ObjectPrims.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -180,11 +180,9 @@ public int getNumArguments() {
180180
@ImportStatic(Nil.class)
181181
@GenerateWrapper
182182
public abstract static class IsValue extends UnaryExpressionNode {
183-
protected IsValue() {
184-
}
183+
protected IsValue() {}
185184

186-
protected IsValue(final IsValue node) {
187-
}
185+
protected IsValue(final IsValue node) {}
188186

189187
@Override
190188
public abstract Object executeEvaluated(VirtualFrame frame, Object rcvr);

src/som/vm/ObjectSystem.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,7 @@ public ObjectSystem(final SourcecodeCompiler compiler,
102102
this.compiler = compiler;
103103
structuralProbe = probe;
104104
loadedModules = EconomicMap.create();
105-
if (VmSettings.SNAPSHOTS_ENABLED) {
106-
// List is not modified, only used at program termination to know which modules need to
107-
// be loaded in replay
105+
if (VmSettings.SNAPSHOT_REPLAY) {
108106
SnapshotBackend.registerLoadedModules(loadedModules);
109107
}
110108
this.vm = vm;
@@ -172,10 +170,6 @@ public MixinDefinition loadModule(final Source source) throws IOException {
172170
}
173171
}
174172

175-
public EconomicMap<URI, MixinDefinition> getLoadedModulesForSnapshot() {
176-
return loadedModules;
177-
}
178-
179173
private SObjectWithoutFields constructVmMirror() {
180174
EconomicMap<SSymbol, Dispatchable> vmMirrorMethods = primitives.takeVmMirrorPrimitives();
181175
SClass vmMirrorClass = constructPrimitiveClass(vmMirrorMethods);

src/som/vmobjects/SClass.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
import com.oracle.truffle.api.frame.MaterializedFrame;
3636
import com.oracle.truffle.api.nodes.ExplodeLoop;
3737

38-
import som.Output;
3938
import som.VM;
4039
import som.compiler.AccessModifier;
4140
import som.compiler.MixinBuilder.MixinDefinitionId;
@@ -156,7 +155,6 @@ public EconomicSet<SlotDefinition> getInstanceSlots() {
156155
public void initializeClass(final SSymbol name, final SClass superclass) {
157156
assert (this.name == null || this.name == name) && (this.superclass == null
158157
|| this.superclass == superclass) : "Should only be initialized once";
159-
160158
this.name = name;
161159
this.superclass = superclass;
162160
}
@@ -387,10 +385,6 @@ public MaterializedFrame getContext() {
387385
}
388386

389387
public void serialize(final Object o, final SnapshotBuffer sb) {
390-
if (instanceClassGroup == null) {
391-
Output.errorPrintln(this.toString());
392-
}
393-
394388
assert instanceClassGroup != null;
395389
if (!sb.getRecord().containsObjectUnsync(o)) {
396390
instanceClassGroup.serialize(o, sb);

src/tools/concurrency/TracingActivityThread.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,6 @@ private void newSnapshot() {
244244
extIndex = 0;
245245
}
246246
}
247-
248247
this.snapshotId = SnapshotBackend.getSnapshotVersion();
249248

250249
// get net snapshotbuffer

src/tools/concurrency/TracingActors.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,8 +432,8 @@ protected void processCurrentMessages(final ActorProcessingThread currentThread,
432432
final WebDebugger dbg) {
433433
assert actor instanceof ReplayActor;
434434
assert size > 0;
435-
final ReplayActor a = (ReplayActor) actor;
436435

436+
final ReplayActor a = (ReplayActor) actor;
437437
Queue<EventualMessage> todo = determineNextMessages(a.leftovers);
438438

439439
for (EventualMessage msg : todo) {

src/tools/snapshot/SnapshotBackend.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ public static void writeSnapshot() {
359359
for (SnapshotRecord sr : deferredSerializations.keySet()) {
360360
assert sr.owner != null;
361361
deferredSerializations.remove(sr);
362-
buffer.owner.setCurrentActorSnapshot(sr.owner);
362+
buffer.owner.setCurrentActorForSnapshot(sr.owner);
363363
sr.handleObjectsReferencedFromFarRefs(buffer, classPrim);
364364
}
365365
}
@@ -532,6 +532,9 @@ public static void registerLostResolution(final SResolver resolver,
532532
}
533533

534534
public static void registerClassLocation(final int identity, final long classLocation) {
535+
if (VmSettings.TEST_SNAPSHOTS) {
536+
return;
537+
}
535538
synchronized (classLocations) {
536539
classLocations.put(identity, classLocation);
537540
}

src/tools/snapshot/SnapshotBuffer.java

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -69,29 +69,6 @@ public int addObject(final Object o, final SClass clazz, final int payload) {
6969
return oldPos + CLASS_ID_SIZE;
7070
}
7171

72-
public int addObjectWithFields(final Object o, final SClass clazz,
73-
final int fieldCnt) {
74-
assert fieldCnt < MAX_FIELD_CNT;
75-
assert !getRecord().containsObjectUnsync(o) : "Object serialized multiple times";
76-
77-
int oldPos = this.position;
78-
getRecord().addObjectEntry(o, calculateReference(oldPos));
79-
80-
if (clazz.getSOMClass() == Classes.classClass) {
81-
TracingActor owner = clazz.getOwnerOfOuter();
82-
if (owner == null) {
83-
owner = (TracingActor) SomLanguage.getCurrent().getVM().getMainActor();
84-
}
85-
86-
assert owner != null;
87-
owner.getSnapshotRecord().farReference(clazz, null, 0);
88-
}
89-
90-
this.putIntAt(this.position, clazz.getIdentity());
91-
this.position += CLASS_ID_SIZE + (FIELD_SIZE * fieldCnt);
92-
return oldPos + CLASS_ID_SIZE;
93-
}
94-
9572
public int addMessage(final int payload, final EventualMessage msg) {
9673
// we dont put messages into our lookup table as there should be only one reference to it
9774
// (either from a promise or a mailbox)

src/tools/snapshot/SnapshotRecord.java

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -113,20 +113,6 @@ public void handleObjectsReferencedFromFarRefs(final SnapshotBuffer sb,
113113
*/
114114
public void farReference(final Object o, final SnapshotBuffer other,
115115
final int destination) {
116-
117-
// Have to do this to avoid a memory leak, actors that are inactive for a long time, but
118-
// farReffed by others ended up keeping alive a large number of SnapshotBuffers.
119-
120-
/*
121-
* ConcurrentLinkedQueue<DeferredFarRefSerialization> oldReferences = externalReferences;
122-
* externalReferences = new ConcurrentLinkedQueue<>();
123-
* for (DeferredFarRefSerialization deffered : oldReferences) {
124-
* if (deffered.referer.snapshotVersion == this.snapshotVersion) {
125-
* externalReferences.add(deffered);
126-
* }
127-
* }
128-
*/
129-
130116
Long l = getEntrySynced(o);
131117

132118
if (l != null && other != null) {

src/tools/snapshot/deserialization/DeserializationBuffer.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public Object deserialize(final long current) {
103103
public long readOuterForClass(final long classLocation) {
104104
long previous = this.position();
105105
this.position(classLocation);
106-
this.getInt();// consume the classclass information
106+
this.getInt(); // consume the classclass information
107107
long result = ClassSerializationNode.readOuterLocation(this);
108108
this.position(previous);
109109
return result;
@@ -147,6 +147,7 @@ public Object deserializeWithoutContext(final long current) {
147147

148148
/**
149149
* This causes the lastRef to stay overwritten for fixup purposes!
150+
*
150151
* @return
151152
*/
152153
public Object getReference() {

src/tools/snapshot/nodes/CachedSerializationNode.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package tools.snapshot.nodes;
22

33
import com.oracle.truffle.api.Assumption;
4+
import com.oracle.truffle.api.CompilerDirectives;
45
import com.oracle.truffle.api.dsl.Cached;
56
import com.oracle.truffle.api.dsl.GenerateNodeFactory;
67
import com.oracle.truffle.api.dsl.NodeFactory;
@@ -10,6 +11,7 @@
1011
import som.interpreter.Types;
1112
import som.interpreter.nodes.dispatch.DispatchGuard;
1213
import som.primitives.ObjectPrims.ClassPrim;
14+
import som.primitives.ObjectPrimsFactory.ClassPrimFactory;
1315
import som.vm.VmSettings;
1416
import som.vmobjects.SClass;
1517
import tools.snapshot.SnapshotBuffer;
@@ -64,7 +66,12 @@ public void serialize(final Object o, final SnapshotBuffer sb,
6466

6567
@Specialization
6668
public void fallback(final Object o, final SnapshotBuffer sb) {
67-
Types.getClassOf(o).serialize(o, sb);
69+
if (classprim == null) {
70+
CompilerDirectives.transferToInterpreter();
71+
classprim = ClassPrimFactory.create(null);
72+
}
73+
74+
classprim.executeEvaluated(o).serialize(o, sb);
6875
}
6976

7077
@Override

src/tools/snapshot/nodes/MessageSerializationNode.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import com.oracle.truffle.api.dsl.Specialization;
88
import com.oracle.truffle.api.nodes.ExplodeLoop;
99

10-
import som.Output;
1110
import som.interpreter.SomLanguage;
1211
import som.interpreter.actors.Actor;
1312
import som.interpreter.actors.EventualMessage;
@@ -547,9 +546,6 @@ public void setMessage(final PromiseMessage pm) {
547546

548547
@Override
549548
public void fixUp(final Object o) {
550-
if (o == null) {
551-
Output.println("Test");
552-
}
553549
assert pm != null && o != null;
554550
this.pm.setPromise((SPromise) o);
555551
}

src/tools/snapshot/nodes/ObjectSerializationNodes.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@
3535

3636

3737
public abstract class ObjectSerializationNodes {
38+
public static final int FIELD_SIZE = 8;
39+
public static final int MAX_FIELD_CNT = Byte.MAX_VALUE;
3840

3941
public abstract static class ObjectSerializationNode extends AbstractSerializationNode {
4042

@@ -186,7 +188,9 @@ public void serialize(final SObject so, final SnapshotBuffer sb) {
186188

187189
@ExplodeLoop
188190
public void doCached(final SObject o, final SnapshotBuffer sb) {
189-
int base = sb.addObjectWithFields(o, o.getSOMClass(), fieldCnt);
191+
int base = sb.addObject(o, o.getSOMClass(), FIELD_SIZE * fieldCnt);
192+
193+
assert fieldCnt < MAX_FIELD_CNT;
190194

191195
SnapshotRecord record = sb.getRecord();
192196
for (int i = 0; i < fieldCnt; i++) {

src/tools/snapshot/nodes/PromiseSerializationNodes.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ private SPromise deserializeUnresolvedPromise(final DeserializationBuffer sb) {
292292
return promise;
293293
}
294294

295-
private static final void initialiseChainedPromise(final STracingPromise p,
295+
private static void initialiseChainedPromise(final STracingPromise p,
296296
final SPromise remote) {
297297
boolean complete = remote.isCompleted();
298298
int resolver = p.getResolvingActor();

tests/snapshot-replay/test.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
#!/bin/bash
22
# quit on first error
33
set -e
4-
iterations=100
4+
iterations=1
55

66
if [ "$1" = "1" ]
77
then
88
declare -a Savina=(
9-
#"PingPong $iterations 0 40000"
9+
"PingPong $iterations 0 40000"
1010
"Counting $iterations 0 50000"
1111
"ForkJoinThroughput $iterations 0 300:60"
1212
"ForkJoinActorCreation $iterations 0 4000"
@@ -43,16 +43,16 @@ SOM_DIR=$SCRIPT_PATH/../..
4343
for args in "${Savina[@]}"
4444
do
4545
counter=1
46-
while [ $counter -le 1 ]
46+
while [ $counter -le 10 ]
4747
do
4848

4949
echo "$counter. $args"
5050
echo "Tracing:"
5151
$SOM_DIR/som -EG -as -at -JXmx3000m -JXss8192k core-lib/Benchmarks/AsyncHarness.ns SavinaSnap.$args
5252
echo ""
53-
#echo "Replay:"
54-
#$SOM_DIR/som -EG -as -r -JXmx2000m -JXss8192k -vmd core-lib/Benchmarks/AsyncHarness.ns SavinaSnap.$args
55-
#echo ""
53+
echo "Replay:"
54+
$SOM_DIR/som -EG -as -r -JXmx2000m -JXss8192k -vmd core-lib/Benchmarks/AsyncHarness.ns SavinaSnap.$args
55+
echo ""
5656
echo "========================================================"
5757
echo ""
5858
((counter++))

tests/snapshot/test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ for args in "${Savina[@]}"
3636
do
3737
echo "$args"
3838
echo "Tracing:"
39-
$SOM_DIR/som -G -JXss4096k -at -as -sam -TF core-lib/Benchmarks/AsyncHarness.ns Savina.$args
39+
$SOM_DIR/som -G -JXss8096k -at -as -sam -TF -sind=0 core-lib/Benchmarks/AsyncHarness.ns Savina.$args
4040
echo ""
4141
echo "========================================================"
4242
echo ""

0 commit comments

Comments
 (0)