Skip to content

Commit

Permalink
Merge branch 'abk/run-825-account-for-instrumentation-in-complexity' …
Browse files Browse the repository at this point in the history
…into 'master'

RUN-825: Account for Call generated by Grow instructions

When validating a Wasm module, we should take into account the fact that
`TableGrow` and `MemoryGrow` instructions end up generating a `Call`
when instrumented. So they should have higher weights. 

See merge request dfinity-lab/public/ic!15675
  • Loading branch information
adambratschikaye committed Oct 30, 2023
2 parents dc09a9c + cbad521 commit 8b7676e
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions rs/embedders/src/wasm_utils/validation.rs
Expand Up @@ -1129,11 +1129,15 @@ fn wasm_function_complexity(body: &Body<'_>) -> Complexity {
| BrIf { .. }
| BrTable { .. }
| Call { .. }
| CallIndirect { .. } => 50,
| CallIndirect { .. }
// `MemoryGrow` and `TableGrow` add `Call` instructions after
// instrumentation.
| MemoryGrow { .. }
| TableGrow { .. } => 50,
TableGet { .. } => 14,
RefFunc { .. } => 8,
TableSet { .. } => 7,
TableGrow { .. } | RefIsNull => 6,
RefIsNull => 6,
TableFill { .. }
| I32TruncF32S
| I32TruncF32U
Expand All @@ -1160,8 +1164,7 @@ fn wasm_function_complexity(body: &Body<'_>) -> Complexity {
| F64Abs
| TableCopy { .. }
| TableInit { .. }
| MemoryCopy { .. }
| MemoryGrow { .. } => 4,
| MemoryCopy { .. } => 4,
F32Copysign
| F64Copysign
| F64Eq
Expand Down

0 comments on commit 8b7676e

Please sign in to comment.