Class ByteArrayMemory

java.lang.Object
com.dylibso.chicory.runtime.ByteArrayMemory
All Implemented Interfaces:
Memory

public final class ByteArrayMemory extends Object implements Memory
Represents the linear memory in the Wasm program. Can be shared reference b/w the host and the guest. try-catch is faster than explicit checks and can be optimized by the JVM. Catching generic RuntimeException to keep the method bodies short and easily inlinable.
  • Constructor Details

  • Method Details

    • pages

      public int pages()
      Gets the size of the memory in number of pages
      Specified by:
      pages in interface Memory
    • grow

      public int grow(int size)
      Specified by:
      grow in interface Memory
    • initialPages

      public int initialPages()
      Specified by:
      initialPages in interface Memory
    • maximumPages

      public int maximumPages()
      Specified by:
      maximumPages in interface Memory
    • initialize

      public void initialize(Instance instance, DataSegment[] dataSegments)
      Specified by:
      initialize in interface Memory
    • initPassiveSegment

      public void initPassiveSegment(int segmentId, int dest, int offset, int size)
      Specified by:
      initPassiveSegment in interface Memory
    • write

      public void write(int addr, byte[] data, int offset, int size)
      Specified by:
      write in interface Memory
    • read

      public byte read(int addr)
      Specified by:
      read in interface Memory
    • readBytes

      public byte[] readBytes(int addr, int len)
      Specified by:
      readBytes in interface Memory
    • writeI32

      public void writeI32(int addr, int data)
      Specified by:
      writeI32 in interface Memory
    • readInt

      public int readInt(int addr)
      Specified by:
      readInt in interface Memory
    • writeLong

      public void writeLong(int addr, long data)
      Specified by:
      writeLong in interface Memory
    • readLong

      public long readLong(int addr)
      Specified by:
      readLong in interface Memory
    • writeShort

      public void writeShort(int addr, short data)
      Specified by:
      writeShort in interface Memory
    • readShort

      public short readShort(int addr)
      Specified by:
      readShort in interface Memory
    • readU16

      public long readU16(int addr)
      Specified by:
      readU16 in interface Memory
    • writeByte

      public void writeByte(int addr, byte data)
      Specified by:
      writeByte in interface Memory
    • writeF32

      public void writeF32(int addr, float data)
      Specified by:
      writeF32 in interface Memory
    • readF32

      public long readF32(int addr)
      Specified by:
      readF32 in interface Memory
    • readFloat

      public float readFloat(int addr)
      Specified by:
      readFloat in interface Memory
    • writeF64

      public void writeF64(int addr, double data)
      Specified by:
      writeF64 in interface Memory
    • readDouble

      public double readDouble(int addr)
      Specified by:
      readDouble in interface Memory
    • readF64

      public long readF64(int addr)
      Specified by:
      readF64 in interface Memory
    • zero

      public void zero()
      Specified by:
      zero in interface Memory
    • fill

      public void fill(byte value, int fromIndex, int toIndex)
      Specified by:
      fill in interface Memory
    • drop

      public void drop(int segment)
      Specified by:
      drop in interface Memory