Skip to content

Commit

Permalink
[Truffle] Remove more notDesigneds.
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisseaton committed May 7, 2015
1 parent af42d09 commit 740b5e5
Show file tree
Hide file tree
Showing 13 changed files with 47 additions and 143 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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?

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -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++) {
Expand Down Expand Up @@ -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()));
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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) {
Expand Down Expand Up @@ -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;

Expand All @@ -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;

Expand All @@ -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);
}
Expand All @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand All @@ -111,8 +111,6 @@ public PidNode(RubyContext context, SourceSection sourceSection) {

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

return posix().getpid();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}

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

Expand Down
Loading

0 comments on commit 740b5e5

Please sign in to comment.