Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

WASM Runtime refactoring #6596

Merged
merged 4 commits into from Oct 4, 2017
Merged

WASM Runtime refactoring #6596

merged 4 commits into from Oct 4, 2017

Conversation

NikVolf
Copy link
Contributor

@NikVolf NikVolf commented Sep 26, 2017

message arguments are not copied to wasm memory always anymore, they can be retrieved by externs as other blockchain-related stuff

@NikVolf NikVolf added A0-pleasereview 🤓 Pull request needs code review. M4-core ⛓ Core client code / Rust. labels Sep 26, 2017
params.data.unwrap_or(Vec::with_capacity(0)),
)
).map_err(|e| Error(e))?;
let d_ptr = runtime.write_descriptor(params.data.unwrap_or(Vec::with_capacity(0)))
Copy link
Contributor

Choose a reason for hiding this comment

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

Vec::new is guaranteed not to allocate. unwrap_or_else would be nicer looking for the same behavior

)
).map_err(|e| Error(e))?;
let d_ptr = runtime.write_descriptor(params.data.unwrap_or(Vec::with_capacity(0)))
.map_err(|e| Error(e))?;
Copy link
Contributor

Choose a reason for hiding this comment

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

map_err(Error)

@@ -442,10 +434,10 @@ impl<'a, 'b> Runtime<'a, 'b> {
}

/// Write call descriptor to wasm memory
pub fn write_descriptor(&mut self, call_args: CallArgs) -> Result<WasmPtr, InterpreterError> {
pub fn write_descriptor(&mut self, input: Vec<u8>) -> Result<WasmPtr, InterpreterError> {
Copy link
Contributor

Choose a reason for hiding this comment

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

seems to only require an &[u8] and not ownership of a Vec

@rphmeier rphmeier added A5-grumble 🔥 Pull request has minor issues that must be addressed before merging. and removed A0-pleasereview 🤓 Pull request needs code review. labels Sep 26, 2017
@NikVolf NikVolf added A0-pleasereview 🤓 Pull request needs code review. and removed A5-grumble 🔥 Pull request has minor issues that must be addressed before merging. labels Sep 26, 2017
@NikVolf
Copy link
Contributor Author

NikVolf commented Sep 26, 2017

@rphmeier updated, thanks

@@ -88,7 +88,7 @@ fn logger() {
};

println!("ext.store: {:?}", ext.store);
assert_eq!(gas_left, U256::from(98417));
assert_eq!(gas_left, U256::from(98731));
Copy link
Contributor

Choose a reason for hiding this comment

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

missing _ for consistency with the others.

sender_address: None,
receive_address: None,
value: Some(1_000_000_000.into()),
data: vec![0u8, 2, 4, 8, 16, 32, 64, 128],
code_address: None,
}
));
assert_eq!(gas_left, U256::from(98_860));
assert_eq!(gas_left, U256::from(99113));
Copy link
Contributor

Choose a reason for hiding this comment

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

missing _

@@ -441,7 +443,7 @@ fn keccak() {
};

assert_eq!(H256::from_slice(&result), H256::from("68371d7e884c168ae2022c82bd837d51837718a7f7dfb7aa3f753074a35e1d87"));
assert_eq!(gas_left, U256::from(84003));
assert_eq!(gas_left, U256::from(84026));
Copy link
Contributor

Choose a reason for hiding this comment

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

missing _ (and others below)

fn sender(&mut self, context: InterpreterCallerContext)
-> Result<Option<interpreter::RuntimeValue>, InterpreterError>
{
let return_ptr = context.value_stack.pop_as::<i32>()? as u32;
Copy link
Contributor

Choose a reason for hiding this comment

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

why doesn't context.value_stack.pop_as::<u32>()? work?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it's not native webassembly type
there are only four i32, i64, f32, f64

@gavofyork
Copy link
Contributor

looks ok to me except for the questions/formatting.

@svyatonik svyatonik added A8-looksgood 🦄 Pull request is reviewed well. and removed A0-pleasereview 🤓 Pull request needs code review. labels Oct 3, 2017
@arkpar arkpar merged commit 4260910 into master Oct 4, 2017
@arkpar arkpar deleted the wasm-ext branch October 4, 2017 11:16
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A8-looksgood 🦄 Pull request is reviewed well. M4-core ⛓ Core client code / Rust.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants