Skip to content
Snippets Groups Projects
Commit 09d9ad0d authored by Adam Welc's avatar Adam Welc
Browse files

Merged.

parents 63c70471 85cd22d6
Branches
No related tags found
No related merge requests found
......@@ -24,7 +24,10 @@ package com.oracle.truffle.r.nodes.builtin.base;
import static com.oracle.truffle.r.nodes.builtin.RBuiltinKind.*;
import com.oracle.truffle.api.*;
import com.oracle.truffle.api.dsl.*;
import com.oracle.truffle.r.nodes.*;
import com.oracle.truffle.r.nodes.access.*;
import com.oracle.truffle.r.nodes.builtin.*;
import com.oracle.truffle.r.runtime.*;
import com.oracle.truffle.r.runtime.data.*;
......@@ -33,8 +36,33 @@ import com.oracle.truffle.r.runtime.data.model.*;
public class IsListFunctions {
@RBuiltin(name = "is.list", kind = PRIMITIVE)
@SuppressWarnings("unused")
// TODO ideally this would inherit from isTypeNode,
// but issues around subclassing would need to be resolved
public abstract static class IsList extends RBuiltinNode {
private static final String[] PARAMETER_NAMES = new String[]{"x"};
@Override
public Object[] getParameterNames() {
return PARAMETER_NAMES;
}
@Override
public RNode[] getParameterValues() {
return new RNode[]{ConstantNode.create(RMissing.instance)};
}
protected byte error() throws RError {
CompilerDirectives.transferToInterpreter();
throw RError.getZ1ArgumentsPassed(getEncapsulatingSourceSection(), getRBuiltin().name());
}
@Specialization
public byte isType(RMissing value) {
controlVisibility();
return error();
}
@Specialization
public byte isType(RList value) {
controlVisibility();
......@@ -65,6 +93,12 @@ public class IsListFunctions {
return RRuntime.LOGICAL_FALSE;
}
@Specialization(order = 12)
public byte isType(REnvironment env) {
controlVisibility();
return RRuntime.LOGICAL_FALSE;
}
protected boolean isList(RAbstractVector vector) {
return vector.getElementClass() == Object.class;
}
......
......@@ -54,6 +54,7 @@ public class ParserGeneration {
"more verbose debug output for source attribution",
"adopt changed SourceSection creation API",
"support NA_real_",
"support NA_character_",
};
}
......@@ -491,6 +491,7 @@ simple_expr returns [ASTNode v]
| t=NAN { $v = Constant.createDoubleConstant(sourceSection("simple_expr/NAN", t), "NaN"); }
| t=NAINT { $v = Constant.createIntConstant(sourceSection("simple_expr/NAINT", t), "NA_integer_"); }
| t=NAREAL { $v = Constant.createDoubleConstant(sourceSection("simple_expr/NAREAL", t), "NA_real_"); }
| t=NACHAR { $v = Constant.createStringNA(sourceSection("simple_expr/NACHAR", t)); }
| num=number { $v = num; }
| cstr=conststring { $v = cstr; }
| pkg=id nsg=(NS_GET|NS_GET_INT) n_ comp=id {
......@@ -632,7 +633,7 @@ NULL : 'NULL' ;
NA : 'NA' ;
NAINT : 'NA_integer_' ;
NAREAL : 'NA_real_' ;
///NACHAR : 'NA_character_' ;
NACHAR : 'NA_character_' ;
///NACOMPL : 'NA_complex_' ;
TRUE : 'TRUE' ;
FALSE : 'FALSE' ;
......
......@@ -91,6 +91,10 @@ public class Constant extends ASTNode {
return new Constant(values, ConstantType.STRING, src);
}
public static Constant createStringNA(SourceSection src) {
return new Constant(new String[]{RRuntime.STRING_NA}, ConstantType.STRING, src);
}
public void addNegativeSign() {
values[0] = "-" + values[0];
}
......
......@@ -20,7 +20,7 @@
# or visit www.oracle.com if you need additional information or have any
# questions.
#
import subprocess, tempfile, shutil, filecmp, platform
import subprocess, tempfile, shutil, filecmp, platform, shlex
from os.path import join, sep
from argparse import ArgumentParser, REMAINDER
import mx
......@@ -29,7 +29,9 @@ import os
_fastr_suite = None
def _runR(args, className, nonZeroIsFatal=True):
def _runR(args, className, nonZeroIsFatal=True, extraVmArgs=None):
# extraVmArgs is not normally necessary as the global --J option can be used running R/RScript
# However, the bench command invokes other Java VMs along the way, so it must use extraVmArgs
os.environ['R_HOME'] = _fastr_suite.dir
# Set up path for Lapack libraries
osname = platform.system()
......@@ -41,11 +43,14 @@ def _runR(args, className, nonZeroIsFatal=True):
else:
lib_env = 'LD_LIBRARY_PATH'
os.environ[lib_env] = lib_value
return mx_graal.vm(['-ea', '-esa', '-cp', mx.classpath("com.oracle.truffle.r.shell"), className] + args, nonZeroIsFatal=nonZeroIsFatal)
vmArgs = ['-ea', '-esa', '-cp', mx.classpath("com.oracle.truffle.r.shell")]
if extraVmArgs:
vmArgs = vmArgs + extraVmArgs
return mx_graal.vm(vmArgs + [className] + args, nonZeroIsFatal=nonZeroIsFatal)
def runRCommand(args, nonZeroIsFatal=True):
def runRCommand(args, nonZeroIsFatal=True, extraVmArgs=None):
'''run R shell'''
return _runR(args, "com.oracle.truffle.r.shell.RCommand", nonZeroIsFatal=nonZeroIsFatal)
return _runR(args, "com.oracle.truffle.r.shell.RCommand", nonZeroIsFatal=nonZeroIsFatal, extraVmArgs=extraVmArgs)
def runRscriptCommand(args, nonZeroIsFatal=True):
'''run Rscript file'''
......@@ -191,6 +196,7 @@ def testgen(args):
def rbench(args):
'''run a one or more R benchmarks'''
parser = ArgumentParser(prog='mx rbench')
parser.add_argument('--J', dest='extra_javavm_args', help='extra Java VM arguments', metavar='@<args>')
parser.add_argument('--path', action='store_true', help='print path to benchmark')
parser.add_argument('--gnur', action='store_true', help='run under GnuR')
parser.add_argument('--gnur-path', action='store', metavar='<path>', help='specify path to GnuR', default='R')
......@@ -199,6 +205,8 @@ def rbench(args):
parser.add_argument('benchmarks', nargs=REMAINDER, metavar='benchmarkgroup.name', help='list of benchmarks to run')
args = parser.parse_args(args)
if args.extra_javavm_args:
args.extra_javavm_args = shlex.split(args.extra_javavm_args.lstrip('@'))
# dynamically load the benchmarks suite
hg_base = mx.get_env('HG_BASE')
alternate = None if hg_base is None else join(hg_base, 'r_benchmarks')
......@@ -227,7 +235,7 @@ def rbench(args):
else:
# temporary: disable group generics as long as they impose a considerable performance overhead
command = ['--DisableGroupGenerics'] + command
rc = runRCommand(command, nonZeroIsFatal=False)
rc = runRCommand(command, nonZeroIsFatal=False, extraVmArgs=args.extra_javavm_args)
if rc != 0:
print 'benchmark ' + bm + ' failed'
emsg = rc
......@@ -250,6 +258,8 @@ def _bench_harness_body(args, vmArgs):
'shootout.regexdna', 'shootout.reversecomplement', 'shootout.spectralnorm',
'b25.bench.prog-1', 'b25.bench.prog-2', 'b25.bench.prog-3', 'b25.bench.prog-4', 'b25.bench.prog-5',
'b25.bench.matcal-1', 'b25.bench.matcal-2']
if vmArgs:
marks = ['--J', vmArgs] + marks
return rbench(marks)
def bench(args):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment