Skip to content

Commit b729250

Browse files
committed
Merge commit '0fbf411bdf2c910807997494636320288df73746' into release/graal-vm/1.0
2 parents d6ce128 + 0fbf411 commit b729250

File tree

66 files changed

+1731
-830
lines changed

Some content is hidden

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

66 files changed

+1731
-830
lines changed

CHANGELOG.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,24 @@
11
# 1.0 RC 7
22

3+
API changes
4+
5+
* eval.polyglot: the parameter `source` was renamed to `code`
6+
37
New features
48

59
* AWT based graphics devices (jpg, png, X11, ...) supported in native image
10+
* Seamless way to create R data frames from Polyglot objects
11+
* Handled by as.data.frame.polyglot.value
12+
* Expected structure: KEYS are used as column names, the values must be homogenous arrays (e.g. respond to HAS_SIZE)
613

7-
Added missing R builtins and C API
14+
Bug fixes
15+
16+
* S3 dispatch works correctly with NULL
17+
* Paths in eval.polyglot are resolved relative to the current working directory
18+
* Connections: sockets can always be read and written, raw connections are always binary
19+
* Promises are evaluated in LazyLoadDBFetch (to support delayedAssign)
20+
* Fixed broken `Rscript --version`
21+
* Various fixes necessary to pass dplyr tests (GitHub version of dplyr)
822

923
Bugfixes
1024

README.md

Lines changed: 36 additions & 132 deletions
Original file line numberDiff line numberDiff line change
@@ -1,155 +1,59 @@
1-
# FastR
1+
A high performance implementation of the R programming language., built on the GraalVM by Oracle Labs.
22

