Skip to content

Commit

Permalink
[Truffle] No need for frame in ObjectIDPrimitiveNode and callers.
Browse files Browse the repository at this point in the history
  • Loading branch information
eregon committed Oct 20, 2016
1 parent 8b7c038 commit 3af802a
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 11 deletions.
Expand Up @@ -13,7 +13,6 @@
import com.oracle.truffle.api.dsl.Cached;
import com.oracle.truffle.api.dsl.Fallback;
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.profiles.ConditionProfile;
import com.oracle.truffle.api.source.SourceSection;
Expand Down Expand Up @@ -43,7 +42,7 @@ public abstract class ObjectNodes {
@Primitive(name = "object_id")
public abstract static class ObjectIDPrimitiveNode extends PrimitiveArrayArgumentsNode {

public abstract Object executeObjectID(VirtualFrame frame, Object value);
public abstract Object executeObjectID(Object value);

@Specialization(guards = "isNil(nil)")
public long objectIDNil(Object nil) {
Expand Down
Expand Up @@ -35,12 +35,12 @@ public ToSNode(RubyContext context, SourceSection sourceSection) {
callToSNode = DispatchHeadNodeFactory.createMethodCall(context, true);
}

protected DynamicObject kernelToS(VirtualFrame frame, Object object) {
protected DynamicObject kernelToS(Object object) {
if (kernelToSNode == null) {
CompilerDirectives.transferToInterpreterAndInvalidate();
kernelToSNode = insert(KernelNodesFactory.ToSNodeFactory.create(getContext(), null, null));
}
return kernelToSNode.executeToS(frame, object);
return kernelToSNode.executeToS(object);
}

@Specialization(guards = "isRubyString(string)")
Expand All @@ -66,7 +66,7 @@ public DynamicObject toSFallback(VirtualFrame frame, Object object) {
if (RubyGuards.isRubyString(value)) {
return (DynamicObject) value;
} else {
return kernelToS(frame, object);
return kernelToS(object);
}
}

Expand Down
Expand Up @@ -140,7 +140,7 @@ public byte[] toString(VirtualFrame frame, Object object) {
inspectNode = insert(KernelNodesFactory.ToSNodeFactory.create(getContext(), null, null));
}

return Layouts.STRING.getRope(inspectNode.toS(frame, object)).getBytes();
return Layouts.STRING.getRope(inspectNode.toS(object)).getBytes();
} else {
throw new NoImplicitConversionException(object, "String");
}
Expand Down
Expand Up @@ -1831,7 +1831,7 @@ public boolean isTainted(Object object) {

public abstract static class ToHexStringNode extends CoreMethodArrayArgumentsNode {

public abstract String executeToHexString(VirtualFrame frame, Object value);
public abstract String executeToHexString(Object value);

@Specialization
public String toHexString(int value) {
Expand Down Expand Up @@ -1866,13 +1866,13 @@ public ToSNode(RubyContext context, SourceSection sourceSection) {
toHexStringNode = KernelNodesFactory.ToHexStringNodeFactory.create(null);
}

public abstract DynamicObject executeToS(VirtualFrame frame, Object self);
public abstract DynamicObject executeToS(Object self);

@Specialization
public DynamicObject toS(VirtualFrame frame, Object self) {
public DynamicObject toS(Object self) {
String className = Layouts.MODULE.getFields(classNode.executeLogicalClass(self)).getName();
Object id = objectIDNode.executeObjectID(frame, self);
String hexID = toHexStringNode.executeToHexString(frame, id);
Object id = objectIDNode.executeObjectID(self);
String hexID = toHexStringNode.executeToHexString(id);

final DynamicObject string = createString(formatToS(className, hexID));
taintResultNode.maybeTaint(self, string);
Expand Down

0 comments on commit 3af802a

Please sign in to comment.