File: 216-Fix-bytecode-iteration-to-handle-EXTENDED_ARG-as-jump.patch

package info (click to toggle)
numba 0.56.4%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 23,672 kB
  • sloc: python: 183,651; ansic: 15,370; cpp: 2,259; javascript: 424; sh: 308; makefile: 174
file content (33 lines) | stat: -rw-r--r-- 1,361 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
From 1af5b2c34ed4794ae925aa2761d73a816ff21bd2 Mon Sep 17 00:00:00 2001
From: Stuart Archibald <stuartarchibald@users.noreply.github.com>
Origin: https://github.com/numba/numba/pull/8639
Date: Tue, 29 Nov 2022 11:26:38 +0000
Subject: [PATCH 16/20] Fix bytecode iteration to handle EXTENDED_ARG as jump
 target.

As title.
---
 numba/core/bytecode.py | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/numba/core/bytecode.py b/numba/core/bytecode.py
index 4f5d449dd04..6305751d424 100644
--- a/numba/core/bytecode.py
+++ b/numba/core/bytecode.py
@@ -155,7 +155,15 @@ def _unpack_opargs(code):
                 arg |= code[i + j] << (8 * j)
             i += ARG_LEN
             if op == EXTENDED_ARG:
+                # This is a deviation from what dis does...
+                # In python 3.11 it seems like EXTENDED_ARGs appear more often
+                # and are also used as jump targets. So as to not have to do
+                # "book keeping" for where EXTENDED_ARGs have been "skipped"
+                # they are replaced with NOPs so as to provide a legal jump
+                # target and also ensure that the bytecode offsets are correct.
+                yield (offset, OPCODE_NOP, arg, i)
                 extended_arg = arg << 8 * ARG_LEN
+                offset = i
                 continue
         else:
             arg = None