Class CanonicalABI

java.lang.Object
ai.tegmentum.webassembly4j.runtime.marshal.CanonicalABI

public final class CanonicalABI extends Object
Static utilities for Component Model Canonical ABI layout calculations.
  • Method Details

    • alignTo

      public static int alignTo(int offset, int alignment)
      Aligns an offset up to the given alignment boundary.
      Parameters:
      offset - the current offset
      alignment - the required alignment (must be a power of 2)
      Returns:
      the aligned offset
    • recordSize

      public static int recordSize(TypeLayout... fields)
      Computes the total size of a record with the given field layouts, including padding for alignment.
      Parameters:
      fields - the field layouts in order
      Returns:
      the total record size in bytes (padded to record alignment)
    • fieldOffsets

      public static int[] fieldOffsets(TypeLayout... fields)
      Computes the byte offset of each field in a record.
      Parameters:
      fields - the field layouts in order
      Returns:
      an array of byte offsets, one per field
    • recordAlignment

      public static int recordAlignment(TypeLayout... fields)
      Computes the alignment of a record, which is the maximum alignment of its fields.
      Parameters:
      fields - the field layouts
      Returns:
      the record alignment in bytes