Skip to content

Commit 6b3d158

Browse files
committed
Merge commit 'ee11fce71b248d77ac4d6d6af75a2a5b33c20035' into release/graal-vm/1.0
2 parents 3a3e6cf + ee11fce commit 6b3d158

File tree

194 files changed

+7180
-2194
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

194 files changed

+7180
-2194
lines changed

CHANGELOG.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,42 @@
1+
# 1.0 RC 10
2+
3+
New features:
4+
5+
* interop and tooling: READ and WRITE of ActiveBinding may have side effects. This is communicated via `KEY_INFO` to the tools and other languages (e.g., a debugger may warn before evaluating an ActiveBinding)
6+
* the MRAN mirror used by FastR as default repo was moved to https://mran.microsoft.com/snapshot/2018-06-20
7+
* new function `install.fastr.packages` to install FastR rJava replacement and possibly other packages in the future
8+
* print the whole guest language stacktrace if an exception occurs during an interop call into another language
9+
10+
Added missing R builtins and C API
11+
12+
* `pos.to.env` builtin
13+
* private `do_fmin` external function from the stats packages used by public R function `optimize`
14+
* `beta` #33
15+
16+
Bug fixes:
17+
18+
* tooling: top level statements are not marked as functions (e.g., a debugger will not treat them as such anymore)
19+
* update rpath correctly for redistributed libraries when producing a release build. This issue caused linking problems for MacOS users #26
20+
* UseMethod caused internal error under some specific circumstances (happens during installation of the R.oo package)
21+
* fully support indirect use of .Internal, e.g. in `(get('.Internal'))(paste0(list(1,2),','))`
22+
* `as.character(external-pointer)` does not crash, but prints the pointer address #28
23+
* `file.path` with `NULL` as one of its arguments gives correct result (empty character vector)
24+
* `format.POSIXlt` uses the same time zone database as rest of the system #29
25+
* `dev.control(displaylist = 'inhibit')` caused `ClassCastException`
26+
* `download.file` follows redirects.
27+
* static members of Java interop objects are not ignored during printing and deparsing
28+
* fixed internal error in `on.exit(NULL)`
29+
* fixed `mget` to accept also non list values for `ifnotfound`
30+
* updating dimensions of a vector always resets the dimnames. #34
31+
* `env2list` used in, e.g., `as.list.environment` can handle `...` inside the environment
32+
133
# 1.0 RC 9
234

335
New features
436

