-
Notifications
You must be signed in to change notification settings - Fork 1.7k
WASM Runtime refactoring #6596
WASM Runtime refactoring #6596
Conversation
ethcore/wasm/src/lib.rs
Outdated
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))) |
There was a problem hiding this comment.
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
ethcore/wasm/src/lib.rs
Outdated
) | ||
).map_err(|e| Error(e))?; | ||
let d_ptr = runtime.write_descriptor(params.data.unwrap_or(Vec::with_capacity(0))) | ||
.map_err(|e| Error(e))?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
map_err(Error)
ethcore/wasm/src/runtime.rs
Outdated
@@ -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> { |
There was a problem hiding this comment.
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 updated, thanks |
ethcore/wasm/src/tests.rs
Outdated
@@ -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)); |
There was a problem hiding this comment.
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.
ethcore/wasm/src/tests.rs
Outdated
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)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing _
ethcore/wasm/src/tests.rs
Outdated
@@ -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)); |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
looks ok to me except for the questions/formatting. |
message arguments are not copied to wasm memory always anymore, they can be retrieved by externs as other blockchain-related stuff