Skip to content

Commit

Permalink
[Truffle] Remove RubyObject class - use RubyBasicObject instead in mo…
Browse files Browse the repository at this point in the history
…st instances.
  • Loading branch information
chrisseaton committed Nov 30, 2014
1 parent b45a7f0 commit 28403ca
Show file tree
Hide file tree
Showing 35 changed files with 92 additions and 154 deletions.
4 changes: 0 additions & 4 deletions core/src/main/java/org/jruby/truffle/nodes/RubyNode.java
Expand Up @@ -143,10 +143,6 @@ public RubyNilClass executeRubyNilClass(VirtualFrame frame) throws UnexpectedRes
return RubyTypesGen.RUBYTYPES.expectRubyNilClass(execute(frame));
}

public RubyObject executeRubyObject(VirtualFrame frame) throws UnexpectedResultException {
return RubyTypesGen.RUBYTYPES.expectRubyObject(execute(frame));
}

public RubyProc executeRubyProc(VirtualFrame frame) throws UnexpectedResultException {
return RubyTypesGen.RUBYTYPES.expectRubyProc(execute(frame));
}
Expand Down
1 change: 0 additions & 1 deletion core/src/main/java/org/jruby/truffle/nodes/RubyTypes.java
Expand Up @@ -62,7 +62,6 @@
RubiniusChannel.class, //
RubiniusByteArray.class, //
RubyEncodingConverter.class, //
RubyObject.class, //
RubyBasicObject.class, //
Object[].class})

Expand Down
Expand Up @@ -134,11 +134,6 @@ public RubyNilClass executeRubyNilClass(VirtualFrame frame) throws UnexpectedRes
return child.executeRubyNilClass(frame);
}

@Override
public RubyObject executeRubyObject(VirtualFrame frame) throws UnexpectedResultException {
return child.executeRubyObject(frame);
}

