Skip to content

Commit

Permalink
fix grow by count metadata prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
chenyan-dfinity committed Sep 25, 2023
1 parent 8b16ddd commit a68ac0c
Show file tree
Hide file tree
Showing 10 changed files with 12 additions and 8 deletions.
9 changes: 5 additions & 4 deletions src/instrumentation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,9 @@ fn make_stable_writer(m: &mut Module, vars: &Variables, config: &Config) -> Func
.func_body()
.global_get(vars.page_size)
.i32_const(65536)
.binop(BinaryOp::I32Mul);
.binop(BinaryOp::I32Mul)
.i32_const(METADATA_SIZE)
.binop(BinaryOp::I32Sub);
}
builder
.func_body()
Expand Down Expand Up @@ -568,9 +570,8 @@ fn inject_canister_methods(m: &mut Module, vars: &Variables) {
ExportItem::Function(id)
if e.name != "canister_update __motoko_async_helper"
&& (e.name.starts_with("canister_update")
// don't clear logs for query method, as we cannot store the logs anyway
//|| e.name.starts_with("canister_query")
//|| e.name.starts_with("canister_composite_query")
|| e.name.starts_with("canister_query")
|| e.name.starts_with("canister_composite_query")
|| e.name.starts_with("canister_heartbeat")
// don't clear logs for timer and post_upgrade, as they are trigger by other signals
//|| e.name == "canister_global_timer"
Expand Down
7 changes: 5 additions & 2 deletions tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@ To regenerate the Wasm file:
```motoko
import Region "mo:base/Region";
actor {
let profiling = Region.new();
ignore Region.grow(profiling, 32);
stable let profiling = do {
let r = Region.new();
ignore Region.grow(r, 32);
r;
};
...
}
```
Expand Down
4 changes: 2 additions & 2 deletions tests/deployable.ic-repl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,11 @@ let S = counter(file("ok/motoko-gc-instrument.wasm"));
check_profiling(S, 250, 4);
let wasm = file("ok/motoko-region-instrument.wasm");
let S = counter(wasm);
check_profiling(S, 463589, 78);
check_profiling(S, 463666, 78);
upgrade(S, wasm);
call S.get();
assert _ == (45 : nat);
check_profiling(S, 472223, 374);
check_profiling(S, 474294, 460);
counter(file("ok/motoko-shrink.wasm"));
counter(file("ok/motoko-limit.wasm"));

Expand Down
Binary file modified tests/motoko-region.wasm
Binary file not shown.
Binary file modified tests/ok/motoko-gc-instrument.wasm
Binary file not shown.
Binary file modified tests/ok/motoko-instrument.wasm
Binary file not shown.
Binary file modified tests/ok/motoko-region-instrument.wasm
Binary file not shown.
Binary file modified tests/ok/rust-instrument.wasm
Binary file not shown.
Binary file modified tests/ok/rust-region-instrument.wasm
Binary file not shown.
Binary file modified tests/ok/wat-instrument.wasm
Binary file not shown.

0 comments on commit a68ac0c

Please sign in to comment.