Skip to content

Parse current_memory instruction #31

Description

@fermuch

Trying the language poetry, I found WaspVM doesn't currently parse current_memory, which is not mentioned at the specification but seems to be valid on firefox, chrome and nodejs. Related issue on the spec: WebAssembly/design#904

Minimal poetry code which uses current_memory

export_memory "memory"

export "init" init
  return true

WAT file


Traceback of the error

[error][ ] Task #PID<0.1283.0> started from #PID<0.1206.0> terminating
** (RuntimeError) Couldn't parse instruction for current_memory
    (wasp_vm) lib/decoding/instruction_parser.ex:193: WaspVM.Decoder.InstructionParser.parse_instruction/2
    (wasp_vm) lib/decoding/code_section_parser.ex:70: WaspVM.Decoder.CodeSectionParser.parse_bytecode/2
    (wasp_vm) lib/decoding/code_section_parser.ex:36: WaspVM.Decoder.CodeSectionParser.parse_bodies/2
    (wasp_vm) lib/decoding/code_section_parser.ex:12: WaspVM.Decoder.CodeSectionParser.parse/1
    (elixir) lib/task/supervised.ex:90: Task.Supervised.invoke_mfa/2
    (elixir) lib/task/supervised.ex:35: Task.Supervised.reply/5
    (stdlib) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
Function: &:erlang.apply/2
    Args: [#Function<0.26794313/1 in WaspVM.Decoder.parallel_decode/1>, [{10, <<109, 23, 1, 2, 127, 16, 46, 2, 64, 65, 5, 33, 0, 12, 0, 65, 1, 33, 1, 11, 32, 0, 16, 47, 11, 8, 0, 32, 0, 16, 52, 16, 99, 11, 8, 0, 32, 0, 16, 54, 16, 99, 11, 8, 0, ...>>}]]
** (EXIT from #PID<0.1206.0>) shell process exited with reason: an exception was raised:
    ** (RuntimeError) Couldn't parse instruction for current_memory
        (wasp_vm) lib/decoding/instruction_parser.ex:193: WaspVM.Decoder.InstructionParser.parse_instruction/2
        (wasp_vm) lib/decoding/code_section_parser.ex:70: WaspVM.Decoder.CodeSectionParser.parse_bytecode/2
        (wasp_vm) lib/decoding/code_section_parser.ex:36: WaspVM.Decoder.CodeSectionParser.parse_bodies/2
        (wasp_vm) lib/decoding/code_section_parser.ex:12: WaspVM.Decoder.CodeSectionParser.parse/1
        (elixir) lib/task/supervised.ex:90: Task.Supervised.invoke_mfa/2
        (elixir) lib/task/supervised.ex:35: Task.Supervised.reply/5
        (stdlib) proc_lib.erl:249: :proc_lib.init_p_do_apply/3

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions