mirror of
https://github.com/fluencelabs/wasm-utils
synced 2025-05-27 22:51:20 +00:00
Merge pull request #54 from paritytech/fix-grow
Fix grow_memory transform
This commit is contained in:
commit
3feb8da52b
@ -41,16 +41,15 @@ fn add_grow_counter(module: elements::Module, rules: &rules::Set, gas_func: u32)
|
||||
let mut b = builder::from_module(module);
|
||||
b.push_function(
|
||||
builder::function()
|
||||
.signature().params().i32().i32().build().with_return_type(Some(elements::ValueType::I32)).build()
|
||||
.signature().params().i32().build().with_return_type(Some(elements::ValueType::I32)).build()
|
||||
.body()
|
||||
.with_opcodes(elements::Opcodes::new(vec![
|
||||
GetLocal(0),
|
||||
GetLocal(0),
|
||||
I32Const(rules.grow_cost() as i32),
|
||||
I32Mul,
|
||||
TeeLocal(1),
|
||||
// todo: there should be strong guarantee that it does not return anything on stack?
|
||||
Call(gas_func),
|
||||
GetLocal(1),
|
||||
GrowMemory(0),
|
||||
GetLocal(0),
|
||||
End,
|
||||
@ -241,12 +240,11 @@ mod tests {
|
||||
);
|
||||
assert_eq!(
|
||||
&vec![
|
||||
GetLocal(0),
|
||||
GetLocal(0),
|
||||
I32Const(10000),
|
||||
I32Mul,
|
||||
TeeLocal(1),
|
||||
Call(0),
|
||||
GetLocal(1),
|
||||
GrowMemory(0),
|
||||
GetLocal(0),
|
||||
End,
|
||||
|
Loading…
x
Reference in New Issue
Block a user