Packages

p

swam

runtime

package runtime

This package contains all the classes and types related to running WebAssembly modules.

The entry point for almost all users will be Engine. A typical use of the engine is:

import swam._
import text._
import runtime._
import exports._

import cats.implicits._
import cats.effect._

import java.nio.file.Paths

val tcompiler = Compiler[IO]
val engine = Engine[IO]

for {
  tcompiler <- tcompiler
  engine <- engine
  mod <- engine.compile(/* source of the module */)
  inst <- mod.newInstance()
  f <- inst.exports.function1[Int, Int]("f")
  res <- f(43)
} yield res

println(res.unsafeRunSync())
Source
package.scala
Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. runtime
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Package Members

  1. package config
  2. package formats
  3. package imports
  4. package internals
  5. package memory
  6. package trace
  7. package wasi

Type Members

  1. type CanFail[+T] = Either[String, T]
  2. final class CompileException extends SwamException

    Raised when module compilation is not possible.

  3. case class CompiledData[F[_]](offset: Array[AsmInst[F]], init: ByteBuffer) extends Product with Serializable
  4. case class CompiledElem[F[_]](offset: Array[AsmInst[F]], init: Vector[Int]) extends Product with Serializable
  5. final class ConversionException extends RuntimeException

    Raised when trying to type interface elements with invalid types.

  6. case class Custom(name: String, payload: BitVector) extends Product with Serializable
  7. class Engine[F[_]] extends ModuleLoader[F]

    This is the engine used to compile, instantiate and run modules.

    This is the engine used to compile, instantiate and run modules. It exposes all the needed interface to interact with modules.

    You typically want to reuse the same instance for all your executions over the same effectful type F.

  8. sealed trait Export extends AnyRef
  9. abstract class Function[F[_]] extends Interface[F, FuncType]

    Functions must implement this interface to be used by Swam.

  10. abstract class Global[F[_]] extends Interface[F, GlobalType]

    Globals must implement this interface to be used by Swam.

  11. sealed trait Import extends AnyRef
  12. class Instance[F[_]] extends AnyRef

    A module instance that has already been initialized.

  13. sealed trait Interface[F[_], +T <: Type] extends AnyRef

    All elements that are part of the interface of an instance must implement this interface.

    All elements that are part of the interface of an instance must implement this interface.

    Each specialization defines a specific WebAssembly type that can be imported or exported.

  14. final class LinkException extends SwamException

    Raised when a problem occurs at module instantiation or when required exports are missing.

  15. abstract class Memory[F[_]] extends Interface[F, MemType]

    Memories must implement this interface to be used by Swam.

    Memories must implement this interface to be used by Swam.

    This interface is unsafe, meaning that no exception is expected when calling any method on it. The Swam engine ensures that this does not occur by running only validated WebAssembly code, where size constraints are checked before execution. Implementations must respect the contract of each method.

    This interface is not thread-safe, concurrent access to the same instance may lead to undefined behaviors.

  16. class Module[F[_]] extends AnyRef

    The runtime representation of a validated and compiled module.

  17. sealed class RuntimeException extends SwamException

    Raised when something goes wrong during module execution.

  18. trait StackFrame extends AnyRef

    Interface of a stack frame, making it possible to create a call stack on trap for reporting purpose.

  19. final class StackOverflowException extends RuntimeException

    Raised when call stack overflows.

  20. trait Table[F[_]] extends Interface[F, TableType]

    Tables must implement this interface to be used by Swam.

    Tables must implement this interface to be used by Swam. This interface is unsafe, meaning that no exception is expected when calling any method on it.

    This interface is not thread-safe, concurrent modifications may lead to undefined behaviors.

  21. final class TrapException extends RuntimeException

    Raised when a trap is raised in a module.

  22. sealed abstract class Value extends AnyRef

Value Members

  1. val pageSize: Int

    The size in bytes of a memory page.

  2. object Engine
  3. object Export
  4. object F32
  5. object F64
  6. object I32
  7. object I64
  8. object Import
  9. object Memory
  10. object Value

Inherited from AnyRef

Inherited from Any

Ungrouped