Class InterpreterMachine

java.lang.Object
com.dylibso.chicory.runtime.InterpreterMachine
All Implemented Interfaces:
Machine
Direct Known Subclasses:
CompilerInterpreterMachine

public class InterpreterMachine extends Object implements Machine
This is responsible for holding and interpreting the Wasm code.
  • Field Details

  • Constructor Details

    • InterpreterMachine

      public InterpreterMachine(Instance instance)
  • Method Details

    • evalDefault

      protected void evalDefault(MStack stack, Instance instance, Deque<StackFrame> callStack, com.dylibso.chicory.wasm.types.Instruction instruction, InterpreterMachine.Operands operands) throws com.dylibso.chicory.wasm.ChicoryException
      Throws:
      com.dylibso.chicory.wasm.ChicoryException
    • call

      public long[] call(int funcId, long[] args) throws com.dylibso.chicory.wasm.ChicoryException
      Specified by:
      call in interface Machine
      Throws:
      com.dylibso.chicory.wasm.ChicoryException
    • call

      protected long[] call(MStack stack, Instance instance, Deque<StackFrame> callStack, int funcId, long[] args, com.dylibso.chicory.wasm.types.FunctionType callType, boolean popResults) throws com.dylibso.chicory.wasm.ChicoryException
      Throws:
      com.dylibso.chicory.wasm.ChicoryException
    • instance

      protected Instance instance()
    • stack

      protected MStack stack()
    • eval

      protected void eval(MStack stack, Instance instance, Deque<StackFrame> callStack) throws com.dylibso.chicory.wasm.ChicoryException
      Throws:
      com.dylibso.chicory.wasm.ChicoryException
    • CALL

      protected void CALL(InterpreterMachine.Operands operands)
    • readMemPtr

      protected static int readMemPtr(MStack stack, InterpreterMachine.Operands operands)
    • useCurrentInstanceInterpreter

      protected boolean useCurrentInstanceInterpreter(Instance instance, Instance refInstance, int funcId)
    • THROW_REF

      protected static StackFrame THROW_REF(Instance instance, int exceptionIdx, MStack stack, StackFrame frame, Deque<StackFrame> callStack)
    • extractArgsForParams

      protected static long[] extractArgsForParams(MStack stack, List<com.dylibso.chicory.wasm.types.ValType> params)
    • verifyIndirectCall

      protected static void verifyIndirectCall(com.dylibso.chicory.wasm.types.FunctionType actual, com.dylibso.chicory.wasm.types.FunctionType expected) throws com.dylibso.chicory.wasm.ChicoryException
      Throws:
      com.dylibso.chicory.wasm.ChicoryException