Skip to content

Commit

Permalink
Merge commit 'c01c32f85d9' into release/graal-vm/1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ansalond committed Jan 7, 2019
2 parents 6b3d158 + c01c32f commit 1d674b1
Show file tree
Hide file tree
Showing 527 changed files with 318,638 additions and 4,374 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@
.metadata/
.gdb_history
*.swo
*.csv
*.iml
*.swp
*.class
Expand Down Expand Up @@ -103,7 +102,7 @@ scratch/
bin/
share/
etc/
doc/
/doc/
src_gen/
/local/
/.hgtip
Expand Down
1,688 changes: 1,620 additions & 68 deletions 3rd_party_licenses.txt

Large diffs are not rendered by default.

32 changes: 32 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,35 @@
# 1.0 RC 11

* upgraded the R version to R-3.5.1
* base packages and other sources used directly from GNU-R upgraded to their R-3.5.1 versions
* fixed differences between R-3.4.0 and R-3.5.1

* FastR does not print or log any details for internal errors unless it is run with `--jvm.DR:+PrintErrorStacktracesToFile`

Added missing R builtins and C API

* `Rf_duplicated`
* `Rf_setVar`
* `norm_rand`
* `exp_rand`

Bug fixes:

* internal error in `mapply` with empty arguments list
* `comment` and `comment<-` work with S4 objects
* `iconvlist()` was failing on argument error #43
* `range` works properly with lists
* the reference count of `dimnames` of the result of `==` was not handled properly leading to incorrect results #40
* `exists` did not work properly in all cases when used with the `mode` argument #44
* 'charIndex out of range' when parsing an incomplete source #39
* `no_proxy` environment variable was not parsed correctly
* `read.csv` treats empty value as `NA` of the same type as the rest of the values in the column #42
* `SET_NAMED` allows to decrease the reference count to support a pattern from `data.table`
* exception when writing into the result returned from `split`
* `switch` falls through only if the actual argument is empty constant: `switch('x',x=,y=42)` vs. `switch('x',x=quote(f(1,))[[3]],y=42)`
* `oldClass<-` works with external pointers and other less common R types
* C API function `Rf_setAttrib` coerces double vector to integer when setting "dim" attribute #46

# 1.0 RC 10

New features:
Expand Down
5 changes: 4 additions & 1 deletion ci_common/common.hocon
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# java 7 is needed by Truffle (for now)
java7 : {name : oraclejdk, version : "7", platformspecific: true}
# java 8 must be a jvmci enabled variant
java8 : {name : labsjdk, version : "8u172-jvmci-0.47", platformspecific: true}
java8 : {name : labsjdk, version : "8u192-jvmci-0.52", platformspecific: true}
java9 : {name : oraclejdk, version : "9.0.4+11", platformspecific: true}

