[pypy-commit] pypy result-in-resops: make test_compile pass by fixing compile.py

fijal noreply at buildbot.pypy.org
Tue Aug 28 18:08:13 CEST 2012


Author: Maciej Fijalkowski <fijall at gmail.com>
Branch: result-in-resops
Changeset: r56909:cf3f6ddaf7e6
Date: 2012-08-28 18:07 +0200
http://bitbucket.org/pypy/pypy/changeset/cf3f6ddaf7e6/

Log:	make test_compile pass by fixing compile.py

diff --git a/pypy/jit/metainterp/compile.py b/pypy/jit/metainterp/compile.py
--- a/pypy/jit/metainterp/compile.py
+++ b/pypy/jit/metainterp/compile.py
@@ -1,5 +1,5 @@
 import weakref
-from pypy.rpython.lltypesystem import lltype
+from pypy.rpython.lltypesystem import lltype, llmemory
 from pypy.rlib.objectmodel import we_are_translated
 from pypy.rlib.debug import debug_start, debug_stop, debug_print
 from pypy.rlib import rstack
@@ -7,11 +7,12 @@
 from pypy.conftest import option
 from pypy.tool.sourcetools import func_with_new_name
 
-from pypy.jit.metainterp.resoperation import rop, create_resop, ConstInt
+from pypy.jit.metainterp.resoperation import rop, create_resop, ConstInt,\
+     ConstPtr
 from pypy.jit.metainterp.history import TreeLoop, Box, JitCellToken, TargetToken
 from pypy.jit.metainterp.history import AbstractFailDescr, BoxInt
 from pypy.jit.metainterp.history import BoxPtr, BoxFloat
-from pypy.jit.metainterp import history
+from pypy.jit.metainterp import history, resoperation
 from pypy.jit.metainterp.optimize import InvalidLoop
 from pypy.jit.metainterp.inliner import Inliner
 from pypy.jit.metainterp.resume import NUMBERING, PENDINGFIELDSP
@@ -741,7 +742,7 @@
 class ResumeGuardCountersRef(AbstractResumeGuardCounters):
     def __init__(self):
         self.counters = [0] * 5
-        self.values = [history.ConstPtr.value] * 5
+        self.values = [ConstPtr.value] * 5
     see_ref = func_with_new_name(_see, 'see_ref')
 
 class ResumeGuardCountersFloat(AbstractResumeGuardCounters):
@@ -842,33 +843,38 @@
         else: raise AssertionError
         inputargs.append(box)
     k = jitdriver_sd.portal_runner_adr
-    funcbox = history.ConstInt(heaptracker.adr2int(k))
+    funcbox = ConstInt(heaptracker.adr2int(k))
     callargs = [funcbox] + greenboxes + inputargs
     #
     result_type = jitdriver_sd.result_type
-    if result_type == history.INT:
-        result = BoxInt()
-    elif result_type == history.REF:
-        result = BoxPtr()
-    elif result_type == history.FLOAT:
-        result = BoxFloat()
-    elif result_type == history.VOID:
-        result = None
+    jd = jitdriver_sd
+    if result_type == resoperation.INT:
+        op0 = resoperation.create_resop(rop.CALL_i, 0, callargs,
+                                        descr=jd.portal_calldescr)
+    elif result_type == resoperation.REF:
+        null = lltype.nullptr(llmemory.GCREF.TO)
+        op0 = resoperation.create_resop(rop.CALL_p, null, callargs,
+                                        descr=jd.portal_calldescr)
+    elif result_type == resoperation.FLOAT:
+        op0 = resoperation.create_resop(rop.CALL_p, 0.0, callargs,
+                                        descr=jd.portal_calldescr)
+    elif result_type == resoperation.VOID:
+        op0 = resoperation.create_resop(rop.CALL_n, None, callargs,
+                                        descr=jd.portal_calldescr)
     else:
         assert 0, "bad result_type"
-    if result is not None:
-        finishargs = [result]
+    #
+    faildescr = PropagateExceptionDescr()
+    op1 = resoperation.create_resop_0(rop.GUARD_NO_EXCEPTION, None,
+                                      descr=faildescr)
+    op1.set_extra("failargs", [])
+    if result_type != resoperation.VOID:
+        finishargs = [op0]
     else:
         finishargs = []
