expr icon indicating copy to clipboard operation
expr copied to clipboard

Support long jumps inside an expression

Open danysirota opened this issue 3 years ago • 1 comments

We are generating really long expressions (>1MB) and using conditionals there that can cause more than 64KB jumps. Today, the args of the opcodes are 2 bytes and long jumps are truncated to this size. When running the expression, the VM jumps (actual_offset % 64Kb) and runs invalid opcodes.

danysirota avatar Jun 26 '22 16:06 danysirota

Wow! Such a big expression. Amazing) So, yes. this is a limitation of the current VM.

I see to possible solutions:

  1. Use bigger opcodes (this will require proper benchmarking to make sure be op size performance as the same level).
  2. Or panic on trying to generate too big jump.

antonmedv avatar Jun 26 '22 21:06 antonmedv

Fixed! I refactored vm. Now it uses int for args. So, jumps can be really long. Also it got 50% faster).

antonmedv avatar Nov 05 '22 15:11 antonmedv