Commits

Armin Rigo committed 17f62ee Merge

merge heads

  • Participants
  • Parent commits 157e0dd, 93f7b05
  • Branches stmgc-c4

Comments (0)

Files changed (27)

File lib_pypy/_tkinter/tklib.py

 # C bindings with libtcl and libtk.
 
 from cffi import FFI
+import sys
 
 tkffi = FFI()
 
 int Tk_GetNumMainWindows();
 """)
 
+# XXX find a better way to detect paths
+# XXX pick up CPPFLAGS and LDFLAGS and add to these paths?
+if sys.platform.startswith("openbsd"):
+    incdirs = ['/usr/local/include/tcl8.5', '/usr/local/include/tk8.5', '/usr/X11R6/include']
+    linklibs = ['tk85', 'tcl85']
+    libdirs = ['/usr/local/lib', '/usr/X11R6/lib']
+else:
+    incdirs=['/usr/include/tcl'],
+    linklibs=['tcl', 'tk'],
+    libdirs = []
+
 tklib = tkffi.verify("""
 #include <tcl.h>
 #include <tk.h>
 char *get_tk_version() { return TK_VERSION; }
 char *get_tcl_version() { return TCL_VERSION; }
 """,
-include_dirs=['/usr/include/tcl'],
-libraries=['tcl', 'tk'],
+include_dirs=incdirs,
+libraries=linklibs,
+library_dirs = libdirs
 )

File pypy/interpreter/baseobjspace.py

         raise NotImplementedError("only for interp-level user subclasses "
                                   "from typedef.py")
 
-    def getname(self, space, default='?'):
+    def getname(self, space):
         try:
             return space.str_w(space.getattr(self, space.wrap('__name__')))
         except OperationError, e:
             if e.match(space, space.w_TypeError) or e.match(space, space.w_AttributeError):
-                return default
+                return '?'
             raise
 
     def getaddrstring(self, space):

File pypy/interpreter/function.py

                 space.abstract_isinstance_w(w_firstarg, self.w_class)):
             pass  # ok
         else:
-            clsdescr = self.w_class.getname(space, "")
-            if clsdescr:
+            clsdescr = self.w_class.getname(space)
+            if clsdescr and clsdescr != '?':
                 clsdescr += " instance"
             else:
                 clsdescr = "instance"
             if w_firstarg is None:
                 instdescr = "nothing"
             else:
-                instname = space.abstract_getclass(w_firstarg).getname(space,
-                                                                       "")
-                if instname:
+                instname = space.abstract_getclass(w_firstarg).getname(space)
+                if instname and instname != '?':
                     instdescr = instname + " instance"
                 else:
                     instdescr = "instance"

File pypy/interpreter/test/test_argument.py

 
     def type(self, obj):
         class Type:
-            def getname(self, space, default='?'):
+            def getname(self, space):
                 return type(obj).__name__
         return Type()
 

File pypy/module/_minimal_curses/fficurses.py

 def try_ldflags():
     yield ExternalCompilationInfo(libraries=['curses'])
     yield ExternalCompilationInfo(libraries=['curses', 'tinfo'])
+    yield ExternalCompilationInfo(libraries=['ncurses'])
+    yield ExternalCompilationInfo(libraries=['ncurses'],
+                                  library_dirs=['/usr/lib64'])
 
 def try_tools():
     try:

File pypy/module/_weakref/interp__weakref.py

             state = '; dead'
         else:
             typename = space.type(w_obj).getname(space)
-            objname = w_obj.getname(space, '')
-            if objname:
+            objname = w_obj.getname(space)
+            if objname and objname != '?':
                 state = "; to '%s' (%s)" % (typename, objname)
             else:
                 state = "; to '%s'" % (typename,)

File pypy/objspace/descroperation.py

         if num1 != num2:
             lt = num1      # if obj1 is a number, it is Lower Than obj2
         else:
-            name1 = w_typ1.getname(space, "")
-            name2 = w_typ2.getname(space, "")
+            name1 = w_typ1.getname(space)
+            name2 = w_typ2.getname(space)
             if name1 != name2:
                 lt = name1 < name2
             else:

File pypy/objspace/std/typeobject.py

         else:
             return w_self.name
 
+    def getname(w_self, space):
+        name = w_self.name
+        if name is None:
+            name = '?'
+        return name
+
     def add_subclass(w_self, w_subclass):
         space = w_self.space
         if not space.config.translation.rweakref:

File rpython/jit/backend/arm/assembler.py

File contents unchanged.

File rpython/jit/backend/llsupport/regalloc.py

File contents unchanged.

File rpython/jit/backend/x86/assembler.py

 from rpython.jit.backend.x86 import stmtlocal
 from rpython.rlib import rstm
 from rpython.memory.gc.stmgc import StmGC
+from rpython.jit.backend.llsupport.gc import STMBarrierDescr
 
 
 class Assembler386(BaseAssembler):
         Before using such a relative address, call 
         self._stm_tl_segment_prefix_if_necessary."""
         if self.cpu.gc_ll_descr.stm and we_are_translated():
-            # also not during tests
+            # only for STM and not during tests
             result = adr - stmtlocal.threadlocal_base()
             assert rx86.fits_in_32bits(result)
             return result
         return adr
 
-    def _stm_tl_segment_prefix_if_necessary(self, mc):
+    def _tl_segment_if_stm(self, mc):
+        """Insert segment prefix for thread-local memory if we run
+        in STM and not during testing."""
         if self.cpu.gc_ll_descr.stm and we_are_translated():
             stmtlocal.tl_segment_prefix(mc)
         
             mc.ADD_ri(esp.value, WORD)
         #
         ea = self._get_stm_tl(self.cpu.pos_exception())
-        self._stm_tl_segment_prefix_if_necessary(mc)
+        self._tl_segment_if_stm(mc)
         mc.MOV(eax, heap(ea))
         mc.TEST_rr(eax.value, eax.value)
         mc.J_il8(rx86.Conditions['NZ'], 0)
         that gives the address of the stack top.  If this integer doesn't
         fit in 32 bits, it will be loaded in r11.
         """
-        rst = self._get_root_stack_top_addr()
+        rst = self._get_stm_tl(gcrootmap.get_root_stack_top_addr())
         if rx86.fits_in_32bits(rst):
-            if gcrootmap.is_stm and we_are_translated():
-                # during testing, it will be an absolute address
-                stmtlocal.tl_segment_prefix(mc)
+            self._tl_segment_if_stm(mc)
             mc.MOV_rj(ebx.value, rst)            # MOV ebx, [rootstacktop]
         else:
             mc.MOV_ri(X86_64_SCRATCH_REG.value, rst) # MOV r11, rootstacktop
         self.mc.ADD_ri(ebx.value, WORD)
         
         if rx86.fits_in_32bits(rst):
-            if gcrootmap.is_stm and we_are_translated():
-                # during testing, it will be an absolute address
-                stmtlocal.tl_segment_prefix(self.mc)
+            self._tl_segment_if_stm(self.mc)
             self.mc.MOV_jr(rst, ebx.value)            # MOV [rootstacktop], ebx
         else:
             # The integer 'rst' doesn't fit in 32 bits, so we know that
                            ebx.value) # MOV [r11], ebx
 
     def _call_footer_shadowstack(self, gcrootmap):
-        rst = self._get_root_stack_top_addr()
-        
+        rst = self._get_stm_tl(gcrootmap.get_root_stack_top_addr())
         if rx86.fits_in_32bits(rst):
-            if gcrootmap.is_stm and we_are_translated():
-                # during testing, it will be an absolute address
-                stmtlocal.tl_segment_prefix(self.mc)
+            self._tl_segment_if_stm(self.mc)
             self.mc.SUB_ji8(rst, WORD)       # SUB [rootstacktop], WORD
         else:
             self.mc.MOV_ri(ebx.value, rst)           # MOV ebx, rootstacktop
         cb = callbuilder.CallBuilder(self, fnloc, arglocs)
         cb.emit_no_collect()
 
-    def _get_root_stack_top_addr(self):
-        gcrootmap = self.cpu.gc_ll_descr.gcrootmap
-        
-        rst = gcrootmap.get_root_stack_top_addr()
-        if gcrootmap.is_stm and we_are_translated():
-            # during testing, we return an absolute address
-            rst = rst - stmtlocal.threadlocal_base()
-            assert rx86.fits_in_32bits(rst)
-        return rst
-            
     def _reload_frame_if_necessary(self, mc, align_stack=False):
         gc_ll_descr = self.cpu.gc_ll_descr
         gcrootmap = gc_ll_descr.gcrootmap
         if gcrootmap and gcrootmap.is_shadow_stack:
-            rst = self._get_root_stack_top_addr()
-
-            if gcrootmap.is_stm and we_are_translated():
-                # during testing, it will be an absolute address
-                stmtlocal.tl_segment_prefix(mc)
+            rst = self._get_stm_tl(gcrootmap.get_root_stack_top_addr())
+            self._tl_segment_if_stm(mc)
             mc.MOV(ecx, heap(rst))
             mc.MOV(ebp, mem(ecx, -WORD))
         #
     def genop_guard_guard_no_exception(self, ign_1, guard_op, guard_token,
                                        locs, ign_2):
         ea = self._get_stm_tl(self.cpu.pos_exception())
-        self._stm_tl_segment_prefix_if_necessary(self.mc)
+        self._tl_segment_if_stm(self.mc)
         self.mc.CMP(heap(ea), imm0)
         self.implement_guard(guard_token, 'NZ')
 
         loc = locs[0]
         loc1 = locs[1]
         ea = self._get_stm_tl(self.cpu.pos_exception())
-        self._stm_tl_segment_prefix_if_necessary(self.mc)
+        self._tl_segment_if_stm(self.mc)
         self.mc.MOV(loc1, heap(ea))
         self.mc.CMP(loc1, loc)
         self.implement_guard(guard_token, 'NE')
         eva = self._get_stm_tl(self.cpu.pos_exc_value())
         ea = self._get_stm_tl(self.cpu.pos_exception())
         #
-        self._stm_tl_segment_prefix_if_necessary(mc)
+        self._tl_segment_if_stm(mc)
         if excvalloc is not None:
             assert excvalloc.is_core_reg()
             mc.MOV(excvalloc, heap(eva))
         #
         if exctploc is not None:
             assert exctploc.is_core_reg()
-            self._stm_tl_segment_prefix_if_necessary(mc)
+            self._tl_segment_if_stm(mc)
             mc.MOV(exctploc, heap(ea))
         #
-        self._stm_tl_segment_prefix_if_necessary(mc)
+        self._tl_segment_if_stm(mc)
         mc.MOV(heap(ea), imm0)
-        self._stm_tl_segment_prefix_if_necessary(mc)
+        self._tl_segment_if_stm(mc)
         mc.MOV(heap(eva), imm0)
 
     def _restore_exception(self, mc, excvalloc, exctploc, tmploc=None):
         eva = self._get_stm_tl(self.cpu.pos_exc_value())
         ea = self._get_stm_tl(self.cpu.pos_exception())
         if excvalloc is not None:
-            self._stm_tl_segment_prefix_if_necessary(mc)
+            self._tl_segment_if_stm(mc)
             mc.MOV(heap(eva), excvalloc)
         else:
             assert tmploc is not None
             ofs = self.cpu.get_ofs_of_frame_field('jf_guard_exc')
             mc.MOV(tmploc, RawEbpLoc(ofs))
             mc.MOV_bi(ofs, 0)
-            self._stm_tl_segment_prefix_if_necessary(mc)
+            self._tl_segment_if_stm(mc)
             mc.MOV(heap(eva), tmploc)
-        self._stm_tl_segment_prefix_if_necessary(mc)
+        self._tl_segment_if_stm(mc)
         mc.MOV(heap(ea), exctploc)
 
     def _gen_guard_overflow(self, guard_op, guard_token):
             # We might have an exception pending.  Load it into ebx...
             eva = self._get_stm_tl(self.cpu.pos_exc_value())
             ea = self._get_stm_tl(self.cpu.pos_exception())
-            self._stm_tl_segment_prefix_if_necessary(mc)
+            self._tl_segment_if_stm(mc)
             mc.MOV(ebx, heap(eva))
-            self._stm_tl_segment_prefix_if_necessary(mc)
+            self._tl_segment_if_stm(mc)
             mc.MOV(heap(ea), imm0)
-            self._stm_tl_segment_prefix_if_necessary(mc)
+            self._tl_segment_if_stm(mc)
             mc.MOV(heap(eva), imm0)
             # ...and save ebx into 'jf_guard_exc'
             offset = self.cpu.get_ofs_of_frame_field('jf_guard_exc')
             mc.overwrite(j_ok3 - 1, chr(offset))
 
     def _get_stm_private_rev_num_addr(self):
-        assert self.cpu.gc_ll_descr.stm
-        rn = rstm.get_adr_of_private_rev_num()
-        rn = rn - stmtlocal.threadlocal_base()
-        assert rx86.fits_in_32bits(rn)
-        return rn
+        return self._get_stm_tl(rstm.get_adr_of_private_rev_num())
 
     def _get_stm_read_barrier_cache_addr(self):
-        assert self.cpu.gc_ll_descr.stm
-        rbc = rstm.get_adr_of_read_barrier_cache()
-        rbc = rbc - stmtlocal.threadlocal_base()
-        assert rx86.fits_in_32bits(rbc)
-        return rbc
+        return self._get_stm_tl(rstm.get_adr_of_read_barrier_cache())
         
     def _stm_barrier_fastpath(self, mc, descr, arglocs, is_frame=False,
                               align_stack=False):
         assert self.cpu.gc_ll_descr.stm
-        from rpython.jit.backend.llsupport.gc import (
-            STMBarrierDescr, STMReadBarrierDescr, STMWriteBarrierDescr)
         if we_are_translated():
             # tests use a a mock class, but translation needs it
             assert isinstance(descr, STMBarrierDescr)
         if we_are_translated():
             # during tests, _get_stm_private_rev_num_addr returns
             # an absolute address, not a tl-offset
-            stmtlocal.tl_segment_prefix(mc)
+            self._tl_segment_if_stm(mc)
             mc.MOV_rj(X86_64_SCRATCH_REG.value, rn)
         else: # testing:
             mc.MOV(X86_64_SCRATCH_REG, heap(rn))
             if we_are_translated():
                 # during tests, _get_stm_rbca returns
                 # an absolute address, not a tl-offset
-                stmtlocal.tl_segment_prefix(mc)
+                self._tl_segment_if_stm(mc)
                 mc.ADD_rj(X86_64_SCRATCH_REG.value, rbc)
             else: # testing:
                 mc.PUSH_r(eax.value)

File rpython/jit/backend/x86/regalloc.py

 from rpython.rlib.rarithmetic import r_longlong, r_uint
 from rpython.rtyper.lltypesystem.lloperation import llop
 from rpython.rtyper.lltypesystem import lltype, rffi, rstr
+from rpython.rtyper.lltypesystem.lloperation import llop
 
 
 class X86RegisterManager(RegisterManager):

File rpython/jit/backend/x86/runner.py

File contents unchanged.

File rpython/jit/backend/x86/test/test_stm_integration.py

                         ResOperation(rop.FINISH, [i], None, 
                                      descr=finaldescr)
                         )
+                    print operations
 
+                    
                     # COMPILE & EXECUTE LOOP:
                     inputargs = [p for p in (p1, p2) 
                                  if not isinstance(p, Const)]
 
                     args = [s for i, s in enumerate((s1, s2))
                             if not isinstance((p1, p2)[i], Const)] + [7]
-                    print "======"
-                    print "inputargs:", inputargs+[i1], args
-                    print "\n".join(map(str,c_loop[1]))
                                         
                     frame = self.cpu.execute_token(looptoken, *args)
                     frame = rffi.cast(JITFRAMEPTR, frame)
                                   looptoken)
         
         args = []
-        print "======"
-        print "inputargs:", inputargs, args
-        print "\n".join(map(str,c_loop[1]))
         
         frame = self.cpu.execute_token(looptoken, *args)
 
         looptoken = JitCellToken()
         looptoken.outermost_jitdriver_sd = FakeJitDriverSD()
         c_loop = cpu.compile_loop(None, inputargs, ops, looptoken)
-        print "\n".join(map(str,c_loop[1]))
         
         ARGS = [lltype.Signed] * 10
         RES = lltype.Signed
         othertoken = JitCellToken()
         cpu.done_with_this_frame_descr_int = BasicFinalDescr()
         c_loop = cpu.compile_loop(None, [], ops, othertoken)
-        print "\n".join(map(str,c_loop[1]))
         
         deadframe = cpu.execute_token(othertoken)
         frame = rffi.cast(JITFRAMEPTR, deadframe)

File rpython/rlib/rgc.py

File contents unchanged.

File rpython/rtyper/test/test_rclass.py

 
         assert self.interpret(f, [True]) == f(True)
         assert self.interpret(f, [False]) == f(False)
+
+    def test_init_with_star_args(self):
+        class Base(object):
+            def __init__(self, a, b):
+                self.a = a
+                self.b = b
+        class A(Base):
+            def __init__(self, *args):
+                Base.__init__(self, *args)
+                self.c = -1
+        cls = [Base, A]
+
+        def f(k, a, b):
+            return cls[k](a, b).b
+
+        assert self.interpret(f, [1, 4, 7]) == 7

File rpython/translator/backendopt/all.py

File contents unchanged.

File rpython/translator/backendopt/gilanalysis.py

File contents unchanged.

File rpython/translator/backendopt/graphanalyze.py

File contents unchanged.

File rpython/translator/c/src/debug_print.c

 FILE *pypy_debug_file = NULL;   /* XXX make it thread-local too? */
 static unsigned char debug_ready = 0;
 static unsigned char debug_profile = 0;
-__thread_if_stm static char debug_start_colors_1[32];
-__thread_if_stm static char debug_start_colors_2[28];
+static __thread_if_stm char debug_start_colors_1[32];
+static __thread_if_stm char debug_start_colors_2[28];
 __thread_if_stm char pypy_debug_threadid[16] = {0};
 static char *debug_stop_colors = "";
 static char *debug_prefix = NULL;

File rpython/translator/stm/src_stm/et.c

File contents unchanged.

File rpython/translator/stm/src_stm/extra.c

File contents unchanged.

File rpython/translator/stm/src_stm/extra.h

File contents unchanged.

File rpython/translator/stm/src_stm/gcpage.c

File contents unchanged.

File rpython/translator/stm/src_stm/nursery.c

File contents unchanged.

File rpython/translator/stm/src_stm/revision

File contents unchanged.

File rpython/translator/stm/src_stm/stmgc.h

File contents unchanged.