diff --git a/CHANGELOG.md b/CHANGELOG.md index 4d2d7f05c..8692e8ca3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Release notes +## 1.2.4 + +* Updated to rich 11.0 +* Fix a bug in the CIL disassembler for constant double (LDC_R8) opcodes + ## 1.2.3 * Unboxed operations won't update frame last instruction since they're unable to raise exceptions (making them faster) diff --git a/Tests/test_dis.py b/Tests/test_dis.py index 84d92284c..e2008ebb5 100644 --- a/Tests/test_dis.py +++ b/Tests/test_dis.py @@ -1,4 +1,4 @@ -from pyjion.dis import print_il, dis, dis_native, flow_graph +from pyjion.dis import print_il, dis, dis_native, flow_graph, cil_instructions import pyjion import sys import pytest @@ -28,15 +28,30 @@ def test_f(): def test_flow_graph(): - def test_f(): + def f(): numbers = (1, 2, 3, 4) return sum(numbers) - assert test_f() == 10 - graph = flow_graph(test_f) + assert f() == 10 + graph = flow_graph(f) assert "digraph" in graph +def test_jump_offsets(): + def f(): + a = 2 + b = 3.0 + c = 4.0 + c += a * b + return c + assert f() == 10.0 + instructions = cil_instructions(pyjion.il(f), pyjion.symbols(f)) + for i in instructions: + if i.jump_offset: + assert i.jump_offset < instructions[-1].offset + + + @pytest.mark.graph @pytest.mark.nopgc # TODO : Resolve PGC error in dis module. def test_dis_with_offsets(capsys): diff --git a/src/pyjion/dis.py b/src/pyjion/dis.py index 1e8ddab3b..f6c4afd92 100644 --- a/src/pyjion/dis.py +++ b/src/pyjion/dis.py @@ -446,9 +446,9 @@ def cil_instructions(il, symbols) -> List[CILInstruction]: pc += 5 continue elif op.size == InlineR: - [target] = struct.unpack('f', bytes((next(i), next(i), next(i), next(i)))) + target = struct.unpack('d', bytes((next(i), next(i), next(i), next(i), next(i), next(i), next(i), next(i)))) instructions.append(CILInstruction(pc, op, target, None)) - pc += 5 + pc += 9 continue elif op.size == InlineI: target = int.from_bytes((next(i), next(i), next(i), next(i)), byteorder='little', signed=True)