diff --git a/src/som/interpreter/Method.java b/src/som/interpreter/Method.java index cf9b5cf0d..d4c3ecb76 100644 --- a/src/som/interpreter/Method.java +++ b/src/som/interpreter/Method.java @@ -82,7 +82,7 @@ public SourceSection[] getDefinition() { @Override public String toString() { - return "Method " + getName() + "\t@" + Integer.toHexString(hashCode()); + return getName() + "\t@" + Integer.toHexString(hashCode()); } @Override diff --git a/src/som/interpreter/Primitive.java b/src/som/interpreter/Primitive.java index 535e39eb0..fb29ab595 100644 --- a/src/som/interpreter/Primitive.java +++ b/src/som/interpreter/Primitive.java @@ -59,7 +59,7 @@ public String toString() { if (n != expressionOrSequence) { nodeType += " (wrapped)"; // indicate that it is wrapped } - return "Primitive " + nodeType + "@" + Integer.toHexString(hashCode()); + return nodeType + "\t@" + Integer.toHexString(hashCode()); } @Override diff --git a/src/som/interpreter/nodes/ContextualNode.java b/src/som/interpreter/nodes/ContextualNode.java index 19d75781f..c49697ca7 100644 --- a/src/som/interpreter/nodes/ContextualNode.java +++ b/src/som/interpreter/nodes/ContextualNode.java @@ -40,6 +40,7 @@ public abstract class ContextualNode extends ExprWithTagsNode { protected final int contextLevel; private final ValueProfile frameType; private final ValueProfile outerType; + private final ValueProfile rcvrType; @CompilationFinal DetermineContext determineContext; @@ -47,6 +48,7 @@ public ContextualNode(final int contextLevel) { this.contextLevel = contextLevel; this.frameType = ValueProfile.createClassProfile(); this.outerType = ValueProfile.createClassProfile(); + this.rcvrType = ValueProfile.createClassProfile(); } public final int getContextLevel() { @@ -55,7 +57,7 @@ public final int getContextLevel() { private DetermineContext buildChain(final SObjectWithContext self, final int i) { if (i > 0) { - DetermineContext outer = buildChain(self.getOuterSelf(), i - 1); + DetermineContext outer = buildChain(self.getOuterSelf(rcvrType), i - 1); if (self instanceof SBlock) { return new BlockContext(outer); } else if (self instanceof SClass) { @@ -71,7 +73,7 @@ private DetermineContext buildChain(final SObjectWithContext self, final int i) @ExplodeLoop protected final MaterializedFrame determineContext(final Frame frame) { - SObjectWithContext self = (SObjectWithContext) SArguments.rcvr(frame); + SObjectWithContext self = (SObjectWithContext) rcvrType.profile(SArguments.rcvr(frame)); int i = contextLevel - 1; @@ -96,15 +98,17 @@ protected final MaterializedFrame determineContext(final Frame frame) { */ public abstract static class DetermineContext { protected final DetermineContext next; + protected final ValueProfile rcvrType; protected DetermineContext(final DetermineContext next) { this.next = next; + this.rcvrType = ValueProfile.createClassProfile(); } protected abstract SObjectWithContext getOuterSelf(SObjectWithContext obj); protected final SObjectWithContext getOuter(final SObjectWithContext obj) { - SObjectWithContext outer = obj.getOuterSelf(); + SObjectWithContext outer = obj.getOuterSelf(rcvrType); if (next != null) { return next.getOuterSelf(outer); } else { diff --git a/src/som/interpreter/nodes/literals/ArrayLiteralNode.java b/src/som/interpreter/nodes/literals/ArrayLiteralNode.java index 495a4fb29..4d757347d 100644 --- a/src/som/interpreter/nodes/literals/ArrayLiteralNode.java +++ b/src/som/interpreter/nodes/literals/ArrayLiteralNode.java @@ -1,5 +1,6 @@ package som.interpreter.nodes.literals; +import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.instrumentation.Tag; import com.oracle.truffle.api.source.SourceSection; @@ -95,7 +96,9 @@ private Specialized(final ExpressionNode[] expressions) { public final Object executeGeneric(final VirtualFrame frame) { Object storage = executeSpecialized(frame); SMutableArray result = new SMutableArray(storage, Classes.arrayClass); + if (!expectedType(result)) { + CompilerDirectives.transferToInterpreterAndInvalidate(); replace(new Objects(expressions).initialize(sourceSection)); } return result; diff --git a/src/som/vmobjects/SObjectWithContext.java b/src/som/vmobjects/SObjectWithContext.java index 6dced1538..d022aa16e 100644 --- a/src/som/vmobjects/SObjectWithContext.java +++ b/src/som/vmobjects/SObjectWithContext.java @@ -1,6 +1,7 @@ package som.vmobjects; import com.oracle.truffle.api.frame.MaterializedFrame; +import com.oracle.truffle.api.profiles.ValueProfile; import som.interpreter.SArguments; @@ -29,8 +30,8 @@ public interface SObjectWithContext { * Return the object enclosing the current object, * which is the receiver of this object. */ - default SObjectWithContext getOuterSelf() { - return (SObjectWithContext) SArguments.rcvr(getContext()); + default SObjectWithContext getOuterSelf(final ValueProfile rcvrType) { + return (SObjectWithContext) rcvrType.profile(SArguments.rcvr(getContext())); } }