@Override
public RubyProc executeRubyProc(VirtualFrame frame) throws UnexpectedResultException {
return child.executeRubyProc(frame);
Expand Down
36 changes: 17 additions & 19 deletions core/src/main/java/org/jruby/truffle/nodes/core/KernelNodes.java
Expand Up @@ -15,7 +15,6 @@

import com.oracle.truffle.api.CompilerDirectives.SlowPath;
import com.oracle.truffle.api.*;
import com.oracle.truffle.api.nodes.SlowPathException;
import com.oracle.truffle.api.source.*;
import com.oracle.truffle.api.dsl.*;
import com.oracle.truffle.api.frame.*;
Expand All @@ -32,7 +31,6 @@
import org.jruby.truffle.runtime.*;
import org.jruby.truffle.runtime.backtrace.Activation;
import org.jruby.truffle.runtime.backtrace.Backtrace;
import org.jruby.truffle.runtime.backtrace.BacktraceFormatter;
import org.jruby.truffle.runtime.backtrace.MRIBacktraceFormatter;
import org.jruby.truffle.runtime.control.*;
import org.jruby.truffle.runtime.core.*;
Expand Down Expand Up @@ -148,7 +146,7 @@ public CompareNode(CompareNode prev) {
}

@Specialization
public Object compare(VirtualFrame frame, RubyObject self, RubyObject other) {
public Object compare(VirtualFrame frame, RubyBasicObject self, RubyBasicObject other) {
notDesignedForCompilation();

if ((self == other) || booleanCast.executeBoolean(frame, equalNode.call(frame, self, "==", null, other))) {
Expand Down Expand Up @@ -668,7 +666,7 @@ public FreezeNode(FreezeNode prev) {
}

@Specialization
public RubyObject freeze(RubyObject self) {
public RubyBasicObject freeze(RubyBasicObject self) {
notDesignedForCompilation();

self.freeze();
Expand All @@ -689,7 +687,7 @@ public FrozenNode(FrozenNode prev) {
}

@Specialization
public boolean isFrozen(RubyObject self) {
public boolean isFrozen(RubyBasicObject self) {
notDesignedForCompilation();

return self.isFrozen();
Expand Down Expand Up @@ -789,7 +787,7 @@ public int hash(BigInteger value) {
}

@Specialization
public int hash(RubyObject self) {
public int hash(RubyBasicObject self) {
notDesignedForCompilation();

return self.hashCode();
Expand Down Expand Up @@ -879,14 +877,14 @@ public InstanceVariableDefinedNode(InstanceVariableDefinedNode prev) {
public boolean isInstanceVariableDefined(RubyBasicObject object, RubyString name) {
notDesignedForCompilation();

return object.isFieldDefined(RubyObject.checkInstanceVariableName(getContext(), name.toString(), this));
return object.isFieldDefined(RubyContext.checkInstanceVariableName(getContext(), name.toString(), this));
}

@Specialization
public boolean isInstanceVariableDefined(RubyBasicObject object, RubySymbol name) {
notDesignedForCompilation();

return object.isFieldDefined(RubyObject.checkInstanceVariableName(getContext(), name.toString(), this));
return object.isFieldDefined(RubyContext.checkInstanceVariableName(getContext(), name.toString(), this));
}

}
Expand All @@ -906,14 +904,14 @@ public InstanceVariableGetNode(InstanceVariableGetNode prev) {
public Object isInstanceVariableGet(RubyBasicObject object, RubyString name) {
notDesignedForCompilation();

return object.getInstanceVariable(RubyObject.checkInstanceVariableName(getContext(), name.toString(), this));
return object.getInstanceVariable(RubyContext.checkInstanceVariableName(getContext(), name.toString(), this));
}

@Specialization
public Object isInstanceVariableGet(RubyBasicObject object, RubySymbol name) {
notDesignedForCompilation();

return object.getInstanceVariable(RubyObject.checkInstanceVariableName(getContext(), name.toString(), this));
return object.getInstanceVariable(RubyContext.checkInstanceVariableName(getContext(), name.toString(), this));
}

}
Expand All @@ -933,15 +931,15 @@ public InstanceVariableSetNode(InstanceVariableSetNode prev) {
public Object isInstanceVariableSet(RubyBasicObject object, RubyString name, Object value) {
notDesignedForCompilation();

object.setInstanceVariable(RubyObject.checkInstanceVariableName(getContext(), name.toString(), this), value);
object.setInstanceVariable(RubyContext.checkInstanceVariableName(getContext(), name.toString(), this), value);
return value;
}

@Specialization
public Object isInstanceVariableSet(RubyBasicObject object, RubySymbol name, Object value) {
notDesignedForCompilation();

object.setInstanceVariable(RubyObject.checkInstanceVariableName(getContext(), name.toString(), this), value);
object.setInstanceVariable(RubyContext.checkInstanceVariableName(getContext(), name.toString(), this), value);
return value;
}

Expand All @@ -959,7 +957,7 @@ public InstanceVariablesNode(InstanceVariablesNode prev) {
}

@Specialization
public RubyArray instanceVariables(RubyObject self) {
public RubyArray instanceVariables(RubyBasicObject self) {
notDesignedForCompilation();

final String[] instanceVariableNames = self.getFieldNames();
Expand Down Expand Up @@ -1124,12 +1122,12 @@ public MethodsNode(MethodsNode prev) {
}

@Specialization
public RubyArray methods(RubyObject self, @SuppressWarnings("unused") UndefinedPlaceholder unused) {
public RubyArray methods(RubyBasicObject self, @SuppressWarnings("unused") UndefinedPlaceholder unused) {
return methods(self, true);
}

@Specialization
public RubyArray methods(RubyObject self, boolean includeInherited) {
public RubyArray methods(RubyBasicObject self, boolean includeInherited) {
notDesignedForCompilation();

final RubyArray array = new RubyArray(self.getContext().getCoreLibrary().getArrayClass());
Expand Down Expand Up @@ -1330,7 +1328,7 @@ public PublicMethodsNode(PublicMethodsNode prev) {
}

@Specialization
public RubyArray methods(RubyObject self, boolean includeInherited) {
public RubyArray methods(RubyBasicObject self, boolean includeInherited) {
notDesignedForCompilation();

if (!includeInherited) {
Expand All @@ -1341,7 +1339,7 @@ public RubyArray methods(RubyObject self, boolean includeInherited) {
}

@Specialization
public RubyArray methods(RubyObject self, @SuppressWarnings("unused") UndefinedPlaceholder includeInherited) {
public RubyArray methods(RubyBasicObject self, @SuppressWarnings("unused") UndefinedPlaceholder includeInherited) {
notDesignedForCompilation();

final RubyArray array = new RubyArray(self.getContext().getCoreLibrary().getArrayClass());
Expand Down Expand Up @@ -1659,7 +1657,7 @@ public SingletonMethodsNode(SingletonMethodsNode prev) {
}

@Specialization
public RubyArray singletonMethods(RubyObject self, boolean includeInherited) {
public RubyArray singletonMethods(RubyBasicObject self, boolean includeInherited) {
notDesignedForCompilation();

final RubyArray array = new RubyArray(self.getContext().getCoreLibrary().getArrayClass());
Expand All @@ -1680,7 +1678,7 @@ public RubyArray singletonMethods(RubyObject self, boolean includeInherited) {
}

@Specialization
public RubyArray singletonMethods(RubyObject self, @SuppressWarnings("unused") UndefinedPlaceholder includeInherited) {
public RubyArray singletonMethods(RubyBasicObject self, @SuppressWarnings("unused") UndefinedPlaceholder includeInherited) {
return singletonMethods(self, false);
}

Expand Down
Expand Up @@ -656,13 +656,13 @@ public ClassVariableGetNode(ClassVariableGetNode prev) {
@Specialization
public Object getClassVariable(RubyModule module, RubyString name) {
notDesignedForCompilation();
return ModuleOperations.lookupClassVariable(module, RubyObject.checkClassVariableName(getContext(), name.toString(), this));
return ModuleOperations.lookupClassVariable(module, RubyContext.checkClassVariableName(getContext(), name.toString(), this));
}

@Specialization
public Object getClassVariable(RubyModule module, RubySymbol name) {
notDesignedForCompilation();
return ModuleOperations.lookupClassVariable(module, RubyObject.checkClassVariableName(getContext(), name.toString(), this));
return ModuleOperations.lookupClassVariable(module, RubyContext.checkClassVariableName(getContext(), name.toString(), this));
}

}
Expand Down
Expand Up @@ -1010,7 +1010,7 @@ public DataNode(DataNode prev) {
}

@Specialization
public RubyObject data(RubyString string) {
public RubyBasicObject data(RubyString string) {
return new RubiniusByteArray(getContext().getCoreLibrary().getRubiniusLibrary().getByteArrayCLass(), string.getBytes().getUnsafeBytes());
}
}
Expand Down
19 changes: 0 additions & 19 deletions core/src/main/java/org/jruby/truffle/nodes/debug/ProxyNode.java
Expand Up @@ -421,25 +421,6 @@ public RubyNilClass executeRubyNilClass(VirtualFrame frame) throws UnexpectedRes
return result;
}

@Override
public RubyObject executeRubyObject(VirtualFrame frame) throws UnexpectedResultException {
enter(frame);

final RubyObject result;

try {
result = child.executeRubyObject(frame);
leave(frame, result);
} catch (KillException e) {
throw (e);
} catch (Exception e) {
leaveExceptional(frame, e);
throw e;
}

return result;
}

@Override
public RubyProc executeRubyProc(VirtualFrame frame) throws UnexpectedResultException {
enter(frame);
Expand Down
Expand Up @@ -32,7 +32,7 @@ public ReadClassVariableNode(RubyContext context, SourceSection sourceSection, S
public Object execute(VirtualFrame frame) {
notDesignedForCompilation();

final RubyObject object = (RubyObject) module.execute(frame);
final RubyBasicObject object = (RubyBasicObject) module.execute(frame);

RubyModule moduleObject;

Expand All @@ -58,7 +58,7 @@ public Object execute(VirtualFrame frame) {
public Object isDefined(VirtualFrame frame) {
final RubyContext context = getContext();

final RubyObject object = (RubyObject) module.execute(frame);
final RubyBasicObject object = (RubyBasicObject) module.execute(frame);

RubyModule moduleObject;

Expand Down
Expand Up @@ -20,7 +20,7 @@
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.control.RaiseException;
import org.jruby.truffle.runtime.core.RubyClass;
import org.jruby.truffle.runtime.core.RubyObject;
import org.jruby.truffle.runtime.core.RubyBasicObject;
import org.jruby.truffle.runtime.core.RubyString;
import org.jruby.truffle.runtime.rubinius.RubiniusByteArray;
import org.jruby.truffle.runtime.util.TypeConversionUtils;
Expand All @@ -38,7 +38,7 @@ public AllocateNode(AllocateNode prev) {
}

@Specialization
public RubyObject allocate(RubyObject baClass, RubyObject size) {
public RubyBasicObject allocate(RubyBasicObject baClass, RubyBasicObject size) {
throw new RaiseException(getContext().getCoreLibrary().typeError("ByteArray cannot be created via allocate()", this));
}
}
Expand All @@ -59,7 +59,7 @@ public AllocateSizedNode(AllocateSizedNode prev) {
}

@Specialization
public RubyObject allocate_sized(VirtualFrame frame, RubyObject bytes) {
public RubyBasicObject allocate_sized(VirtualFrame frame, RubyBasicObject bytes) {
RubyClass self = (RubyClass) RubyArguments.getSelf(frame.getArguments());
return RubiniusByteArray.allocate_sized(this, self, TypeConversionUtils.convertToLong(this, bytesToIntNode, frame, bytes));
}
Expand All @@ -85,7 +85,7 @@ public FetchBytesNode(FetchBytesNode prev) {
}

@Specialization
public RubyObject fetch_bytes(VirtualFrame frame, RubiniusByteArray self, RubyObject start, RubyObject count) {
public RubyBasicObject fetch_bytes(VirtualFrame frame, RubiniusByteArray self, RubyBasicObject start, RubyBasicObject count) {
return self.fetch_bytes(this, TypeConversionUtils.convertToLong(this, startToIntNode, frame, start), TypeConversionUtils.convertToLong(this, countToIntNode, frame, count));
}
}
Expand Down Expand Up @@ -114,7 +114,7 @@ public MoveBytesNode(MoveBytesNode prev) {
}

@Specialization
public RubyObject move_bytes(VirtualFrame frame, RubiniusByteArray self, RubyObject start, RubyObject count, RubyObject dest) {
public RubyBasicObject move_bytes(VirtualFrame frame, RubiniusByteArray self, RubyBasicObject start, RubyBasicObject count, RubyBasicObject dest) {
self.move_bytes(this, TypeConversionUtils.convertToLong(this, startToIntNode, frame, start), TypeConversionUtils.convertToLong(this, countToIntNode, frame, count),
TypeConversionUtils.convertToLong(this, destToIntNode, frame, dest));
return count;
Expand All @@ -137,7 +137,7 @@ public GetByteNode(GetByteNode prev) {
}

@Specialization
public int get_byte(VirtualFrame frame, RubiniusByteArray self, RubyObject index) {
public int get_byte(VirtualFrame frame, RubiniusByteArray self, RubyBasicObject index) {
return self.get_byte(this, TypeConversionUtils.convertToLong(this, indexToIntNode, frame, index));
}
}
Expand All @@ -162,7 +162,7 @@ public SetByteNode(SetByteNode prev) {
}

@Specialization
public int set_byte(VirtualFrame frame, RubiniusByteArray self, RubyObject index, RubyObject value) {
public int set_byte(VirtualFrame frame, RubiniusByteArray self, RubyBasicObject index, RubyBasicObject value) {
return self.set_byte(this, TypeConversionUtils.convertToLong(this, indexToIntNode, frame, index), TypeConversionUtils.convertToLong(this, valueToIntNode, frame, value));
}
}
Expand All @@ -187,7 +187,7 @@ public CompareBytesNode(CompareBytesNode prev) {
}

@Specialization
public int compare_bytes(VirtualFrame frame, RubiniusByteArray self, RubiniusByteArray other, RubyObject a, RubyObject b) {
public int compare_bytes(VirtualFrame frame, RubiniusByteArray self, RubiniusByteArray other, RubyBasicObject a, RubyBasicObject b) {
return self.compare_bytes(this, other, TypeConversionUtils.convertToLong(this, aToIntNode, frame, a), TypeConversionUtils.convertToLong(this, bToIntNode, frame, b));
}
}
Expand Down Expand Up @@ -232,7 +232,7 @@ public LocateNode(LocateNode prev) {
}

@Specialization
public Object locate(VirtualFrame frame, RubiniusByteArray self, RubyObject pattern, RubyObject start, RubyObject max_o) {
public Object locate(VirtualFrame frame, RubiniusByteArray self, RubyBasicObject pattern, RubyBasicObject start, RubyBasicObject max_o) {
return self.locate((RubyString) patternToStringNode.call(frame, pattern, "to_s", null), TypeConversionUtils.convertToLong(this, startToIntNode, frame, start),
TypeConversionUtils.convertToLong(this, max_oToIntNode, frame, max_o));
}
Expand All @@ -254,7 +254,7 @@ public PrependNode(PrependNode prev) {
}

@Specialization
public RubyObject prepend(VirtualFrame frame, RubiniusByteArray self, RubyObject str) {
public RubyBasicObject prepend(VirtualFrame frame, RubiniusByteArray self, RubyBasicObject str) {
return self.prepend((RubyString) strToStringNode.call(frame, str, "to_s", null));
}
}
Expand All @@ -270,7 +270,7 @@ public Utf8CharNode(Utf8CharNode prev) {
}

@Specialization
public RubyObject utf8_char(RubiniusByteArray self, RubyObject offset) {
public RubyBasicObject utf8_char(RubiniusByteArray self, RubyBasicObject offset) {
return self.utf8_char(this, offset);
}
}
Expand All @@ -295,7 +295,7 @@ public ReverseNode(ReverseNode prev) {
}

@Specialization
public RubyObject reverse(VirtualFrame frame, RubiniusByteArray self, RubyObject o_start, RubyObject o_total) {
public RubyBasicObject reverse(VirtualFrame frame, RubiniusByteArray self, RubyBasicObject o_start, RubyBasicObject o_total) {
return self.reverse(TypeConversionUtils.convertToLong(this, o_startToIntNode, frame, o_start), TypeConversionUtils.convertToLong(this, o_totalToIntNode, frame, o_total));
}
}
Expand Down
Expand Up @@ -16,7 +16,7 @@
import org.jruby.truffle.nodes.core.CoreMethodNode;
import org.jruby.truffle.runtime.core.*;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.core.RubyObject;
import org.jruby.truffle.runtime.core.RubyBasicObject;
import org.jruby.truffle.runtime.rubinius.RubiniusChannel;

@CoreClass(name = "Channel")
Expand All @@ -33,7 +33,7 @@ public SendNode(SendNode prev) {
}

@Specialization
public Object send(RubiniusChannel self, RubyObject value) {
public Object send(RubiniusChannel self, RubyBasicObject value) {
self.send(value);
return getContext().getCoreLibrary().getNilObject();
}
Expand Down

0 comments on commit 28403ca

Please sign in to comment.