diff --git a/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/common/JavaUpCallsRFFIImpl.java b/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/common/JavaUpCallsRFFIImpl.java index 967be7aeeff45a46ba52aeeec43e85ae574f509f..9c89ec3258afce7e357a46d969db49005a1e40c4 100644 --- a/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/common/JavaUpCallsRFFIImpl.java +++ b/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/common/JavaUpCallsRFFIImpl.java @@ -131,8 +131,6 @@ import sun.misc.Unsafe; */ public abstract class JavaUpCallsRFFIImpl implements UpCallsRFFI { - private final Map<String, Object> nameSymbolCache = new ConcurrentHashMap<>(); - private static RuntimeException implementedAsNode() { // TODO: Exception handling over native boundaries is currently missing. Once this works, // remove the following two lines. @@ -270,6 +268,11 @@ public abstract class JavaUpCallsRFFIImpl implements UpCallsRFFI { while (env != REnvironment.emptyEnv()) { Object value = env.get(name.getName()); if (value != null) { + if (value instanceof RPromise && ((RPromise) value).isOptimized()) { + // From the point of view of RFFI, optimized promises (i.e. promises with null + // env) should not show up + return ((RPromise) value).getRawValue(); + } return value; } if (!inherits) { @@ -350,12 +353,7 @@ public abstract class JavaUpCallsRFFIImpl implements UpCallsRFFI { @Override @TruffleBoundary public Object Rf_install(String name) { - Object ret = nameSymbolCache.get(name); - if (ret == null) { - ret = RDataFactory.createSymbolInterned(name); - nameSymbolCache.put(name, ret); - } - return ret; + return RDataFactory.createSymbolInterned(name); } @Override diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/RPromise.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/RPromise.java index 8f4bc9a99b1ab10abef07b05c514614fafe3da45..acf61beac80b4fda379e5b6517a6084091d2608f 100644 --- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/RPromise.java +++ b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/RPromise.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2018, 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 @@ -215,6 +215,14 @@ public class RPromise extends RObject implements RTypedValue { this.value = newValue; } + /** + * Promises to constants can be optimized, which means that they only hold the value, but do not + * need to keep the frame and will never need the frame. + */ + public boolean isOptimized() { + return this.execFrame == null; + } + /** * Returns {@code true} if this promise has been evaluated? */