-    #
-    jd = jitdriver_sd
-    faildescr = PropagateExceptionDescr()
-    operations = [
-        ResOperation(rop.CALL, callargs, result, descr=jd.portal_calldescr),
-        ResOperation(rop.GUARD_NO_EXCEPTION, [], None, descr=faildescr),
-        ResOperation(rop.FINISH, finishargs, None, descr=jd.portal_finishtoken)
-        ]
-    operations[1].setfailargs([])
+    op2 = resoperation.create_resop(rop.FINISH, None, finishargs,
+                                    descr=jd.portal_finishtoken)
+    operations = [op0, op1, op2]
     cpu.compile_loop(inputargs, operations, jitcell_token, log=False)
     if memory_manager is not None:    # for tests
         memory_manager.keep_loop_alive(jitcell_token)
diff --git a/pypy/jit/metainterp/optimizeopt/test/test_optimizeopt.py b/pypy/jit/metainterp/optimizeopt/test/test_optimizeopt.py
--- a/pypy/jit/metainterp/optimizeopt/test/test_optimizeopt.py
+++ b/pypy/jit/metainterp/optimizeopt/test/test_optimizeopt.py
@@ -6,11 +6,10 @@
 import pypy.jit.metainterp.optimizeopt.virtualize as virtualize
 from pypy.jit.metainterp.optimizeopt import build_opt_chain
 from pypy.jit.metainterp.optimize import InvalidLoop
-from pypy.jit.metainterp.history import AbstractDescr, ConstInt, TreeLoop
+from pypy.jit.metainterp.history import AbstractDescr, TreeLoop
 from pypy.jit.metainterp import compile, resume
-from pypy.jit.metainterp.resoperation import rop, opname
+from pypy.jit.metainterp.resoperation import rop, opname, ConstInt
 from pypy.jit.metainterp.optimizeopt.test.test_optimizebasic import FakeMetaInterpStaticData
-from pypy.config.pypyoption import get_pypy_config
 
 def test_build_opt_chain():
     def check(chain, expected_names):
diff --git a/pypy/jit/metainterp/test/test_compile.py b/pypy/jit/metainterp/test/test_compile.py
--- a/pypy/jit/metainterp/test/test_compile.py
+++ b/pypy/jit/metainterp/test/test_compile.py
@@ -1,8 +1,7 @@
 from pypy.config.pypyoption import get_pypy_config
-from pypy.jit.metainterp.history import TargetToken, ConstInt, History, Stats
-from pypy.jit.metainterp.history import BoxInt, INT
+from pypy.jit.metainterp.resoperation import ConstInt
+from pypy.jit.metainterp.history import INT, History, Stats
 from pypy.jit.metainterp.compile import compile_loop
-from pypy.jit.metainterp.compile import ResumeGuardDescr
 from pypy.jit.metainterp.compile import ResumeGuardCountersInt
 from pypy.jit.metainterp.compile import compile_tmp_callback
 from pypy.jit.metainterp import jitprof, typesystem, compile
@@ -64,7 +63,7 @@
     #
     loop = parse('''
     [p1]
-    i1 = getfield_gc(p1, descr=valuedescr)
+    i1 = getfield_gc_i(p1, descr=valuedescr)
     i2 = int_add(i1, 1)
     p2 = new_with_vtable(ConstClass(node_vtable))
     setfield_gc(p2, i2, descr=valuedescr)
diff --git a/pypy/jit/metainterp/virtualref.py b/pypy/jit/metainterp/virtualref.py
--- a/pypy/jit/metainterp/virtualref.py
+++ b/pypy/jit/metainterp/virtualref.py
@@ -1,6 +1,6 @@
 from pypy.rpython.rmodel import inputconst, log
 from pypy.rpython.lltypesystem import lltype, llmemory, rclass
-from pypy.jit.metainterp import history
+from pypy.jit.metainterp import resoperation
 from pypy.jit.codewriter import heaptracker
 from pypy.rlib.jit import InvalidVirtualRef
 
@@ -22,7 +22,7 @@
         # build some constants
         adr = llmemory.cast_ptr_to_adr(self.jit_virtual_ref_vtable)
         adr = heaptracker.adr2int(adr)
-        self.jit_virtual_ref_const_class = history.ConstInt(adr)
+        self.jit_virtual_ref_const_class = resoperation.ConstInt(adr)
         fielddescrof = self.cpu.fielddescrof
         self.descr_virtual_token = fielddescrof(self.JIT_VIRTUAL_REF,
                                                 'virtual_token')


More information about the pypy-commit mailing list