3-
FastR is an implementation of the [R Language](http://www.r-project.org/) in Java atop [Truffle](https://github.com/graalvm/), a framework for building self-optimizing AST interpreters.
3+
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.
5+
* [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.
48

5-
FastR is:
9+
## Getting Started
10+
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/).
611

7-
* polyglot
8-
9-
..R is very powerful and flexible, but certain tasks are best solved by using R in combination with other programming languages.
10-
..Interfaces to languages, e.g., Java, Fortran and C/C++, incur a significant overhead, which is caused, to a large degree, by the different execution strategies employed by different languages, e.g., compiled vs. interpreted, and by incompatible internal data representations.
11-
12-
..The Truffle framework addresses these issues at a very fundamental level, and builds the necessary polyglot primitives directly into the runtime.
13-
..Consequently, FastR leverages this infrastructure to allow multiple languages to interact transparently and seamlessly.
14-
..All parts of a polyglot application can be compiled by the same optimizing compiler, and can be executed and debugged simultaneously, with little to no overhead at the language boundary.
15-
16-
* efficient
17-
18-
..R is a highly dynamic language that employs a unique combination of data type immutability, lazy evaluation, argument matching, large amount of built-in functionality, and interaction with C and Fortran code.
19-
..Consequently, applications that spend a lot of time in R code often have performance problems.
20-
..Common solutions are to try to apply primitives to large amounts of data at once and to convert R code to a native language like C.
21-
22-
..FastR makes extensive use of the dynamic optimization features provided by the Truffle framework to remove the abstractions that the R language introduces, and can use the Graal compiler to create optimized machine code on the fly.
23-
24-
* compatible
25-
26-
..The hardest challenge for implementations of the R language is the tradeoff between compatibility and performance.
27-
..If an implementation is very compatible, e.g., by using the traditional internal data layout, it cannot perform optimizations that imply a radically different internal structure.
28-
..If an implementation is very efficient, e.g., by adapting internal data structures to the current requirements, it will find it difficult to implement some parts of the GNUR system that are interfacing with applications and packages.
29-
30-
FastR employs many different solution strategies in order to overcome these problems.
31-
It also explores possible solutions at a grander scale, like evolution and emulation of R’s native interfaces.
32-
33-
## Getting FastR
34-
35-
FastR is available in two forms:
36-
37-
1. As a [pre-built binary](http://www.graalvm.org/downloads/). Note that this also includes (Truffle) implementations of JavaScript and optionally Ruby and Python. The pre-built binaries are available for Linux and Mac OS X. There is no Windows version available. The binary release is updated monthly.
38-
2. As a source release on [GitHub](https://github.com/graalvm/fastr) for developers wishing to contribute to the project and/or study the implementation. The source release is updated regularly and always contains the latest tested version.
39-
* Note: there is a comunity provided and maintained [Dockerfile](https://github.com/nuest/fastr-docker) for FastR.
12+
```
13+
$ $GRAALVM/bin/R
14+
Type 'q()' to quit R.
15+
> print("Hello R!")
16+
[1] "Hello R!"
17+
>
18+
```
4019

4120
## Documentation
4221

43-
Reference manual for FastR, its limitations, compatibility and additional functionality is
44-
available at [GraalVM website](http://www.graalvm.org/docs/reference-manual/languages/r/).
45-
46-
Further documentation is in the [documentation folder](documentation/Index.md) of this repository.
47-
48-
# Building FastR from Source
49-
50-
Building FastR from source is supported on Mac OS X (El Capitan onwards), and various flavors of Linux.
51-
FastR uses a build tool called `mx` (cf `maven`) which can be downloaded from [here](http://github.com/graalvm/mx).
52-
`mx` manages software in _suites_, which are normally one-to-one with a `git` repository. FastR depends fundamentally on the [truffle](http://github.com/graalvm/graal) suite. However, performance also depends on the [Graal compiler](http://github.com/graalvm/graal) as without it, FastR operates in interpreted mode only. The conventional way to arrange the Git repos (suites) is as siblings in a parent directory, which we will call `FASTR_HOME`.
53-
54-
## Pre-Requisites
55-
FastR shares some code with GnuR, for example, the default packages and the Blas library. Therefore, a version of GnuR (currently
56-
R-3.4.0), is downloaded and built as part of the build. Both GNU R and FastR require access certain tools and packages that must be available
57-
prior to the build. These are:
58-
59-
A jvmci-enabled Java JDK which is available from [pre-built binary](http://www.oracle.com/technetwork/oracle-labs/program-languages/downloads/index.html)
60-
Python version 2.7.x
61-
A Fortran compiler and libraries. Typically gfortran 4.8 or later
62-
A C compiler and libraries. Typically gcc or clang
63-
The pcre package, version 8.38 or later
64-
The zlib package, version 1.2.8 or later
65-
The bzip2 package, version 1.0.6 or later
66-
The xz package, version 5.2.2 or later
67-
The curl package, version 7.50.1 or later
68-
69-
If any of these are missing the GNU R build will fail which will cause the FastR build to fail also. If the build fails, more details can be found in log files in
70-
the `libdownloads/R-{version}` directory. Note that your system may have existing installations of these packages, possibly in standard system locations,
71-
but older versions. These must either be upgraded or newer versions installed with the package manager on your system. Since different systems use different package
72-
managers some of which install packages in directories that are not scanned by default by the C compiler and linker, it may be necessary to inform the build of these
73-
locations using the following environment variables:
22+
The reference manual for FastR, which explains its advantages, its current limitations, compatibility and additional functionality is available on the [GraalVM website](http://www.graalvm.org/docs/reference-manual/languages/r/).
7423

75-
PKG_INCLUDE_FLAGS_OVERRIDE
76-
PKG_LDFLAGS_OVERRIDE
24+
Further documentation, including contributor/developer-oriented information, is in the [documentation folder](documentation/Index.md) of this repository.
7725

78-
For example, on Mac OS, the MacPorts installer places headers in /opt/local/include and libraries in /opt/local/lib, in which case, the above variables must be set to these
79-
values prior to the build, e.g.:
26+
## Current Status
8027

81-
export PKG_INCLUDE_FLAGS_OVERRIDE=-I/opt/local/include
82-
export PKG_LDFLAGS_OVERRIDE=-L/opt/local/lib
28+
The goal of FastR is to be a drop-in replacement for GNU-R, the reference implementation of the R language.
29+
FastR faithfully implements the R language, and any difference in behavior is considered to be a bug.
8330

84-
Note that if more than once location must be specified, the values must be quoted, e.g., as in `export PKG_LDFLAGS_OVERRIDE="-Lpath1 -Lpath2"`.
31+
FastR is capable of running binary R packages built for GNU-R as long as those packages properly use the R extensions C API (for best results, it is recommended to install R packages from source).
32+
FastR supports R graphics via the grid package and packages based on grid (like lattice and ggplot2).
33+
We are currently working towards support for the base graphics package.
34+
FastR currently supports many of the popular R packages, such as ggplot2, jsonlite, testthat, assertthat, knitr, Shiny, Rcpp, rJava, quantmod and more…
8535

86-
The environment variable `JAVA_HOME` must be set to the location of the jvmci-enabled Java JDK.
36+
Moreover, support for dplyr and data.table are on the way.
37+
We are actively monitoring and improving FastR support for the most popular packages published on CRAN including all the tidyverse packages.
38+
However, one should take into account the experimental state of FastR, there can be packages that are not compatible yet, and if you try it on a complex R application, it can stumble on those.
8739

88-
## Building FastR
89-
Use the following sequence of commands to download and build an interpreted version of FastR.
40+
## Stay connected with the community
9041

91-
$ mkdir $FASTR_HOME
92-
$ cd $FASTR_HOME
93-
$ git clone http://github.com/graalvm/mx
94-
$ PATH=$PATH:$FASTR_HOME/mx
95-
$ git clone http://github.com/graalvm/fastr
96-
$ cd fastr
97-
$ mx build
98-
99-
The build will clone the Truffle repository and also download various required libraries, including GNU R, which is built first. Any problems with the GNU R configure step likely relate
100-
to dependent packages, so review the previous section. For FastR development, GNU R only needs to be built once, but an `mx clean` will, by default remove it. This can be prevented by setting
101-
the `GNUR_NOCLEAN` environment variable to any value.
102-
103-
It is possible to build FastR in "release mode" which builds and installs the GNU R "recommended" packages and also creates a `fastr-release.jar` file that contains everything that is needed to
104-
run FastR, apart from a Java VM. In particular it captures the package dependencies, e.g., `pcre` and `libgfortran`, so that when the file is unpacked on another system it will work regardless of whether the packages are installed on that system. For some systems that depend on FastR, e.g., GraalVM, it is a requirement to build in release mode as they depend on this file. To build in release mode, set the `FASTR_RELEASE` environment variable to any value. Note that this can be done at any time without doing a complete clean and rebuild. Simply set the variable and execute `mx build`.
105-
106-
## Running FastR
107-
108-
After building, running the FastR console can be done either with `bin/R` or with `mx r` or `mx R`. Using `mx` makes available some additional options that are of interest to FastR developers.
109-
FastR supports the same command line arguments as R, so running an R script is done with `bin/R -f <file>` or `bin/Rscript <file>`.
110-
111-
## IDE Usage
112-
113-
`mx` supports IDE integration with Eclipse, Netbeans or IntelliJ and creates project metadata with the `ideinit` command (you can limit metadata creation to one IDE by setting the `MX_IDE` environment variable to, say, `eclipse`). After running this command you can import the `fastr` and `truffle` projects using the `File->Import` menu.
114-
115-
## Contributing
42+
See [graalvm.org/community](https://www.graalvm.org/community/) on how to stay connected with the development community.
43+
The discussion on [gitter](https://gitter.im/graalvm/graal-core) is a good way to get in touch with us.
11644

11745
We would like to grow the FastR open-source community to provide a free R implementation atop the Truffle/Graal stack.
11846
We encourage contributions, and invite interested developers to join in.
11947
Prospective contributors need to sign the [Oracle Contributor Agreement (OCA)](http://www.oracle.com/technetwork/community/oca-486395.html).
120-
The access point for contributions, issues and questions about FastR is the [GitHub repository ](https://github.com/graalvm/fastr)
121-
122-
## Troubleshooting
123-
124-
### GNU-R build fails
125-
126-
GNU-R is built as part of the FastR build and therefore all GNU-R dependencies are required.
127-
The output from GNU-R configuration is logged in `libdownloads/R-3.4.0/gnur_configure.log`.
48+
The access point for contributions, issues and questions about FastR is the [GitHub repository](https://github.com/oracle/fastr).
12849

129-
### Build fails when generating R grammar
50+
## Authors
13051

131-
This problem manifests by the following error message in the build output:
52+
FastR is developed by Oracle Labs and is based on [the GNU-R runtime](http://www.r-project.org/).
53+
It contains contributions by researchers at Purdue University ([purdue-fastr](https://github.com/allr/purdue-fastr)), Northeastern University, JKU Linz, TU Dortmund and TU Berlin.
13254

133-
`Parser failed to execute command`
55+
## License
13456

135-
followed by a series of parser errors, such as:
57+
FastR is available under a GPLv3 license.
13658

137-
`error(170): R.g:<LINE>:<COL>: the .. range operator isn't allowed in parser rules`
138-
139-
It seems to be an ANTLR issue occurring when `LANG`, `LC_ALL` and `LC_CTYPE` environment
140-
variables are not set to the same value.
141-
142-
The solution is to set those variables to the same value, e.g.
143-
144-
```
145-
export LANG=en_US.UTF-8
146-
export LC_ALL=en_US.UTF-8
147-
export LC_CTYPE=en_US.UTF-8
148-
```
149-
150-
Note: you may need to install `locale` and run the following before setting the above env variables:
151-
152-
```
153-
locale en_US.UTF-8
154-
```
15559

ci.hocon

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ builds = [
1717
${gateTestDarwin} {capabilities : [darwin_sierra, amd64], targets : [gate], name: "gate-test-darwin-amd64"}
1818
${gateStyle} {capabilities : [linux, amd64], targets : [gate], name: "gate-style-linux-amd64"}
1919
${gateBuildWithEcj} {capabilities : [linux, amd64], targets : [gate], name: "gate-ecj-linux-amd64"}
20-
${rbcheck} {capabilities : [linux, amd64], targets : [gate], name: "gate-rbcheck-linux-amd64"}
20+
# GR-11799
21+
# ${rbcheck} {capabilities : [linux, amd64], targets : [gate], name: "gate-rbcheck-linux-amd64"}
2122
${internalPkgtest} {capabilities : [linux, amd64], targets : [gate], name: "gate-internal-pkgtest-linux-amd64"}
2223
${gateTestJava9Linux} {capabilities : [linux, amd64, fast], targets : [gate], name: "gate-test-java9-linux-amd64"}
2324
# ${gnurTests} {capabilities : [linux, amd64, fast], targets : [gate], name: "gate-gnur-tests"}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ protected String toString(RContext context, Object value) {
131131
if (unwrapped instanceof RPromise) {
132132
RPromise promise = (RPromise) unwrapped;
133133
if (promise.isEvaluated()) {
134-
unwrapped = promise.getValue();
134+
unwrapped = RRuntime.asAbstractVector(promise.getValue());
135135
}
136136
}
137137
if (unwrapped instanceof String) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ protected Object access(Object receiver) {
6262
}
6363

6464
@CanResolve
65-
public abstract static class RConnection extends Node {
65+
public abstract static class CanResolveRConnection extends Node {
6666

6767
protected static boolean test(TruffleObject receiver) {
6868
return receiver instanceof RConnection;

com.oracle.truffle.r.ffi.codegen/src/com/oracle/truffle/r/ffi/codegen/FFITestsCodeGen.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@
4747
public final class FFITestsCodeGen extends CodeGenBase {
4848
private static final String FUN_PREFIX = "api_";
4949
private static final HashSet<String> IGNORE_FUNS = new HashSet<>(
50-
Arrays.asList("Rf_cospi", "Rf_sinpi", "Rf_tanpi", "R_forceAndCall", "Rf_duplicate", "R_ToplevelExec", "R_CleanUp", "R_ParseVector", "octsize", "R_NewHashedEnv"));
50+
Arrays.asList("Rf_cospi", "Rf_sinpi", "Rf_tanpi", "R_forceAndCall", "Rf_duplicate", "R_ToplevelExec", "R_CleanUp", "R_ParseVector", "octsize", "R_NewHashedEnv", "Rf_ScalarComplex",
51+
"Rf_ScalarRaw", "Rf_allocList", "Rf_allocSExp"));
5152

5253
public static void main(String[] args) {
5354
new FFITestsCodeGen().run(args);

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@
9595
import com.oracle.truffle.r.runtime.data.RUnboundValue;
9696
import com.oracle.truffle.r.runtime.data.RVector;
9797
import com.oracle.truffle.r.runtime.data.model.RAbstractListVector;
98+
import com.oracle.truffle.r.runtime.data.model.RAbstractStringVector;
9899
import com.oracle.truffle.r.runtime.data.model.RAbstractVector;
99100
import com.oracle.truffle.r.runtime.data.nodes.VectorAccess;
100101
import com.oracle.truffle.r.runtime.data.nodes.VectorAccess.RandomIterator;
@@ -1084,7 +1085,7 @@ private enum ParseStatus {
10841085
@TruffleBoundary
10851086
public Object R_ParseVector(Object text, int n, Object srcFile) {
10861087
// TODO general case + all statuses
1087-
assert n == 1 : "unsupported: R_ParseVector with n != 0.";
1088+
assert n == 1 || (n < 0 && (text instanceof String || (text instanceof RAbstractStringVector && ((RAbstractStringVector) text).getLength() == 1))) : "unsupported: R_ParseVector with n != 0.";
10881089
assert srcFile == RNull.instance : "unsupported: R_ParseVector with non-null srcFile argument.";
10891090
String textString = RRuntime.asString(text);
10901091
assert textString != null;

com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/nodes/RForceAndCallNode.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
import com.oracle.truffle.api.dsl.Cached;
3030
import com.oracle.truffle.api.dsl.Specialization;
3131
import com.oracle.truffle.api.frame.VirtualFrame;
32-
import com.oracle.truffle.api.nodes.ExplodeLoop;
3332
import com.oracle.truffle.api.profiles.ValueProfile;
3433
import com.oracle.truffle.r.nodes.access.variables.ReadVariableNode;
3534
import com.oracle.truffle.r.nodes.function.PromiseHelperNode;
@@ -116,7 +115,6 @@ private static RArgsValuesAndNames createArgsAndNames(List<Object> argValues, RA
116115
return argsAndNames;
117116
}
118117

119-
@ExplodeLoop
120118
private void flattenFirstArgs(VirtualFrame frame, int n, RArgsValuesAndNames args) {
121119
if (promiseHelper == null) {
122120
CompilerDirectives.transferToInterpreterAndInvalidate();

com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/upcalls/DLLUpCallsRFFI.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import com.oracle.truffle.api.interop.TruffleObject;
2626
import com.oracle.truffle.r.ffi.processor.RFFICpointer;
2727
import com.oracle.truffle.r.ffi.processor.RFFICstring;
28+
import com.oracle.truffle.r.ffi.processor.RFFIResultOwner;
2829

2930
public interface DLLUpCallsRFFI {
3031

@@ -48,7 +49,7 @@ public interface DLLUpCallsRFFI {
4849
* @param fun a representation of the the C address of the function (in the table)
4950
* @param numArgs the number of arguments the function takes.
5051
*/
51-
Object setDotSymbolValues(Object dllInfo, @RFFICstring String name, @RFFICpointer Object fun, int numArgs);
52+
Object setDotSymbolValues(Object dllInfo, @RFFICstring String name, @RFFIResultOwner @RFFICpointer Object fun, int numArgs);
5253

5354
/**
5455
* Directly implements {@code R_useDynamicSymbols}.

com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/upcalls/IDEUpCallsRFFI.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
package com.oracle.truffle.r.ffi.impl.upcalls;
2424

2525
import com.oracle.truffle.api.frame.Frame;
26+
import com.oracle.truffle.r.ffi.processor.RFFIResultOwner;
2627

2728
/**
2829
* Additional upcalls created for supporting FastR in RStudio. These mainly relate to the GNU R
@@ -42,7 +43,7 @@ public interface IDEUpCallsRFFI {
4243

4344
Object R_getContextCall(Object c);
4445

45-
Object R_getContextSrcRef(Object c);
46+
Object R_getContextSrcRef(@RFFIResultOwner Object c);
4647

4748
int R_insideBrowser();
4849

0 commit comments

Comments
 (0)