Skip to content

Commit

Permalink
Merge 40bc9a1 into 8a9e09b
Browse files Browse the repository at this point in the history
  • Loading branch information
smarr committed Jun 17, 2020
2 parents 8a9e09b + 40bc9a1 commit 5ead4bd
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/som/interpreter/Method.java
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/som/interpreter/Primitive.java
Expand Up @@ -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
Expand Down
10 changes: 7 additions & 3 deletions src/som/interpreter/nodes/ContextualNode.java
Expand Up @@ -40,13 +40,15 @@ 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;

public ContextualNode(final int contextLevel) {
this.contextLevel = contextLevel;
this.frameType = ValueProfile.createClassProfile();
this.outerType = ValueProfile.createClassProfile();
this.rcvrType = ValueProfile.createClassProfile();
}

public final int getContextLevel() {
Expand All @@ -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) {
Expand All @@ -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;

Expand All @@ -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 {
Expand Down
3 changes: 3 additions & 0 deletions 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;
Expand Down Expand Up @@ -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;
Expand Down
5 changes: 3 additions & 2 deletions 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;

Expand Down Expand Up @@ -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()));
}

}

0 comments on commit 5ead4bd

Please sign in to comment.