Skip to content

Commit 9814099

Browse files
committed
[GR-65045] Fix shared arena support for layers.
PullRequest: graal/20862
2 parents c460f60 + b7e3d5b commit 9814099

File tree

2 files changed

+17
-13
lines changed

2 files changed

+17
-13
lines changed

substratevm/src/com.oracle.svm.hosted.foreign/src/com/oracle/svm/hosted/foreign/ForeignFunctionsFeature.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -664,6 +664,10 @@ protected void initSafeArenaAccessors(BeforeAnalysisAccessImpl access) throws No
664664
registerSafeArenaAccessorMethod(metaAccess, ReflectionUtil.lookupMethod(mappedMemoryUtils, "isLoaded", long.class, boolean.class, long.class));
665665
registerSafeArenaAccessorMethod(metaAccess, ReflectionUtil.lookupMethod(mappedMemoryUtils, "unload", long.class, boolean.class, long.class));
666666
registerSafeArenaAccessorMethod(metaAccess, ReflectionUtil.lookupMethod(SubstrateMappedMemoryUtils.class, "load", long.class, boolean.class, long.class));
667+
668+
// the actual method checking a valid session state (if not inlined) is also safe as this
669+
// one would yield the error
670+
registerSafeArenaAccessorMethod(metaAccess, ReflectionUtil.lookupMethod(MemorySessionImpl.class, "checkValidStateRaw"));
667671
}
668672

669673
protected void registerSafeArenaAccessorClass(MetaAccessProvider metaAccess, Class<?> klass) {

substratevm/src/com.oracle.svm.hosted.foreign/src/com/oracle/svm/hosted/foreign/phases/SubstrateOptimizeSharedArenaAccessPhase.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -645,10 +645,9 @@ private static EconomicSet<DominatedCall> insertSessionChecks(StructuredGraph gr
645645
// Compute the graph with all the necessary data about scoped memory accesses.
646646
EconomicSet<DominatedCall> calls = EconomicSet.create();
647647
EconomicMap<Node, List<ScopedAccess>> sugaredGraph = enumerateScopedAccesses(cfg, context, calls);
648-
if (sugaredGraph == null) {
649-
return null;
648+
if (sugaredGraph != null) {
649+
ReentrantBlockIterator.apply(new MinimalSessionChecks(graph, sugaredGraph, cfg, calls), cfg.getStartBlock());
650650
}
651-
ReentrantBlockIterator.apply(new MinimalSessionChecks(graph, sugaredGraph, cfg, calls), cfg.getStartBlock());
652651
return calls;
653652
}
654653

@@ -754,16 +753,6 @@ protected NodeBitMap cloneState(NodeBitMap oldState) {
754753
* are not needed any more.
755754
*/
756755
private void cleanupClusterNodes(StructuredGraph graph, MidTierContext context, EconomicSet<DominatedCall> calls) {
757-
if (VERIFY_NO_DOMINATED_CALLS) {
758-
if (calls != null) {
759-
for (DominatedCall call : calls) {
760-
if (call.invoke.isAlive()) {
761-
throw GraalError.shouldNotReachHere("After inserting all session checks call " + call.invoke + " was not inlined and could access a session");
762-
}
763-
}
764-
}
765-
}
766-
767756
for (MemoryArenaValidInScopeNode scopeNode : graph.getNodes().filter(MemoryArenaValidInScopeNode.class).snapshot()) {
768757
scopeNode.delete(0);
769758
}
@@ -775,6 +764,17 @@ private void cleanupClusterNodes(StructuredGraph graph, MidTierContext context,
775764
}
776765
canonicalizer.apply(graph, context);
777766
scheduleVerify(graph);
767+
768+
if (VERIFY_NO_DOMINATED_CALLS) {
769+
if (calls != null) {
770+
for (DominatedCall call : calls) {
771+
if (call.invoke.isAlive()) {
772+
throw GraalError.shouldNotReachHere("After inserting all session checks call " + call.invoke + " was not inlined and could access a session");
773+
}
774+
}
775+
}
776+
}
777+
778778
}
779779

780780
/**

0 commit comments

Comments
 (0)