Skip to content

Commit dff76ed

Browse files
committed
[GR-35569] Fixing compilation of LoadModulesNode failing.
PullRequest: graal/10560
2 parents 91cc0f5 + dcbe637 commit dff76ed

File tree

3 files changed

+14
-36
lines changed

3 files changed

+14
-36
lines changed

sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/LLVMAlias.java

Lines changed: 10 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2018, 2021, Oracle and/or its affiliates.
2+
* Copyright (c) 2018, 2022, Oracle and/or its affiliates.
33
*
44
* All rights reserved.
55
*
@@ -29,33 +29,25 @@
2929
*/
3030
package com.oracle.truffle.llvm.runtime;
3131

32-
import com.oracle.truffle.api.CompilerDirectives.CompilationFinal;
33-
import com.oracle.truffle.llvm.runtime.except.LLVMLinkerException;
3432
import com.oracle.truffle.llvm.runtime.global.LLVMGlobal;
35-
import org.graalvm.collections.EconomicSet;
36-
import org.graalvm.collections.Equivalence;
3733

3834
public class LLVMAlias extends LLVMSymbol {
3935

40-
@CompilationFinal private LLVMSymbol target;
36+
private final LLVMSymbol target;
4137

4238
public LLVMAlias(String name, LLVMSymbol target, boolean exported) {
4339
super(name, IDGenerater.INVALID_ID, LLVMSymbol.INVALID_INDEX, exported, false);
44-
setTarget(target);
40+
if (target instanceof LLVMAlias) {
41+
this.target = ((LLVMAlias) target).getTarget();
42+
} else {
43+
this.target = target;
44+
}
4545
}
4646

4747
public LLVMSymbol getTarget() {
4848
return target;
4949
}
5050

51-
public void setTarget(LLVMSymbol value) {
52-
this.target = value;
53-
if (target instanceof LLVMAlias) {
54-
EconomicSet<LLVMAlias> visited = EconomicSet.create(Equivalence.IDENTITY);
55-
checkForCycle(this, visited);
56-
}
57-
}
58-
5951
@Override
6052
public boolean isFunction() {
6153
return target.isFunction();
@@ -86,25 +78,11 @@ public String toString() {
8678
return super.getName() + " -> " + target.toString();
8779
}
8880

89-
private void checkForCycle(LLVMAlias alias, EconomicSet<LLVMAlias> visited) {
90-
if (visited.contains(alias)) {
91-
throw new LLVMLinkerException("Found a cycle between the following aliases: " + visited.toString());
92-
}
93-
visited.add(alias);
94-
if (alias.getTarget() instanceof LLVMAlias) {
95-
checkForCycle((LLVMAlias) alias.getTarget(), visited);
96-
}
97-
}
98-
9981
public static LLVMSymbol resolveAlias(LLVMSymbol symbol) {
100-
if (symbol == null) {
101-
return null;
102-
}
103-
LLVMSymbol tmp = symbol;
104-
while (tmp.isAlias()) {
105-
tmp = ((LLVMAlias) tmp).getTarget();
82+
if (symbol.isAlias()) {
83+
return ((LLVMAlias) symbol).getTarget();
10684
}
107-
return tmp;
85+
return symbol;
10886
}
10987

11088
@Override

sulong/projects/com.oracle.truffle.llvm/src/com/oracle/truffle/llvm/initialization/InitializeOverwriteNode.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020, 2021, Oracle and/or its affiliates.
2+
* Copyright (c) 2020, 2022, Oracle and/or its affiliates.
33
*
44
* All rights reserved.
55
*
@@ -30,6 +30,7 @@
3030
package com.oracle.truffle.llvm.initialization;
3131

3232
import com.oracle.truffle.api.CompilerDirectives.CompilationFinal;
33+
import com.oracle.truffle.api.nodes.ExplodeLoop;
3334
import com.oracle.truffle.llvm.initialization.AllocExternalSymbolNodeFactory.AllocExistingLocalSymbolsNodeGen;
3435
import com.oracle.truffle.llvm.initialization.AllocExternalSymbolNodeFactory.AllocExistingLocalSymbolsNodeGen.AllocExistingGlobalSymbolsNodeGen.AllocExternalGlobalNodeGen;
3536
import com.oracle.truffle.llvm.parser.LLVMParserResult;
@@ -101,6 +102,7 @@ public InitializeOverwriteNode(LLVMParserResult result) {
101102
this.allocExternalSymbols = allocExternaSymbolsList.toArray(AllocExternalSymbolNode.EMPTY);
102103
}
103104

105+
@ExplodeLoop
104106
public void execute(LLVMContext context, LLVMScopeChain localScope, RTLDFlags rtldFlags) {
105107
LLVMScopeChain globalScope = context.getGlobalScopeChain();
106108
for (int i = 0; i < allocExternalSymbols.length; i++) {

sulong/projects/com.oracle.truffle.llvm/src/com/oracle/truffle/llvm/initialization/LoadDependencyNode.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2021, Oracle and/or its affiliates.
2+
* Copyright (c) 2022, Oracle and/or its affiliates.
33
*
44
* All rights reserved.
55
*
@@ -78,8 +78,6 @@ public CallTarget execute() {
7878
return calls;
7979
} else {
8080
Object sourceOrCallTarget = createDependencySource(libraryName, libraryName, file);
81-
// A source is null if it's a native library, which will be added to the NFI
82-
// context extension instead.
8381
if (sourceOrCallTarget instanceof Source) {
8482
return getContext().getEnv().parseInternal((Source) sourceOrCallTarget);
8583
} else if (sourceOrCallTarget instanceof CallTarget) {

0 commit comments

Comments
 (0)