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

memory imports #124

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

memory imports #124

wants to merge 3 commits into from

Conversation

george-cosma
Copy link
Collaborator

Pull Request Overview

This pull request adds/changes/fixes...

Testing Strategy

This pull request was tested by...

TODO or Help Wanted

This pull request still needs...

Formatting

  • Ran cargo fmt
  • Ran cargo check
  • Ran cargo build
  • Ran cargo doc
  • Ran nix fmt

Github Issue

This pull request closes <GITHUB_ISSUE>

Copy link

codecov bot commented Jan 29, 2025

Codecov Report

Attention: Patch coverage is 73.29545% with 94 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/execution/interpreter_loop.rs 64.05% 78 Missing ⚠️
src/execution/store.rs 26.66% 11 Missing ⚠️
src/core/reader/types/import.rs 0.00% 1 Missing and 1 partial ⚠️
src/execution/lut.rs 93.54% 1 Missing and 1 partial ⚠️
src/validation/mod.rs 95.45% 1 Missing ⚠️
Files with missing lines Coverage Δ
src/execution/execution_info.rs 100.00% <100.00%> (ø)
src/execution/mod.rs 92.59% <100.00%> (+0.65%) ⬆️
src/validation/code.rs 63.85% <100.00%> (+0.04%) ⬆️
src/validation/mod.rs 82.60% <95.45%> (+1.39%) ⬆️
src/core/reader/types/import.rs 26.31% <0.00%> (ø)
src/execution/lut.rs 96.10% <93.54%> (+0.10%) ⬆️
src/execution/store.rs 71.42% <26.66%> (-13.99%) ⬇️
src/execution/interpreter_loop.rs 90.26% <64.05%> (-1.98%) ⬇️

@george-cosma george-cosma marked this pull request as draft January 31, 2025 10:08
Comment on lines +130 to +132
if imported_memories.len() > 1 {
return Err(Error::MoreThanOneMemory);
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
if imported_memories.len() > 1 {
return Err(Error::MoreThanOneMemory);
}
#[cfg(not(multiple_memories))] // maybe without this
if local_memories.len() + imported_memories.len() > 1 {
return Err(Error::MoreThanOneMemory);
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

In the multiple memories proposal, can you have more than 1 local memory? Or is it multiple local, multiple imported?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Looking through the code, I disagree. We have bits in execution_info that MUST have a single memory otherwise it panics.

Comment on lines +118 to 120
if local_memories.len() > 1 {
return Err(Error::MoreThanOneMemory);
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
if local_memories.len() > 1 {
return Err(Error::MoreThanOneMemory);
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

not under #cfg?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Looking through the code, I disagree. We have bits in execution_info that MUST have a single memory otherwise it panics.

@@ -441,7 +469,7 @@ where
ty: *ty,
locals,
code_expr,
// TODO fix this ugly clone
// TODO: Not used any more. Should we remove it?
sidetable: sidetable.clone(),
Copy link
Collaborator

Choose a reason for hiding this comment

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

we should remove this, otherwise there might be confusion

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@cemonem agree?


self.module_map
.insert(module_name.to_string(), self.modules.len());
self.modules.push(exec_info);

let local_sidetables = validation_info
Copy link
Collaborator

Choose a reason for hiding this comment

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

Since Sidetables are not supposed to be modified after initialization, would it be better if we'd attach them to the FunctionDeclarations?

Mr. Titzer does the exact same thing where the Sidetable is attached to its corresponding FuncDecl.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Letting them attatched to FunctionInst gives us headaches in terms of rust optimizations

What I am doing there is not to modify the sidetables, I am just shoving them in an array (and syncing it with function indexing by inserting dummy tables for imported functions which are not used anyway)

@@ -477,9 +493,12 @@ pub(super) fn run<H: HookSet>(
let mem = modules[*current_module_idx]
.store
.mems
.first()
.first_mut()
Copy link
Collaborator

Choose a reason for hiding this comment

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

I still think we should shrink down the interpreter loop massively through the use of macros

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I thought you loved +4000 lines of code changed D:
Jokes aside, I agree that we should abstract away some parts of the interpreter loop, though I'm not sure I agree with macros.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

check element / look at the get_mem function. Abstracting it any more isn't worthwhile imho. ctrl+f works fast enough

@george-cosma george-cosma marked this pull request as ready for review February 4, 2025 19:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants