WebAssembly / binaryen

Optimizer and compiler/toolchain library for WebAssembly
Apache License 2.0
7.43k stars 735 forks source link

Are there any limits on nested blocks/loops in binaryen ? #6830

Open hgruniaux opened 1 month ago

hgruniaux commented 1 month ago

The question is in the title.

I searched in the code, and I found nothing. I am curious to know if there are any limits in the parser or the static analyzer for the depth of nested blocks or loops.

Also, do you know if such limits exist in current engines?

Thanks in advance.

kripken commented 1 month ago

I don't believe there is a specific limit for such nesting. Here is the V8 file with such limits:

https://github.com/v8/v8/blob/main/src/wasm/wasm-limits.h

I don't recall this being an issue in the past, either in V8 or Binaryen or elsewhere. It is common to have many thousands of nested blocks in practice for various switch constructs, for example.

hgruniaux commented 1 month ago

Thanks for your answer!