java8Downloads : {
Expand Down Expand Up @@ -64,6 +64,7 @@ packagesLinux : ${pkgEnvironment} {
mercurial : ">=2.2"
"pip:astroid" : "==1.1.0"
"pip:pylint" : "==1.1.0"
"pip:ninja_syntax" : "==1.7.2"
make : ">=3.83"
gcc-build-essentials : "==4.9.1" # GCC 4.9.0 fails on cluster
readline : "==6.3"
Expand All @@ -76,6 +77,7 @@ packagesLinux : ${pkgEnvironment} {
packagesDarwin : {
"pip:astroid" : "==1.1.0"
"pip:pylint" : "==1.1.0"
"pip:ninja_syntax" : "==1.7.2"
"pcre" : "==8.38"
}

Expand All @@ -88,6 +90,7 @@ common : ${java8Downloads} ${packagesLinux} {
environment : {
PKG_TEST_ENV_miniUI : "LC_ALL=C"
PKG_TEST_ENV_compare : "LC_ALL=C"
FASTR_OPTION_PrintErrorStacktracesToFile: "true"
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,6 @@
*/
package com.oracle.truffle.r.engine;

import java.io.BufferedReader;
import java.io.IOException;
import java.net.URI;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

import com.oracle.truffle.api.CallTarget;
import com.oracle.truffle.api.CompilerAsserts;
import com.oracle.truffle.api.CompilerDirectives;
Expand Down Expand Up @@ -63,6 +55,7 @@
import com.oracle.truffle.r.nodes.function.RCallerHelper;
import com.oracle.truffle.r.nodes.function.call.CallRFunctionNode;
import com.oracle.truffle.r.nodes.function.opt.ShareObjectNode;
import com.oracle.truffle.r.nodes.function.opt.UnShareObjectNode;
import com.oracle.truffle.r.nodes.function.visibility.GetVisibilityNode;
import com.oracle.truffle.r.nodes.function.visibility.SetVisibilityNode;
import com.oracle.truffle.r.nodes.instrumentation.RInstrumentation;
Expand All @@ -80,8 +73,8 @@
import com.oracle.truffle.r.runtime.RRuntime;
import com.oracle.truffle.r.runtime.RSource;
import com.oracle.truffle.r.runtime.ReturnException;
import com.oracle.truffle.r.runtime.RootWithBody;
import com.oracle.truffle.r.runtime.RootBodyNode;
import com.oracle.truffle.r.runtime.RootWithBody;
import com.oracle.truffle.r.runtime.ThreadTimings;
import com.oracle.truffle.r.runtime.Utils;
import com.oracle.truffle.r.runtime.Utils.DebugExitException;
Expand All @@ -103,6 +96,14 @@
import com.oracle.truffle.r.runtime.nodes.RNode;
import com.oracle.truffle.r.runtime.nodes.RSyntaxNode;

import java.io.BufferedReader;
import java.io.IOException;
import java.net.URI;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
* The engine for the FastR implementation. Handles parsing and evaluation. There is one instance of
* this class per {@link RContext}.
Expand Down Expand Up @@ -171,7 +172,7 @@ private void initializeNonShared() {
} catch (ParseException e) {
throw new RInternalError(e, "error while parsing system profile from %s", RProfile.systemProfile().getName());
}
checkAndRunStartupShutdownFunction(".OptRequireMethods");
checkAndRunStartupShutdownFunction(".OptRequireMethods", ".OptRequireMethods()");

suppressWarnings = false;
Source siteProfile = context.stateRProfile.siteProfile();
Expand All @@ -192,37 +193,25 @@ private void initializeNonShared() {
}
if (context.getStartParams().restore()) {
// call sys.load.image(".RData", RCmdOption.QUIET
checkAndRunStartupShutdownFunction("sys.load.image", new String[]{"\".RData\"", context.getStartParams().isQuiet() ? "TRUE" : "FALSE"});
checkAndRunStartupShutdownFunction("sys.load.image", "sys.load.image('.RData'," + (context.getStartParams().isQuiet() ? "TRUE" : "FALSE") + ')');
}
checkAndRunStartupShutdownFunction(".First");
checkAndRunStartupShutdownFunction(".First.sys");
checkAndRunStartupShutdownFunction(".First", ".First()");
checkAndRunStartupShutdownFunction(".First.sys", ".First.sys()");

StartupTiming.timestamp("After Profiles Loaded");
}
}

@Override
public void checkAndRunStartupShutdownFunction(String name, String... args) {
public void checkAndRunStartupShutdownFunction(String name, String code) {
// sanity check: code should be invocation of the function, so it should contain
// "{name}(some-args)"
assert code.contains("(") && code.contains(name);
Object func = REnvironment.globalEnv().findFunction(name);
if (func != null) {
String call = name;
if (args.length == 0) {
call += "()";
} else {
call += "(";
if (args.length > 0) {
for (int i = 0; i < args.length; i++) {
call += args[i];
if (i != args.length - 1) {
call += ", ";
}
}
}
call += ")";
}
// Should this print the result?
try {
parseAndEval(RSource.fromTextInternal(call, RSource.Internal.STARTUP_SHUTDOWN), globalFrame, false);
parseAndEval(RSource.fromTextInternal(code, RSource.Internal.STARTUP_SHUTDOWN), globalFrame, false);
} catch (ParseException e) {
throw new RInternalError(e, "error while parsing startup function");
}
Expand Down Expand Up @@ -292,7 +281,10 @@ private List<RSyntaxNode> parseSource(Source source) throws ParseException {
@Override
public RExpression parse(Source source) throws ParseException {
List<RSyntaxNode> list = parseSource(source);
Object[] data = list.stream().map(node -> RASTUtils.createLanguageElement(node)).toArray();
Object[] data = new Object[list.size()];
for (int i = 0; i < data.length; i++) {
data[i] = RASTUtils.createLanguageElement(list.get(i));
}
return RDataFactory.createExpression(data);
}

Expand Down Expand Up @@ -377,15 +369,18 @@ private EngineRootNode createRScriptRoot(Source fullSource, MaterializedFrame fr
int lineIndex = 1;
int startLine = lineIndex;
StringBuilder sb = new StringBuilder();
String nextLineInput = br.readLine();
ParseException lastParseException = null;
while (true) {
String input = br.readLine();
String input = nextLineInput;
if (input == null) {
if (sb.length() != 0) {
// end of file, but not end of statement => error
statements.add(new SyntaxErrorNode(null, fullSource.createSection(startLine, 1, sb.length())));
statements.add(new SyntaxErrorNode(lastParseException, fullSource.createSection(startLine, 1, sb.length())));
}
break;
}
nextLineInput = br.readLine();
sb.append(input);
Source src = Source.newBuilder(RRuntime.R_LANGUAGE_ID, sb.toString(), file + "#" + startLine + "-" + lineIndex).uri(uri).build();
lineIndex++;
Expand All @@ -394,7 +389,10 @@ private EngineRootNode createRScriptRoot(Source fullSource, MaterializedFrame fr
RParserFactory.Parser<RSyntaxNode> parser = RParserFactory.getParser();
currentStmts = parser.statements(src, fullSource, startLine, new RASTBuilder(), context.getLanguage());
} catch (IncompleteSourceException e) {
sb.append('\n');
lastParseException = e;
if (nextLineInput != null) {
sb.append('\n');
}
continue;
} catch (ParseException e) {
statements.add(new SyntaxErrorNode(e, fullSource.createSection(startLine, 1, sb.length())));
Expand Down Expand Up @@ -647,8 +645,8 @@ public RNode getBody() {

@TruffleBoundary
private static boolean checkResult(Object result) {
if (FastROptions.CheckResultCompleteness.getBooleanValue() && result instanceof RAbstractVector) {
assert RAbstractVector.verify((RAbstractVector) result);
if (result instanceof RAbstractVector) {
return RAbstractVector.verify((RAbstractVector) result);
}
return true;
}
Expand Down Expand Up @@ -678,7 +676,7 @@ private static void printValue(RContext ctx, MaterializedFrame callingFrame, Obj
RFunction function = (RFunction) evaluatePromise(printMethod);
CallRFunctionNode.executeSlowpath(function, RCaller.createInvalid(callingFrame), callingFrame, new Object[]{resultValue, RArgsValuesAndNames.EMPTY}, null);
}
ShareObjectNode.unshare(resultValue);
UnShareObjectNode.unshare(resultValue);
} else {
// this supports printing of non-R values (via toString for now)
String str;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
package com.oracle.truffle.r.engine;

import java.io.ByteArrayOutputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
Expand Down Expand Up @@ -55,7 +54,6 @@
import com.oracle.truffle.r.nodes.function.ClassHierarchyNode;
import com.oracle.truffle.r.nodes.function.FunctionDefinitionNode;
import com.oracle.truffle.r.nodes.function.RCallNode;
import com.oracle.truffle.r.nodes.instrumentation.RInstrumentation;
import com.oracle.truffle.r.nodes.instrumentation.RSyntaxTags.FunctionBodyBlockTag;
import com.oracle.truffle.r.nodes.instrumentation.RSyntaxTags.LoopTag;
import com.oracle.truffle.r.runtime.ArgumentsSignature;
Expand Down Expand Up @@ -354,20 +352,20 @@ public boolean disableDebug(RFunction func) {
}

@Override
public Object rcommandMain(String[] args, String[] env, boolean intern) {
public Object rcommandMain(String[] args, String[] env, boolean intern, int timeoutSecs) {
IORedirect redirect = handleIORedirect(args, intern);
assert env == null : "re-enable env arguments";
int result = RMain.runR(redirect.args, redirect.in, redirect.out, redirect.err);
int result = RMain.runR(redirect.args, redirect.in, redirect.out, redirect.err, timeoutSecs);
return redirect.getInternResult(result);
}

@Override
public Object rscriptMain(String[] args, String[] env, boolean intern) {
public Object rscriptMain(String[] args, String[] env, boolean intern, int timeoutSecs) {
IORedirect redirect = handleIORedirect(args, intern);
// TODO argument parsing can fail with ExitException, which needs to be handled correctly in
// nested context
assert env == null : "re-enable env arguments";
int result = RMain.runRscript(redirect.args, redirect.in, redirect.out, redirect.err);
int result = RMain.runRscript(redirect.args, redirect.in, redirect.out, redirect.err, timeoutSecs);
return redirect.getInternResult(result);
}

Expand Down Expand Up @@ -433,7 +431,7 @@ private static IORedirect handleIORedirect(String[] args, boolean intern) {
throw RError.error(RError.NO_CALLER, RError.Message.GENERIC, "redirect missing");
}
try {
in = new FileInputStream(file);
in = RContext.getInstance().getEnv().getTruffleFile(file).newInputStream();
} catch (IOException ex) {
throw RError.error(RError.NO_CALLER, RError.Message.NO_SUCH_FILE, file);
}
Expand Down Expand Up @@ -490,11 +488,6 @@ public String encodeComplex(RComplex x, int digits) {
return ComplexVectorPrinter.encodeComplex(x, digits);
}

@Override
public void checkDebugRequest(RFunction func) {
RInstrumentation.checkDebugRequested(func);
}

@Override
public Class<? extends TruffleRLanguage> getTruffleRLanguage() {
return TruffleRLanguageImpl.class;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,12 @@ protected Object write(TruffleObject receiver, int idx, Object valueObj) {
return write(receiver, new Object[]{idx + 1}, valueObj);
}

@Specialization
protected Object write(TruffleObject receiver, long idx, Object valueObj) {
// idx + 1 R is indexing from 1
return write(receiver, new Object[]{idx + 1}, valueObj);
}

@Specialization
protected Object write(TruffleObject receiver, String field, Object valueObj) {
return write(receiver, new Object[]{field}, valueObj);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand All @@ -23,6 +23,7 @@
package com.oracle.truffle.r.engine.interop;

import java.util.List;
import java.util.function.Supplier;

import com.oracle.truffle.api.CallTarget;
import com.oracle.truffle.api.CompilerDirectives;
Expand Down Expand Up @@ -472,7 +473,16 @@ public Object execute(VirtualFrame frame) {
});
}

static class Check extends RootNode {
public static final Supplier<RootNode> CHECK_FACTORY = new CheckFactory();

private static final class CheckFactory implements Supplier<RootNode> {
@Override
public RootNode get() {
return new Check();
}
}

private static final class Check extends RootNode {

Check() {
super(null);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -122,7 +122,7 @@ public ForeignAccess getForeignAccess(RTruffleObject obj) {
} else if (obj instanceof RInteropNA) {
return RInteropNAMRForeign.ACCESS;
} else if (obj instanceof RAbstractAtomicVector) {
return ForeignAccess.create(new RAbstractVectorAccessFactory(), new RAbstractVectorAccessFactory.Check());
return ForeignAccess.createAccess(new RAbstractVectorAccessFactory(), RAbstractVectorAccessFactory.CHECK_FACTORY);
} else {
ForeignAccess access = FFI_RForeignAccessFactoryImpl.getForeignAccess(obj);
if (access != null) {
Expand Down
Loading

0 comments on commit 1d674b1

Please sign in to comment.