537
* various improvements in handling of foreign objects in R
38+
* [brief overview in the documentation](http://www.graalvm.org/docs/reference-manual/languages/r/#foreign)
39+
* [executable specification](https://github.com/oracle/fastr/blob/master/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/library/fastr/R/interop-array-conversion-test.R#L158)
640

741
Added missing R builtins and C API
842

README.md

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,21 @@
1-
A high performance implementation of the R programming language., built on the GraalVM by Oracle Labs.
1+
[![Join the chat at https://gitter.im/graalvm/graal-core](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/graalvm/graal-core?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
2+
3+
A high-performance implementation of the R programming language, built on GraalVM.
24

35
FastR aims to be:
4-
* [efficient](https://medium.com/graalvm/faster-r-with-fastr-4b8db0e0dceb#4ab6): executing R language scripts faster than any other R runtime.
6+
* [efficient](https://medium.com/graalvm/faster-r-with-fastr-4b8db0e0dceb#4ab6): executing R language scripts faster than any other R runtime
57
* [polyglot](https://medium.com/graalvm/faster-r-with-fastr-4b8db0e0dceb#0f5c): allowing [polyglot interoperability](https://www.graalvm.org/docs/reference-manual/polyglot/) with other languages in the GraalVM ecosystem.
6-
* [compatible](https://medium.com/graalvm/faster-r-with-fastr-4b8db0e0dceb#fff5): providing support for existing packages and the R native interface.
7-
* [embeddable](https://github.com/graalvm/examples/tree/master/r_java_embedding): allowing integration using the R embedding API or the GraalVM polyglot embedding SDK.
8+
* [compatible](https://medium.com/graalvm/faster-r-with-fastr-4b8db0e0dceb#fff5): providing support for existing packages and the R native interface
9+
* [embeddable](https://github.com/graalvm/examples/tree/master/r_java_embedding): allowing integration using the R embedding API or the GraalVM polyglot embedding SDK
10+
11+
12+
The screenshot below shows Java application with embedded FastR engine.
13+
The plot below was generated by `ggplot2` running on FastR and it shows
14+
peak performance of the [raytracing example](http://www.tylermw.com/throwing-shade/).
15+
The measurements were [reproduced independently](https://nextjournal.com/sdanisch/fastr-benchmark).
16+
17+
![Java embedding](documentation/assets/javaui.png)
18+
![Speedup](documentation/assets/speedup.png)
819

920
## Getting Started
1021
See the documentation on the GraalVM website on how to [get GraalVM](https://www.graalvm.org/docs/getting-started/) and [install and use FastR](http://www.graalvm.org/docs/reference-manual/languages/r/).

ci_common/common.hocon

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,14 @@ logfiles : [
3636
"com.oracle.truffle.r.test.native/embedded/src/*.output"
3737
# Uncomment to debug pkgtest issues, produces lot of logs!
3838
"test.fastr/**/*.Rout"
39+
"test.fastr/**/*.fail"
3940
"test.fastr/**/*-tests/*.Rout"
4041
"test.gnur/**/*.Rout"
4142
"test.gnur/**/*-tests/*.Rout"
43+
"test.gnur/**/*.fail"
44+
# Uncomment to debug the event loop hanging issue. It must be accompanied by enabling
45+
# the logging by setting the TRACE_EVENT_LOOP env var to true.
46+
# "traceEventLoop.log"
4247
]
4348

4449
# This is needed by all (Linux) builds but is specific to the module system employed
@@ -223,7 +228,7 @@ rbcheck : ${common} {
223228
internalPkgtest: ${common} {
224229
run : [
225230
["mx", "build"]
226-
["mx", "pkgtest", "--repos", "FASTR", "--pkg-filelist", "com.oracle.truffle.r.test.native/packages/pkg-filelist"]
231+
["mx", "pkgtest", "--verbose", "--repos", "FASTR", "--pkg-filelist", "com.oracle.truffle.r.test.native/packages/pkg-filelist"]
227232
]
228233
logs: ${common.logs}
229234
}

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
import com.oracle.truffle.api.CompilerDirectives;
2828
import com.oracle.truffle.api.Truffle;
29+
import com.oracle.truffle.api.TruffleException;
2930
import com.oracle.truffle.api.TruffleLanguage.ContextReference;
3031
import com.oracle.truffle.api.frame.MaterializedFrame;
3132
import com.oracle.truffle.api.frame.VirtualFrame;
@@ -91,6 +92,9 @@ public Object execute(VirtualFrame frame) {
9192
throw e;
9293
} catch (Throwable t) {
9394
CompilerDirectives.transferToInterpreter();
95+
if (t instanceof TruffleException && !((TruffleException) t).isInternalError()) {
96+
throw t;
97+
}
9498
// other errors didn't produce an output yet
9599
RInternalError.reportError(t);
96100
throw t;

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ private EngineRootNode createRScriptRoot(Source fullSource, MaterializedFrame fr
415415

416416
@Override
417417
@TruffleBoundary
418-
public Object eval(RExpression exprs, REnvironment envir, RCaller caller) {
418+
public Object eval(RExpression exprs, REnvironment envir, Object callerFrame, RCaller caller, RFunction function) {
419419
Object result = RNull.instance;
420420
for (int i = 0; i < exprs.getLength(); i++) {
421421
Object obj = exprs.getDataAt(i);
@@ -427,7 +427,7 @@ public Object eval(RExpression exprs, REnvironment envir, RCaller caller) {
427427
throw RError.error(RError.SHOW_CALLER, RError.Message.ARGUMENT_MISSING, identifier);
428428
}
429429
} else if ((obj instanceof RPairList && ((RPairList) obj).isLanguage())) {
430-
result = eval((RPairList) obj, envir, caller);
430+
result = eval((RPairList) obj, envir, callerFrame, caller, function);
431431
} else {
432432
result = obj;
433433
}
@@ -437,9 +437,9 @@ public Object eval(RExpression exprs, REnvironment envir, RCaller caller) {
437437

438438
@Override
439439
@TruffleBoundary
440-
public Object eval(RPairList expr, REnvironment envir, RCaller caller) {
440+
public Object eval(RPairList expr, REnvironment envir, Object callerFrame, RCaller caller, RFunction function) {
441441
assert expr.isLanguage();
442-
return expr.getClosure().eval(envir, caller);
442+
return expr.getClosure().eval(envir, callerFrame, caller, function);
443443
}
444444

445445
@Override

com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/REnvironmentMR.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -259,11 +259,16 @@ abstract static class REnvironmentKeyInfoImplNode extends Node {
259259

260260
@Specialization
261261
protected int access(REnvironment receiver, String identifier) {
262-
Object val = receiver.get(identifier);
263-
if (val == null) {
264-
return 0;
265-
}
262+
Object val = null;
266263
int result = KeyInfo.READABLE;
264+
if (receiver.isActiveBinding(identifier)) {
265+
result |= KeyInfo.READ_SIDE_EFFECTS | KeyInfo.WRITE_SIDE_EFFECTS;
266+
} else {
267+
val = receiver.get(identifier);
268+
if (val == null) {
269+
return 0;
270+
}
271+
}
267272
if (!receiver.isLocked() && !receiver.bindingIsLocked(identifier)) {
268273
result |= KeyInfo.MODIFIABLE;
269274
}

com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/shell/REmbedded.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ private static void runRmainloop() {
133133
RContext ctx = RContext.getInstance();
134134
ctx.completeEmbeddedInitialization();
135135
ctx.getRFFI().initializeEmbedded(ctx);
136-
int status = REPL.readEvalPrint(context, consoleHandler, false);
136+
int status = REPL.readEvalPrint(context, consoleHandler, false, System.err);
137137
context.leave();
138138
context.close();
139139
Utils.systemExit(status);

com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/common/JavaUpCallsRFFIImpl.java

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -75,25 +75,29 @@
7575
import com.oracle.truffle.r.runtime.data.RComplexVector;
7676
import com.oracle.truffle.r.runtime.data.RDataFactory;
7777
import com.oracle.truffle.r.runtime.data.RDoubleVector;
78+
import com.oracle.truffle.r.runtime.data.REmpty;
7879
import com.oracle.truffle.r.runtime.data.RExpression;
7980
import com.oracle.truffle.r.runtime.data.RExternalPtr;
8081
import com.oracle.truffle.r.runtime.data.RFunction;
8182
import com.oracle.truffle.r.runtime.data.RIntVector;
82-
import com.oracle.truffle.r.runtime.data.RPairList;
8383
import com.oracle.truffle.r.runtime.data.RList;
8484
import com.oracle.truffle.r.runtime.data.RLogicalVector;
85+
import com.oracle.truffle.r.runtime.data.RMissing;
8586
import com.oracle.truffle.r.runtime.data.RNull;
8687
import com.oracle.truffle.r.runtime.data.RObject;
88+
import com.oracle.truffle.r.runtime.data.RPairList;
8789
import com.oracle.truffle.r.runtime.data.RPromise;
88-
import com.oracle.truffle.r.runtime.data.RRaw;
8990
import com.oracle.truffle.r.runtime.data.RPromise.EagerPromise;
91+
import com.oracle.truffle.r.runtime.data.RRaw;
9092
import com.oracle.truffle.r.runtime.data.RRawVector;
9193
import com.oracle.truffle.r.runtime.data.RShareable;
9294
import com.oracle.truffle.r.runtime.data.RStringVector;
9395
import com.oracle.truffle.r.runtime.data.RSymbol;
9496
import com.oracle.truffle.r.runtime.data.RTypedValue;
9597
import com.oracle.truffle.r.runtime.data.RUnboundValue;
9698
import com.oracle.truffle.r.runtime.data.RVector;
99+
import com.oracle.truffle.r.runtime.data.model.RAbstractAtomicVector;
100+
import com.oracle.truffle.r.runtime.data.model.RAbstractListBaseVector;
97101
import com.oracle.truffle.r.runtime.data.model.RAbstractListVector;
98102
import com.oracle.truffle.r.runtime.data.model.RAbstractStringVector;
99103
import com.oracle.truffle.r.runtime.data.model.RAbstractVector;
@@ -224,7 +228,11 @@ public void Rf_defineVar(Object symbolArg, Object value, Object envArg) {
224228
REnvironment env = (REnvironment) envArg;
225229
RSymbol name = (RSymbol) symbolArg;
226230
try {
227-
env.put(name.getName(), value);
231+
if (value == RUnboundValue.instance) {
232+
env.rm(name.getName());
233+
} else {
234+
env.put(name.getName(), value);
235+
}
228236
} catch (PutException ex) {
229237
throw RError.error(RError.SHOW_CALLER2, ex);
230238
}
@@ -283,7 +291,11 @@ private static Object findVarInFrameHelper(Object envArg, Object symbolArg, bool
283291
return ((RPromise) value).getRawValue();
284292
}
285293
if (value instanceof RArgsValuesAndNames) {
286-
return ((RArgsValuesAndNames) value).toPairlist();
294+
RArgsValuesAndNames argsValsNames = (RArgsValuesAndNames) value;
295+
return argsValsNames.isEmpty() ? RSymbol.MISSING : argsValsNames.toPairlist();
296+
}
297+
if (value == RMissing.instance || value == REmpty.instance) {
298+
return RSymbol.MISSING;
287299
}
288300
return value;
289301
}
@@ -460,6 +472,8 @@ public Object Rf_allocVector(int mode, long n) {
460472
case LISTSXP:
461473
case LANGSXP:
462474
return RDataFactory.createPairList(ni, type);
475+
case NILSXP:
476+
return RNull.instance;
463477
default:
464478
throw unimplemented("unexpected SEXPTYPE " + type);
465479
}
@@ -727,7 +741,7 @@ public Object PRINTNAME(Object x) {
727741
return x;
728742
}
729743
guaranteeInstanceOf(x, RSymbol.class);
730-
return CharSXPWrapper.create(((RSymbol) x).getName());
744+
return ((RSymbol) x).getWrappedName();
731745
}
732746

733747
@Override
@@ -1619,8 +1633,7 @@ public int registerRoutines(Object dllInfoObj, int nstOrd, int num, Object routi
16191633
@Override
16201634
@TruffleBoundary
16211635
public int registerCCallable(String pkgName, String functionName, Object address) {
1622-
DLLInfo lib = DLL.safeFindLibrary(pkgName);
1623-
lib.registerCEntry(new CEntry(functionName, new SymbolHandle(address)));
1636+
DLLInfo.registerCEntry(pkgName, new CEntry(functionName, new SymbolHandle(address)));
16241637
return 0;
16251638
}
16261639

@@ -2399,8 +2412,12 @@ public Object LOGICAL(Object x) {
23992412
}
24002413

24012414
@Override
2415+
@TruffleBoundary
24022416
public Object REAL(Object x) {
2403-
return VectorRFFIWrapper.get(guaranteeVectorOrNull(x, RDoubleVector.class));
2417+
if ((x instanceof RAbstractStringVector) || (x instanceof RAbstractListBaseVector)) {
2418+
RFFIUtils.unimplemented("REAL is being called for type " + Utils.getTypeName(x));
2419+
}
2420+
return VectorRFFIWrapper.get(guaranteeVectorOrNull(x, RAbstractAtomicVector.class));
24042421
}
24052422

24062423
@Override
@@ -2433,6 +2450,11 @@ public Object R_forceAndCall(Object e, Object f, int n, Object args) {
24332450
throw implementedAsNode();
24342451
}
24352452

2453+
@Override
2454+
public void R_MakeActiveBinding(Object symArg, Object funArg, Object envArg) {
2455+
throw implementedAsNode();
2456+
}
2457+
24362458
private static TruffleObject guaranteeVectorOrNull(Object obj, Class<? extends TruffleObject> clazz) {
24372459
if (obj == RNull.instance) {
24382460
return RNull.instance;

com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/common/RFFIUtils.java

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,10 @@
3232
import com.oracle.truffle.api.interop.UnsupportedMessageException;
3333
import com.oracle.truffle.api.nodes.Node;
3434
import com.oracle.truffle.r.runtime.RInternalError;
35+
import com.oracle.truffle.r.runtime.Utils;
3536
import com.oracle.truffle.r.runtime.context.RContext;
3637
import com.oracle.truffle.r.runtime.data.RObject;
3738
import com.oracle.truffle.r.runtime.data.RPairList;
38-
import com.oracle.truffle.r.runtime.data.RSymbol;
39-
import com.oracle.truffle.r.runtime.data.model.RAbstractVector;
4039
import com.oracle.truffle.r.runtime.ffi.RFFIContext;
4140
import com.oracle.truffle.r.runtime.ffi.RFFILog;
4241

@@ -121,32 +120,20 @@ private static void printArgs(CallMode mode, StringBuilder sb, Object[] args) {
121120
sb.append("null");
122121
continue;
123122
}
124-
sb.append(arg.getClass().getSimpleName()).append('(').append(arg.hashCode());
123+
sb.append(arg.getClass().getSimpleName()).append('(').append(arg.hashCode()).append(';');
125124
if (arg instanceof TruffleObject && ForeignAccess.sendIsPointer(getIsPointerNode(), (TruffleObject) arg)) {
126125
try {
127-
sb.append(";ptr:").append(String.valueOf(ForeignAccess.sendAsPointer(getAsPointerNode(), (TruffleObject) arg)));
126+
sb.append("ptr:").append(Long.toHexString(ForeignAccess.sendAsPointer(getAsPointerNode(), (TruffleObject) arg)));
128127
} catch (UnsupportedMessageException e) {
129128
throw RInternalError.shouldNotReachHere();
130129
}
131-
} else if (arg instanceof RSymbol) {
132-
sb.append(';').append("\"" + arg.toString() + "\"");
133-
} else if (arg instanceof RAbstractVector) {
134-
RAbstractVector vec = (RAbstractVector) arg;
135-
if (vec.getLength() == 0) {
136-
sb.append(";empty");
137-
} else {
138-
sb.append(";len:" + vec.getLength() + ";data:");
139-
for (int i = 0; i < Math.min(3, vec.getLength()); i++) {
140-
String str = ((RAbstractVector) arg).getDataAtAsObject(0).toString();
141-
str = str.length() > 30 ? str.substring(0, 27) + "..." : str;
142-
sb.append(',').append(str);
143-
}
144-
}
130+
} else {
131+
Utils.printDebugInfo(sb, arg);
145132
}
146133
// Note: it makes sense to include native mirrors only once they have been create
147134
// already
148135
if (mode.logNativeMirror && arg instanceof RObject) {
149-
sb.append(";" + ((RObject) arg).getNativeMirror());
136+
sb.append(((RObject) arg).getNativeMirror());
150137
}
151138
sb.append(')');
152139
}

com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/llvm/TruffleLLVM_DLL.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444

4545
import com.oracle.truffle.api.CallTarget;
4646
import com.oracle.truffle.api.CompilerDirectives;
47+
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
4748
import com.oracle.truffle.api.interop.ForeignAccess;
4849
import com.oracle.truffle.api.interop.Message;
4950
import com.oracle.truffle.api.interop.TruffleObject;
@@ -180,6 +181,7 @@ private LLVMArchive(LLVM_IR[] irs, List<String> nativeLibs) {
180181
}
181182
}
182183

184+
@TruffleBoundary
183185
public static LLVMArchive getZipLLVMIR(String path) {
184186
List<String> nativeLibs = Collections.emptyList();
185187
try (ZipInputStream zis = new ZipInputStream(new BufferedInputStream(new FileInputStream(path + "l")))) {
@@ -248,6 +250,7 @@ private static class TruffleLLVM_DLOpenNode extends Node implements DLOpenNode {
248250
* the IR has not been parsed yet.
249251
*/
250252
@Override
253+
@TruffleBoundary
251254
public Object execute(String path, boolean local, boolean now) {
252255
try {
253256
LLVMArchive ar = getZipLLVMIR(path);
@@ -365,6 +368,7 @@ private static String getLibName(String path) {
365368
*/
366369
private LLVM_IR[] libRModules;
367370

371+
@TruffleBoundary
368372
private static CallTarget parseLLVM(String libName, LLVM_IR ir) {
369373
if (ir instanceof LLVM_IR.Binary) {
370374
LLVM_IR.Binary bir = (LLVM_IR.Binary) ir;

0 commit comments

Comments
 (0)