Skip to content

Commit f848d2b

Browse files
committed
[GR-12559] Clean-up FastROptions and hide internal errors logging behind an option.
PullRequest: fastr/1841
2 parents 882b22c + e0a59fc commit f848d2b

File tree

9 files changed

+11
-59
lines changed

9 files changed

+11
-59
lines changed

ci_common/common.hocon

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ common : ${java8Downloads} ${packagesLinux} {
9090
environment : {
9191
PKG_TEST_ENV_miniUI : "LC_ALL=C"
9292
PKG_TEST_ENV_compare : "LC_ALL=C"
93+
FASTR_OPTION_PrintErrorStacktracesToFile: "true"
9394
}
9495
}
9596

com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/REngine.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -641,8 +641,8 @@ public RNode getBody() {
641641

642642
@TruffleBoundary
643643
private static boolean checkResult(Object result) {
644-
if (FastROptions.CheckResultCompleteness.getBooleanValue() && result instanceof RAbstractVector) {
645-
assert RAbstractVector.verify((RAbstractVector) result);
644+
if (result instanceof RAbstractVector) {
645+
return RAbstractVector.verify((RAbstractVector) result);
646646
}
647647
return true;
648648
}

com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/RRuntimeASTAccessImpl.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@
5454
import com.oracle.truffle.r.nodes.function.ClassHierarchyNode;
5555
import com.oracle.truffle.r.nodes.function.FunctionDefinitionNode;
5656
import com.oracle.truffle.r.nodes.function.RCallNode;
57-
import com.oracle.truffle.r.nodes.instrumentation.RInstrumentation;
5857
import com.oracle.truffle.r.nodes.instrumentation.RSyntaxTags.FunctionBodyBlockTag;
5958
import com.oracle.truffle.r.nodes.instrumentation.RSyntaxTags.LoopTag;
6059
import com.oracle.truffle.r.runtime.ArgumentsSignature;
@@ -489,11 +488,6 @@ public String encodeComplex(RComplex x, int digits) {
489488
return ComplexVectorPrinter.encodeComplex(x, digits);
490489
}
491490

492-
@Override
493-
public void checkDebugRequest(RFunction func) {
494-
RInstrumentation.checkDebugRequested(func);
495-
}
496-
497491
@Override
498492
public Class<? extends TruffleRLanguage> getTruffleRLanguage() {
499493
return TruffleRLanguageImpl.class;

com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/FunctionExpressionNode.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
import com.oracle.truffle.r.nodes.function.PromiseHelperNode.PromiseDeoptimizeFrameNode;
3434
import com.oracle.truffle.r.nodes.function.opt.EagerEvalHelper;
3535
import com.oracle.truffle.r.nodes.function.visibility.SetVisibilityNode;
36-
import com.oracle.truffle.r.nodes.instrumentation.RInstrumentation;
3736
import com.oracle.truffle.r.runtime.ArgumentsSignature;
3837
import com.oracle.truffle.r.runtime.RArguments;
3938
import com.oracle.truffle.r.runtime.data.RDataFactory;
@@ -82,9 +81,7 @@ public RFunction execute(VirtualFrame frame) {
8281
}
8382
initialized = true;
8483
}
85-
RFunction func = RDataFactory.createFunction(RFunction.NO_NAME, RFunction.NO_NAME, callTarget, null, matFrame);
86-
RInstrumentation.checkDebugRequested(func);
87-
return func;
84+
return RDataFactory.createFunction(RFunction.NO_NAME, RFunction.NO_NAME, callTarget, null, matFrame);
8885
}
8986

9087
public RootCallTarget getCallTarget() {

com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/instrumentation/RInstrumentation.java

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
*/
2323
package com.oracle.truffle.r.nodes.instrumentation;
2424

25-
import com.oracle.truffle.api.CompilerDirectives.CompilationFinal;
2625
import com.oracle.truffle.api.instrumentation.Instrumenter;
2726
import com.oracle.truffle.api.instrumentation.SourceSectionFilter;
2827
import com.oracle.truffle.api.instrumentation.SourceSectionFilter.IndexRange;
@@ -31,7 +30,6 @@
3130
import com.oracle.truffle.api.source.SourceSection;
3231
import com.oracle.truffle.r.nodes.function.FunctionDefinitionNode;
3332
import com.oracle.truffle.r.nodes.instrumentation.RSyntaxTags.FunctionBodyBlockTag;
34-
import com.oracle.truffle.r.runtime.FastROptions;
3533
import com.oracle.truffle.r.runtime.RSource;
3634
import com.oracle.truffle.r.runtime.context.RContext;
3735
import com.oracle.truffle.r.runtime.data.RFunction;
@@ -43,12 +41,6 @@
4341
*/
4442
public class RInstrumentation {
4543

46-
/**
47-
* The function names that were requested to be used in implicit {@code debug(f)} calls, when
48-
* those functions are defined. Global to all contexts.
49-
*/
50-
@CompilationFinal(dimensions = 1) private static String[] debugFunctionNames;
51-
5244
public static FunctionDefinitionNode getFunctionDefinitionNode(RFunction func) {
5345
assert !func.isBuiltin();
5446
return (FunctionDefinitionNode) func.getRootNode();
@@ -58,30 +50,18 @@ public static SourceSection getSourceSection(RFunction func) {
5850
return func.getRootNode().getSourceSection();
5951
}
6052

61-
/**
62-
* Create a filter that matches all the statement nodes in {@code func}.
63-
*/
64-
static SourceSectionFilter.Builder createFunctionStatementFilter(RFunction func) {
65-
return createFunctionFilter(func, StandardTags.StatementTag.class);
66-
}
67-
6853
public static SourceSectionFilter.Builder createFunctionStatementFilter(FunctionDefinitionNode fdn) {
6954
return createFunctionFilter(fdn, StandardTags.StatementTag.class);
7055
}
7156

72-
static SourceSectionFilter.Builder createFunctionFilter(RFunction func, Class<?> tag) {
73-
FunctionDefinitionNode fdn = getFunctionDefinitionNode(func);
74-
return createFunctionFilter(fdn, tag);
75-
}
76-
7757
public static SourceSectionFilter.Builder createFunctionFilter(FunctionDefinitionNode fdn, Class<?> tag) {
7858
/* Filter needs to check for statement tags in the range of the function in the Source */
7959
SourceSectionFilter.Builder builder = SourceSectionFilter.newBuilder();
8060
builder.tagIs(tag);
8161
SourceSection fdns = fdn.getSourceSection();
8262
builder.indexIn(fdns.getCharIndex(), fdns.getCharLength());
8363
Source source = fdns.getSource();
84-
builder.sourceIs(s -> source.equals(s));
64+
builder.sourceIs(source::equals);
8565
return builder;
8666
}
8767

@@ -113,26 +93,11 @@ public static SourceSectionFilter.Builder createFunctionStartFilter(RFunction fu
11393
* global (command-line) options for tracing and timing. They are applied to every context.
11494
*/
11595
public static void activate(@SuppressWarnings("unused") RContext context) {
116-
String rdebugValue = FastROptions.Rdebug.getStringValue();
117-
if (rdebugValue != null) {
118-
debugFunctionNames = rdebugValue.split(",");
119-
}
12096
// Check for function tracing
12197
RContext.getRRuntimeASTAccess().traceAllFunctions();
12298
}
12399

124100
public static Instrumenter getInstrumenter() {
125101
return RContext.getInstance().getInstrumentationState().getInstrumenter();
126102
}
127-
128-
public static void checkDebugRequested(RFunction func) {
129-
if (debugFunctionNames != null) {
130-
FunctionDefinitionNode fdn = (FunctionDefinitionNode) func.getRootNode();
131-
for (String debugFunctionName : debugFunctionNames) {
132-
if (debugFunctionName.equals(fdn.toString())) {
133-
RContext.getRRuntimeASTAccess().enableDebug(func, false);
134-
}
135-
}
136-
}
137-
}
138103
}

com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/FastROptions.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@
3838
*/
3939
public enum FastROptions {
4040
PrintErrorStacktraces("Prints Java and R stack traces for all errors", false),
41-
PrintErrorStacktracesToFile("Dumps Java and R stack traces to 'fastr_errors.log' for all errors", true),
42-
CheckResultCompleteness("Assert completeness of results vectors after evaluating unit tests and R shell commands", true),
41+
PrintErrorStacktracesToFile("Dumps Java and R stack traces to 'fastr_errors.log' for all errors", false),
42+
// TODO: this should be logging category
4343
Debug("Debug=name1,name2,...; Turn on debugging output for 'name1', 'name2', etc.", null, true),
4444
TraceCalls("Trace all R function calls", false),
4545
TraceCallsToFile("TraceCalls output is sent to 'fastr_tracecalls.log'", false),
@@ -50,15 +50,14 @@ public enum FastROptions {
5050
PrintComplexLookups("Print a message for each non-trivial variable lookup", false),
5151
FullPrecisionSum("Use 128 bit arithmetic in sum builtin", false),
5252
InvisibleArgs("Argument writes do not trigger state transitions", true),
53-
RefCountIncrementOnly("Disable reference count decrements for experimental state transition implementation", false),
53+
RefCountIncrementOnly("Disable reference count decrements", false),
5454
UseInternalGridGraphics("Whether the internal (Java) grid graphics implementation should be used", true),
5555
UseSpecials("Whether the fast-path special call nodes should be created for simple enough arguments.", true),
5656
ForceSources("Generate source sections for unserialized code", false),
5757
SharedContexts("Whether all child contexts are to be shared contexts", true),
5858
SearchPathForcePromises("Whether all promises for frames on shared path are forced in presence of shared contexts", false),
5959
LoadPackagesNativeCode("Load native code of packages, including builtin packages.", !FastRConfig.ManagedMode),
6060
SynchronizeNativeCode("allow only one thread to enter packages' native code", false),
61-
ForeignObjectWrappers("use wrappers for foreign objects (as opposed to full conversion)", true),
6261

6362
// Promises optimizations
6463
EagerEval("If enabled, overrides all other EagerEval switches (see EagerEvalHelper)", false),
@@ -74,8 +73,7 @@ public enum FastROptions {
7473

7574
IgnoreGraphicsCalls("Silently ignore unimplemented functions from graphics package", false),
7675
AdditionalOptions("List of R level options default values. Syntax: 'optionName:value;optionName2:value;'. " +
77-
"Value can be 'T' or 'F' in which case it is interpreted as boolean, otherwise as string", "", true),
78-
StartupTiming("Records and prints various timestamps during initialization", false);
76+
"Value can be 'T' or 'F' in which case it is interpreted as boolean, otherwise as string", "", true);
7977

8078
/**
8179
* Setting this environment variable activates the tracing of the bitcode of selected LLVM

com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RInternalError.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,8 @@ private static void reportError(String errMsg, Throwable throwable, int contextI
213213
RSuicide.rSuicide("FastR internal error");
214214
}
215215
} else {
216-
message += ".";
216+
message += ". You can rerun FastR with --jvm.DR:+" + FastROptions.PrintErrorStacktracesToFile.name() +
217+
" to turn on internal errors logging. Please attach the log file to the issue if possible.";
217218
}
218219
if (!FastROptions.PrintErrorStacktraces.getBooleanValue() && !FastROptions.PrintErrorStacktracesToFile.getBooleanValue()) {
219220
System.err.println(message);

com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RRuntimeASTAccess.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,6 @@ default String getCallerSource(RCaller caller) {
159159

160160
String encodeComplex(RComplex x, int digits);
161161

162-
void checkDebugRequest(RFunction func);
163-
164162
RAbstractStringVector getClassHierarchy(RAttributable value);
165163

166164
RContext getCurrentContext();

com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RSerialize.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2620,8 +2620,6 @@ public static RFunction processFunction(Object car, Object cdr, REnvironment env
26202620
FrameSlotChangeMonitor.initializeEnclosingFrame(callTarget.getRootNode().getFrameDescriptor(), enclosingFrame);
26212621
RFunction func = RDataFactory.createFunction(functionName, packageName, callTarget, null, enclosingFrame);
26222622

2623-
RContext.getRRuntimeASTAccess().checkDebugRequest(func);
2624-
26252623
/*
26262624
* TODO: this is missing the code that registers sources with RPackageSource!
26272625
*/

0 commit comments

Comments
 (0)