[pypy-commit] pypy default: c_longdouble is not supported by PyPy. Skip a related test

2012-02-27 Thread antocuni
Author: Antonio Cuni anto.c...@gmail.com
Branch: 
Changeset: r52917:c80ff2d04fb3
Date: 2012-02-27 10:50 +0100
http://bitbucket.org/pypy/pypy/changeset/c80ff2d04fb3/

Log:c_longdouble is not supported by PyPy. Skip a related test

diff --git a/lib-python/modified-2.7/ctypes/test/test_arrays.py 
b/lib-python/modified-2.7/ctypes/test/test_arrays.py
--- a/lib-python/modified-2.7/ctypes/test/test_arrays.py
+++ b/lib-python/modified-2.7/ctypes/test/test_arrays.py
@@ -1,12 +1,23 @@
 import unittest
 from ctypes import *
+from test.test_support import impl_detail
 
 formats = bBhHiIlLqQfd
 
+# c_longdouble commented out for PyPy, look at the commend in test_longdouble
 formats = c_byte, c_ubyte, c_short, c_ushort, c_int, c_uint, \
-  c_long, c_ulonglong, c_float, c_double, c_longdouble
+  c_long, c_ulonglong, c_float, c_double #, c_longdouble
 
 class ArrayTestCase(unittest.TestCase):
+
+@impl_detail('long double not supported by PyPy', pypy=False)
+def test_longdouble(self):
+
+This test is empty. It's just here to remind that we commented out
+c_longdouble in formats. If pypy will ever supports c_longdouble, we
+should kill this test and uncomment c_longdouble inside formats.
+
+
 def test_simple(self):
 # create classes holding simple numeric types, and check
 # various properties.
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Hack to display again the log of the loop before sending it to the

2012-02-27 Thread arigo
Author: Armin Rigo ar...@tunes.org
Branch: 
Changeset: r52918:8e55816f5dfe
Date: 2012-02-27 11:15 +0100
http://bitbucket.org/pypy/pypy/changeset/8e55816f5dfe/

Log:Hack to display again the log of the loop before sending it to the
backend, in addition to after sending it to the backend. That's
necessary to make any sense of the error if the backend crashes.

diff --git a/pypy/jit/metainterp/compile.py b/pypy/jit/metainterp/compile.py
--- a/pypy/jit/metainterp/compile.py
+++ b/pypy/jit/metainterp/compile.py
@@ -289,8 +289,21 @@
 assert isinstance(token, TargetToken)
 assert token.original_jitcell_token is None
 token.original_jitcell_token = trace.original_jitcell_token
-
-
+
+
+def do_compile_loop(metainterp_sd, inputargs, operations, looptoken,
+log=True, name=''):
+metainterp_sd.logger_ops.log_loop(inputargs, operations, -2,
+  'compiling', name=name)
+return metainterp_sd.cpu.compile_loop(inputargs, operations, looptoken,
+  log=log, name=name)
+
+def do_compile_bridge(metainterp_sd, faildescr, inputargs, operations,
+  original_loop_token, log=True):
+metainterp_sd.logger_ops.log_bridge(inputargs, operations, -2)
+return metainterp_sd.cpu.compile_bridge(faildescr, inputargs, operations,
+original_loop_token, log=log)
+
 def send_loop_to_backend(greenkey, jitdriver_sd, metainterp_sd, loop, type):
 vinfo = jitdriver_sd.virtualizable_info
 if vinfo is not None:
@@ -319,9 +332,9 @@
 metainterp_sd.profiler.start_backend()
 debug_start(jit-backend)
 try:
-asminfo = metainterp_sd.cpu.compile_loop(loop.inputargs, operations,
-  original_jitcell_token,
-  name=loopname)
+asminfo = do_compile_loop(metainterp_sd, loop.inputargs,
+  operations, original_jitcell_token,
+  name=loopname)
 finally:
 debug_stop(jit-backend)
 metainterp_sd.profiler.end_backend()
@@ -333,7 +346,6 @@
 metainterp_sd.stats.compiled()
 metainterp_sd.log(compiled new  + type)
 #
-loopname = jitdriver_sd.warmstate.get_location_str(greenkey)
 if asminfo is not None:
 ops_offset = asminfo.ops_offset
 else:
@@ -365,9 +377,9 @@
 metainterp_sd.profiler.start_backend()
 debug_start(jit-backend)
 try:
-asminfo = metainterp_sd.cpu.compile_bridge(faildescr, inputargs,
-   operations,
-   original_loop_token)
+asminfo = do_compile_bridge(metainterp_sd, faildescr, inputargs,
+operations,
+original_loop_token)
 finally:
 debug_stop(jit-backend)
 metainterp_sd.profiler.end_backend()
diff --git a/pypy/jit/metainterp/logger.py b/pypy/jit/metainterp/logger.py
--- a/pypy/jit/metainterp/logger.py
+++ b/pypy/jit/metainterp/logger.py
@@ -18,6 +18,10 @@
 debug_start(jit-log-noopt-loop)
 logops = self._log_operations(inputargs, operations, ops_offset)
 debug_stop(jit-log-noopt-loop)
+elif number == -2:
+debug_start(jit-log-compiling-loop)
+logops = self._log_operations(inputargs, operations, ops_offset)
+debug_stop(jit-log-compiling-loop)
 else:
 debug_start(jit-log-opt-loop)
 debug_print(# Loop, number, '(%s)' % name , :, type,
@@ -31,6 +35,10 @@
 debug_start(jit-log-noopt-bridge)
 logops = self._log_operations(inputargs, operations, ops_offset)
 debug_stop(jit-log-noopt-bridge)
+elif number == -2:
+debug_start(jit-log-compiling-bridge)
+logops = self._log_operations(inputargs, operations, ops_offset)
+debug_stop(jit-log-compiling-bridge)
 else:
 debug_start(jit-log-opt-bridge)
 debug_print(# bridge out of Guard, number,
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: merge heads

2012-02-27 Thread arigo
Author: Armin Rigo ar...@tunes.org
Branch: 
Changeset: r52919:5a84240692b4
Date: 2012-02-27 11:15 +0100
http://bitbucket.org/pypy/pypy/changeset/5a84240692b4/

Log:merge heads

diff --git a/lib-python/modified-2.7/ctypes/test/test_arrays.py 
b/lib-python/modified-2.7/ctypes/test/test_arrays.py
--- a/lib-python/modified-2.7/ctypes/test/test_arrays.py
+++ b/lib-python/modified-2.7/ctypes/test/test_arrays.py
@@ -1,12 +1,23 @@
 import unittest
 from ctypes import *
+from test.test_support import impl_detail
 
 formats = bBhHiIlLqQfd
 
+# c_longdouble commented out for PyPy, look at the commend in test_longdouble
 formats = c_byte, c_ubyte, c_short, c_ushort, c_int, c_uint, \
-  c_long, c_ulonglong, c_float, c_double, c_longdouble
+  c_long, c_ulonglong, c_float, c_double #, c_longdouble
 
 class ArrayTestCase(unittest.TestCase):
+
+@impl_detail('long double not supported by PyPy', pypy=False)
+def test_longdouble(self):
+
+This test is empty. It's just here to remind that we commented out
+c_longdouble in formats. If pypy will ever supports c_longdouble, we
+should kill this test and uncomment c_longdouble inside formats.
+
+
 def test_simple(self):
 # create classes holding simple numeric types, and check
 # various properties.
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: start to kill the references to the module/_file, which will be killed soon.

2012-02-27 Thread antocuni
Author: Antonio Cuni anto.c...@gmail.com
Branch: py3k
Changeset: r52920:319e160de1b9
Date: 2012-02-27 11:30 +0100
http://bitbucket.org/pypy/pypy/changeset/319e160de1b9/

Log:start to kill the references to the module/_file, which will be
killed soon.

module/marshal used to special-case W_File for performances: now the
fast path is disabled, we should evenutally redo it for _io files.

diff --git a/pypy/config/pypyoption.py b/pypy/config/pypyoption.py
--- a/pypy/config/pypyoption.py
+++ b/pypy/config/pypyoption.py
@@ -13,14 +13,14 @@
and not p.basename.startswith('test')]
 
 essential_modules = dict.fromkeys(
-[exceptions, _file, sys, builtins, posix]
+[exceptions, _io, sys, builtins, posix]
 )
 
 default_modules = essential_modules.copy()
 default_modules.update(dict.fromkeys(
 [_codecs, atexit, gc, _weakref, marshal, errno, imp,
  math, cmath, _sre, _pickle_support, operator,
- parser, symbol, token, _ast,  _io, _random, __pypy__,
+ parser, symbol, token, _ast, _random, __pypy__,
  _string, _testing]))
 
 
diff --git a/pypy/module/array/interp_array.py 
b/pypy/module/array/interp_array.py
--- a/pypy/module/array/interp_array.py
+++ b/pypy/module/array/interp_array.py
@@ -4,7 +4,6 @@
 from pypy.interpreter.error import OperationError
 from pypy.interpreter.gateway import interp2app, unwrap_spec
 from pypy.interpreter.typedef import GetSetProperty, make_weakref_descr
-from pypy.module._file.interp_file import W_File
 from pypy.objspace.std.model import W_Object
 from pypy.objspace.std.multimethod import FailedToImplement
 from pypy.objspace.std.stdtypedef import SMM, StdTypeDef
diff --git a/pypy/module/marshal/interp_marshal.py 
b/pypy/module/marshal/interp_marshal.py
--- a/pypy/module/marshal/interp_marshal.py
+++ b/pypy/module/marshal/interp_marshal.py
@@ -1,19 +1,16 @@
 from pypy.interpreter.error import OperationError
 from pypy.rlib.rarithmetic import intmask
 from pypy.rlib import rstackovf
-from pypy.module._file.interp_file import W_File
 
 
 Py_MARSHAL_VERSION = 2
 
 def dump(space, w_data, w_f, w_version=Py_MARSHAL_VERSION):
 Write the 'data' object into the open file 'f'.
-# special case real files for performance
-file = space.interpclass_w(w_f)
-if isinstance(file, W_File):
-writer = DirectStreamWriter(space, file)
-else:
-writer = FileWriter(space, w_f)
+# XXX: before py3k, we special-cased W_File to use a more performant
+# FileWriter class. Should we do the same for py3k? Look also at
+# DirectStreamWriter
+writer = FileWriter(space, w_f)
 try:
 # note: bound methods are currently not supported,
 # so we have to pass the instance in, instead.
@@ -32,12 +29,10 @@
 
 def load(space, w_f):
 Read one value from the file 'f' and return it.
-# special case real files for performance
-file = space.interpclass_w(w_f)
-if isinstance(file, W_File):
-reader = DirectStreamReader(space, file)
-else:
-reader = FileReader(space, w_f)
+# XXX: before py3k, we special-cased W_File to use a more performant
+# FileWriter class. Should we do the same for py3k? Look also at
+# DirectStreamReader
+reader = FileReader(space, w_f)
 try:
 u = Unmarshaller(space, reader)
 return u.load_w_obj()
@@ -120,10 +115,16 @@
 self.file.unlock()
 
 class DirectStreamWriter(StreamReaderWriter):
+
+XXX: this class is unused right now. Look at the comment in dump()
+
 def write(self, data):
 self.file.do_direct_write(data)
 
 class DirectStreamReader(StreamReaderWriter):
+
+XXX: this class is unused right now. Look at the comment in dump()
+
 def read(self, n):
 data = self.file.direct_read(n)
 if len(data)  n:
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: fix syntax. The test is still skipped, but this happens also on default

2012-02-27 Thread antocuni
Author: Antonio Cuni anto.c...@gmail.com
Branch: py3k
Changeset: r52921:ad992ca38af4
Date: 2012-02-27 11:37 +0100
http://bitbucket.org/pypy/pypy/changeset/ad992ca38af4/

Log:fix syntax. The test is still skipped, but this happens also on
default

diff --git a/pypy/module/imp/test/test_import.py 
b/pypy/module/imp/test/test_import.py
--- a/pypy/module/imp/test/test_import.py
+++ b/pypy/module/imp/test/test_import.py
@@ -364,13 +364,13 @@
 import sys, os
 p = os.path.join(sys.path[-1], 'readonly')
 try:
-os.chmod(p, 0555)
+os.chmod(p, 0o555)
 except:
 skip(cannot chmod() the test directory to read-only)
 try:
 import readonly.x# cannot write x.pyc, but should not crash
 finally:
-os.chmod(p, 0775)
+os.chmod(p, 0o775)
 
 def test__import__empty_string(self):
 raises(ValueError, __import__, )
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: 'typo'. The directory hierarchy created by the test is put in sys.path[0], not [-1]. This test has been silently skipped for ages probably

2012-02-27 Thread antocuni
Author: Antonio Cuni anto.c...@gmail.com
Branch: 
Changeset: r52922:b081147f76f3
Date: 2012-02-27 11:41 +0100
http://bitbucket.org/pypy/pypy/changeset/b081147f76f3/

Log:'typo'. The directory hierarchy created by the test is put in
sys.path[0], not [-1]. This test has been silently skipped for ages
probably

diff --git a/pypy/module/imp/test/test_import.py 
b/pypy/module/imp/test/test_import.py
--- a/pypy/module/imp/test/test_import.py
+++ b/pypy/module/imp/test/test_import.py
@@ -357,7 +357,7 @@
 
 def test_cannot_write_pyc(self):
 import sys, os
-p = os.path.join(sys.path[-1], 'readonly')
+p = os.path.join(sys.path[0], 'readonly')
 try:
 os.chmod(p, 0555)
 except:
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: hg merge default

2012-02-27 Thread antocuni
Author: Antonio Cuni anto.c...@gmail.com
Branch: py3k
Changeset: r52923:9e1b5a6a8752
Date: 2012-02-27 11:43 +0100
http://bitbucket.org/pypy/pypy/changeset/9e1b5a6a8752/

Log:hg merge default

diff --git a/lib-python/modified-2.7/ctypes/test/test_arrays.py 
b/lib-python/modified-2.7/ctypes/test/test_arrays.py
--- a/lib-python/modified-2.7/ctypes/test/test_arrays.py
+++ b/lib-python/modified-2.7/ctypes/test/test_arrays.py
@@ -1,12 +1,23 @@
 import unittest
 from ctypes import *
+from test.test_support import impl_detail
 
 formats = bBhHiIlLqQfd
 
+# c_longdouble commented out for PyPy, look at the commend in test_longdouble
 formats = c_byte, c_ubyte, c_short, c_ushort, c_int, c_uint, \
-  c_long, c_ulonglong, c_float, c_double, c_longdouble
+  c_long, c_ulonglong, c_float, c_double #, c_longdouble
 
 class ArrayTestCase(unittest.TestCase):
+
+@impl_detail('long double not supported by PyPy', pypy=False)
+def test_longdouble(self):
+
+This test is empty. It's just here to remind that we commented out
+c_longdouble in formats. If pypy will ever supports c_longdouble, we
+should kill this test and uncomment c_longdouble inside formats.
+
+
 def test_simple(self):
 # create classes holding simple numeric types, and check
 # various properties.
diff --git a/pypy/jit/backend/x86/assembler.py 
b/pypy/jit/backend/x86/assembler.py
--- a/pypy/jit/backend/x86/assembler.py
+++ b/pypy/jit/backend/x86/assembler.py
@@ -33,7 +33,7 @@
 from pypy.jit.backend.x86.support import values_array
 from pypy.jit.backend.x86 import support
 from pypy.rlib.debug import (debug_print, debug_start, debug_stop,
- have_debug_prints, fatalerror_notb)
+ have_debug_prints)
 from pypy.rlib import rgc
 from pypy.rlib.clibffi import FFI_DEFAULT_ABI
 from pypy.jit.backend.x86.jump import remap_frame_layout
@@ -104,7 +104,6 @@
 self._debug = v
 
 def setup_once(self):
-self._check_sse2()
 # the address of the function called by 'new'
 gc_ll_descr = self.cpu.gc_ll_descr
 gc_ll_descr.initialize()
@@ -162,28 +161,6 @@
 debug_print(prefix + ':' + str(struct.i))
 debug_stop('jit-backend-counts')
 
-_CHECK_SSE2_FUNC_PTR = lltype.Ptr(lltype.FuncType([], lltype.Signed))
-
-def _check_sse2(self):
-if WORD == 8:
-return # all x86-64 CPUs support SSE2
-if not self.cpu.supports_floats:
-return # the CPU doesn't support float, so we don't need SSE2
-#
-from pypy.jit.backend.x86.detect_sse2 import INSNS
-mc = codebuf.MachineCodeBlockWrapper()
-for c in INSNS:
-mc.writechar(c)
-rawstart = mc.materialize(self.cpu.asmmemmgr, [])
-fnptr = rffi.cast(self._CHECK_SSE2_FUNC_PTR, rawstart)
-features = fnptr()
-if bool(features  (125)) and bool(features  (126)):
-return # CPU supports SSE2
-fatalerror_notb(
-  This version of PyPy was compiled for a x86 CPU supporting SSE2.\n
-  Your CPU is too old.  Please translate a PyPy with the option:\n
-  --jit-backend=x86-without-sse2)
-
 def _build_float_constants(self):
 datablockwrapper = MachineDataBlockWrapper(self.cpu.asmmemmgr, [])
 float_constants = datablockwrapper.malloc_aligned(32, alignment=16)
diff --git a/pypy/jit/backend/x86/detect_sse2.py 
b/pypy/jit/backend/x86/detect_sse2.py
--- a/pypy/jit/backend/x86/detect_sse2.py
+++ b/pypy/jit/backend/x86/detect_sse2.py
@@ -1,18 +1,17 @@
 import autopath
+from pypy.rpython.lltypesystem import lltype, rffi
+from pypy.rlib.rmmap import alloc, free
 
-INSNS = (\xB8\x01\x00\x00\x00 # MOV EAX, 1
- \x53 # PUSH EBX
- \x0F\xA2 # CPUID
- \x5B # POP EBX
- \x92 # XCHG EAX, EDX
- \xC3)# RET
 
 def detect_sse2():
-from pypy.rpython.lltypesystem import lltype, rffi
-from pypy.rlib.rmmap import alloc, free
 data = alloc(4096)
 pos = 0
-for c in INSNS:
+for c in (\xB8\x01\x00\x00\x00 # MOV EAX, 1
+  \x53 # PUSH EBX
+  \x0F\xA2 # CPUID
+  \x5B # POP EBX
+  \x92 # XCHG EAX, EDX
+  \xC3):   # RET
 data[pos] = c
 pos += 1
 fnptr = rffi.cast(lltype.Ptr(lltype.FuncType([], lltype.Signed)), data)
diff --git a/pypy/jit/backend/x86/support.py b/pypy/jit/backend/x86/support.py
--- a/pypy/jit/backend/x86/support.py
+++ b/pypy/jit/backend/x86/support.py
@@ -1,6 +1,7 @@
 import sys
 from pypy.rpython.lltypesystem import lltype, rffi, llmemory
 from pypy.translator.tool.cbuild import ExternalCompilationInfo
+from pypy.jit.backend.x86.arch import WORD
 
 
 def 

[pypy-commit] pypy default: merge heads

2012-02-27 Thread antocuni
Author: Antonio Cuni anto.c...@gmail.com
Branch: 
Changeset: r52924:29f8443e00ec
Date: 2012-02-27 11:44 +0100
http://bitbucket.org/pypy/pypy/changeset/29f8443e00ec/

Log:merge heads

diff --git a/pypy/jit/metainterp/compile.py b/pypy/jit/metainterp/compile.py
--- a/pypy/jit/metainterp/compile.py
+++ b/pypy/jit/metainterp/compile.py
@@ -289,8 +289,21 @@
 assert isinstance(token, TargetToken)
 assert token.original_jitcell_token is None
 token.original_jitcell_token = trace.original_jitcell_token
-
-
+
+
+def do_compile_loop(metainterp_sd, inputargs, operations, looptoken,
+log=True, name=''):
+metainterp_sd.logger_ops.log_loop(inputargs, operations, -2,
+  'compiling', name=name)
+return metainterp_sd.cpu.compile_loop(inputargs, operations, looptoken,
+  log=log, name=name)
+
+def do_compile_bridge(metainterp_sd, faildescr, inputargs, operations,
+  original_loop_token, log=True):
+metainterp_sd.logger_ops.log_bridge(inputargs, operations, -2)
+return metainterp_sd.cpu.compile_bridge(faildescr, inputargs, operations,
+original_loop_token, log=log)
+
 def send_loop_to_backend(greenkey, jitdriver_sd, metainterp_sd, loop, type):
 vinfo = jitdriver_sd.virtualizable_info
 if vinfo is not None:
@@ -319,9 +332,9 @@
 metainterp_sd.profiler.start_backend()
 debug_start(jit-backend)
 try:
-asminfo = metainterp_sd.cpu.compile_loop(loop.inputargs, operations,
-  original_jitcell_token,
-  name=loopname)
+asminfo = do_compile_loop(metainterp_sd, loop.inputargs,
+  operations, original_jitcell_token,
+  name=loopname)
 finally:
 debug_stop(jit-backend)
 metainterp_sd.profiler.end_backend()
@@ -333,7 +346,6 @@
 metainterp_sd.stats.compiled()
 metainterp_sd.log(compiled new  + type)
 #
-loopname = jitdriver_sd.warmstate.get_location_str(greenkey)
 if asminfo is not None:
 ops_offset = asminfo.ops_offset
 else:
@@ -365,9 +377,9 @@
 metainterp_sd.profiler.start_backend()
 debug_start(jit-backend)
 try:
-asminfo = metainterp_sd.cpu.compile_bridge(faildescr, inputargs,
-   operations,
-   original_loop_token)
+asminfo = do_compile_bridge(metainterp_sd, faildescr, inputargs,
+operations,
+original_loop_token)
 finally:
 debug_stop(jit-backend)
 metainterp_sd.profiler.end_backend()
diff --git a/pypy/jit/metainterp/logger.py b/pypy/jit/metainterp/logger.py
--- a/pypy/jit/metainterp/logger.py
+++ b/pypy/jit/metainterp/logger.py
@@ -18,6 +18,10 @@
 debug_start(jit-log-noopt-loop)
 logops = self._log_operations(inputargs, operations, ops_offset)
 debug_stop(jit-log-noopt-loop)
+elif number == -2:
+debug_start(jit-log-compiling-loop)
+logops = self._log_operations(inputargs, operations, ops_offset)
+debug_stop(jit-log-compiling-loop)
 else:
 debug_start(jit-log-opt-loop)
 debug_print(# Loop, number, '(%s)' % name , :, type,
@@ -31,6 +35,10 @@
 debug_start(jit-log-noopt-bridge)
 logops = self._log_operations(inputargs, operations, ops_offset)
 debug_stop(jit-log-noopt-bridge)
+elif number == -2:
+debug_start(jit-log-compiling-bridge)
+logops = self._log_operations(inputargs, operations, ops_offset)
+debug_stop(jit-log-compiling-bridge)
 else:
 debug_start(jit-log-opt-bridge)
 debug_print(# bridge out of Guard, number,
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: hg merge default again

2012-02-27 Thread antocuni
Author: Antonio Cuni anto.c...@gmail.com
Branch: py3k
Changeset: r52925:de6a79306bfe
Date: 2012-02-27 11:44 +0100
http://bitbucket.org/pypy/pypy/changeset/de6a79306bfe/

Log:hg merge default again

diff --git a/pypy/jit/metainterp/compile.py b/pypy/jit/metainterp/compile.py
--- a/pypy/jit/metainterp/compile.py
+++ b/pypy/jit/metainterp/compile.py
@@ -289,8 +289,21 @@
 assert isinstance(token, TargetToken)
 assert token.original_jitcell_token is None
 token.original_jitcell_token = trace.original_jitcell_token
-
-
+
+
+def do_compile_loop(metainterp_sd, inputargs, operations, looptoken,
+log=True, name=''):
+metainterp_sd.logger_ops.log_loop(inputargs, operations, -2,
+  'compiling', name=name)
+return metainterp_sd.cpu.compile_loop(inputargs, operations, looptoken,
+  log=log, name=name)
+
+def do_compile_bridge(metainterp_sd, faildescr, inputargs, operations,
+  original_loop_token, log=True):
+metainterp_sd.logger_ops.log_bridge(inputargs, operations, -2)
+return metainterp_sd.cpu.compile_bridge(faildescr, inputargs, operations,
+original_loop_token, log=log)
+
 def send_loop_to_backend(greenkey, jitdriver_sd, metainterp_sd, loop, type):
 vinfo = jitdriver_sd.virtualizable_info
 if vinfo is not None:
@@ -319,9 +332,9 @@
 metainterp_sd.profiler.start_backend()
 debug_start(jit-backend)
 try:
-asminfo = metainterp_sd.cpu.compile_loop(loop.inputargs, operations,
-  original_jitcell_token,
-  name=loopname)
+asminfo = do_compile_loop(metainterp_sd, loop.inputargs,
+  operations, original_jitcell_token,
+  name=loopname)
 finally:
 debug_stop(jit-backend)
 metainterp_sd.profiler.end_backend()
@@ -333,7 +346,6 @@
 metainterp_sd.stats.compiled()
 metainterp_sd.log(compiled new  + type)
 #
-loopname = jitdriver_sd.warmstate.get_location_str(greenkey)
 if asminfo is not None:
 ops_offset = asminfo.ops_offset
 else:
@@ -365,9 +377,9 @@
 metainterp_sd.profiler.start_backend()
 debug_start(jit-backend)
 try:
-asminfo = metainterp_sd.cpu.compile_bridge(faildescr, inputargs,
-   operations,
-   original_loop_token)
+asminfo = do_compile_bridge(metainterp_sd, faildescr, inputargs,
+operations,
+original_loop_token)
 finally:
 debug_stop(jit-backend)
 metainterp_sd.profiler.end_backend()
diff --git a/pypy/jit/metainterp/logger.py b/pypy/jit/metainterp/logger.py
--- a/pypy/jit/metainterp/logger.py
+++ b/pypy/jit/metainterp/logger.py
@@ -18,6 +18,10 @@
 debug_start(jit-log-noopt-loop)
 logops = self._log_operations(inputargs, operations, ops_offset)
 debug_stop(jit-log-noopt-loop)
+elif number == -2:
+debug_start(jit-log-compiling-loop)
+logops = self._log_operations(inputargs, operations, ops_offset)
+debug_stop(jit-log-compiling-loop)
 else:
 debug_start(jit-log-opt-loop)
 debug_print(# Loop, number, '(%s)' % name , :, type,
@@ -31,6 +35,10 @@
 debug_start(jit-log-noopt-bridge)
 logops = self._log_operations(inputargs, operations, ops_offset)
 debug_stop(jit-log-noopt-bridge)
+elif number == -2:
+debug_start(jit-log-compiling-bridge)
+logops = self._log_operations(inputargs, operations, ops_offset)
+debug_stop(jit-log-compiling-bridge)
 else:
 debug_start(jit-log-opt-bridge)
 debug_print(# bridge out of Guard, number,
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Test and fix. Probably fixes Spacelee on pypy-dev.

2012-02-27 Thread arigo
Author: Armin Rigo ar...@tunes.org
Branch: 
Changeset: r52926:e91c5cdac576
Date: 2012-02-27 14:41 +0100
http://bitbucket.org/pypy/pypy/changeset/e91c5cdac576/

Log:Test and fix. Probably fixes Spacelee on pypy-dev.

diff --git a/pypy/jit/backend/llsupport/rewrite.py 
b/pypy/jit/backend/llsupport/rewrite.py
--- a/pypy/jit/backend/llsupport/rewrite.py
+++ b/pypy/jit/backend/llsupport/rewrite.py
@@ -1,6 +1,6 @@
 import sys
 from pypy.rlib.rarithmetic import ovfcheck
-from pypy.jit.metainterp.history import ConstInt, BoxPtr, ConstPtr
+from pypy.jit.metainterp.history import ConstInt, BoxPtr, ConstPtr, BoxInt
 from pypy.jit.metainterp.resoperation import ResOperation, rop
 from pypy.jit.codewriter import heaptracker
 from pypy.jit.backend.llsupport.symbolic import WORD
@@ -96,8 +96,8 @@
 def handle_new_fixedsize(self, descr, op):
 assert isinstance(descr, SizeDescr)
 size = descr.size
-self.gen_malloc_nursery(size, op.result)
-self.gen_initialize_tid(op.result, descr.tid)
+in_nursery = self.gen_malloc_nursery(size, op.result)
+self.gen_initialize_tid(op.result, descr.tid, in_nursery)
 
 def handle_new_array(self, arraydescr, op):
 v_length = op.getarg(0)
@@ -113,8 +113,8 @@
 elif arraydescr.itemsize == 0:
 total_size = arraydescr.basesize
 if 0 = total_size = 0xff: # up to 16MB, arbitrarily
-self.gen_malloc_nursery(total_size, op.result)
-self.gen_initialize_tid(op.result, arraydescr.tid)
+in_nursery = self.gen_malloc_nursery(total_size, op.result)
+self.gen_initialize_tid(op.result, arraydescr.tid, in_nursery)
 self.gen_initialize_len(op.result, v_length, arraydescr.lendescr)
 elif self.gc_ll_descr.kind == 'boehm':
 self.gen_boehm_malloc_array(arraydescr, v_length, op.result)
@@ -212,7 +212,7 @@
 size = self.round_up_for_allocation(size)
 if not self.gc_ll_descr.can_use_nursery_malloc(size):
 self.gen_malloc_fixedsize(size, v_result)
-return
+return False
 #
 op = None
 if self._op_malloc_nursery is not None:
@@ -238,12 +238,26 @@
 self._previous_size = size
 self._v_last_malloced_nursery = v_result
 self.recent_mallocs[v_result] = None
+return True
 
-def gen_initialize_tid(self, v_newgcobj, tid):
+def gen_initialize_tid(self, v_newgcobj, tid, in_nursery):
 if self.gc_ll_descr.fielddescr_tid is not None:
 # produce a SETFIELD to initialize the GC header
+v_tid = ConstInt(tid)
+if not in_nursery:
+# important: must preserve the gcflags!  rare case.
+v_tidbase = BoxInt()
+v_tidcombined = BoxInt()
+op = ResOperation(rop.GETFIELD_RAW,
+  [v_newgcobj], v_tidbase,
+  descr=self.gc_ll_descr.fielddescr_tid)
+self.newops.append(op)
+op = ResOperation(rop.INT_OR,
+  [v_tidbase, v_tid], v_tidcombined)
+self.newops.append(op)
+v_tid = v_tidcombined
 op = ResOperation(rop.SETFIELD_GC,
-  [v_newgcobj, ConstInt(tid)], None,
+  [v_newgcobj, v_tid], None,
   descr=self.gc_ll_descr.fielddescr_tid)
 self.newops.append(op)
 
diff --git a/pypy/jit/backend/llsupport/test/test_rewrite.py 
b/pypy/jit/backend/llsupport/test/test_rewrite.py
--- a/pypy/jit/backend/llsupport/test/test_rewrite.py
+++ b/pypy/jit/backend/llsupport/test/test_rewrite.py
@@ -371,7 +371,9 @@
 p0 = call_malloc_gc(ConstClass(malloc_fixedsize), \
 %(bdescr.basesize + 104)d,\
 descr=malloc_fixedsize_descr)
-setfield_gc(p0, 8765, descr=tiddescr)
+i0 = getfield_raw(p0, descr=tiddescr)
+i1 = int_or(i0, 8765)
+setfield_gc(p0, i1, descr=tiddescr)
 setfield_gc(p0, 103, descr=blendescr)
 jump()
 )
@@ -437,7 +439,9 @@
 [p1]
 p0 = call_malloc_gc(ConstClass(malloc_fixedsize), 104, \
 descr=malloc_fixedsize_descr)
-setfield_gc(p0, 9315, descr=tiddescr)
+i0 = getfield_raw(p0, descr=tiddescr)
+i1 = int_or(i0, 9315)
+setfield_gc(p0, i1, descr=tiddescr)
 setfield_gc(p0, ConstClass(o_vtable), descr=vtable_descr)
 jump()
 )
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy faster-str-decode-escape: Try to speed up string's decode escape by using a string builder and appending unescaped text in slices

2012-02-27 Thread justinpeel
Author: Justin Peel notmuchtot...@gmail.com
Branch: faster-str-decode-escape
Changeset: r52927:6f5ea64c8b8d
Date: 2012-02-27 07:55 -0700
http://bitbucket.org/pypy/pypy/changeset/6f5ea64c8b8d/

Log:Try to speed up string's decode escape by using a string builder and
appending unescaped text in slices

diff --git a/pypy/interpreter/pyparser/parsestring.py 
b/pypy/interpreter/pyparser/parsestring.py
--- a/pypy/interpreter/pyparser/parsestring.py
+++ b/pypy/interpreter/pyparser/parsestring.py
@@ -115,21 +115,24 @@
 the string is UTF-8 encoded and should be re-encoded in the
 specified encoding.
 
-lis = []
+from pypy.rlib.rstring import StringBuilder
+builder = StringBuilder(len(s))
 ps = 0
 end = len(s)
-while ps  end:
-if s[ps] != '\\':
-# note that the C code has a label here.
-# the logic is the same.
+while 1:
+ps2 = ps
+while ps  end and s[ps] != '\\':
 if recode_encoding and ord(s[ps])  0x80:
 w, ps = decode_utf8(space, s, ps, end, recode_encoding)
-# Append bytes to output buffer.
-lis.append(w)
+builder.append(w)
+ps2 = ps
 else:
-lis.append(s[ps])
 ps += 1
-continue
+if ps  ps2:
+builder.append_slice(s, ps2, ps)
+if ps == end:
+break
+
 ps += 1
 if ps == end:
 raise_app_valueerror(space, 'Trailing \\ in string')
@@ -140,25 +143,25 @@
 if ch == '\n':
 pass
 elif ch == '\\':
-lis.append('\\')
+builder.append('\\')
 elif ch == ':
-lis.append(')
+builder.append(')
 elif ch == '':
-lis.append('')
+builder.append('')
 elif ch == 'b':
-lis.append(\010)
+builder.append(\010)
 elif ch == 'f':
-lis.append('\014') # FF
+builder.append('\014') # FF
 elif ch == 't':
-lis.append('\t')
+builder.append('\t')
 elif ch == 'n':
-lis.append('\n')
+builder.append('\n')
 elif ch == 'r':
-lis.append('\r')
+builder.append('\r')
 elif ch == 'v':
-lis.append('\013') # VT
+builder.append('\013') # VT
 elif ch == 'a':
-lis.append('\007') # BEL, not classic C
+builder.append('\007') # BEL, not classic C
 elif ch in '01234567':
 # Look for up to two more octal digits
 span = ps
@@ -168,13 +171,13 @@
 # emulate a strange wrap-around behavior of CPython:
 # \400 is the same as \000 because 0400 == 256
 num = int(octal, 8)  0xFF
-lis.append(chr(num))
+builder.append(chr(num))
 ps = span
 elif ch == 'x':
 if ps+2 = end and isxdigit(s[ps]) and isxdigit(s[ps + 1]):
 hexa = s[ps : ps + 2]
 num = int(hexa, 16)
-lis.append(chr(num))
+builder.append(chr(num))
 ps += 2
 else:
 raise_app_valueerror(space, 'invalid \\x escape')
@@ -184,13 +187,13 @@
 # this was not an escape, so the backslash
 # has to be added, and we start over in
 # non-escape mode.
-lis.append('\\')
+builder.append('\\')
 ps -= 1
 assert ps = 0
 continue
 # an arbitry number of unescaped UTF-8 bytes may follow.
 
-buf = ''.join(lis)
+buf = builder.build()
 return buf
 
 
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Fixes fixes fixes.

2012-02-27 Thread arigo
Author: Armin Rigo ar...@tunes.org
Branch: 
Changeset: r52928:b9733690c4de
Date: 2012-02-27 16:14 +0100
http://bitbucket.org/pypy/pypy/changeset/b9733690c4de/

Log:Fixes fixes fixes.

diff --git a/pypy/jit/backend/llsupport/gc.py b/pypy/jit/backend/llsupport/gc.py
--- a/pypy/jit/backend/llsupport/gc.py
+++ b/pypy/jit/backend/llsupport/gc.py
@@ -769,11 +769,21 @@
 self.generate_function('malloc_unicode', malloc_unicode,
[lltype.Signed])
 
-# Rarely called: allocate a fixed-size amount of bytes, but
-# not in the nursery, because it is too big.  Implemented like
-# malloc_nursery_slowpath() above.
-self.generate_function('malloc_fixedsize', malloc_nursery_slowpath,
-   [lltype.Signed])
+# Never called as far as I can tell, but there for completeness:
+# allocate a fixed-size object, but not in the nursery, because
+# it is too big.
+def malloc_big_fixedsize(size, tid):
+Allocate 'size' null bytes out of the nursery.
+Note that the fast path is typically inlined by the backend.
+if self.DEBUG:
+self._random_usage_of_xmm_registers()
+type_id = llop.extract_ushort(llgroup.HALFWORD, tid)
+check_typeid(type_id)
+return llop1.do_malloc_fixedsize_clear(llmemory.GCREF,
+   type_id, size,
+   False, False, False)
+self.generate_function('malloc_big_fixedsize', malloc_big_fixedsize,
+   [lltype.Signed] * 2)
 
 def _bh_malloc(self, sizedescr):
 from pypy.rpython.memory.gctypelayout import check_typeid
diff --git a/pypy/jit/backend/llsupport/rewrite.py 
b/pypy/jit/backend/llsupport/rewrite.py
--- a/pypy/jit/backend/llsupport/rewrite.py
+++ b/pypy/jit/backend/llsupport/rewrite.py
@@ -96,8 +96,10 @@
 def handle_new_fixedsize(self, descr, op):
 assert isinstance(descr, SizeDescr)
 size = descr.size
-in_nursery = self.gen_malloc_nursery(size, op.result)
-self.gen_initialize_tid(op.result, descr.tid, in_nursery)
+if self.gen_malloc_nursery(size, op.result):
+self.gen_initialize_tid(op.result, descr.tid)
+else:
+self.gen_malloc_fixedsize(size, descr.tid, op.result)
 
 def handle_new_array(self, arraydescr, op):
 v_length = op.getarg(0)
@@ -112,9 +114,9 @@
 pass# total_size is still -1
 elif arraydescr.itemsize == 0:
 total_size = arraydescr.basesize
-if 0 = total_size = 0xff: # up to 16MB, arbitrarily
-in_nursery = self.gen_malloc_nursery(total_size, op.result)
-self.gen_initialize_tid(op.result, arraydescr.tid, in_nursery)
+if (0 = total_size = 0xff and # up to 16MB, arbitrarily
+self.gen_malloc_nursery(total_size, op.result)):
+self.gen_initialize_tid(op.result, arraydescr.tid)
 self.gen_initialize_len(op.result, v_length, arraydescr.lendescr)
 elif self.gc_ll_descr.kind == 'boehm':
 self.gen_boehm_malloc_array(arraydescr, v_length, op.result)
@@ -147,13 +149,22 @@
 # mark 'v_result' as freshly malloced
 self.recent_mallocs[v_result] = None
 
-def gen_malloc_fixedsize(self, size, v_result):
-Generate a CALL_MALLOC_GC(malloc_fixedsize_fn, Const(size)).
-Note that with the framework GC, this should be called very rarely.
+def gen_malloc_fixedsize(self, size, typeid, v_result):
+Generate a CALL_MALLOC_GC(malloc_fixedsize_fn, ...).
+Used on Boehm, and on the framework GC for large fixed-size
+mallocs.  (For all I know this latter case never occurs in
+practice, but better safe than sorry.)
 
-addr = self.gc_ll_descr.get_malloc_fn_addr('malloc_fixedsize')
-self._gen_call_malloc_gc([ConstInt(addr), ConstInt(size)], v_result,
- self.gc_ll_descr.malloc_fixedsize_descr)
+if self.gc_ll_descr.fielddescr_tid is not None:  # framework GC
+assert (size  (WORD-1)) == 0, size not aligned?
+addr = self.gc_ll_descr.get_malloc_fn_addr('malloc_big_fixedsize')
+args = [ConstInt(addr), ConstInt(size), ConstInt(typeid)]
+descr = self.gc_ll_descr.malloc_big_fixedsize_descr
+else:# Boehm
+addr = self.gc_ll_descr.get_malloc_fn_addr('malloc_fixedsize')
+args = [ConstInt(addr), ConstInt(size)]
+descr = self.gc_ll_descr.malloc_fixedsize_descr
+self._gen_call_malloc_gc(args, v_result, descr)
 
 def gen_boehm_malloc_array(self, arraydescr, v_num_elem, v_result):
 Generate a CALL_MALLOC_GC(malloc_array_fn, ...) for Boehm.
@@ -211,7 +222,6 @@
 
 size = 

[pypy-commit] pypy default: Fix and comment.

2012-02-27 Thread arigo
Author: Armin Rigo ar...@tunes.org
Branch: 
Changeset: r52929:4991f822e3a7
Date: 2012-02-27 16:17 +0100
http://bitbucket.org/pypy/pypy/changeset/4991f822e3a7/

Log:Fix and comment.

diff --git a/pypy/rpython/memory/gc/minimark.py 
b/pypy/rpython/memory/gc/minimark.py
--- a/pypy/rpython/memory/gc/minimark.py
+++ b/pypy/rpython/memory/gc/minimark.py
@@ -608,8 +608,9 @@
 specified as 0 if the object is not varsized.  The returned
 object is fully initialized and zero-filled.
 #
-# Here we really need a valid 'typeid'.
-ll_assert(rffi.cast(lltype.Signed, typeid) != 0,
+# Here we really need a valid 'typeid', not 0 (as the JIT might
+# try to send us if there is still a bug).
+ll_assert(bool(self.combine(typeid, 0)),
   external_malloc: typeid == 0)
 #
 # Compute the total size, carefully checking for overflows.
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Remove the 16MB boundary logic which is pointless now.

2012-02-27 Thread arigo
Author: Armin Rigo ar...@tunes.org
Branch: 
Changeset: r52931:c08753e77c67
Date: 2012-02-27 16:30 +0100
http://bitbucket.org/pypy/pypy/changeset/c08753e77c67/

Log:Remove the 16MB boundary logic which is pointless now.

diff --git a/pypy/jit/backend/llsupport/rewrite.py 
b/pypy/jit/backend/llsupport/rewrite.py
--- a/pypy/jit/backend/llsupport/rewrite.py
+++ b/pypy/jit/backend/llsupport/rewrite.py
@@ -114,7 +114,7 @@
 pass# total_size is still -1
 elif arraydescr.itemsize == 0:
 total_size = arraydescr.basesize
-if (0 = total_size = 0xff and # up to 16MB, arbitrarily
+if (total_size = 0 and
 self.gen_malloc_nursery(total_size, op.result)):
 self.gen_initialize_tid(op.result, arraydescr.tid)
 self.gen_initialize_len(op.result, v_length, arraydescr.lendescr)
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Remove again unused import.

2012-02-27 Thread arigo
Author: Armin Rigo ar...@tunes.org
Branch: 
Changeset: r52932:27e3f649d735
Date: 2012-02-27 16:34 +0100
http://bitbucket.org/pypy/pypy/changeset/27e3f649d735/

Log:Remove again unused import.

diff --git a/pypy/jit/backend/llsupport/rewrite.py 
b/pypy/jit/backend/llsupport/rewrite.py
--- a/pypy/jit/backend/llsupport/rewrite.py
+++ b/pypy/jit/backend/llsupport/rewrite.py
@@ -1,6 +1,6 @@
 import sys
 from pypy.rlib.rarithmetic import ovfcheck
-from pypy.jit.metainterp.history import ConstInt, BoxPtr, ConstPtr, BoxInt
+from pypy.jit.metainterp.history import ConstInt, BoxPtr, ConstPtr
 from pypy.jit.metainterp.resoperation import ResOperation, rop
 from pypy.jit.codewriter import heaptracker
 from pypy.jit.backend.llsupport.symbolic import WORD
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: pff, yak shaving. Since we are now passing an explicit globals() for exec(),

2012-02-27 Thread antocuni
Author: Antonio Cuni anto.c...@gmail.com
Branch: py3k
Changeset: r52933:504ecf08
Date: 2012-02-27 14:16 +0100
http://bitbucket.org/pypy/pypy/changeset/504ecf08/

Log:pff, yak shaving. Since we are now passing an explicit globals() for
exec(), the __name__ was not set. This caused the imp module to be
confused, and the test to fail. It took 2 hours to track it down
:-(

diff --git a/pypy/module/imp/test/test_import.py 
b/pypy/module/imp/test/test_import.py
--- a/pypy/module/imp/test/test_import.py
+++ b/pypy/module/imp/test/test_import.py
@@ -422,17 +422,18 @@
 assert pkg.pkg1.__package__ == 'pkg.pkg1'
 
 def test_future_relative_import_error_when_in_non_package(self):
-ns = {}
+ns = {'__name__': __name__}
 exec(def imp():
+print('__name__ =', __name__)
 from .string import inpackage
-.rstrip(), ns)
+, ns)
 raises(ValueError, ns['imp'])
 
 def test_future_relative_import_error_when_in_non_package2(self):
-ns = {}
+ns = {'__name__': __name__}
 exec(def imp():
 from .. import inpackage
-.rstrip(), ns)
+, ns)
 raises(ValueError, ns['imp'])
 
 def test_relative_import_with___name__(self):
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: these two tests were really meant to be run against itertools, because it's a

2012-02-27 Thread antocuni
Author: Antonio Cuni anto.c...@gmail.com
Branch: py3k
Changeset: r52935:aca4ff218220
Date: 2012-02-27 14:51 +0100
http://bitbucket.org/pypy/pypy/changeset/aca4ff218220/

Log:these two tests were really meant to be run against itertools,
because it's a builtin module. It seems that a20df1bb1bb8 did a
s/itertools/queue, but I can't see why. Revert it.

diff --git a/pypy/module/imp/test/test_import.py 
b/pypy/module/imp/test/test_import.py
--- a/pypy/module/imp/test/test_import.py
+++ b/pypy/module/imp/test/test_import.py
@@ -38,7 +38,7 @@
 test_reload = def test():\nraise ValueError\n,
 infinite_reload = import infinite_reload; 
reload(infinite_reload),
 del_sys_module = import sys\ndel 
sys.modules['del_sys_module']\n,
-queue = hello_world = 42\n,
+itertools = hello_world = 42\n,
 gc = should_never_be_seen = 42\n,
 )
 root.ensure(notapackage, dir=1)# empty, no __init__.py
@@ -151,7 +151,7 @@
 class AppTestImport:
 
 def setup_class(cls): # interpreter-level
-#cls.space = gettestobjspace(usemodules=['itertools'])
+cls.space = gettestobjspace(usemodules=['itertools'])
 cls.w_runappdirect = cls.space.wrap(conftest.option.runappdirect)
 cls.saved_modules = _setup(cls.space)
 #XXX Compile class
@@ -606,32 +606,32 @@
 
 def test_shadow_extension_1(self):
 if self.runappdirect: skip(hard to test: module is already imported)
-# 'import queue' is supposed to find queue.py if there is
+# 'import itertools' is supposed to find itertools.py if there is
 # one in sys.path.
 import sys
-assert 'queue' not in sys.modules
-import queue
-assert hasattr(queue, 'hello_world')
-assert not hasattr(queue, 'count')
-assert '(built-in)' not in repr(queue)
-del sys.modules['queue']
+assert 'itertools' not in sys.modules
+import itertools
+assert hasattr(itertools, 'hello_world')
+assert not hasattr(itertools, 'count')
+assert '(built-in)' not in repr(itertools)
+del sys.modules['itertools']
 
 def test_shadow_extension_2(self):
 if self.runappdirect: skip(hard to test: module is already imported)
-# 'import queue' is supposed to find the built-in module even
+# 'import itertools' is supposed to find the built-in module even
 # if there is also one in sys.path as long as it is *after* the
 # special entry '.../lib_pypy/__extensions__'.
 import sys
-assert 'queue' not in sys.modules
+assert 'itertools' not in sys.modules
 sys.path.append(sys.path.pop(0))
 try:
-import queue
-assert not hasattr(queue, 'hello_world')
-assert hasattr(queue, 'izip')
-assert '(built-in)' in repr(queue)
+import itertools
+assert not hasattr(itertools, 'hello_world')
+assert hasattr(itertools, 'izip')
+assert '(built-in)' in repr(itertools)
 finally:
 sys.path.insert(0, sys.path.pop())
-del sys.modules['queue']
+del sys.modules['itertools']
 
 
 class TestAbi:
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: sys.setdefaultencoding is no longer there, use settrace for this test

2012-02-27 Thread antocuni
Author: Antonio Cuni anto.c...@gmail.com
Branch: py3k
Changeset: r52934:b7200ae0e860
Date: 2012-02-27 14:20 +0100
http://bitbucket.org/pypy/pypy/changeset/b7200ae0e860/

Log:sys.setdefaultencoding is no longer there, use settrace for this
test

diff --git a/pypy/module/imp/test/test_import.py 
b/pypy/module/imp/test/test_import.py
--- a/pypy/module/imp/test/test_import.py
+++ b/pypy/module/imp/test/test_import.py
@@ -553,14 +553,14 @@
 import sys
 oldpath = sys.path
 try:
-del sys.setdefaultencoding
+del sys.settrace
 except AttributeError:
 pass
 
 reload(sys)
 
 assert sys.path is oldpath
-assert 'setdefaultencoding' in dir(sys)
+assert 'settrace' in dir(sys)
 
 def test_reload_infinite(self):
 import infinite_reload
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: urlparse and compiler.misc no longer exists. Replace also distutils.core with

2012-02-27 Thread antocuni
Author: Antonio Cuni anto.c...@gmail.com
Branch: py3k
Changeset: r52936:e838b0057e5d
Date: 2012-02-27 15:02 +0100
http://bitbucket.org/pypy/pypy/changeset/e838b0057e5d/

Log:urlparse and compiler.misc no longer exists. Replace also
distutils.core with html.parser, because it's much faster to import

diff --git a/pypy/module/imp/test/test_import.py 
b/pypy/module/imp/test/test_import.py
--- a/pypy/module/imp/test/test_import.py
+++ b/pypy/module/imp/test/test_import.py
@@ -1135,7 +1135,7 @@
 sys.path_hooks.append(ImpWrapper)
 sys.path_importer_cache.clear()
 try:
-mnames = (colorsys, urlparse, distutils.core, 
compiler.misc)
+mnames = (colorsys, html.parser)
 for mname in mnames:
 parent = mname.split(.)[0]
 for n in sys.modules.keys():
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: forgot to fix the invocation of _testfile after I changed its signature

2012-02-27 Thread antocuni
Author: Antonio Cuni anto.c...@gmail.com
Branch: py3k
Changeset: r52939:3133f7b5d52b
Date: 2012-02-27 16:37 +0100
http://bitbucket.org/pypy/pypy/changeset/3133f7b5d52b/

Log:forgot to fix the invocation of _testfile after I changed its
signature

diff --git a/pypy/module/imp/test/test_import.py 
b/pypy/module/imp/test/test_import.py
--- a/pypy/module/imp/test/test_import.py
+++ b/pypy/module/imp/test/test_import.py
@@ -737,7 +737,7 @@
 space = self.space
 mtime = 12345
 co = compile('x = 42', '?', 'exec')
-cpathname = _testfile(importing.get_pyc_magic(space), mtime, co)
+cpathname = _testfile(space, importing.get_pyc_magic(space), mtime, co)
 w_modulename = space.wrap('somemodule')
 stream = streamio.open_file_as_stream(cpathname, rb)
 try:
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: datetime is now imported from lib-python/3.2, which in turns does other two imports from _datetime. Use 'math' instead, which is builtin and so we are sure it doesn't do any i

2012-02-27 Thread antocuni
Author: Antonio Cuni anto.c...@gmail.com
Branch: py3k
Changeset: r52937:fb993f9644b1
Date: 2012-02-27 15:33 +0100
http://bitbucket.org/pypy/pypy/changeset/fb993f9644b1/

Log:datetime is now imported from lib-python/3.2, which in turns does
other two imports from _datetime. Use 'math' instead, which is
builtin and so we are sure it doesn't do any import

diff --git a/pypy/module/imp/test/test_import.py 
b/pypy/module/imp/test/test_import.py
--- a/pypy/module/imp/test/test_import.py
+++ b/pypy/module/imp/test/test_import.py
@@ -1012,24 +1012,24 @@
 os.environ['LANG'] = oldlang
 
 class AppTestImportHooks(object):
-def test_meta_path(self):
+def test_meta_path_1(self):
 tried_imports = []
 class Importer(object):
 def find_module(self, fullname, path=None):
 tried_imports.append((fullname, path))
 
-import sys, datetime
-del sys.modules[datetime]
+import sys, math
+del sys.modules[math]
 
 sys.meta_path.append(Importer())
 try:
-import datetime
+import math
 assert len(tried_imports) == 1
 package_name = '.'.join(__name__.split('.')[:-1])
 if package_name:
-assert tried_imports[0][0] == package_name + .datetime
+assert tried_imports[0][0] == package_name + .math
 else:
-assert tried_imports[0][0] == datetime
+assert tried_imports[0][0] == math
 finally:
 sys.meta_path.pop()
 
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: bah, we can't marshal a host code object and then expect to unmarshal a PyCode with our own implementation. Instead, convert the host code object to PyCode, and marshal it wit

2012-02-27 Thread antocuni
Author: Antonio Cuni anto.c...@gmail.com
Branch: py3k
Changeset: r52938:372725be34a9
Date: 2012-02-27 16:12 +0100
http://bitbucket.org/pypy/pypy/changeset/372725be34a9/

Log:bah, we can't marshal a host code object and then expect to
unmarshal a PyCode with our own implementation. Instead, convert the
host code object to PyCode, and marshal it with out own impl

diff --git a/pypy/module/imp/test/test_import.py 
b/pypy/module/imp/test/test_import.py
--- a/pypy/module/imp/test/test_import.py
+++ b/pypy/module/imp/test/test_import.py
@@ -2,7 +2,7 @@
 from pypy.interpreter.module import Module
 from pypy.interpreter import gateway
 from pypy.interpreter.error import OperationError
-import pypy.interpreter.pycode
+from pypy.interpreter.pycode import PyCode
 from pypy.tool.udir import udir
 from pypy.rlib import streamio
 from pypy.conftest import gettestobjspace
@@ -649,13 +649,18 @@
 x = marshal.dumps(data)
 return x[-4:]
 
-def _testfile(magic, mtime, co=None):
+def _testfile(space, magic, mtime, co=None):
 cpathname = str(udir.join('test.pyc'))
 f = file(cpathname, wb)
 f.write(_getlong(magic))
 f.write(_getlong(mtime))
 if co:
-marshal.dump(co, f)
+# marshal the code object with the PyPy marshal impl
+pyco = PyCode._from_code(space, co)
+w_marshal = space.getbuiltinmodule('marshal')
+w_marshaled_code = space.call_method(w_marshal, 'dumps', pyco)
+marshaled_code = space.bytes_w(w_marshaled_code)
+f.write(marshaled_code)
 f.close()
 return cpathname
 
@@ -712,7 +717,7 @@
 space = self.space
 mtime = 12345
 co = compile('x = 42', '?', 'exec')
-cpathname = _testfile(importing.get_pyc_magic(space), mtime, co)
+cpathname = _testfile(space, importing.get_pyc_magic(space), mtime, co)
 stream = streamio.open_file_as_stream(cpathname, rb)
 try:
 stream.seek(8, 0)
@@ -721,7 +726,7 @@
 pycode = space.interpclass_w(w_code)
 finally:
 stream.close()
-assert type(pycode) is pypy.interpreter.pycode.PyCode
+assert type(pycode) is PyCode
 w_dic = space.newdict()
 pycode.exec_code(space, w_dic, w_dic)
 w_ret = space.getitem(w_dic, space.wrap('x'))
@@ -764,7 +769,7 @@
 finally:
 stream.close()
 pycode = space.interpclass_w(w_ret)
-assert type(pycode) is pypy.interpreter.pycode.PyCode
+assert type(pycode) is PyCode
 w_dic = space.newdict()
 pycode.exec_code(space, w_dic, w_dic)
 w_ret = space.getitem(w_dic, space.wrap('x'))
@@ -908,7 +913,7 @@
 finally:
 stream.close()
 pycode = space.interpclass_w(w_ret)
-assert type(pycode) is pypy.interpreter.pycode.PyCode
+assert type(pycode) is PyCode
 
 cpathname = str(udir.join('cpathname.pyc'))
 mode = 0777
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: StringIO is no longer there, use cmd instead; fix the syntax of an octal number

2012-02-27 Thread antocuni
Author: Antonio Cuni anto.c...@gmail.com
Branch: py3k
Changeset: r52940:58feb84d8e37
Date: 2012-02-27 16:46 +0100
http://bitbucket.org/pypy/pypy/changeset/58feb84d8e37/

Log:StringIO is no longer there, use cmd instead; fix the syntax of an
octal number

diff --git a/pypy/module/imp/test/test_app.py b/pypy/module/imp/test/test_app.py
--- a/pypy/module/imp/test/test_app.py
+++ b/pypy/module/imp/test/test_app.py
@@ -25,7 +25,7 @@
 
 def test_find_module(self):
 import os
-file, pathname, description = self.imp.find_module('StringIO')
+file, pathname, description = self.imp.find_module('cmd')
 assert file is not None
 file.close()
 assert os.path.exists(pathname)
@@ -63,7 +63,7 @@
 assert not 
self.imp.is_frozen('hello.world.this.is.never.a.frozen.module.name')
 
 
-def test_load_module_py(self):
+def test_load_module_pyx(self):
 fn = self._py_file()
 descr = ('.py', 'U', self.imp.PY_SOURCE)
 f = open(fn, 'U')
@@ -164,7 +164,7 @@
 with open(file_name, wb) as f:
 f.write(code)
 compiled_name = file_name + (c if __debug__ else o)
-chmod(file_name, 0777)
+chmod(file_name, 0o777)
 
 # Setup
 sys_path = path[:]
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: fix typo

2012-02-27 Thread antocuni
Author: Antonio Cuni anto.c...@gmail.com
Branch: py3k
Changeset: r52941:96b007a12d00
Date: 2012-02-27 16:50 +0100
http://bitbucket.org/pypy/pypy/changeset/96b007a12d00/

Log:fix typo

diff --git a/pypy/module/imp/test/test_app.py b/pypy/module/imp/test/test_app.py
--- a/pypy/module/imp/test/test_app.py
+++ b/pypy/module/imp/test/test_app.py
@@ -63,7 +63,7 @@
 assert not 
self.imp.is_frozen('hello.world.this.is.never.a.frozen.module.name')
 
 
-def test_load_module_pyx(self):
+def test_load_module_py(self):
 fn = self._py_file()
 descr = ('.py', 'U', self.imp.PY_SOURCE)
 f = open(fn, 'U')
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: make sure that we write *bytes* when marshaling; test_load_module_pyc_1 makes a bit of more progress, now it fails because we don't know how to handle _io files

2012-02-27 Thread antocuni
Author: Antonio Cuni anto.c...@gmail.com
Branch: py3k
Changeset: r52942:138699bd5038
Date: 2012-02-27 16:57 +0100
http://bitbucket.org/pypy/pypy/changeset/138699bd5038/

Log:make sure that we write *bytes* when marshaling;
test_load_module_pyc_1 makes a bit of more progress, now it fails
because we don't know how to handle _io files

diff --git a/pypy/module/imp/test/test_app.py b/pypy/module/imp/test/test_app.py
--- a/pypy/module/imp/test/test_app.py
+++ b/pypy/module/imp/test/test_app.py
@@ -18,7 +18,7 @@
 co = compile(marker=42, x.py, exec)
 f = open('@TEST.pyc', 'wb')
 f.write(imp.get_magic())
-f.write('\x00\x00\x00\x00')
+f.write(b'\x00\x00\x00\x00')
 marshal.dump(co, f)
 f.close()
 return '@TEST.pyc'
diff --git a/pypy/module/marshal/interp_marshal.py 
b/pypy/module/marshal/interp_marshal.py
--- a/pypy/module/marshal/interp_marshal.py
+++ b/pypy/module/marshal/interp_marshal.py
@@ -81,7 +81,7 @@
 
 def write(self, data):
 space = self.space
-space.call_function(self.func, space.wrap(data))
+space.call_function(self.func, space.wrapbytes(data))
 
 
 class FileReader(AbstractReaderWriter):
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Test from issue1073.

2012-02-27 Thread arigo
Author: Armin Rigo ar...@tunes.org
Branch: 
Changeset: r52943:092ee39048af
Date: 2012-02-27 17:23 +0100
http://bitbucket.org/pypy/pypy/changeset/092ee39048af/

Log:Test from issue1073.

diff --git a/pypy/module/pypyjit/test_pypy_c/test_00_model.py 
b/pypy/module/pypyjit/test_pypy_c/test_00_model.py
--- a/pypy/module/pypyjit/test_pypy_c/test_00_model.py
+++ b/pypy/module/pypyjit/test_pypy_c/test_00_model.py
@@ -60,6 +60,9 @@
 stdout=subprocess.PIPE,
 stderr=subprocess.PIPE)
 stdout, stderr = pipe.communicate()
+if getattr(pipe, 'returncode', 0)  0:
+raise IOError(subprocess was killed by signal %d % (
+pipe.returncode,))
 if stderr.startswith('SKIP:'):
 py.test.skip(stderr)
 if stderr.startswith('debug_alloc.h:'):   # lldebug builds
diff --git a/pypy/module/pypyjit/test_pypy_c/test_alloc.py 
b/pypy/module/pypyjit/test_pypy_c/test_alloc.py
new file mode 100644
--- /dev/null
+++ b/pypy/module/pypyjit/test_pypy_c/test_alloc.py
@@ -0,0 +1,26 @@
+import py, sys
+from pypy.module.pypyjit.test_pypy_c.test_00_model import BaseTestPyPyC
+
+class TestAlloc(BaseTestPyPyC):
+
+SIZES = dict.fromkeys([2 ** n for n in range(26)] + # up to 32MB
+  [2 ** n - 1 for n in range(26)])
+
+def test_newstr_constant_size(self):
+for size in TestAlloc.SIZES:
+yield self.newstr_constant_size, size
+
+def newstr_constant_size(self, size):
+src = if 1:
+N = %(size)d
+part_a = 'a' * N
+part_b = 'b' * N
+for i in xrange(20):
+ao = '%%s%%s' %% (part_a, part_b)
+def main():
+return 42
+ % {'size': size}
+log = self.run(src, [], threshold=10)
+assert log.result == 42
+loop, = log.loops_by_filename(self.filepath)
+# assert did not crash
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy miniscan: Check-in intermediate progress for completeness, and close this

2012-02-27 Thread arigo
Author: Armin Rigo ar...@tunes.org
Branch: miniscan
Changeset: r52944:698dc6400468
Date: 2012-02-27 18:20 +0100
http://bitbucket.org/pypy/pypy/changeset/698dc6400468/

Log:Check-in intermediate progress for completeness, and close this
branch as abandoned.

diff --git a/pypy/rpython/memory/gc/minimark.py 
b/pypy/rpython/memory/gc/minimark.py
--- a/pypy/rpython/memory/gc/minimark.py
+++ b/pypy/rpython/memory/gc/minimark.py
@@ -1300,10 +1300,17 @@
 # then the write_barrier must have ensured that the prebuilt
 # GcStruct is in the list self.old_objects_pointing_to_young.
 debug_start(gc-minor-walkroots)
+if self.root_walker.conservative_stack_roots:
+self.prepare_conservative_stack_roots_minor()
+stack_roots = MiniMarkGC.conservative_stack_roots_minor
+else:
+stack_roots = MiniMarkGC._trace_drag_out1
 self.root_walker.walk_roots(
-MiniMarkGC._trace_drag_out1,  # stack roots
+stack_roots,  # stack roots
 MiniMarkGC._trace_drag_out1,  # static in prebuilt non-gc
 None) # static in prebuilt gc
+if self.root_walker.conservative_stack_roots:
+self.finish_conservative_stack_roots_minor()
 debug_stop(gc-minor-walkroots)
 
 def collect_cardrefs_to_nursery(self):
@@ -1708,10 +1715,17 @@
self.objects_to_trace)
 #
 # Add the roots from the other sources.
+if self.root_walker.conservative_stack_roots:
+self.prepare_conservative_stack_roots_major()
+stack_roots = MiniMarkGC.conservative_stack_roots_major
+else:
+stack_roots = MiniMarkGC._collect_ref_stk
 self.root_walker.walk_roots(
-MiniMarkGC._collect_ref_stk, # stack roots
+stack_roots, # stack roots
 MiniMarkGC._collect_ref_stk, # static in prebuilt non-gc structures
 None)   # we don't need the static in all prebuilt gc objects
+if self.root_walker.conservative_stack_roots:
+self.finish_conservative_stack_roots_major()
 #
 # If we are in an inner collection caused by a call to a finalizer,
 # the 'run_finalizers' objects also need to be kept alive.
@@ -2022,6 +2036,42 @@
 self.old_objects_with_weakrefs.delete()
 self.old_objects_with_weakrefs = new_with_weakref
 
+# --
+# Conservative stack scanning, for --gcrootfinder=scan
+
+SMALL_VALUE_MAX = 4095
+
+def prepare_conservative_stack_roots_minor(self):
+...
+
+def conservative_stack_roots_minor(self, start, stop):
+Called during a minor collection.  Must conservatively find
+addresses from the stack, between 'start' and 'stop', that
+point to young objects.  These objects must be pinned down.
+
+scan = start
+while scan != stop:
+addr = scan.address[0]   # maybe an address
+addrint = llmemory.cast_adr_to_int(addr)
+scan += llmemory.sizeof(llmemory.Address)
+#
+# A first quick check for NULLs or small positive integers
+if r_uint(addrint) = r_uint(self.SMALL_VALUE_MAX):
+continue
+#
+# If it's not aligned to a WORD, no chance
+if addrint  (WORD-1) != 0:
+continue
+#
+# Is it in the nursery?
+if self.is_in_nursery(addr):
+#
+# ././.
+
+
+def conservative_stack_roots_major(self, start, stop):
+xxx
+
 
 # 
 
diff --git a/pypy/rpython/memory/gctransform/framework.py 
b/pypy/rpython/memory/gctransform/framework.py
--- a/pypy/rpython/memory/gctransform/framework.py
+++ b/pypy/rpython/memory/gctransform/framework.py
@@ -1341,6 +1341,7 @@
 class BaseRootWalker(object):
 need_root_stack = False
 thread_setup = None
+conservative_stack_roots = False
 
 def __init__(self, gctransformer):
 self.gcdata = gctransformer.gcdata
diff --git a/pypy/rpython/memory/gctransform/scan.py 
b/pypy/rpython/memory/gctransform/scan.py
--- a/pypy/rpython/memory/gctransform/scan.py
+++ b/pypy/rpython/memory/gctransform/scan.py
@@ -35,6 +35,7 @@
 
 
 class ScanStackRootWalker(BaseRootWalker):
+conservative_stack_roots = True
 
 def __init__(self, gctransformer):
 BaseRootWalker.__init__(self, gctransformer)
@@ -44,25 +45,50 @@
 self._asm_callback = _asm_callback
 
 #def need_stacklet_support(self, gctransformer, getfn):
-#   anything needed?
+#   xxx
 
 #def need_thread_support(self, gctransformer, getfn):
 #   xxx
 
-def walk_stack_roots(self, collect_stack_root):
+def walk_stack_roots(self, collect_stack_root_range):
 gcdata = self.gcdata
-  

[pypy-commit] pypy dead-code-optimization: implement dead ops removal

2012-02-27 Thread fijal
Author: Maciej Fijalkowski fij...@gmail.com
Branch: dead-code-optimization
Changeset: r52945:58bcd5dd0b05
Date: 2012-02-27 16:50 -0800
http://bitbucket.org/pypy/pypy/changeset/58bcd5dd0b05/

Log:implement dead ops removal

diff --git a/pypy/jit/metainterp/optimizeopt/__init__.py 
b/pypy/jit/metainterp/optimizeopt/__init__.py
--- a/pypy/jit/metainterp/optimizeopt/__init__.py
+++ b/pypy/jit/metainterp/optimizeopt/__init__.py
@@ -9,6 +9,7 @@
 from pypy.jit.metainterp.optimizeopt.simplify import OptSimplify
 from pypy.jit.metainterp.optimizeopt.pure import OptPure
 from pypy.jit.metainterp.optimizeopt.earlyforce import OptEarlyForce
+from pypy.jit.metainterp.optimizeopt.deadops import remove_dead_ops
 from pypy.rlib.jit import PARAMETERS
 from pypy.rlib.unroll import unrolling_iterable
 from pypy.rlib.debug import debug_start, debug_stop, debug_print
@@ -65,6 +66,7 @@
 else:
 optimizer = Optimizer(metainterp_sd, loop, optimizations)
 optimizer.propagate_all_forward()
+remove_dead_ops(loop)
 finally:
 debug_stop(jit-optimize)
 
diff --git a/pypy/jit/metainterp/optimizeopt/deadops.py 
b/pypy/jit/metainterp/optimizeopt/deadops.py
new file mode 100644
--- /dev/null
+++ b/pypy/jit/metainterp/optimizeopt/deadops.py
@@ -0,0 +1,16 @@
+
+def remove_dead_ops(loop):
+newops = []
+seen = {}
+for i in range(len(loop.operations) -1, -1, -1):
+op = loop.operations[i]
+if op.has_no_side_effect() and op.result not in seen:
+continue
+for arg in op.getarglist():
+seen[arg] = None
+if op.getfailargs():
+for arg in op.getfailargs():
+seen[arg] = None
+newops.append(op)
+newops.reverse()
+loop.operations[:] = newops
diff --git a/pypy/jit/metainterp/optimizeopt/test/test_deadops.py 
b/pypy/jit/metainterp/optimizeopt/test/test_deadops.py
new file mode 100644
--- /dev/null
+++ b/pypy/jit/metainterp/optimizeopt/test/test_deadops.py
@@ -0,0 +1,57 @@
+
+from pypy.jit.metainterp.optimizeopt.test.test_util import LLtypeMixin
+from pypy.jit.metainterp.optimizeopt.test.test_optimizebasic import 
BaseTestBasic
+
+class TestRemoveDeadOps(BaseTestBasic, LLtypeMixin):
+def test_deadops(self):
+ops = 
+[i0]
+i1 = int_add(i0, 1)
+jump()
+
+expected = 
+[i0]
+jump()
+
+self.optimize_loop(ops, expected)
+
+def test_not_deadops(self):
+ops = 
+[i0]
+i1 = int_add(i0, 1)
+jump(i1)
+
+expected = 
+[i0]
+i1 = int_add(i0, 1)
+jump(i1)
+
+self.optimize_loop(ops, expected)
+
+def test_not_deadops_1(self):
+ops = 
+[i0]
+i1 = int_add(i0, 1)
+guard_true(i0) [i1]
+jump()
+
+expected = 
+[i0] 
+i1 = int_add(i0, 1)
+guard_true(i0) [i1]
+jump()
+
+self.optimize_loop(ops, expected)
+
+def test_not_deadops_2(self):
+ops = 
+[p0, i0]
+setfield_gc(p0, i0)
+jump()
+
+expected = 
+[p0, i0]
+setfield_gc(p0, i0)
+jump()
+
+self.optimize_loop(ops, expected)
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy faster-str-decode-escape: merge in default

2012-02-27 Thread justinpeel
Author: Justin Peel notmuchtot...@gmail.com
Branch: faster-str-decode-escape
Changeset: r52946:c095ae1d0b83
Date: 2012-02-27 20:24 -0700
http://bitbucket.org/pypy/pypy/changeset/c095ae1d0b83/

Log:merge in default

diff --git a/pypy/jit/backend/llsupport/gc.py b/pypy/jit/backend/llsupport/gc.py
--- a/pypy/jit/backend/llsupport/gc.py
+++ b/pypy/jit/backend/llsupport/gc.py
@@ -769,11 +769,19 @@
 self.generate_function('malloc_unicode', malloc_unicode,
[lltype.Signed])
 
-# Rarely called: allocate a fixed-size amount of bytes, but
-# not in the nursery, because it is too big.  Implemented like
-# malloc_nursery_slowpath() above.
-self.generate_function('malloc_fixedsize', malloc_nursery_slowpath,
-   [lltype.Signed])
+# Never called as far as I can tell, but there for completeness:
+# allocate a fixed-size object, but not in the nursery, because
+# it is too big.
+def malloc_big_fixedsize(size, tid):
+if self.DEBUG:
+self._random_usage_of_xmm_registers()
+type_id = llop.extract_ushort(llgroup.HALFWORD, tid)
+check_typeid(type_id)
+return llop1.do_malloc_fixedsize_clear(llmemory.GCREF,
+   type_id, size,
+   False, False, False)
+self.generate_function('malloc_big_fixedsize', malloc_big_fixedsize,
+   [lltype.Signed] * 2)
 
 def _bh_malloc(self, sizedescr):
 from pypy.rpython.memory.gctypelayout import check_typeid
diff --git a/pypy/jit/backend/llsupport/rewrite.py 
b/pypy/jit/backend/llsupport/rewrite.py
--- a/pypy/jit/backend/llsupport/rewrite.py
+++ b/pypy/jit/backend/llsupport/rewrite.py
@@ -1,6 +1,6 @@
 import sys
 from pypy.rlib.rarithmetic import ovfcheck
-from pypy.jit.metainterp.history import ConstInt, BoxPtr, ConstPtr, BoxInt
+from pypy.jit.metainterp.history import ConstInt, BoxPtr, ConstPtr
 from pypy.jit.metainterp.resoperation import ResOperation, rop
 from pypy.jit.codewriter import heaptracker
 from pypy.jit.backend.llsupport.symbolic import WORD
@@ -96,8 +96,10 @@
 def handle_new_fixedsize(self, descr, op):
 assert isinstance(descr, SizeDescr)
 size = descr.size
-in_nursery = self.gen_malloc_nursery(size, op.result)
-self.gen_initialize_tid(op.result, descr.tid, in_nursery)
+if self.gen_malloc_nursery(size, op.result):
+self.gen_initialize_tid(op.result, descr.tid)
+else:
+self.gen_malloc_fixedsize(size, descr.tid, op.result)
 
 def handle_new_array(self, arraydescr, op):
 v_length = op.getarg(0)
@@ -112,9 +114,9 @@
 pass# total_size is still -1
 elif arraydescr.itemsize == 0:
 total_size = arraydescr.basesize
-if 0 = total_size = 0xff: # up to 16MB, arbitrarily
-in_nursery = self.gen_malloc_nursery(total_size, op.result)
-self.gen_initialize_tid(op.result, arraydescr.tid, in_nursery)
+if (total_size = 0 and
+self.gen_malloc_nursery(total_size, op.result)):
+self.gen_initialize_tid(op.result, arraydescr.tid)
 self.gen_initialize_len(op.result, v_length, arraydescr.lendescr)
 elif self.gc_ll_descr.kind == 'boehm':
 self.gen_boehm_malloc_array(arraydescr, v_length, op.result)
@@ -147,13 +149,22 @@
 # mark 'v_result' as freshly malloced
 self.recent_mallocs[v_result] = None
 
-def gen_malloc_fixedsize(self, size, v_result):
-Generate a CALL_MALLOC_GC(malloc_fixedsize_fn, Const(size)).
-Note that with the framework GC, this should be called very rarely.
+def gen_malloc_fixedsize(self, size, typeid, v_result):
+Generate a CALL_MALLOC_GC(malloc_fixedsize_fn, ...).
+Used on Boehm, and on the framework GC for large fixed-size
+mallocs.  (For all I know this latter case never occurs in
+practice, but better safe than sorry.)
 
-addr = self.gc_ll_descr.get_malloc_fn_addr('malloc_fixedsize')
-self._gen_call_malloc_gc([ConstInt(addr), ConstInt(size)], v_result,
- self.gc_ll_descr.malloc_fixedsize_descr)
+if self.gc_ll_descr.fielddescr_tid is not None:  # framework GC
+assert (size  (WORD-1)) == 0, size not aligned?
+addr = self.gc_ll_descr.get_malloc_fn_addr('malloc_big_fixedsize')
+args = [ConstInt(addr), ConstInt(size), ConstInt(typeid)]
+descr = self.gc_ll_descr.malloc_big_fixedsize_descr
+else:# Boehm
+addr = self.gc_ll_descr.get_malloc_fn_addr('malloc_fixedsize')
+args = [ConstInt(addr), ConstInt(size)]
+descr = self.gc_ll_descr.malloc_fixedsize_descr
+

[pypy-commit] pypy default: merge in faster-str-decode-escape branch

2012-02-27 Thread justinpeel
Author: Justin Peel notmuchtot...@gmail.com
Branch: 
Changeset: r52947:80e3d375b9ec
Date: 2012-02-27 20:25 -0700
http://bitbucket.org/pypy/pypy/changeset/80e3d375b9ec/

Log:merge in faster-str-decode-escape branch

diff --git a/pypy/interpreter/pyparser/parsestring.py 
b/pypy/interpreter/pyparser/parsestring.py
--- a/pypy/interpreter/pyparser/parsestring.py
+++ b/pypy/interpreter/pyparser/parsestring.py
@@ -115,21 +115,24 @@
 the string is UTF-8 encoded and should be re-encoded in the
 specified encoding.
 
-lis = []
+from pypy.rlib.rstring import StringBuilder
+builder = StringBuilder(len(s))
 ps = 0
 end = len(s)
-while ps  end:
-if s[ps] != '\\':
-# note that the C code has a label here.
-# the logic is the same.
+while 1:
+ps2 = ps
+while ps  end and s[ps] != '\\':
 if recode_encoding and ord(s[ps])  0x80:
 w, ps = decode_utf8(space, s, ps, end, recode_encoding)
-# Append bytes to output buffer.
-lis.append(w)
+builder.append(w)
+ps2 = ps
 else:
-lis.append(s[ps])
 ps += 1
-continue
+if ps  ps2:
+builder.append_slice(s, ps2, ps)
+if ps == end:
+break
+
 ps += 1
 if ps == end:
 raise_app_valueerror(space, 'Trailing \\ in string')
@@ -140,25 +143,25 @@
 if ch == '\n':
 pass
 elif ch == '\\':
-lis.append('\\')
+builder.append('\\')
 elif ch == ':
-lis.append(')
+builder.append(')
 elif ch == '':
-lis.append('')
+builder.append('')
 elif ch == 'b':
-lis.append(\010)
+builder.append(\010)
 elif ch == 'f':
-lis.append('\014') # FF
+builder.append('\014') # FF
 elif ch == 't':
-lis.append('\t')
+builder.append('\t')
 elif ch == 'n':
-lis.append('\n')
+builder.append('\n')
 elif ch == 'r':
-lis.append('\r')
+builder.append('\r')
 elif ch == 'v':
-lis.append('\013') # VT
+builder.append('\013') # VT
 elif ch == 'a':
-lis.append('\007') # BEL, not classic C
+builder.append('\007') # BEL, not classic C
 elif ch in '01234567':
 # Look for up to two more octal digits
 span = ps
@@ -168,13 +171,13 @@
 # emulate a strange wrap-around behavior of CPython:
 # \400 is the same as \000 because 0400 == 256
 num = int(octal, 8)  0xFF
-lis.append(chr(num))
+builder.append(chr(num))
 ps = span
 elif ch == 'x':
 if ps+2 = end and isxdigit(s[ps]) and isxdigit(s[ps + 1]):
 hexa = s[ps : ps + 2]
 num = int(hexa, 16)
-lis.append(chr(num))
+builder.append(chr(num))
 ps += 2
 else:
 raise_app_valueerror(space, 'invalid \\x escape')
@@ -184,13 +187,13 @@
 # this was not an escape, so the backslash
 # has to be added, and we start over in
 # non-escape mode.
-lis.append('\\')
+builder.append('\\')
 ps -= 1
 assert ps = 0
 continue
 # an arbitry number of unescaped UTF-8 bytes may follow.
 
-buf = ''.join(lis)
+buf = builder.build()
 return buf
 
 
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: close branch

2012-02-27 Thread justinpeel
Author: Justin Peel notmuchtot...@gmail.com
Branch: 
Changeset: r52948:034e2cd62f1c
Date: 2012-02-27 20:26 -0700
http://bitbucket.org/pypy/pypy/changeset/034e2cd62f1c/

Log:close branch

___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy faster-str-decode-escape: close this branch

2012-02-27 Thread justinpeel
Author: Justin Peel notmuchtot...@gmail.com
Branch: faster-str-decode-escape
Changeset: r52949:6cd6773cb83a
Date: 2012-02-27 20:28 -0700
http://bitbucket.org/pypy/pypy/changeset/6cd6773cb83a/

Log:close this branch

___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: move import outside of function

2012-02-27 Thread justinpeel
Author: Justin Peel notmuchtot...@gmail.com
Branch: 
Changeset: r52950:1604c8f1d469
Date: 2012-02-27 20:37 -0700
http://bitbucket.org/pypy/pypy/changeset/1604c8f1d469/

Log:move import outside of function

diff --git a/pypy/interpreter/pyparser/parsestring.py 
b/pypy/interpreter/pyparser/parsestring.py
--- a/pypy/interpreter/pyparser/parsestring.py
+++ b/pypy/interpreter/pyparser/parsestring.py
@@ -109,13 +109,14 @@
 result = 0 + result
 return result
 
+from pypy.rlib.rstring import StringBuilder
+
 def PyString_DecodeEscape(space, s, recode_encoding):
 
 Unescape a backslash-escaped string. If recode_encoding is non-zero,
 the string is UTF-8 encoded and should be re-encoded in the
 specified encoding.
 
-from pypy.rlib.rstring import StringBuilder
 builder = StringBuilder(len(s))
 ps = 0
 end = len(s)
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: move import to top...

2012-02-27 Thread justinpeel
Author: Justin Peel notmuchtot...@gmail.com
Branch: 
Changeset: r52951:079551524b28
Date: 2012-02-27 21:09 -0700
http://bitbucket.org/pypy/pypy/changeset/079551524b28/

Log:move import to top...

diff --git a/pypy/interpreter/pyparser/parsestring.py 
b/pypy/interpreter/pyparser/parsestring.py
--- a/pypy/interpreter/pyparser/parsestring.py
+++ b/pypy/interpreter/pyparser/parsestring.py
@@ -1,5 +1,6 @@
 from pypy.interpreter.error import OperationError
 from pypy.interpreter import unicodehelper
+from pypy.rlib.rstring import StringBuilder
 
 def parsestr(space, encoding, s, unicode_literals=False):
 # compiler.transformer.Transformer.decode_literal depends on what 
@@ -109,8 +110,6 @@
 result = 0 + result
 return result
 
-from pypy.rlib.rstring import StringBuilder
-
 def PyString_DecodeEscape(space, s, recode_encoding):
 
 Unescape a backslash-escaped string. If recode_encoding is non-zero,
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy reflex-support: refactoring

2012-02-27 Thread wlav
Author: Wim Lavrijsen wlavrij...@lbl.gov
Branch: reflex-support
Changeset: r52952:23a40fce87d8
Date: 2012-02-27 14:19 -0800
http://bitbucket.org/pypy/pypy/changeset/23a40fce87d8/

Log:refactoring

diff --git a/pypy/module/cppyy/converter.py b/pypy/module/cppyy/converter.py
--- a/pypy/module/cppyy/converter.py
+++ b/pypy/module/cppyy/converter.py
@@ -167,9 +167,8 @@
 def convert_argument(self, space, w_obj, address):
 x = rffi.cast(self.rffiptype, address)
 x[0] = self._unwrap_object(space, w_obj)
-typecode = rffi.cast(rffi.CCHARP,
-capi.direct_ptradd(address, capi.c_function_arg_typeoffset()))
-typecode[0] = self.typecode
+ba = rffi.cast(rffi.CCHARP, address)
+ba[capi.c_function_arg_typeoffset()] = self.typecode
 
 
 class VoidConverter(TypeConverter):
@@ -360,9 +359,8 @@
 x = rffi.cast(rffi.LONGP, address)
 arg = space.str_w(w_obj)
 x[0] = rffi.cast(rffi.LONG, rffi.str2charp(arg))
-typecode = rffi.cast(rffi.CCHARP,
-capi.direct_ptradd(address, capi.c_function_arg_typeoffset()))
-typecode[0] = 'o'
+ba = rffi.cast(rffi.CCHARP, address)
+ba[capi.c_function_arg_typeoffset()] = 'o'
 
 def from_memory(self, space, w_obj, w_type, offset):
 address = self._get_raw_address(space, w_obj, offset)
@@ -379,9 +377,8 @@
 def convert_argument(self, space, w_obj, address):
 x = rffi.cast(rffi.VOIDPP, address)
 x[0] = rffi.cast(rffi.VOIDP, get_rawobject(space, w_obj))
-typecode = rffi.cast(rffi.CCHARP,
-   capi.direct_ptradd(address, capi.c_function_arg_typeoffset()))
-typecode[0] = 'a'
+ba = rffi.cast(rffi.CCHARP, address)
+ba[capi.c_function_arg_typeoffset()] = 'a'
 
 def convert_argument_libffi(self, space, w_obj, argchain):
 argchain.arg(get_rawobject(space, w_obj))
@@ -393,9 +390,8 @@
 def convert_argument(self, space, w_obj, address):
 x = rffi.cast(rffi.VOIDPP, address)
 x[0] = rffi.cast(rffi.VOIDP, get_rawobject(space, w_obj))
-typecode = rffi.cast(rffi.CCHARP,
-capi.direct_ptradd(address, capi.c_function_arg_typeoffset()))
-typecode[0] = 'p'
+ba = rffi.cast(rffi.CCHARP, address)
+ba[capi.c_function_arg_typeoffset()] = 'p'
 
 
 class VoidPtrRefConverter(TypeConverter):
@@ -404,9 +400,8 @@
 def convert_argument(self, space, w_obj, address):
 x = rffi.cast(rffi.VOIDPP, address)
 x[0] = rffi.cast(rffi.VOIDP, get_rawobject(space, w_obj))
-typecode = rffi.cast(rffi.CCHARP,
-capi.direct_ptradd(address, capi.c_function_arg_typeoffset()))
-typecode[0] = 'r'
+ba = rffi.cast(rffi.CCHARP, address)
+ba[capi.c_function_arg_typeoffset()] = 'r'
 
 
 class ShortArrayConverter(ArrayTypeConverterMixin, TypeConverter):
@@ -516,9 +511,8 @@
 x = rffi.cast(rffi.VOIDPP, address)
 x[0] = rffi.cast(rffi.VOIDP, self._unwrap_object(space, w_obj))
 address = rffi.cast(capi.C_OBJECT, address)
-typecode = rffi.cast(rffi.CCHARP,
-capi.direct_ptradd(address, capi.c_function_arg_typeoffset()))
-typecode[0] = 'o'
+ba = rffi.cast(rffi.CCHARP, address)
+ba[capi.c_function_arg_typeoffset()] = 'o'
 
 def convert_argument_libffi(self, space, w_obj, argchain):
 argchain.arg(self._unwrap_object(space, w_obj))
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy reflex-support: probably no need for builtin vectorint with new TApplication enabled ...

2012-02-27 Thread wlav
Author: Wim Lavrijsen wlavrij...@lbl.gov
Branch: reflex-support
Changeset: r52953:ebbf2f8ead62
Date: 2012-02-27 17:32 -0800
http://bitbucket.org/pypy/pypy/changeset/ebbf2f8ead62/

Log:probably no need for builtin vectorint with new TApplication
enabled ...

diff --git a/pypy/module/cppyy/test/stltypes_LinkDef.h 
b/pypy/module/cppyy/test/stltypes_LinkDef.h
--- a/pypy/module/cppyy/test/stltypes_LinkDef.h
+++ b/pypy/module/cppyy/test/stltypes_LinkDef.h
@@ -4,9 +4,9 @@
 #pragma link off all classes;
 #pragma link off all functions;
 
-#pragma link C++ class std::vectorint;
-#pragma link C++ class std::vectorint::iterator;
-#pragma link C++ class std::vectorint::const_iterator;
+//#pragma link C++ class std::vectorint;
+//#pragma link C++ class std::vectorint::iterator;
+//#pragma link C++ class std::vectorint::const_iterator;
 #pragma link C++ class std::vectorjust_a_class;
 #pragma link C++ class std::vectorjust_a_class::iterator;
 #pragma link C++ class std::vectorjust_a_class::const_iterator;
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy reflex-support: refactoring and cleanup (Reflex backend): the idea is to speed up the slow path by handing out the stub functions rather than method indices; it should also help wit

2012-02-27 Thread wlav
Author: Wim Lavrijsen wlavrij...@lbl.gov
Branch: reflex-support
Changeset: r52954:e7c4a93f01f3
Date: 2012-02-27 17:34 -0800
http://bitbucket.org/pypy/pypy/changeset/e7c4a93f01f3/

Log:refactoring and cleanup (Reflex backend): the idea is to speed up
the slow path by handing out the stub functions rather than method
indices; it should also help with stability in the case of
additional methods to a namespace (since the stubs don't move,
whereas the indices could change)

diff --git a/pypy/module/cppyy/capi/__init__.py 
b/pypy/module/cppyy/capi/__init__.py
--- a/pypy/module/cppyy/capi/__init__.py
+++ b/pypy/module/cppyy/capi/__init__.py
@@ -9,11 +9,17 @@
 _C_OPAQUE_PTR = rffi.LONG
 _C_OPAQUE_NULL = lltype.nullptr(rffi.LONGP.TO)# ALT: _C_OPAQUE_PTR.TO
 
-C_TYPEHANDLE = _C_OPAQUE_PTR
-C_NULL_TYPEHANDLE = rffi.cast(C_TYPEHANDLE, _C_OPAQUE_NULL)
+C_SCOPE = _C_OPAQUE_PTR
+C_NULL_SCOPE = rffi.cast(C_SCOPE, _C_OPAQUE_NULL)
+
+C_TYPE = C_SCOPE
+C_NULL_TYPE = C_NULL_SCOPE
+
 C_OBJECT = _C_OPAQUE_PTR
 C_NULL_OBJECT = rffi.cast(C_OBJECT, _C_OPAQUE_NULL)
 
+C_METHOD = _C_OPAQUE_PTR
+
 C_METHPTRGETTER = lltype.FuncType([C_OBJECT], rffi.VOIDP)
 C_METHPTRGETTER_PTR = lltype.Ptr(C_METHPTRGETTER)
 
@@ -26,128 +32,85 @@
 
 c_load_dictionary = backend.c_load_dictionary
 
-c_get_typehandle = rffi.llexternal(
-cppyy_get_typehandle,
-[rffi.CCHARP], C_OBJECT,
+# name to opaque C++ scope representation 
+c_get_scope = rffi.llexternal(
+cppyy_get_scope,
+[rffi.CCHARP], C_SCOPE,
 compilation_info=backend.eci)
-c_get_templatehandle = rffi.llexternal(
-cppyy_get_templatehandle,
-[rffi.CCHARP], C_TYPEHANDLE,
+c_get_template = rffi.llexternal(
+cppyy_get_template,
+[rffi.CCHARP], C_TYPE,
 compilation_info=backend.eci)
 
+# memory management --
 c_allocate = rffi.llexternal(
 cppyy_allocate,
-[C_TYPEHANDLE], C_OBJECT,
+[C_TYPE], C_OBJECT,
 compilation_info=backend.eci)
 c_deallocate = rffi.llexternal(
 cppyy_deallocate,
-[C_TYPEHANDLE, C_OBJECT], lltype.Void,
+[C_TYPE, C_OBJECT], lltype.Void,
 compilation_info=backend.eci)
 c_destruct = rffi.llexternal(
 cppyy_destruct,
-[C_TYPEHANDLE, C_OBJECT], lltype.Void,
+[C_TYPE, C_OBJECT], lltype.Void,
 compilation_info=backend.eci)
 
-c_is_namespace = rffi.llexternal(
-cppyy_is_namespace,
-[C_TYPEHANDLE], rffi.INT,
-compilation_info=backend.eci)
-c_final_name = rffi.llexternal(
-cppyy_final_name,
-[C_TYPEHANDLE], rffi.CCHARP,
-compilation_info=backend.eci)
-
-c_has_complex_hierarchy = rffi.llexternal(
-cppyy_has_complex_hierarchy,
-[C_TYPEHANDLE], rffi.INT,
-compilation_info=backend.eci)
-c_num_bases = rffi.llexternal(
-cppyy_num_bases,
-[C_TYPEHANDLE], rffi.INT,
-compilation_info=backend.eci)
-c_base_name = rffi.llexternal(
-cppyy_base_name,
-[C_TYPEHANDLE, rffi.INT], rffi.CCHARP,
-compilation_info=backend.eci)
-
-_c_is_subtype = rffi.llexternal(
-cppyy_is_subtype,
-[C_TYPEHANDLE, C_TYPEHANDLE], rffi.INT,
-compilation_info=backend.eci,
-elidable_function=True)
-
-@jit.elidable_promote()
-def c_is_subtype(td, tb):
-if td == tb:
-return 1
-return _c_is_subtype(td, tb)
-
-_c_base_offset = rffi.llexternal(
-cppyy_base_offset,
-[C_TYPEHANDLE, C_TYPEHANDLE, C_OBJECT], rffi.SIZE_T,
-compilation_info=backend.eci,
-elidable_function=True)
-
-@jit.elidable_promote()
-def c_base_offset(td, tb, address):
-if td == tb:
-return 0
-return _c_base_offset(td, tb, address)
-
+# method/function dispatching 
 c_call_v = rffi.llexternal(
 cppyy_call_v,
-[C_TYPEHANDLE, rffi.INT, C_OBJECT, rffi.INT, rffi.VOIDP], lltype.Void,
-compilation_info=backend.eci)
-c_call_o = rffi.llexternal(
-cppyy_call_o,
-[C_TYPEHANDLE, rffi.INT, C_OBJECT, rffi.INT, rffi.VOIDP, C_TYPEHANDLE], 
rffi.LONG,
+[C_METHOD, C_OBJECT, rffi.INT, rffi.VOIDP], lltype.Void,
 compilation_info=backend.eci)
 c_call_b = rffi.llexternal(
 cppyy_call_b,
-[C_TYPEHANDLE, rffi.INT, C_OBJECT, rffi.INT, rffi.VOIDP], rffi.INT,
+[C_METHOD, C_OBJECT, rffi.INT, rffi.VOIDP], rffi.INT,
 compilation_info=backend.eci)
 c_call_c = rffi.llexternal(
 cppyy_call_c,
-[C_TYPEHANDLE, rffi.INT, C_OBJECT, rffi.INT, rffi.VOIDP], rffi.CHAR,
+[C_METHOD, C_OBJECT, rffi.INT, rffi.VOIDP], rffi.CHAR,
 compilation_info=backend.eci)
 c_call_h = rffi.llexternal(
 cppyy_call_h,
-[C_TYPEHANDLE, rffi.INT, C_OBJECT, rffi.INT, rffi.VOIDP], rffi.SHORT,
+[C_METHOD, C_OBJECT, rffi.INT, rffi.VOIDP], rffi.SHORT,
 compilation_info=backend.eci)
 c_call_i = rffi.llexternal(
 cppyy_call_i,
-[C_TYPEHANDLE, rffi.INT, C_OBJECT, rffi.INT, rffi.VOIDP], rffi.INT,
+[C_METHOD, C_OBJECT, rffi.INT, rffi.VOIDP], rffi.INT,
 

[pypy-commit] pypy reflex-support: like for Reflex backend, now refactoring to get access to stubs for the CINT backend

2012-02-27 Thread wlav
Author: Wim Lavrijsen wlavrij...@lbl.gov
Branch: reflex-support
Changeset: r52955:21d4b7fc4514
Date: 2012-02-27 18:13 -0800
http://bitbucket.org/pypy/pypy/changeset/21d4b7fc4514/

Log:like for Reflex backend, now refactoring to get access to stubs for
the CINT backend

diff --git a/pypy/module/cppyy/src/cintcwrapper.cxx 
b/pypy/module/cppyy/src/cintcwrapper.cxx
--- a/pypy/module/cppyy/src/cintcwrapper.cxx
+++ b/pypy/module/cppyy/src/cintcwrapper.cxx
@@ -118,11 +118,11 @@
 return cppstring_to_cstring(true_name);
 }
 
-static inline TClassRef type_from_handle(cppyy_typehandle_t handle) {
+static inline TClassRef type_from_handle(cppyy_type_t handle) {
 return g_classrefs[(ClassRefs_t::size_type)handle];
 }
 
-static inline TFunction* type_get_method(cppyy_typehandle_t handle, int 
method_index) {
+static inline TFunction* type_get_method(cppyy_type_t handle, int 
method_index) {
 TClassRef cr = type_from_handle(handle);
 if (cr.GetClass())
 return (TFunction*)cr-GetListOfMethods()-At(method_index);
@@ -148,168 +148,133 @@
 }
 
 
-/* name to handle - */
-cppyy_typehandle_t cppyy_get_typehandle(const char* class_name) {
-ClassRefIndices_t::iterator icr = g_classref_indices.find(class_name);
+/* name to opaque C++ scope representation  */
+cppyy_scope_t cppyy_get_scope(const char* scope_name) {
+ClassRefIndices_t::iterator icr = g_classref_indices.find(scope_name);
 if (icr != g_classref_indices.end())
-return (cppyy_typehandle_t)icr-second;
+return (cppyy_type_t)icr-second;
 
 // use TClass directly, to enable auto-loading
-TClassRef cr(TClass::GetClass(class_name, kTRUE, kTRUE));
+TClassRef cr(TClass::GetClass(scope_name, kTRUE, kTRUE));
 if (!cr.GetClass())
-return (cppyy_typehandle_t)NULL;
+return (cppyy_type_t)NULL;
 
 if (!cr-GetClassInfo())
-return (cppyy_typehandle_t)NULL;
+return (cppyy_type_t)NULL;
 
-if (!G__TypeInfo(class_name).IsValid())
-return (cppyy_typehandle_t)NULL;
+if (!G__TypeInfo(scope_name).IsValid())
+return (cppyy_type_t)NULL;
 
 ClassRefs_t::size_type sz = g_classrefs.size();
-g_classref_indices[class_name] = sz;
-g_classrefs.push_back(TClassRef(class_name));
-return (cppyy_typehandle_t)sz;
+g_classref_indices[scope_name] = sz;
+g_classrefs.push_back(TClassRef(scope_name));
+return (cppyy_scope_t)sz;
 }
 
-cppyy_typehandle_t cppyy_get_templatehandle(const char* template_name) {
+cppyy_type_t cppyy_get_template(const char* template_name) {
 ClassRefIndices_t::iterator icr = g_classref_indices.find(template_name);
 if (icr != g_classref_indices.end())
-return (cppyy_typehandle_t)icr-second;
+return (cppyy_type_t)icr-second;
 
 if (!G__defined_templateclass((char*)template_name))
-return (cppyy_typehandle_t)NULL;
+return (cppyy_type_t)NULL;
 
 // the following yields a dummy TClassRef, but its name can be queried
 ClassRefs_t::size_type sz = g_classrefs.size();
 g_classref_indices[template_name] = sz;
 g_classrefs.push_back(TClassRef(template_name));
-return (cppyy_typehandle_t)sz;
+return (cppyy_type_t)sz;
 }
 
 
 /* memory management -- */
-void* cppyy_allocate(cppyy_typehandle_t handle) {
+cppyy_object_t cppyy_allocate(cppyy_type_t handle) {
 TClassRef cr = type_from_handle(handle);
-return malloc(cr-Size());
+return (cppyy_object_t)malloc(cr-Size());
 }
 
-void cppyy_deallocate(cppyy_typehandle_t /*handle*/, cppyy_object_t instance) {
+void cppyy_deallocate(cppyy_type_t /*handle*/, cppyy_object_t instance) {
 free((void*)instance);
 }
 
-void cppyy_destruct(cppyy_typehandle_t handle, cppyy_object_t self) {
+void cppyy_destruct(cppyy_type_t handle, cppyy_object_t self) {
 TClassRef cr = type_from_handle(handle);
 cr-Destructor((void*)self, true);
 }
 
 
 /* method/function dispatching  */
-static inline G__value cppyy_call_T(cppyy_typehandle_t handle,
-int method_index, cppyy_object_t self, int numargs, void* args) {
+static inline G__value cppyy_call_T(cppyy_method_t method,
+cppyy_object_t self, int nargs, void* args) {
 
-   if ((long)handle != GLOBAL_HANDLE) {
-TClassRef cr = type_from_handle(handle);
-assert(method_index  cr-GetListOfMethods()-GetSize());
-TMethod* m = (TMethod*)cr-GetListOfMethods()-At(method_index);
+G__InterfaceMethod meth = (G__InterfaceMethod)method;
+G__param* libp = (G__param*)((char*)args - offsetof(G__param, para));
+assert(libp-paran == nargs);
+fixup_args(libp);
 
-G__InterfaceMethod meth = (G__InterfaceMethod)m-InterfaceMethod();
-G__param* libp = (G__param*)((char*)args - offsetof(G__param, para));
-assert(libp-paran == numargs);
-  

[pypy-commit] pypy reflex-support: fix for name matching if a class lives in a namespace

2012-02-27 Thread wlav
Author: Wim Lavrijsen wlavrij...@lbl.gov
Branch: reflex-support
Changeset: r52956:1174528adf73
Date: 2012-02-27 21:52 -0800
http://bitbucket.org/pypy/pypy/changeset/1174528adf73/

Log:fix for name matching if a class lives in a namespace

diff --git a/pypy/module/cppyy/src/cintcwrapper.cxx 
b/pypy/module/cppyy/src/cintcwrapper.cxx
--- a/pypy/module/cppyy/src/cintcwrapper.cxx
+++ b/pypy/module/cppyy/src/cintcwrapper.cxx
@@ -206,7 +206,7 @@
 /* method/function dispatching  */
 static inline G__value cppyy_call_T(cppyy_method_t method,
 cppyy_object_t self, int nargs, void* args) {
-
+
 G__InterfaceMethod meth = (G__InterfaceMethod)method;
 G__param* libp = (G__param*)((char*)args - offsetof(G__param, para));
 assert(libp-paran == nargs);
@@ -466,7 +466,7 @@
 int cppyy_is_constructor(cppyy_type_t handle, int method_index) {
 TClassRef cr = type_from_handle(handle);
 TMethod* m = (TMethod*)cr-GetListOfMethods()-At(method_index);
-return strcmp(m-GetName(), cr-GetName()) == 0;
+return strcmp(m-GetName(), ((G__ClassInfo*)cr-GetClassInfo())-Name()) 
== 0;
 }
 
 int cppyy_is_staticmethod(cppyy_type_t handle, int method_index) {
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Failing test where i73 is assigned twice in the optimized trace.

2012-02-27 Thread hakanardo
Author: Hakan Ardo ha...@debian.org
Branch: 
Changeset: r52957:9a45d7852b5b
Date: 2012-02-28 08:15 +0100
http://bitbucket.org/pypy/pypy/changeset/9a45d7852b5b/

Log:Failing test where i73 is assigned twice in the optimized trace.

diff --git a/pypy/jit/metainterp/optimizeopt/test/test_multilabel.py 
b/pypy/jit/metainterp/optimizeopt/test/test_multilabel.py
--- a/pypy/jit/metainterp/optimizeopt/test/test_multilabel.py
+++ b/pypy/jit/metainterp/optimizeopt/test/test_multilabel.py
@@ -398,6 +398,50 @@
 with raises(InvalidLoop):
 self.optimize_loop(ops, ops)
 
+def test_maybe_issue1045_related(self):
+ops = 
+[p8]
+p54 = getfield_gc(p8, descr=valuedescr)
+mark_opaque_ptr(p54)
+i55 = getfield_gc(p54, descr=nextdescr)
+p57 = new_with_vtable(ConstClass(node_vtable))
+setfield_gc(p57, i55, descr=otherdescr)
+p69 = new_with_vtable(ConstClass(node_vtable))
+setfield_gc(p69, i55, descr=otherdescr)
+i71 = int_eq(i55, -9223372036854775808)
+guard_false(i71) []
+i73 = int_mod(i55, 2)
+i75 = int_rshift(i73, 63)
+i76 = int_and(2, i75)
+i77 = int_add(i73, i76)
+p79 = new_with_vtable(ConstClass(node_vtable))
+setfield_gc(p79, i77, descr=otherdescr)
+i81 = int_eq(i77, 1)
+guard_false(i81) []
+i0 = int_ge(i55, 1)
+guard_true(i0) []
+label(p57)
+jump(p57)
+
+expected = 
+[p8]
+p54 = getfield_gc(p8, descr=valuedescr)
+i55 = getfield_gc(p54, descr=nextdescr)
+i71 = int_eq(i55, -9223372036854775808)
+guard_false(i71) []
+i73 = int_mod(i55, 2)
+i75 = int_rshift(i73, 63)
+i76 = int_and(2, i75)
+i77 = int_add(i73, i76)
+i81 = int_eq(i77, 1)
+guard_false(i81) []
+i0 = int_ge(i55, 1)
+guard_true(i0) []
+label(i55)
+jump(i55)
+
+self.optimize_loop(ops, expected)
+
 class OptRenameStrlen(Optimization):
 def propagate_forward(self, op):
 dispatch_opt(self, op)
@@ -457,7 +501,6 @@
 jump(p1, i11)
 
 self.optimize_loop(ops, expected)
-
 
 
 class TestLLtype(OptimizeoptTestMultiLabel, LLtypeMixin):
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: hg merge

2012-02-27 Thread hakanardo
Author: Hakan Ardo ha...@debian.org
Branch: 
Changeset: r52958:402fe7ba5442
Date: 2012-02-28 08:53 +0100
http://bitbucket.org/pypy/pypy/changeset/402fe7ba5442/

Log:hg merge

diff --git a/lib-python/modified-2.7/ctypes/test/test_arrays.py 
b/lib-python/modified-2.7/ctypes/test/test_arrays.py
--- a/lib-python/modified-2.7/ctypes/test/test_arrays.py
+++ b/lib-python/modified-2.7/ctypes/test/test_arrays.py
@@ -1,12 +1,23 @@
 import unittest
 from ctypes import *
+from test.test_support import impl_detail
 
 formats = bBhHiIlLqQfd
 
+# c_longdouble commented out for PyPy, look at the commend in test_longdouble
 formats = c_byte, c_ubyte, c_short, c_ushort, c_int, c_uint, \
-  c_long, c_ulonglong, c_float, c_double, c_longdouble
+  c_long, c_ulonglong, c_float, c_double #, c_longdouble
 
 class ArrayTestCase(unittest.TestCase):
+
+@impl_detail('long double not supported by PyPy', pypy=False)
+def test_longdouble(self):
+
+This test is empty. It's just here to remind that we commented out
+c_longdouble in formats. If pypy will ever supports c_longdouble, we
+should kill this test and uncomment c_longdouble inside formats.
+
+
 def test_simple(self):
 # create classes holding simple numeric types, and check
 # various properties.
diff --git a/pypy/interpreter/pyparser/parsestring.py 
b/pypy/interpreter/pyparser/parsestring.py
--- a/pypy/interpreter/pyparser/parsestring.py
+++ b/pypy/interpreter/pyparser/parsestring.py
@@ -1,5 +1,6 @@
 from pypy.interpreter.error import OperationError
 from pypy.interpreter import unicodehelper
+from pypy.rlib.rstring import StringBuilder
 
 def parsestr(space, encoding, s, unicode_literals=False):
 # compiler.transformer.Transformer.decode_literal depends on what 
@@ -115,21 +116,23 @@
 the string is UTF-8 encoded and should be re-encoded in the
 specified encoding.
 
-lis = []
+builder = StringBuilder(len(s))
 ps = 0
 end = len(s)
-while ps  end:
-if s[ps] != '\\':
-# note that the C code has a label here.
-# the logic is the same.
+while 1:
+ps2 = ps
+while ps  end and s[ps] != '\\':
 if recode_encoding and ord(s[ps])  0x80:
 w, ps = decode_utf8(space, s, ps, end, recode_encoding)
-# Append bytes to output buffer.
-lis.append(w)
+builder.append(w)
+ps2 = ps
 else:
-lis.append(s[ps])
 ps += 1
-continue
+if ps  ps2:
+builder.append_slice(s, ps2, ps)
+if ps == end:
+break
+
 ps += 1
 if ps == end:
 raise_app_valueerror(space, 'Trailing \\ in string')
@@ -140,25 +143,25 @@
 if ch == '\n':
 pass
 elif ch == '\\':
-lis.append('\\')
+builder.append('\\')
 elif ch == ':
-lis.append(')
+builder.append(')
 elif ch == '':
-lis.append('')
+builder.append('')
 elif ch == 'b':
-lis.append(\010)
+builder.append(\010)
 elif ch == 'f':
-lis.append('\014') # FF
+builder.append('\014') # FF
 elif ch == 't':
-lis.append('\t')
+builder.append('\t')
 elif ch == 'n':
-lis.append('\n')
+builder.append('\n')
 elif ch == 'r':
-lis.append('\r')
+builder.append('\r')
 elif ch == 'v':
-lis.append('\013') # VT
+builder.append('\013') # VT
 elif ch == 'a':
-lis.append('\007') # BEL, not classic C
+builder.append('\007') # BEL, not classic C
 elif ch in '01234567':
 # Look for up to two more octal digits
 span = ps
@@ -168,13 +171,13 @@
 # emulate a strange wrap-around behavior of CPython:
 # \400 is the same as \000 because 0400 == 256
 num = int(octal, 8)  0xFF
-lis.append(chr(num))
+builder.append(chr(num))
 ps = span
 elif ch == 'x':
 if ps+2 = end and isxdigit(s[ps]) and isxdigit(s[ps + 1]):
 hexa = s[ps : ps + 2]
 num = int(hexa, 16)
-lis.append(chr(num))
+builder.append(chr(num))
 ps += 2
 else:
 raise_app_valueerror(space, 'invalid \\x escape')
@@ -184,13 +187,13 @@
 # this was not an escape, so the backslash
 # has to be added, and we start over in
 # non-escape mode.
-lis.append('\\')
+builder.append('\\')
 ps -= 1
 assert ps = 0
 continue
 # an arbitry number of unescaped UTF-8 bytes may follow.
 
-buf = ''.join(lis)
+buf =