Search in sources :

Example 1 with ElemSym

use of org.graalvm.wasm.Linker.ResolutionDag.ElemSym in project graal by oracle.

the class Linker method resolveElemSegment.

void resolveElemSegment(WasmContext context, WasmInstance instance, int elemSegmentId, int offsetAddress, int offsetGlobalIndex, int[] functionsIndices) {
    final Runnable resolveAction = () -> immediatelyResolveElemSegment(context, instance, elemSegmentId, offsetAddress, offsetGlobalIndex, functionsIndices);
    final ArrayList<Sym> dependencies = new ArrayList<>();
    if (instance.symbolTable().importedTable() != null) {
        dependencies.add(new ImportTableSym(instance.name(), instance.symbolTable().importedTable()));
    }
    if (elemSegmentId > 0) {
        dependencies.add(new ElemSym(instance.name(), elemSegmentId - 1));
    }
    if (offsetGlobalIndex != -1) {
        dependencies.add(new InitializeGlobalSym(instance.name(), offsetGlobalIndex));
    }
    for (final int functionIndex : functionsIndices) {
        final WasmFunction function = instance.module().function(functionIndex);
        if (function.importDescriptor() != null) {
            dependencies.add(new ImportFunctionSym(instance.name(), function.importDescriptor(), function.index()));
        }
    }
    resolutionDag.resolveLater(new ElemSym(instance.name(), elemSegmentId), dependencies.toArray(new Sym[dependencies.size()]), resolveAction);
}
Also used : ElemSym(org.graalvm.wasm.Linker.ResolutionDag.ElemSym) ImportTableSym(org.graalvm.wasm.Linker.ResolutionDag.ImportTableSym) ElemSym(org.graalvm.wasm.Linker.ResolutionDag.ElemSym) ExportMemorySym(org.graalvm.wasm.Linker.ResolutionDag.ExportMemorySym) ExportTableSym(org.graalvm.wasm.Linker.ResolutionDag.ExportTableSym) InitializeGlobalSym(org.graalvm.wasm.Linker.ResolutionDag.InitializeGlobalSym) ExportFunctionSym(org.graalvm.wasm.Linker.ResolutionDag.ExportFunctionSym) CodeEntrySym(org.graalvm.wasm.Linker.ResolutionDag.CodeEntrySym) CallsiteSym(org.graalvm.wasm.Linker.ResolutionDag.CallsiteSym) ImportMemorySym(org.graalvm.wasm.Linker.ResolutionDag.ImportMemorySym) ExportGlobalSym(org.graalvm.wasm.Linker.ResolutionDag.ExportGlobalSym) ImportFunctionSym(org.graalvm.wasm.Linker.ResolutionDag.ImportFunctionSym) Sym(org.graalvm.wasm.Linker.ResolutionDag.Sym) ImportTableSym(org.graalvm.wasm.Linker.ResolutionDag.ImportTableSym) ImportGlobalSym(org.graalvm.wasm.Linker.ResolutionDag.ImportGlobalSym) DataSym(org.graalvm.wasm.Linker.ResolutionDag.DataSym) ArrayList(java.util.ArrayList) InitializeGlobalSym(org.graalvm.wasm.Linker.ResolutionDag.InitializeGlobalSym) ImportFunctionSym(org.graalvm.wasm.Linker.ResolutionDag.ImportFunctionSym)

Aggregations

ArrayList (java.util.ArrayList)1 CallsiteSym (org.graalvm.wasm.Linker.ResolutionDag.CallsiteSym)1 CodeEntrySym (org.graalvm.wasm.Linker.ResolutionDag.CodeEntrySym)1 DataSym (org.graalvm.wasm.Linker.ResolutionDag.DataSym)1 ElemSym (org.graalvm.wasm.Linker.ResolutionDag.ElemSym)1 ExportFunctionSym (org.graalvm.wasm.Linker.ResolutionDag.ExportFunctionSym)1 ExportGlobalSym (org.graalvm.wasm.Linker.ResolutionDag.ExportGlobalSym)1 ExportMemorySym (org.graalvm.wasm.Linker.ResolutionDag.ExportMemorySym)1 ExportTableSym (org.graalvm.wasm.Linker.ResolutionDag.ExportTableSym)1 ImportFunctionSym (org.graalvm.wasm.Linker.ResolutionDag.ImportFunctionSym)1 ImportGlobalSym (org.graalvm.wasm.Linker.ResolutionDag.ImportGlobalSym)1 ImportMemorySym (org.graalvm.wasm.Linker.ResolutionDag.ImportMemorySym)1 ImportTableSym (org.graalvm.wasm.Linker.ResolutionDag.ImportTableSym)1 InitializeGlobalSym (org.graalvm.wasm.Linker.ResolutionDag.InitializeGlobalSym)1 Sym (org.graalvm.wasm.Linker.ResolutionDag.Sym)1