[pypy-commit] cffi default: issue #94: Document

2013-07-29 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r1298:d0ab3b159a1f
Date: 2013-07-29 09:15 +0200
http://bitbucket.org/cffi/cffi/changeset/d0ab3b159a1f/

Log:issue #94: Document

diff --git a/doc/source/index.rst b/doc/source/index.rst
--- a/doc/source/index.rst
+++ b/doc/source/index.rst
@@ -1216,7 +1216,10 @@
 ``struct foo_s``, return its "address", as a cdata whose type is
 ``struct foo_s *``.  Also works on unions, but not on any other type.
 (It would be difficult because only structs and unions are internally
-stored as an indirect pointer to the data.)  If ``field`` is given,
+stored as an indirect pointer to the data.  If you need a C int whose
+address can be taken, use ``ffi.new("int[1]")`` in the first place;
+similarly, if it's a C pointer, use ``ffi.new("foo_t *[1]")``.)
+If ``field`` is given,
 returns the address of that field in the structure.  The returned
 pointer is only valid as long as the original ``cdata`` object is; be
 sure to keep it alive if it was obtained directly from ``ffi.new()``.
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy release-2.1.x: revert setting cppflags and ldflagsto original appraoch, this doesnt break setuptools monkeypatching distutils

2013-07-29 Thread squeaky
Author: Paweł Piotr Przeradowski 
Branch: release-2.1.x
Changeset: r65766:522f7674a168
Date: 2013-07-28 01:08 +0200
http://bitbucket.org/pypy/pypy/changeset/522f7674a168/

Log:revert setting cppflags and ldflagsto original appraoch, this doesnt
break setuptools monkeypatching distutils (transplanted from
9fad3a8b420858513f1356f3d82f6e4b7f377e6e)

diff --git a/lib-python/2.7/distutils/sysconfig_pypy.py 
b/lib-python/2.7/distutils/sysconfig_pypy.py
--- a/lib-python/2.7/distutils/sysconfig_pypy.py
+++ b/lib-python/2.7/distutils/sysconfig_pypy.py
@@ -12,6 +12,7 @@
 
 import sys
 import os
+import shlex
 
 from distutils.errors import DistutilsPlatformError
 
@@ -65,11 +66,6 @@
 g['SOABI'] = g['SO'].rsplit('.')[0]
 g['LIBDIR'] = os.path.join(sys.prefix, 'lib')
 g['CC'] = "gcc -pthread" # -pthread might not be valid on OS/X, check
-g['OPT'] = ""
-g['CFLAGS'] = ""
-g['CPPFLAGS'] = ""
-g['CCSHARED'] = '-shared -O2 -fPIC -Wimplicit'
-g['LDSHARED'] = g['CC'] + ' -shared'
 
 global _config_vars
 _config_vars = g
@@ -127,34 +123,21 @@
 optional C speedup components.
 """
 if compiler.compiler_type == "unix":
-cc, opt, cflags, ccshared, ldshared = get_config_vars(
-'CC', 'OPT', 'CFLAGS', 'CCSHARED', 'LDSHARED')
-
+compiler.compiler_so.extend(['-O2', '-fPIC', '-Wimplicit'])
 compiler.shared_lib_extension = get_config_var('SO')
-
-if 'LDSHARED' in os.environ:
-ldshared = os.environ['LDSHARED']
-if 'CPP' in os.environ:
-cpp = os.environ['CPP']
-else:
-cpp = cc + " -E"   # not always
-if 'LDFLAGS' in os.environ:
-ldshared = ldshared + ' ' + os.environ['LDFLAGS']
-if 'CFLAGS' in os.environ:
-cflags = opt + ' ' + os.environ['CFLAGS']
-ldshared = ldshared + ' ' + os.environ['CFLAGS']
-if 'CPPFLAGS' in os.environ:
-cpp = cpp + ' ' + os.environ['CPPFLAGS']
-cflags = cflags + ' ' + os.environ['CPPFLAGS']
-ldshared = ldshared + ' ' + os.environ['CPPFLAGS']
-
-cc_cmd = cc + ' ' + cflags
-
-compiler.set_executables(
-preprocessor=cpp,
-compiler=cc_cmd,
-compiler_so=cc_cmd + ' ' + ccshared,
-linker_so=ldshared)
+if "CPPFLAGS" in os.environ:
+cppflags = shlex.split(os.environ["CPPFLAGS"])
+compiler.compiler.extend(cppflags)
+compiler.compiler_so.extend(cppflags)
+compiler.linker_so.extend(cppflags)
+if "CFLAGS" in os.environ:
+cflags = shlex.split(os.environ["CFLAGS"])
+compiler.compiler.extend(cflags)
+compiler.compiler_so.extend(cflags)
+compiler.linker_so.extend(cflags)
+if "LDFLAGS" in os.environ:
+ldflags = shlex.split(os.environ["LDFLAGS"])
+compiler.linker_so.extend(ldflags)
 
 
 from sysconfig_cpython import (
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy release-2.1.x: bump version numbers

2013-07-29 Thread bivab
Author: David Schneider 
Branch: release-2.1.x
Changeset: r65767:6fdd7202b805
Date: 2013-07-29 09:30 +0200
http://bitbucket.org/pypy/pypy/changeset/6fdd7202b805/

Log:bump version numbers

diff --git a/pypy/module/cpyext/include/patchlevel.h 
b/pypy/module/cpyext/include/patchlevel.h
--- a/pypy/module/cpyext/include/patchlevel.h
+++ b/pypy/module/cpyext/include/patchlevel.h
@@ -29,7 +29,7 @@
 #define PY_VERSION "2.7.3"
 
 /* PyPy version as a string */
-#define PYPY_VERSION "2.1.0-beta2"
+#define PYPY_VERSION "2.1.0"
 
 /* Subversion Revision number of this file (not of the repository).
  * Empty since Mercurial migration. */
diff --git a/pypy/module/sys/version.py b/pypy/module/sys/version.py
--- a/pypy/module/sys/version.py
+++ b/pypy/module/sys/version.py
@@ -11,7 +11,7 @@
 #XXX # sync CPYTHON_VERSION with patchlevel.h, package.py
 CPYTHON_API_VERSION= 1013   #XXX # sync with include/modsupport.h
 
-PYPY_VERSION   = (2, 1, 0, "beta", 2)#XXX # sync patchlevel.h
+PYPY_VERSION   = (2, 1, 0, "final", 0)#XXX # sync patchlevel.h
 
 if platform.name == 'msvc':
 COMPILER_INFO = 'MSC v.%d 32 bit' % (platform.version * 10 + 600)
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Fix 74ec2abeb333: in particular, the line

2013-07-29 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r65768:a89ed91dc553
Date: 2013-07-29 10:28 +0200
http://bitbucket.org/pypy/pypy/changeset/a89ed91dc553/

Log:Fix 74ec2abeb333: in particular, the line

 if infobits | T_HAS_GCPTR_IN_VARSIZE...

is equivalent to "if True", so the shortcut was never taken.

diff --git a/rpython/memory/gc/minimark.py b/rpython/memory/gc/minimark.py
--- a/rpython/memory/gc/minimark.py
+++ b/rpython/memory/gc/minimark.py
@@ -991,9 +991,12 @@
 # after a minor or major collection, no object should be in the nursery
 ll_assert(not self.is_in_nursery(obj),
   "object in nursery after collection")
-# similarily, all objects should have this flag:
-ll_assert(self.header(obj).tid & GCFLAG_TRACK_YOUNG_PTRS != 0,
-  "missing GCFLAG_TRACK_YOUNG_PTRS")
+# similarily, all objects should have this flag, except if they
+# don't have any GC pointer
+typeid = self.get_type_id(obj)
+if self.has_gcptr(typeid):
+ll_assert(self.header(obj).tid & GCFLAG_TRACK_YOUNG_PTRS != 0,
+  "missing GCFLAG_TRACK_YOUNG_PTRS")
 # the GCFLAG_VISITED should not be set between collections
 ll_assert(self.header(obj).tid & GCFLAG_VISITED == 0,
   "unexpected GCFLAG_VISITED")
diff --git a/rpython/memory/gctypelayout.py b/rpython/memory/gctypelayout.py
--- a/rpython/memory/gctypelayout.py
+++ b/rpython/memory/gctypelayout.py
@@ -203,6 +203,8 @@
 offsets = offsets_to_gc_pointers(TYPE)
 infobits = index
 info.ofstoptrs = builder.offsets2table(offsets, TYPE)
+if len(offsets) > 0:
+infobits |= T_HAS_GCPTR
 #
 fptrs = builder.special_funcptr_for_type(TYPE)
 if fptrs:
@@ -216,7 +218,7 @@
 infobits |= T_HAS_FINALIZER | T_HAS_LIGHTWEIGHT_FINALIZER
 if "custom_trace" in fptrs:
 extra.customtracer = fptrs["custom_trace"]
-infobits |= T_HAS_CUSTOM_TRACE
+infobits |= T_HAS_CUSTOM_TRACE | T_HAS_GCPTR
 info.extra = extra
 #
 if not TYPE._is_varsize():
@@ -249,15 +251,13 @@
 else:
 offsets = ()
 if len(offsets) > 0:
-infobits |= T_HAS_GCPTR_IN_VARSIZE
+infobits |= T_HAS_GCPTR_IN_VARSIZE | T_HAS_GCPTR
 varinfo.varofstoptrs = builder.offsets2table(offsets, ARRAY.OF)
 varinfo.varitemsize = llmemory.sizeof(ARRAY.OF)
 if builder.is_weakref_type(TYPE):
 infobits |= T_IS_WEAKREF
 if is_subclass_of_object(TYPE):
 infobits |= T_IS_RPYTHON_INSTANCE
-if infobits | T_HAS_GCPTR_IN_VARSIZE or offsets:
-infobits |= T_HAS_GCPTR
 info.infobits = infobits | T_KEY_VALUE
 
 # 
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy stmgc-c4: remove a jump

2013-07-29 Thread Raemi
Author: Remi Meier 
Branch: stmgc-c4
Changeset: r65769:646270f9f8db
Date: 2013-07-26 16:29 +0200
http://bitbucket.org/pypy/pypy/changeset/646270f9f8db/

Log:remove a jump

diff --git a/rpython/jit/backend/x86/assembler.py 
b/rpython/jit/backend/x86/assembler.py
--- a/rpython/jit/backend/x86/assembler.py
+++ b/rpython/jit/backend/x86/assembler.py
@@ -2232,7 +2232,7 @@
 mc.CMP_rb(X86_64_SCRATCH_REG.value, StmGC.H_REVISION)
 else:
 mc.CMP(X86_64_SCRATCH_REG, mem(loc_base, StmGC.H_REVISION))
-
+#
 if isinstance(descr, STMReadBarrierDescr):
 # jump to end if h_rev==priv_rev
 mc.J_il8(rx86.Conditions['Z'], 0) # patched below
@@ -2268,19 +2268,15 @@
 mc.TEST8_bi(StmGC.H_TID + off, flag)
 else:
 mc.TEST8_mi((loc_base.value, StmGC.H_TID + off), flag)
-mc.J_il8(rx86.Conditions['NZ'], 0) # patched below
-jnz_location2 = mc.get_relative_pos()
-
-# jump to end
-mc.JMP_l8(0) # patched below
+
+mc.J_il8(rx86.Conditions['Z'], 0) # patched below
 jz_location = mc.get_relative_pos()
+# both conditions succeeded, jump to end
 
 # jump target slowpath:
 offset = mc.get_relative_pos() - jnz_location
-offset2 = mc.get_relative_pos() - jnz_location2
 assert 0 < offset <= 127
 mc.overwrite(jnz_location - 1, chr(offset))
-mc.overwrite(jnz_location2 - 1, chr(offset2))
 #
 # SLOWPATH_START
 #
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy stmgc-c4: add failing test for repeating a read_barrier after a write_barrier

2013-07-29 Thread Raemi
Author: Remi Meier 
Branch: stmgc-c4
Changeset: r65774:ca6cec2712bf
Date: 2013-07-29 11:28 +0200
http://bitbucket.org/pypy/pypy/changeset/ca6cec2712bf/

Log:add failing test for repeating a read_barrier after a write_barrier

diff --git a/rpython/jit/backend/llsupport/test/test_stmrewrite.py 
b/rpython/jit/backend/llsupport/test/test_stmrewrite.py
--- a/rpython/jit/backend/llsupport/test/test_stmrewrite.py
+++ b/rpython/jit/backend/llsupport/test/test_stmrewrite.py
@@ -64,6 +64,26 @@
 jump()
 """, t=NULL)
 
+def test_invalidate_read_status_after_write(self):
+self.check_rewrite("""
+[p0]
+p1 = same_as(p0)
+p2 = same_as(p0)
+p4 = getfield_gc(p1, descr=tzdescr)
+setfield_gc(p2, p0, descr=tzdescr)
+p5 = getfield_gc(p1, descr=tzdescr)
+""", """
+[p0]
+p1 = same_as(p0)
+p2 = same_as(p0)
+cond_call_stm_b(p1, descr=P2Rdescr)
+p4 = getfield_gc(p1, descr=tzdescr)
+cond_call_stm_b(p2, descr=P2Wdescr)
+setfield_gc(p2, p0, descr=tzdescr)
+cond_call_stm_b(p1, descr=P2Rdescr)
+p5 = getfield_gc(p1, descr=tzdescr)
+""")
+
 def test_rewrite_write_barrier_after_malloc(self):
 self.check_rewrite("""
 [p1, p3]
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy stmgc-c4: Merge

2013-07-29 Thread Raemi
Author: Remi Meier 
Branch: stmgc-c4
Changeset: r65771:ed40f1172b80
Date: 2013-07-29 08:41 +0200
http://bitbucket.org/pypy/pypy/changeset/ed40f1172b80/

Log:Merge

diff --git a/rpython/memory/gc/stmgc.py b/rpython/memory/gc/stmgc.py
--- a/rpython/memory/gc/stmgc.py
+++ b/rpython/memory/gc/stmgc.py
@@ -44,15 +44,16 @@
 GCFLAG_PREBUILT_ORIGINAL  = first_gcflag << 3
 GCFLAG_PUBLIC_TO_PRIVATE  = first_gcflag << 4
 GCFLAG_WRITE_BARRIER  = first_gcflag << 5 # stmgc.h
-GCFLAG_NURSERY_MOVED  = first_gcflag << 6
+GCFLAG_MOVED  = first_gcflag << 6
 GCFLAG_BACKUP_COPY= first_gcflag << 7 # debug
 GCFLAG_STUB   = first_gcflag << 8 # debug
 GCFLAG_PRIVATE_FROM_PROTECTED = first_gcflag << 9
 GCFLAG_HAS_ID = first_gcflag << 10
 GCFLAG_IMMUTABLE  = first_gcflag << 11
 GCFLAG_SMALLSTUB  = first_gcflag << 12
+GCFLAG_MARKED = first_gcflag << 13
 
-PREBUILT_FLAGS= first_gcflag * (1 + 2 + 4 + 8)
+PREBUILT_FLAGS= first_gcflag * ((1<<0) | (1<<1) | (1<<2) | (1<<3) | 
(1<<13))
 PREBUILT_REVISION = r_uint(1)
 
 FX_MASK = 65535
@@ -109,7 +110,7 @@
 # XXX finalizers are ignored for now
 #ll_assert(not needs_finalizer, 'XXX needs_finalizer')
 #ll_assert(not is_finalizer_light, 'XXX is_finalizer_light')
-#ll_assert(not contains_weakptr, 'XXX contains_weakptr')
+ll_assert(not contains_weakptr, 'contains_weakptr: use malloc_weakref')
 # XXX call optimized versions, e.g. if size < GC_NURSERY_SECTION
 return llop.stm_allocate(llmemory.GCREF, size, typeid16)
 
@@ -131,12 +132,14 @@
 seen by the GC, then it can get collected."""
 tid = self.get_hdr_tid(obj)[0]
 if bool(tid & self.GCFLAG_OLD):
-return False
+return False# XXX wrong so far.  We should add a flag to the
+# object that means "don't ever kill this copy"
 return True
 
 
 @classmethod
 def JIT_max_size_of_young_obj(cls):
+# XXX there is actually a maximum, check
 return None
 
 @classmethod
diff --git a/rpython/translator/stm/src_stm/dbgmem.c 
b/rpython/translator/stm/src_stm/dbgmem.c
--- a/rpython/translator/stm/src_stm/dbgmem.c
+++ b/rpython/translator/stm/src_stm/dbgmem.c
@@ -9,7 +9,7 @@
 #ifdef _GC_DEBUG
 //
 
-#define MMAP_TOTAL  671088640   /* 640MB */
+#define MMAP_TOTAL  1280*1024*1024   /* 1280MB */
 
 static pthread_mutex_t malloc_mutex = PTHREAD_MUTEX_INITIALIZER;
 static char *zone_start, *zone_current = NULL, *zone_end = NULL;
@@ -71,6 +71,10 @@
 
 void stm_free(void *p, size_t sz)
 {
+if (p == NULL) {
+assert(sz == 0);
+return;
+}
 assert(((intptr_t)((char *)p + sz) & (PAGE_SIZE-1)) == 0);
 
 size_t nb_pages = (sz + PAGE_SIZE - 1) / PAGE_SIZE + 1;
@@ -84,6 +88,14 @@
 _stm_dbgmem(p, sz, PROT_NONE);
 }
 
+void *stm_realloc(void *p, size_t newsz, size_t oldsz)
+{
+void *r = stm_malloc(newsz);
+memcpy(r, p, oldsz < newsz ? oldsz : newsz);
+stm_free(p, oldsz);
+return r;
+}
+
 int _stm_can_access_memory(char *p)
 {
 long base = ((char *)p - zone_start) / PAGE_SIZE;
diff --git a/rpython/translator/stm/src_stm/dbgmem.h 
b/rpython/translator/stm/src_stm/dbgmem.h
--- a/rpython/translator/stm/src_stm/dbgmem.h
+++ b/rpython/translator/stm/src_stm/dbgmem.h
@@ -7,6 +7,7 @@
 
 void *stm_malloc(size_t);
 void stm_free(void *, size_t);
+void *stm_realloc(void *, size_t, size_t);
 int _stm_can_access_memory(char *);
 void assert_cleared(char *, size_t);
 
@@ -14,6 +15,7 @@
 
 #define stm_malloc(sz)malloc(sz)
 #define stm_free(p,sz)free(p)
+#define stm_realloc(p,newsz,oldsz)  realloc(p,newsz)
 #define assert_cleared(p,sz) do { } while(0)
 
 #endif
diff --git a/rpython/translator/stm/src_stm/et.c 
b/rpython/translator/stm/src_stm/et.c
--- a/rpython/translator/stm/src_stm/et.c
+++ b/rpython/translator/stm/src_stm/et.c
@@ -146,7 +146,7 @@
   gcptr P_prev = P;
   P = (gcptr)v;
   assert((P->h_tid & GCFLAG_PUBLIC) ||
- (P_prev->h_tid & GCFLAG_NURSERY_MOVED));
+ (P_prev->h_tid & GCFLAG_MOVED));
 
   v = ACCESS_ONCE(P->h_revision);
 
@@ -238,7 +238,7 @@
  add_in_recent_reads_cache:
   /* The risks are that the following assert fails, because the flag was
  added just now by a parallel thread during stealing... */
-  /*assert(!(P->h_tid & GCFLAG_NURSERY_MOVED));*/
+  /*assert(!(P->h_tid & GCFLAG_MOVED));*/
   fxcache_add(&d->recent_reads_cache, P);
   return P;
 
@@ -281,7 +281,7 @@
*/
   if (P->h_tid & GCFLAG_PUBLIC)
 {
-  if (P->h_tid & GCFLAG_NURSERY_MOVED)
+  if (P->h_tid & GCFLAG_MOVED)
 {
   P = (gcptr)P->h_revision;
   assert(P->h_tid & GCFLAG_PUBLIC);
@@ -413,7 +413,7 @@
 

[pypy-commit] pypy stmgc-c4: add stm_dont_track_raw_accesses hint for classes; use it for 'aroundstate'

2013-07-29 Thread Raemi
Author: Remi Meier 
Branch: stmgc-c4
Changeset: r65773:ba7123a9d332
Date: 2013-07-29 11:21 +0200
http://bitbucket.org/pypy/pypy/changeset/ba7123a9d332/

Log:add stm_dont_track_raw_accesses hint for classes; use it for
'aroundstate' also mark ExcData to not track. this may require
clearing it on abort!

diff --git a/rpython/rtyper/lltypesystem/rclass.py 
b/rpython/rtyper/lltypesystem/rclass.py
--- a/rpython/rtyper/lltypesystem/rclass.py
+++ b/rpython/rtyper/lltypesystem/rclass.py
@@ -367,6 +367,7 @@
 if hints is None:
 hints = {}
 hints = self._check_for_immutable_hints(hints)
+hints = self._check_for_stm_hints(hints)
 kwds = {}
 if self.gcflavor == 'gc':
 kwds['rtti'] = True
diff --git a/rpython/rtyper/lltypesystem/rffi.py 
b/rpython/rtyper/lltypesystem/rffi.py
--- a/rpython/rtyper/lltypesystem/rffi.py
+++ b/rpython/rtyper/lltypesystem/rffi.py
@@ -329,6 +329,7 @@
 
 class AroundState:
 _alloc_flavor_ = "raw"
+_stm_dont_track_raw_accesses_ = True
 
 def _cleanup_(self):
 self.before = None# or a regular RPython function
diff --git a/rpython/rtyper/rclass.py b/rpython/rtyper/rclass.py
--- a/rpython/rtyper/rclass.py
+++ b/rpython/rtyper/rclass.py
@@ -46,6 +46,10 @@
 class ImmutableConflictError(Exception):
 """Raised when the _immutable_ or _immutable_fields_ hints are
 not consistent across a class hierarchy."""
+
+class StmHintConflictError(Exception):
+"""Raised when the _stm_dont_track_raw_accesses_ hints are
+not consistent across a class hierarchy."""
 
 
 def getclassrepr(rtyper, classdef):
@@ -215,6 +219,26 @@
 hints['immutable_fields'] = accessor
 return hints
 
+def _check_for_stm_hints(self, hints):
+loc = self.classdef.classdesc.lookup('_stm_dont_track_raw_accesses_')
+if loc is not None:
+if loc is not self.classdef.classdesc:
+raise StmHintConflictError(
+"class %r inherits from its parent"
+" _immutable__stm_dont_track_raw_accesses_=True, "
+"so it should also declare"
+" _stm_dont_track_raw_accesses_=True" % (
+self.classdef,))
+if loc.classdict.get('_stm_dont_track_raw_accesses_').value is not 
True:
+raise TyperError(
+"class %r: _stm_dont_track_raw_accesses_ = something "
+"else than True" % (
+self.classdef,))
+hints = hints.copy()
+hints['stm_dont_track_raw_accesses'] = True
+return hints
+
+
 def __repr__(self):
 if self.classdef is None:
 clsname = 'object'
diff --git a/rpython/translator/exceptiontransform.py 
b/rpython/translator/exceptiontransform.py
--- a/rpython/translator/exceptiontransform.py
+++ b/rpython/translator/exceptiontransform.py
@@ -470,7 +470,8 @@
 EXCDATA = lltype.Struct('ExcData',
 ('exc_type',  self.lltype_of_exception_type),
 ('exc_value', self.lltype_of_exception_value),
-hints={'stm_thread_local': True})
+hints={'stm_thread_local': True,
+   'stm_dont_track_raw_accesses':True})
 self.EXCDATA = EXCDATA
 
 exc_data = lltype.malloc(EXCDATA, immortal=True)
diff --git a/rpython/translator/stm/test/test_inevitable.py 
b/rpython/translator/stm/test/test_inevitable.py
--- a/rpython/translator/stm/test/test_inevitable.py
+++ b/rpython/translator/stm/test/test_inevitable.py
@@ -224,4 +224,22 @@
 res = self.interpret_inevitable(f1, [True])
 assert res is None
 
+def test_raw_class_hint(self):
+class A:
+_alloc_flavor_ = "raw"
+_stm_dont_track_raw_accesses_ = True
+def __init__(self): self.x = 1
 
+def f2():
+return A()
+
+def f(i):
+a = f2()
+a.x = i
+i = a.x
+lltype.free(a, flavor='raw')
+return i
+
+res = self.interpret_inevitable(f, [2])
+assert res == 'free' # not setfield or getfield
+
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy stmgc-c4: attempt to implement ptr_eq fastpath

2013-07-29 Thread Raemi
Author: Remi Meier 
Branch: stmgc-c4
Changeset: r65770:6317510aa84e
Date: 2013-07-29 08:38 +0200
http://bitbucket.org/pypy/pypy/changeset/6317510aa84e/

Log:attempt to implement ptr_eq fastpath

diff --git a/pypy/tool/jitlogparser/parser.py b/pypy/tool/jitlogparser/parser.py
--- a/pypy/tool/jitlogparser/parser.py
+++ b/pypy/tool/jitlogparser/parser.py
@@ -395,7 +395,7 @@
 addr = int(m.group(1), 16)
 addrs.setdefault(addr, []).append(name)
 dumps = {}
-executables = set()
+executables = set(["??"])
 symbols = {}
 for entry in extract_category(log, 'jit-backend-dump'):
 entry = purge_thread_numbers(entry)
diff --git a/rpython/jit/backend/x86/assembler.py 
b/rpython/jit/backend/x86/assembler.py
--- a/rpython/jit/backend/x86/assembler.py
+++ b/rpython/jit/backend/x86/assembler.py
@@ -1042,7 +1042,6 @@
 assert self.cpu.gc_ll_descr.stm
 rl = result_loc.lowest8bits()
 self._stm_ptr_eq_fastpath(self.mc, arglocs, result_loc)
-self.mc.TEST_rr(eax.value, eax.value)
 self.mc.SET_ir(rx86.Conditions['NZ'], rl.value)
 self.mc.MOVZX8_rr(result_loc.value, rl.value)
 
@@ -1052,7 +1051,6 @@
 assert self.cpu.gc_ll_descr.stm
 rl = result_loc.lowest8bits()
 self._stm_ptr_eq_fastpath(self.mc, arglocs, result_loc)
-self.mc.TEST_rr(eax.value, eax.value)
 self.mc.SET_ir(rx86.Conditions['Z'], rl.value)
 self.mc.MOVZX8_rr(result_loc.value, rl.value)
 
@@ -1064,7 +1062,6 @@
 assert not self.cpu.gc_ll_descr.stm
 guard_opnum = guard_op.getopnum()
 self._stm_ptr_eq_fastpath(self.mc, arglocs, result_loc)
-self.mc.TEST_rr(eax.value, eax.value)
 if guard_opnum == rop.GUARD_FALSE:
 self.implement_guard(guard_token, "Z")
 else:
@@ -1078,7 +1075,6 @@
 assert not self.cpu.gc_ll_descr.stm
 guard_opnum = guard_op.getopnum()
 self._stm_ptr_eq_fastpath(self.mc, arglocs, result_loc)
-self.mc.TEST_rr(eax.value, eax.value)
 if guard_opnum == rop.GUARD_FALSE:
 self.implement_guard(guard_token, "NZ")
 else:
@@ -2173,6 +2169,34 @@
 assert self.ptr_eq_slowpath is not None
 a_base = arglocs[0]
 b_base = arglocs[1]
+
+#
+# FASTPATH
+#
+# a == b -> SET NZ
+sl = X86_64_SCRATCH_REG.lowest8bits()
+mc.MOV(X86_64_SCRATCH_REG, a_base)
+mc.CMP(X86_64_SCRATCH_REG, b_base)
+mc.SET_ir(rx86.Conditions['Z'], sl.value)
+mc.MOVZX8_rr(X86_64_SCRATCH_REG.value, sl.value)
+mc.TEST(X86_64_SCRATCH_REG, X86_64_SCRATCH_REG)
+mc.J_il8(rx86.Conditions['NZ'], 0)
+j_ok1 = mc.get_relative_pos()
+
+# a == 0 || b == 0 -> SET Z
+mc.CMP(a_base, imm(0))
+mc.J_il8(rx86.Conditions['Z'], 0)
+j_ok2 = mc.get_relative_pos()
+#
+mc.CMP(a_base, imm(0))
+mc.J_il8(rx86.Conditions['Z'], 0)
+j_ok3 = mc.get_relative_pos()
+
+# a.type != b.type
+# XXX: todo, if it ever happens..
+
+#
+# SLOWPATH
 #
 mc.PUSH(b_base)
 mc.PUSH(a_base)
@@ -2180,7 +2204,22 @@
 mc.CALL(imm(func))
 # result still on stack
 assert isinstance(result_loc, RegLoc)
-mc.POP_r(result_loc.value)
+mc.POP_r(X86_64_SCRATCH_REG.value)
+# set flags:
+mc.TEST(X86_64_SCRATCH_REG, X86_64_SCRATCH_REG)
+#
+# END SLOWPATH
+#
+
+# OK: flags already set
+offset = mc.get_relative_pos() - j_ok1
+mc.overwrite(j_ok1 - 1, chr(offset))
+offset = mc.get_relative_pos() - j_ok2
+mc.overwrite(j_ok2 - 1, chr(offset))
+offset = mc.get_relative_pos() - j_ok3
+mc.overwrite(j_ok3 - 1, chr(offset))
+
+
 
 def _get_stm_private_rev_num_addr(self):
 assert self.cpu.gc_ll_descr.stm
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy stmgc-c4: adapt to new api

2013-07-29 Thread Raemi
Author: Remi Meier 
Branch: stmgc-c4
Changeset: r65772:17d05e7de409
Date: 2013-07-29 11:20 +0200
http://bitbucket.org/pypy/pypy/changeset/17d05e7de409/

Log:adapt to new api

diff --git a/rpython/translator/stm/test/targetjit1.py 
b/rpython/translator/stm/test/targetjit1.py
--- a/rpython/translator/stm/test/targetjit1.py
+++ b/rpython/translator/stm/test/targetjit1.py
@@ -52,17 +52,13 @@
 
 def run(self):
 try:
-rstm.perform_transaction(ThreadRunner.run_really,
- ThreadRunner, self)
+while self.value < glob.LENGTH:
+jitdriver.jit_merge_point(self=self)
+glob.node = Node(self.value, glob.node)
+self.value += 1
 finally:
 self.finished_lock.release()
 
-def run_really(self, retry_counter):
-jitdriver.jit_merge_point(self=self)
-glob.node = Node(self.value, glob.node)
-self.value += 1
-return int(self.value < glob.LENGTH)
-
 jitdriver = jit.JitDriver(greens=[], reds=['self'])
 
 # 
@@ -84,9 +80,9 @@
 bootstrapper.lock = None
 bootstrapper.args = None
 
-def _freeze_(self):
-self.reinit()
-return False
+# def _freeze_(self):
+# self.reinit()
+# return False
 
 @staticmethod
 def bootstrap():
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] extradoc extradoc: an announcement for the demo evening

2013-07-29 Thread cfbolz
Author: Carl Friedrich Bolz 
Branch: extradoc
Changeset: r5011:6ab14e85a0c2
Date: 2013-07-29 12:04 +0200
http://bitbucket.org/pypy/extradoc/changeset/6ab14e85a0c2/

Log:an announcement for the demo evening

diff --git a/sprintinfo/london-2013/demo-announcement.txt 
b/sprintinfo/london-2013/demo-announcement.txt
new file mode 100644
--- /dev/null
+++ b/sprintinfo/london-2013/demo-announcement.txt
@@ -0,0 +1,29 @@
+PyPy is a fast Python VM. Maybe you've never used PyPy and want to find out
+what use it might be for you? Or you and your organisation have been using it
+and you want to find out more about how it works under the hood? If so, this
+demo session is for you!
+
+Members of the PyPy team will give a series of lightning talks on PyPy: its
+benefits; how it works; research currently being undertaken to make it
+faster; and unusual uses it can be put to. Speakers will be available
+afterwards for informal discussions. This is the first time an event like
+this has been held in the UK, and is a unique opportunity to speak to core
+people. Speakers confirmed thus far include: Armin Rigo, `Maciej 
Fijałkowski`_,
+`Carl Friedrich Bolz`_, `Lukas Diekmann`_, `Laurence Tratt`__.
+
+.. __: http://tratt.net/laurie/
+
+.. _`Maciej Fijałkowski`: http://baroquesoftware.com/
+.. _`Carl Friedrich Bolz`: http://cfbolz.de
+.. _`Lukas Diekmann`: http://lukasdiekmann.com/
+
+The venue for this talk is the `Software Development Team`_, King's College
+London. The main entrance is on the Strand, from where the room for the event
+will be clearly signposted. Travel directions can be found at
+http://www.kcl.ac.uk/campuslife/campuses/directions/strand.aspx
+
+.. _`Software Development Team`: http://soft-dev.org/
+
+If you have any questions about the event, please contact `Laurence Tratt`_
+
+.. _`Laurence Tratt`: mailto:lau...@tratt.net
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: ups fix

2013-07-29 Thread fijal
Author: Maciej Fijalkowski 
Branch: 
Changeset: r65775:ee83b070300a
Date: 2013-07-29 12:39 +0200
http://bitbucket.org/pypy/pypy/changeset/ee83b070300a/

Log:ups fix

diff --git a/pypy/tool/jitlogparser/parser.py b/pypy/tool/jitlogparser/parser.py
--- a/pypy/tool/jitlogparser/parser.py
+++ b/pypy/tool/jitlogparser/parser.py
@@ -396,7 +396,7 @@
 comm = loop.comment
 comm = comm.lower()
 if comm.startswith('# bridge'):
-m = re.search('guard (-?[\da-f]+)', comm)
+m = re.search('guard 0x(-?[\da-f]+)', comm)
 name = 'guard ' + m.group(1)
 elif "(" in comm:
 name = comm[2:comm.find('(')-1]
@@ -460,4 +460,4 @@
 
 if __name__ == '__main__':
 import_log(sys.argv[1])
-
+
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] extradoc extradoc: Add myself (London 2013).

2013-07-29 Thread Manuel Jacob
Author: Manuel Jacob
Branch: extradoc
Changeset: r5012:8ac2a032fde2
Date: 2013-07-29 13:24 +0200
http://bitbucket.org/pypy/extradoc/changeset/8ac2a032fde2/

Log:Add myself (London 2013).

diff --git a/sprintinfo/london-2013/people.txt 
b/sprintinfo/london-2013/people.txt
--- a/sprintinfo/london-2013/people.txt
+++ b/sprintinfo/london-2013/people.txt
@@ -20,6 +20,7 @@
 Remi Meier   24/8-1/9   ?
 Marko Bencun 24/8-1/9   ?
 Maciej Fijalkowski   25/8-1/9   private
+Manuel Jacob ?  sth. cheap, pref. share
  == ===
 
 
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy refactor-str-types: Add auto-convertion method descr_contains() in W_BytesObject.

2013-07-29 Thread Manuel Jacob
Author: Manuel Jacob
Branch: refactor-str-types
Changeset: r65777:fcbbf370c6ac
Date: 2013-07-29 14:36 +0200
http://bitbucket.org/pypy/pypy/changeset/fcbbf370c6ac/

Log:Add auto-convertion method descr_contains() in W_BytesObject.

diff --git a/pypy/objspace/std/bytesobject.py b/pypy/objspace/std/bytesobject.py
--- a/pypy/objspace/std/bytesobject.py
+++ b/pypy/objspace/std/bytesobject.py
@@ -204,6 +204,12 @@
 return self_as_unicode._endswith(space, self_as_unicode._value, 
w_suffix, start, end)
 return StringMethods._endswith(self, space, value, w_suffix, start, 
end)
 
+def descr_contains(self, space, w_sub):
+if space.isinstance_w(w_sub, space.w_unicode):
+self_as_unicode = unicode_from_encoded_object(space, self, None, 
None)
+return 
space.newbool(self_as_unicode._value.find(self._op_val(space, w_sub)) >= 0)
+return StringMethods.descr_contains(self, space, w_sub)
+
 @unwrap_spec(count=int)
 def descr_replace(self, space, w_old, w_new, count=-1):
 old_is_unicode = space.isinstance_w(w_old, space.w_unicode)
diff --git a/pypy/objspace/std/test/test_unicodeobject.py 
b/pypy/objspace/std/test/test_unicodeobject.py
--- a/pypy/objspace/std/test/test_unicodeobject.py
+++ b/pypy/objspace/std/test/test_unicodeobject.py
@@ -86,6 +86,7 @@
 def test_contains(self):
 assert u'a' in 'abc'
 assert 'a' in u'abc'
+raises(UnicodeDecodeError, "u'\xe2' in 'g\xe2teau'")
 
 def test_splitlines(self):
 assert u''.splitlines() == []
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy refactor-str-types: Fix app-level unicode's istitle() method.

2013-07-29 Thread Manuel Jacob
Author: Manuel Jacob
Branch: refactor-str-types
Changeset: r65778:76dd0077753a
Date: 2013-07-29 14:52 +0200
http://bitbucket.org/pypy/pypy/changeset/76dd0077753a/

Log:Fix app-level unicode's istitle() method.

diff --git a/pypy/objspace/std/stringmethods.py 
b/pypy/objspace/std/stringmethods.py
--- a/pypy/objspace/std/stringmethods.py
+++ b/pypy/objspace/std/stringmethods.py
@@ -357,7 +357,7 @@
 
 for pos in range(0, len(input)):
 ch = input[pos]
-if self._isupper(ch):
+if self._istitle(ch):
 if previous_is_cased:
 return space.w_False
 previous_is_cased = True
diff --git a/pypy/objspace/std/test/test_unicodeobject.py 
b/pypy/objspace/std/test/test_unicodeobject.py
--- a/pypy/objspace/std/test/test_unicodeobject.py
+++ b/pypy/objspace/std/test/test_unicodeobject.py
@@ -215,7 +215,9 @@
 assert u"!Brown Fox".istitle() == True
 assert u"BrowN Fox".istitle() == True
 assert u"!Brown Fox".istitle() == False
-
+assert u'\u1FFc'.istitle()
+assert u'Greek \u1FFcitlecases ...'.istitle()
+
 def test_capitalize(self):
 assert u"brown fox".capitalize() == u"Brown fox"
 assert u' hello '.capitalize() == u' hello '
diff --git a/pypy/objspace/std/unicodeobject.py 
b/pypy/objspace/std/unicodeobject.py
--- a/pypy/objspace/std/unicodeobject.py
+++ b/pypy/objspace/std/unicodeobject.py
@@ -105,7 +105,7 @@
 return unicodedb.isnumeric(ord(ch))
 
 def _istitle(self, ch):
-return unicodedb.istitle(ord(ch))
+return unicodedb.isupper(ord(ch)) or unicodedb.istitle(ord(ch))
 
 def _isspace(self, ch):
 return unicodedb.isspace(ord(ch))
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy refactor-str-types: Test and fix to make bytearray.partition() return a new object.

2013-07-29 Thread Manuel Jacob
Author: Manuel Jacob
Branch: refactor-str-types
Changeset: r65776:21cef1d9c01c
Date: 2013-07-29 13:43 +0200
http://bitbucket.org/pypy/pypy/changeset/21cef1d9c01c/

Log:Test and fix to make bytearray.partition() return a new object.

diff --git a/pypy/objspace/std/stringmethods.py 
b/pypy/objspace/std/stringmethods.py
--- a/pypy/objspace/std/stringmethods.py
+++ b/pypy/objspace/std/stringmethods.py
@@ -484,6 +484,9 @@
  space.wrap("empty separator"))
 pos = value.find(sub)
 if pos == -1:
+from pypy.objspace.std.bytearrayobject import W_BytearrayObject
+if isinstance(self, W_BytearrayObject):
+self = self._new(value)
 return space.newtuple([self, self._empty(), self._empty()])
 else:
 from pypy.objspace.std.bytearrayobject import W_BytearrayObject
diff --git a/pypy/objspace/std/test/test_bytearrayobject.py 
b/pypy/objspace/std/test/test_bytearrayobject.py
--- a/pypy/objspace/std/test/test_bytearrayobject.py
+++ b/pypy/objspace/std/test/test_bytearrayobject.py
@@ -462,3 +462,7 @@
 for i in range(count):
 b[i:i+1] = 'y'
 assert str(b) == 'y' * count
+
+def test_partition_return_copy(self):
+b = bytearray(b'foo')
+assert b.partition(b'x')[0] is not b
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Fix the test and generate more efficient code.

2013-07-29 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r65781:caa2340430f2
Date: 2013-07-29 14:59 +0200
http://bitbucket.org/pypy/pypy/changeset/caa2340430f2/

Log:Fix the test and generate more efficient code.

diff --git a/rpython/jit/backend/x86/assembler.py 
b/rpython/jit/backend/x86/assembler.py
--- a/rpython/jit/backend/x86/assembler.py
+++ b/rpython/jit/backend/x86/assembler.py
@@ -14,7 +14,7 @@
 from rpython.rlib.jit import AsmInfo
 from rpython.jit.backend.model import CompiledLoopToken
 from rpython.jit.backend.x86.regalloc import (RegAlloc, get_ebp_ofs,
-gpr_reg_mgr_cls, xmm_reg_mgr_cls, _register_arguments)
+gpr_reg_mgr_cls, xmm_reg_mgr_cls)
 from rpython.jit.backend.llsupport.regalloc import (get_scale, 
valid_addressing_size)
 from rpython.jit.backend.x86.arch import (FRAME_FIXED_SIZE, WORD, IS_X86_64,
JITFRAME_FIXED_SIZE, IS_X86_32,
@@ -154,7 +154,11 @@
 come.
 """
 mc = codebuf.MachineCodeBlockWrapper()
-self._push_all_regs_to_frame(mc, [], supports_floats, callee_only)
+# copy registers to the frame, with the exception of the
+# 'cond_call_register_arguments' and eax, because these have already
+# been saved by the caller
+self._push_all_regs_to_frame(mc, cond_call_register_arguments + [eax],
+ supports_floats, callee_only)
 if IS_X86_64:
 mc.SUB(esp, imm(WORD))
 self.set_extra_stack_depth(mc, 2 * WORD)
@@ -164,7 +168,7 @@
 mc.SUB(esp, imm(WORD * 7))
 self.set_extra_stack_depth(mc, 8 * WORD)
 for i in range(4):
-mc.MOV_sr(i * WORD, _register_arguments[i].value)
+mc.MOV_sr(i * WORD, cond_call_register_arguments[i].value)
 mc.CALL(eax)
 if IS_X86_64:
 mc.ADD(esp, imm(WORD))
@@ -172,8 +176,7 @@
 mc.ADD(esp, imm(WORD * 7))
 self.set_extra_stack_depth(mc, 0)
 self._reload_frame_if_necessary(mc, align_stack=True)
-self._pop_all_regs_from_frame(mc, [], supports_floats,
-  callee_only)
+self._pop_all_regs_from_frame(mc, [], supports_floats, callee_only)
 mc.RET()
 return mc.materialize(self.cpu.asmmemmgr, [])
 
@@ -1755,7 +1758,7 @@
 regs = gpr_reg_mgr_cls.save_around_call_regs
 else:
 regs = gpr_reg_mgr_cls.all_regs
-for i, gpr in enumerate(regs):
+for gpr in regs:
 if gpr not in ignored_regs:
 v = gpr_reg_mgr_cls.all_reg_indexes[gpr.value]
 mc.MOV_br(v * WORD + base_ofs, gpr.value)
@@ -1777,7 +1780,7 @@
 regs = gpr_reg_mgr_cls.save_around_call_regs
 else:
 regs = gpr_reg_mgr_cls.all_regs
-for i, gpr in enumerate(regs):
+for gpr in regs:
 if gpr not in ignored_regs:
 v = gpr_reg_mgr_cls.all_reg_indexes[gpr.value]
 mc.MOV_rb(gpr.value, v * WORD + base_ofs)
@@ -2161,11 +2164,29 @@
 def label(self):
 self._check_frame_depth_debug(self.mc)
 
-def cond_call(self, op, gcmap, cond_loc, call_loc):
-self.mc.TEST(cond_loc, cond_loc)
+def cond_call(self, op, gcmap, loc_cond, imm_func, arglocs):
+self.mc.TEST(loc_cond, loc_cond)
 self.mc.J_il8(rx86.Conditions['Z'], 0) # patched later
 jmp_adr = self.mc.get_relative_pos()
+#
 self.push_gcmap(self.mc, gcmap, store=True)
+#
+# first save away the 4 registers from 'cond_call_register_arguments'
+# plus the register 'eax'
+base_ofs = self.cpu.get_baseofs_of_frame_field()
+for gpr in cond_call_register_arguments + [eax]:
+v = gpr_reg_mgr_cls.all_reg_indexes[gpr.value]
+self.mc.MOV_br(v * WORD + base_ofs, gpr.value)
+#
+# load the 0-to-4 arguments into these registers
+from rpython.jit.backend.x86.jump import remap_frame_layout
+remap_frame_layout(self, arglocs,
+   cond_call_register_arguments[:len(arglocs)], eax)
+#
+# load the constant address of the function to call into eax
+self.mc.MOV(eax, imm_func)
+#
+# figure out which variant of cond_call_slowpath to call, and call it
 callee_only = False
 floats = False
 if self._regalloc is not None:
@@ -2348,5 +2369,7 @@
 os.write(2, '[x86/asm] %s\n' % msg)
 raise NotImplementedError(msg)
 
+cond_call_register_arguments = [edi, esi, edx, ecx]
+
 class BridgeAlreadyCompiled(Exception):
 pass
diff --git a/rpython/jit/backend/x86/regalloc.py 
b/rpython/jit/backend/x86/regalloc.py
--- a/rpython/jit/backend/x86/regalloc.py
+++ b/rpython/jit/backend/x86/regalloc.py
@@ -119,8 +119,6 @@
 for _i, _reg in enumerate(gpr_reg_mgr_cls.all_regs):
 gpr_reg_mgr_cls.all_reg_indexes[_reg.value] = _i
 
-_register_arguments = [edi, esi, edx,

[pypy-commit] pypy default: A random test for COND_CALL. It can fail so far.

2013-07-29 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r65780:0a06c71baefa
Date: 2013-07-29 14:58 +0200
http://bitbucket.org/pypy/pypy/changeset/0a06c71baefa/

Log:A random test for COND_CALL. It can fail so far.

diff --git a/rpython/jit/backend/test/test_ll_random.py 
b/rpython/jit/backend/test/test_ll_random.py
--- a/rpython/jit/backend/test/test_ll_random.py
+++ b/rpython/jit/backend/test/test_ll_random.py
@@ -502,6 +502,7 @@
 # 3. raising call and wrong guard_exception
 # 4. raising call and guard_no_exception
 # 5. non raising call and guard_exception
+# (6. test of a cond_call, always non-raising and guard_no_exception)
 
 class BaseCallOperation(test_random.AbstractOperation):
 def non_raising_func_code(self, builder, r):
@@ -648,6 +649,34 @@
 builder.guard_op = op
 builder.loop.operations.append(op)
 
+# 6. a conditional call (for now always with no exception raised)
+class CondCallOperation(BaseCallOperation):
+def produce_into(self, builder, r):
+fail_subset = builder.subset_of_intvars(r)
+v_cond = builder.get_bool_var(r)
+subset = builder.subset_of_intvars(r)[:4]
+for i in range(len(subset)):
+if r.random() < 0.35:
+subset[i] = ConstInt(r.random_integer())
+#
+seen = []
+def call_me(*args):
+if len(seen) == 0:
+seen.append(args)
+else:
+assert seen[0] == args
+#
+TP = lltype.FuncType([lltype.Signed] * len(subset), lltype.Void)
+ptr = llhelper(lltype.Ptr(TP), call_me)
+c_addr = ConstAddr(llmemory.cast_ptr_to_adr(ptr), builder.cpu)
+args = [v_cond, c_addr] + subset
+descr = self.getcalldescr(builder, TP)
+self.put(builder, args, descr)
+op = ResOperation(rop.GUARD_NO_EXCEPTION, [], None,
+  descr=builder.getfaildescr())
+op.setfailargs(fail_subset)
+builder.loop.operations.append(op)
+
 # 
 
 OPERATIONS = test_random.OPERATIONS[:]
@@ -684,6 +713,7 @@
 OPERATIONS.append(RaisingCallOperationGuardNoException(rop.CALL))
 OPERATIONS.append(RaisingCallOperationWrongGuardException(rop.CALL))
 OPERATIONS.append(CallOperationException(rop.CALL))
+OPERATIONS.append(CondCallOperation(rop.COND_CALL))
 OPERATIONS.append(GuardNonNullClassOperation(rop.GUARD_NONNULL_CLASS))
 
 LLtypeOperationBuilder.OPERATIONS = OPERATIONS
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: fix

2013-07-29 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r65782:ee82feb0142b
Date: 2013-07-29 15:07 +0200
http://bitbucket.org/pypy/pypy/changeset/ee82feb0142b/

Log:fix

diff --git a/rpython/jit/backend/x86/assembler.py 
b/rpython/jit/backend/x86/assembler.py
--- a/rpython/jit/backend/x86/assembler.py
+++ b/rpython/jit/backend/x86/assembler.py
@@ -2181,7 +2181,8 @@
 # load the 0-to-4 arguments into these registers
 from rpython.jit.backend.x86.jump import remap_frame_layout
 remap_frame_layout(self, arglocs,
-   cond_call_register_arguments[:len(arglocs)], eax)
+   cond_call_register_arguments[:len(arglocs)],
+   X86_64_SCRATCH_REG if IS_X86_64 else None)
 #
 # load the constant address of the function to call into eax
 self.mc.MOV(eax, imm_func)
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Only save registers that really contain something

2013-07-29 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r65783:80e614cc3039
Date: 2013-07-29 15:22 +0200
http://bitbucket.org/pypy/pypy/changeset/80e614cc3039/

Log:Only save registers that really contain something

diff --git a/rpython/jit/backend/x86/assembler.py 
b/rpython/jit/backend/x86/assembler.py
--- a/rpython/jit/backend/x86/assembler.py
+++ b/rpython/jit/backend/x86/assembler.py
@@ -2174,7 +2174,10 @@
 # first save away the 4 registers from 'cond_call_register_arguments'
 # plus the register 'eax'
 base_ofs = self.cpu.get_baseofs_of_frame_field()
+should_be_saved = self._regalloc.rm.reg_bindings.values()
 for gpr in cond_call_register_arguments + [eax]:
+if gpr not in should_be_saved:
+continue
 v = gpr_reg_mgr_cls.all_reg_indexes[gpr.value]
 self.mc.MOV_br(v * WORD + base_ofs, gpr.value)
 #
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy refactor-str-types: Remove these imports.

2013-07-29 Thread Manuel Jacob
Author: Manuel Jacob
Branch: refactor-str-types
Changeset: r65785:7fc0e8b104b0
Date: 2013-07-29 15:33 +0200
http://bitbucket.org/pypy/pypy/changeset/7fc0e8b104b0/

Log:Remove these imports.

diff --git a/pypy/objspace/std/bytearrayobject.py 
b/pypy/objspace/std/bytearrayobject.py
--- a/pypy/objspace/std/bytearrayobject.py
+++ b/pypy/objspace/std/bytearrayobject.py
@@ -1,11 +1,9 @@
 """The builtin bytearray implementation"""
 
-from pypy.interpreter.baseobjspace import W_Root
 from pypy.interpreter.buffer import RWBuffer
 from pypy.interpreter.error import OperationError, operationerrfmt
 from pypy.interpreter.gateway import interp2app, unwrap_spec, WrappedDefault
 from pypy.interpreter.signature import Signature
-from pypy.objspace.std.inttype import wrapint
 from pypy.objspace.std.model import W_Object, registerimplementation
 from pypy.objspace.std.sliceobject import W_SliceObject
 from pypy.objspace.std.stdtypedef import StdTypeDef
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy refactor-str-types: Remove string types from multi-method table.

2013-07-29 Thread Manuel Jacob
Author: Manuel Jacob
Branch: refactor-str-types
Changeset: r65786:808f2aea0f13
Date: 2013-07-29 16:00 +0200
http://bitbucket.org/pypy/pypy/changeset/808f2aea0f13/

Log:Remove string types from multi-method table.

diff --git a/pypy/module/micronumpy/interp_boxes.py 
b/pypy/module/micronumpy/interp_boxes.py
--- a/pypy/module/micronumpy/interp_boxes.py
+++ b/pypy/module/micronumpy/interp_boxes.py
@@ -2,9 +2,9 @@
 from pypy.interpreter.error import operationerrfmt, OperationError
 from pypy.interpreter.gateway import interp2app, unwrap_spec
 from pypy.interpreter.typedef import TypeDef, GetSetProperty
-from pypy.objspace.std.bytesobject import str_typedef
+from pypy.objspace.std.bytesobject import W_BytesObject
 from pypy.objspace.std.floattype import float_typedef
-from pypy.objspace.std.unicodeobject import unicode_typedef, 
unicode_from_object
+from pypy.objspace.std.unicodeobject import W_UnicodeObject, 
unicode_from_object
 from pypy.objspace.std.inttype import int_typedef
 from pypy.objspace.std.complextype import complex_typedef
 from rpython.rlib.rarithmetic import LONG_BIT
@@ -682,12 +682,12 @@
 __module__ = "numpypy",
 )
 
-W_StringBox.typedef = TypeDef("string_", (str_typedef, W_CharacterBox.typedef),
+W_StringBox.typedef = TypeDef("string_", (W_BytesObject.typedef, 
W_CharacterBox.typedef),
 __module__ = "numpypy",
 __new__ = interp2app(W_StringBox.descr__new__string_box.im_func),
 )
 
-W_UnicodeBox.typedef = TypeDef("unicode_", (unicode_typedef, 
W_CharacterBox.typedef),
+W_UnicodeBox.typedef = TypeDef("unicode_", (W_UnicodeObject.typedef, 
W_CharacterBox.typedef),
 __module__ = "numpypy",
 __new__ = interp2app(W_UnicodeBox.descr__new__unicode_box.im_func),
 )
diff --git a/pypy/objspace/std/bytearrayobject.py 
b/pypy/objspace/std/bytearrayobject.py
--- a/pypy/objspace/std/bytearrayobject.py
+++ b/pypy/objspace/std/bytearrayobject.py
@@ -1,10 +1,10 @@
 """The builtin bytearray implementation"""
 
+from pypy.interpreter.baseobjspace import W_Root
 from pypy.interpreter.buffer import RWBuffer
 from pypy.interpreter.error import OperationError, operationerrfmt
 from pypy.interpreter.gateway import interp2app, unwrap_spec, WrappedDefault
 from pypy.interpreter.signature import Signature
-from pypy.objspace.std.model import W_Object, registerimplementation
 from pypy.objspace.std.sliceobject import W_SliceObject
 from pypy.objspace.std.stdtypedef import StdTypeDef
 from pypy.objspace.std.stringmethods import StringMethods
@@ -16,7 +16,7 @@
 def _make_data(s):
 return [s[i] for i in range(len(s))]
 
-class W_BytearrayObject(W_Object, StringMethods):
+class W_BytearrayObject(W_Root, StringMethods):
 def __init__(w_self, data):
 w_self.data = data
 
@@ -378,7 +378,7 @@
 
 # 
 
-bytearray_typedef = W_BytearrayObject.typedef = StdTypeDef(
+W_BytearrayObject.typedef = StdTypeDef(
 "bytearray",
 __doc__ = '''bytearray() -> an empty bytearray
 bytearray(sequence) -> bytearray initialized from sequence\'s items
@@ -460,7 +460,6 @@
 remove = interp2app(W_BytearrayObject.descr_remove),
 reverse = interp2app(W_BytearrayObject.descr_reverse),
 )
-registerimplementation(W_BytearrayObject)
 
 init_signature = Signature(['source', 'encoding', 'errors'], None, None)
 init_defaults = [None, None, None]
diff --git a/pypy/objspace/std/bytesobject.py b/pypy/objspace/std/bytesobject.py
--- a/pypy/objspace/std/bytesobject.py
+++ b/pypy/objspace/std/bytesobject.py
@@ -1,12 +1,12 @@
 """The builtin str implementation"""
 
+from pypy.interpreter.baseobjspace import W_Root
 from pypy.interpreter.buffer import StringBuffer
 from pypy.interpreter.error import OperationError, operationerrfmt
 from pypy.interpreter.gateway import interp2app, unwrap_spec, WrappedDefault
 from pypy.objspace.std import newformat
 from pypy.objspace.std.basestringtype import basestring_typedef
 from pypy.objspace.std.formatting import mod_format
-from pypy.objspace.std.model import W_Object, registerimplementation
 from pypy.objspace.std.stdtypedef import StdTypeDef
 from pypy.objspace.std.stringmethods import StringMethods
 from pypy.objspace.std.unicodeobject import (unicode_from_string,
@@ -16,7 +16,7 @@
 from rpython.rlib.rstring import StringBuilder, replace
 
 
-class W_AbstractBytesObject(W_Object):
+class W_AbstractBytesObject(W_Root):
 __slots__ = ()
 
 def is_w(self, space, w_other):
@@ -265,8 +265,6 @@
 # listview_str
 return [s for s in value]
 
-registerimplementation(W_BytesObject)
-
 W_BytesObject.EMPTY = W_BytesObject('')
 W_BytesObject.PREBUILT = [W_BytesObject(chr(i)) for i in range(256)]
 del i
@@ -294,7 +292,7 @@
 else:
 return W_BytesObject(c)
 
-str_typedef = W_BytesObject.typedef = StdTypeDef(
+W_BytesObject.typedef = StdTypeDef(
 "str", basestring_typedef,
 __new__ = interp2app(W_BytesObject.descr_new),
 __doc__ = '''str(object) -> string
diff --git a/pypy/objspace/std/model.p

[pypy-commit] pypy refactor-str-types: Fix translation.

2013-07-29 Thread Manuel Jacob
Author: Manuel Jacob
Branch: refactor-str-types
Changeset: r65787:8f3122422344
Date: 2013-07-29 16:04 +0200
http://bitbucket.org/pypy/pypy/changeset/8f3122422344/

Log:Fix translation.

diff --git a/pypy/objspace/std/bytearrayobject.py 
b/pypy/objspace/std/bytearrayobject.py
--- a/pypy/objspace/std/bytearrayobject.py
+++ b/pypy/objspace/std/bytearrayobject.py
@@ -58,7 +58,7 @@
 return ch.islower()
 
 def _istitle(self, ch):
-return ch.istitle()
+return ch.isupper()
 
 def _isspace(self, ch):
 return ch.isspace()
diff --git a/pypy/objspace/std/bytesobject.py b/pypy/objspace/std/bytesobject.py
--- a/pypy/objspace/std/bytesobject.py
+++ b/pypy/objspace/std/bytesobject.py
@@ -101,7 +101,7 @@
 return ch.islower()
 
 def _istitle(self, ch):
-return ch.istitle()
+return ch.isupper()
 
 def _isspace(self, ch):
 return ch.isspace()
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy refactor-str-types: Remove dead code in bytearrayobject.py.

2013-07-29 Thread Manuel Jacob
Author: Manuel Jacob
Branch: refactor-str-types
Changeset: r65784:e783a620e81a
Date: 2013-07-29 15:24 +0200
http://bitbucket.org/pypy/pypy/changeset/e783a620e81a/

Log:Remove dead code in bytearrayobject.py.

diff --git a/pypy/objspace/std/bytearrayobject.py 
b/pypy/objspace/std/bytearrayobject.py
--- a/pypy/objspace/std/bytearrayobject.py
+++ b/pypy/objspace/std/bytearrayobject.py
@@ -1,20 +1,15 @@
 """The builtin bytearray implementation"""
 
-from pypy.interpreter.baseobjspace import ObjSpace, W_Root
+from pypy.interpreter.baseobjspace import W_Root
 from pypy.interpreter.buffer import RWBuffer
 from pypy.interpreter.error import OperationError, operationerrfmt
 from pypy.interpreter.gateway import interp2app, unwrap_spec, WrappedDefault
 from pypy.interpreter.signature import Signature
-from pypy.objspace.std import bytesobject
-from pypy.objspace.std.intobject import W_IntObject
 from pypy.objspace.std.inttype import wrapint
 from pypy.objspace.std.model import W_Object, registerimplementation
-from pypy.objspace.std.multimethod import FailedToImplement
-from pypy.objspace.std.noneobject import W_NoneObject
-from pypy.objspace.std.sliceobject import W_SliceObject, normalize_simple_slice
-from pypy.objspace.std.stdtypedef import StdTypeDef, SMM
+from pypy.objspace.std.sliceobject import W_SliceObject
+from pypy.objspace.std.stdtypedef import StdTypeDef
 from pypy.objspace.std.stringmethods import StringMethods
-from pypy.objspace.std.unicodeobject import W_UnicodeObject
 from pypy.objspace.std.util import get_positive_index
 from rpython.rlib.objectmodel import newlist_hint, resizelist_hint
 from rpython.rlib.rstring import StringBuilder
@@ -267,7 +262,7 @@
 def descr_remove(self, space, w_char):
 char = space.int_w(space.index(w_char))
 try:
-result = self.data.remove(chr(char))
+self.data.remove(chr(char))
 except ValueError:
 raise OperationError(space.w_ValueError, space.wrap(
 "value not found in bytearray"))
@@ -275,42 +270,6 @@
 def descr_reverse(self, space):
 self.data.reverse()
 
-
-bytearray_append  = SMM('append', 2)
-bytearray_extend  = SMM('extend', 2)
-bytearray_insert  = SMM('insert', 3,
-doc="B.insert(index, int) -> None\n\n"
-"Insert a single item into the bytearray before "
-"the given index.")
-
-bytearray_pop  = SMM('pop', 2, defaults=(-1,),
-doc="B.pop([index]) -> int\n\nRemove and return a "
-"single item from B. If no index\nargument is given, "
-"will pop the last value.")
-
-bytearray_remove  = SMM('remove', 2,
-doc="B.remove(int) -> None\n\n"
-"Remove the first occurance of a value in B.")
-
-bytearray_reverse  = SMM('reverse', 1,
-doc="B.reverse() -> None\n\n"
-"Reverse the order of the values in B in place.")
-
-bytearray_strip  = SMM('strip', 2, defaults=(None,),
-doc="B.strip([bytes]) -> bytearray\n\nStrip leading "
-"and trailing bytes contained in the argument.\nIf "
-"the argument is omitted, strip ASCII whitespace.")
-
-bytearray_lstrip  = SMM('lstrip', 2, defaults=(None,),
-doc="B.lstrip([bytes]) -> bytearray\n\nStrip leading "
-"bytes contained in the argument.\nIf the argument is "
-"omitted, strip leading ASCII whitespace.")
-
-bytearray_rstrip  = SMM('rstrip', 2, defaults=(None,),
-doc="'B.rstrip([bytes]) -> bytearray\n\nStrip trailing "
-"bytes contained in the argument.\nIf the argument is "
-"omitted, strip trailing ASCII whitespace.")
-
 def getbytevalue(space, w_value):
 if space.isinstance_w(w_value, space.w_str):
 string = space.str_w(w_value)
@@ -508,191 +467,8 @@
 init_signature = Signature(['source', 'encoding', 'errors'], None, None)
 init_defaults = [None, None, None]
 
-def len__Bytearray(space, w_bytearray):
-result = len(w_bytearray.data)
-return wrapint(space, result)
 
-def ord__Bytearray(space, w_bytearray):
-if len(w_bytearray.data) != 1:
-raise OperationError(space.w_TypeError,
- space.wrap("expected a character, but string"
-"of length %s found" % len(w_bytearray.data)))
-return space.wrap(ord(w_bytearray.data[0]))
-
-def getitem__Bytearray_ANY(space, w_bytearray, w_index):
-# getindex_w should get a second argument space.w_IndexError,
-# but that doesn't exist the first time this is called.
-try:
-w_IndexError = space.w_IndexError
-except AttributeError:
-w_IndexError = None
-index = space.getindex_w(w_index, w_IndexError, "bytearray index")
-try:
-return space.newint(ord(w_bytearray.data[index]))
-except IndexError:
-raise O

[pypy-commit] pypy default: Fix the comments (only).

2013-07-29 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r65788:de8a5af76f3a
Date: 2013-07-29 16:15 +0200
http://bitbucket.org/pypy/pypy/changeset/de8a5af76f3a/

Log:Fix the comments (only).

diff --git a/rpython/jit/backend/x86/assembler.py 
b/rpython/jit/backend/x86/assembler.py
--- a/rpython/jit/backend/x86/assembler.py
+++ b/rpython/jit/backend/x86/assembler.py
@@ -156,17 +156,20 @@
 mc = codebuf.MachineCodeBlockWrapper()
 # copy registers to the frame, with the exception of the
 # 'cond_call_register_arguments' and eax, because these have already
-# been saved by the caller
+# been saved by the caller.  Note that this is not symmetrical:
+# these 5 registers are saved by the caller but restored here at
+# the end of this function.
 self._push_all_regs_to_frame(mc, cond_call_register_arguments + [eax],
  supports_floats, callee_only)
 if IS_X86_64:
-mc.SUB(esp, imm(WORD))
+mc.SUB(esp, imm(WORD)) # alignment
 self.set_extra_stack_depth(mc, 2 * WORD)
+# the arguments are already in the correct registers
 else:
-# we want space for 3 arguments + call + alignment
-# the caller is responsible for putting arguments in the right spot
+# we want space for 4 arguments + call + alignment
 mc.SUB(esp, imm(WORD * 7))
 self.set_extra_stack_depth(mc, 8 * WORD)
+# store the arguments at the correct place in the stack
 for i in range(4):
 mc.MOV_sr(i * WORD, cond_call_register_arguments[i].value)
 mc.CALL(eax)
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Move pop_gcmap() into the helper.

2013-07-29 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r65789:285d5480fe3c
Date: 2013-07-29 16:31 +0200
http://bitbucket.org/pypy/pypy/changeset/285d5480fe3c/

Log:Move pop_gcmap() into the helper.

diff --git a/rpython/jit/backend/x86/assembler.py 
b/rpython/jit/backend/x86/assembler.py
--- a/rpython/jit/backend/x86/assembler.py
+++ b/rpython/jit/backend/x86/assembler.py
@@ -180,6 +180,7 @@
 self.set_extra_stack_depth(mc, 0)
 self._reload_frame_if_necessary(mc, align_stack=True)
 self._pop_all_regs_from_frame(mc, [], supports_floats, callee_only)
+self.pop_gcmap(mc)   # push_gcmap(store=True) done by the caller
 mc.RET()
 return mc.materialize(self.cpu.asmmemmgr, [])
 
@@ -2206,11 +2207,13 @@
 floats = True
 cond_call_adr = self.cond_call_slowpath[floats * 2 + callee_only]
 self.mc.CALL(imm(cond_call_adr))
-self.pop_gcmap(self.mc)
-# never any result value
+# restoring the registers saved above, and doing pop_gcmap(), is left
+# to the cond_call_slowpath helper.  We never have any result value.
 offset = self.mc.get_relative_pos() - jmp_adr
 assert 0 < offset <= 127
 self.mc.overwrite(jmp_adr-1, chr(offset))
+# XXX if the next operation is a GUARD_NO_EXCEPTION, we should
+# somehow jump over it too in the fast path
 
 def malloc_cond(self, nursery_free_adr, nursery_top_adr, size, gcmap):
 assert size & (WORD-1) == 0 # must be correctly aligned
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Better docstring

2013-07-29 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r65790:c70b14d46ab9
Date: 2013-07-29 16:35 +0200
http://bitbucket.org/pypy/pypy/changeset/c70b14d46ab9/

Log:Better docstring

diff --git a/rpython/translator/goal/targetjitstandalone.py 
b/rpython/translator/goal/targetjitstandalone.py
--- a/rpython/translator/goal/targetjitstandalone.py
+++ b/rpython/translator/goal/targetjitstandalone.py
@@ -28,7 +28,9 @@
 
 def entry_point(argv):
 if len(argv) < 3:
-print "Usage: jitstandalone  "
+print "Usage: jitstandalone  "
+print "runs a total of '2 * count1 * count2' iterations"
+return 0
 count1 = int(argv[1])
 count2 = int(argv[2])
 s = 0
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy stmgc-c4: fix ptr_eq and add a test for it in zrpy_gc_test.py

2013-07-29 Thread Raemi
Author: Remi Meier 
Branch: stmgc-c4
Changeset: r65791:796f9faedadc
Date: 2013-07-29 16:54 +0200
http://bitbucket.org/pypy/pypy/changeset/796f9faedadc/

Log:fix ptr_eq and add a test for it in zrpy_gc_test.py

diff --git a/rpython/config/translationoption.py 
b/rpython/config/translationoption.py
--- a/rpython/config/translationoption.py
+++ b/rpython/config/translationoption.py
@@ -74,10 +74,10 @@
("translation.gctransformer", "boehm")],
  "minimark": [("translation.gctransformer", "framework")],
  "stmgc": [("translation.gctransformer", "framework"),
-   ("translation.gcrootfinder", "stm")],
+   ("translation.gcrootfinder", "stm"),
+   ("translation.gcremovetypeptr", False)],
  },
  suggests = {
- "stmgc": [("translation.gcremovetypeptr", True)],
  },
   cmdline="--gc"),
 ChoiceOption("gctransformer", "GC transformer that is used - internal",
diff --git a/rpython/jit/backend/llsupport/test/zrpy_gc_test.py 
b/rpython/jit/backend/llsupport/test/zrpy_gc_test.py
--- a/rpython/jit/backend/llsupport/test/zrpy_gc_test.py
+++ b/rpython/jit/backend/llsupport/test/zrpy_gc_test.py
@@ -45,9 +45,11 @@
 rgc.collect()
 rgc.collect(); rgc.collect()
 freed = 0
-for r in r_list:
+for i, r in enumerate(r_list):
 if r() is None:
 freed += 1
+else:
+print "not freed:", r(), "pos:", i
 print freed
 return 0
 
@@ -79,10 +81,11 @@
 if gcrootfinder == 'stm':
 t.config.translation.stm = True
 t.config.translation.gc = 'stmgc'
+gc = 'stmgc'
 else:
 t.config.translation.gc = gc
 #
-if gc != 'boehm':
+if gc != 'boehm' and gc != 'stmgc':
 t.config.translation.gcremovetypeptr = True
 for name, value in kwds.items():
 setattr(t.config.translation, name, value)
@@ -777,3 +780,33 @@
 
 def test_compile_framework_call_assembler(self):
 self.run('compile_framework_call_assembler')
+
+def define_compile_framework_ptr_eq(cls):
+# test ptr_eq
+def raiseassert(cond):
+if not bool(cond):
+raise AssertionError
+
+def before(n, x):
+x0 = X()
+x1 = X()
+ptrs = [None, x0, x1, X()]
+return (n, x, x0, x1, None, None, None,
+None, None, None, ptrs, None)
+
+@unroll_safe
+def f(n, x, x0, x1, x2, x3, x4, x5, x6, x7, ptrs, s):
+raiseassert(x0 != ptrs[0])
+raiseassert(x0 == ptrs[1])
+raiseassert(x0 != ptrs[2])
+raiseassert(x0 != ptrs[3])
+raiseassert(x1 != ptrs[0])
+raiseassert(x1 != ptrs[1])
+raiseassert(x1 == ptrs[2])
+raiseassert(x1 != ptrs[3])
+#
+return n - 1, x, x0, x1, x2, x3, x4, x5, x6, x7, ptrs, s
+return before, f, None
+
+def test_compile_framework_ptr_eq(self):
+self.run('compile_framework_ptr_eq')
diff --git a/rpython/jit/backend/x86/assembler.py 
b/rpython/jit/backend/x86/assembler.py
--- a/rpython/jit/backend/x86/assembler.py
+++ b/rpython/jit/backend/x86/assembler.py
@@ -1059,7 +1059,7 @@
 if not self.cpu.gc_ll_descr.stm:
 self.genop_guard_int_eq(op, guard_op, guard_token,
 arglocs, result_loc)
-assert not self.cpu.gc_ll_descr.stm
+assert self.cpu.gc_ll_descr.stm
 guard_opnum = guard_op.getopnum()
 self._stm_ptr_eq_fastpath(self.mc, arglocs, result_loc)
 if guard_opnum == rop.GUARD_FALSE:
@@ -1072,7 +1072,7 @@
 if not self.cpu.gc_ll_descr.stm:
 self.genop_guard_int_ne(op, guard_op, guard_token,
 arglocs, result_loc)
-assert not self.cpu.gc_ll_descr.stm
+assert self.cpu.gc_ll_descr.stm
 guard_opnum = guard_op.getopnum()
 self._stm_ptr_eq_fastpath(self.mc, arglocs, result_loc)
 if guard_opnum == rop.GUARD_FALSE:
@@ -2179,7 +2179,8 @@
 mc.CMP(X86_64_SCRATCH_REG, b_base)
 mc.SET_ir(rx86.Conditions['Z'], sl.value)
 mc.MOVZX8_rr(X86_64_SCRATCH_REG.value, sl.value)
-mc.TEST(X86_64_SCRATCH_REG, X86_64_SCRATCH_REG)
+# mc.TEST8_rr() without movzx8
+mc.TEST_rr(X86_64_SCRATCH_REG.value, X86_64_SCRATCH_REG.value)
 mc.J_il8(rx86.Conditions['NZ'], 0)
 j_ok1 = mc.get_relative_pos()
 
@@ -2188,7 +2189,7 @@
 mc.J_il8(rx86.Conditions['Z'], 0)
 j_ok2 = mc.get_relative_pos()
 #
-mc.CMP(a_base, imm(0))
+mc.CMP(b_base, imm(0))
 mc.J_il8(rx86.Conditions['Z'], 0)
 j_ok3 = mc.get_relative_pos()
 
@@ -2203,7 +2204,6 @

[pypy-commit] pypy refactor-str-types: Use space.listview_{str, unicode} in descr_join().

2013-07-29 Thread Manuel Jacob
Author: Manuel Jacob
Branch: refactor-str-types
Changeset: r65793:f0078474599f
Date: 2013-07-29 16:33 +0200
http://bitbucket.org/pypy/pypy/changeset/f0078474599f/

Log:Use space.listview_{str,unicode} in descr_join().

diff --git a/pypy/objspace/std/stringmethods.py 
b/pypy/objspace/std/stringmethods.py
--- a/pypy/objspace/std/stringmethods.py
+++ b/pypy/objspace/std/stringmethods.py
@@ -387,11 +387,21 @@
 
 @specialize.argtype(0)
 def descr_join(self, space, w_list):
-#l = space.listview_str(w_list)
-#if l is not None:
-#if len(l) == 1:
-#return space.wrap(l[0])
-#return space.wrap(self._val(space).join(l))
+from pypy.objspace.std.bytesobject import W_BytesObject
+from pypy.objspace.std.unicodeobject import W_UnicodeObject
+
+if isinstance(self, W_BytesObject):
+l = space.listview_str(w_list)
+if l is not None:
+if len(l) == 1:
+return space.wrap(l[0])
+return space.wrap(self._val(space).join(l))
+elif isinstance(self, W_UnicodeObject):
+l = space.listview_unicode(w_list)
+if l is not None:
+if len(l) == 1:
+return space.wrap(l[0])
+return space.wrap(self._val(space).join(l))
 
 list_w = space.listview(w_list)
 size = len(list_w)
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy refactor-str-types: Fix translation.

2013-07-29 Thread Manuel Jacob
Author: Manuel Jacob
Branch: refactor-str-types
Changeset: r65794:3788cc2a0262
Date: 2013-07-29 16:39 +0200
http://bitbucket.org/pypy/pypy/changeset/3788cc2a0262/

Log:Fix translation.

diff --git a/pypy/objspace/std/bytesobject.py b/pypy/objspace/std/bytesobject.py
--- a/pypy/objspace/std/bytesobject.py
+++ b/pypy/objspace/std/bytesobject.py
@@ -206,6 +206,8 @@
 
 def descr_contains(self, space, w_sub):
 if space.isinstance_w(w_sub, space.w_unicode):
+from pypy.objspace.std.unicodeobject import W_UnicodeObject
+assert isinstance(w_sub, W_UnicodeObject)
 self_as_unicode = unicode_from_encoded_object(space, self, None, 
None)
 return space.newbool(self_as_unicode._value.find(w_sub._value) >= 
0)
 return StringMethods.descr_contains(self, space, w_sub)
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy refactor-str-types: Fix marshalling of string types.

2013-07-29 Thread Manuel Jacob
Author: Manuel Jacob
Branch: refactor-str-types
Changeset: r65795:d0e72051a49f
Date: 2013-07-29 16:53 +0200
http://bitbucket.org/pypy/pypy/changeset/d0e72051a49f/

Log:Fix marshalling of string types.

diff --git a/pypy/objspace/std/marshal_impl.py 
b/pypy/objspace/std/marshal_impl.py
--- a/pypy/objspace/std/marshal_impl.py
+++ b/pypy/objspace/std/marshal_impl.py
@@ -251,11 +251,11 @@
 def PySTRING_CHECK_INTERNED(w_str):
 return False
 
-def marshal_w__Bytes(space, w_str, m):
-# using the fastest possible access method here
-# that does not touch the internal representation,
-# which might change (array of bytes?)
-s = w_str.unwrap(space)
+def marshal_bytes(space, w_str, m):
+if not isinstance(w_str, W_BytesObject):
+raise_exception(space, "unmarshallable object")
+
+s = space.str_w(w_str)
 if m.version >= 1 and PySTRING_CHECK_INTERNED(w_str):
 # we use a native rtyper stringdict for speed
 idx = m.stringtable.get(s, -1)
@@ -267,10 +267,11 @@
 m.atom_str(TYPE_INTERNED, s)
 else:
 m.atom_str(TYPE_STRING, s)
+handled_by_any.append(('str', marshal_bytes))
 
-def unmarshal_String(space, u, tc):
+def unmarshal_bytes(space, u, tc):
 return space.wrap(u.get_str())
-register(TYPE_STRING, unmarshal_String)
+register(TYPE_STRING, unmarshal_bytes)
 
 def unmarshal_interned(space, u, tc):
 w_ret = space.wrap(u.get_str())
@@ -410,13 +411,16 @@
 return space.wrap(code)
 register(TYPE_CODE, unmarshal_pycode)
 
-def marshal_w__Unicode(space, w_unicode, m):
+def marshal_unicode(space, w_unicode, m):
+if not isinstance(w_unicode, W_UnicodeObject):
+raise_exception(space, "unmarshallable object")
 s = unicodehelper.encode_utf8(space, space.unicode_w(w_unicode))
 m.atom_str(TYPE_UNICODE, s)
+handled_by_any.append(('unicode', marshal_unicode))
 
-def unmarshal_Unicode(space, u, tc):
+def unmarshal_unicode(space, u, tc):
 return space.wrap(unicodehelper.decode_utf8(space, u.get_str()))
-register(TYPE_UNICODE, unmarshal_Unicode)
+register(TYPE_UNICODE, unmarshal_unicode)
 
 app = gateway.applevel(r'''
 def tuple_to_set(datalist, frozen=False):
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy refactor-str-types: Fix.

2013-07-29 Thread Manuel Jacob
Author: Manuel Jacob
Branch: refactor-str-types
Changeset: r65796:d42a088324cb
Date: 2013-07-29 17:12 +0200
http://bitbucket.org/pypy/pypy/changeset/d42a088324cb/

Log:Fix.

diff --git a/pypy/objspace/std/stringmethods.py 
b/pypy/objspace/std/stringmethods.py
--- a/pypy/objspace/std/stringmethods.py
+++ b/pypy/objspace/std/stringmethods.py
@@ -515,6 +515,9 @@
  space.wrap("empty separator"))
 pos = value.rfind(sub)
 if pos == -1:
+from pypy.objspace.std.bytearrayobject import W_BytearrayObject
+if isinstance(self, W_BytearrayObject):
+self = self._new(value)
 return space.newtuple([self._empty(), self._empty(), self])
 else:
 from pypy.objspace.std.bytearrayobject import W_BytearrayObject
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy refactor-str-types: Fix.

2013-07-29 Thread Manuel Jacob
Author: Manuel Jacob
Branch: refactor-str-types
Changeset: r65792:33ad6ccc9a91
Date: 2013-07-29 16:18 +0200
http://bitbucket.org/pypy/pypy/changeset/33ad6ccc9a91/

Log:Fix.

diff --git a/pypy/objspace/std/bytesobject.py b/pypy/objspace/std/bytesobject.py
--- a/pypy/objspace/std/bytesobject.py
+++ b/pypy/objspace/std/bytesobject.py
@@ -207,7 +207,7 @@
 def descr_contains(self, space, w_sub):
 if space.isinstance_w(w_sub, space.w_unicode):
 self_as_unicode = unicode_from_encoded_object(space, self, None, 
None)
-return 
space.newbool(self_as_unicode._value.find(self._op_val(space, w_sub)) >= 0)
+return space.newbool(self_as_unicode._value.find(w_sub._value) >= 
0)
 return StringMethods.descr_contains(self, space, w_sub)
 
 @unwrap_spec(count=int)
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Some more OO specific code

2013-07-29 Thread alex_gaynor
Author: Alex Gaynor 
Branch: 
Changeset: r65798:2f7eaa5b4466
Date: 2013-07-29 13:41 -0700
http://bitbucket.org/pypy/pypy/changeset/2f7eaa5b4466/

Log:Some more OO specific code

diff --git a/rpython/rlib/streamio.py b/rpython/rlib/streamio.py
--- a/rpython/rlib/streamio.py
+++ b/rpython/rlib/streamio.py
@@ -185,11 +185,8 @@
 SetEndOfFile = rffi.llexternal('SetEndOfFile', [HANDLE], BOOL,
compilation_info=_eci)
 
-# HACK: These implementations are specific to MSVCRT and the C backend.
-# When generating on CLI or JVM, these are patched out.
-# See PyPyTarget.target() in targetpypystandalone.py
 def _setfd_binary(fd):
-#Allow this to succeed on invalid fd's
+# Allow this to succeed on invalid fd's
 if rposix.is_valid_fd(fd):
 _setmode(fd, os.O_BINARY)
 
diff --git a/rpython/rtyper/rtyper.py b/rpython/rtyper/rtyper.py
--- a/rpython/rtyper/rtyper.py
+++ b/rpython/rtyper/rtyper.py
@@ -58,7 +58,6 @@
 self.classdef_to_pytypeobject = {}
 self.concrete_calltables = {}
 self.class_pbc_attributes = {}
-self.oo_meth_impls = {}
 self.cache_dummy_values = {}
 self.lltype2vtable = {}
 self.typererrors = []
diff --git a/rpython/translator/backendopt/test/test_removenoops.py 
b/rpython/translator/backendopt/test/test_removenoops.py
--- a/rpython/translator/backendopt/test/test_removenoops.py
+++ b/rpython/translator/backendopt/test/test_removenoops.py
@@ -97,9 +97,8 @@
 
 
 def test_remove_unaryops():
-# We really want to use remove_unaryops for things like ooupcast and
-# oodowncast in dynamically typed languages, but it's easier to test
-# it with operations on ints here.
+# We really want to use remove_unaryops for more complex operations, but
+# it's easier to test it with operations on ints here.
 def f(x):
 i = llop.int_invert(lltype.Signed, x)
 i = llop.int_add(lltype.Signed, x, 1)
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: apply 9fad3a8b4208 from default

2013-07-29 Thread pjenvey
Author: Philip Jenvey 
Branch: py3k
Changeset: r65800:c6070a1abed2
Date: 2013-07-29 13:42 -0700
http://bitbucket.org/pypy/pypy/changeset/c6070a1abed2/

Log:apply 9fad3a8b4208 from default

diff --git a/lib-python/3/distutils/sysconfig_pypy.py 
b/lib-python/3/distutils/sysconfig_pypy.py
--- a/lib-python/3/distutils/sysconfig_pypy.py
+++ b/lib-python/3/distutils/sysconfig_pypy.py
@@ -12,6 +12,7 @@
 
 import sys
 import os
+import shlex
 
 from distutils.errors import DistutilsPlatformError
 
@@ -124,11 +125,19 @@
 if compiler.compiler_type == "unix":
 compiler.compiler_so.extend(['-O2', '-fPIC', '-Wimplicit'])
 compiler.shared_lib_extension = get_config_var('SO')
+if "CPPFLAGS" in os.environ:
+cppflags = shlex.split(os.environ["CPPFLAGS"])
+compiler.compiler.extend(cppflags)
+compiler.compiler_so.extend(cppflags)
+compiler.linker_so.extend(cppflags)
 if "CFLAGS" in os.environ:
-cflags = os.environ["CFLAGS"].split()
+cflags = shlex.split(os.environ["CFLAGS"])
 compiler.compiler.extend(cflags)
 compiler.compiler_so.extend(cflags)
 compiler.linker_so.extend(cflags)
+if "LDFLAGS" in os.environ:
+ldflags = shlex.split(os.environ["LDFLAGS"])
+compiler.linker_so.extend(ldflags)
 
 
 from .sysconfig_cpython import (
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Removed some more OO specific code

2013-07-29 Thread alex_gaynor
Author: Alex Gaynor 
Branch: 
Changeset: r65797:1b006d0e4bcd
Date: 2013-07-29 13:36 -0700
http://bitbucket.org/pypy/pypy/changeset/1b006d0e4bcd/

Log:Removed some more OO specific code

diff --git a/rpython/jit/backend/model.py b/rpython/jit/backend/model.py
--- a/rpython/jit/backend/model.py
+++ b/rpython/jit/backend/model.py
@@ -187,10 +187,6 @@
 # with Voids removed
 raise NotImplementedError
 
-def methdescrof(self, SELFTYPE, methname):
-# must return a subclass of history.AbstractMethDescr
-raise NotImplementedError
-
 def typedescrof(self, TYPE):
 raise NotImplementedError
 
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
@@ -34,7 +34,6 @@
 return 'int' # singlefloats are stored in an int
 if TYPE in (lltype.Float, lltype.SingleFloat):
 raise NotImplementedError("type %s not supported" % TYPE)
-# XXX fix this for oo...
 if (TYPE != llmemory.Address and
 rffi.sizeof(TYPE) > rffi.sizeof(lltype.Signed)):
 if supports_longlong and TYPE is not lltype.LongFloat:
@@ -168,18 +167,11 @@
 def __init__(self, identifier=None):
 self.identifier = identifier  # for testing
 
+
 class BasicFailDescr(AbstractFailDescr):
 def __init__(self, identifier=None):
 self.identifier = identifier  # for testing
 
-class AbstractMethDescr(AbstractDescr):
-# the base class of the result of cpu.methdescrof()
-jitcodes = None
-def setup(self, jitcodes):
-# jitcodes maps { runtimeClass -> jitcode for runtimeClass.methname }
-self.jitcodes = jitcodes
-def get_jitcode_for_class(self, oocls):
-return self.jitcodes[oocls]
 
 class Const(AbstractValue):
 __slots__ = ()
diff --git a/rpython/rlib/longlong2float.py b/rpython/rlib/longlong2float.py
--- a/rpython/rlib/longlong2float.py
+++ b/rpython/rlib/longlong2float.py
@@ -68,14 +68,12 @@
 uint2singlefloat = rffi.llexternal(
 "pypy__uint2singlefloat", [rffi.UINT], rffi.FLOAT,
 _callable=uint2singlefloat_emulator, compilation_info=eci,
-_nowrapper=True, elidable_function=True, sandboxsafe=True,
-oo_primitive="pypy__uint2singlefloat")
+_nowrapper=True, elidable_function=True, sandboxsafe=True)
 
 singlefloat2uint = rffi.llexternal(
 "pypy__singlefloat2uint", [rffi.FLOAT], rffi.UINT,
 _callable=singlefloat2uint_emulator, compilation_info=eci,
-_nowrapper=True, elidable_function=True, sandboxsafe=True,
-oo_primitive="pypy__singlefloat2uint")
+_nowrapper=True, elidable_function=True, sandboxsafe=True)
 
 
 class Float2LongLongEntry(ExtRegistryEntry):
diff --git a/rpython/rlib/rlocale.py b/rpython/rlib/rlocale.py
--- a/rpython/rlib/rlocale.py
+++ b/rpython/rlib/rlocale.py
@@ -193,11 +193,11 @@
 raise LocaleError("unsupported locale setting")
 return rffi.charp2str(ll_result)
 
-isalpha = external('isalpha', [rffi.INT], rffi.INT, 
oo_primitive='locale_isalpha')
-isupper = external('isupper', [rffi.INT], rffi.INT, 
oo_primitive='locale_isupper')
-islower = external('islower', [rffi.INT], rffi.INT, 
oo_primitive='locale_islower')
-tolower = external('tolower', [rffi.INT], rffi.INT, 
oo_primitive='locale_tolower')
-isalnum = external('isalnum', [rffi.INT], rffi.INT, 
oo_primitive='locale_isalnum')
+isalpha = external('isalpha', [rffi.INT], rffi.INT)
+isupper = external('isupper', [rffi.INT], rffi.INT)
+islower = external('islower', [rffi.INT], rffi.INT)
+tolower = external('tolower', [rffi.INT], rffi.INT)
+isalnum = external('isalnum', [rffi.INT], rffi.INT)
 
 if HAVE_LANGINFO:
 _nl_langinfo = external('nl_langinfo', [rffi.INT], rffi.CCHARP)
diff --git a/rpython/rtyper/lltypesystem/rffi.py 
b/rpython/rtyper/lltypesystem/rffi.py
--- a/rpython/rtyper/lltypesystem/rffi.py
+++ b/rpython/rtyper/lltypesystem/rffi.py
@@ -62,8 +62,8 @@
compilation_info=ExternalCompilationInfo(),
sandboxsafe=False, threadsafe='auto',
_nowrapper=False, calling_conv='c',
-   oo_primitive=None, elidable_function=False,
-   macro=None, random_effects_on_gcobjs='auto'):
+   elidable_function=False, macro=None,
+   random_effects_on_gcobjs='auto'):
 """Build an external function that will invoke the C function 'name'
 with the given 'args' types and 'result' type.
 
@@ -97,8 +97,6 @@
 if elidable_function:
 _callable._elidable_function_ = True
 kwds = {}
-if oo_primitive:
-kwds['oo_primitive'] = oo_primitive
 
 has_callback = False
 for ARG in args:
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] extradoc extradoc: Thanks Romain for the booking

2013-07-29 Thread arigo
Author: Armin Rigo 
Branch: extradoc
Changeset: r5013:2511be10f422
Date: 2013-07-29 23:03 +0200
http://bitbucket.org/pypy/extradoc/changeset/2511be10f422/

Log:Thanks Romain for the booking

diff --git a/sprintinfo/london-2013/people.txt 
b/sprintinfo/london-2013/people.txt
--- a/sprintinfo/london-2013/people.txt
+++ b/sprintinfo/london-2013/people.txt
@@ -12,10 +12,10 @@
  == ===
 Carl Friedrich Bolz  ?  Lukas
 Lukas Diekmann   lives there
-Romain Guillebert?  ?
+Romain Guillebert?  hotel LSE Northumberl.
 Laurence Tratt   lives there
 Edd Barrett  ?  ?
-Armin Rigo   ?  hotel I'd like to share
+Armin Rigo   25/8-2/9   hotel LSE Northumberl.
 Richard Emslie   25/8-2/9   some hotel
 Remi Meier   24/8-1/9   ?
 Marko Bencun 24/8-1/9   ?
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: test, fix for uninitialized Scalar.value

2013-07-29 Thread mattip
Author: Matti Picus 
Branch: 
Changeset: r65801:78634b86b451
Date: 2013-07-30 00:49 +0300
http://bitbucket.org/pypy/pypy/changeset/78634b86b451/

Log:test, fix for uninitialized Scalar.value

diff --git a/pypy/module/micronumpy/base.py b/pypy/module/micronumpy/base.py
--- a/pypy/module/micronumpy/base.py
+++ b/pypy/module/micronumpy/base.py
@@ -37,7 +37,8 @@
 from pypy.module.micronumpy.arrayimpl import concrete, scalar
 
 if not shape:
-impl = scalar.Scalar(dtype.base)
+w_val = dtype.base.coerce(space, space.wrap(0))
+impl = scalar.Scalar(dtype.base, w_val)
 else:
 strides, backstrides = calc_strides(shape, dtype.base, order)
 impl = concrete.ConcreteArray(shape, dtype.base, order, strides,
@@ -79,6 +80,8 @@
 
 if w_val is not None:
 w_val = dtype.coerce(space, w_val)
+else:
+w_val = dtype.coerce(space, space.wrap(0))
 return W_NDimArray(scalar.Scalar(dtype, w_val))
 
 
diff --git a/pypy/module/micronumpy/test/test_numarray.py 
b/pypy/module/micronumpy/test/test_numarray.py
--- a/pypy/module/micronumpy/test/test_numarray.py
+++ b/pypy/module/micronumpy/test/test_numarray.py
@@ -264,6 +264,8 @@
 assert a.dtype is dtype(int)
 a = ndarray([], dtype=float)
 assert a.shape == ()
+# test uninitialized value crash?
+assert len(str(a)) > 0
 
 def test_ndmin(self):
 from numpypy import array
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy stdlib-2.7.4: Merged in andrewsmedina/numpypy/stdlib-2.7.4-fixed-class (pull request #172)

2013-07-29 Thread pjenvey
Author: Philip Jenvey 
Branch: stdlib-2.7.4
Changeset: r65803:37f208085f71
Date: 2013-07-29 15:23 -0700
http://bitbucket.org/pypy/pypy/changeset/37f208085f71/

Log:Merged in andrewsmedina/numpypy/stdlib-2.7.4-fixed-class (pull
request #172)

fixed support for class in stdlib 2.7.4

diff --git a/pypy/module/__builtin__/interp_classobj.py 
b/pypy/module/__builtin__/interp_classobj.py
--- a/pypy/module/__builtin__/interp_classobj.py
+++ b/pypy/module/__builtin__/interp_classobj.py
@@ -116,6 +116,9 @@
 return None
 
 def descr_getattribute(self, space, w_attr):
+if not space.isinstance_w(w_attr, space.w_str):
+msg = "attribute name must be a string"
+raise OperationError(space.w_TypeError, space.wrap(msg))
 name = unwrap_attr(space, w_attr)
 if name and name[0] == "_":
 if name == "__dict__":
@@ -137,6 +140,9 @@
 return space.call_function(w_descr_get, w_value, space.w_None, self)
 
 def descr_setattr(self, space, w_attr, w_value):
+if not space.isinstance_w(w_attr, space.w_str):
+msg = "attribute name must be a string"
+raise OperationError(space.w_TypeError, space.wrap(msg))
 name = unwrap_attr(space, w_attr)
 if name and name[0] == "_":
 if name == "__dict__":
@@ -370,6 +376,9 @@
 return None
 
 def descr_getattribute(self, space, w_attr):
+if not space.isinstance_w(w_attr, space.w_str):
+msg = "attribute name must be a string"
+raise OperationError(space.w_TypeError, space.wrap(msg))
 name = space.str_w(w_attr)
 if len(name) >= 8 and name[0] == '_':
 if name == "__dict__":
@@ -379,6 +388,9 @@
 return self.getattr(space, name)
 
 def descr_setattr(self, space, w_name, w_value):
+if not space.isinstance_w(w_name, space.w_str):
+msg = "attribute name must be a string"
+raise OperationError(space.w_TypeError, space.wrap(msg))
 name = unwrap_attr(space, w_name)
 w_meth = self.getattr_from_class(space, '__setattr__')
 if name and name[0] == "_":
diff --git a/pypy/module/__builtin__/test/test_classobj.py 
b/pypy/module/__builtin__/test/test_classobj.py
--- a/pypy/module/__builtin__/test/test_classobj.py
+++ b/pypy/module/__builtin__/test/test_classobj.py
@@ -1078,6 +1078,13 @@
 b = 2
 assert self.is_strdict(A)
 
+def test_attr_slots(self):
+class C:
+pass
+for c in C, C():
+raises(TypeError, type(c).__getattribute__, c, [])
+raises(TypeError, type(c).__setattr__, c, [], [])
+
 class AppTestOldStyleMapDict(AppTestOldstyle):
 spaceconfig = {"objspace.std.withmapdict": True}
 
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy stdlib-2.7.4-fixed-class: fixed support for class in stdlib 2.7.4

2013-07-29 Thread andrewsmedina
Author: Andrews Medina 
Branch: stdlib-2.7.4-fixed-class
Changeset: r65802:ab9512fa99c0
Date: 2013-07-29 10:23 -0300
http://bitbucket.org/pypy/pypy/changeset/ab9512fa99c0/

Log:fixed support for class in stdlib 2.7.4

diff --git a/pypy/module/__builtin__/interp_classobj.py 
b/pypy/module/__builtin__/interp_classobj.py
--- a/pypy/module/__builtin__/interp_classobj.py
+++ b/pypy/module/__builtin__/interp_classobj.py
@@ -116,6 +116,9 @@
 return None
 
 def descr_getattribute(self, space, w_attr):
+if not space.isinstance_w(w_attr, space.w_str):
+msg = "attribute name must be a string"
+raise OperationError(space.w_TypeError, space.wrap(msg))
 name = unwrap_attr(space, w_attr)
 if name and name[0] == "_":
 if name == "__dict__":
@@ -137,6 +140,9 @@
 return space.call_function(w_descr_get, w_value, space.w_None, self)
 
 def descr_setattr(self, space, w_attr, w_value):
+if not space.isinstance_w(w_attr, space.w_str):
+msg = "attribute name must be a string"
+raise OperationError(space.w_TypeError, space.wrap(msg))
 name = unwrap_attr(space, w_attr)
 if name and name[0] == "_":
 if name == "__dict__":
@@ -370,6 +376,9 @@
 return None
 
 def descr_getattribute(self, space, w_attr):
+if not space.isinstance_w(w_attr, space.w_str):
+msg = "attribute name must be a string"
+raise OperationError(space.w_TypeError, space.wrap(msg))
 name = space.str_w(w_attr)
 if len(name) >= 8 and name[0] == '_':
 if name == "__dict__":
@@ -379,6 +388,9 @@
 return self.getattr(space, name)
 
 def descr_setattr(self, space, w_name, w_value):
+if not space.isinstance_w(w_name, space.w_str):
+msg = "attribute name must be a string"
+raise OperationError(space.w_TypeError, space.wrap(msg))
 name = unwrap_attr(space, w_name)
 w_meth = self.getattr_from_class(space, '__setattr__')
 if name and name[0] == "_":
diff --git a/pypy/module/__builtin__/test/test_classobj.py 
b/pypy/module/__builtin__/test/test_classobj.py
--- a/pypy/module/__builtin__/test/test_classobj.py
+++ b/pypy/module/__builtin__/test/test_classobj.py
@@ -1078,6 +1078,13 @@
 b = 2
 assert self.is_strdict(A)
 
+def test_attr_slots(self):
+class C:
+pass
+for c in C, C():
+raises(TypeError, type(c).__getattribute__, c, [])
+raises(TypeError, type(c).__setattr__, c, [], [])
+
 class AppTestOldStyleMapDict(AppTestOldstyle):
 spaceconfig = {"objspace.std.withmapdict": True}
 
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy stdlib-2.7.4-fixed-io: pep8 fix

2013-07-29 Thread andrewsmedina
Author: Andrews Medina 
Branch: stdlib-2.7.4-fixed-io
Changeset: r65805:2acd05e29823
Date: 2013-07-29 19:30 -0300
http://bitbucket.org/pypy/pypy/changeset/2acd05e29823/

Log:pep8 fix

diff --git a/pypy/module/_io/interp_textio.py b/pypy/module/_io/interp_textio.py
--- a/pypy/module/_io/interp_textio.py
+++ b/pypy/module/_io/interp_textio.py
@@ -555,7 +555,8 @@
 space.wrap(self.chunk_size))
 
 if not space.isinstance_w(w_input, space.w_str):
-msg = "decoder getstate() should have returned a bytes object not 
'%T'"
+msg = "decoder getstate() should have returned a bytes " \
+  "object not '%T'"
 raise operationerrfmt(space.w_TypeError, msg, w_input)
 
 eof = space.len_w(w_input) == 0
@@ -865,7 +866,8 @@
 w_chunk = space.call_method(self.w_buffer, "read",
 space.wrap(cookie.bytes_to_feed))
 if not space.isinstance_w(w_chunk, space.w_str):
-msg = "underlying read() should have returned a bytes object, 
not '%T'"
+msg = "underlying read() should have returned " \
+  "a bytes object, not '%T'"
 raise operationerrfmt(space.w_TypeError, msg, w_chunk)
 
 self.snapshot = PositionSnapshot(cookie.dec_flags,
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy stdlib-2.7.4-fixed-io: fixed support for io in stdlib 2.7.4

2013-07-29 Thread andrewsmedina
Author: Andrews Medina 
Branch: stdlib-2.7.4-fixed-io
Changeset: r65804:43221a2e8365
Date: 2013-07-28 18:46 -0300
http://bitbucket.org/pypy/pypy/changeset/43221a2e8365/

Log:fixed support for io in stdlib 2.7.4

diff --git a/lib-python/2.7/test/test_io.py b/lib-python/2.7/test/test_io.py
--- a/lib-python/2.7/test/test_io.py
+++ b/lib-python/2.7/test/test_io.py
@@ -1004,6 +1004,7 @@
 support.gc_collect()
 self.assertTrue(wr() is None, wr)
 
+@support.impl_detail(cpython=True)
 def test_args_error(self):
 # Issue #17275
 with self.assertRaisesRegexp(TypeError, "BufferedReader"):
@@ -1302,6 +1303,7 @@
 with self.open(support.TESTFN, "rb") as f:
 self.assertEqual(f.read(), b"123xxx")
 
+@support.impl_detail(cpython=True)
 def test_args_error(self):
 # Issue #17275
 with self.assertRaisesRegexp(TypeError, "BufferedWriter"):
@@ -1676,6 +1678,7 @@
 CBufferedReaderTest.test_garbage_collection(self)
 CBufferedWriterTest.test_garbage_collection(self)
 
+@support.impl_detail(cpython=True)
 def test_args_error(self):
 # Issue #17275
 with self.assertRaisesRegexp(TypeError, "BufferedRandom"):
diff --git a/pypy/module/_io/interp_textio.py b/pypy/module/_io/interp_textio.py
--- a/pypy/module/_io/interp_textio.py
+++ b/pypy/module/_io/interp_textio.py
@@ -1,7 +1,7 @@
 import sys
 
 from pypy.interpreter.baseobjspace import W_Root
-from pypy.interpreter.error import OperationError
+from pypy.interpreter.error import OperationError, operationerrfmt
 from pypy.interpreter.gateway import WrappedDefault, interp2app, unwrap_spec
 from pypy.interpreter.typedef import (
 GetSetProperty, TypeDef, generic_new_descr, interp_attrproperty,
@@ -327,6 +327,13 @@
 self.flags = flags
 self.input = input
 
+
+def check_decoded(space, w_decoded):
+if not space.isinstance_w(w_decoded, space.w_unicode):
+msg = "decoder should return a string result, not '%T'"
+raise operationerrfmt(space.w_TypeError, msg, w_decoded)
+
+
 class W_TextIOWrapper(W_TextIOBase):
 def __init__(self, space):
 W_TextIOBase.__init__(self, space)
@@ -546,9 +553,15 @@
 # Read a chunk, decode it, and put the result in self._decoded_chars
 w_input = space.call_method(self.w_buffer, "read1",
 space.wrap(self.chunk_size))
+
+if not space.isinstance_w(w_input, space.w_str):
+msg = "decoder getstate() should have returned a bytes object not 
'%T'"
+raise operationerrfmt(space.w_TypeError, msg, w_input)
+
 eof = space.len_w(w_input) == 0
 w_decoded = space.call_method(self.w_decoder, "decode",
   w_input, space.wrap(eof))
+check_decoded(space, w_decoded)
 self._set_decoded_chars(space.unicode_w(w_decoded))
 if space.len_w(w_decoded) > 0:
 eof = False
@@ -577,10 +590,12 @@
 
 size = convert_size(space, w_size)
 self._writeflush(space)
+
 if size < 0:
 # Read everything
 w_bytes = space.call_method(self.w_buffer, "read")
 w_decoded = space.call_method(self.w_decoder, "decode", w_bytes, 
space.w_True)
+check_decoded(space, w_decoded)
 w_result = space.wrap(self._get_decoded_chars(-1))
 w_final = space.add(w_result, w_decoded)
 self.snapshot = None
@@ -701,6 +716,10 @@
 if not self.w_encoder:
 raise OperationError(space.w_IOError, space.wrap("not writable"))
 
+if not space.isinstance_w(w_text, space.w_unicode):
+msg = "unicode argument expected, got '%T'"
+raise operationerrfmt(space.w_TypeError, msg, w_text)
+
 text = space.unicode_w(w_text)
 textlen = len(text)
 
@@ -845,11 +864,16 @@
 # Just like _read_chunk, feed the decoder and save a snapshot.
 w_chunk = space.call_method(self.w_buffer, "read",
 space.wrap(cookie.bytes_to_feed))
+if not space.isinstance_w(w_chunk, space.w_str):
+msg = "underlying read() should have returned a bytes object, 
not '%T'"
+raise operationerrfmt(space.w_TypeError, msg, w_chunk)
+
 self.snapshot = PositionSnapshot(cookie.dec_flags,
  space.str_w(w_chunk))
 
 w_decoded = space.call_method(self.w_decoder, "decode",
   w_chunk, space.wrap(cookie.need_eof))
+check_decoded(space, w_decoded)
 self._set_decoded_chars(space.unicode_w(w_decoded))
 
 # Skip chars_to_skip of the decoded characters
@@ -918,6 +942,7 @@
 while i < len(input):
 w_decoded = space.call_method(self.w_decoder, "decode",
   space.wrap(input[i]))
+ 

[pypy-commit] pypy stdlib-2.7.4: Merged in andrewsmedina/numpypy/stdlib-2.7.4-fixed-io (pull request #170)

2013-07-29 Thread pjenvey
Author: Philip Jenvey 
Branch: stdlib-2.7.4
Changeset: r65806:0f6b5939f7a6
Date: 2013-07-29 15:33 -0700
http://bitbucket.org/pypy/pypy/changeset/0f6b5939f7a6/

Log:Merged in andrewsmedina/numpypy/stdlib-2.7.4-fixed-io (pull request
#170)

fixed support for io in stdlib 2.7.4

diff --git a/lib-python/2.7/test/test_io.py b/lib-python/2.7/test/test_io.py
--- a/lib-python/2.7/test/test_io.py
+++ b/lib-python/2.7/test/test_io.py
@@ -1004,6 +1004,7 @@
 support.gc_collect()
 self.assertTrue(wr() is None, wr)
 
+@support.impl_detail(cpython=True)
 def test_args_error(self):
 # Issue #17275
 with self.assertRaisesRegexp(TypeError, "BufferedReader"):
@@ -1302,6 +1303,7 @@
 with self.open(support.TESTFN, "rb") as f:
 self.assertEqual(f.read(), b"123xxx")
 
+@support.impl_detail(cpython=True)
 def test_args_error(self):
 # Issue #17275
 with self.assertRaisesRegexp(TypeError, "BufferedWriter"):
@@ -1676,6 +1678,7 @@
 CBufferedReaderTest.test_garbage_collection(self)
 CBufferedWriterTest.test_garbage_collection(self)
 
+@support.impl_detail(cpython=True)
 def test_args_error(self):
 # Issue #17275
 with self.assertRaisesRegexp(TypeError, "BufferedRandom"):
diff --git a/pypy/module/_io/interp_textio.py b/pypy/module/_io/interp_textio.py
--- a/pypy/module/_io/interp_textio.py
+++ b/pypy/module/_io/interp_textio.py
@@ -1,7 +1,7 @@
 import sys
 
 from pypy.interpreter.baseobjspace import W_Root
-from pypy.interpreter.error import OperationError
+from pypy.interpreter.error import OperationError, operationerrfmt
 from pypy.interpreter.gateway import WrappedDefault, interp2app, unwrap_spec
 from pypy.interpreter.typedef import (
 GetSetProperty, TypeDef, generic_new_descr, interp_attrproperty,
@@ -327,6 +327,13 @@
 self.flags = flags
 self.input = input
 
+
+def check_decoded(space, w_decoded):
+if not space.isinstance_w(w_decoded, space.w_unicode):
+msg = "decoder should return a string result, not '%T'"
+raise operationerrfmt(space.w_TypeError, msg, w_decoded)
+
+
 class W_TextIOWrapper(W_TextIOBase):
 def __init__(self, space):
 W_TextIOBase.__init__(self, space)
@@ -546,9 +553,16 @@
 # Read a chunk, decode it, and put the result in self._decoded_chars
 w_input = space.call_method(self.w_buffer, "read1",
 space.wrap(self.chunk_size))
+
+if not space.isinstance_w(w_input, space.w_str):
+msg = "decoder getstate() should have returned a bytes " \
+  "object not '%T'"
+raise operationerrfmt(space.w_TypeError, msg, w_input)
+
 eof = space.len_w(w_input) == 0
 w_decoded = space.call_method(self.w_decoder, "decode",
   w_input, space.wrap(eof))
+check_decoded(space, w_decoded)
 self._set_decoded_chars(space.unicode_w(w_decoded))
 if space.len_w(w_decoded) > 0:
 eof = False
@@ -577,10 +591,12 @@
 
 size = convert_size(space, w_size)
 self._writeflush(space)
+
 if size < 0:
 # Read everything
 w_bytes = space.call_method(self.w_buffer, "read")
 w_decoded = space.call_method(self.w_decoder, "decode", w_bytes, 
space.w_True)
+check_decoded(space, w_decoded)
 w_result = space.wrap(self._get_decoded_chars(-1))
 w_final = space.add(w_result, w_decoded)
 self.snapshot = None
@@ -701,6 +717,10 @@
 if not self.w_encoder:
 raise OperationError(space.w_IOError, space.wrap("not writable"))
 
+if not space.isinstance_w(w_text, space.w_unicode):
+msg = "unicode argument expected, got '%T'"
+raise operationerrfmt(space.w_TypeError, msg, w_text)
+
 text = space.unicode_w(w_text)
 textlen = len(text)
 
@@ -845,11 +865,17 @@
 # Just like _read_chunk, feed the decoder and save a snapshot.
 w_chunk = space.call_method(self.w_buffer, "read",
 space.wrap(cookie.bytes_to_feed))
+if not space.isinstance_w(w_chunk, space.w_str):
+msg = "underlying read() should have returned " \
+  "a bytes object, not '%T'"
+raise operationerrfmt(space.w_TypeError, msg, w_chunk)
+
 self.snapshot = PositionSnapshot(cookie.dec_flags,
  space.str_w(w_chunk))
 
 w_decoded = space.call_method(self.w_decoder, "decode",
   w_chunk, space.wrap(cookie.need_eof))
+check_decoded(space, w_decoded)
 self._set_decoded_chars(space.unicode_w(w_decoded))
 
 # Skip chars_to_skip of the decoded characters
@@ -918,6 +944,7 @@
 while i < len(input):