Skip to content

Replace stdin with preinitialized input buffer #96

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

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jeffcharles
Copy link
Contributor

Instead of using WASI standard input to get input, have the host call an exported function to initialize an in-memory buffer for the input, then copy the input into the buffer, then reset the fuel counter and call the function. This excludes our code that loads the data from the limits imposed on the partner function (though we could choose to subject this function to the limits as well) and replaces n hostcalls with a single call to an exported function to setup the input.

@@ -91,6 +99,7 @@ fn run_example(example: &str, input_bytes: Vec<u8>) -> Result<(Vec<u8>, u64)> {

let instance = linker.instantiate(&mut store, &module)?;

store.set_fuel(STARTING_FUEL)?;
Copy link
Member

Choose a reason for hiding this comment

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

One note here: I think we want to set the fuel before the previous line e.g.,

store.set_fuel(STARTING_FUEL)?;
let instance = linker.instantiate(&mut store, &module)?;

since there's code that could run at instantiation time, e.g., the start function.

@@ -43,7 +43,7 @@ fn assert_fuel_consumed_within_threshold(target_fuel: u64, fuel_consumed: u64) {
}
}

fn run_example(example: &str, input_bytes: Vec<u8>) -> Result<(Vec<u8>, u64)> {
fn run_example(example: &str, input_bytes: Vec<u8>, use_wasi: bool) -> Result<(Vec<u8>, u64)> {
Copy link
Member

Choose a reason for hiding this comment

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

Minor nit: what do you think of avoiding the usage of bool params?

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