Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug in memory.init and memory.grow opcodes for fast-jit when multithreading is enabled #2841

Merged

Conversation

TianlongLiang
Copy link
Collaborator

Modify the approach to calculate the offset and access the data members in WASMMemoryInstance when shared memory(multithreading) is enabled. Instead of calculating it from the module instance base address, now use module_inst -> memories[0] as the base address for memory.init, memory.grow, and certain boundary check related APIs.

else if (module->import_memory_count != 0) {
memory_import = &(module->import_memories[mem_idx].u.memory);
is_shared = memory_import->flags & 0x02 ? true : false;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had better:

    if (mem_idx < module->import_memory_count) {
        memory_import = &(module->import_memories[mem_idx].u.memory);
        is_shared = memory_import->flags & 0x02 ? true : false;
    }
    else {
        memory = &module->memories[mem_idx - module->import_memory_count];
        is_shared = memory->flags & 0x02 ? true : false;
    }

We may implement multiple memories feature in the future.

Copy link
Contributor

@wenyongh wenyongh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@wenyongh wenyongh merged commit 3d0342f into bytecodealliance:main Dec 1, 2023
383 checks passed
@TianlongLiang TianlongLiang deleted the dev/fast-jit-threads-memory-fix branch December 4, 2023 02:21
victoryang00 pushed a commit to victoryang00/wamr-aot-gc-checkpoint-restore that referenced this pull request May 27, 2024
…#2841)

For shared memory, runtime should get the memories pointer from
module_inst first, then get memory instance from memories array,
and then get the fields of the memory instance.
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.

2 participants