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

[GR-7472] String.format calls are always slow path.

parents 4fc71e66 d71ee15f
Branches
No related tags found
No related merge requests found
...@@ -123,7 +123,7 @@ public final class RForeignAccessFactoryImpl implements RForeignAccessFactory { ...@@ -123,7 +123,7 @@ public final class RForeignAccessFactoryImpl implements RForeignAccessFactory {
if (access != null) { if (access != null) {
return access; return access;
} else { } 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 @@ ...@@ -23,6 +23,7 @@
package com.oracle.truffle.r.ffi.impl.managed; package com.oracle.truffle.r.ffi.impl.managed;
import com.oracle.truffle.api.CompilerAsserts; import com.oracle.truffle.api.CompilerAsserts;
import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.api.interop.TruffleObject; import com.oracle.truffle.api.interop.TruffleObject;
import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.nodes.Node;
...@@ -167,8 +168,8 @@ public final class Managed_RFFIFactory extends RFFIFactory { ...@@ -167,8 +168,8 @@ public final class Managed_RFFIFactory extends RFFIFactory {
return new ManagedRFFIContext(); return new ManagedRFFIContext();
} }
@TruffleBoundary
static RError unsupported(String name) { 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)); 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 @@ ...@@ -22,6 +22,7 @@
*/ */
package com.oracle.truffle.r.ffi.impl.nodes; 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.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Cached;
import com.oracle.truffle.api.dsl.Fallback; import com.oracle.truffle.api.dsl.Fallback;
...@@ -193,15 +194,16 @@ public final class CoerceNodes { ...@@ -193,15 +194,16 @@ public final class CoerceNodes {
@Specialization(replaces = {"doCachedNotList", "doCached"}, guards = {"!isS4Object(value)", "isValidMode(mode)"}) @Specialization(replaces = {"doCachedNotList", "doCached"}, guards = {"!isS4Object(value)", "isValidMode(mode)"})
Object doCached(Object value, int mode) { Object doCached(Object value, int mode) {
CompilerDirectives.transferToInterpreter();
String type = value != null ? value.getClass().getSimpleName() : "null"; 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 @Fallback
@TruffleBoundary
Object doFallback(Object value, Object mode) { Object doFallback(Object value, Object mode) {
CompilerDirectives.transferToInterpreter();
String type = value != null ? value.getClass().getSimpleName() : "null"; 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) { static boolean isS4Object(Object obj) {
...@@ -256,7 +258,7 @@ public final class CoerceNodes { ...@@ -256,7 +258,7 @@ public final class CoerceNodes {
case RAWSXP: case RAWSXP:
return CastRawNode.createForRFFI(true, preserveDims, preserveAttrs); return CastRawNode.createForRFFI(true, preserveDims, preserveAttrs);
default: 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 { ...@@ -55,7 +55,7 @@ public abstract class Substr extends RBuiltinNode.Arg3 {
@SuppressWarnings("unused") @SuppressWarnings("unused")
@Specialization(guards = "emptyArg(arg)") @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(); return RDataFactory.createEmptyStringVector();
} }
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
*/ */
package com.oracle.truffle.r.nodes.control; 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.instrumentation.InstrumentableFactory.WrapperNode;
import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.nodes.Node;
import com.oracle.truffle.api.nodes.RepeatingNode; import com.oracle.truffle.api.nodes.RepeatingNode;
...@@ -43,6 +44,7 @@ public abstract class AbstractLoopNode extends OperatorNode { ...@@ -43,6 +44,7 @@ public abstract class AbstractLoopNode extends OperatorNode {
@Override @Override
public String toString() { public String toString() {
CompilerAsserts.neverPartOfCompilation();
RootNode rootNode = getRootNode(); RootNode rootNode = getRootNode();
String function = "?"; String function = "?";
if (rootNode instanceof RRootNode) { if (rootNode instanceof RRootNode) {
......
...@@ -52,12 +52,12 @@ public final class RInternalError extends Error implements TruffleException { ...@@ -52,12 +52,12 @@ public final class RInternalError extends Error implements TruffleException {
private final String verboseStackTrace; private final String verboseStackTrace;
public RInternalError(String message, Object... args) { public RInternalError(String message, Object... args) {
super(String.format(message, args)); super(Utils.stringFormat(message, args));
verboseStackTrace = createVerboseStackTrace(); verboseStackTrace = createVerboseStackTrace();
} }
public RInternalError(Throwable cause, String message, Object... args) { public RInternalError(Throwable cause, String message, Object... args) {
super(String.format(message, args), cause); super(Utils.stringFormat(message, args), cause);
verboseStackTrace = createVerboseStackTrace(); verboseStackTrace = createVerboseStackTrace();
} }
...@@ -106,6 +106,11 @@ public final class RInternalError extends Error implements TruffleException { ...@@ -106,6 +106,11 @@ public final class RInternalError extends Error implements TruffleException {
throw new RInternalError("not implemented: %s", message); 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() { public static RuntimeException shouldNotReachHere() {
CompilerDirectives.transferToInterpreter(); CompilerDirectives.transferToInterpreter();
throw new RInternalError("should not reach here"); throw new RInternalError("should not reach here");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment