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

Merge pull request #549 in G/fastr from ~LUKAS.STADLER_ORACLE.COM/fastr:cleanups to master

* commit 'bb62d4d7':
  simplifications in RContext, use new DSL layout in Tilde, fast path in RSerialize, more precise TruffleBoundary in RRuntime
parents 0a3bac5f bb62d4d7
No related branches found
No related tags found
No related merge requests found
...@@ -22,12 +22,13 @@ ...@@ -22,12 +22,13 @@
*/ */
package com.oracle.truffle.r.nodes.builtin.base; package com.oracle.truffle.r.nodes.builtin.base;
import static com.oracle.truffle.r.nodes.builtin.CastBuilder.Predef.*; import static com.oracle.truffle.r.nodes.builtin.CastBuilder.Predef.notEmpty;
import static com.oracle.truffle.r.nodes.builtin.CastBuilder.Predef.stringValue;
import static com.oracle.truffle.r.nodes.builtin.CastBuilder.Predef.toBoolean;
import static com.oracle.truffle.r.runtime.RVisibility.OFF; import static com.oracle.truffle.r.runtime.RVisibility.OFF;
import static com.oracle.truffle.r.runtime.builtins.RBehavior.COMPLEX; import static com.oracle.truffle.r.runtime.builtins.RBehavior.COMPLEX;
import static com.oracle.truffle.r.runtime.builtins.RBuiltinKind.INTERNAL; import static com.oracle.truffle.r.runtime.builtins.RBuiltinKind.INTERNAL;
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.Specialization; import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.r.nodes.builtin.CastBuilder; import com.oracle.truffle.r.nodes.builtin.CastBuilder;
...@@ -51,7 +52,6 @@ public abstract class Warning extends RBuiltinNode { ...@@ -51,7 +52,6 @@ public abstract class Warning extends RBuiltinNode {
@Specialization @Specialization
@TruffleBoundary @TruffleBoundary
protected String warning(boolean call, boolean immediate, boolean noBreakWarning, String message) { protected String warning(boolean call, boolean immediate, boolean noBreakWarning, String message) {
CompilerDirectives.transferToInterpreter();
RErrorHandling.warningcallInternal(call, message, immediate, noBreakWarning); RErrorHandling.warningcallInternal(call, message, immediate, noBreakWarning);
return message; return message;
} }
......
...@@ -27,7 +27,9 @@ import static com.oracle.truffle.r.runtime.builtins.RBuiltinKind.PRIMITIVE; ...@@ -27,7 +27,9 @@ import static com.oracle.truffle.r.runtime.builtins.RBuiltinKind.PRIMITIVE;
import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Cached;
import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.dsl.TypeSystemReference;
import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.r.nodes.EmptyTypeSystemFlatLayout;
import com.oracle.truffle.r.nodes.attributes.SetFixedAttributeNode; import com.oracle.truffle.r.nodes.attributes.SetFixedAttributeNode;
import com.oracle.truffle.r.nodes.attributes.SpecialAttributesFunctions.SetClassAttributeNode; import com.oracle.truffle.r.nodes.attributes.SpecialAttributesFunctions.SetClassAttributeNode;
import com.oracle.truffle.r.nodes.builtin.RBuiltinNode; import com.oracle.truffle.r.nodes.builtin.RBuiltinNode;
...@@ -48,6 +50,7 @@ import com.oracle.truffle.r.runtime.nodes.RBaseNode; ...@@ -48,6 +50,7 @@ import com.oracle.truffle.r.runtime.nodes.RBaseNode;
* argument is missing, i.e. {@code ~ x} result in {@code `~`(x)}. * argument is missing, i.e. {@code ~ x} result in {@code `~`(x)}.
*/ */
@RBuiltin(name = "~", kind = PRIMITIVE, parameterNames = {"x", "y"}, nonEvalArgs = {0, 1}, behavior = READS_FRAME) @RBuiltin(name = "~", kind = PRIMITIVE, parameterNames = {"x", "y"}, nonEvalArgs = {0, 1}, behavior = READS_FRAME)
@TypeSystemReference(EmptyTypeSystemFlatLayout.class)
public abstract class Tilde extends RBuiltinNode { public abstract class Tilde extends RBuiltinNode {
private static final RStringVector FORMULA_CLASS = RDataFactory.createStringVectorFromScalar(RRuntime.FORMULA_CLASS); private static final RStringVector FORMULA_CLASS = RDataFactory.createStringVectorFromScalar(RRuntime.FORMULA_CLASS);
......
...@@ -58,7 +58,7 @@ public abstract class FirstBooleanNode extends CastNode { ...@@ -58,7 +58,7 @@ public abstract class FirstBooleanNode extends CastNode {
protected boolean firstScalar(byte argument) { protected boolean firstScalar(byte argument) {
if (RRuntime.isNA(argument)) { if (RRuntime.isNA(argument)) {
CompilerDirectives.transferToInterpreter(); CompilerDirectives.transferToInterpreter();
RError.error(this, invalidValueName == null ? Message.NA_UNEXP : Message.INVALID_VALUE, invalidValueName); throw RError.error(this, invalidValueName == null ? Message.NA_UNEXP : Message.INVALID_VALUE, invalidValueName);
} }
return RRuntime.fromLogical(argument); return RRuntime.fromLogical(argument);
} }
......
...@@ -512,15 +512,19 @@ public class RRuntime { ...@@ -512,15 +512,19 @@ public class RRuntime {
return isNA(i) ? createComplexNA() : int2complexNoCheck(i); return isNA(i) ? createComplexNA() : int2complexNoCheck(i);
} }
@TruffleBoundary
public static String intToStringNoCheck(int operand) { public static String intToStringNoCheck(int operand) {
if (operand >= MIN_CACHED_NUMBER && operand <= MAX_CACHED_NUMBER) { if (operand >= MIN_CACHED_NUMBER && operand <= MAX_CACHED_NUMBER) {
return numberStringCache[operand - MIN_CACHED_NUMBER]; return numberStringCache[operand - MIN_CACHED_NUMBER];
} else { } else {
return String.valueOf(operand); return intToStringInternal(operand);
} }
} }
@TruffleBoundary
private static String intToStringInternal(int operand) {
return String.valueOf(operand);
}
public static boolean isCachedNumberString(int value) { public static boolean isCachedNumberString(int value) {
return value >= MIN_CACHED_NUMBER && value <= MAX_CACHED_NUMBER; return value >= MIN_CACHED_NUMBER && value <= MAX_CACHED_NUMBER;
} }
......
...@@ -458,8 +458,12 @@ public class RSerialize { ...@@ -458,8 +458,12 @@ public class RSerialize {
* only used in a warning message in the unlikely event that the namespace * only used in a warning message in the unlikely event that the namespace
* cannot be found. * cannot be found.
*/ */
Object r = RContext.getEngine().evalFunction(contextState.getDotDotFindNamespace(), null, null, null, s, ""); // fast path through getRegisteredNamespace
return checkResult(addReadRef(r)); Object namespace = REnvironment.getRegisteredNamespace(s.getDataAt(0));
if (namespace == null) {
namespace = RContext.getEngine().evalFunction(contextState.getDotDotFindNamespace(), null, null, null, s, "");
}
return checkResult(addReadRef(namespace));
} }
case PERSISTSXP: { case PERSISTSXP: {
......
...@@ -41,7 +41,6 @@ import com.oracle.truffle.api.TruffleLanguage.Env; ...@@ -41,7 +41,6 @@ import com.oracle.truffle.api.TruffleLanguage.Env;
import com.oracle.truffle.api.instrumentation.Instrumenter; import com.oracle.truffle.api.instrumentation.Instrumenter;
import com.oracle.truffle.api.interop.ForeignAccess; import com.oracle.truffle.api.interop.ForeignAccess;
import com.oracle.truffle.api.interop.TruffleObject; import com.oracle.truffle.api.interop.TruffleObject;
import com.oracle.truffle.api.nodes.InvalidAssumptionException;
import com.oracle.truffle.api.source.Source; import com.oracle.truffle.api.source.Source;
import com.oracle.truffle.api.vm.PolyglotEngine; import com.oracle.truffle.api.vm.PolyglotEngine;
import com.oracle.truffle.r.runtime.ExitException; import com.oracle.truffle.r.runtime.ExitException;
...@@ -648,13 +647,8 @@ public final class RContext extends ExecutionContext implements TruffleObject { ...@@ -648,13 +647,8 @@ public final class RContext extends ExecutionContext implements TruffleObject {
public static RContext getInstance() { public static RContext getInstance() {
RContext context = singleContext; RContext context = singleContext;
if (context != null) { if (singleContextAssumption.isValid() && context != null) {
try { return context;
singleContextAssumption.check();
return context;
} catch (InvalidAssumptionException e) {
// fallback to slow case
}
} }
Thread current = Thread.currentThread(); Thread current = Thread.currentThread();
......
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