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 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
|
From: Siu Kwan Lam <1929845+sklam@users.noreply.github.com>
Origin: https://github.com/numba/numba/pull/8545
Date: Fri, 9 Sep 2022 12:45:11 -0500
Subject: Add more BACKWARD jump and PUSH_NULL.
---
numba/core/bytecode.py | 5 ++++-
numba/core/byteflow.py | 13 ++++++++++++-
numba/core/interpreter.py | 12 ++++++++++++
3 files changed, 28 insertions(+), 2 deletions(-)
diff --git a/numba/core/bytecode.py b/numba/core/bytecode.py
index 5bdd0be..6b7bb0f 100644
--- a/numba/core/bytecode.py
+++ b/numba/core/bytecode.py
@@ -91,7 +91,10 @@ class ByteCodeInst(object):
# https://github.com/python/cpython/pull/25069
assert self.is_jump
if PYVERSION >= (3, 11):
- if self.opcode == dis.opmap["JUMP_BACKWARD"]:
+ if self.opcode in (dis.opmap[k]
+ for k in ("JUMP_BACKWARD",
+ "POP_JUMP_BACKWARD_IF_TRUE",
+ "POP_JUMP_BACKWARD_IF_FALSE")):
return self.offset - self.arg * 2
if PYVERSION >= (3, 10):
if self.opcode in JREL_OPS:
diff --git a/numba/core/byteflow.py b/numba/core/byteflow.py
index a02c171..4655663 100644
--- a/numba/core/byteflow.py
+++ b/numba/core/byteflow.py
@@ -297,6 +297,9 @@ class TraceRunner(object):
def op_PRECALL(self, state, inst):
state.append(inst)
+ def op_PUSH_NULL(self, state, inst):
+ state.append(inst)
+
def op_FORMAT_VALUE(self, state, inst):
"""
FORMAT_VALUE(flags): flags argument specifies format spec which is
@@ -649,13 +652,21 @@ class TraceRunner(object):
def op_POP_JUMP_FORWARD_IF_FALSE(self, state, inst):
self._op_POP_JUMP_IF(state, inst)
+ def op_POP_JUMP_FORWARD_IF_TRUE(self, state, inst):
+ self._op_POP_JUMP_IF(state, inst)
+
+ def op_POP_JUMP_BACKWARD_IF_FALSE(self, state, inst):
+ self._op_POP_JUMP_IF(state, inst)
+
+ def op_POP_JUMP_BACKWARD_IF_TRUE(self, state, inst):
+ self._op_POP_JUMP_IF(state, inst)
+
def op_JUMP_FORWARD(self, state, inst):
state.append(inst)
state.fork(pc=inst.get_jump_target())
def op_JUMP_BACKWARD(self, state, inst):
state.append(inst)
- print(inst)
state.fork(pc=inst.get_jump_target())
def op_JUMP_ABSOLUTE(self, state, inst):
diff --git a/numba/core/interpreter.py b/numba/core/interpreter.py
index de3c93d..f5de300 100644
--- a/numba/core/interpreter.py
+++ b/numba/core/interpreter.py
@@ -1718,6 +1718,9 @@ class Interpreter(object):
def op_PRECALL(self, inst):
pass
+ def op_PUSH_NULL(self, inst):
+ pass
+
def op_PRINT_ITEM(self, inst, item, printvar, res):
item = self.get(item)
printgv = ir.Global("print", print, loc=self.loc)
@@ -2699,6 +2702,15 @@ class Interpreter(object):
def op_POP_JUMP_FORWARD_IF_FALSE(self, inst, pred):
self._op_JUMP_IF(inst, pred=pred, iftrue=False)
+ def op_POP_JUMP_FORWARD_IF_TRUE(self, inst, pred):
+ self._op_JUMP_IF(inst, pred=pred, iftrue=True)
+
+ def op_POP_JUMP_BACKWARD_IF_FALSE(self, inst, pred):
+ self._op_JUMP_IF(inst, pred=pred, iftrue=False)
+
+ def op_POP_JUMP_BACKWARD_IF_TRUE(self, inst, pred):
+ self._op_JUMP_IF(inst, pred=pred, iftrue=True)
+
def op_POP_JUMP_IF_FALSE(self, inst, pred):
self._op_JUMP_IF(inst, pred=pred, iftrue=False)
|