Skip to content

Commit

Permalink
Showing 13 changed files with 47 additions and 143 deletions.
Original file line number Diff line number Diff line change
@@ -9,6 +9,7 @@
*/
package org.jruby.truffle.nodes.core;

import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.source.SourceSection;
import org.jruby.truffle.nodes.RubyNode;
@@ -28,7 +29,7 @@ public ArrayPushNode(RubyContext context, SourceSection sourceSection, RubyNode

@Override
public Object execute(VirtualFrame frame) {
notDesignedForCompilation();
CompilerDirectives.transferToInterpreter();

final Object arrayObject = array.execute(frame);
assert arrayObject instanceof RubyArray : getSourceSection();
Original file line number Diff line number Diff line change
@@ -572,7 +572,7 @@ public Object mod(int a, RubyBignum b) {

@Specialization
public Object mod(long a, RubyBignum b) {
notDesignedForCompilation();
CompilerDirectives.transferToInterpreter();

// TODO(CS): why are we getting this case?

Original file line number Diff line number Diff line change
@@ -116,7 +116,6 @@ public Object downto(VirtualFrame frame, long from, long to, RubyProc block) {

@Specialization
public Object downto(VirtualFrame frame, int from, double to, RubyProc block) {
notDesignedForCompilation();
return downto(frame, from, (int) Math.ceil(to), block);
}

@@ -139,8 +138,6 @@ public TimesNode(RubyContext context, SourceSection sourceSection) {

@Specialization
public RubyArray times(VirtualFrame frame, int n, UndefinedPlaceholder block) {
notDesignedForCompilation();

final int[] array = new int[n];

for (int i = 0; i < n; i++) {
@@ -214,8 +211,6 @@ public Object times(VirtualFrame frame, long n, RubyProc block) {

@Specialization
public Object times(VirtualFrame frame, RubyBignum n, RubyProc block) {
notDesignedForCompilation();

if (fixnumOrBignum == null) {
CompilerDirectives.transferToInterpreter();
fixnumOrBignum = insert(new FixnumOrBignumNode(getContext(), getSourceSection()));
@@ -309,14 +304,11 @@ public Object upto(VirtualFrame frame, int from, int to, RubyProc block) {

@Specialization
public Object upto(VirtualFrame frame, int from, double to, RubyProc block) {
notDesignedForCompilation();
return upto(frame, from, (int) Math.floor(to), block);
}

@Specialization
public Object upto(VirtualFrame frame, long from, long to, RubyProc block) {
notDesignedForCompilation();

int count = 0;

try {
Original file line number Diff line number Diff line change
@@ -33,7 +33,6 @@ public PublicNode(RubyContext context, SourceSection sourceSection) {

@Specialization
public RubyModule doPublic(VirtualFrame frame, Object[] args) {
notDesignedForCompilation();
final RubyClass object = getContext().getCoreLibrary().getObjectClass();
return publicNode.executePublic(frame, object, args);
}
@@ -51,7 +50,6 @@ public PrivateNode(RubyContext context, SourceSection sourceSection) {

@Specialization
public RubyModule doPrivate(VirtualFrame frame, Object[] args) {
notDesignedForCompilation();
final RubyClass object = getContext().getCoreLibrary().getObjectClass();
return privateNode.executePrivate(frame, object, args);
}
Original file line number Diff line number Diff line change
@@ -9,6 +9,7 @@
*/
package org.jruby.truffle.nodes.core;

import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.source.SourceSection;
@@ -33,10 +34,9 @@ public Object id2Ref(int id) {
return id2Ref((long) id);
}

@CompilerDirectives.TruffleBoundary
@Specialization
public Object id2Ref(long id) {
notDesignedForCompilation();

if (id == ObjectIDOperations.NIL) {
return nil();
} else if (id == ObjectIDOperations.TRUE) {
@@ -85,7 +85,7 @@ public EachObjectNode(RubyContext context, SourceSection sourceSection) {

@Specialization
public int eachObject(VirtualFrame frame, UndefinedPlaceholder ofClass, RubyProc block) {
notDesignedForCompilation();
CompilerDirectives.transferToInterpreter();

int count = 0;

@@ -101,7 +101,7 @@ public int eachObject(VirtualFrame frame, UndefinedPlaceholder ofClass, RubyProc

@Specialization
public int eachObject(VirtualFrame frame, RubyClass ofClass, RubyProc block) {
notDesignedForCompilation();
CompilerDirectives.transferToInterpreter();

int count = 0;

@@ -128,10 +128,9 @@ public DefineFinalizerNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@CompilerDirectives.TruffleBoundary
@Specialization
public RubyArray defineFinalizer(Object object, RubyProc finalizer) {
notDesignedForCompilation();

getContext().getObjectSpaceManager().defineFinalizer((RubyBasicObject) object, finalizer);
return RubyArray.fromObjects(getContext().getCoreLibrary().getArrayClass(), 0, finalizer);
}
@@ -144,10 +143,9 @@ public UndefineFinalizerNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@CompilerDirectives.TruffleBoundary
@Specialization
public Object undefineFinalizer(Object object) {
notDesignedForCompilation();

getContext().getObjectSpaceManager().undefineFinalizer((RubyBasicObject) object);
return object;
}
Original file line number Diff line number Diff line change
@@ -101,10 +101,9 @@ public RubyNilClass initialize(RubyProc proc, RubyProc block) {
return nil();
}

@CompilerDirectives.TruffleBoundary
@Specialization
public RubyNilClass initialize(VirtualFrame frame, RubyProc proc, UndefinedPlaceholder block) {
notDesignedForCompilation();

public RubyNilClass initialize(RubyProc proc, UndefinedPlaceholder block) {
final Memo<Integer> frameCount = new Memo<>(0);

// The parent will be the Proc.new call. We need to go an extra level up in order to get the parent
@@ -178,10 +177,9 @@ public SourceLocationNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@CompilerDirectives.TruffleBoundary
@Specialization
public Object sourceLocation(RubyProc proc) {
notDesignedForCompilation();

SourceSection sourceSection = proc.getSharedMethodInfo().getSourceSection();

if (sourceSection instanceof NullSourceSection) {
Original file line number Diff line number Diff line change
@@ -9,6 +9,7 @@
*/
package org.jruby.truffle.nodes.core;

import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.source.SourceSection;
import org.jruby.truffle.runtime.RubyContext;
@@ -84,10 +85,9 @@ public KillNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@CompilerDirectives.TruffleBoundary
@Specialization
public int kill(RubySymbol signalName, int pid) {
notDesignedForCompilation();

int self = posix().getpid();

if (self == pid) {
@@ -111,8 +111,6 @@ public PidNode(RubyContext context, SourceSection sourceSection) {

@Specialization
public int pid() {
notDesignedForCompilation();

return posix().getpid();
}

Original file line number Diff line number Diff line change
@@ -146,10 +146,9 @@ public EscapeNode(RubyContext context, SourceSection sourceSection) {

public abstract RubyString executeEscape(VirtualFrame frame, RubyString pattern);

@CompilerDirectives.TruffleBoundary
@Specialization
public RubyString escape(RubyString pattern) {
notDesignedForCompilation();

return getContext().makeString(org.jruby.RubyRegexp.quote19(new ByteList(pattern.getByteList()), true).toString());
}

@@ -231,15 +230,13 @@ public OptionsNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@CompilerDirectives.TruffleBoundary
@Specialization
public int options(RubyRegexp regexp) {
notDesignedForCompilation();

if (notYetInitializedProfile.profile(regexp.getRegex() == null)) {
CompilerDirectives.transferToInterpreter();

throw new RaiseException(getContext().getCoreLibrary().typeError("uninitialized Regexp", this));
}

if(regexp.getOptions() != null){
return regexp.getOptions().toOptions();
}
@@ -256,19 +253,15 @@ public QuoteNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@CompilerDirectives.TruffleBoundary
@Specialization
public RubyString quote(RubyString raw) {
notDesignedForCompilation();

boolean isAsciiOnly = raw.getByteList().getEncoding().isAsciiCompatible() && raw.scanForCodeRange() == CR_7BIT;

return getContext().makeString(org.jruby.RubyRegexp.quote19(raw.getByteList(), isAsciiOnly));
}

@Specialization
public RubyString quote(RubySymbol raw) {
notDesignedForCompilation();

return quote(raw.toRubyString());
}

Original file line number Diff line number Diff line change
@@ -219,7 +219,7 @@ public int compare(RubyString a, RubyString b) {

@Specialization(guards = "!isRubyString(b)")
public Object compare(VirtualFrame frame, RubyString a, Object b) {
notDesignedForCompilation();
CompilerDirectives.transferToInterpreter();

if (respondToToStrNode == null) {
CompilerDirectives.transferToInterpreter();
@@ -343,7 +343,6 @@ public RubyString concat(RubyString string, RubyString other) {

@Specialization(guards = {"!isInteger(other)", "!isLong(other)", "!isRubyBignum(other)", "!isRubyString(other)"})
public Object concat(VirtualFrame frame, RubyString string, Object other) {
notDesignedForCompilation();
return ruby(frame, "concat StringValue(other)", "other", other);
}

@@ -503,8 +502,6 @@ public Object slice(VirtualFrame frame, RubyString string, RubyRegexp regexp, Ob

@Specialization
public Object slice(VirtualFrame frame, RubyString string, RubyString matchStr, UndefinedPlaceholder undefined) {
notDesignedForCompilation();

if (includeNode == null) {
CompilerDirectives.transferToInterpreter();
includeNode = insert(DispatchHeadNodeFactory.createMethodCall(getContext()));
@@ -565,10 +562,9 @@ public ASCIIOnlyNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@TruffleBoundary
@Specialization
public boolean asciiOnly(RubyString string) {
notDesignedForCompilation();

if (!string.getByteList().getEncoding().isAsciiCompatible()) {
return false;
}
@@ -697,10 +693,9 @@ public ChopBangNode(RubyContext context, SourceSection sourceSection) {
sizeNode = StringNodesFactory.SizeNodeFactory.create(context, sourceSection, new RubyNode[] { null });
}

@TruffleBoundary
@Specialization
public Object chopBang(VirtualFrame frame, RubyString string) {
notDesignedForCompilation();

if (sizeNode.executeInteger(frame, string) == 0) {
return nil();
}
@@ -734,8 +729,6 @@ public CountNode(RubyContext context, SourceSection sourceSection) {

@Specialization
public int count(VirtualFrame frame, RubyString string, Object[] otherStrings) {
notDesignedForCompilation();

if (string.getByteList().getRealSize() == 0) {
return 0;
}
@@ -748,9 +741,8 @@ public int count(VirtualFrame frame, RubyString string, Object[] otherStrings) {
return countSlow(frame, string, otherStrings);
}

@TruffleBoundary
private int countSlow(VirtualFrame frame, RubyString string, Object[] args) {
notDesignedForCompilation();

RubyString[] otherStrings = new RubyString[args.length];

for (int i = 0; i < args.length; i++) {
@@ -870,9 +862,8 @@ public Object deleteBang(VirtualFrame frame, RubyString string, Object... otherS
return deleteBangSlow(frame, string, otherStrings);
}

@TruffleBoundary
private Object deleteBangSlow(VirtualFrame frame, RubyString string, Object... args) {
notDesignedForCompilation();

RubyString[] otherStrings = new RubyString[args.length];

for (int i = 0; i < args.length; i++) {
@@ -1148,8 +1139,6 @@ public InspectNode(RubyContext context, SourceSection sourceSection) {
@TruffleBoundary
@Specialization
public RubyString inspect(RubyString string) {
notDesignedForCompilation();

final org.jruby.RubyString inspected = (org.jruby.RubyString) org.jruby.RubyString.inspect19(getContext().getRuntime(), string.getByteList());
return getContext().makeString(inspected.getByteList());
}
@@ -1341,10 +1330,7 @@ public MatchNode(RubyContext context, SourceSection sourceSection) {

@Specialization
public Object match(VirtualFrame frame, RubyString string, RubyString regexpString) {
notDesignedForCompilation();

final RubyRegexp regexp = new RubyRegexp(this, getContext().getCoreLibrary().getRegexpClass(), regexpString.getByteList(), Option.DEFAULT);

return regexpMatchNode.call(frame, regexp, "match", null, string);
}

@@ -1556,10 +1542,9 @@ public StripNode(RubyContext context, SourceSection sourceSection) {

@Specialization
public RubyString strip(RubyString string) {
notDesignedForCompilation();
CompilerDirectives.transferToInterpreter();

// Hacky implementation to get something working

return getContext().makeString(string.toString().trim());
}

@@ -1624,30 +1609,24 @@ public ScanNode(RubyContext context, SourceSection sourceSection) {

@Specialization
public RubyArray scan(RubyString string, RubyString regexpString, UndefinedPlaceholder block) {
notDesignedForCompilation();

final RubyRegexp regexp = new RubyRegexp(this, getContext().getCoreLibrary().getRegexpClass(), regexpString.getByteList(), Option.DEFAULT);
return scan(string, regexp, block);
}

@Specialization
public RubyString scan(VirtualFrame frame, RubyString string, RubyString regexpString, RubyProc block) {
notDesignedForCompilation();

final RubyRegexp regexp = new RubyRegexp(this, getContext().getCoreLibrary().getRegexpClass(), regexpString.getByteList(), Option.DEFAULT);
return scan(frame, string, regexp, block);
}

@Specialization
public RubyArray scan(RubyString string, RubyRegexp regexp, UndefinedPlaceholder block) {
notDesignedForCompilation();

return RubyArray.fromObjects(getContext().getCoreLibrary().getArrayClass(), (Object[]) regexp.scan(string));
}

@Specialization
public RubyString scan(VirtualFrame frame, RubyString string, RubyRegexp regexp, RubyProc block) {
notDesignedForCompilation();
CompilerDirectives.transferToInterpreter();

// TODO (nirvdrum 12-Jan-15) Figure out a way to make this not just a complete copy & paste of RubyRegexp#scan.

@@ -1860,10 +1839,9 @@ public SuccNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@TruffleBoundary
@Specialization
public RubyString succ(RubyString string) {
notDesignedForCompilation();

if (string.length() > 0) {
return getContext().makeString(string.getLogicalClass(), StringSupport.succCommon(getContext().getRuntime(), string.getByteList()));
} else {
@@ -1879,10 +1857,9 @@ public SuccBangNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@TruffleBoundary
@Specialization
public RubyString succBang(RubyString string) {
notDesignedForCompilation();

if (string.getByteList().getRealSize() > 0) {
string.set(StringSupport.succCommon(getContext().getRuntime(), string.getByteList()));
}
@@ -2011,8 +1988,6 @@ public ToSymNode(RubyContext context, SourceSection sourceSection) {

@Specialization
public RubySymbol toSym(RubyString string) {
notDesignedForCompilation();

return getContext().getSymbol(string.getByteList());
}
}
@@ -2326,10 +2301,8 @@ public ClearNode(RubyContext context, SourceSection sourceSection) {

@Specialization
public RubyString clear(RubyString string) {
notDesignedForCompilation();
ByteList empty = ByteList.EMPTY_BYTELIST;
empty.setEncoding(string.getByteList().getEncoding());

string.set(empty);
return string;
}
Original file line number Diff line number Diff line change
@@ -47,16 +47,14 @@ public CompareNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@TruffleBoundary
@Specialization
public int compare(RubySymbol a, RubySymbol b) {
notDesignedForCompilation();

return a.getByteList().cmp(b.getByteList());
}

@Specialization(guards = "!isRubySymbol(other)")
public RubyNilClass compare(RubySymbol symbol, Object other) {
notDesignedForCompilation();
return nil();
}
}
@@ -68,10 +66,9 @@ public AllSymbolsNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@TruffleBoundary
@Specialization
public RubyArray allSymbols() {
notDesignedForCompilation();

final RubyArray array = new RubyArray(getContext().getCoreLibrary().getArrayClass());

for (RubySymbol s : getContext().getSymbolTable().allSymbols()) {
@@ -91,7 +88,6 @@ public CapitalizeNode(RubyContext context, SourceSection sourceSection) {

@Specialization
public RubySymbol capitalize(RubySymbol symbol) {
notDesignedForCompilation();
final ByteList byteList = SymbolNodesHelper.capitalize(symbol.getByteList());
return getContext().getSymbol(byteList);
}
@@ -105,16 +101,14 @@ public CaseCompareNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@TruffleBoundary
@Specialization
public int caseCompare(RubySymbol symbol, RubySymbol other) {
notDesignedForCompilation();

return symbol.getByteList().caseInsensitiveCmp(other.getByteList());
}

@Specialization(guards = "!isRubySymbol(other)")
public RubyNilClass caseCompare(RubySymbol symbol, Object other) {
notDesignedForCompilation();
return nil();
}

@@ -127,10 +121,9 @@ public DowncaseNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@TruffleBoundary
@Specialization
public RubySymbol downcase(RubySymbol symbol) {
notDesignedForCompilation();

final ByteList byteList = SymbolNodesHelper.downcase(symbol.getByteList());
return getContext().getSymbol(byteList);
}
@@ -146,8 +139,6 @@ public EmptyNode(RubyContext context, SourceSection sourceSection) {

@Specialization
public boolean empty(RubySymbol symbol) {
notDesignedForCompilation();

return symbol.toString().isEmpty();
}

@@ -162,8 +153,6 @@ public EncodingNode(RubyContext context, SourceSection sourceSection) {

@Specialization
public RubyEncoding encoding(RubySymbol symbol) {
notDesignedForCompilation();

return RubyEncoding.getEncoding(symbol.getByteList().getEncoding());
}

@@ -204,10 +193,9 @@ public ToProcNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@TruffleBoundary
@Specialization
public RubyProc toProc(RubySymbol symbol) {
notDesignedForCompilation();

// TODO(CS): this should be doing all kinds of caching
return symbol.toProc(Truffle.getRuntime().getCallerFrame().getCallNode().getEncapsulatingSourceSection(), this);
}
@@ -248,10 +236,9 @@ public InspectNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@TruffleBoundary
@Specialization
public RubyString inspect(RubySymbol symbol) {
notDesignedForCompilation();

return getContext().makeString(symbol.getJRubySymbol().inspect(getContext().getRuntime().getCurrentContext()).asString().decodeString());
}

@@ -280,8 +267,6 @@ public SwapcaseNode(RubyContext context, SourceSection sourceSection) {

@Specialization
public RubySymbol swapcase(RubySymbol symbol) {
notDesignedForCompilation();

final ByteList byteList = SymbolNodesHelper.swapcase(symbol.getByteList());
return getContext().getSymbol(byteList);
}
@@ -297,8 +282,6 @@ public UpcaseNode(RubyContext context, SourceSection sourceSection) {

@Specialization
public RubySymbol upcase(RubySymbol symbol) {
notDesignedForCompilation();

final ByteList byteList = SymbolNodesHelper.upcase(symbol.getByteList());
return getContext().getSymbol(byteList);
}
Original file line number Diff line number Diff line change
@@ -86,8 +86,6 @@ public InitializeNode(RubyContext context, SourceSection sourceSection) {

@Specialization
public RubyNilClass initialize(RubyThread thread, RubyProc block) {
notDesignedForCompilation();

thread.initialize(getContext(), this, block);
return nil();
}
@@ -103,8 +101,6 @@ public JoinNode(RubyContext context, SourceSection sourceSection) {

@Specialization
public RubyThread join(RubyThread thread, UndefinedPlaceholder timeout) {
notDesignedForCompilation();

thread.join();
return thread;
}
@@ -116,15 +112,11 @@ public RubyThread join(RubyThread thread, RubyNilClass timeout) {

@Specialization
public Object join(RubyThread thread, int timeout) {
notDesignedForCompilation();

return joinMillis(thread, timeout * 1000);
}

@Specialization
public Object join(RubyThread thread, double timeout) {
notDesignedForCompilation();

return joinMillis(thread, (int) (timeout * 1000.0));
}

@@ -223,8 +215,6 @@ public StatusNode(RubyContext context, SourceSection sourceSection) {

@Specialization
public Object status(RubyThread self) {
notDesignedForCompilation();

// TODO: slightly hackish
if (self.getStatus() == Status.DEAD) {
if (self.getException() != null) {
@@ -248,8 +238,6 @@ public StopNode(RubyContext context, SourceSection sourceSection) {

@Specialization
public boolean stop(RubyThread self) {
notDesignedForCompilation();

return self.getStatus() == Status.DEAD || self.getStatus() == Status.SLEEP;
}

@@ -264,10 +252,7 @@ public ValueNode(RubyContext context, SourceSection sourceSection) {

@Specialization
public Object value(RubyThread self) {
notDesignedForCompilation();

self.join();

return self.getValue();
}

@@ -282,8 +267,6 @@ public WakeupNode(RubyContext context, SourceSection sourceSection) {

@Specialization
public RubyThread wakeup(final RubyThread thread) {
notDesignedForCompilation();

if (thread.getStatus() == Status.DEAD) {
CompilerDirectives.transferToInterpreter();
throw new RaiseException(getContext().getCoreLibrary().threadError("killed thread", this));
Original file line number Diff line number Diff line change
@@ -57,8 +57,6 @@ public RubyBinding bindingOfCaller() {
* this method, that is then the binding of the caller of the caller.
*/

notDesignedForCompilation();

final Memo<Integer> frameCount = new Memo<>(0);

final MaterializedFrame frame = Truffle.getRuntime().iterateFrames(new FrameInstanceVisitor<MaterializedFrame>() {
@@ -92,8 +90,6 @@ public SourceOfCallerNode(RubyContext context, SourceSection sourceSection) {

@Specialization
public RubyString sourceOfCaller() {
notDesignedForCompilation();

final Memo<Integer> frameCount = new Memo<>(0);

final String source = Truffle.getRuntime().iterateFrames(new FrameInstanceVisitor<String>() {
@@ -136,6 +132,7 @@ public GCTimeNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@CompilerDirectives.TruffleBoundary
@Specialization
public long gcTime() {
return RubyGC.getCollectionTime();
@@ -164,6 +161,7 @@ public AssertNotCompiledNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@CompilerDirectives.TruffleBoundary
@Specialization
public RubyNilClass assertNotCompiled() {
throw new RaiseException(getContext().getCoreLibrary().runtimeError("Truffle::Primitive.assert_not_compiled can only be called lexically", this));
@@ -178,10 +176,9 @@ public DumpCallStackNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@CompilerDirectives.TruffleBoundary
@Specialization
public RubyNilClass dumpCallStack() {
notDesignedForCompilation();

for (String line : Backtrace.DEBUG_FORMATTER.format(getContext(), null, RubyCallStack.getBacktrace(this))) {
System.err.println(line);
}
@@ -213,10 +210,9 @@ public FullTreeNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@CompilerDirectives.TruffleBoundary
@Specialization
public RubyString fullTree() {
notDesignedForCompilation();

return getContext().makeString(NodeUtil.printTreeToString(Truffle.getRuntime().getCallerFrame().getCallNode().getRootNode()));
}

@@ -231,8 +227,6 @@ public JavaClassOfNode(RubyContext context, SourceSection sourceSection) {

@Specialization
public RubyString javaClassOf(Object value) {
notDesignedForCompilation();

return getContext().makeString(value.getClass().getName());
}

@@ -245,10 +239,9 @@ public DumpStringNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@CompilerDirectives.TruffleBoundary
@Specialization
public RubyString dumpString(RubyString string) {
notDesignedForCompilation();

final StringBuilder builder = new StringBuilder();
builder.append("\"");

@@ -270,10 +263,9 @@ public SourceAttributionTreeNode(RubyContext context, SourceSection sourceSectio
super(context, sourceSection);
}

@CompilerDirectives.TruffleBoundary
@Specialization
public RubyString sourceAttributionTree() {
notDesignedForCompilation();

return getContext().makeString(NodeUtil.printSourceAttributionTree(Truffle.getRuntime().getCallerFrame().getCallNode().getRootNode()));
}

@@ -288,8 +280,6 @@ public StorageClassNode(RubyContext context, SourceSection sourceSection) {

@Specialization
public RubyString storageClass(RubyArray array) {
notDesignedForCompilation();

if (array.getStore() == null) {
return getContext().makeString("null");
} else {
@@ -299,8 +289,6 @@ public RubyString storageClass(RubyArray array) {

@Specialization
public RubyString storageClass(RubyHash hash) {
notDesignedForCompilation();

if (hash.getStore() == null) {
return getContext().makeString("null");
} else {
@@ -332,10 +320,9 @@ public ParseTreeNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@CompilerDirectives.TruffleBoundary
@Specialization
public Object parseTree(VirtualFrame frame) {
notDesignedForCompilation();

final org.jruby.ast.Node parseTree = RubyCallStack.getCallingMethod(frame).getSharedMethodInfo().getParseTree();

if (parseTree == null) {
@@ -354,10 +341,9 @@ public TreeNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@CompilerDirectives.TruffleBoundary
@Specialization
public RubyString tree() {
notDesignedForCompilation();

return getContext().makeString(NodeUtil.printCompactTreeToString(Truffle.getRuntime().getCallerFrame().getCallNode().getRootNode()));
}

@@ -370,6 +356,7 @@ public GraalNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@CompilerDirectives.TruffleBoundary
@Specialization
public boolean graal() {
return Truffle.getRuntime().getName().toLowerCase(Locale.ENGLISH).contains("graal");
@@ -398,6 +385,7 @@ public GraalVersionNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@CompilerDirectives.TruffleBoundary
@Specialization
public RubyString graalVersion() {
return getContext().makeString(System.getProperty("graal.version", "unknown"));
@@ -428,6 +416,7 @@ public CoverageResultNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@CompilerDirectives.TruffleBoundary
@Specialization
public RubyHash coverageResult() {
if (getContext().getCoverageTracker() == null) {
Original file line number Diff line number Diff line change
@@ -77,7 +77,8 @@ private RubyClass metaClass(VirtualFrame frame, Object object) {

@Specialization
public RubyMethod bind(VirtualFrame frame, RubyUnboundMethod unboundMethod, Object object) {
notDesignedForCompilation();
CompilerDirectives.transferToInterpreter();

RubyModule module = unboundMethod.getMethod().getDeclaringModule();
// the (redundant) instanceof is to satisfy FindBugs with the following cast
if (module instanceof RubyClass && !ModuleOperations.canBindMethodTo(module, metaClass(frame, object))) {
@@ -103,8 +104,6 @@ public NameNode(RubyContext context, SourceSection sourceSection) {

@Specialization
public RubySymbol name(RubyUnboundMethod unboundMethod) {
notDesignedForCompilation();

return getContext().getSymbol(unboundMethod.getMethod().getName());
}

@@ -146,10 +145,9 @@ public SourceLocationNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@CompilerDirectives.TruffleBoundary
@Specialization
public Object sourceLocation(RubyUnboundMethod unboundMethod) {
notDesignedForCompilation();

SourceSection sourceSection = unboundMethod.getMethod().getSharedMethodInfo().getSourceSection();

if (sourceSection instanceof NullSourceSection) {

0 comments on commit 740b5e5

Please sign in to comment.