Skip to content

Commit 6e25248

Browse files
committed
bug
1 parent f97966e commit 6e25248

File tree

4 files changed

+15
-19
lines changed

4 files changed

+15
-19
lines changed

substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/OpenTypeWorldFeature.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,7 @@ public void beforeCompilation(BeforeCompilationAccess access) {
9999
public static void computeIndirectCallTargets(HostedUniverse hUniverse, Map<AnalysisMethod, HostedMethod> methods) {
100100
Map<HostedType, HostedType[]> allInterfacesMap = new HashMap<>();
101101
methods.forEach((aMethod, hMethod) -> {
102-
if (!aMethod.isOriginalMethod()) {
103-
// We don't need to set this; only original methods will be call targets
104-
return;
105-
}
102+
assert aMethod.isOriginalMethod();
106103

107104
var aAlias = calculateIndirectCallTarget(allInterfacesMap, hMethod);
108105
HostedMethod hAlias;

substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/meta/HostedMethod.java

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -395,19 +395,8 @@ public HostedMethod getIndirectCallTarget() {
395395
return indirectCallTarget;
396396
}
397397

398-
void finalizeVTableIndex(boolean closedTypeWorld) {
399-
if (closedTypeWorld) {
400-
/*
401-
* In the closed type word we do not have a different indirectCallTarget, so the
402-
* vtableIndex is always the original vtable index.
403-
*/
404-
indirectCallVTableIndex = computedVTableIndex;
405-
} else {
406-
/*
407-
* In the open type word we must use the vtable index from the indirect call target.
408-
*/
409-
indirectCallVTableIndex = indirectCallTarget.computedVTableIndex;
410-
}
398+
void finalizeIndirectCallVTableIndex() {
399+
indirectCallVTableIndex = indirectCallTarget.computedVTableIndex;
411400
}
412401

413402
@Override
@@ -673,6 +662,9 @@ public HostedMethod getOrCreateMultiMethod(MultiMethodKey key) {
673662
return (HostedMethod) multiMethodMap.computeIfAbsent(key, (k) -> {
674663
HostedMethod newMultiMethod = create0(wrapped, holder, signature, constantPool, handlers, k, multiMethodMap, localVariableTable);
675664
newMultiMethod.implementations = implementations;
665+
newMultiMethod.computedVTableIndex = computedVTableIndex;
666+
newMultiMethod.indirectCallTarget = indirectCallTarget;
667+
newMultiMethod.indirectCallVTableIndex = indirectCallVTableIndex;
676668
return newMultiMethod;
677669
});
678670
}

substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/meta/UniverseBuilder.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,15 @@ public void build(DebugContext debug) {
182182
HostedMethod previous = hUniverse.methods.put(aMethod, origHMethod);
183183
assert previous == null : "Overwriting analysis key";
184184
}
185+
186+
// see SharedMethod#getIndirectCallTarget for more information
185187
if (!SubstrateOptions.useClosedTypeWorldHubLayout()) {
186188
OpenTypeWorldFeature.computeIndirectCallTargets(hUniverse, hUniverse.methods);
189+
} else {
190+
hUniverse.methods.forEach((aMethod, hMethod) -> {
191+
assert aMethod.isOriginalMethod();
192+
hMethod.setIndirectCallTarget(hMethod);
193+
});
187194
}
188195

189196
HostedConfiguration.initializeDynamicHubLayout(hMetaAccess);

substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/meta/VTableBuilder.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,10 @@ public static void buildTables(HostedUniverse hUniverse, HostedMetaAccess hMetaA
6060
VTableBuilder builder = new VTableBuilder(hUniverse, hMetaAccess);
6161
if (SubstrateOptions.useClosedTypeWorldHubLayout()) {
6262
builder.buildClosedTypeWorldVTables();
63-
hUniverse.methods.forEach((k, v) -> v.finalizeVTableIndex(true));
63+
hUniverse.methods.forEach((k, v) -> v.finalizeIndirectCallVTableIndex());
6464
} else {
6565
builder.buildOpenTypeWorldDispatchTables();
66-
hUniverse.methods.forEach((k, v) -> v.finalizeVTableIndex(false));
66+
hUniverse.methods.forEach((k, v) -> v.finalizeIndirectCallVTableIndex());
6767
assert builder.verifyOpenTypeWorldDispatchTables();
6868
}
6969
}

0 commit comments

Comments
 (0)