Skip to content

Commit

Permalink
Showing 10 changed files with 14 additions and 55 deletions.
Original file line number Diff line number Diff line change
@@ -11,6 +11,7 @@
*/
package org.jruby.truffle.nodes.rubinius;

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;
@@ -198,7 +199,7 @@ public EncodingConverterLastErrorNode(RubyContext context, SourceSection sourceS

@Specialization
public Object encodingConverterLastError(VirtualFrame frame, RubyEncodingConverter encodingConverter) {
notDesignedForCompilation();
CompilerDirectives.transferToInterpreter();

final EConv ec = encodingConverter.getEConv();
final EConv.LastError lastError = ec.lastError;
@@ -248,7 +249,7 @@ public EncodingConverterErrinfoNode(RubyContext context, SourceSection sourceSec

@Specialization
public Object encodingConverterLastError(RubyEncodingConverter encodingConverter) {
notDesignedForCompilation();
CompilerDirectives.transferToInterpreter();

final EConv ec = encodingConverter.getEConv();

Original file line number Diff line number Diff line change
@@ -28,15 +28,11 @@ public EncodingGetObjectEncodingNode(RubyContext context, SourceSection sourceSe

@Specialization
public RubyEncoding encodingGetObjectEncoding(RubyString string) {
notDesignedForCompilation();

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

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

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

Original file line number Diff line number Diff line change
@@ -139,10 +139,9 @@ public Object pow(long a, double b) {
}
}

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

if (a == 0) {
return 0;
}
Original file line number Diff line number Diff line change
@@ -32,10 +32,9 @@ public FloatDToAPrimitiveNode(RubyContext context, SourceSection sourceSection)
super(context, sourceSection);
}

@CompilerDirectives.TruffleBoundary
@Specialization
public RubyArray dToA(double value) {
notDesignedForCompilation();

String string = String.format(Locale.ENGLISH, "%.9f", value);

if (string.toLowerCase(Locale.ENGLISH).contains("e")) {
Original file line number Diff line number Diff line change
@@ -38,8 +38,6 @@ public RandomizerSeedPrimitiveNode(RubyContext context, SourceSection sourceSect

@Specialization
public long randomizerSeed(RubyBasicObject random) {
notDesignedForCompilation();

return System.currentTimeMillis();
}

@@ -54,8 +52,6 @@ public RandomizerRandFloatPrimitiveNode(RubyContext context, SourceSection sourc

@Specialization
public double randomizerRandFloat(RubyBasicObject random) {
notDesignedForCompilation();

return Math.random();
}

@@ -70,15 +66,11 @@ public RandomizerRandIntPrimitiveNode(RubyContext context, SourceSection sourceS

@Specialization
public long randomizerRandInt(RubyBasicObject random, Integer limit) {
notDesignedForCompilation();

return RandomPrimitiveHelper.randomInt(getContext().getRuntime().getCurrentContext().getRuntime(), limit);
}

@Specialization
public long randomizerRandInt(RubyBasicObject random, Long limit) {
notDesignedForCompilation();

return RandomPrimitiveHelper.randomInt(getContext().getRuntime().getCurrentContext().getRuntime(), limit);
}
}
@@ -90,10 +82,9 @@ public RandomizerGenSeedPrimitiveNode(RubyContext context, SourceSection sourceS
super(context, sourceSection);
}

@CompilerDirectives.TruffleBoundary
@Specialization
public RubyBignum randomizerGenSeed(RubyBasicObject random) {
notDesignedForCompilation();

BigInteger integer = RandomPrimitiveHelper.randomSeed(getContext().getRuntime().getCurrentContext().getRuntime());
return new RubyBignum(getContext().getCoreLibrary().getBignumClass(), integer);
}
Original file line number Diff line number Diff line change
@@ -37,8 +37,6 @@ public RegexpInitializePrimitiveNode(RubyContext context, SourceSection sourceSe

@Specialization
public RubyRegexp initialize(RubyRegexp regexp, RubyString pattern, int options) {
notDesignedForCompilation();

regexp.initialize(this, pattern.getByteList(), options);
return regexp;
}
@@ -52,17 +50,14 @@ public RegexpSearchRegionPrimitiveNode(RubyContext context, SourceSection source
super(context, sourceSection);
}

@CompilerDirectives.TruffleBoundary
@Specialization
public Object searchRegion(RubyRegexp regexp, RubyString string, int start, int end, boolean forward) {
notDesignedForCompilation();

if (regexp.getRegex() == null) {
CompilerDirectives.transferToInterpreter();
throw new RaiseException(getContext().getCoreLibrary().typeError("uninitialized Regexp", this));
}

if (string.scanForCodeRange() == StringSupport.CR_BROKEN) {
CompilerDirectives.transferToInterpreter();
throw new RaiseException(getContext().getCoreLibrary().argumentError(
String.format("invalid byte sequence in %s", string.getByteList().getEncoding()), this));
}
@@ -83,8 +78,6 @@ public RegexpSetLastMatchPrimitiveNode(RubyContext context, SourceSection source

@Specialization
public Object setLastMatch(RubyClass regexpClass, Object matchData) {
notDesignedForCompilation();

getContext().getThreadManager().getCurrentThread().getThreadLocals().getObjectType().setInstanceVariable(
getContext().getThreadManager().getCurrentThread().getThreadLocals(), "$~", matchData);

Original file line number Diff line number Diff line change
@@ -118,10 +118,9 @@ public StringAwkSplitPrimitiveNode(RubyContext context, SourceSection sourceSect
taintResultNode = new TaintResultNode(context, sourceSection);
}

@CompilerDirectives.TruffleBoundary
@Specialization
public RubyArray stringAwkSplit(RubyString string, int lim) {
notDesignedForCompilation();

final List<RubyString> ret = new ArrayList<>();
final ByteList value = string.getByteList();
final boolean limit = lim > 0;
@@ -535,21 +534,18 @@ public RubyString stringFromCodepointSimple(int code, RubyEncoding encoding) {
new ByteList(new byte[]{(byte) code}, encoding.getEncoding()));
}

@CompilerDirectives.TruffleBoundary
@Specialization(guards = "!isSimple(code, encoding)")
public RubyString stringFromCodepoint(int code, RubyEncoding encoding) {
notDesignedForCompilation();

final int length;

try {
length = encoding.getEncoding().codeToMbcLength(code);
} catch (EncodingException e) {
CompilerDirectives.transferToInterpreter();
throw new RaiseException(getContext().getCoreLibrary().rangeError(code, encoding, this));
}

if (length <= 0) {
CompilerDirectives.transferToInterpreter();
throw new RaiseException(getContext().getCoreLibrary().rangeError(code, encoding, this));
}

@@ -569,8 +565,6 @@ public RubyString stringFromCodepoint(int code, RubyEncoding encoding) {

@Specialization
public RubyString stringFromCodepointSimple(long code, RubyEncoding encoding) {
notDesignedForCompilation();

if (code < Integer.MIN_VALUE || code > Integer.MAX_VALUE) {
CompilerDirectives.transferToInterpreter();
throw new UnsupportedOperationException();
@@ -594,8 +588,6 @@ public StringToFPrimitiveNode(RubyContext context, SourceSection sourceSection)

@Specialization
public Object stringToF(RubyString string) {
notDesignedForCompilation();

try {
return Double.parseDouble(string.toString());
} catch (NumberFormatException e) {
@@ -707,10 +699,9 @@ public StringCharacterIndexPrimitiveNode(RubyContext context, SourceSection sour
super(context, sourceSection);
}

@CompilerDirectives.TruffleBoundary
@Specialization
public Object stringCharacterIndex(RubyString string, RubyString pattern, int offset) {
notDesignedForCompilation();

if (offset < 0) {
return nil();
}
@@ -1089,18 +1080,16 @@ public StringToInumPrimitiveNode(RubyContext context, SourceSection sourceSectio
super(context, sourceSection);
}

@CompilerDirectives.TruffleBoundary
@Specialization
public Object stringToInum(RubyString string, int fixBase, boolean strict) {
notDesignedForCompilation();

try {
final org.jruby.RubyInteger result = ConvertBytes.byteListToInum19(getContext().getRuntime(),
string.getByteList(),
fixBase,
strict);

return getContext().toTruffle(result);

} catch (org.jruby.exceptions.RaiseException e) {
throw new RaiseException(getContext().toTruffle(e.getException(), this));
}
@@ -1117,7 +1106,6 @@ public StringByteAppendPrimitiveNode(RubyContext context, SourceSection sourceSe

@Specialization
public RubyString stringByteAppend(RubyString string, RubyString other) {
notDesignedForCompilation();
string.getByteList().append(other.getByteList());
return string;
}
Original file line number Diff line number Diff line change
@@ -9,6 +9,7 @@
*/
package org.jruby.truffle.nodes.rubinius;

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;
@@ -26,9 +27,9 @@ public SymbolIsConstantPrimitiveNode(RubyContext context, SourceSection sourceSe
super(context, sourceSection);
}

@CompilerDirectives.TruffleBoundary
@Specialization
public boolean symbolIsConstant(RubySymbol symbol) {
notDesignedForCompilation();
final String string = symbol.toString();
return string.length() > 0 && Character.isUpperCase(string.charAt(0));
}
Original file line number Diff line number Diff line change
@@ -99,14 +99,12 @@ private boolean areSame(VirtualFrame frame, Object left, Object right) {

@Specialization
public Object doCatch(VirtualFrame frame, Object tag, RubyProc block) {
notDesignedForCompilation();
CompilerDirectives.transferToInterpreter();

try {
return dispatchNode.dispatch(frame, block, tag);
} catch (ThrowException e) {
if (areSame(frame, e.getTag(), tag)) {
notDesignedForCompilation();

if (clearExceptionVariableNode == null) {
CompilerDirectives.transferToInterpreter();
clearExceptionVariableNode = insert(
@@ -157,7 +155,6 @@ public VMGetModuleNamePrimitiveNode(RubyContext context, SourceSection sourceSec

@Specialization
public RubyString vmGetModuleName(RubyModule module) {
notDesignedForCompilation();
return getContext().makeString(module.getName());
}

@@ -335,7 +332,6 @@ public VMObjectSingletonClassObjectPrimitiveNode(RubyContext context, SourceSect

@Specialization
public Object vmSingletonClassObject(Object object) {
notDesignedForCompilation();
return object instanceof RubyClass && ((RubyClass) object).isSingleton();
}

@@ -350,8 +346,6 @@ public ThrowNode(RubyContext context, SourceSection sourceSection) {

@Specialization
public Object doThrow(Object tag, Object value) {
notDesignedForCompilation();

throw new ThrowException(tag, value);
}

Original file line number Diff line number Diff line change
@@ -430,14 +430,11 @@ public Object scan(RubyString string) {
}

public static Regex compile(Node currentNode, RubyContext context, ByteList bytes, int options) {
RubyNode.notDesignedForCompilation();
return compile(currentNode, context, bytes.bytes(), bytes.getEncoding(), options);
}

@TruffleBoundary
public static Regex compile(Node currentNode, RubyContext context, byte[] bytes, Encoding encoding, int options) {
RubyNode.notDesignedForCompilation();

try {
return new Regex(bytes, 0, bytes.length, options, encoding, Syntax.RUBY);
} catch (ValueException e) {

0 comments on commit a5b4813

Please sign in to comment.