Search in sources :

Example 6 with Sym

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

the class Linker method resolveTableExport.

void resolveTableExport(WasmModule module, String exportedTableName) {
    final ImportDescriptor importDescriptor = module.symbolTable().importedTable();
    final Sym[] dependencies = importDescriptor != null ? new Sym[] { new ImportTableSym(module.name(), importDescriptor) } : ResolutionDag.NO_DEPENDENCIES;
    resolutionDag.resolveLater(new ExportTableSym(module.name(), exportedTableName), dependencies, NO_RESOLVE_ACTION);
}
Also used : 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) ExportTableSym(org.graalvm.wasm.Linker.ResolutionDag.ExportTableSym)

Example 7 with Sym

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

the class Linker method resolveGlobalExport.

void resolveGlobalExport(WasmModule module, String globalName, int globalIndex) {
    final Sym[] dependencies;
    dependencies = new Sym[] { new InitializeGlobalSym(module.name(), globalIndex) };
    resolutionDag.resolveLater(new ExportGlobalSym(module.name(), globalName), dependencies, NO_RESOLVE_ACTION);
}
Also used : ExportGlobalSym(org.graalvm.wasm.Linker.ResolutionDag.ExportGlobalSym) 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) InitializeGlobalSym(org.graalvm.wasm.Linker.ResolutionDag.InitializeGlobalSym)

Example 8 with Sym

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

the class Linker method resolveMemoryExport.

void resolveMemoryExport(WasmInstance instance, String exportedMemoryName) {
    WasmModule module = instance.module();
    final ImportDescriptor importDescriptor = module.symbolTable().importedMemory();
    final Sym[] dependencies = importDescriptor != null ? new Sym[] { new ImportMemorySym(module.name(), importDescriptor) } : ResolutionDag.NO_DEPENDENCIES;
    resolutionDag.resolveLater(new ExportMemorySym(module.name(), exportedMemoryName), dependencies, () -> {
    });
}
Also used : ImportMemorySym(org.graalvm.wasm.Linker.ResolutionDag.ImportMemorySym) 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) ExportMemorySym(org.graalvm.wasm.Linker.ResolutionDag.ExportMemorySym)

Example 9 with Sym

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

the class Linker method resolveFunctionImport.

void resolveFunctionImport(WasmContext context, WasmInstance instance, WasmFunction function) {
    final Runnable resolveAction = () -> {
        final WasmInstance importedInstance = context.moduleInstances().get(function.importedModuleName());
        if (importedInstance == null) {
            throw WasmException.create(Failure.UNKNOWN_IMPORT, "The module '" + function.importedModuleName() + "', referenced by the import '" + function.importedFunctionName() + "' in the module '" + instance.name() + "', does not exist.");
        }
        WasmFunction importedFunction = importedInstance.module().exportedFunctions().get(function.importedFunctionName());
        if (importedFunction == null) {
            throw WasmException.create(Failure.UNKNOWN_IMPORT, "The imported function '" + function.importedFunctionName() + "', referenced in the module '" + instance.name() + "', does not exist in the imported module '" + function.importedModuleName() + "'.");
        }
        if (!function.type().equals(importedFunction.type())) {
            throw WasmException.create(Failure.INCOMPATIBLE_IMPORT_TYPE);
        }
        final CallTarget target = importedInstance.target(importedFunction.index());
        final WasmFunctionInstance functionInstance = importedInstance.functionInstance(importedFunction);
        instance.setTarget(function.index(), target);
        instance.setFunctionInstance(function.index(), functionInstance);
    };
    final Sym[] dependencies = new Sym[] { new ExportFunctionSym(function.importDescriptor().moduleName, function.importDescriptor().memberName) };
    resolutionDag.resolveLater(new ImportFunctionSym(instance.name(), function.importDescriptor(), function.index()), dependencies, resolveAction);
}
Also used : ExportFunctionSym(org.graalvm.wasm.Linker.ResolutionDag.ExportFunctionSym) CallTarget(com.oracle.truffle.api.CallTarget) 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) ImportFunctionSym(org.graalvm.wasm.Linker.ResolutionDag.ImportFunctionSym)

Example 10 with Sym

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

the class Linker method resolveFunctionExport.

void resolveFunctionExport(WasmModule module, int functionIndex, String exportedFunctionName) {
    final ImportDescriptor importDescriptor = module.symbolTable().function(functionIndex).importDescriptor();
    final Sym[] dependencies = (importDescriptor != null) ? new Sym[] { new ImportFunctionSym(module.name(), importDescriptor, functionIndex) } : ResolutionDag.NO_DEPENDENCIES;
    resolutionDag.resolveLater(new ExportFunctionSym(module.name(), exportedFunctionName), dependencies, NO_RESOLVE_ACTION);
}
Also used : ExportFunctionSym(org.graalvm.wasm.Linker.ResolutionDag.ExportFunctionSym) 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) ImportFunctionSym(org.graalvm.wasm.Linker.ResolutionDag.ImportFunctionSym)

Aggregations

CallsiteSym (org.graalvm.wasm.Linker.ResolutionDag.CallsiteSym)12 CodeEntrySym (org.graalvm.wasm.Linker.ResolutionDag.CodeEntrySym)12 DataSym (org.graalvm.wasm.Linker.ResolutionDag.DataSym)12 ElemSym (org.graalvm.wasm.Linker.ResolutionDag.ElemSym)12 ExportFunctionSym (org.graalvm.wasm.Linker.ResolutionDag.ExportFunctionSym)12 ExportGlobalSym (org.graalvm.wasm.Linker.ResolutionDag.ExportGlobalSym)12 ExportMemorySym (org.graalvm.wasm.Linker.ResolutionDag.ExportMemorySym)12 ExportTableSym (org.graalvm.wasm.Linker.ResolutionDag.ExportTableSym)12 ImportFunctionSym (org.graalvm.wasm.Linker.ResolutionDag.ImportFunctionSym)12 ImportGlobalSym (org.graalvm.wasm.Linker.ResolutionDag.ImportGlobalSym)12 ImportMemorySym (org.graalvm.wasm.Linker.ResolutionDag.ImportMemorySym)12 ImportTableSym (org.graalvm.wasm.Linker.ResolutionDag.ImportTableSym)12 InitializeGlobalSym (org.graalvm.wasm.Linker.ResolutionDag.InitializeGlobalSym)12 Sym (org.graalvm.wasm.Linker.ResolutionDag.Sym)12 ArrayList (java.util.ArrayList)3 CallTarget (com.oracle.truffle.api.CallTarget)1 List (java.util.List)1 WasmMemory (org.graalvm.wasm.memory.WasmMemory)1