Skip to content

Commit

Permalink
integrate more feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
daumayr committed Oct 5, 2018
1 parent ec74524 commit f121b69
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 10 deletions.
12 changes: 11 additions & 1 deletion src/som/compiler/MixinDefinition.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package som.compiler;

import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
Expand Down Expand Up @@ -851,12 +853,20 @@ public static boolean isInstance(final TruffleObject obj) {
return obj instanceof MixinDefinition;
}

/**
* This method provides a String that can be used to identify a MixinDefinition.
* The String takes a shape like this: "relativePath:module.class.nestedClass"
*
* @return the fully qualified name of this MixinDefinition
*/
public String getIdentifier() {
MixinDefinition outer = getOuterMixinDefinition();
if (outer != null) {
return outer.getIdentifier() + "." + this.name.getString();
} else if (this.isModule && this.sourceSection != null) {
return this.sourceSection.getSource().getPath() + ":" + this.name.getString();
Path absolute = Paths.get(this.sourceSection.getSource().getURI());
Path relative = Paths.get("").toAbsolutePath().relativize(absolute);
return relative.toString() + ":" + this.name.getString();
}
return this.name.getString();
}
Expand Down
39 changes: 30 additions & 9 deletions src/som/vmobjects/SClass.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.graalvm.collections.EconomicMap;
import org.graalvm.collections.EconomicSet;

import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.CompilerDirectives.CompilationFinal;
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.api.dsl.NodeFactory;
Expand Down Expand Up @@ -89,7 +90,12 @@ public SClass(final SObjectWithClass enclosing,
final NodeFactory<? extends AbstractSerializationNode> factory) {
this.enclosingObject = enclosing;
this.context = null;
this.serializationRoot = new SerializerRootNode(null, factory.createNode(this));
if (VmSettings.SNAPSHOTS_ENABLED) {
CompilerDirectives.transferToInterpreter();
this.serializationRoot = new SerializerRootNode(null, factory.createNode(this));
} else {
this.serializationRoot = null;
}
}

public SClass(final SObjectWithClass enclosing) {
Expand All @@ -105,20 +111,30 @@ public SClass(final SObjectWithClass enclosing, final SClass clazz,
super(clazz, clazz.getInstanceFactory());
this.enclosingObject = enclosing;
this.context = null;
this.serializationRoot = new SerializerRootNode(null, factory.createNode(this));
if (VmSettings.SNAPSHOTS_ENABLED) {
CompilerDirectives.transferToInterpreter();
this.serializationRoot = new SerializerRootNode(null, factory.createNode(this));
} else {
this.serializationRoot = null;
}
}

public SClass(final SObjectWithClass enclosing, final SClass clazz) {
super(clazz, clazz.getInstanceFactory());
this.enclosingObject = enclosing;
this.context = null;
if (clazz == Classes.metaclassClass) {
this.serializationRoot = new SerializerRootNode(null,
ClassSerializationNodeFactory.getInstance().createNode(this));
if (VmSettings.SNAPSHOTS_ENABLED) {
CompilerDirectives.transferToInterpreter();
if (clazz == Classes.metaclassClass) {
this.serializationRoot = new SerializerRootNode(null,
ClassSerializationNodeFactory.getInstance().createNode(this));
} else {
this.serializationRoot =
new SerializerRootNode(null,
ObjectSerializationNode.create(this));
}
} else {
this.serializationRoot =
new SerializerRootNode(null,
ObjectSerializationNode.create(this));
this.serializationRoot = null;
}
}

Expand All @@ -133,7 +149,12 @@ public SClass(final SObjectWithClass enclosing, final SClass clazz,
super(clazz, clazz.getInstanceFactory());
this.enclosingObject = enclosing;
this.context = frame;
this.serializationRoot = new SerializerRootNode(null, factory.createNode(this));
if (VmSettings.SNAPSHOTS_ENABLED) {
CompilerDirectives.transferToInterpreter();
this.serializationRoot = new SerializerRootNode(null, factory.createNode(this));
} else {
this.serializationRoot = null;
}
}

public SClass(final SObjectWithClass enclosing, final SClass clazz,
Expand Down
2 changes: 2 additions & 0 deletions src/tools/snapshot/nodes/AbstractSerializationNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import com.oracle.truffle.api.nodes.Node;

import som.vm.VmSettings;
import som.vmobjects.SClass;
import tools.snapshot.SnapshotBackend;
import tools.snapshot.SnapshotBuffer;
Expand All @@ -13,6 +14,7 @@ public abstract class AbstractSerializationNode extends Node {
public final SClass clazz;

public AbstractSerializationNode(final SClass clazz) {
assert VmSettings.SNAPSHOTS_ENABLED;
this.clazz = clazz;
}

Expand Down
Binary file modified tests/dym/expected-results.tar.bz2
Binary file not shown.

0 comments on commit f121b69

Please sign in to comment.