Skip to content
Snippets Groups Projects
Commit d71ee15f authored by Lukas Stadler's avatar Lukas Stadler
Browse files

String.format calls are always slow path

parent 514efe21
No related branches found
No related tags found
No related merge requests found
......@@ -123,7 +123,7 @@ public final class RForeignAccessFactoryImpl implements RForeignAccessFactory {
if (access != null) {
return access;
} else {
throw RInternalError.unimplemented("missing foreign access factory for " + obj.getClass().getSimpleName());
throw RInternalError.unimplemented("missing foreign access factory for %s", obj.getClass().getSimpleName());
}
}
}
......
......@@ -23,6 +23,7 @@
package com.oracle.truffle.r.ffi.impl.managed;
import com.oracle.truffle.api.CompilerAsserts;
import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.api.interop.TruffleObject;
import com.oracle.truffle.api.nodes.Node;
......@@ -167,8 +168,8 @@ public final class Managed_RFFIFactory extends RFFIFactory {
return new ManagedRFFIContext();
}
@TruffleBoundary
static RError unsupported(String name) {
CompilerDirectives.transferToInterpreter();
throw RError.error(RError.NO_CALLER, Message.GENERIC, String.format("Feature '%s' is not supported by managed FFI, i.e. it requires running native code.", name));
}
}
......@@ -22,6 +22,7 @@
*/
package com.oracle.truffle.r.ffi.impl.nodes;
import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.api.dsl.Cached;
import com.oracle.truffle.api.dsl.Fallback;
......@@ -193,15 +194,16 @@ public final class CoerceNodes {
@Specialization(replaces = {"doCachedNotList", "doCached"}, guards = {"!isS4Object(value)", "isValidMode(mode)"})
Object doCached(Object value, int mode) {
CompilerDirectives.transferToInterpreter();
String type = value != null ? value.getClass().getSimpleName() : "null";
throw RInternalError.unimplemented(String.format("Rf_coerceVector unimplemented for type %s or mode %s.", type, mode));
throw RInternalError.unimplemented("Rf_coerceVector unimplemented for type %s or mode %s.", type, mode);
}
@Fallback
@TruffleBoundary
Object doFallback(Object value, Object mode) {
CompilerDirectives.transferToInterpreter();
String type = value != null ? value.getClass().getSimpleName() : "null";
throw RInternalError.unimplemented(String.format("Rf_coerceVector unimplemented for type %s or mode %s.", type, mode));
throw RInternalError.unimplemented("Rf_coerceVector unimplemented for type %s or mode %s.", type, mode);
}
static boolean isS4Object(Object obj) {
......@@ -256,7 +258,7 @@ public final class CoerceNodes {
case RAWSXP:
return CastRawNode.createForRFFI(true, preserveDims, preserveAttrs);
default:
throw RInternalError.unimplemented(String.format("Rf_coerceVector called with unimplemented mode %d (type %s).", mode, type));
throw RInternalError.unimplemented("Rf_coerceVector called with unimplemented mode %d (type %s).", mode, type);
}
}
......
......@@ -55,7 +55,7 @@ public abstract class Substr extends RBuiltinNode.Arg3 {
@SuppressWarnings("unused")
@Specialization(guards = "emptyArg(arg)")
protected RStringVector substrEmptyArg(VirtualFrame frame, RAbstractStringVector arg, RAbstractIntVector start, RAbstractIntVector stop) {
protected RStringVector substrEmptyArg(RAbstractStringVector arg, RAbstractIntVector start, RAbstractIntVector stop) {
return RDataFactory.createEmptyStringVector();
}
......
......@@ -22,6 +22,7 @@
*/
package com.oracle.truffle.r.nodes.control;
import com.oracle.truffle.api.CompilerAsserts;
import com.oracle.truffle.api.instrumentation.InstrumentableFactory.WrapperNode;
import com.oracle.truffle.api.nodes.Node;
import com.oracle.truffle.api.nodes.RepeatingNode;
......@@ -43,6 +44,7 @@ public abstract class AbstractLoopNode extends OperatorNode {
@Override
public String toString() {
CompilerAsserts.neverPartOfCompilation();
RootNode rootNode = getRootNode();
String function = "?";
if (rootNode instanceof RRootNode) {
......
......@@ -52,12 +52,12 @@ public final class RInternalError extends Error implements TruffleException {
private final String verboseStackTrace;
public RInternalError(String message, Object... args) {
super(String.format(message, args));
super(Utils.stringFormat(message, args));
verboseStackTrace = createVerboseStackTrace();
}
public RInternalError(Throwable cause, String message, Object... args) {
super(String.format(message, args), cause);
super(Utils.stringFormat(message, args), cause);
verboseStackTrace = createVerboseStackTrace();
}
......@@ -106,6 +106,11 @@ public final class RInternalError extends Error implements TruffleException {
throw new RInternalError("not implemented: %s", message);
}
public static RuntimeException unimplemented(String format, Object... args) {
CompilerDirectives.transferToInterpreter();
throw new RInternalError("not implemented: %s", String.format(format, args));
}
public static RuntimeException shouldNotReachHere() {
CompilerDirectives.transferToInterpreter();
throw new RInternalError("should not reach here");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment