Skip to content
Snippets Groups Projects
Commit df4ac095 authored by stepan's avatar stepan
Browse files

UpCalls should not return optimized promises, return the value instead

parent d231a024
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
/*
* 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?
*/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment