[pypy-commit] pypy jit-cleanup: Remove ConstRef, NULLREF, CONST_NULL from llhelper

rlamy pypy.commits at gmail.com
Mon Apr 1 11:50:03 EDT 2019


Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: jit-cleanup
Changeset: r96394:f0523017b3da
Date: 2019-04-01 03:52 +0100
http://bitbucket.org/pypy/pypy/changeset/f0523017b3da/

Log:	Remove ConstRef, NULLREF, CONST_NULL from llhelper

diff --git a/rpython/jit/metainterp/history.py b/rpython/jit/metainterp/history.py
--- a/rpython/jit/metainterp/history.py
+++ b/rpython/jit/metainterp/history.py
@@ -186,8 +186,6 @@
             else:
                 intval = lltype.cast_primitive(lltype.Signed, x)
             return ConstInt(intval)
-        elif kind == "ref":
-            return cpu.ts.new_ConstRef(x)
         elif kind == "float":
             return ConstFloat(longlong.getfloatstorage(x))
         else:
@@ -716,7 +714,7 @@
     @specialize.argtype(2)
     def set_op_value(self, op, value):
         if value is None:
-            return        
+            return
         elif isinstance(value, bool):
             op.setint(int(value))
         elif lltype.typeOf(value) == lltype.Signed:
diff --git a/rpython/jit/metainterp/optimizeopt/bridgeopt.py b/rpython/jit/metainterp/optimizeopt/bridgeopt.py
--- a/rpython/jit/metainterp/optimizeopt/bridgeopt.py
+++ b/rpython/jit/metainterp/optimizeopt/bridgeopt.py
@@ -2,6 +2,7 @@
 optimizer of the bridge attached to a guard. """
 
 from rpython.jit.metainterp import resumecode
+from rpython.jit.metainterp.history import Const, ConstInt, CONST_NULL
 
 
 # adds the following sections at the end of the resume code:
@@ -34,7 +35,6 @@
 # maybe should be delegated to the optimization classes?
 
 def tag_box(box, liveboxes_from_env, memo):
-    from rpython.jit.metainterp.history import Const
     if isinstance(box, Const):
         return memo.getconst(box)
     else:
@@ -43,13 +43,12 @@
 def decode_box(resumestorage, tagged, liveboxes, cpu):
     from rpython.jit.metainterp.resume import untag, TAGCONST, TAGINT, TAGBOX
     from rpython.jit.metainterp.resume import NULLREF, TAG_CONST_OFFSET, tagged_eq
-    from rpython.jit.metainterp.history import ConstInt
     num, tag = untag(tagged)
     # NB: the TAGVIRTUAL case can't happen here, because this code runs after
     # virtuals are already forced again
     if tag == TAGCONST:
         if tagged_eq(tagged, NULLREF):
-            box = cpu.ts.CONST_NULL
+            box = CONST_NULL
         else:
             box = resumestorage.rd_consts[num - TAG_CONST_OFFSET]
     elif tag == TAGINT:
@@ -61,7 +60,6 @@
     return box
 
 def serialize_optimizer_knowledge(optimizer, numb_state, liveboxes, liveboxes_from_env, memo):
-    from rpython.jit.metainterp.history import ConstInt
     available_boxes = {}
     for box in liveboxes:
         if box is not None and box in liveboxes_from_env:
@@ -124,7 +122,6 @@
         numb_state.append_int(0)
 
 def deserialize_optimizer_knowledge(optimizer, resumestorage, frontend_boxes, liveboxes):
-    from rpython.jit.metainterp.history import ConstInt
     reader = resumecode.Reader(resumestorage.rd_numb)
     assert len(frontend_boxes) == len(liveboxes)
     metainterp_sd = optimizer.metainterp_sd
diff --git a/rpython/jit/metainterp/optimizeopt/optimizer.py b/rpython/jit/metainterp/optimizeopt/optimizer.py
--- a/rpython/jit/metainterp/optimizeopt/optimizer.py
+++ b/rpython/jit/metainterp/optimizeopt/optimizer.py
@@ -1,6 +1,7 @@
 from rpython.jit.metainterp import jitprof, resume, compile
 from rpython.jit.metainterp.executor import execute_nonspec_const
-from rpython.jit.metainterp.history import Const, ConstInt, ConstPtr
+from rpython.jit.metainterp.history import (
+    Const, ConstInt, ConstPtr, CONST_NULL)
 from rpython.jit.metainterp.optimizeopt.intutils import IntBound,\
      ConstIntBound, MININT, MAXINT, IntUnbounded
 from rpython.jit.metainterp.optimizeopt.util import make_dispatcher_method
@@ -21,7 +22,6 @@
 CONST_0      = ConstInt(0)
 CONST_1      = ConstInt(1)
 CONST_ZERO_FLOAT = Const._new(0.0)
-llhelper.CONST_NULLREF = llhelper.CONST_NULL
 REMOVED = AbstractResOp()
 
 class LoopInfo(object):
@@ -158,7 +158,7 @@
         if isinstance(fw, info.AbstractRawPtrInfo):
             return True
         return False
-    
+
     def getrawptrinfo(self, op, create=False, is_object=False):
         assert op.type == 'i'
         op = self.get_box_replacement(op)
@@ -464,7 +464,7 @@
 
     def make_nonnull_str(self, op, mode):
         from rpython.jit.metainterp.optimizeopt import vstring
-        
+
         op = self.get_box_replacement(op)
         if op.is_constant():
             return
@@ -475,7 +475,7 @@
 
     def ensure_ptr_info_arg0(self, op):
         from rpython.jit.metainterp.optimizeopt import vstring
-        
+
         arg0 = self.get_box_replacement(op.getarg(0))
         if arg0.is_constant():
             return info.ConstPtrInfo(arg0)
@@ -503,7 +503,7 @@
         elif opnum in (rop.GUARD_CLASS, rop.GUARD_NONNULL_CLASS):
             opinfo = info.InstancePtrInfo()
         elif opnum in (rop.STRLEN,):
-            opinfo = vstring.StrPtrInfo(vstring.mode_string)            
+            opinfo = vstring.StrPtrInfo(vstring.mode_string)
         elif opnum in (rop.UNICODELEN,):
             opinfo = vstring.StrPtrInfo(vstring.mode_unicode)
         else:
@@ -515,7 +515,7 @@
 
     def new_const(self, fieldofs):
         if fieldofs.is_pointer_field():
-            return self.cpu.ts.CONST_NULL
+            return CONST_NULL
         elif fieldofs.is_float_field():
             return CONST_ZERO_FLOAT
         else:
@@ -523,7 +523,7 @@
 
     def new_const_item(self, arraydescr):
         if arraydescr.is_array_of_pointers():
-            return self.cpu.ts.CONST_NULL
+            return CONST_NULL
         elif arraydescr.is_array_of_floats():
             return CONST_ZERO_FLOAT
         else:
diff --git a/rpython/jit/metainterp/optimizeopt/rewrite.py b/rpython/jit/metainterp/optimizeopt/rewrite.py
--- a/rpython/jit/metainterp/optimizeopt/rewrite.py
+++ b/rpython/jit/metainterp/optimizeopt/rewrite.py
@@ -1,8 +1,8 @@
 from rpython.jit.codewriter.effectinfo import EffectInfo
 from rpython.jit.codewriter import longlong
 from rpython.jit.metainterp import compile
-from rpython.jit.metainterp.history import (Const, ConstInt, make_hashable_int,
-                                            ConstFloat)
+from rpython.jit.metainterp.history import (
+    Const, ConstInt, make_hashable_int, ConstFloat, CONST_NULL)
 from rpython.jit.metainterp.optimize import InvalidLoop
 from rpython.jit.metainterp.optimizeopt.intutils import IntBound
 from rpython.jit.metainterp.optimizeopt.optimizer import (
@@ -354,7 +354,7 @@
         return self.emit(op)
 
     def postprocess_GUARD_ISNULL(self, op):
-        self.make_constant(op.getarg(0), self.optimizer.cpu.ts.CONST_NULL)
+        self.make_constant(op.getarg(0), CONST_NULL)
 
     def optimize_GUARD_IS_OBJECT(self, op):
         info = self.getptrinfo(op.getarg(0))
diff --git a/rpython/jit/metainterp/optimizeopt/virtualize.py b/rpython/jit/metainterp/optimizeopt/virtualize.py
--- a/rpython/jit/metainterp/optimizeopt/virtualize.py
+++ b/rpython/jit/metainterp/optimizeopt/virtualize.py
@@ -122,8 +122,7 @@
         newop.set_forwarded(vrefvalue)
         token = ResOperation(rop.FORCE_TOKEN, [])
         vrefvalue.setfield(descr_virtual_token, newop, token)
-        vrefvalue.setfield(descr_forced, newop,
-                           self.optimizer.cpu.ts.CONST_NULLREF)
+        vrefvalue.setfield(descr_forced, newop, CONST_NULL)
         return self.emit(token)
 
     def optimize_VIRTUAL_REF_FINISH(self, op):
diff --git a/rpython/jit/metainterp/optimizeopt/vstring.py b/rpython/jit/metainterp/optimizeopt/vstring.py
--- a/rpython/jit/metainterp/optimizeopt/vstring.py
+++ b/rpython/jit/metainterp/optimizeopt/vstring.py
@@ -1,7 +1,7 @@
 from rpython.jit.codewriter.effectinfo import EffectInfo
 from rpython.jit.metainterp.history import (Const, ConstInt, ConstPtr,
     get_const_ptr_for_string, get_const_ptr_for_unicode, REF, INT,
-    DONT_CHANGE)
+    DONT_CHANGE, CONST_NULL)
 from rpython.jit.metainterp.optimizeopt import optimizer
 from rpython.jit.metainterp.optimizeopt.optimizer import CONST_0, CONST_1
 from rpython.jit.metainterp.optimizeopt.optimizer import llhelper, REMOVED
@@ -140,12 +140,12 @@
         srcbox = self.force_box(op, string_optimizer)
         return copy_str_content(string_optimizer, srcbox, targetbox,
                                 CONST_0, offsetbox, lengthbox, mode)
-     
+
 class VStringPlainInfo(StrPtrInfo):
     #_attrs_ = ('mode', '_is_virtual')
 
     _chars = None
-    
+
     def __init__(self, mode, is_virtual, length):
         if length != -1:
             self._chars = [None] * length
@@ -218,7 +218,7 @@
     start = None
     lgtop = None
     s = None
-    
+
     def __init__(self, s, start, length, mode):
         self.s = s
         self.start = start
@@ -271,7 +271,7 @@
     vleft = None
     vright = None
     _is_virtual = False
-    
+
     def __init__(self, mode, vleft, vright, is_virtual):
         self.vleft = vleft
         self.vright = vright
@@ -785,9 +785,8 @@
             if i1 and i1.is_null():
                 self.make_constant(resultop, CONST_1)
                 return True, None
-            op = self.optimizer.replace_op_with(resultop, rop.PTR_EQ,
-                                                [arg1, llhelper.CONST_NULL],
-                                                descr=DONT_CHANGE)
+            op = self.optimizer.replace_op_with(
+                resultop, rop.PTR_EQ, [arg1, CONST_NULL], descr=DONT_CHANGE)
             return True, self.emit(op)
         #
         return False, None
diff --git a/rpython/jit/metainterp/pyjitpl.py b/rpython/jit/metainterp/pyjitpl.py
--- a/rpython/jit/metainterp/pyjitpl.py
+++ b/rpython/jit/metainterp/pyjitpl.py
@@ -8,7 +8,7 @@
 from rpython.jit.metainterp import history, compile, resume, executor, jitexc
 from rpython.jit.metainterp.heapcache import HeapCache
 from rpython.jit.metainterp.history import (Const, ConstInt, ConstPtr,
-    ConstFloat, TargetToken, MissingValue, SwitchToBlackhole)
+    ConstFloat, CONST_NULL, TargetToken, MissingValue, SwitchToBlackhole)
 from rpython.jit.metainterp.jitprof import EmptyProfiler
 from rpython.jit.metainterp.logger import Logger
 from rpython.jit.metainterp.optimizeopt.util import args_dict
@@ -136,9 +136,12 @@
             # is not defined yet.
             argcode = self._result_argcode
             index = ord(self.bytecode[self.pc - 1])
-            if   argcode == 'i': self.registers_i[index] = history.CONST_FALSE
-            elif argcode == 'r': self.registers_r[index] = history.CONST_NULL
-            elif argcode == 'f': self.registers_f[index] = history.CONST_FZERO
+            if argcode == 'i':
+                self.registers_i[index] = history.CONST_FALSE
+            elif argcode == 'r':
+                self.registers_r[index] = CONST_NULL
+            elif argcode == 'f':
+                self.registers_f[index] = history.CONST_FZERO
             self._result_argcode = '?'     # done
         #
         info = self.get_current_position_info()
@@ -269,11 +272,11 @@
 
     @arguments("box")
     def opimpl_ptr_nonzero(self, box):
-        return self.execute(rop.PTR_NE, box, history.CONST_NULL)
+        return self.execute(rop.PTR_NE, box, CONST_NULL)
 
     @arguments("box")
     def opimpl_ptr_iszero(self, box):
-        return self.execute(rop.PTR_EQ, box, history.CONST_NULL)
+        return self.execute(rop.PTR_EQ, box, CONST_NULL)
 
     @arguments("box")
     def opimpl_assert_not_none(self, box):
@@ -931,8 +934,7 @@
         token_descr = vinfo.vable_token_descr
         mi = self.metainterp
         tokenbox = mi.execute_and_record(rop.GETFIELD_GC_R, token_descr, box)
-        condbox = mi.execute_and_record(rop.PTR_NE, None, tokenbox,
-                                       history.CONST_NULL)
+        condbox = mi.execute_and_record(rop.PTR_NE, None, tokenbox, CONST_NULL)
         funcbox = ConstInt(rffi.cast(lltype.Signed, vinfo.clear_vable_ptr))
         calldescr = vinfo.clear_vable_descr
         self.execute_varargs(rop.COND_CALL, [condbox, funcbox, box],
@@ -1495,7 +1497,7 @@
         vref = vrefbox.getref_base()
         if vrefinfo.is_virtual_ref(vref):
             # XXX write a comment about nullbox
-            nullbox = self.metainterp.cpu.ts.CONST_NULL
+            nullbox = CONST_NULL
             metainterp.history.record(rop.VIRTUAL_REF_FINISH,
                                       [vrefbox, nullbox], None)
 
@@ -2957,7 +2959,7 @@
         # CALL_xxx is recorded
         self.history.record(rop.VIRTUAL_REF_FINISH, [vrefbox, virtualbox], None)
         # mark this situation by replacing the vrefbox with ConstPtr(NULL)
-        self.virtualref_boxes[i+1] = self.cpu.ts.CONST_NULL
+        self.virtualref_boxes[i+1] = CONST_NULL
 
     def handle_possible_exception(self):
         if self.last_exc_value:
@@ -3075,7 +3077,7 @@
                                             abox, ConstInt(j), itembox)
             assert i + 1 == len(self.virtualizable_boxes)
             # we're during tracing, so we should not execute it
-            self.history.record(rop.SETFIELD_GC, [vbox, self.cpu.ts.CONST_NULL],
+            self.history.record(rop.SETFIELD_GC, [vbox, CONST_NULL],
                                 None, descr=vinfo.vable_token_descr)
 
     def replace_box(self, oldbox, newbox):
diff --git a/rpython/jit/metainterp/quasiimmut.py b/rpython/jit/metainterp/quasiimmut.py
--- a/rpython/jit/metainterp/quasiimmut.py
+++ b/rpython/jit/metainterp/quasiimmut.py
@@ -42,7 +42,7 @@
 def do_force_quasi_immutable(cpu, p, mutatefielddescr):
     qmut_ref = cpu.bh_getfield_gc_r(p, mutatefielddescr)
     if qmut_ref:
-        cpu.bh_setfield_gc_r(p, cpu.ts.NULLREF, mutatefielddescr)
+        cpu.bh_setfield_gc_r(p, ConstPtr.value, mutatefielddescr)
         qmut_ptr = lltype.cast_opaque_ptr(rclass.OBJECTPTR, qmut_ref)
         qmut = cast_base_ptr_to_instance(QuasiImmut, qmut_ptr)
         qmut.invalidate()
@@ -109,7 +109,7 @@
     # fields
     struct = lltype.nullptr(llmemory.GCREF.TO)
     fielddescr = None
-    
+
     def __init__(self, cpu, struct, fielddescr, mutatefielddescr):
         self.cpu = cpu
         self.struct = struct
diff --git a/rpython/jit/metainterp/resume.py b/rpython/jit/metainterp/resume.py
--- a/rpython/jit/metainterp/resume.py
+++ b/rpython/jit/metainterp/resume.py
@@ -1,8 +1,8 @@
 from rpython.jit.codewriter.effectinfo import EffectInfo
 from rpython.jit.metainterp import jitprof
-from rpython.jit.metainterp.history import (Const, ConstInt, getkind,
-    INT, REF, FLOAT, AbstractDescr, IntFrontendOp, RefFrontendOp,
-    FloatFrontendOp)
+from rpython.jit.metainterp.history import (
+    Const, ConstInt, ConstPtr, getkind, INT, REF, FLOAT, CONST_NULL,
+    AbstractDescr, IntFrontendOp, RefFrontendOp, FloatFrontendOp)
 from rpython.jit.metainterp.resoperation import rop
 from rpython.rlib import rarithmetic, rstack
 from rpython.rlib.objectmodel import (we_are_translated, specialize,
@@ -241,7 +241,7 @@
                     is_virtual = (info is not None and info.is_virtual())
                 if box.type == 'i':
                     info = optimizer.getrawptrinfo(box, create=False)
-                    is_virtual = (info is not None and info.is_virtual()) 
+                    is_virtual = (info is not None and info.is_virtual())
                 if is_virtual:
                     tagged = tag(num_virtuals, TAGVIRTUAL)
                     num_virtuals += 1
@@ -471,7 +471,7 @@
 
     def _number_virtuals(self, liveboxes, optimizer, num_env_virtuals):
         from rpython.jit.metainterp.optimizeopt.info import AbstractVirtualPtrInfo
-        
+
         # !! 'liveboxes' is a list that is extend()ed in-place !!
         memo = self.memo
         new_liveboxes = [None] * memo.num_cached_boxes()
@@ -1251,7 +1251,7 @@
         num, tag = untag(tagged)
         if tag == TAGCONST:
             if tagged_eq(tagged, NULLREF):
-                box = self.cpu.ts.CONST_NULL
+                box = CONST_NULL
             else:
                 box = self.consts[num - TAG_CONST_OFFSET]
         elif tag == TAGVIRTUAL:
@@ -1569,7 +1569,7 @@
         num, tag = untag(tagged)
         if tag == TAGCONST:
             if tagged_eq(tagged, NULLREF):
-                return self.cpu.ts.NULLREF
+                return ConstPtr.value
             return self.consts[num - TAG_CONST_OFFSET].getref_base()
         elif tag == TAGVIRTUAL:
             return self.getvirtual_ptr(num)
diff --git a/rpython/jit/metainterp/test/test_resume.py b/rpython/jit/metainterp/test/test_resume.py
--- a/rpython/jit/metainterp/test/test_resume.py
+++ b/rpython/jit/metainterp/test/test_resume.py
@@ -2,31 +2,30 @@
 import py
 import sys
 from rpython.rtyper.lltypesystem import lltype, llmemory, rffi
-from rpython.jit.metainterp.resume import ResumeDataVirtualAdder,\
-     AbstractResumeDataReader, get_VirtualCache_class, ResumeDataBoxReader,\
-     tag, TagOverflow, untag, tagged_eq, UNASSIGNED, TAGBOX, TAGVIRTUAL,\
-     tagged_list_eq, AbstractVirtualInfo, TAGCONST, NULLREF,\
-     ResumeDataDirectReader, TAGINT, REF, VirtualInfo, VStructInfo,\
-     VArrayInfoNotClear, VStrPlainInfo, VStrConcatInfo, VStrSliceInfo,\
-     VUniPlainInfo, VUniConcatInfo, VUniSliceInfo,\
-     capture_resumedata, ResumeDataLoopMemo, UNASSIGNEDVIRTUAL, INT,\
-     annlowlevel, PENDINGFIELDSP, TAG_CONST_OFFSET
-from rpython.jit.metainterp.resumecode import unpack_numbering,\
-     create_numbering, NULL_NUMBER
-from rpython.jit.metainterp.opencoder import Trace, Snapshot, TopSnapshot
+from rpython.jit.metainterp.resume import (
+    ResumeDataVirtualAdder, AbstractResumeDataReader, get_VirtualCache_class,
+    ResumeDataBoxReader, tag, TagOverflow, untag, tagged_eq, UNASSIGNED,
+    TAGBOX, TAGVIRTUAL, tagged_list_eq, AbstractVirtualInfo, TAGCONST,
+    NULLREF, ResumeDataDirectReader, TAGINT, REF, VirtualInfo, VStructInfo,
+    VArrayInfoNotClear, VStrPlainInfo, VStrConcatInfo, VStrSliceInfo,
+    VUniPlainInfo, VUniConcatInfo, VUniSliceInfo, capture_resumedata,
+    ResumeDataLoopMemo, UNASSIGNEDVIRTUAL, INT, annlowlevel, PENDINGFIELDSP,
+    TAG_CONST_OFFSET)
+from rpython.jit.metainterp.resumecode import (
+    unpack_numbering, create_numbering)
+from rpython.jit.metainterp.opencoder import Trace
 
 from rpython.jit.metainterp.optimizeopt import info
-from rpython.jit.metainterp.history import ConstInt, Const, AbstractDescr
-from rpython.jit.metainterp.history import ConstPtr, ConstFloat,\
-     IntFrontendOp, RefFrontendOp
+from rpython.jit.metainterp.history import (
+    ConstInt, Const, AbstractDescr, ConstPtr, ConstFloat, IntFrontendOp,
+    RefFrontendOp, CONST_NULL)
 from rpython.jit.metainterp.optimizeopt.test.test_util import LLtypeMixin
 from rpython.jit.metainterp import executor
 from rpython.jit.codewriter import heaptracker, longlong
 from rpython.jit.metainterp.resoperation import ResOperation, rop
 from rpython.rlib.debug import debug_start, debug_stop, debug_print,\
-     have_debug_prints
+    have_debug_prints
 from rpython.jit.metainterp.test.strategies import intconsts
-from rpython.jit.metainterp import resumecode
 
 from hypothesis import given, strategies
 
@@ -57,7 +56,7 @@
 
     def getptrinfo(self, op, create=True):
         op = self.get_box_replacement(op)
-        return op.get_forwarded()        
+        return op.get_forwarded()
 
 
 # ____________________________________________________________
@@ -185,7 +184,7 @@
     def newframe(self, jitcode):
         frame = FakeFrame(jitcode, -1)
         self.framestack.append(frame)
-        return frame    
+        return frame
 
     def execute_and_record(self, opnum, descr, *argboxes):
         resvalue = executor.execute(self.cpu, None, opnum, descr, *argboxes)
@@ -228,17 +227,17 @@
 gcrefnull = lltype.nullptr(llmemory.GCREF.TO)
 
 class MyCPU:
-    class ts:
-        NULLREF = gcrefnull
-        CONST_NULL = ConstPtr(gcrefnull)
     def __init__(self, values):
         self.values = values
+
     def get_int_value(self, deadframe, index):
         assert deadframe == "deadframe"
         return self.values[index]
+
     def get_ref_value(self, deadframe, index):
         assert deadframe == "deadframe"
         return self.values[index]
+
     def get_float_value(self, deadframe, index):
         assert deadframe == "deadframe"
         return self.values[index]
@@ -378,7 +377,7 @@
 
 class FakeResumeDataReader(AbstractResumeDataReader):
     VirtualCache = get_VirtualCache_class('Fake')
-    
+
     def allocate_with_vtable(self, descr):
         return FakeBuiltObject(vtable=descr)
     def allocate_struct(self, typedescr):
@@ -521,7 +520,7 @@
 
     def setup_resume_at_op(self, pc, exception_target, env):
         self.__init__(self.jitcode, pc, exception_target, *env)
-    
+
     def __eq__(self, other):
         return self.__dict__ == other.__dict__
     def __ne__(self, other):
@@ -544,7 +543,7 @@
 def test_rebuild_from_resumedata():
     py.test.skip("XXX rewrite")
     b1, b2, b3 = [BoxInt(), InputArgRef(), BoxInt()]
-    c1, c2, c3 = [ConstInt(1), ConstInt(2), ConstInt(3)]    
+    c1, c2, c3 = [ConstInt(1), ConstInt(2), ConstInt(3)]
     storage = Storage()
     fs = [FakeFrame("code0", 0, b1, c1, b2),
           FakeFrame("code1", 3, b3, c2, b1),
@@ -568,7 +567,7 @@
 def test_rebuild_from_resumedata_with_virtualizable():
     py.test.skip("XXX rewrite")
     b1, b2, b3, b4 = [BoxInt(), InputArgRef(), BoxInt(), InputArgRef()]
-    c1, c2, c3 = [ConstInt(1), ConstInt(2), ConstInt(3)]    
+    c1, c2, c3 = [ConstInt(1), ConstInt(2), ConstInt(3)]
     storage = Storage()
     fs = [FakeFrame("code0", 0, b1, c1, b2),
           FakeFrame("code1", 3, b3, c2, b1),
@@ -593,7 +592,7 @@
 def test_rebuild_from_resumedata_two_guards():
     py.test.skip("XXX rewrite")
     b1, b2, b3, b4 = [BoxInt(), InputArgRef(), BoxInt(), BoxInt()]
-    c1, c2, c3 = [ConstInt(1), ConstInt(2), ConstInt(3)]    
+    c1, c2, c3 = [ConstInt(1), ConstInt(2), ConstInt(3)]
     storage = Storage()
     fs = [FakeFrame("code0", 0, b1, c1, b2),
           FakeFrame("code1", 3, b3, c2, b1),
@@ -602,7 +601,7 @@
     storage2 = Storage()
     fs = fs[:-1] + [FakeFrame("code2", 10, c3, b2, b4)]
     capture_resumedata(fs, None, [], storage2)
-    
+
     memo = ResumeDataLoopMemo(FakeMetaInterpStaticData())
     modifier = ResumeDataVirtualAdder(FakeOptimizer({}), storage, memo)
     liveboxes = modifier.finish()
@@ -653,7 +652,7 @@
 
 def test_rebuild_from_resumedata_two_guards_w_virtuals():
     py.test.skip("XXX rewrite")
-    
+
     b1, b2, b3, b4, b5 = [BoxInt(), InputArgRef(), BoxInt(), BoxInt(), BoxInt()]
     c1, c2, c3, c4 = [ConstInt(1), ConstInt(2), ConstInt(3),
                       LLtypeMixin.nodebox.constbox()]
@@ -665,7 +664,7 @@
     storage2 = Storage()
     fs = fs[:-1] + [FakeFrame("code2", 10, c3, b2, b4)]
     capture_resumedata(fs, None, [], storage2)
-    
+
     memo = ResumeDataLoopMemo(FakeMetaInterpStaticData())
     values = {b2: virtual_value(b2, b5, c4)}
     modifier = ResumeDataVirtualAdder(FakeOptimizer(values), storage, memo)
@@ -676,12 +675,12 @@
 
     b6 = InputArgRef()
     v6 = virtual_value(b6, c2, None)
-    v6.setfield(LLtypeMixin.nextdescr, v6)    
+    v6.setfield(LLtypeMixin.nextdescr, v6)
     values = {b2: virtual_value(b2, b4, v6), b6: v6}
     memo.clear_box_virtual_numbers()
     modifier = ResumeDataVirtualAdder(FakeOptimizer(values), storage2, memo)
     liveboxes2 = modifier.finish()
-    assert len(storage2.rd_virtuals) == 2    
+    assert len(storage2.rd_virtuals) == 2
     assert storage2.rd_virtuals[0].fieldnums == [tag(len(liveboxes2)-1, TAGBOX),
                                                  tag(-1, TAGVIRTUAL)]
     assert storage2.rd_virtuals[1].fieldnums == [tag(2, TAGINT),
@@ -712,7 +711,7 @@
     fs2 = [FakeFrame("code0", 0, b1t, c1, b2t),
            FakeFrame("code1", 3, b3t, c2, b1t),
            FakeFrame("code2", 10, c3, b2t, b4t)]
-    assert metainterp.framestack == fs2    
+    assert metainterp.framestack == fs2
 
 def test_rebuild_from_resumedata_two_guards_w_shared_virtuals():
     py.test.skip("XXX rewrite")
@@ -722,7 +721,7 @@
     storage = Storage()
     fs = [FakeFrame("code0", 0, c1, b2, b3)]
     capture_resumedata(fs, None, [], storage)
-    
+
     memo = ResumeDataLoopMemo(FakeMetaInterpStaticData())
     values = {b2: virtual_value(b2, b5, c4)}
     modifier = ResumeDataVirtualAdder(FakeOptimizer(values), storage, memo)
@@ -740,7 +739,7 @@
     assert len(storage2.rd_virtuals) == 2
     assert storage2.rd_virtuals[1].fieldnums == storage.rd_virtuals[0].fieldnums
     assert storage2.rd_virtuals[1] is storage.rd_virtuals[0]
-    
+
 
 def test_resumedata_top_recursive_virtuals():
     py.test.skip("XXX rewrite")
@@ -748,7 +747,7 @@
     storage = Storage()
     fs = [FakeFrame("code0", 0, b1, b2)]
     capture_resumedata(fs, None, [], storage)
-    
+
     memo = ResumeDataLoopMemo(FakeMetaInterpStaticData())
     v1 = virtual_value(b1, b3, None)
     v2 = virtual_value(b2, b3, v1)
@@ -761,7 +760,7 @@
     assert storage.rd_virtuals[0].fieldnums == [tag(-1, TAGBOX),
                                                 tag(1, TAGVIRTUAL)]
     assert storage.rd_virtuals[1].fieldnums == [tag(-1, TAGBOX),
-                                                tag(0, TAGVIRTUAL)]    
+                                                tag(0, TAGVIRTUAL)]
 
 
 # ____________________________________________________________
@@ -787,24 +786,23 @@
 demo55o = lltype.cast_opaque_ptr(llmemory.GCREF, demo55)
 demo66 = lltype.malloc(LLtypeMixin.NODE)
 demo66o = lltype.cast_opaque_ptr(llmemory.GCREF, demo66)
-    
+
 def test_ResumeDataLoopMemo_refs():
-    cpu = LLtypeMixin.cpu
     memo = ResumeDataLoopMemo(FakeMetaInterpStaticData())
-    const = cpu.ts.ConstRef(demo55o)
+    const = ConstPtr(demo55o)
     tagged = memo.getconst(const)
     index, tagbits = untag(tagged)
     assert tagbits == TAGCONST
-    assert memo.consts[index - TAG_CONST_OFFSET] is const    
-    tagged = memo.getconst(cpu.ts.ConstRef(demo55o))
+    assert memo.consts[index - TAG_CONST_OFFSET] is const
+    tagged = memo.getconst(ConstPtr(demo55o))
     index2, tagbits = untag(tagged)
     assert tagbits == TAGCONST
     assert index2 == index
-    tagged = memo.getconst(cpu.ts.ConstRef(demo66o))
+    tagged = memo.getconst(ConstPtr(demo66o))
     index3, tagbits = untag(tagged)
     assert tagbits == TAGCONST
-    assert index3 != index    
-    tagged = memo.getconst(cpu.ts.CONST_NULL)
+    assert index3 != index
+    tagged = memo.getconst(CONST_NULL)
     assert tagged == NULLREF
 
 def test_ResumeDataLoopMemo_other():
@@ -828,7 +826,7 @@
 def test_ResumeDataLoopMemo_number():
     b1, b2, b3, b4, b5 = [IntFrontendOp(0), IntFrontendOp(1), IntFrontendOp(2),
                           RefFrontendOp(3), RefFrontendOp(4)]
-    c1, c2, c3, c4 = [ConstInt(1), ConstInt(2), ConstInt(3), ConstInt(4)]    
+    c1, c2, c3, c4 = [ConstInt(1), ConstInt(2), ConstInt(3), ConstInt(4)]
 
     env = [b1, c1, b2, b1, c2]
     metainterp_sd = FakeMetaInterpStaticData()
@@ -892,7 +890,7 @@
     numb_state3 = memo.number(FakeOptimizer(), 2, iter)
     numb3 = numb_state3.create_numbering()
     assert numb_state3.num_virtuals == 0
-    
+
     assert numb_state3.liveboxes == {b1: tag(0, TAGBOX), b2: tag(1, TAGBOX)}
     assert unpack_numbering(numb3) == ([17, 0, 0, 2, tag(3, TAGINT), tag(4, TAGINT),
                                        tag(0, TAGBOX), tag(3, TAGINT)] +
@@ -908,7 +906,7 @@
     numb_state4 = memo.number(FakeOptimizer(), 3, iter)
     numb4 = numb_state4.create_numbering()
     assert numb_state4.num_virtuals == 1
-    
+
     assert numb_state4.liveboxes == {b1: tag(0, TAGBOX), b2: tag(1, TAGBOX),
                                      b4: tag(0, TAGVIRTUAL)}
     assert unpack_numbering(numb4) == [17, 0, 0, 2, tag(3, TAGINT), tag(0, TAGVIRTUAL),
@@ -964,7 +962,7 @@
             assert memo.consts[v].getint() == item.getint()
         elif tag == TAGINT:
             assert v == item.getint()
-    
+
 def test_ResumeDataLoopMemo_number_boxes():
     memo = ResumeDataLoopMemo(FakeMetaInterpStaticData())
     b1, b2 = [IntFrontendOp(0), IntFrontendOp(0)]
@@ -1064,7 +1062,7 @@
     b1s, b2s, b3s = [ConstInt(sys.maxint), ConstInt(2**16), ConstInt(-65)]
     storage, t = make_storage(b1s, b2s, b3s)
     metainterp_sd = FakeMetaInterpStaticData()
-    memo = ResumeDataLoopMemo(metainterp_sd)  
+    memo = ResumeDataLoopMemo(metainterp_sd)
     i = t.get_iter()
     modifier = ResumeDataVirtualAdder(FakeOptimizer(i), storage, storage, i, memo)
     liveboxes = modifier.finish()
@@ -1095,7 +1093,7 @@
     modifier2 = ResumeDataVirtualAdder(FakeOptimizer(i), storage2, storage2,
                                        i, memo)
     modifier2.finish()
-    assert len(memo.consts) == 3    
+    assert len(memo.consts) == 3
     assert storage2.rd_consts is memo.consts
 
 
@@ -1177,7 +1175,7 @@
     assert_same(lst, [ConstInt(2), ConstInt(3)])
     lst = reader.consume_boxes()
     assert_same(lst, [b1t, ConstInt(1), b1t, b1t])
-    assert metainterp.trace == []    
+    assert metainterp.trace == []
 
 
 def test_virtual_adder_make_constant():
@@ -1185,7 +1183,7 @@
     b1s, b2s, b3s = [InputArgInt(1), InputArgRef(), InputArgInt(3)]
     b1s = ConstInt(111)
     storage = make_storage(b1s, b2s, b3s)
-    memo = ResumeDataLoopMemo(FakeMetaInterpStaticData())        
+    memo = ResumeDataLoopMemo(FakeMetaInterpStaticData())
     modifier = ResumeDataVirtualAdder(FakeOptimizer(), storage, storage, memo)
     liveboxes = modifier.finish()
     b2t, b3t = [InputArgRef(demo55o), InputArgInt(33)]
@@ -1204,7 +1202,7 @@
 
 def test_virtual_adder_make_virtual():
     b2s, b3s, b4s, b5s = [IntFrontendOp(0), IntFrontendOp(0), RefFrontendOp(0),
-                          RefFrontendOp(0)]  
+                          RefFrontendOp(0)]
     c1s = ConstInt(111)
     storage = Storage()
     memo = ResumeDataLoopMemo(FakeMetaInterpStaticData())
@@ -1542,7 +1540,7 @@
 def test_invalidation_needed():
     class options:
         failargs_limit = 10
-        
+
     metainterp_sd = FakeMetaInterpStaticData()
     metainterp_sd.options = options
     memo = ResumeDataLoopMemo(metainterp_sd)
@@ -1556,5 +1554,5 @@
 
     assert not modifier._invalidation_needed(10, 2)
     assert not modifier._invalidation_needed(10, 3)
-    assert modifier._invalidation_needed(10, 4)        
-    
+    assert modifier._invalidation_needed(10, 4)
+
diff --git a/rpython/jit/metainterp/typesystem.py b/rpython/jit/metainterp/typesystem.py
--- a/rpython/jit/metainterp/typesystem.py
+++ b/rpython/jit/metainterp/typesystem.py
@@ -33,14 +33,7 @@
     nullptr = staticmethod(lltype.nullptr)
     cast_instance_to_base_ref = staticmethod(cast_instance_to_base_ptr)
     BASETYPE = llmemory.GCREF
-    ConstRef = history.ConstPtr
     loops_done_with_this_frame_ref = None # patched by compile.py
-    NULLREF = history.ConstPtr.value
-    CONST_NULL = history.ConstPtr(NULLREF)
-
-    def new_ConstRef(self, x):
-        ptrval = lltype.cast_opaque_ptr(llmemory.GCREF, x)
-        return history.ConstPtr(ptrval)
 
     def get_typeptr(self, obj):
         return obj.typeptr


More information about the pypy-commit mailing list