Packages

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

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.

Source
Interface.scala
Linear Supertypes
Interface[F, MemType], AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Memory
  2. Interface
  3. AnyRef
  4. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Instance Constructors

  1. new Memory()(implicit F: MonadError[F, Throwable])

Abstract Value Members

  1. abstract def size: Int

    Returns the size in bytes of this memory instance.

  2. abstract def tpe: MemType

    Returns the type of this interface element.

    Returns the type of this interface element.

    Definition Classes
    Interface
  3. abstract def unsafeGrow(by: Int): Boolean
  4. abstract def unsafeReadByte(idx: Int): Byte
  5. abstract def unsafeReadBytes(idx: Int, length: Int): Array[Byte]
  6. abstract def unsafeReadDouble(idx: Int): Double
  7. abstract def unsafeReadFloat(idx: Int): Float
  8. abstract def unsafeReadInt(idx: Int): Int
  9. abstract def unsafeReadLong(idx: Int): Long
  10. abstract def unsafeReadShort(idx: Int): Short
  11. abstract def unsafeWriteByte(idx: Int, v: Byte): Unit
  12. abstract def unsafeWriteBytes(idx: Int, bytes: ByteBuffer): Unit
  13. abstract def unsafeWriteDouble(idx: Int, v: Double): Unit
  14. abstract def unsafeWriteFloat(idx: Int, v: Float): Unit
  15. abstract def unsafeWriteInt(idx: Int, v: Int): Unit
  16. abstract def unsafeWriteLong(idx: Int, v: Long): Unit
  17. abstract def unsafeWriteShort(idx: Int, v: Short): Unit

Concrete Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##: Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  5. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native() @HotSpotIntrinsicCandidate()
  6. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  7. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  8. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  9. def grow(by: Int): F[Boolean]

    Tries to grow the available space by by pages.

    Tries to grow the available space by by pages.

    Instances should use the constant swam.runtime.pageSize to ensure the correct page size is always used even if it changes in subsequent versions. This method should never throw an exception. If growing is not possible, whatever the reason, it must simply return false.

  10. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  11. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  12. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  13. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  14. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  15. def readByte(idx: Int): F[Byte]

    Reads a byte at the given index in memory.

    Reads a byte at the given index in memory.

    Implementations need not check for boundaries in this method since the Swam engine already checks it.

  16. def readBytes(idx: Int, length: Int): F[Array[Byte]]

    Reads the bytes in the provided buffer at the given index in memory.

    Reads the bytes in the provided buffer at the given index in memory.

    This method is used by Swam to initialize the memory upon module instantiation and should not be used otherwise.

    Implementations need not check for boundaries in this method since the Swam engine already checks it.

  17. def readDouble(idx: Int): F[Double]

    Reads a double at the given index in memory.

    Reads a double at the given index in memory.

    Implementations need not check for boundaries in this method since the Swam engine already checks it.

  18. def readFloat(idx: Int): F[Float]

    Reads a float at the given index in memory.

    Reads a float at the given index in memory.

    Implementations need not check for boundaries in this method since the Swam engine already checks it.

  19. def readInt(idx: Int): F[Int]

    Reads a integer at the given index in memory.

    Reads a integer at the given index in memory.

    Implementations need not check for boundaries in this method since the Swam engine already checks it.

  20. def readLong(idx: Int): F[Long]

    Reads a long at the given index in memory.

    Reads a long at the given index in memory.

    Implementations need not check for boundaries in this method since the Swam engine already checks it.

  21. def readShort(idx: Int): F[Short]

    Reads a short at the given index in memory.

    Reads a short at the given index in memory.

    Implementations need not check for boundaries in this method since the Swam engine already checks it.

  22. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  23. def toString(): String
    Definition Classes
    AnyRef → Any
  24. def unsafeWriteBytes(idx: Int, bytes: Array[Byte]): Unit
  25. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  26. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()
  27. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  28. def writeByte(idx: Int, v: Byte): F[Unit]

    Writes a byte at the given index in memory.

    Writes a byte at the given index in memory.

    Implementations need not check for boundaries in this method since the Swam engine already checks it.

  29. def writeBytes(idx: Int, bytes: Array[Byte]): F[Unit]
  30. def writeBytes(idx: Int, bytes: ByteBuffer): F[Unit]

    Writes the bytes in the provided buffer at the given index in memory.

    Writes the bytes in the provided buffer at the given index in memory.

    This method is used by Swam to initialize the memory upon module instantiation and should not be used otherwise.

    Implementations need not check for boundaries in this method since the Swam engine already checks it.

  31. def writeDouble(idx: Int, v: Double): F[Unit]

    Writes a double at the given index in memory.

    Writes a double at the given index in memory.

    Implementations need not check for boundaries in this method since the Swam engine already checks it.

  32. def writeFloat(idx: Int, v: Float): F[Unit]

    Writes a float at the given index in memory.

    Writes a float at the given index in memory.

    Implementations need not check for boundaries in this method since the Swam engine already checks it.

  33. def writeInt(idx: Int, v: Int): F[Unit]

    Writes a integer at the given index in memory.

    Writes a integer at the given index in memory.

    Implementations need not check for boundaries in this method since the Swam engine already checks it.

  34. def writeLong(idx: Int, v: Long): F[Unit]

    Writes a long at the given index in memory.

    Writes a long at the given index in memory.

    Implementations need not check for boundaries in this method since the Swam engine already checks it.

  35. def writeShort(idx: Int, v: Short): F[Unit]

    Writes a short at the given index in memory.

    Writes a short at the given index in memory.

    Implementations need not check for boundaries in this method since the Swam engine already checks it.

Deprecated Value Members

  1. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable]) @Deprecated @deprecated
    Deprecated

    (Since version ) see corresponding Javadoc for more information.

Inherited from Interface[F, MemType]

Inherited from AnyRef

Inherited from Any

Ungrouped