Commits

Armin Rigo committed 120ed4c

Fix test

Comments (0)

Files changed (1)

pypy/jit/backend/x86/test/test_assembler.py

 from pypy.jit.backend.x86.arch import WORD, IS_X86_32, IS_X86_64
 from pypy.jit.backend.detect_cpu import getcpuclass 
 from pypy.jit.backend.x86.regalloc import X86RegisterManager, X86_64_RegisterManager, X86XMMRegisterManager, X86_64_XMMRegisterManager
+from pypy.jit.backend.llsupport import jitframe
 from pypy.jit.codewriter import longlong
 import ctypes
 import py
     supports_floats = True
     NUM_REGS = ACTUAL_CPU.NUM_REGS
 
+    class gc_ll_descr:
+        kind = "boehm"
+
     def fielddescrof(self, STRUCT, name):
         return 42
 
+    def get_fail_descr_from_number(self, num):
+        assert num == 0x1C3
+        return FakeFailDescr()
+
 class FakeMC:
     def __init__(self):
         self.content = []
     def writechar(self, char):
         self.content.append(ord(char))
 
+class FakeFailDescr:
+    def hide(self, cpu):
+        return rffi.cast(llmemory.GCREF, 123)
+
 def test_write_failure_recovery_description():
     assembler = Assembler386(FakeCPU())
     mc = FakeMC()
     stacklen = baseloc + 30
     stack = lltype.malloc(rffi.LONGP.TO, stacklen, flavor='raw',
                           immortal=True)
-    expected_ints = [0] * len(content)
-    expected_ptrs = [lltype.nullptr(llmemory.GCREF.TO)] * len(content)
-    expected_floats = [longlong.ZEROF] * len(content)
+    expected_ints = [None] * len(content)
+    expected_ptrs = [None] * len(content)
+    expected_floats = [None] * len(content)
 
     def write_in_stack(loc, value):
         assert loc >= 0
 
     # run!
     assembler = Assembler386(FakeCPU())
-    assembler.fail_boxes_int.get_addr_for_num(len(content)-1)   # preallocate
-    assembler.fail_boxes_ptr.get_addr_for_num(len(content)-1)
-    assembler.fail_boxes_float.get_addr_for_num(len(content)-1)
-    res = assembler.failure_recovery_func(registers)
-    assert res == 0x1C3
+    deadframe = assembler.failure_recovery_func(registers)
+    deadframe = lltype.cast_opaque_ptr(jitframe.DEADFRAMEPTR, deadframe)
+    assert deadframe.jf_descr == rffi.cast(llmemory.GCREF, 123)
 
     # check the fail_boxes
     for i in range(len(content)):
-        assert assembler.fail_boxes_int.getitem(i) == expected_ints[i]
-        assert assembler.fail_boxes_ptr.getitem(i) == expected_ptrs[i]
+        if expected_ints[i] is not None:
+            assert deadframe.jf_values[i].int == expected_ints[i]
+        if expected_ptrs[i] is not None:
+            assert deadframe.jf_values[i].ref == expected_ptrs[i]
         # note: we expect *exact* results below.  If you have only
         # an approximate result, it might mean that only the first 32
         # bits of the float were correctly saved and restored.
-        assert assembler.fail_boxes_float.getitem(i) == expected_floats[i]
-
-    # verify that until clear_latest_values() is called, reading the
-    # same values multiple times work
-    for i in range(len(content)):
-        assert assembler.fail_boxes_int.getitem(i) == expected_ints[i]
-        assert assembler.fail_boxes_ptr.getitem(i) == expected_ptrs[i]
-        assert assembler.fail_boxes_float.getitem(i) == expected_floats[i]
+        if expected_floats[i] is not None:
+            assert deadframe.jf_values[i].float == expected_floats[i]
 
 # ____________________________________________________________
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.