Skip to content

Commit

Permalink
Correct 64-bit float (double) instruction disassembly (#472)
Browse files Browse the repository at this point in the history
* Correct 64-bit float (double) instruction disassembly

* Update release notes
  • Loading branch information
tonybaloney authored Jan 10, 2022
1 parent 5425243 commit 658e106
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 6 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
23 changes: 19 additions & 4 deletions Tests/test_dis.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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):
Expand Down
4 changes: 2 additions & 2 deletions src/pyjion/dis.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 658e106

Please sign in to comment.