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
- Alphabetic
- By Inheritance
- Memory
- Interface
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Instance Constructors
- new Memory()(implicit F: MonadError[F, Throwable])
Abstract Value Members
- abstract def size: Int
Returns the size in bytes of this memory instance.
- abstract def tpe: MemType
Returns the type of this interface element.
Returns the type of this interface element.
- Definition Classes
- Interface
- abstract def unsafeGrow(by: Int): Boolean
- abstract def unsafeReadByte(idx: Int): Byte
- abstract def unsafeReadBytes(idx: Int, length: Int): Array[Byte]
- abstract def unsafeReadDouble(idx: Int): Double
- abstract def unsafeReadFloat(idx: Int): Float
- abstract def unsafeReadInt(idx: Int): Int
- abstract def unsafeReadLong(idx: Int): Long
- abstract def unsafeReadShort(idx: Int): Short
- abstract def unsafeWriteByte(idx: Int, v: Byte): Unit
- abstract def unsafeWriteBytes(idx: Int, bytes: ByteBuffer): Unit
- abstract def unsafeWriteDouble(idx: Int, v: Double): Unit
- abstract def unsafeWriteFloat(idx: Int, v: Float): Unit
- abstract def unsafeWriteInt(idx: Int, v: Int): Unit
- abstract def unsafeWriteLong(idx: Int, v: Long): Unit
- abstract def unsafeWriteShort(idx: Int, v: Short): Unit
Concrete Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native() @HotSpotIntrinsicCandidate()
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- 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
. - def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- AnyRef → Any
- def unsafeWriteBytes(idx: Int, bytes: Array[Byte]): Unit
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- 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.
- def writeBytes(idx: Int, bytes: Array[Byte]): F[Unit]
- 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.
- 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.
- 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.
- 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.
- 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.
- 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
- 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.