Skip to content

Commit 1d18b92

Browse files
committed
Merge branch 'topic/fix_memoization_cache' into 'master'
Replace memoization cache map by a hash map Closes #459 See merge request eng/libadalang/langkit-query-language!426
2 parents b32f0ed + 8c202ce commit 1d18b92

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

lkql_jit/language/src/main/java/com/adacore/lkql_jit/nodes/root_nodes/MemoizedRootNode.java

+10-5
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import com.oracle.truffle.api.CompilerDirectives;
99
import com.oracle.truffle.api.TruffleLanguage;
1010
import com.oracle.truffle.api.frame.FrameDescriptor;
11-
import org.graalvm.collections.EconomicMap;
11+
import java.util.HashMap;
1212

1313
/**
1414
* This root node is the base of all root node which can be memoized in LKQL.
@@ -19,8 +19,13 @@ public abstract class MemoizedRootNode<K, V> extends BaseRootNode {
1919

2020
// ----- Attributes -----
2121

22-
/** Cache to store the root node execution results. */
23-
protected final EconomicMap<K, V> memoizationCache;
22+
/**
23+
* Cache to store the root node execution results.
24+
*
25+
* IMPORTANT: We don't use the {@link org.graalvm.collections.EconomicMap} class to represent
26+
* the cache because there is an implementation error causing invalid cache hits.
27+
*/
28+
protected final HashMap<K, V> memoizationCache;
2429

2530
// ----- Constructors -----
2631

@@ -35,7 +40,7 @@ protected MemoizedRootNode(
3540
final FrameDescriptor frameDescriptor
3641
) {
3742
super(language, frameDescriptor);
38-
this.memoizationCache = EconomicMap.create();
43+
this.memoizationCache = new HashMap<>();
3944
}
4045

4146
// ----- Instance methods -----
@@ -59,7 +64,7 @@ protected boolean isMemoized(final K key) {
5964
*/
6065
@CompilerDirectives.TruffleBoundary
6166
protected V getMemoized(final K key) {
62-
return this.memoizationCache.get(key, null);
67+
return this.memoizationCache.get(key);
6368
}
6469

6570
/**

0 commit comments

Comments
 (0)