Skip to content

Conversation

Copy link

Copilot AI commented May 21, 2025

Changes

This PR implements the i64.load instruction in the WebAssembly interpreter, enabling 64-bit memory loads.

The changes include:

  1. Added a readInt64 method to the Memory class to support reading 64-bit integers from memory
  2. Created an I64Load class in Module.java extending MemoryAccess to implement the instruction's functionality
  3. Updated Parser.java to handle the i64.load instruction (opcode 0x29)

Implementation Details

The readInt64 method reads memory in 32-bit chunks and combines them into a 64-bit value:

long readInt64(int address) {
    return (readInt32(address) & 0xFFFFFFFFL) | ((long)readInt32(address + 4) << 32);
}

The new I64Load class follows the same pattern as existing load instructions:

final static class I64Load extends MemoryAccess {
    I64Load(int align, int offset) {
        super(align, offset);
    }

    @Override
    Value readMemory(Memory memory, int address) {
        return new Value(memory.readInt64(address));
    }
}

All tests are passing with these changes.

Fixes #4.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: hisano <76080+hisano@users.noreply.github.com>
Copilot AI changed the title [WIP] i64.load命令の追加 Implement i64.load instruction in WebAssembly interpreter May 21, 2025
Copilot AI requested a review from hisano May 21, 2025 00:28
Copilot finished work on behalf of hisano May 21, 2025 00:28
@hisano
Copy link
Owner

hisano commented May 21, 2025

テストケースも追加して。

Co-authored-by: hisano <76080+hisano@users.noreply.github.com>
Copy link
Author

Copilot AI commented May 21, 2025

テストケースも追加して。

I've added a test for the i64.load instruction in commit 65ecc7a. The test verifies that the implemented functionality correctly reads 64-bit values from memory and returns them as expected.

Copilot finished work on behalf of hisano May 21, 2025 00:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

i64.load命令の追加

2 participants