Skip to content

Commit

Permalink
Fix mem instruction parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
virgil-serbanuta committed Jan 27, 2025
1 parent 5703267 commit d9a126d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
14 changes: 12 additions & 2 deletions pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/instr.md
Original file line number Diff line number Diff line change
Expand Up @@ -509,9 +509,19 @@ module BINARY-PARSER-INSTR
rule #parseInstrx62s1(memArgResult(MemArg2:MemArg, BWI:BytesWithIndex)) => instrResult(#store(i64, store32, getMemArgOffset(MemArg2)), BWI)
rule #parseInstrx62s1(E:ParseError) => E
syntax InstrResult ::= parseInstrx63(BytesWithIndex) [function, total]
rule parseInstrx63(BWI:BytesWithIndex) => instrResult(memory.size, BWI)
syntax InstrResult ::= #parseInstrx63s1
( BytesWithIndexOrError
) [function, total]
rule parseInstrx63(BWI) => #parseInstrx63s1(parseConstant(BWI, b"\x00"))
rule #parseInstrx63s1(BWI:BytesWithIndex) => instrResult(memory.size, BWI)
rule #parseInstrx63s1(E:ParseError) => E
syntax InstrResult ::= parseInstrx64(BytesWithIndex) [function, total]
rule parseInstrx64(BWI:BytesWithIndex) => instrResult(memory.grow, BWI)
syntax InstrResult ::= #parseInstrx64s1
( BytesWithIndexOrError
) [function, total]
rule parseInstrx64(BWI) => #parseInstrx64s1(parseConstant(BWI, b"\x00"))
rule #parseInstrx64s1(BWI:BytesWithIndex) => instrResult(memory.grow, BWI)
rule #parseInstrx64s1(E:ParseError) => E
syntax InstrResult ::= parseInstrx65(BytesWithIndex) [function, total]
syntax InstrResult ::= #parseInstrx65s1
( IntResult
Expand Down
4 changes: 2 additions & 2 deletions pykwasm/src/pykwasm/scripts/binary-parser-gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,8 +404,8 @@ def with_prefix(self, p: bytes) -> 'InstrConfig':
InstrConfig('I64_STORE_8', b'\x3C', [constructor_arg('i64'), constructor_arg('store8'), 'MemArg', ], '#store'),
InstrConfig('I64_STORE_16', b'\x3D', [constructor_arg('i64'), constructor_arg('store16'), 'MemArg', ], '#store'),
InstrConfig('I64_STORE_32', b'\x3E', [constructor_arg('i64'), constructor_arg('store32'), 'MemArg', ], '#store'),
InstrConfig('MEM_SIZE', b'\x3F', [], 'memory.size'),
InstrConfig('MEM_GROW', b'\x40', [], 'memory.grow'),
InstrConfig('MEM_SIZE', b'\x3F', [parse_constant(b'\x00')], 'memory.size'),
InstrConfig('MEM_GROW', b'\x40', [parse_constant(b'\x00')], 'memory.grow'),
InstrConfig('MEM_INIT', b'\xFC\x08', ['UnsignedInt', parse_constant(b'\x00'), ], not_implemented()),
InstrConfig('DATA_DROP', b'\xFC\x09', ['UnsignedInt', ], not_implemented()),
InstrConfig('MEM_COPY', b'\xFC\x0A', [parse_constant(b'\x00'), parse_constant(b'\x00'), ], 'memory.copy'),
Expand Down

0 comments on commit d9a126d

Please sign in to comment.