[pypy-commit] pypy jit-leaner-frontend: fix test_pyjitpl

fijal pypy.commits at gmail.com
Tue Mar 22 04:22:50 EDT 2016


Author: fijal
Branch: jit-leaner-frontend
Changeset: r83241:1b06b9d26321
Date: 2016-03-22 10:21 +0200
http://bitbucket.org/pypy/pypy/changeset/1b06b9d26321/

Log:	fix test_pyjitpl

diff --git a/rpython/jit/metainterp/opencoder.py b/rpython/jit/metainterp/opencoder.py
--- a/rpython/jit/metainterp/opencoder.py
+++ b/rpython/jit/metainterp/opencoder.py
@@ -224,10 +224,8 @@
     def __init__(self, inputargs):
         self._ops = [rffi.cast(rffi.SHORT, -15)] * 30000
         self._pos = 0
-        self._snapshot_lgt = 0
         self._consts_bigint = 0
         self._consts_float = 0
-        self._sharings = 0
         self._total_snapshots = 0
         self._consts_ptr = 0
         self._descrs = [None]
@@ -261,9 +259,7 @@
         self._floats_dict = {}
         debug_start("jit-trace-done")
         debug_print("trace length: " + str(self._pos))
-        debug_print(" snapshots: " + str(self._snapshot_lgt))
-        debug_print("  sharings: " + str(self._sharings))
-        debug_print("  total snapshots: " + str(self._total_snapshots))
+        debug_print(" total snapshots: " + str(self._total_snapshots))
         debug_print(" bigint consts: " + str(self._consts_bigint) + " " + str(len(self._bigints)))
         debug_print(" float consts: " + str(self._consts_float) + " " + str(len(self._floats)))
         debug_print(" ref consts: " + str(self._consts_ptr) + " " + str(len(self._refs)))
@@ -356,13 +352,6 @@
         self._descrs.append(descr)
         return len(self._descrs) - 1
 
-    def record_snapshot_link(self, pos):
-        self._sharings += 1
-        lower = pos & 0x7fff
-        upper = pos >> 15
-        self.append(-upper-1)
-        self.append(lower)
-
     def _list_of_boxes(self, boxes):
         array = [rffi.cast(rffi.SHORT, 0)] * len(boxes)
         for i in range(len(boxes)):
diff --git a/rpython/jit/metainterp/test/test_compile.py b/rpython/jit/metainterp/test/test_compile.py
--- a/rpython/jit/metainterp/test/test_compile.py
+++ b/rpython/jit/metainterp/test/test_compile.py
@@ -116,7 +116,6 @@
 
 
 def test_compile_tmp_callback():
-    from rpython.jit.codewriter import heaptracker
     from rpython.jit.backend.llgraph import runner
     from rpython.rtyper.lltypesystem import lltype, llmemory
     from rpython.rtyper.annlowlevel import llhelper
diff --git a/rpython/jit/metainterp/test/test_opencoder.py b/rpython/jit/metainterp/test/test_opencoder.py
--- a/rpython/jit/metainterp/test/test_opencoder.py
+++ b/rpython/jit/metainterp/test/test_opencoder.py
@@ -155,13 +155,6 @@
         loop2.operations = l
         BaseTest.assert_equal(loop1, loop2)
 
-    @given(strategies.integers(min_value=0, max_value=2**25))
-    def test_packing(self, i):
-        t = Trace([])
-        t.record_snapshot_link(i)
-        iter = t.get_iter(metainterp_sd)
-        assert (((-iter._next() - 1) << 15) | (iter._next())) == i
-
     def test_cut_trace_from(self):
         i0, i1, i2 = IntFrontendOp(0), IntFrontendOp(0), IntFrontendOp(0)
         t = Trace([i0, i1, i2])
diff --git a/rpython/jit/metainterp/test/test_pyjitpl.py b/rpython/jit/metainterp/test/test_pyjitpl.py
--- a/rpython/jit/metainterp/test/test_pyjitpl.py
+++ b/rpython/jit/metainterp/test/test_pyjitpl.py
@@ -5,7 +5,7 @@
 from rpython.jit.metainterp import pyjitpl
 from rpython.jit.metainterp import jitprof
 from rpython.jit.metainterp.history import ConstInt
-from rpython.jit.metainterp.history import History
+from rpython.jit.metainterp.history import History, IntFrontendOp
 from rpython.jit.metainterp.resoperation import ResOperation, rop, InputArgInt
 from rpython.jit.metainterp.optimizeopt.util import equaloplists
 from rpython.jit.codewriter.jitcode import JitCode
@@ -82,8 +82,10 @@
         return True
     metainterp = pyjitpl.MetaInterp(FakeStaticData(), None)
     metainterp.history = History()
-    b1 = InputArgInt(1)
-    b2 = InputArgInt(2)
+    b1 = IntFrontendOp(1)
+    b1.setint(1)
+    b2 = IntFrontendOp(2)
+    b2.setint(2)
     c3 = ConstInt(3)
     boxes = [b1, b2, b1, c3]
     dup = {}
@@ -93,21 +95,14 @@
     assert boxes[1] is b2
     assert is_another_box_like(boxes[2], b1)
     assert is_another_box_like(boxes[3], c3)
-    assert equaloplists(metainterp.history.operations, [
+    inp, operations = metainterp.history.trace.unpack(metainterp.staticdata)
+    remap = dict(zip([b1, b2], inp))
+    assert equaloplists(operations, [
         ResOperation(rop.SAME_AS_I, [b1]),
         ResOperation(rop.SAME_AS_I, [c3]),
-        ])
+        ], remap=remap)
     assert dup == {b1: None, b2: None}
     #
-    del metainterp.history.operations[:]
-    b4 = InputArgInt(4)
-    boxes = [b2, b4, "something random"]
-    metainterp.remove_consts_and_duplicates(boxes, 2, dup)
-    assert is_another_box_like(boxes[0], b2)
-    assert boxes[1] is b4
-    assert equaloplists(metainterp.history.operations, [
-        ResOperation(rop.SAME_AS_I, [b2]),
-        ])
 
 def test_get_name_from_address():
     class FakeMetaInterpSd(pyjitpl.MetaInterpStaticData):


More information about the pypy-commit mailing list