diff --git a/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/ffi/TruffleC.java b/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/ffi/llvm/TruffleLLVM_C.java similarity index 95% rename from com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/ffi/TruffleC.java rename to com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/ffi/llvm/TruffleLLVM_C.java index 9c5d86b065c1187113c9664dd7b705afdad03553..e2eb33c9f70afe2c9fe855efc8b08a817f78bfdf 100644 --- a/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/ffi/TruffleC.java +++ b/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/ffi/llvm/TruffleLLVM_C.java @@ -20,7 +20,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package com.oracle.truffle.r.engine.interop.ffi; +package com.oracle.truffle.r.engine.interop.ffi.llvm; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.interop.ForeignAccess; @@ -35,7 +35,7 @@ import com.oracle.truffle.r.runtime.ffi.NativeCallInfo; import com.oracle.truffle.r.runtime.ffi.jni.JNI_C; import com.oracle.truffle.r.runtime.ffi.truffle.TruffleRFFIFrameHelper; -class TruffleC implements CRFFI { +class TruffleLLVM_C implements CRFFI { private static class TruffleCRFFINode extends JNI_C.JNI_CRFFINode { @Override @@ -44,7 +44,7 @@ class TruffleC implements CRFFI { super.invoke(nativeCallInfo, args); } else { VirtualFrame frame = TruffleRFFIFrameHelper.create(); - TruffleDLL.ensureParsed(nativeCallInfo); + TruffleLLVM_DLL.ensureParsed(nativeCallInfo); Object[] wargs = wrap(args); try { Node messageNode = Message.createExecute(0).createNode(); diff --git a/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/ffi/TruffleCAccess.java b/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/ffi/llvm/TruffleLLVM_CAccess.java similarity index 61% rename from com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/ffi/TruffleCAccess.java rename to com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/ffi/llvm/TruffleLLVM_CAccess.java index d6773884df9469afce34f1716abec2f04fa2b676..8df6ca4e5321b157588acbbbc6f9107e7d4ae7db 100644 --- a/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/ffi/TruffleCAccess.java +++ b/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/ffi/llvm/TruffleLLVM_CAccess.java @@ -20,14 +20,22 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package com.oracle.truffle.r.engine.interop.ffi; +package com.oracle.truffle.r.engine.interop.ffi.llvm; import com.oracle.truffle.r.runtime.ffi.DLL; +import com.oracle.truffle.r.runtime.ffi.jni.JNI_DLL; +import com.oracle.truffle.r.runtime.rng.user.UserRNG; /** - * Access to primitive C operations. + * Access to some primitive C operations. This is required by the {@link UserRNG} API which works + * with {@code double *}. + * + * N.B. When {@code libR} is not completely in LLVM mode (as now), we have to look up the symbols + * using an explicitly created {@link TruffleLLVM_DLL.LLVM_Handle}and not go via generic lookup in + * {@link DLL} as that would use a {@link JNI_DLL} handle. */ -public class TruffleCAccess { +public class TruffleLLVM_CAccess { + private static final TruffleLLVM_DLL.LLVM_Handle handle = new TruffleLLVM_DLL.LLVM_Handle("libR"); public enum Function { READ_POINTER_INT, @@ -39,7 +47,10 @@ public class TruffleCAccess { public DLL.SymbolHandle getSymbolHandle() { if (symbolHandle == null) { - symbolHandle = DLL.findSymbol(cName(), null); + // This would be the generic path + // symbolHandle = DLL.findSymbol(cName(), null); + symbolHandle = (DLL.SymbolHandle) DLL.DLLFFIRootNode.create().getCallTarget().call(DLL.DLLFFIRootNode.DLSYM, handle, cName()); + assert symbolHandle != null; } return symbolHandle; } diff --git a/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/ffi/TruffleCall.java b/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/ffi/llvm/TruffleLLVM_Call.java similarity index 93% rename from com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/ffi/TruffleCall.java rename to com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/ffi/llvm/TruffleLLVM_Call.java index 5fd056c445db51ec1bd1eba916d7c1780a689e53..016158c4b07a2d148b33af3c8e0aa1da0e9a0dca 100644 --- a/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/ffi/TruffleCall.java +++ b/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/ffi/llvm/TruffleLLVM_Call.java @@ -20,7 +20,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package com.oracle.truffle.r.engine.interop.ffi; +package com.oracle.truffle.r.engine.interop.ffi.llvm; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.ImportStatic; @@ -31,8 +31,8 @@ import com.oracle.truffle.api.interop.Message; import com.oracle.truffle.api.interop.TruffleObject; import com.oracle.truffle.api.interop.java.JavaInterop; import com.oracle.truffle.api.nodes.Node; -import com.oracle.truffle.r.engine.interop.ffi.TruffleCallFactory.InvokeTruffleNodeGen; -import com.oracle.truffle.r.engine.interop.ffi.TruffleCallFactory.SplitTruffleCallRFFINodeGen; +import com.oracle.truffle.r.engine.interop.ffi.llvm.TruffleLLVM_CallFactory.InvokeTruffleNodeGen; +import com.oracle.truffle.r.engine.interop.ffi.llvm.TruffleLLVM_CallFactory.SplitTruffleCallRFFINodeGen; import com.oracle.truffle.r.runtime.RInternalError; import com.oracle.truffle.r.runtime.context.RContext; import com.oracle.truffle.r.runtime.context.RContext.ContextState; @@ -45,18 +45,18 @@ import com.oracle.truffle.r.runtime.ffi.jni.JNI_Call; import com.oracle.truffle.r.runtime.ffi.jni.JNI_Call.JNI_CallRFFINode; import com.oracle.truffle.r.runtime.ffi.truffle.TruffleRFFIFrameHelper; -class TruffleCall implements CallRFFI { - private static TruffleCall truffleCall; +class TruffleLLVM_Call implements CallRFFI { + private static TruffleLLVM_Call truffleCall; private static TruffleObject truffleCallTruffleObject; private static TruffleObject truffleCallHelper; @SuppressWarnings("unused") - TruffleCall() { + TruffleLLVM_Call() { new JNI_Call(); truffleCall = this; truffleCallTruffleObject = JavaInterop.asTruffleObject(truffleCall); - TrufflePkgInit.initialize(); - truffleCallHelper = TruffleCallHelper.initialize(); + TruffleLLVM_PkgInit.initialize(); + truffleCallHelper = TruffleLLVM_UpCallsRFFIImpl.initialize(); } static class ContextStateImpl implements RContext.ContextState { @@ -96,7 +96,7 @@ class TruffleCall implements CallRFFI { private static void initVariables(RContext context) { // must have parsed the variables module in libR for (INIT_VAR_FUN initVarFun : INIT_VAR_FUN.values()) { - TruffleDLL.ensureParsed("libR", initVarFun.funName, true); + TruffleLLVM_DLL.ensureParsed("libR", initVarFun.funName, true); initVarFun.symbolHandle = new SymbolHandle(context.getEnv().importSymbol("@" + initVarFun.funName)); } VirtualFrame frame = TruffleRFFIFrameHelper.create(); @@ -171,8 +171,8 @@ class TruffleCall implements CallRFFI { } public static boolean ensureReady(NativeCallInfo nativeCallInfo) { - TruffleDLL.ensureParsed(nativeCallInfo); - ContextStateImpl contextState = TruffleRFFIContextState.getContextState().callState; + TruffleLLVM_DLL.ensureParsed(nativeCallInfo); + ContextStateImpl contextState = TruffleLLVM_RFFIContextState.getContextState().callState; if (!contextState.initVariablesDone) { initVariables(contextState.context); contextState.initVariablesDone = true; diff --git a/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/ffi/TruffleDLL.java b/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/ffi/llvm/TruffleLLVM_DLL.java similarity index 96% rename from com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/ffi/TruffleDLL.java rename to com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/ffi/llvm/TruffleLLVM_DLL.java index a857e0b53dfccfd350ceadadcc89054104997af2..b7c6a35f646644e5430013fb46df33cc0d94afff 100644 --- a/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/ffi/TruffleDLL.java +++ b/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/ffi/llvm/TruffleLLVM_DLL.java @@ -20,7 +20,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package com.oracle.truffle.r.engine.interop.ffi; +package com.oracle.truffle.r.engine.interop.ffi.llvm; import java.nio.file.FileSystems; import java.util.HashMap; @@ -80,7 +80,7 @@ import com.oracle.truffle.r.runtime.ffi.truffle.LLVM_IR; * native code is used by non-LLVM packages (libraries) and the LLVM code is used by the LLVM * packages (libraries). */ -class TruffleDLL extends JNI_DLL implements DLLRFFI { +class TruffleLLVM_DLL extends JNI_DLL implements DLLRFFI { /** * Supports lazy parsing of LLVM modules. */ @@ -142,9 +142,9 @@ class TruffleDLL extends JNI_DLL implements DLLRFFI { } } - private static TruffleDLL truffleDLL; + private static TruffleLLVM_DLL truffleDLL; - TruffleDLL() { + TruffleLLVM_DLL() { assert truffleDLL == null; truffleDLL = this; } @@ -168,10 +168,10 @@ class TruffleDLL extends JNI_DLL implements DLLRFFI { return true; } - static class TruffleHandle { + static class LLVM_Handle { private final String libName; - TruffleHandle(String libName) { + LLVM_Handle(String libName) { this.libName = libName; } } @@ -207,7 +207,7 @@ class TruffleDLL extends JNI_DLL implements DLLRFFI { LLVM_IR ir = irs[i]; addExportsToMap(contextState, libName, ir, (name) -> true); } - return new TruffleHandle(libName); + return new LLVM_Handle(libName); } } catch (Exception ex) { return null; @@ -216,10 +216,10 @@ class TruffleDLL extends JNI_DLL implements DLLRFFI { @Override public SymbolHandle dlsym(Object handle, String symbol) { - if (handle instanceof TruffleHandle) { + if (handle instanceof LLVM_Handle) { // If the symbol exists it will be in the map ParseStatus parseStatus = getContextState().parseStatusMap.get(symbol); - if (parseStatus != null && parseStatus.libName.equals(((TruffleHandle) handle).libName)) { + if (parseStatus != null && parseStatus.libName.equals(((LLVM_Handle) handle).libName)) { // force a parse so we have a "value" if (!parseStatus.parsed) { ensureParsed(parseStatus.libName, symbol, true); @@ -238,7 +238,7 @@ class TruffleDLL extends JNI_DLL implements DLLRFFI { @Override public int dlclose(Object handle) { - if (handle instanceof TruffleHandle) { + if (handle instanceof LLVM_Handle) { return 0; } else { return super.dlclose(handle); @@ -273,7 +273,7 @@ class TruffleDLL extends JNI_DLL implements DLLRFFI { private LLVM_IR[] libRModules; private static ContextStateImpl getContextState() { - return TruffleRFFIContextState.getContextState().dllState; + return TruffleLLVM_RFFIContextState.getContextState().dllState; } /** diff --git a/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/ffi/TrufflePkgInit.java b/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/ffi/llvm/TruffleLLVM_PkgInit.java similarity index 94% rename from com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/ffi/TrufflePkgInit.java rename to com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/ffi/llvm/TruffleLLVM_PkgInit.java index 26d01e6f739901449907ca802c2fd8c5c5a16341..0524af4dbfc2a51bea97d07b2ea9b30ffbdf42ab 100644 --- a/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/ffi/TrufflePkgInit.java +++ b/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/ffi/llvm/TruffleLLVM_PkgInit.java @@ -20,7 +20,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package com.oracle.truffle.r.engine.interop.ffi; +package com.oracle.truffle.r.engine.interop.ffi.llvm; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.interop.ForeignAccess; @@ -37,9 +37,9 @@ import com.oracle.truffle.r.runtime.ffi.DLL.DotSymbol; import com.oracle.truffle.r.runtime.ffi.DLL.SymbolHandle; import com.oracle.truffle.r.runtime.ffi.truffle.TruffleRFFIFrameHelper; -class TrufflePkgInit { +class TruffleLLVM_PkgInit { - private static TrufflePkgInit trufflePkgInit; + private static TruffleLLVM_PkgInit trufflePkgInit; private static TruffleObject trufflePkgInitTruffleObject; static class ContextStateImpl implements RContext.ContextState { @@ -58,9 +58,9 @@ class TrufflePkgInit { return new ContextStateImpl(); } - static TrufflePkgInit initialize() { + static TruffleLLVM_PkgInit initialize() { if (trufflePkgInit == null) { - trufflePkgInit = new TrufflePkgInit(); + trufflePkgInit = new TruffleLLVM_PkgInit(); trufflePkgInitTruffleObject = JavaInterop.asTruffleObject(trufflePkgInit); } return trufflePkgInit; diff --git a/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/ffi/TruffleRFFIContextState.java b/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/ffi/llvm/TruffleLLVM_RFFIContextState.java similarity index 68% rename from com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/ffi/TruffleRFFIContextState.java rename to com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/ffi/llvm/TruffleLLVM_RFFIContextState.java index 4df65f0d27c3b9f6d3241ef26a3353fa9f3b7590..75fae59b7fba90e36c1e1e703d375dae09f6ad2c 100644 --- a/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/ffi/TruffleRFFIContextState.java +++ b/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/ffi/llvm/TruffleLLVM_RFFIContextState.java @@ -20,7 +20,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package com.oracle.truffle.r.engine.interop.ffi; +package com.oracle.truffle.r.engine.interop.ffi.llvm; import com.oracle.truffle.r.runtime.context.RContext; import com.oracle.truffle.r.runtime.context.RContext.ContextState; @@ -29,25 +29,25 @@ import com.oracle.truffle.r.runtime.context.RContext.ContextState; * A facade for the context state for the Truffle LLVM factory. Delegates to the various * module-specific pieces of state. This may get merged into a single instance eventually. */ -class TruffleRFFIContextState implements ContextState { - TruffleDLL.ContextStateImpl dllState; - TrufflePkgInit.ContextStateImpl pkgInitState; - TruffleCall.ContextStateImpl callState; - TruffleStats.ContextStateImpl statsState; +class TruffleLLVM_RFFIContextState implements ContextState { + TruffleLLVM_DLL.ContextStateImpl dllState; + TruffleLLVM_PkgInit.ContextStateImpl pkgInitState; + TruffleLLVM_Call.ContextStateImpl callState; + TruffleLLVM_Stats.ContextStateImpl statsState; - TruffleRFFIContextState() { - dllState = TruffleDLL.newContextState(); - pkgInitState = TrufflePkgInit.newContextState(); - callState = TruffleCall.newContextState(); - statsState = TruffleStats.newContextState(); + TruffleLLVM_RFFIContextState() { + dllState = TruffleLLVM_DLL.newContextState(); + pkgInitState = TruffleLLVM_PkgInit.newContextState(); + callState = TruffleLLVM_Call.newContextState(); + statsState = TruffleLLVM_Stats.newContextState(); } - static TruffleRFFIContextState getContextState() { - return (TruffleRFFIContextState) RContext.getInstance().getStateRFFI(); + static TruffleLLVM_RFFIContextState getContextState() { + return (TruffleLLVM_RFFIContextState) RContext.getInstance().getStateRFFI(); } - static TruffleRFFIContextState getContextState(RContext context) { - return (TruffleRFFIContextState) context.getStateRFFI(); + static TruffleLLVM_RFFIContextState getContextState(RContext context) { + return (TruffleLLVM_RFFIContextState) context.getStateRFFI(); } @Override diff --git a/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/ffi/Truffle_RFFIFactory.java b/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/ffi/llvm/TruffleLLVM_RFFIFactory.java similarity index 84% rename from com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/ffi/Truffle_RFFIFactory.java rename to com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/ffi/llvm/TruffleLLVM_RFFIFactory.java index 8af33a15658061790ebdf5d51b566acb3fd62dd8..dbac7eb62f59d806abe29f866a981dbf9481352c 100644 --- a/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/ffi/Truffle_RFFIFactory.java +++ b/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/ffi/llvm/TruffleLLVM_RFFIFactory.java @@ -20,7 +20,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package com.oracle.truffle.r.engine.interop.ffi; +package com.oracle.truffle.r.engine.interop.ffi.llvm; import com.oracle.truffle.r.runtime.context.RContext.ContextState; import com.oracle.truffle.r.runtime.ffi.CRFFI; @@ -35,7 +35,7 @@ import com.oracle.truffle.r.runtime.ffi.jni.JNI_RFFIFactory; * Incremental approach to using Truffle, defaults to the JNI factory. * */ -public class Truffle_RFFIFactory extends JNI_RFFIFactory implements RFFI { +public class TruffleLLVM_RFFIFactory extends JNI_RFFIFactory implements RFFI { @Override protected void initialize(boolean runtime) { @@ -44,7 +44,7 @@ public class Truffle_RFFIFactory extends JNI_RFFIFactory implements RFFI { @Override public ContextState newContextState() { - return new TruffleRFFIContextState(); + return new TruffleLLVM_RFFIContextState(); } private CRFFI cRFFI; @@ -52,7 +52,7 @@ public class Truffle_RFFIFactory extends JNI_RFFIFactory implements RFFI { @Override public CRFFI getCRFFI() { if (cRFFI == null) { - cRFFI = new TruffleC(); + cRFFI = new TruffleLLVM_C(); } return cRFFI; } @@ -62,7 +62,7 @@ public class Truffle_RFFIFactory extends JNI_RFFIFactory implements RFFI { @Override public DLLRFFI getDLLRFFI() { if (dllRFFI == null) { - dllRFFI = new TruffleDLL(); + dllRFFI = new TruffleLLVM_DLL(); } return dllRFFI; } @@ -72,7 +72,7 @@ public class Truffle_RFFIFactory extends JNI_RFFIFactory implements RFFI { @Override public UserRngRFFI getUserRngRFFI() { if (truffleUserRngRFFI == null) { - truffleUserRngRFFI = new TruffleUserRng(); + truffleUserRngRFFI = new TruffleLLVM_UserRng(); } return truffleUserRngRFFI; } @@ -82,7 +82,7 @@ public class Truffle_RFFIFactory extends JNI_RFFIFactory implements RFFI { @Override public CallRFFI getCallRFFI() { if (truffleCallRFFI == null) { - truffleCallRFFI = new TruffleCall(); + truffleCallRFFI = new TruffleLLVM_Call(); } return truffleCallRFFI; } @@ -91,11 +91,11 @@ public class Truffle_RFFIFactory extends JNI_RFFIFactory implements RFFI { @Override public StatsRFFI getStatsRFFI() { - if (TruffleDLL.isBlacklisted("stats")) { + if (TruffleLLVM_DLL.isBlacklisted("stats")) { return super.getStatsRFFI(); } if (truffleStatsRFFI == null) { - truffleStatsRFFI = new TruffleStats(); + truffleStatsRFFI = new TruffleLLVM_Stats(); } return truffleStatsRFFI; } diff --git a/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/ffi/TruffleStats.java b/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/ffi/llvm/TruffleLLVM_Stats.java similarity index 89% rename from com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/ffi/TruffleStats.java rename to com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/ffi/llvm/TruffleLLVM_Stats.java index 954c8e256ab9f5e57b371588086e88715798743a..7b99290107d3bbd0010972b10a36d5c676d08610 100644 --- a/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/ffi/TruffleStats.java +++ b/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/ffi/llvm/TruffleLLVM_Stats.java @@ -20,7 +20,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package com.oracle.truffle.r.engine.interop.ffi; +package com.oracle.truffle.r.engine.interop.ffi.llvm; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.ImportStatic; @@ -31,8 +31,8 @@ import com.oracle.truffle.api.interop.Message; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.r.engine.interop.NativeDoubleArray; import com.oracle.truffle.r.engine.interop.NativeIntegerArray; -import com.oracle.truffle.r.engine.interop.ffi.TruffleStatsFactory.ExecuteFactorNodeGen; -import com.oracle.truffle.r.engine.interop.ffi.TruffleStatsFactory.ExecuteWorkNodeGen; +import com.oracle.truffle.r.engine.interop.ffi.llvm.TruffleLLVM_StatsFactory.ExecuteFactorNodeGen; +import com.oracle.truffle.r.engine.interop.ffi.llvm.TruffleLLVM_StatsFactory.ExecuteWorkNodeGen; import com.oracle.truffle.r.runtime.RInternalError; import com.oracle.truffle.r.runtime.context.RContext; import com.oracle.truffle.r.runtime.context.RContext.ContextState; @@ -44,7 +44,7 @@ import com.oracle.truffle.r.runtime.ffi.DLLRFFI.DLLRFFINode; import com.oracle.truffle.r.runtime.ffi.StatsRFFI; import com.oracle.truffle.r.runtime.ffi.truffle.TruffleRFFIFrameHelper; -public class TruffleStats implements StatsRFFI { +public class TruffleLLVM_Stats implements StatsRFFI { public enum FFT_FUN { fft_work, @@ -60,15 +60,15 @@ public class TruffleStats implements StatsRFFI { * it here. */ if (context.getKind() == RContext.ContextKind.SHARE_PARENT_RW) { - TruffleDLL.ContextStateImpl contextState = TruffleRFFIContextState.getContextState().dllState; - TruffleDLL.ContextStateImpl parentDLLContextState = TruffleRFFIContextState.getContextState(context.getParent()).dllState; - TruffleDLL.ParseStatus parseStatus = null; + TruffleLLVM_DLL.ContextStateImpl contextState = TruffleLLVM_RFFIContextState.getContextState().dllState; + TruffleLLVM_DLL.ContextStateImpl parentDLLContextState = TruffleLLVM_RFFIContextState.getContextState(context.getParent()).dllState; + TruffleLLVM_DLL.ParseStatus parseStatus = null; for (FFT_FUN f : FFT_FUN.values()) { String funName = f.name(); - TruffleDLL.ParseStatus parentParseStatus = parentDLLContextState.parseStatusMap.get(funName); + TruffleLLVM_DLL.ParseStatus parentParseStatus = parentDLLContextState.parseStatusMap.get(funName); if (parentParseStatus != null) { if (parseStatus == null) { - parseStatus = new TruffleDLL.ParseStatus("stats", parentParseStatus.ir, false); + parseStatus = new TruffleLLVM_DLL.ParseStatus("stats", parentParseStatus.ir, false); } contextState.parseStatusMap.put(f.name(), parseStatus); } @@ -96,7 +96,7 @@ public class TruffleStats implements StatsRFFI { SymbolHandle result = dllRFFINode.dlsym(dllInfo.handle, name); if (result == DLL.SYMBOL_NOT_FOUND) { @SuppressWarnings("unused") - TruffleRFFIContextState cs = TruffleRFFIContextState.getContextState(); + TruffleLLVM_RFFIContextState cs = TruffleLLVM_RFFIContextState.getContextState(); throw RInternalError.shouldNotReachHere(); } return result; diff --git a/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/ffi/TruffleCallHelper.java b/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/ffi/llvm/TruffleLLVM_UpCallsRFFIImpl.java similarity index 93% rename from com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/ffi/TruffleCallHelper.java rename to com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/ffi/llvm/TruffleLLVM_UpCallsRFFIImpl.java index 64126ff2c7de51b08f2db0ef561c15ee636b5510..a772cd62ca08f428c0193d2da389b3f633f744eb 100644 --- a/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/ffi/TruffleCallHelper.java +++ b/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/ffi/llvm/TruffleLLVM_UpCallsRFFIImpl.java @@ -20,7 +20,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package com.oracle.truffle.r.engine.interop.ffi; +package com.oracle.truffle.r.engine.interop.ffi.llvm; import java.nio.charset.StandardCharsets; @@ -46,17 +46,16 @@ import com.oracle.truffle.r.runtime.data.RUnboundValue; import com.oracle.truffle.r.runtime.ffi.CharSXPWrapper; /** - * A wrapper class that can be instantiated and export for method lookup. For now just delegates to - * {@link UpCallsRFFIImpl}. + * (Incomplete) Variant of {@link UpCallsRFFIImpl} for Truffle LLVM. * */ -public class TruffleCallHelper extends UpCallsRFFIImpl { - private static TruffleCallHelper singleton; +public class TruffleLLVM_UpCallsRFFIImpl extends UpCallsRFFIImpl { + private static TruffleLLVM_UpCallsRFFIImpl singleton; private static TruffleObject singletonTruffleObject; public static TruffleObject initialize() { if (singleton == null) { - singleton = new TruffleCallHelper(); + singleton = new TruffleLLVM_UpCallsRFFIImpl(); singletonTruffleObject = JavaInterop.asTruffleObject(singleton); } return singletonTruffleObject; diff --git a/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/ffi/TruffleUserRng.java b/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/ffi/llvm/TruffleLLVM_UserRng.java similarity index 90% rename from com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/ffi/TruffleUserRng.java rename to com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/ffi/llvm/TruffleLLVM_UserRng.java index 41c8dacbd0c378c4b2380f127d4e9deab08d10e6..4b65f52a6741a4805f63fda9ba9edd95f83d145c 100644 --- a/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/ffi/TruffleUserRng.java +++ b/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/ffi/llvm/TruffleLLVM_UserRng.java @@ -20,7 +20,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package com.oracle.truffle.r.engine.interop.ffi; +package com.oracle.truffle.r.engine.interop.ffi.llvm; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.interop.ForeignAccess; @@ -31,7 +31,7 @@ import com.oracle.truffle.r.runtime.ffi.UserRngRFFI; import com.oracle.truffle.r.runtime.ffi.truffle.TruffleRFFIFrameHelper; import com.oracle.truffle.r.runtime.rng.user.UserRNG.Function; -public class TruffleUserRng implements UserRngRFFI { +public class TruffleLLVM_UserRng implements UserRngRFFI { private static class TruffleUserRngRFFINode extends UserRngRFFINode { Node initMessage; Node randMessage; @@ -60,7 +60,7 @@ public class TruffleUserRng implements UserRngRFFI { } try { Object address = ForeignAccess.sendExecute(randMessage, frame, Function.Rand.getSymbolHandle().asTruffleObject()); - Object value = ForeignAccess.sendExecute(readPointerNode, frame, TruffleCAccess.Function.READ_POINTER_DOUBLE.getSymbolHandle().asTruffleObject(), address); + Object value = ForeignAccess.sendExecute(readPointerNode, frame, TruffleLLVM_CAccess.Function.READ_POINTER_DOUBLE.getSymbolHandle().asTruffleObject(), address); return (double) value; } catch (Throwable t) { throw RInternalError.shouldNotReachHere(); @@ -75,7 +75,7 @@ public class TruffleUserRng implements UserRngRFFI { } try { Object address = ForeignAccess.sendExecute(nSeedMessage, frame, Function.NSeed.getSymbolHandle().asTruffleObject()); - Object n = ForeignAccess.sendExecute(readPointerNode, frame, TruffleCAccess.Function.READ_POINTER_INT.getSymbolHandle().asTruffleObject(), address); + Object n = ForeignAccess.sendExecute(readPointerNode, frame, TruffleLLVM_CAccess.Function.READ_POINTER_INT.getSymbolHandle().asTruffleObject(), address); return (int) n; } catch (Throwable t) { throw RInternalError.shouldNotReachHere(); @@ -91,7 +91,7 @@ public class TruffleUserRng implements UserRngRFFI { try { Object address = ForeignAccess.sendExecute(seedsMessage, frame, Function.Seedloc.getSymbolHandle().asTruffleObject()); for (int i = 0; i < n.length; i++) { - Object seed = ForeignAccess.sendExecute(readPointerNode, frame, TruffleCAccess.Function.READ_ARRAY_INT.getSymbolHandle().asTruffleObject(), address, i); + Object seed = ForeignAccess.sendExecute(readPointerNode, frame, TruffleLLVM_CAccess.Function.READ_ARRAY_INT.getSymbolHandle().asTruffleObject(), address, i); n[i] = (int) seed; } } catch (Throwable t) { diff --git a/com.oracle.truffle.r.native/fficall/Makefile b/com.oracle.truffle.r.native/fficall/Makefile index dbbd428176014064c69dfcefebb80ce6b495f70d..78b1f4b0c3f55fb10f8180ab0b4492966b9645f5 100644 --- a/com.oracle.truffle.r.native/fficall/Makefile +++ b/com.oracle.truffle.r.native/fficall/Makefile @@ -72,7 +72,7 @@ jni.done: $(MAKE) -C src/common all $(MAKE) -C src/jni all ifeq ($(HAVE_SULONG),yes) - $(MAKE) -C src/truffle all + $(MAKE) -C src/truffle_llvm all endif touch jni.done @@ -90,7 +90,7 @@ clean: $(MAKE) -C src/common clean $(MAKE) -C src/jni clean ifeq ($(HAVE_SULONG),yes) - $(MAKE) -C src/truffle clean + $(MAKE) -C src/truffle_llvm clean endif rm -rf $(R_LIB) rm -rf $(JNIBOOT_LIB) diff --git a/com.oracle.truffle.r.native/fficall/src/truffle/Makefile b/com.oracle.truffle.r.native/fficall/src/truffle_llvm/Makefile similarity index 98% rename from com.oracle.truffle.r.native/fficall/src/truffle/Makefile rename to com.oracle.truffle.r.native/fficall/src/truffle_llvm/Makefile index f493f5f594d809918fe148e508e6384ae39e9fcb..99821495d2e45ace8ec7db91c0034b62688c4f92 100644 --- a/com.oracle.truffle.r.native/fficall/src/truffle/Makefile +++ b/com.oracle.truffle.r.native/fficall/src/truffle_llvm/Makefile @@ -1,5 +1,5 @@ # -# Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2014, 2017, 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 diff --git a/com.oracle.truffle.r.native/fficall/src/truffle/README.md b/com.oracle.truffle.r.native/fficall/src/truffle_llvm/README.md similarity index 100% rename from com.oracle.truffle.r.native/fficall/src/truffle/README.md rename to com.oracle.truffle.r.native/fficall/src/truffle_llvm/README.md diff --git a/com.oracle.truffle.r.native/fficall/src/truffle/Rdynload_fastr.c b/com.oracle.truffle.r.native/fficall/src/truffle_llvm/Rdynload_fastr.c similarity index 98% rename from com.oracle.truffle.r.native/fficall/src/truffle/Rdynload_fastr.c rename to com.oracle.truffle.r.native/fficall/src/truffle_llvm/Rdynload_fastr.c index 45eef643d9a124db2d32f59496e422faaf3387a7..5898757681b0d2fce70c0ae8b228210c281684a8 100644 --- a/com.oracle.truffle.r.native/fficall/src/truffle/Rdynload_fastr.c +++ b/com.oracle.truffle.r.native/fficall/src/truffle_llvm/Rdynload_fastr.c @@ -5,7 +5,7 @@ * * Copyright (c) 1995-2012, The R Core Team * Copyright (c) 2003, The R Foundation - * Copyright (c) 2014, 2016, Oracle and/or its affiliates + * Copyright (c) 2014, 2017, Oracle and/or its affiliates * * All rights reserved. */ diff --git a/com.oracle.truffle.r.native/fficall/src/truffle/Rinternals.c b/com.oracle.truffle.r.native/fficall/src/truffle_llvm/Rinternals.c similarity index 99% rename from com.oracle.truffle.r.native/fficall/src/truffle/Rinternals.c rename to com.oracle.truffle.r.native/fficall/src/truffle_llvm/Rinternals.c index d91c866eb705a11d63e948c03a24cfe4d61949f6..ccdcdcd041973e0a3ec5b868d22a004ca18b0a66 100644 --- a/com.oracle.truffle.r.native/fficall/src/truffle/Rinternals.c +++ b/com.oracle.truffle.r.native/fficall/src/truffle_llvm/Rinternals.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2017, 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 diff --git a/com.oracle.truffle.r.native/fficall/src/truffle/caccess.c b/com.oracle.truffle.r.native/fficall/src/truffle_llvm/caccess.c similarity index 95% rename from com.oracle.truffle.r.native/fficall/src/truffle/caccess.c rename to com.oracle.truffle.r.native/fficall/src/truffle_llvm/caccess.c index d07c61c716cf948d2b91d97027a2aa67c0e4b9cc..6743e91b48a8436d2f36d0ae9f41da0926747e0a 100644 --- a/com.oracle.truffle.r.native/fficall/src/truffle/caccess.c +++ b/com.oracle.truffle.r.native/fficall/src/truffle_llvm/caccess.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2017, 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 diff --git a/com.oracle.truffle.r.native/fficall/src/truffle/llvm_dummy.c b/com.oracle.truffle.r.native/fficall/src/truffle_llvm/llvm_dummy.c similarity index 94% rename from com.oracle.truffle.r.native/fficall/src/truffle/llvm_dummy.c rename to com.oracle.truffle.r.native/fficall/src/truffle_llvm/llvm_dummy.c index f786ab945c7932692e6fbecf8c98b9e0b58bac95..4ad1b6b8d8df5d22e2431a5652d1a4fbfe42b8f8 100644 --- a/com.oracle.truffle.r.native/fficall/src/truffle/llvm_dummy.c +++ b/com.oracle.truffle.r.native/fficall/src/truffle_llvm/llvm_dummy.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2017, 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 diff --git a/com.oracle.truffle.r.native/fficall/src/truffle/llvm_dummy.f b/com.oracle.truffle.r.native/fficall/src/truffle_llvm/llvm_dummy.f similarity index 100% rename from com.oracle.truffle.r.native/fficall/src/truffle/llvm_dummy.f rename to com.oracle.truffle.r.native/fficall/src/truffle_llvm/llvm_dummy.f diff --git a/com.oracle.truffle.r.native/fficall/src/truffle/rffiutils.c b/com.oracle.truffle.r.native/fficall/src/truffle_llvm/rffiutils.c similarity index 95% rename from com.oracle.truffle.r.native/fficall/src/truffle/rffiutils.c rename to com.oracle.truffle.r.native/fficall/src/truffle_llvm/rffiutils.c index 82a74a54059453e7fc5731fc9c429b7a8f3949c4..bc39a9ebed13c9b4c21b54f6558f4231ee1a6813 100644 --- a/com.oracle.truffle.r.native/fficall/src/truffle/rffiutils.c +++ b/com.oracle.truffle.r.native/fficall/src/truffle_llvm/rffiutils.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2017, 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 diff --git a/com.oracle.truffle.r.native/fficall/src/truffle/rffiutils.h b/com.oracle.truffle.r.native/fficall/src/truffle_llvm/rffiutils.h similarity index 95% rename from com.oracle.truffle.r.native/fficall/src/truffle/rffiutils.h rename to com.oracle.truffle.r.native/fficall/src/truffle_llvm/rffiutils.h index d4a21793b398c4e34ea2c64f83deac513ec88ba4..2a380ccc847e663f248294608b6566ddf88e9d21 100644 --- a/com.oracle.truffle.r.native/fficall/src/truffle/rffiutils.h +++ b/com.oracle.truffle.r.native/fficall/src/truffle_llvm/rffiutils.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2017, 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 diff --git a/com.oracle.truffle.r.native/fficall/src/truffle/variables.c b/com.oracle.truffle.r.native/fficall/src/truffle_llvm/variables.c similarity index 98% rename from com.oracle.truffle.r.native/fficall/src/truffle/variables.c rename to com.oracle.truffle.r.native/fficall/src/truffle_llvm/variables.c index a9944e5183845b3407a18815dc52638b53caa09f..296aa073f59ca463fe1faf04783c74b201b440e3 100644 --- a/com.oracle.truffle.r.native/fficall/src/truffle/variables.c +++ b/com.oracle.truffle.r.native/fficall/src/truffle_llvm/variables.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2017, 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 diff --git a/documentation/dev/ffi.md b/documentation/dev/ffi.md index 0be78c5bacccd8fc4563b4da07e17bf5c9c1c6a3..96c15ef183eaf5b5489ab3ce391b0f4a77ca38c0 100644 --- a/documentation/dev/ffi.md +++ b/documentation/dev/ffi.md @@ -49,6 +49,6 @@ dependent. In order to support a JNI and a non-JNI implementation, the file is s ## The `jni` directory `jni` contains the implementation that is based on and has explicit dependencies on Java JNI. It is described in more detail [here](jni_ffi.md) -## The `truffle` directory +## The `truffle_llvm` directory -`truffle` contains the native side of the variant that is based on the Truffle LLVM implementation. It is described in more detail [here](truffle_ffi.md) \ No newline at end of file +`truffle` contains the native side of the variant that is based on the Truffle LLVM implementation. It is described in more detail [here](truffle_llvm_ffi.md) \ No newline at end of file diff --git a/documentation/dev/truffle_ffi.md b/documentation/dev/truffle_llvm_ffi.md similarity index 100% rename from documentation/dev/truffle_ffi.md rename to documentation/dev/truffle_llvm_ffi.md diff --git a/mx.fastr/copyrights/overrides b/mx.fastr/copyrights/overrides index 012e56015970dcfb0066ab7f11d1688a8630bd34..5e0730c8e000a7e849b5ddc7b212b38080ef76e2 100644 --- a/mx.fastr/copyrights/overrides +++ b/mx.fastr/copyrights/overrides @@ -141,7 +141,7 @@ com.oracle.truffle.r.native/fficall/src/variable_defs/variable_defs.h,gnu_r.copy com.oracle.truffle.r.native/fficall/src/jni/Memory.c,gnu_r.copyright com.oracle.truffle.r.native/fficall/src/jni/pcre_rffi.c,gnu_r_gentleman_ihaka2.copyright com.oracle.truffle.r.native/fficall/src/jni/Rdynload_fastr.c,gnu_r.copyright -com.oracle.truffle.r.native/fficall/src/truffle/Rdynload_fastr.c,gnu_r.copyright +com.oracle.truffle.r.native/fficall/src/truffle_llvm/Rdynload_fastr.c,gnu_r.copyright com.oracle.truffle.r.native/fficall/src/jni/Rembedded.c,gnu_r.copyright com.oracle.truffle.r.native/include/src/libintl.h,no.copyright com.oracle.truffle.r.native/library/base/src/registration.c,no.copyright diff --git a/mx.fastr/mx_fastr.py b/mx.fastr/mx_fastr.py index ae23ab25f04efa2d6096f993195c49b6c4518656..fbba58aff015a9320c03f816472756010c44622c 100644 --- a/mx.fastr/mx_fastr.py +++ b/mx.fastr/mx_fastr.py @@ -151,7 +151,7 @@ def set_graal_options(): def _sulong_options(): if _mx_sulong: - return ['-Dfastr.ffi.factory.class=com.oracle.truffle.r.engine.interop.ffi.Truffle_RFFIFactory', + return ['-Dfastr.ffi.factory.class=com.oracle.truffle.r.engine.interop.ffi.llvm.TruffleLLVM_RFFIFactory', '-XX:-UseJVMCIClassLoader'] else: return [] diff --git a/mx.fastr/mx_fastr_compile.py b/mx.fastr/mx_fastr_compile.py index 701f3c2a5f7689543111444151572e3865128520..94fac7e4f7dbb70935e2c1e220b35d9b46d62cf4 100644 --- a/mx.fastr/mx_fastr_compile.py +++ b/mx.fastr/mx_fastr_compile.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2016, 2017, 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 @@ -69,7 +69,7 @@ class AnalyzedArgs: def _c_dummy_file(): - return os.path.join(mx_fastr._fastr_suite.dir, 'com.oracle.truffle.r.native', 'fficall', 'src', 'truffle', 'llvm_dummy.c') + return os.path.join(mx_fastr._fastr_suite.dir, 'com.oracle.truffle.r.native', 'fficall', 'src', 'truffle_llvm', 'llvm_dummy.c') def _analyze_args(args, dragonEgg=False): '''