[pypy-commit] pypy jit-targets: fix test

2011-11-08 Thread hakanardo
Author: Hakan Ardo ha...@debian.org
Branch: jit-targets
Changeset: r48900:01cb9893b566
Date: 2011-11-07 18:28 +0100
http://bitbucket.org/pypy/pypy/changeset/01cb9893b566/

Log:fix test

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
@@ -89,7 +89,8 @@
 assert descr.exported_state is None 
 if not we_are_translated():
 op._descr_wref = weakref.ref(op._descr)
-op._descr = None# clear reference, mostly for tests
+# xxx why do we need to clear op._descr??
+#op._descr = None# clear reference, mostly for tests
 # record this looptoken on the QuasiImmut used in the code
 if loop.quasi_immutable_deps is not None:
 for qmut in loop.quasi_immutable_deps:
diff --git a/pypy/jit/metainterp/test/test_ajit.py 
b/pypy/jit/metainterp/test/test_ajit.py
--- a/pypy/jit/metainterp/test/test_ajit.py
+++ b/pypy/jit/metainterp/test/test_ajit.py
@@ -1760,7 +1760,7 @@
 array=array)
 res = res.binop(x)
 res.val += array[idx] + array[1]
-if y  7:
+if y  10:
 idx = 2
 y -= 1
 return res
@@ -1772,10 +1772,10 @@
 assert a1.val == a2.val
 assert b1.val == b2.val
 return a1.val + b1.val
-res = self.meta_interp(g, [6, 14])
-assert res == g(6, 14)
+res = self.meta_interp(g, [6, 20])
+assert res == g(6, 20)
 self.check_loop_count(9)
-self.check_resops(getarrayitem_gc=8)
+self.check_resops(getarrayitem_gc=10)
 
 def test_multiple_specialied_versions_bridge(self):
 myjitdriver = JitDriver(greens = [], reds = ['y', 'x', 'z', 'res'])
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy jit-targets: abort unsupported case

2011-11-08 Thread hakanardo
Author: Hakan Ardo ha...@debian.org
Branch: jit-targets
Changeset: r48902:0a92fe884bc3
Date: 2011-11-07 19:02 +0100
http://bitbucket.org/pypy/pypy/changeset/0a92fe884bc3/

Log:abort unsupported case

diff --git a/pypy/jit/metainterp/optimizeopt/unroll.py 
b/pypy/jit/metainterp/optimizeopt/unroll.py
--- a/pypy/jit/metainterp/optimizeopt/unroll.py
+++ b/pypy/jit/metainterp/optimizeopt/unroll.py
@@ -527,6 +527,7 @@
 retraced_count = cell_token.retraced_count
 limit = 
self.optimizer.metainterp_sd.warmrunnerdesc.memory_manager.retrace_limit
 if retraced_countlimit:
+debug_print('Retracing (%d/%d)', retraced_count, limit)
 cell_token.retraced_count += 1
 return False
 
diff --git a/pypy/jit/metainterp/pyjitpl.py b/pypy/jit/metainterp/pyjitpl.py
--- a/pypy/jit/metainterp/pyjitpl.py
+++ b/pypy/jit/metainterp/pyjitpl.py
@@ -1959,7 +1959,8 @@
 # Found!  Compile it as a loop.
 # raises in case it works -- which is the common case
 if self.partial_trace:
-assert start == self.retracing_from # FIXME: Giveup
+if  start != self.retracing_from: 
+raise SwitchToBlackhole(ABORT_BAD_LOOP) # For now
 self.compile_loop(original_boxes, live_arg_boxes, start, 
resumedescr)
 # creation of the loop was cancelled!
 self.staticdata.log('cancelled, tracing more...')
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy jit-targets: fix tests

2011-11-08 Thread hakanardo
Author: Hakan Ardo ha...@debian.org
Branch: jit-targets
Changeset: r48904:6ad136c18d39
Date: 2011-11-07 20:15 +0100
http://bitbucket.org/pypy/pypy/changeset/6ad136c18d39/

Log:fix tests

diff --git a/pypy/jit/metainterp/test/test_ajit.py 
b/pypy/jit/metainterp/test/test_ajit.py
--- a/pypy/jit/metainterp/test/test_ajit.py
+++ b/pypy/jit/metainterp/test/test_ajit.py
@@ -3365,7 +3365,7 @@
 res = self.meta_interp(main, [10])
 assert res == main(10)
 self.check_resops({'int_gt': 2, 'strlen': 2, 'guard_true': 2,
-   'int_sub': 2, 'jump': 2, 'call': 2,
+   'int_sub': 2, 'jump': 1, 'call': 2,
'guard_no_exception': 2, 'int_add': 4})
 
 def test_look_inside_iff_const_getarrayitem_gc_pure(self):
@@ -3502,7 +3502,7 @@
 
 res = self.meta_interp(f, [10])
 assert res == 0
-self.check_resops({'jump': 2, 'guard_true': 2, 'int_gt': 2,
+self.check_resops({'jump': 1, 'guard_true': 2, 'int_gt': 2,
'int_sub': 2})
 
 def test_virtual_opaque_ptr(self):
@@ -3522,7 +3522,7 @@
 return n
 res = self.meta_interp(f, [10])
 assert res == 0
-self.check_resops({'jump': 2, 'guard_true': 2, 'int_gt': 2,
+self.check_resops({'jump': 1, 'guard_true': 2, 'int_gt': 2,
'int_sub': 2})
 
 
@@ -3545,7 +3545,7 @@
 res = self.meta_interp(f, [10])
 assert res == 0
 self.check_resops({'int_gt': 2, 'getfield_gc': 1, 'int_eq': 1,
-   'guard_true': 2, 'int_sub': 2, 'jump': 2,
+   'guard_true': 2, 'int_sub': 2, 'jump': 1,
'guard_false': 1})
 
 
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy jit-targets: hg merge jit-refactor-tests

2011-11-08 Thread hakanardo
Author: Hakan Ardo ha...@debian.org
Branch: jit-targets
Changeset: r48906:e008b8114029
Date: 2011-11-08 08:07 +0100
http://bitbucket.org/pypy/pypy/changeset/e008b8114029/

Log:hg merge jit-refactor-tests

diff --git a/pypy/jit/metainterp/test/test_loop.py 
b/pypy/jit/metainterp/test/test_loop.py
--- a/pypy/jit/metainterp/test/test_loop.py
+++ b/pypy/jit/metainterp/test/test_loop.py
@@ -60,7 +60,8 @@
 assert res == f(6, 13)
 self.check_loop_count(1)
 if self.enable_opts:
-self.check_loops(getfield_gc = 0, setfield_gc = 1)
+self.check_resops(setfield_gc=2, getfield_gc=0)
+
 
 def test_loop_with_two_paths(self):
 from pypy.rpython.lltypesystem import lltype
@@ -180,7 +181,10 @@
 assert res == 42
 self.check_loop_count(1)
 # the 'int_eq' and following 'guard' should be constant-folded
-self.check_loops(int_eq=0, guard_true=1, guard_false=0)
+if 'unroll' in self.enable_opts:
+self.check_resops(int_eq=0, guard_true=2, guard_false=0)
+else:
+self.check_resops(int_eq=0, guard_true=1, guard_false=0)
 if self.basic:
 found = 0
 for op in get_stats().loops[0]._all_operations():
@@ -643,8 +647,12 @@
 res = self.meta_interp(main_interpreter_loop, [1])
 assert res == 102
 self.check_loop_count(1)
-self.check_loops({'int_add' : 3, 'int_gt' : 1,
-  'guard_false' : 1, 'jump' : 1})
+if 'unroll' in self.enable_opts:
+self.check_resops({'int_add' : 6, 'int_gt' : 2,
+   'guard_false' : 2, 'jump' : 2})
+else:
+self.check_resops({'int_add' : 3, 'int_gt' : 1,
+   'guard_false' : 1, 'jump' : 1})
 
 def test_automatic_promotion(self):
 myjitdriver = JitDriver(greens = ['i'],
@@ -686,7 +694,7 @@
 self.check_loop_count(1)
 # These loops do different numbers of ops based on which optimizer we
 # are testing with.
-self.check_loops(self.automatic_promotion_result)
+self.check_resops(self.automatic_promotion_result)
 
 def test_can_enter_jit_outside_main_loop(self):
 myjitdriver = JitDriver(greens=[], reds=['i', 'j', 'a'])
diff --git a/pypy/jit/metainterp/test/test_loop_unroll.py 
b/pypy/jit/metainterp/test/test_loop_unroll.py
--- a/pypy/jit/metainterp/test/test_loop_unroll.py
+++ b/pypy/jit/metainterp/test/test_loop_unroll.py
@@ -8,7 +8,8 @@
 enable_opts = ALL_OPTS_NAMES
 
 automatic_promotion_result = {
-'int_add' : 3, 'int_gt' : 1, 'guard_false' : 1, 'jump' : 1, 
+'int_gt': 2, 'guard_false': 2, 'jump': 2, 'int_add': 6,
+'guard_value': 1
 }
 
 #  test_loop.py
diff --git a/pypy/jit/metainterp/test/test_recursive.py 
b/pypy/jit/metainterp/test/test_recursive.py
--- a/pypy/jit/metainterp/test/test_recursive.py
+++ b/pypy/jit/metainterp/test/test_recursive.py
@@ -143,11 +143,11 @@
 f = self.get_interpreter(codes)
 
 assert self.meta_interp(f, [0, 0, 0], enable_opts='') == 42
-self.check_loops(int_add = 1, call_may_force = 1, call = 0)
+self.check_resops(call_may_force=1, int_add=1, call=0)
 assert self.meta_interp(f, [0, 0, 0], enable_opts='',
 inline=True) == 42
-self.check_loops(int_add = 2, call_may_force = 0, call = 0,
- guard_no_exception = 0)
+self.check_resops(call=0, int_add=2, call_may_force=0,
+  guard_no_exception=0)
 
 def test_inline_jitdriver_check(self):
 code = 021
@@ -160,7 +160,7 @@
 inline=True) == 42
 # the call is fully inlined, because we jump to subcode[1], thus
 # skipping completely the JUMP_BACK in subcode[0]
-self.check_loops(call_may_force = 0, call_assembler = 0, call = 0)
+self.check_resops(call=0, call_may_force=0, call_assembler=0)
 
 def test_guard_failure_in_inlined_function(self):
 def p(pc, code):
@@ -491,10 +491,10 @@
 return loop(100)
 
 res = self.meta_interp(main, [0], enable_opts='', 
trace_limit=TRACE_LIMIT)
-self.check_loops(call_may_force=1, call=0)
+self.check_resops(call=0, call_may_force=1)
 
 res = self.meta_interp(main, [1], enable_opts='', 
trace_limit=TRACE_LIMIT)
-self.check_loops(call_may_force=0, call=0)
+self.check_resops(call=0, call_may_force=0)
 
 def test_trace_from_start(self):
 def p(pc, code):
@@ -576,7 +576,7 @@
 result += f('-c---l-', i+100)
 self.meta_interp(g, [10], backendopt=True)
 self.check_aborted_count(1)
-self.check_loops(call_assembler=1, call=0)
+self.check_resops(call=0, call_assembler=2)
 self.check_tree_loop_count(3)
 
 def test_directly_call_assembler(self):
@@ 

[pypy-commit] pypy jit-targets: better way of checking that the retracecount is not exceeded

2011-11-08 Thread hakanardo
Author: Hakan Ardo ha...@debian.org
Branch: jit-targets
Changeset: r48905:178c618d4dc3
Date: 2011-11-08 08:06 +0100
http://bitbucket.org/pypy/pypy/changeset/178c618d4dc3/

Log:better way of checking that the retracecount is not exceeded

diff --git a/pypy/jit/metainterp/test/test_ajit.py 
b/pypy/jit/metainterp/test/test_ajit.py
--- a/pypy/jit/metainterp/test/test_ajit.py
+++ b/pypy/jit/metainterp/test/test_ajit.py
@@ -2704,7 +2704,8 @@
 res = self.meta_interp(g, [10])
 assert res == g(10)
 # 1 preamble and 6 speciealized versions of each loop
-self.check_tree_loop_count(2*(1 + 6))
+for loop in get_stats().loops:
+assert 
len(loop.operations[0].getdescr().targeting_jitcell_token.target_tokens) = 7
 
 def test_nested_retrace(self):
 
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy jit-targets: recursion support

2011-11-08 Thread hakanardo
Author: Hakan Ardo ha...@debian.org
Branch: jit-targets
Changeset: r48909:df9f538c4ae9
Date: 2011-11-08 10:15 +0100
http://bitbucket.org/pypy/pypy/changeset/df9f538c4ae9/

Log:recursion support

diff --git a/pypy/jit/metainterp/pyjitpl.py b/pypy/jit/metainterp/pyjitpl.py
--- a/pypy/jit/metainterp/pyjitpl.py
+++ b/pypy/jit/metainterp/pyjitpl.py
@@ -2025,7 +2025,8 @@
 num_green_args = self.jitdriver_sd.num_green_args
 greenkey = original_boxes[:num_green_args]
 if not self.partial_trace:
-assert self.get_procedure_token(greenkey) == None # FIXME: 
recursion?
+assert self.get_procedure_token(greenkey) is None or \
+   self.get_procedure_token(greenkey).target_tokens is None
 if self.partial_trace:
 target_token = compile.compile_retrace(self, greenkey, start,

original_boxes[num_green_args:],
@@ -2051,6 +2052,8 @@
 target_jitcell_token = self.get_procedure_token(greenkey)
 if not target_jitcell_token:
 return
+if not target_jitcell_token.target_tokens:
+return
 
 self.history.record(rop.JUMP, live_arg_boxes[num_green_args:], None,
 descr=target_jitcell_token)
diff --git a/pypy/jit/metainterp/test/test_ajit.py 
b/pypy/jit/metainterp/test/test_ajit.py
--- a/pypy/jit/metainterp/test/test_ajit.py
+++ b/pypy/jit/metainterp/test/test_ajit.py
@@ -3667,3 +3667,6 @@
 assert x == -42
 x = self.interp_operations(f, [1000, 1], translationoptions=topt)
 assert x == 999
+
+def test_retracing_bridge_from_interpreter_to_finnish(self):
+assert False # FIXME 
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy jit-targets: jumps are allowed to jump to a TargetToken beloning to another procedure

2011-11-08 Thread hakanardo
Author: Hakan Ardo ha...@debian.org
Branch: jit-targets
Changeset: r48907:0ba1948f37c5
Date: 2011-11-08 08:33 +0100
http://bitbucket.org/pypy/pypy/changeset/0ba1948f37c5/

Log:jumps are allowed to jump to a TargetToken beloning to another
procedure

diff --git a/pypy/jit/metainterp/history.py b/pypy/jit/metainterp/history.py
--- a/pypy/jit/metainterp/history.py
+++ b/pypy/jit/metainterp/history.py
@@ -829,7 +829,7 @@
 self.check_consistency_of(self.inputargs, self.operations)
 for op in self.operations:
 descr = op.getdescr()
-if isinstance(descr, TargetToken):
+if op.getopnum() == rop.LABEL and isinstance(descr, TargetToken):
 assert descr.original_jitcell_token is 
self.original_jitcell_token
 
 @staticmethod
diff --git a/pypy/jit/metainterp/test/test_recursive.py 
b/pypy/jit/metainterp/test/test_recursive.py
--- a/pypy/jit/metainterp/test/test_recursive.py
+++ b/pypy/jit/metainterp/test/test_recursive.py
@@ -530,8 +530,8 @@
 result = 0
 for i in range(m):
 result += f('+-cl--', i)
-g(50)
-self.meta_interp(g, [50], backendopt=True)
+res = self.meta_interp(g, [50], backendopt=True)
+assert res == g(50)
 py.test.skip(tracing from start is by now only longer enabled 
  if a trace gets too big)
 self.check_tree_loop_count(3)
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy jit-refactor-tests: convert test

2011-11-08 Thread hakanardo
Author: Hakan Ardo ha...@debian.org
Branch: jit-refactor-tests
Changeset: r48910:c52328c21f19
Date: 2011-11-08 10:25 +0100
http://bitbucket.org/pypy/pypy/changeset/c52328c21f19/

Log:convert test

diff --git a/pypy/jit/metainterp/test/test_exception.py 
b/pypy/jit/metainterp/test/test_exception.py
--- a/pypy/jit/metainterp/test/test_exception.py
+++ b/pypy/jit/metainterp/test/test_exception.py
@@ -35,10 +35,8 @@
 return n
 res = self.meta_interp(f, [10])
 assert res == 0
-self.check_loops({'jump': 1,
-  'int_gt': 1, 'guard_true': 1,
-  'int_sub': 1})
-
+self.check_resops({'jump': 2, 'guard_true': 2,
+   'int_gt': 2, 'int_sub': 2})
 
 def test_bridge_from_guard_exception(self):
 myjitdriver = JitDriver(greens = [], reds = ['n'])
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy jit-targets: renames

2011-11-08 Thread hakanardo
Author: Hakan Ardo ha...@debian.org
Branch: jit-targets
Changeset: r48908:8de0c01fb64b
Date: 2011-11-08 08:55 +0100
http://bitbucket.org/pypy/pypy/changeset/8de0c01fb64b/

Log:renames

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
@@ -745,7 +745,7 @@
 
 # 'redboxes' is only used to know the types of red arguments.
 inputargs = [box.clonebox() for box in redboxes]
-loop_token = make_loop_token(len(inputargs), jitdriver_sd)
+jitcell_token = make_jitcell_token(jitdriver_sd)
 # 'nb_red_args' might be smaller than len(redboxes),
 # because it doesn't include the virtualizable boxes.
 nb_red_args = jitdriver_sd.num_red_args
@@ -778,7 +778,7 @@
 ]
 operations[1].setfailargs([])
 operations = get_deep_immutable_oplist(operations)
-cpu.compile_loop(inputargs, operations, loop_token, log=False)
+cpu.compile_loop(inputargs, operations, jitcell_token, log=False)
 if memory_manager is not None:# for tests
-memory_manager.keep_loop_alive(loop_token)
-return loop_token
+memory_manager.keep_loop_alive(jitcell_token)
+return jitcell_token
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy jit-targets: hg merge jit-refactor-tests

2011-11-08 Thread hakanardo
Author: Hakan Ardo ha...@debian.org
Branch: jit-targets
Changeset: r48911:893335d40c74
Date: 2011-11-08 10:26 +0100
http://bitbucket.org/pypy/pypy/changeset/893335d40c74/

Log:hg merge jit-refactor-tests

diff --git a/pypy/jit/metainterp/test/test_exception.py 
b/pypy/jit/metainterp/test/test_exception.py
--- a/pypy/jit/metainterp/test/test_exception.py
+++ b/pypy/jit/metainterp/test/test_exception.py
@@ -35,10 +35,8 @@
 return n
 res = self.meta_interp(f, [10])
 assert res == 0
-self.check_loops({'jump': 1,
-  'int_gt': 1, 'guard_true': 1,
-  'int_sub': 1})
-
+self.check_resops({'jump': 2, 'guard_true': 2,
+   'int_gt': 2, 'int_sub': 2})
 
 def test_bridge_from_guard_exception(self):
 myjitdriver = JitDriver(greens = [], reds = ['n'])
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy ppc-jit-backend: Re-adding David's changes, which I killed on merge :(

2011-11-08 Thread hager
Author: hager sven.ha...@uni-duesseldorf.de
Branch: ppc-jit-backend
Changeset: r48912:9b76414ee2fe
Date: 2011-11-08 10:34 +0100
http://bitbucket.org/pypy/pypy/changeset/9b76414ee2fe/

Log:Re-adding David's changes, which I killed on merge :(

diff --git a/pypy/jit/backend/ppc/ppcgen/ppc_assembler.py 
b/pypy/jit/backend/ppc/ppcgen/ppc_assembler.py
--- a/pypy/jit/backend/ppc/ppcgen/ppc_assembler.py
+++ b/pypy/jit/backend/ppc/ppcgen/ppc_assembler.py
@@ -122,7 +122,6 @@
 clt.asmmemmgr = []
 return clt.asmmemmgr_blocks
 
-# XXX adjust for 64 bit
 def _make_prologue(self, target_pos, frame_depth):
 if IS_PPC_32:
 # save it in previous frame (Backchain)
@@ -288,7 +287,6 @@
 return mc.materialize(self.cpu.asmmemmgr, [],
self.cpu.gc_ll_descr.gcrootmap)
 
-# XXX 64 bit adjustment needed
 def _gen_exit_path(self):
 mc = PPCBuilder() 
 #
@@ -334,7 +332,6 @@
 
 # Save all registers which are managed by the register
 # allocator on top of the stack before decoding.
-# XXX adjust for 64 bit
 def _save_managed_regs(self, mc):
 for i in range(len(r.MANAGED_REGS) - 1, -1, -1):
 reg = r.MANAGED_REGS[i]
@@ -553,7 +550,10 @@
 
 # store addr in force index field
 self.mc.load_imm(r.r0, memaddr)
-self.mc.stw(r.r0.value, r.SPP.value, 0)
+if IS_PPC_32:
+self.mc.stw(r.r0.value, r.SPP.value, 0)
+else:
+self.mc.std(r.r0.value, r.SPP.value, 0)
 
 if save_exc:
 path = self._leave_jitted_hook_save_exc
@@ -593,7 +593,6 @@
 clt.asmmemmgr_blocks = []
 return clt.asmmemmgr_blocks
 
-# XXX fix for 64 bit
 def regalloc_mov(self, prev_loc, loc):
 if prev_loc.is_imm():
 value = prev_loc.getint()
@@ -605,7 +604,10 @@
 elif loc.is_stack():
 offset = loc.as_key() * WORD - WORD
 self.mc.load_imm(r.r0.value, value)
-self.mc.stw(r.r0.value, r.SPP.value, offset)
+if IS_PPC_32:
+self.mc.stw(r.r0.value, r.SPP.value, offset)
+else:
+self.mc.std(r.r0.value, r.SPP.value, offset)
 return
 assert 0, not supported location
 elif prev_loc.is_stack():
@@ -613,13 +615,20 @@
 # move from memory to register
 if loc.is_reg():
 reg = loc.as_key()
-self.mc.lwz(reg, r.SPP.value, offset)
+if IS_PPC_32:
+self.mc.lwz(reg, r.SPP.value, offset)
+else:
+self.mc.ld(reg, r.SPP.value, offset)
 return
 # move in memory
 elif loc.is_stack():
 target_offset = loc.as_key() * WORD - WORD
-self.mc.lwz(r.r0.value, r.SPP.value, offset)
-self.mc.stw(r.r0.value, r.SPP.value, target_offset)
+if IS_PPC_32:
+self.mc.lwz(r.r0.value, r.SPP.value, offset)
+self.mc.stw(r.r0.value, r.SPP.value, target_offset)
+else:
+self.mc.ld(r.r0.value, r.SPP.value, offset)
+self.mc.std(r.r0.value, r.SPP.value, target_offset)
 return
 assert 0, not supported location
 elif prev_loc.is_reg():
@@ -632,31 +641,36 @@
 # move to memory
 elif loc.is_stack():
 offset = loc.as_key() * WORD - WORD
-self.mc.stw(reg, r.SPP.value, offset)
+if IS_PPC_32:
+self.mc.stw(reg, r.SPP.value, offset)
+else:
+self.mc.std(reg, r.SPP.value, offset)
 return
 assert 0, not supported location
 assert 0, not supported location
 
 def _ensure_result_bit_extension(self, resloc, size, signed):
-if size == 4:
-return
 if size == 1:
 if not signed: #unsigned char
-self.mc.load_imm(r.r0, 0xFF)
-self.mc.and_(resloc.value, resloc.value, r.r0.value)
+if IS_PPC32:
+self.mc.rlwinm(resloc.value, resloc.value, 0, 24, 31)
+else:
+self.mc.rldicl(resloc.value, resloc.value, 0, 56)
 else:
-self.mc.load_imm(r.r0, 24)
-self.mc.slw(resloc.value, resloc.value, r.r0.value)
-self.mc.sraw(resloc.value, resloc.value, r.r0.value)
+self.mc.extsb(resloc.value, resloc.value)
 elif size == 2:
 if not signed:
-self.mc.load_imm(r.r0, 16)
-self.mc.slw(resloc.value, resloc.value, r.r0.value)
-self.mc.srw(resloc.value, resloc.value, r.r0.value)
+if IS_PPC_32:
+

[pypy-commit] pypy default: fix test_urllib2_localnet - don't be too eager on closing the response, closing

2011-11-08 Thread fijal
Author: Maciej Fijalkowski fij...@gmail.com
Branch: 
Changeset: r48913:9827978a2b97
Date: 2011-10-17 11:01 +0200
http://bitbucket.org/pypy/pypy/changeset/9827978a2b97/

Log:fix test_urllib2_localnet - don't be too eager on closing the
response, closing it when we have a socket error seems to be enough
to avoid the leak (and yet you pass tests).

diff --git a/lib-python/modified-2.7/urllib2.py 
b/lib-python/modified-2.7/urllib2.py
--- a/lib-python/modified-2.7/urllib2.py
+++ b/lib-python/modified-2.7/urllib2.py
@@ -395,11 +395,7 @@
 meth_name = protocol+_response
 for processor in self.process_response.get(protocol, []):
 meth = getattr(processor, meth_name)
-try:
-response = meth(req, response)
-except:
-response.close()
-raise
+response = meth(req, response)
 
 return response
 
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy separate-applevel-numpy: merge default

2011-11-08 Thread fijal
Author: Maciej Fijalkowski fij...@gmail.com
Branch: separate-applevel-numpy
Changeset: r48914:c9cb4eb54185
Date: 2011-10-17 17:58 +0200
http://bitbucket.org/pypy/pypy/changeset/c9cb4eb54185/

Log:merge default

diff --git a/pypy/jit/metainterp/graphpage.py b/pypy/jit/metainterp/graphpage.py
--- a/pypy/jit/metainterp/graphpage.py
+++ b/pypy/jit/metainterp/graphpage.py
@@ -12,8 +12,8 @@
 def get_display_text(self):
 return None
 
-def display_loops(loops, errmsg=None, highlight_loops=()):
-graphs = [(loop, loop in highlight_loops) for loop in loops]
+def display_loops(loops, errmsg=None, highlight_loops={}):
+graphs = [(loop, highlight_loops.get(loop, 0)) for loop in loops]
 for graph, highlight in graphs:
 for op in graph.get_operations():
 if is_interesting_guard(op):
@@ -65,8 +65,7 @@
 def add_graph(self, graph, highlight=False):
 graphindex = len(self.graphs)
 self.graphs.append(graph)
-if highlight:
-self.highlight_graphs[graph] = True
+self.highlight_graphs[graph] = highlight
 for i, op in enumerate(graph.get_operations()):
 self.all_operations[op] = graphindex, i
 
@@ -126,10 +125,13 @@
 self.dotgen.emit('subgraph cluster%d {' % graphindex)
 label = graph.get_display_text()
 if label is not None:
-if self.highlight_graphs.get(graph):
-fillcolor = '#f084c2'
+colorindex = self.highlight_graphs.get(graph, 0)
+if colorindex == 1:
+fillcolor = '#f084c2'# highlighted graph
+elif colorindex == 2:
+fillcolor = '#808080'# invalidated graph
 else:
-fillcolor = '#84f0c2'
+fillcolor = '#84f0c2'# normal color
 self.dotgen.emit_node(graphname, shape=octagon,
   label=label, fillcolor=fillcolor)
 self.pendingedges.append((graphname,
diff --git a/pypy/jit/metainterp/history.py b/pypy/jit/metainterp/history.py
--- a/pypy/jit/metainterp/history.py
+++ b/pypy/jit/metainterp/history.py
@@ -732,6 +732,7 @@
 failed_states = None
 retraced_count = 0
 terminating = False # see TerminatingLoopToken in compile.py
+invalidated = False
 outermost_jitdriver_sd = None
 # and more data specified by the backend when the loop is compiled
 number = -1
@@ -934,6 +935,7 @@
 self.loops = []
 self.locations = []
 self.aborted_keys = []
+self.invalidated_token_numbers = set()
 
 def set_history(self, history):
 self.operations = history.operations
@@ -1012,7 +1014,12 @@
 if loop in loops:
 loops.remove(loop)
 loops.append(loop)
-display_loops(loops, errmsg, extraloops)
+highlight_loops = dict.fromkeys(extraloops, 1)
+for loop in loops:
+if hasattr(loop, '_looptoken_number') and (
+loop._looptoken_number in self.invalidated_token_numbers):
+highlight_loops.setdefault(loop, 2)
+display_loops(loops, errmsg, highlight_loops)
 
 # 
 
diff --git a/pypy/jit/metainterp/memmgr.py b/pypy/jit/metainterp/memmgr.py
--- a/pypy/jit/metainterp/memmgr.py
+++ b/pypy/jit/metainterp/memmgr.py
@@ -68,7 +68,8 @@
 debug_print(Loop tokens before:, oldtotal)
 max_generation = self.current_generation - (self.max_age-1)
 for looptoken in self.alive_loops.keys():
-if 0 = looptoken.generation  max_generation:
+if (0 = looptoken.generation  max_generation or
+looptoken.invalidated):
 del self.alive_loops[looptoken]
 newtotal = len(self.alive_loops)
 debug_print(Loop tokens freed: , oldtotal - newtotal)
diff --git a/pypy/jit/metainterp/quasiimmut.py 
b/pypy/jit/metainterp/quasiimmut.py
--- a/pypy/jit/metainterp/quasiimmut.py
+++ b/pypy/jit/metainterp/quasiimmut.py
@@ -2,6 +2,7 @@
 from pypy.rpython.lltypesystem import lltype, rclass
 from pypy.rpython.annlowlevel import cast_base_ptr_to_instance
 from pypy.jit.metainterp.history import AbstractDescr
+from pypy.rlib.objectmodel import we_are_translated
 
 
 def get_mutate_field_name(fieldname):
@@ -50,13 +51,13 @@
 
 class QuasiImmut(object):
 llopaque = True
+compress_limit = 30
 
 def __init__(self, cpu):
 self.cpu = cpu
 # list of weakrefs to the LoopTokens that must be invalidated if
 # this value ever changes
 self.looptokens_wrefs = []
-self.compress_limit = 30
 
 def hide(self):
 qmut_ptr = self.cpu.ts.cast_instance_to_base_ref(self)
@@ -73,8 +74,12 @@
 self.looptokens_wrefs.append(wref_looptoken)
 
 def compress_looptokens_list(self):
-self.looptokens_wrefs = [wref for wref in self.looptokens_wrefs
- 

[pypy-commit] pypy default: write a test that _get_interplevel_cls still works if we have multiple string

2011-11-08 Thread fijal
Author: Maciej Fijalkowski fij...@gmail.com
Branch: 
Changeset: r48915:9d9d4b7af85f
Date: 2011-11-08 11:53 +0100
http://bitbucket.org/pypy/pypy/changeset/9d9d4b7af85f/

Log:write a test that _get_interplevel_cls still works if we have
multiple string implementations. just to avoid confusion I suppose

diff --git a/pypy/objspace/std/test/test_stdobjspace.py 
b/pypy/objspace/std/test/test_stdobjspace.py
--- a/pypy/objspace/std/test/test_stdobjspace.py
+++ b/pypy/objspace/std/test/test_stdobjspace.py
@@ -1,5 +1,6 @@
 from pypy.interpreter.error import OperationError
 from pypy.interpreter.gateway import app2interp
+from pypy.conftest import gettestobjspace
 
 class TestW_StdObjSpace:
 
@@ -60,3 +61,10 @@
 typedef = None
 
 assert space.isinstance_w(X(), space.w_str)
+
+def test_withstrbuf_fastpath_isinstance(self):
+from pypy.objspace.std.stringobject import W_StringObject
+
+space = gettestobjspace(withstrbuf=True) 
+assert space._get_interplevel_cls(space.w_str) is W_StringObject
+
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: merge default

2011-11-08 Thread fijal
Author: Maciej Fijalkowski fij...@gmail.com
Branch: 
Changeset: r48916:cc101bad6f60
Date: 2011-11-08 12:08 +0100
http://bitbucket.org/pypy/pypy/changeset/cc101bad6f60/

Log:merge default

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


[pypy-commit] pypy default: Add a passing test that rgc.ll_arraycopy cannot raise.

2011-11-08 Thread arigo
Author: Armin Rigo ar...@tunes.org
Branch: 
Changeset: r48918:0f2d4f02b0e3
Date: 2011-11-08 12:28 +0100
http://bitbucket.org/pypy/pypy/changeset/0f2d4f02b0e3/

Log:Add a passing test that rgc.ll_arraycopy cannot raise.

diff --git a/pypy/translator/backendopt/test/test_canraise.py 
b/pypy/translator/backendopt/test/test_canraise.py
--- a/pypy/translator/backendopt/test/test_canraise.py
+++ b/pypy/translator/backendopt/test/test_canraise.py
@@ -201,6 +201,16 @@
 result = ra.can_raise(ggraph.startblock.operations[0])
 assert result
 
+def test_ll_arraycopy(self):
+from pypy.rpython.lltypesystem import rffi
+from pypy.rlib.rgc import ll_arraycopy
+def f(a, b, c, d, e):
+ll_arraycopy(a, b, c, d, e)
+t, ra = self.translate(f, [rffi.CCHARP, rffi.CCHARP, int, int, int])
+fgraph = graphof(t, f)
+result = ra.can_raise(fgraph.startblock.operations[0])
+assert not result
+
 
 class TestOOType(OORtypeMixin, BaseTestCanRaise):
 def test_can_raise_recursive(self):
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Move the import globally.

2011-11-08 Thread arigo
Author: Armin Rigo ar...@tunes.org
Branch: 
Changeset: r48917:daf1ca6435fb
Date: 2011-11-08 12:24 +0100
http://bitbucket.org/pypy/pypy/changeset/daf1ca6435fb/

Log:Move the import globally.

diff --git a/pypy/jit/codewriter/test/test_flatten.py 
b/pypy/jit/codewriter/test/test_flatten.py
--- a/pypy/jit/codewriter/test/test_flatten.py
+++ b/pypy/jit/codewriter/test/test_flatten.py
@@ -5,7 +5,7 @@
 from pypy.jit.codewriter.format import assert_format
 from pypy.jit.codewriter import longlong
 from pypy.jit.metainterp.history import AbstractDescr
-from pypy.rpython.lltypesystem import lltype, rclass, rstr
+from pypy.rpython.lltypesystem import lltype, rclass, rstr, rffi
 from pypy.objspace.flow.model import SpaceOperation, Variable, Constant
 from pypy.translator.unsimplify import varoftype
 from pypy.rlib.rarithmetic import ovfcheck, r_uint, r_longlong, r_ulonglong
@@ -743,7 +743,6 @@
 , transform=True)
 
 def test_force_cast(self):
-from pypy.rpython.lltypesystem import rffi
 # NB: we don't need to test for INT here, the logic in jtransform is
 # general enough so that if we have the below cases it should
 # generalize also to INT
@@ -849,7 +848,6 @@
transform=True)
 
 def test_force_cast_pointer(self):
-from pypy.rpython.lltypesystem import rffi
 def h(p):
 return rffi.cast(rffi.VOIDP, p)
 self.encoding_test(h, [lltype.nullptr(rffi.CCHARP.TO)], 
@@ -857,7 +855,6 @@
 , transform=True)
 
 def test_force_cast_floats(self):
-from pypy.rpython.lltypesystem import rffi
 # Caststs to lltype.Float
 def f(n):
 return rffi.cast(lltype.Float, n)
@@ -964,7 +961,6 @@
 , transform=True)
 
 def test_direct_ptradd(self):
-from pypy.rpython.lltypesystem import rffi
 def f(p, n):
 return lltype.direct_ptradd(p, n)
 self.encoding_test(f, [lltype.nullptr(rffi.CCHARP.TO), 123], 
@@ -975,7 +971,6 @@
 
 def check_force_cast(FROM, TO, operations, value):
 Check that the test is correctly written...
-from pypy.rpython.lltypesystem import rffi
 import re
 r = re.compile('(\w+) \%i\d, \$(-?\d+)')
 #
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Add a test here. *Still* passing.

2011-11-08 Thread arigo
Author: Armin Rigo ar...@tunes.org
Branch: 
Changeset: r48919:a800076e6e9c
Date: 2011-11-08 12:33 +0100
http://bitbucket.org/pypy/pypy/changeset/a800076e6e9c/

Log:Add a test here. *Still* passing.

diff --git a/pypy/jit/metainterp/test/test_ajit.py 
b/pypy/jit/metainterp/test/test_ajit.py
--- a/pypy/jit/metainterp/test/test_ajit.py
+++ b/pypy/jit/metainterp/test/test_ajit.py
@@ -3678,3 +3678,16 @@
 assert x == -42
 x = self.interp_operations(f, [1000, 1], translationoptions=topt)
 assert x == 999
+
+def test_ll_arraycopy(self):
+from pypy.rlib import rgc
+A = lltype.GcArray(lltype.Char)
+a = lltype.malloc(A, 10)
+for i in range(10): a[i] = chr(i)
+b = lltype.malloc(A, 10)
+#
+def f(c, d, e):
+rgc.ll_arraycopy(a, b, c, d, e)
+return 42
+self.interp_operations(f, [1, 2, 3])
+self.check_operations_history(call=1, guard_no_exception=0)
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Yet another obscure attempt at catching the bug

2011-11-08 Thread arigo
Author: Armin Rigo ar...@tunes.org
Branch: 
Changeset: r48920:f03b9b71714c
Date: 2011-11-08 12:47 +0100
http://bitbucket.org/pypy/pypy/changeset/f03b9b71714c/

Log:Yet another obscure attempt at catching the bug

diff --git a/pypy/jit/codewriter/effectinfo.py 
b/pypy/jit/codewriter/effectinfo.py
--- a/pypy/jit/codewriter/effectinfo.py
+++ b/pypy/jit/codewriter/effectinfo.py
@@ -78,6 +78,9 @@
 #
 OS_MATH_SQRT= 100
 
+# for debugging:
+_OS_CANRAISE = set([OS_NONE, OS_STR2UNICODE, OS_LIBFFI_CALL])
+
 def __new__(cls, readonly_descrs_fields, readonly_descrs_arrays,
 write_descrs_fields, write_descrs_arrays,
 extraeffect=EF_CAN_RAISE,
@@ -116,6 +119,8 @@
 result.extraeffect = extraeffect
 result.can_invalidate = can_invalidate
 result.oopspecindex = oopspecindex
+if result.check_can_raise():
+assert oopspecindex in cls._OS_CANRAISE
 cls._cache[key] = result
 return result
 
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Don't use range() here, because it can raise MemoryError.

2011-11-08 Thread arigo
Author: Armin Rigo ar...@tunes.org
Branch: 
Changeset: r48922:b1d4b57f6170
Date: 2011-11-08 13:08 +0100
http://bitbucket.org/pypy/pypy/changeset/b1d4b57f6170/

Log:Don't use range() here, because it can raise MemoryError.

diff --git a/pypy/rlib/rgc.py b/pypy/rlib/rgc.py
--- a/pypy/rlib/rgc.py
+++ b/pypy/rlib/rgc.py
@@ -163,8 +163,10 @@
 source_start, dest_start,
 length):
 # if the write barrier is not supported, copy by hand
-for i in range(length):
+i = 0
+while i  length:
 dest[i + dest_start] = source[i + source_start]
+i += 1
 return
 source_addr = llmemory.cast_ptr_to_adr(source)
 dest_addr   = llmemory.cast_ptr_to_adr(dest)
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: merge heads

2011-11-08 Thread arigo
Author: Armin Rigo ar...@tunes.org
Branch: 
Changeset: r48921:2e501c64546b
Date: 2011-11-08 12:48 +0100
http://bitbucket.org/pypy/pypy/changeset/2e501c64546b/

Log:merge heads

diff --git a/pypy/objspace/std/test/test_stdobjspace.py 
b/pypy/objspace/std/test/test_stdobjspace.py
--- a/pypy/objspace/std/test/test_stdobjspace.py
+++ b/pypy/objspace/std/test/test_stdobjspace.py
@@ -1,5 +1,6 @@
 from pypy.interpreter.error import OperationError
 from pypy.interpreter.gateway import app2interp
+from pypy.conftest import gettestobjspace
 
 class TestW_StdObjSpace:
 
@@ -60,3 +61,10 @@
 typedef = None
 
 assert space.isinstance_w(X(), space.w_str)
+
+def test_withstrbuf_fastpath_isinstance(self):
+from pypy.objspace.std.stringobject import W_StringObject
+
+space = gettestobjspace(withstrbuf=True) 
+assert space._get_interplevel_cls(space.w_str) is W_StringObject
+
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy release-1.7.x: Create a 1.7 branch. Bump version numbers

2011-11-08 Thread fijal
Author: Maciej Fijalkowski fij...@gmail.com
Branch: release-1.7.x
Changeset: r48924:a01f9701efa7
Date: 2011-11-08 13:44 +0100
http://bitbucket.org/pypy/pypy/changeset/a01f9701efa7/

Log:Create a 1.7 branch. Bump version numbers

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


[pypy-commit] pypy default: for completeness sake, bump numbers in the default as well

2011-11-08 Thread fijal
Author: Maciej Fijalkowski fij...@gmail.com
Branch: 
Changeset: r48925:d5cc360c2060
Date: 2011-11-08 13:44 +0100
http://bitbucket.org/pypy/pypy/changeset/d5cc360c2060/

Log:for completeness sake, bump numbers in the default as well

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


[pypy-commit] pypy jit-targets: fix test

2011-11-08 Thread hakanardo
Author: Hakan Ardo ha...@debian.org
Branch: jit-targets
Changeset: r48926:340cdb94a9f5
Date: 2011-11-08 10:31 +0100
http://bitbucket.org/pypy/pypy/changeset/340cdb94a9f5/

Log:fix test

diff --git a/pypy/jit/metainterp/test/test_exception.py 
b/pypy/jit/metainterp/test/test_exception.py
--- a/pypy/jit/metainterp/test/test_exception.py
+++ b/pypy/jit/metainterp/test/test_exception.py
@@ -35,7 +35,7 @@
 return n
 res = self.meta_interp(f, [10])
 assert res == 0
-self.check_resops({'jump': 2, 'guard_true': 2,
+self.check_resops({'jump': 1, 'guard_true': 2,
'int_gt': 2, 'int_sub': 2})
 
 def test_bridge_from_guard_exception(self):
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy jit-targets: fix test to not retrace when the guard is created and only to count the number of int_mul which is what the test is about

2011-11-08 Thread hakanardo
Author: Hakan Ardo ha...@debian.org
Branch: jit-targets
Changeset: r48932:1515bd7380ed
Date: 2011-11-08 13:02 +0100
http://bitbucket.org/pypy/pypy/changeset/1515bd7380ed/

Log:fix test to not retrace when the guard is created and only to count
the number of int_mul which is what the test is about

diff --git a/pypy/jit/metainterp/test/test_ajit.py 
b/pypy/jit/metainterp/test/test_ajit.py
--- a/pypy/jit/metainterp/test/test_ajit.py
+++ b/pypy/jit/metainterp/test/test_ajit.py
@@ -180,43 +180,39 @@
 self.check_trace_count(3)
 
 def test_loop_invariant_mul_bridge_maintaining1(self):
-myjitdriver = JitDriver(greens = [], reds = ['y', 'res', 'x'])
-def f(x, y):
+myjitdriver = JitDriver(greens = [], reds = ['y', 'res', 'x', 'n'])
+def f(x, y, n):
 res = 0
 while y  0:
-myjitdriver.can_enter_jit(x=x, y=y, res=res)
-myjitdriver.jit_merge_point(x=x, y=y, res=res)
+myjitdriver.can_enter_jit(x=x, y=y, res=res, n=n)
+myjitdriver.jit_merge_point(x=x, y=y, res=res, n=n)
 res += x * x
-if y16:
+if yn:
 res += 1
 y -= 1
 return res
-res = self.meta_interp(f, [6, 32])
+res = self.meta_interp(f, [6, 32, 16])
 assert res == 1167
 self.check_trace_count(3)
-self.check_resops({'int_lt': 3, 'int_gt': 2, 'int_add': 5,
-   'guard_true': 3, 'int_sub': 4, 'jump': 2,
-   'int_mul': 2, 'guard_false': 2})
+self.check_resops(int_mul=3)
 
 def test_loop_invariant_mul_bridge_maintaining2(self):
-myjitdriver = JitDriver(greens = [], reds = ['y', 'res', 'x'])
-def f(x, y):
+myjitdriver = JitDriver(greens = [], reds = ['y', 'res', 'x', 'n'])
+def f(x, y, n):
 res = 0
 while y  0:
-myjitdriver.can_enter_jit(x=x, y=y, res=res)
-myjitdriver.jit_merge_point(x=x, y=y, res=res)
+myjitdriver.can_enter_jit(x=x, y=y, res=res, n=n)
+myjitdriver.jit_merge_point(x=x, y=y, res=res, n=n)
 z = x * x
 res += z
-if y16:
+if yn:
 res += z
 y -= 1
 return res
-res = self.meta_interp(f, [6, 32])
+res = self.meta_interp(f, [6, 32, 16])
 assert res == 1692
 self.check_trace_count(3)
-self.check_resops({'int_lt': 3, 'int_gt': 2, 'int_add': 5,
-   'guard_true': 3, 'int_sub': 4, 'jump': 2,
-   'int_mul': 2, 'guard_false': 2})
+self.check_resops(int_mul=3)
 
 def test_loop_invariant_mul_bridge_maintaining3(self):
 myjitdriver = JitDriver(greens = [], reds = ['y', 'res', 'x', 'm'])
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy jit-targets: renaming, redefining and reeanbling the loop counters (in progress)

2011-11-08 Thread hakanardo
Author: Hakan Ardo ha...@debian.org
Branch: jit-targets
Changeset: r48930:9b50e8266be0
Date: 2011-11-08 12:11 +0100
http://bitbucket.org/pypy/pypy/changeset/9b50e8266be0/

Log:renaming, redefining and reeanbling the loop counters (in
progress)

diff --git a/pypy/jit/metainterp/test/support.py 
b/pypy/jit/metainterp/test/support.py
--- a/pypy/jit/metainterp/test/support.py
+++ b/pypy/jit/metainterp/test/support.py
@@ -161,34 +161,35 @@
 def check_loops(self, expected=None, everywhere=False, **check):
 get_stats().check_loops(expected=expected, everywhere=everywhere,
 **check)
-def check_loop_count(self, count):
-NB. This is a hack; use check_tree_loop_count() or
-check_enter_count() for the real thing.
-This counts as 1 every bridge in addition to every loop; and it does
-not count at all the entry bridges from interpreter, although they
-are TreeLoops as well.
-return # FIXME
-assert get_stats().compiled_count == count
-def check_tree_loop_count(self, count):
-return # FIXME
+def check_trace_count(self, count):
+# The number of traces compiled
 assert len(get_stats().loops) == count
-def check_loop_count_at_most(self, count):
-return # FIXME
-assert get_stats().compiled_count = count
+def check_trace_count_at_most(self, count):
+assert len(get_stats().loops) = count
+
+def check_jitcell_token_count(self, count):
+tokens = set()
+for loop in get_stats().loops:
+for op in loop.operations:
+descr = op.getdescr()
+if isinstance(descr, history.TargetToken):
+descr = descr.targeting_jitcell_token
+if isinstance(descr, history.JitCellToken):
+tokens.add(descr)
+assert len(tokens) == count
+
 def check_enter_count(self, count):
-return # FIXME
 assert get_stats().enter_count == count
 def check_enter_count_at_most(self, count):
-return # FIXME
 assert get_stats().enter_count = count
+
 def check_jumps(self, maxcount):
 return # FIXME
 assert get_stats().exec_jumps = maxcount
+
 def check_aborted_count(self, count):
-return # FIXME
 assert get_stats().aborted_count == count
 def check_aborted_count_at_least(self, count):
-return # FIXME
 assert get_stats().aborted_count = count
 
 def meta_interp(self, *args, **kwds):
diff --git a/pypy/jit/metainterp/test/test_ajit.py 
b/pypy/jit/metainterp/test/test_ajit.py
--- a/pypy/jit/metainterp/test/test_ajit.py
+++ b/pypy/jit/metainterp/test/test_ajit.py
@@ -78,7 +78,7 @@
 return res
 res = self.meta_interp(f, [6, 7])
 assert res == 42
-self.check_loop_count(1)
+self.check_trace_count(1)
 self.check_resops({'jump': 1, 'int_gt': 2, 'int_add': 2,
'guard_true': 2, 'int_sub': 2})
 
@@ -107,7 +107,7 @@
 return res
 res = self.meta_interp(f, [6, 7])
 assert res == 1323
-self.check_loop_count(1)
+self.check_trace_count(1)
 self.check_resops(int_mul=3)
 
 def test_loop_variant_mul_ovf(self):
@@ -124,7 +124,7 @@
 return res
 res = self.meta_interp(f, [6, 7])
 assert res == 1323
-self.check_loop_count(1)
+self.check_trace_count(1)
 self.check_resops(int_mul_ovf=3)
 
 def test_loop_invariant_mul1(self):
@@ -139,7 +139,7 @@
 return res
 res = self.meta_interp(f, [6, 7])
 assert res == 252
-self.check_loop_count(1)
+self.check_trace_count(1)
 self.check_resops({'jump': 1, 'int_gt': 2, 'int_add': 2,
'int_mul': 1, 'guard_true': 2, 'int_sub': 2})
 
@@ -157,7 +157,7 @@
 return res
 res = self.meta_interp(f, [6, 7])
 assert res == 308
-self.check_loop_count(1)
+self.check_trace_count(1)
 self.check_resops({'jump': 1, 'int_lshift': 2, 'int_gt': 2,
'int_mul_ovf': 1, 'int_add': 4,
'guard_true': 2, 'guard_no_overflow': 1,
@@ -177,7 +177,7 @@
 return res
 res = self.meta_interp(f, [6, 32])
 assert res == 3427
-self.check_loop_count(3)
+self.check_trace_count(3)
 
 def test_loop_invariant_mul_bridge_maintaining1(self):
 myjitdriver = JitDriver(greens = [], reds = ['y', 'res', 'x'])
@@ -193,7 +193,7 @@
 return res
 res = self.meta_interp(f, [6, 32])
 assert res == 1167
-self.check_loop_count(3)
+self.check_trace_count(3)
 self.check_resops({'int_lt': 3, 'int_gt': 2, 'int_add': 5,
'guard_true': 3, 'int_sub': 4, 'jump': 2,
'int_mul': 2, 'guard_false': 2})

[pypy-commit] pypy jit-targets: fix tests

2011-11-08 Thread hakanardo
Author: Hakan Ardo ha...@debian.org
Branch: jit-targets
Changeset: r48933:7d1b9a847447
Date: 2011-11-08 13:27 +0100
http://bitbucket.org/pypy/pypy/changeset/7d1b9a847447/

Log:fix tests

diff --git a/pypy/jit/metainterp/test/test_ajit.py 
b/pypy/jit/metainterp/test/test_ajit.py
--- a/pypy/jit/metainterp/test/test_ajit.py
+++ b/pypy/jit/metainterp/test/test_ajit.py
@@ -880,7 +880,9 @@
 n -= 1
 
 self.meta_interp(f, [20], repeat=7)
-self.check_jitcell_token_count(2)  # the loop and the entry path
+# the loop and the entry path as a single trace
+self.check_jitcell_token_count(1)
+
 # we get:
 #ENTER - compile the new loop and the entry bridge
 #ENTER - compile the leaving path
@@ -1251,7 +1253,7 @@
 
 res = self.meta_interp(f, [10, 3])
 assert res == 9 + 8 + 7 + 6 + 5 + 4 + 3 + 2 + 1 + 0
-self.check_jitcell_token_count(2)
+self.check_jitcell_token_count(1)
 
 res = self.meta_interp(f, [10, 13])
 assert res == 9 + 8 + 7 + 6 + 5 + 4 + 3 + 2 + 1 + 0
@@ -1726,7 +1728,7 @@
 return a1.val + b1.val
 res = self.meta_interp(g, [6, 7])
 assert res == 6*8 + 6**8
-self.check_trace_count(5)
+self.check_trace_count(4)
 self.check_resops({'guard_class': 2, 'int_gt': 4,
'getfield_gc': 4, 'guard_true': 4,
'int_sub': 4, 'jump': 2, 'int_mul': 2,
@@ -1770,7 +1772,7 @@
 return a1.val + b1.val
 res = self.meta_interp(g, [6, 20])
 assert res == g(6, 20)
-self.check_trace_count(9)
+self.check_trace_count(8)
 self.check_resops(getarrayitem_gc=10)
 
 def test_multiple_specialied_versions_bridge(self):
@@ -1958,7 +1960,7 @@
 return a1.val + b1.val
 res = self.meta_interp(g, [3, 23])
 assert res == 7068153
-self.check_trace_count(7)
+self.check_trace_count(6)
 self.check_resops(guard_true=6, guard_class=2, int_mul=3,
   int_add=3, guard_false=3)
 
@@ -2044,7 +2046,7 @@
 return n
 res = self.meta_interp(f, [sys.maxint-10])
 assert res == 11
-self.check_jitcell_token_count(2)
+self.check_jitcell_token_count(1)
 
 def test_wrap_around_mul(self):
 myjitdriver = JitDriver(greens = [], reds = ['x', 'n'])
@@ -2060,7 +2062,7 @@
 return n
 res = self.meta_interp(f, [sys.maxint10])
 assert res == 11
-self.check_jitcell_token_count(2)
+self.check_jitcell_token_count(1)
 
 def test_wrap_around_sub(self):
 myjitdriver = JitDriver(greens = [], reds = ['x', 'n'])
@@ -2076,7 +2078,7 @@
 return n
 res = self.meta_interp(f, [10-sys.maxint])
 assert res == 12
-self.check_jitcell_token_count(2)
+self.check_jitcell_token_count(1)
 
 def test_caching_setfield(self):
 myjitdriver = JitDriver(greens = [], reds = ['sa', 'i', 'n', 'a', 
'node'])
@@ -2596,9 +2598,9 @@
 i += 1
 return sa
 assert self.meta_interp(f, [20, 2]) == f(20, 2)
+self.check_jitcell_token_count(3)
+assert self.meta_interp(f, [20, 3]) == f(20, 3)
 self.check_jitcell_token_count(4)
-assert self.meta_interp(f, [20, 3]) == f(20, 3)
-self.check_jitcell_token_count(5)
 
 def test_max_retrace_guards(self):
 myjitdriver = JitDriver(greens = [], reds = ['n', 'i', 'sa', 'a'])
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy jit-targets: respect retrace limit

2011-11-08 Thread hakanardo
Author: Hakan Ardo ha...@debian.org
Branch: jit-targets
Changeset: r48934:8f5285d28ef9
Date: 2011-11-08 13:38 +0100
http://bitbucket.org/pypy/pypy/changeset/8f5285d28ef9/

Log:respect retrace limit

diff --git a/pypy/jit/metainterp/optimizeopt/unroll.py 
b/pypy/jit/metainterp/optimizeopt/unroll.py
--- a/pypy/jit/metainterp/optimizeopt/unroll.py
+++ b/pypy/jit/metainterp/optimizeopt/unroll.py
@@ -506,42 +506,48 @@
 pass
 target.virtual_state.debug_print(debugmsg, bad)
 
-if ok:
-debug_stop('jit-log-virtualstate')
+if ok:
+debug_stop('jit-log-virtualstate')
 
-values = [self.getvalue(arg)
-  for arg in jumpop.getarglist()]
-args = target.virtual_state.make_inputargs(values, 
self.optimizer,
-   keyboxes=True)
-short_inputargs = target.short_preamble[0].getarglist()
-inliner = Inliner(short_inputargs, args)
+values = [self.getvalue(arg)
+  for arg in jumpop.getarglist()]
+args = target.virtual_state.make_inputargs(values, self.optimizer,
+   keyboxes=True)
+short_inputargs = target.short_preamble[0].getarglist()
+inliner = Inliner(short_inputargs, args)
 
-for guard in extra_guards:
-if guard.is_guard():
-descr = target.start_resumedescr.clone_if_mutable()
-inliner.inline_descr_inplace(descr)
-guard.setdescr(descr)
-self.optimizer.send_extra_operation(guard)
+for guard in extra_guards:
+if guard.is_guard():
+descr = target.start_resumedescr.clone_if_mutable()
+inliner.inline_descr_inplace(descr)
+guard.setdescr(descr)
+self.optimizer.send_extra_operation(guard)
 
-try:
-for shop in target.short_preamble[1:]:
-newop = inliner.inline_op(shop)
-self.optimizer.send_extra_operation(newop)
-except InvalidLoop:
-debug_print(Inlining failed unexpectedly,
-jumping to preamble instead)
-assert cell_token.target_tokens[0].virtual_state is None
-jumpop.setdescr(cell_token.target_tokens[0])
-self.optimizer.send_extra_operation(jumpop)
-return True
+try:
+for shop in target.short_preamble[1:]:
+newop = inliner.inline_op(shop)
+self.optimizer.send_extra_operation(newop)
+except InvalidLoop:
+debug_print(Inlining failed unexpectedly,
+jumping to preamble instead)
+assert cell_token.target_tokens[0].virtual_state is None
+jumpop.setdescr(cell_token.target_tokens[0])
+self.optimizer.send_extra_operation(jumpop)
+return True
 debug_stop('jit-log-virtualstate')
 
-retraced_count = cell_token.retraced_count
 limit = 
self.optimizer.metainterp_sd.warmrunnerdesc.memory_manager.retrace_limit
-if retraced_countlimit:
-debug_print('Retracing (%d/%d)' % (retraced_count, limit))
+if cell_token.retraced_countlimit:
 cell_token.retraced_count += 1
+debug_print('Retracing (%d/%d)' % (cell_token.retraced_count, 
limit))
 return False
+else:
+debug_print(Retrace count reached, jumping to preamble)
+assert cell_token.target_tokens[0].virtual_state is None
+jumpop.setdescr(cell_token.target_tokens[0])
+self.optimizer.send_extra_operation(jumpop)
+return True
+
 
 
 # FIXME: kill
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy jit-targets: support max_retrace_guards

2011-11-08 Thread hakanardo
Author: Hakan Ardo ha...@debian.org
Branch: jit-targets
Changeset: r48936:5a5c19100cf4
Date: 2011-11-08 14:09 +0100
http://bitbucket.org/pypy/pypy/changeset/5a5c19100cf4/

Log:support max_retrace_guards

diff --git a/pypy/jit/metainterp/optimizeopt/unroll.py 
b/pypy/jit/metainterp/optimizeopt/unroll.py
--- a/pypy/jit/metainterp/optimizeopt/unroll.py
+++ b/pypy/jit/metainterp/optimizeopt/unroll.py
@@ -322,6 +322,10 @@
 raise InvalidLoop
 debug_stop('jit-log-virtualstate')
 
+maxguards = 
self.optimizer.metainterp_sd.warmrunnerdesc.memory_manager.max_retrace_guards
+if self.optimizer.emitted_guards  maxguards:
+jumpop.getdescr().targeting_jitcell_token.retraced_count = 
sys.maxint
+
 def finilize_short_preamble(self, start_label):
 short = self.short
 assert short[-1].getopnum() == rop.JUMP
diff --git a/pypy/jit/metainterp/test/test_ajit.py 
b/pypy/jit/metainterp/test/test_ajit.py
--- a/pypy/jit/metainterp/test/test_ajit.py
+++ b/pypy/jit/metainterp/test/test_ajit.py
@@ -2599,10 +2599,10 @@
 return sa
 assert self.meta_interp(f, [20, 2]) == f(20, 2)
 self.check_jitcell_token_count(1)
-assert len(get_stats().jitcell_tokens.pop().target_tokens) == 4
+assert len(list(get_stats().jitcell_tokens)[0].target_tokens) == 4
 assert self.meta_interp(f, [20, 3]) == f(20, 3)
 self.check_jitcell_token_count(1)
-assert len(get_stats().jitcell_tokens.pop().target_tokens) == 5
+assert len(list(get_stats().jitcell_tokens)[0].target_tokens) == 5
 
 def test_max_retrace_guards(self):
 myjitdriver = JitDriver(greens = [], reds = ['n', 'i', 'sa', 'a'])
@@ -2619,10 +2619,11 @@
 i += 1
 return sa
 assert self.meta_interp(f, [20, 1]) == f(20, 1)
-self.check_jitcell_token_count(2)
+self.check_jitcell_token_count(1)
+assert len(list(get_stats().jitcell_tokens)[0].target_tokens) == 2
 assert self.meta_interp(f, [20, 10]) == f(20, 10)
-self.check_jitcell_token_count(5)
-
+self.check_jitcell_token_count(1)
+assert len(list(get_stats().jitcell_tokens)[0].target_tokens) == 5
 
 def test_retrace_limit_with_extra_guards(self):
 myjitdriver = JitDriver(greens = [], reds = ['n', 'i', 'sa', 'a',
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy ppc-jit-backend: PPC64 support for _save_managed_regs

2011-11-08 Thread edelsohn
Author: edelsohn
Branch: ppc-jit-backend
Changeset: r48937:2634db7ce5b0
Date: 2011-11-08 09:35 -0500
http://bitbucket.org/pypy/pypy/changeset/2634db7ce5b0/

Log:PPC64 support for _save_managed_regs

diff --git a/pypy/jit/backend/ppc/ppcgen/ppc_assembler.py 
b/pypy/jit/backend/ppc/ppcgen/ppc_assembler.py
--- a/pypy/jit/backend/ppc/ppcgen/ppc_assembler.py
+++ b/pypy/jit/backend/ppc/ppcgen/ppc_assembler.py
@@ -338,7 +338,7 @@
 if IS_PPC_32:
 mc.stw(reg.value, r.SP.value, -(len(r.MANAGED_REGS) - i) * 
WORD)
 else:
-assert 0, not implemented yet
+mc.std(reg.value, r.SP.value, -(len(r.MANAGED_REGS) - i) * 
WORD)
 
 def gen_bootstrap_code(self, nonfloatlocs, inputargs):
 for i in range(len(nonfloatlocs)):
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy numpy-multidim: a nicely passing test and a test we want to work on

2011-11-08 Thread fijal
Author: Maciej Fijalkowski fij...@gmail.com
Branch: numpy-multidim
Changeset: r48938:8e3ada08df4f
Date: 2011-11-08 16:43 +0100
http://bitbucket.org/pypy/pypy/changeset/8e3ada08df4f/

Log:a nicely passing test and a test we want to work on

diff --git a/pypy/module/micronumpy/test/test_compile.py 
b/pypy/module/micronumpy/test/test_compile.py
--- a/pypy/module/micronumpy/test/test_compile.py
+++ b/pypy/module/micronumpy/test/test_compile.py
@@ -183,3 +183,11 @@
 a - 0 - 1
 )
 assert interp.results[0].value.val == 2
+
+def test_multidim_getitem_2(self):
+interp = self.run(
+a = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]]
+b = a + a
+b - 1 - 1
+)
+assert interp.results[0].value.val == 8
diff --git a/pypy/module/micronumpy/test/test_numarray.py 
b/pypy/module/micronumpy/test/test_numarray.py
--- a/pypy/module/micronumpy/test/test_numarray.py
+++ b/pypy/module/micronumpy/test/test_numarray.py
@@ -737,6 +737,11 @@
 a = array([[1, 2], [3, 4], [5, 6]])
 assert ((a + a) == array([[1+1, 2+2], [3+3, 4+4], [5+5, 6+6]])).all()
 
+def test_getitem_add(self):
+from numpy import array
+a = array([[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]])
+assert (a + a)[1, 1] == 8
+
 class AppTestSupport(object):
 def setup_class(cls):
 import struct
diff --git a/pypy/module/micronumpy/test/test_zjit.py 
b/pypy/module/micronumpy/test/test_zjit.py
--- a/pypy/module/micronumpy/test/test_zjit.py
+++ b/pypy/module/micronumpy/test/test_zjit.py
@@ -243,6 +243,35 @@
   'setarrayitem_raw': 1, 'int_add': 3,
   'int_lt': 1, 'guard_true': 1, 'jump': 1})
 
+def define_multidim():
+return 
+a = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]]
+b = a + a
+b - 1 - 1
+
+
+def test_multidim(self):
+result = self.run('multidim')
+assert result == 8
+self.check_loops({'float_add': 1, 'getarrayitem_raw': 2,
+  'guard_true': 1, 'int_add': 1, 'int_lt': 1,
+  'jump': 1, 'setarrayitem_raw': 1})
+
+def define_multidim_slice():
+return 
+a = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14]]
+b = a - ::2
+c = b + b
+c - 1 - 1
+
+
+def test_multidim_slice(self):
+result = self.run('multidim_slice')
+assert result == 12
+py.test.skip(improve)
+self.check_loops({})
+
+
 class TestNumpyOld(LLJitMixin):
 def setup_class(cls):
 py.test.skip(old)
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy win64_gborg: Merge with default

2011-11-08 Thread ctismer
Author: Christian Tismer tis...@stackless.com
Branch: win64_gborg
Changeset: r48941:8c667375eed2
Date: 2011-11-08 00:43 +0100
http://bitbucket.org/pypy/pypy/changeset/8c667375eed2/

Log:Merge with default

diff --git a/lib_pypy/pyrepl/commands.py b/lib_pypy/pyrepl/commands.py
--- a/lib_pypy/pyrepl/commands.py
+++ b/lib_pypy/pyrepl/commands.py
@@ -33,10 +33,9 @@
 class Command(object):
 finish = 0
 kills_digit_arg = 1
-def __init__(self, reader, (event_name, event)):
+def __init__(self, reader, cmd):
 self.reader = reader
-self.event = event
-self.event_name = event_name
+self.event_name, self.event = cmd
 def do(self):
 pass
 
diff --git a/lib_pypy/pyrepl/pygame_console.py 
b/lib_pypy/pyrepl/pygame_console.py
--- a/lib_pypy/pyrepl/pygame_console.py
+++ b/lib_pypy/pyrepl/pygame_console.py
@@ -130,7 +130,7 @@
 s.fill(c, [0, 600 - bmargin, 800, bmargin])
 s.fill(c, [800 - rmargin, 0, lmargin, 600])
 
-def refresh(self, screen, (cx, cy)):
+def refresh(self, screen, cxy):
 self.screen = screen
 self.pygame_screen.fill(colors.bg,
 [0, tmargin + self.cur_top + self.scroll,
@@ -139,8 +139,8 @@
 
 line_top = self.cur_top
 width, height = self.fontsize
-self.cxy = (cx, cy)
-cp = self.char_pos(cx, cy)
+self.cxy = cxy
+cp = self.char_pos(*cxy)
 if cp[1]  tmargin:
 self.scroll = - (cy*self.fh + self.cur_top)
 self.repaint()
@@ -148,7 +148,7 @@
 self.scroll += (600 - bmargin) - (cp[1] + self.fh)
 self.repaint()
 if self.curs_vis:
-self.pygame_screen.blit(self.cursor, self.char_pos(cx, cy))
+self.pygame_screen.blit(self.cursor, self.char_pos(*cxy))
 for line in screen:
 if 0 = line_top + self.scroll = (600 - bmargin - tmargin - 
self.fh):
 if line:
diff --git a/lib_pypy/pyrepl/unix_console.py b/lib_pypy/pyrepl/unix_console.py
--- a/lib_pypy/pyrepl/unix_console.py
+++ b/lib_pypy/pyrepl/unix_console.py
@@ -163,7 +163,7 @@
 def change_encoding(self, encoding):
 self.encoding = encoding
 
-def refresh(self, screen, (cx, cy)):
+def refresh(self, screen, cxy):
 # this function is still too long (over 90 lines)
 
 if not self.__gone_tall:
@@ -198,6 +198,7 @@
 
 # we make sure the cursor is on the screen, and that we're
 # using all of the screen if we can
+cx, cy = cxy
 if cy  offset:
 offset = cy
 elif cy = offset + height:
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
@@ -55,7 +55,7 @@
 
 
 def optimize_loop_1(metainterp_sd, loop, enable_opts,
-inline_short_preamble=True, retraced=False, bridge=False):
+inline_short_preamble=True, retraced=False):
 Optimize loop.operations to remove internal overheadish operations.
 
 
@@ -64,7 +64,7 @@
 if unroll:
 optimize_unroll(metainterp_sd, loop, optimizations)
 else:
-optimizer = Optimizer(metainterp_sd, loop, optimizations, bridge)
+optimizer = Optimizer(metainterp_sd, loop, optimizations)
 optimizer.propagate_all_forward()
 
 def optimize_bridge_1(metainterp_sd, bridge, enable_opts,
@@ -76,7 +76,7 @@
 except KeyError:
 pass
 optimize_loop_1(metainterp_sd, bridge, enable_opts,
-inline_short_preamble, retraced, bridge=True)
+inline_short_preamble, retraced)
 
 if __name__ == '__main__':
 print ALL_OPTS_NAMES
diff --git a/pypy/jit/metainterp/optimizeopt/heap.py 
b/pypy/jit/metainterp/optimizeopt/heap.py
--- a/pypy/jit/metainterp/optimizeopt/heap.py
+++ b/pypy/jit/metainterp/optimizeopt/heap.py
@@ -234,7 +234,7 @@
 or op.is_ovf()):
 self.posponedop = op
 else:
-self.next_optimization.propagate_forward(op)
+Optimization.emit_operation(self, op)
 
 def emitting_operation(self, op):
 if op.has_no_side_effect():
diff --git a/pypy/jit/metainterp/optimizeopt/intbounds.py 
b/pypy/jit/metainterp/optimizeopt/intbounds.py
--- a/pypy/jit/metainterp/optimizeopt/intbounds.py
+++ b/pypy/jit/metainterp/optimizeopt/intbounds.py
@@ -6,6 +6,7 @@
 IntUpperBound)
 from pypy.jit.metainterp.optimizeopt.util import make_dispatcher_method
 from pypy.jit.metainterp.resoperation import rop
+from pypy.jit.metainterp.optimize import InvalidLoop
 from pypy.rlib.rarithmetic import LONG_BIT
 
 
@@ -13,30 +14,10 @@
 Keeps track of the bounds placed on integers by guards and remove
redundant guards
 
-def setup(self):
-self.posponedop = None
-self.nextop = None
-
 def new(self):
-assert self.posponedop is None
   

[pypy-commit] pypy win64_gborg: Merge with default

2011-11-08 Thread ctismer
Author: Christian Tismer tis...@stackless.com
Branch: win64_gborg
Changeset: r48939:64b52e0ecfcc
Date: 2011-11-07 17:26 +0100
http://bitbucket.org/pypy/pypy/changeset/64b52e0ecfcc/

Log:Merge with default

diff --git a/pypy/module/cpyext/api.py b/pypy/module/cpyext/api.py
--- a/pypy/module/cpyext/api.py
+++ b/pypy/module/cpyext/api.py
@@ -392,6 +392,7 @@
 'Slice': 'space.gettypeobject(W_SliceObject.typedef)',
 'StaticMethod': 'space.gettypeobject(StaticMethod.typedef)',
 'CFunction': 
'space.gettypeobject(cpyext.methodobject.W_PyCFunctionObject.typedef)',
+'WrapperDescr': 
'space.gettypeobject(cpyext.methodobject.W_PyCMethodObject.typedef)'
 }.items():
 GLOBALS['Py%s_Type#' % (cpyname, )] = ('PyTypeObject*', pypyexpr)
 
diff --git a/pypy/module/cpyext/methodobject.py 
b/pypy/module/cpyext/methodobject.py
--- a/pypy/module/cpyext/methodobject.py
+++ b/pypy/module/cpyext/methodobject.py
@@ -240,6 +240,7 @@
 def PyStaticMethod_New(space, w_func):
 return space.wrap(StaticMethod(w_func))
 
+@cpython_api([PyObject, lltype.Ptr(PyMethodDef)], PyObject)
 def PyDescr_NewMethod(space, w_type, method):
 return space.wrap(W_PyCMethodObject(space, method, w_type))
 
diff --git a/pypy/module/cpyext/stubs.py b/pypy/module/cpyext/stubs.py
--- a/pypy/module/cpyext/stubs.py
+++ b/pypy/module/cpyext/stubs.py
@@ -586,10 +586,6 @@
 def PyDescr_NewMember(space, type, meth):
 raise NotImplementedError
 
-@cpython_api([PyTypeObjectPtr, PyMethodDef], PyObject)
-def PyDescr_NewMethod(space, type, meth):
-raise NotImplementedError
-
 @cpython_api([PyTypeObjectPtr, wrapperbase, rffi.VOIDP], PyObject)
 def PyDescr_NewWrapper(space, type, wrapper, wrapped):
 raise NotImplementedError
@@ -610,14 +606,6 @@
 def PyWrapper_New(space, w_d, w_self):
 raise NotImplementedError
 
-@cpython_api([PyObject], PyObject)
-def PyDictProxy_New(space, dict):
-Return a proxy object for a mapping which enforces read-only behavior.
-This is normally used to create a proxy to prevent modification of the
-dictionary for non-dynamic class types.
-
-raise NotImplementedError
-
 @cpython_api([PyObject, PyObject, rffi.INT_real], rffi.INT_real, error=-1)
 def PyDict_Merge(space, a, b, override):
 Iterate over mapping object b adding key-value pairs to dictionary a.
@@ -2293,15 +2281,6 @@
 changes in your code for properly supporting 64-bit systems.
 raise NotImplementedError
 
-@cpython_api([rffi.CWCHARP, Py_ssize_t, rffi.CCHARP], PyObject)
-def PyUnicode_EncodeUTF8(space, s, size, errors):
-Encode the Py_UNICODE buffer of the given size using UTF-8 and return a
-Python string object.  Return NULL if an exception was raised by the codec.
-
-This function used an int type for size. This might require
-changes in your code for properly supporting 64-bit systems.
-raise NotImplementedError
-
 @cpython_api([rffi.CCHARP, Py_ssize_t, rffi.CCHARP, rffi.INTP], PyObject)
 def PyUnicode_DecodeUTF32(space, s, size, errors, byteorder):
 Decode length bytes from a UTF-32 encoded buffer string and return the
@@ -2481,31 +2460,6 @@
 was raised by the codec.
 raise NotImplementedError
 
-@cpython_api([rffi.CCHARP, Py_ssize_t, rffi.CCHARP], PyObject)
-def PyUnicode_DecodeLatin1(space, s, size, errors):
-Create a Unicode object by decoding size bytes of the Latin-1 encoded 
string
-s.  Return NULL if an exception was raised by the codec.
-
-This function used an int type for size. This might require
-changes in your code for properly supporting 64-bit systems.
-raise NotImplementedError
-
-@cpython_api([rffi.CWCHARP, Py_ssize_t, rffi.CCHARP], PyObject)
-def PyUnicode_EncodeLatin1(space, s, size, errors):
-Encode the Py_UNICODE buffer of the given size using Latin-1 and return
-a Python string object.  Return NULL if an exception was raised by the 
codec.
-
-This function used an int type for size. This might require
-changes in your code for properly supporting 64-bit systems.
-raise NotImplementedError
-
-@cpython_api([PyObject], PyObject)
-def PyUnicode_AsLatin1String(space, unicode):
-Encode a Unicode object using Latin-1 and return the result as Python 
string
-object.  Error handling is strict.  Return NULL if an exception was 
raised
-by the codec.
-raise NotImplementedError
-
 @cpython_api([rffi.CCHARP, Py_ssize_t, PyObject, rffi.CCHARP], PyObject)
 def PyUnicode_DecodeCharmap(space, s, size, mapping, errors):
 Create a Unicode object by decoding size bytes of the encoded string s 
using
@@ -2564,13 +2518,6 @@
 
 raise NotImplementedError
 
-@cpython_api([PyObject], PyObject)
-def PyUnicode_AsMBCSString(space, unicode):
-Encode a Unicode object using MBCS and return the result as Python 
string
-object.  Error handling is strict.  Return NULL if an exception was 
raised
-by the codec.
-raise NotImplementedError
-
 @cpython_api([PyObject, PyObject], 

[pypy-commit] pypy win64_gborg: removed the last bug from test_typed.py ehich is not related to rwin32.py buggyness

2011-11-08 Thread ctismer
Author: Christian Tismer tis...@stackless.com
Branch: win64_gborg
Changeset: r48940:0ea921260824
Date: 2011-11-08 00:41 +0100
http://bitbucket.org/pypy/pypy/changeset/0ea921260824/

Log:removed the last bug from test_typed.py ehich is not related to
rwin32.py buggyness

diff --git a/pypy/rlib/rdtoa.py b/pypy/rlib/rdtoa.py
--- a/pypy/rlib/rdtoa.py
+++ b/pypy/rlib/rdtoa.py
@@ -244,8 +244,8 @@
 # The only failure mode is no memory
 raise MemoryError
 try:
-buflen = (rffi.cast(rffi.LONG, end_ptr[0]) -
-  rffi.cast(rffi.LONG, digits))
+buflen = (rffi.cast(lltype.Signed, end_ptr[0]) -
+  rffi.cast(lltype.Signed, digits))
 sign = rffi.cast(lltype.Signed, sign_ptr[0])
 
 # Handle nan and inf
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: added sys.maxint to the compilation hash, to avoid obscure errors on windows

2011-11-08 Thread ctismer
Author: Christian Tismer tis...@stackless.com
Branch: 
Changeset: r48942:905df0d6d47e
Date: 2011-11-08 16:37 +0100
http://bitbucket.org/pypy/pypy/changeset/905df0d6d47e/

Log:added sys.maxint to the compilation hash, to avoid obscure errors on
windows

diff --git a/pypy/translator/platform/__init__.py 
b/pypy/translator/platform/__init__.py
--- a/pypy/translator/platform/__init__.py
+++ b/pypy/translator/platform/__init__.py
@@ -102,6 +102,8 @@
 bits = [self.__class__.__name__, 'cc=%r' % self.cc]
 for varname in self.relevant_environ:
 bits.append('%s=%r' % (varname, os.environ.get(varname)))
+# adding sys.maxint to disambiguate windows
+bits.append('%s=%r' % ('sys.maxint', sys.maxint))
 return ' '.join(bits)
 
 # some helpers which seem to be cross-platform enough
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Merge

2011-11-08 Thread ctismer
Author: Christian Tismer tis...@stackless.com
Branch: 
Changeset: r48943:7c7c46d6a78d
Date: 2011-11-08 16:41 +0100
http://bitbucket.org/pypy/pypy/changeset/7c7c46d6a78d/

Log:Merge

diff --git a/lib_pypy/_ctypes/pointer.py b/lib_pypy/_ctypes/pointer.py
--- a/lib_pypy/_ctypes/pointer.py
+++ b/lib_pypy/_ctypes/pointer.py
@@ -124,7 +124,8 @@
 # for now, we always allow types.pointer, else a lot of tests
 # break. We need to rethink how pointers are represented, though
 if my_ffitype is not ffitype and ffitype is not _ffi.types.void_p:
-raise ArgumentError, expected %s instance, got %s % (type(value), 
ffitype)
+raise ArgumentError(expected %s instance, got %s % (type(value),
+  ffitype))
 return value._get_buffer_value()
 
 def _cast_addr(obj, _, tp):
diff --git a/pypy/jit/codewriter/effectinfo.py 
b/pypy/jit/codewriter/effectinfo.py
--- a/pypy/jit/codewriter/effectinfo.py
+++ b/pypy/jit/codewriter/effectinfo.py
@@ -78,6 +78,9 @@
 #
 OS_MATH_SQRT= 100
 
+# for debugging:
+_OS_CANRAISE = set([OS_NONE, OS_STR2UNICODE, OS_LIBFFI_CALL])
+
 def __new__(cls, readonly_descrs_fields, readonly_descrs_arrays,
 write_descrs_fields, write_descrs_arrays,
 extraeffect=EF_CAN_RAISE,
@@ -116,6 +119,8 @@
 result.extraeffect = extraeffect
 result.can_invalidate = can_invalidate
 result.oopspecindex = oopspecindex
+if result.check_can_raise():
+assert oopspecindex in cls._OS_CANRAISE
 cls._cache[key] = result
 return result
 
@@ -125,6 +130,10 @@
 def check_can_invalidate(self):
 return self.can_invalidate
 
+def check_is_elidable(self):
+return (self.extraeffect == self.EF_ELIDABLE_CAN_RAISE or
+self.extraeffect == self.EF_ELIDABLE_CANNOT_RAISE)
+
 def check_forces_virtual_or_virtualizable(self):
 return self.extraeffect = self.EF_FORCES_VIRTUAL_OR_VIRTUALIZABLE
 
diff --git a/pypy/jit/codewriter/test/test_flatten.py 
b/pypy/jit/codewriter/test/test_flatten.py
--- a/pypy/jit/codewriter/test/test_flatten.py
+++ b/pypy/jit/codewriter/test/test_flatten.py
@@ -5,7 +5,7 @@
 from pypy.jit.codewriter.format import assert_format
 from pypy.jit.codewriter import longlong
 from pypy.jit.metainterp.history import AbstractDescr
-from pypy.rpython.lltypesystem import lltype, rclass, rstr
+from pypy.rpython.lltypesystem import lltype, rclass, rstr, rffi
 from pypy.objspace.flow.model import SpaceOperation, Variable, Constant
 from pypy.translator.unsimplify import varoftype
 from pypy.rlib.rarithmetic import ovfcheck, r_uint, r_longlong, r_ulonglong
@@ -743,7 +743,6 @@
 , transform=True)
 
 def test_force_cast(self):
-from pypy.rpython.lltypesystem import rffi
 # NB: we don't need to test for INT here, the logic in jtransform is
 # general enough so that if we have the below cases it should
 # generalize also to INT
@@ -849,7 +848,6 @@
transform=True)
 
 def test_force_cast_pointer(self):
-from pypy.rpython.lltypesystem import rffi
 def h(p):
 return rffi.cast(rffi.VOIDP, p)
 self.encoding_test(h, [lltype.nullptr(rffi.CCHARP.TO)], 
@@ -857,7 +855,6 @@
 , transform=True)
 
 def test_force_cast_floats(self):
-from pypy.rpython.lltypesystem import rffi
 # Caststs to lltype.Float
 def f(n):
 return rffi.cast(lltype.Float, n)
@@ -964,7 +961,6 @@
 , transform=True)
 
 def test_direct_ptradd(self):
-from pypy.rpython.lltypesystem import rffi
 def f(p, n):
 return lltype.direct_ptradd(p, n)
 self.encoding_test(f, [lltype.nullptr(rffi.CCHARP.TO), 123], 
@@ -975,7 +971,6 @@
 
 def check_force_cast(FROM, TO, operations, value):
 Check that the test is correctly written...
-from pypy.rpython.lltypesystem import rffi
 import re
 r = re.compile('(\w+) \%i\d, \$(-?\d+)')
 #
diff --git a/pypy/jit/metainterp/optimizeopt/test/test_util.py 
b/pypy/jit/metainterp/optimizeopt/test/test_util.py
--- a/pypy/jit/metainterp/optimizeopt/test/test_util.py
+++ b/pypy/jit/metainterp/optimizeopt/test/test_util.py
@@ -183,6 +183,7 @@
 can_invalidate=True))
 arraycopydescr = cpu.calldescrof(FUNC, FUNC.ARGS, FUNC.RESULT,
  EffectInfo([], [arraydescr], [], [arraydescr],
+EffectInfo.EF_CANNOT_RAISE,
 oopspecindex=EffectInfo.OS_ARRAYCOPY))
 
 
@@ -212,12 +213,14 @@
 _oopspecindex = getattr(EffectInfo, _os)
 locals()[_name] = \
 cpu.calldescrof(FUNC, FUNC.ARGS, FUNC.RESULT,
-EffectInfo([], [], [], [], oopspecindex=_oopspecindex))
+EffectInfo([], [], [], [], EffectInfo.EF_CANNOT_RAISE,
+   

[pypy-commit] pypy jit-targets: fix test

2011-11-08 Thread hakanardo
Author: Hakan Ardo ha...@debian.org
Branch: jit-targets
Changeset: r48944:ac7073eb2075
Date: 2011-11-08 15:09 +0100
http://bitbucket.org/pypy/pypy/changeset/ac7073eb2075/

Log:fix test

diff --git a/pypy/jit/metainterp/test/test_ajit.py 
b/pypy/jit/metainterp/test/test_ajit.py
--- a/pypy/jit/metainterp/test/test_ajit.py
+++ b/pypy/jit/metainterp/test/test_ajit.py
@@ -2643,9 +2643,11 @@
 i += 1
 return sa
 assert self.meta_interp(f, [20, 2]) == f(20, 2)
-self.check_jitcell_token_count(4)
+self.check_jitcell_token_count(1)
+assert len(list(get_stats().jitcell_tokens)[0].target_tokens) == 4
 assert self.meta_interp(f, [20, 3]) == f(20, 3)
-self.check_jitcell_token_count(5)
+self.check_jitcell_token_count(1)
+assert len(list(get_stats().jitcell_tokens)[0].target_tokens) == 5
 
 def test_retrace_ending_up_retrazing_another_loop(self):
 
@@ -2688,12 +2690,8 @@
 
 # The attempts of retracing first loop will end up retracing the
 # second and thus fail 5 times, saturating the retrace_count. Instead a
-# bridge back to the preamble of the first loop is produced. A guard in
-# this bridge is later traced resulting in a retrace of the second 
loop.
-# Thus we end up with:
-#   1 preamble and 1 specialized version of first loop
-#   1 preamble and 2 specialized version of second loop
-self.check_jitcell_token_count(2 + 3)
+# bridge back to the preamble of the first loop is produced. 
+self.check_trace_count(6)
 
 # FIXME: Add a gloabl retrace counter and test that we are not trying 
more than 5 times.
 
@@ -2704,10 +2702,12 @@
 
 res = self.meta_interp(g, [10])
 assert res == g(10)
-# 1 preamble and 6 speciealized versions of each loop
-for loop in get_stats().loops:
-assert 
len(loop.operations[0].getdescr().targeting_jitcell_token.target_tokens) = 7
-
+
+self.check_jitcell_token_count(2)
+for cell in get_stats().jitcell_tokens:
+# Initialal trace with two labels and 5 retraces
+assert len(cell.target_tokens) = 7
+
 def test_nested_retrace(self):
 
 myjitdriver = JitDriver(greens = ['pc'], reds = ['n', 'a', 'i', 'j', 
'sa'])
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy jit-targets: fix tests

2011-11-08 Thread hakanardo
Author: Hakan Ardo ha...@debian.org
Branch: jit-targets
Changeset: r48946:b449ace83c77
Date: 2011-11-08 15:25 +0100
http://bitbucket.org/pypy/pypy/changeset/b449ace83c77/

Log:fix tests

diff --git a/pypy/jit/metainterp/test/test_ajit.py 
b/pypy/jit/metainterp/test/test_ajit.py
--- a/pypy/jit/metainterp/test/test_ajit.py
+++ b/pypy/jit/metainterp/test/test_ajit.py
@@ -3149,7 +3149,7 @@
 return sa
 res = self.meta_interp(f, [32])
 assert res == f(32)
-self.check_jitcell_token_count(3)
+self.check_trace_count(2)
 
 def test_two_loopinvariant_arrays2(self):
 from pypy.rpython.lltypesystem import lltype, llmemory, rffi
@@ -3172,7 +3172,7 @@
 return sa
 res = self.meta_interp(f, [32])
 assert res == f(32)
-self.check_jitcell_token_count(3)
+self.check_trace_count(2)
 
 def test_two_loopinvariant_arrays3(self):
 from pypy.rpython.lltypesystem import lltype, llmemory, rffi
@@ -3196,7 +3196,7 @@
 return sa
 res = self.meta_interp(f, [32])
 assert res == f(32)
-self.check_jitcell_token_count(2)
+self.check_trace_count(3)
 
 def test_two_loopinvariant_arrays_boxed(self):
 class A(object):
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy jit-targets: indent

2011-11-08 Thread hakanardo
Author: Hakan Ardo ha...@debian.org
Branch: jit-targets
Changeset: r48945:7d76cfa50b41
Date: 2011-11-08 15:14 +0100
http://bitbucket.org/pypy/pypy/changeset/7d76cfa50b41/

Log:indent

diff --git a/pypy/jit/metainterp/optimizeopt/unroll.py 
b/pypy/jit/metainterp/optimizeopt/unroll.py
--- a/pypy/jit/metainterp/optimizeopt/unroll.py
+++ b/pypy/jit/metainterp/optimizeopt/unroll.py
@@ -510,34 +510,34 @@
 pass
 target.virtual_state.debug_print(debugmsg, bad)
 
-if ok:
-debug_stop('jit-log-virtualstate')
+if ok:
+debug_stop('jit-log-virtualstate')
 
-values = [self.getvalue(arg)
-  for arg in jumpop.getarglist()]
-args = target.virtual_state.make_inputargs(values, self.optimizer,
-   keyboxes=True)
-short_inputargs = target.short_preamble[0].getarglist()
-inliner = Inliner(short_inputargs, args)
+values = [self.getvalue(arg)
+  for arg in jumpop.getarglist()]
+args = target.virtual_state.make_inputargs(values, 
self.optimizer,
+   keyboxes=True)
+short_inputargs = target.short_preamble[0].getarglist()
+inliner = Inliner(short_inputargs, args)
 
-for guard in extra_guards:
-if guard.is_guard():
-descr = target.start_resumedescr.clone_if_mutable()
-inliner.inline_descr_inplace(descr)
-guard.setdescr(descr)
-self.optimizer.send_extra_operation(guard)
+for guard in extra_guards:
+if guard.is_guard():
+descr = target.start_resumedescr.clone_if_mutable()
+inliner.inline_descr_inplace(descr)
+guard.setdescr(descr)
+self.optimizer.send_extra_operation(guard)
 
-try:
-for shop in target.short_preamble[1:]:
-newop = inliner.inline_op(shop)
-self.optimizer.send_extra_operation(newop)
-except InvalidLoop:
-debug_print(Inlining failed unexpectedly,
-jumping to preamble instead)
-assert cell_token.target_tokens[0].virtual_state is None
-jumpop.setdescr(cell_token.target_tokens[0])
-self.optimizer.send_extra_operation(jumpop)
-return True
+try:
+for shop in target.short_preamble[1:]:
+newop = inliner.inline_op(shop)
+self.optimizer.send_extra_operation(newop)
+except InvalidLoop:
+debug_print(Inlining failed unexpectedly,
+jumping to preamble instead)
+assert cell_token.target_tokens[0].virtual_state is None
+jumpop.setdescr(cell_token.target_tokens[0])
+self.optimizer.send_extra_operation(jumpop)
+return True
 debug_stop('jit-log-virtualstate')
 
 if self.did_import:
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy jit-refactor-tests: convreted tests

2011-11-08 Thread hakanardo
Author: Hakan Ardo ha...@debian.org
Branch: jit-refactor-tests
Changeset: r48952:5b50039bad35
Date: 2011-11-08 16:39 +0100
http://bitbucket.org/pypy/pypy/changeset/5b50039bad35/

Log:convreted tests

diff --git a/pypy/jit/metainterp/test/test_del.py 
b/pypy/jit/metainterp/test/test_del.py
--- a/pypy/jit/metainterp/test/test_del.py
+++ b/pypy/jit/metainterp/test/test_del.py
@@ -20,12 +20,12 @@
 n -= 1
 return 42
 self.meta_interp(f, [20])
-self.check_loops({'call': 2,  # calls to a helper function
-  'guard_no_exception': 2,# follows the calls
-  'int_sub': 1,
-  'int_gt': 1,
-  'guard_true': 1,
-  'jump': 1})
+self.check_resops({'call': 4,  # calls to a helper function
+   'guard_no_exception': 4,# follows the calls
+   'int_sub': 2,
+   'int_gt': 2,
+   'guard_true': 2,
+   'jump': 2})
 
 def test_class_of_allocated(self):
 myjitdriver = JitDriver(greens = [], reds = ['n', 'x'])
@@ -78,7 +78,7 @@
 return 1
 res = self.meta_interp(f, [20], enable_opts='')
 assert res == 1
-self.check_loops(call=1)   # for the case B(), but not for the case A()
+self.check_resops(call=1)   # for the case B(), but not for the case 
A()
 
 
 class TestLLtype(DelTests, LLJitMixin):
@@ -103,7 +103,7 @@
 break
 return 42
 self.meta_interp(f, [20])
-self.check_loops(getfield_raw=1, setfield_raw=1, call=0, call_pure=0)
+self.check_resops(call_pure=0, setfield_raw=2, call=0, getfield_raw=2)
 
 class TestOOtype(DelTests, OOJitMixin):
 def setup_class(cls):
diff --git a/pypy/jit/metainterp/test/test_dict.py 
b/pypy/jit/metainterp/test/test_dict.py
--- a/pypy/jit/metainterp/test/test_dict.py
+++ b/pypy/jit/metainterp/test/test_dict.py
@@ -91,7 +91,7 @@
 res1 = f(100)
 res2 = self.meta_interp(f, [100], listops=True)
 assert res1 == res2
-self.check_loops(int_mod=1) # the hash was traced and eq, but cached
+self.check_resops(int_mod=2) # the hash was traced and eq, but cached
 
 def test_dict_setdefault(self):
 myjitdriver = JitDriver(greens = [], reds = ['total', 'dct'])
@@ -107,7 +107,7 @@
 assert f(100) == 50
 res = self.meta_interp(f, [100], listops=True)
 assert res == 50
-self.check_loops(new=0, new_with_vtable=0)
+self.check_resops(new=0, new_with_vtable=0)
 
 def test_dict_as_counter(self):
 myjitdriver = JitDriver(greens = [], reds = ['total', 'dct'])
@@ -128,7 +128,7 @@
 assert f(100) == 50
 res = self.meta_interp(f, [100], listops=True)
 assert res == 50
-self.check_loops(int_mod=1) # key + eq, but cached
+self.check_resops(int_mod=2) # key + eq, but cached
 
 def test_repeated_lookup(self):
 myjitdriver = JitDriver(greens = [], reds = ['n', 'd'])
@@ -153,12 +153,13 @@
 
 res = self.meta_interp(f, [100], listops=True)
 assert res == f(50)
-self.check_loops({call: 5, getfield_gc: 1, getinteriorfield_gc: 
1,
-  guard_false: 1, guard_no_exception: 4,
-  guard_true: 1, int_and: 1, int_gt: 1,
-  int_is_true: 1, int_sub: 1, jump: 1,
-  new_with_vtable: 1, new: 1, new_array: 1,
-  setfield_gc: 3, })
+self.check_resops({'new_array': 2, 'getfield_gc': 2,
+   'guard_true': 2, 'jump': 2,
+   'new_with_vtable': 2, 'getinteriorfield_gc': 2,
+   'setfield_gc': 6, 'int_gt': 2, 'int_sub': 2,
+   'call': 10, 'int_and': 2,
+   'guard_no_exception': 8, 'new': 2,
+   'guard_false': 2, 'int_is_true': 2})
 
 
 class TestOOtype(DictTests, OOJitMixin):
diff --git a/pypy/jit/metainterp/test/test_fficall.py 
b/pypy/jit/metainterp/test/test_fficall.py
--- a/pypy/jit/metainterp/test/test_fficall.py
+++ b/pypy/jit/metainterp/test/test_fficall.py
@@ -68,23 +68,23 @@
  'byval': False}
 supported = all(d[check] for check in jitif)
 if supported:
-self.check_loops(
-call_release_gil=1,   # a CALL_RELEASE_GIL, and no other CALLs
+self.check_resops(
+call_release_gil=2,   # a CALL_RELEASE_GIL, and no other CALLs
 call=0,
 call_may_force=0,
-guard_no_exception=1,
-guard_not_forced=1,
-int_add=1,
-int_lt=1,
-guard_true=1,
-jump=1)
+guard_no_exception=2,
+

[pypy-commit] pypy jit-refactor-tests: converted test

2011-11-08 Thread hakanardo
Author: Hakan Ardo ha...@debian.org
Branch: jit-refactor-tests
Changeset: r48947:9021a2a814b1
Date: 2011-11-08 15:40 +0100
http://bitbucket.org/pypy/pypy/changeset/9021a2a814b1/

Log:converted test

diff --git a/pypy/jit/metainterp/test/test_string.py 
b/pypy/jit/metainterp/test/test_string.py
--- a/pypy/jit/metainterp/test/test_string.py
+++ b/pypy/jit/metainterp/test/test_string.py
@@ -168,12 +168,11 @@
 return 42
 self.meta_interp(f, [6, 7])
 if _str is str:
-self.check_loops(newstr=1, strsetitem=0, copystrcontent=2,
- call=1, call_pure=0)   # escape
+self.check_resops(call_pure=0, copystrcontent=4,
+  strsetitem=0, call=2, newstr=2)
 else:
-self.check_loops(newunicode=1, unicodesetitem=0,
- copyunicodecontent=2,
- call=1, call_pure=0)   # escape
+self.check_resops(call_pure=0, unicodesetitem=0, call=2,
+  copyunicodecontent=4, newunicode=2)
 
 def test_strconcat_escape_str_char(self):
 _str, _chr = self._str, self._chr
@@ -192,12 +191,11 @@
 return 42
 self.meta_interp(f, [6, 7])
 if _str is str:
-self.check_loops(newstr=1, strsetitem=1, copystrcontent=1,
- call=1, call_pure=0)   # escape
+self.check_resops(call_pure=0, copystrcontent=2, strsetitem=2,
+  call=2, newstr=2)
 else:
-self.check_loops(newunicode=1, unicodesetitem=1,
- copyunicodecontent=1,
- call=1, call_pure=0)   # escape
+self.check_resops(call_pure=0, unicodesetitem=2, call=2,
+  copyunicodecontent=2, newunicode=2)
 
 def test_strconcat_escape_char_str(self):
 _str, _chr = self._str, self._chr
@@ -216,12 +214,11 @@
 return 42
 self.meta_interp(f, [6, 7])
 if _str is str:
-self.check_loops(newstr=1, strsetitem=1, copystrcontent=1,
- call=1, call_pure=0)   # escape
+self.check_resops(call_pure=0, copystrcontent=2,
+  strsetitem=2, call=2, newstr=2)
 else:
-self.check_loops(newunicode=1, unicodesetitem=1,
- copyunicodecontent=1,
- call=1, call_pure=0)   # escape
+self.check_resops(call_pure=0, unicodesetitem=2, call=2,
+  copyunicodecontent=2, newunicode=2)
 
 def test_strconcat_escape_char_char(self):
 _str, _chr = self._str, self._chr
@@ -239,12 +236,11 @@
 return 42
 self.meta_interp(f, [6, 7])
 if _str is str:
-self.check_loops(newstr=1, strsetitem=2, copystrcontent=0,
- call=1, call_pure=0)   # escape
+self.check_resops(call_pure=0, copystrcontent=0,
+  strsetitem=4, call=2, newstr=2)
 else:
-self.check_loops(newunicode=1, unicodesetitem=2,
- copyunicodecontent=0,
- call=1, call_pure=0)   # escape
+self.check_resops(call_pure=0, unicodesetitem=4, call=2,
+  copyunicodecontent=0, newunicode=2)
 
 def test_strconcat_escape_str_char_str(self):
 _str, _chr = self._str, self._chr
@@ -263,12 +259,11 @@
 return 42
 self.meta_interp(f, [6, 7])
 if _str is str:
-self.check_loops(newstr=1, strsetitem=1, copystrcontent=2,
- call=1, call_pure=0)   # escape
+self.check_resops(call_pure=0, copystrcontent=4, strsetitem=2,
+  call=2, newstr=2)
 else:
-self.check_loops(newunicode=1, unicodesetitem=1,
- copyunicodecontent=2,
- call=1, call_pure=0)   # escape
+self.check_resops(call_pure=0, unicodesetitem=2, call=2,
+  copyunicodecontent=4, newunicode=2)
 
 def test_strconcat_guard_fail(self):
 _str = self._str
@@ -325,7 +320,7 @@
 m -= 1
 return 42
 self.meta_interp(f, [6, 7])
-self.check_loops(newstr=0, newunicode=0)
+self.check_resops(newunicode=0, newstr=0)
 
 def test_str_slice_len_surviving(self):
 _str = self._str
@@ -504,9 +499,9 @@
 sys.defaultencoding = _str('utf-8')
 return sa
 assert self.meta_interp(f, [8]) == f(8)
-self.check_loops({'int_add': 1, 'guard_true': 1, 'int_sub': 1,
-  'jump': 1, 'int_is_true': 1,
-  'guard_not_invalidated': 1})
+self.check_resops({'jump': 2, 'int_is_true': 2, 'int_add': 2,
+

[pypy-commit] pypy jit-refactor-tests: converted test

2011-11-08 Thread hakanardo
Author: Hakan Ardo ha...@debian.org
Branch: jit-refactor-tests
Changeset: r48948:280c132cc8a4
Date: 2011-11-08 15:52 +0100
http://bitbucket.org/pypy/pypy/changeset/280c132cc8a4/

Log:converted test

diff --git a/pypy/jit/metainterp/test/test_virtualizable.py 
b/pypy/jit/metainterp/test/test_virtualizable.py
--- a/pypy/jit/metainterp/test/test_virtualizable.py
+++ b/pypy/jit/metainterp/test/test_virtualizable.py
@@ -77,7 +77,7 @@
 return xy.inst_x
 res = self.meta_interp(f, [20])
 assert res == 30
-self.check_loops(getfield_gc=0, setfield_gc=0)
+self.check_resops(setfield_gc=0, getfield_gc=0)
 
 def test_preexisting_access_2(self):
 myjitdriver = JitDriver(greens = [], reds = ['n', 'xy'],
@@ -102,7 +102,7 @@
 assert f(5) == 185
 res = self.meta_interp(f, [5])
 assert res == 185
-self.check_loops(getfield_gc=0, setfield_gc=0)
+self.check_resops(setfield_gc=0, getfield_gc=0)
 
 def test_two_paths_access(self):
 myjitdriver = JitDriver(greens = [], reds = ['n', 'xy'],
@@ -124,7 +124,7 @@
 return xy.inst_x
 res = self.meta_interp(f, [18])
 assert res == 10118
-self.check_loops(getfield_gc=0, setfield_gc=0)
+self.check_resops(setfield_gc=0, getfield_gc=0)
 
 def test_synchronize_in_return(self):
 myjitdriver = JitDriver(greens = [], reds = ['n', 'xy'],
@@ -146,7 +146,7 @@
 return xy.inst_x
 res = self.meta_interp(f, [18])
 assert res == 10180
-self.check_loops(getfield_gc=0, setfield_gc=0)
+self.check_resops(setfield_gc=0, getfield_gc=0)
 
 def test_virtualizable_and_greens(self):
 myjitdriver = JitDriver(greens = ['m'], reds = ['n', 'xy'],
@@ -174,7 +174,7 @@
 return res
 res = self.meta_interp(f, [40])
 assert res == 50 * 4
-self.check_loops(getfield_gc=0, setfield_gc=0)
+self.check_resops(setfield_gc=0, getfield_gc=0)
 
 def test_double_frame(self):
 myjitdriver = JitDriver(greens = [], reds = ['n', 'xy', 'other'],
@@ -197,8 +197,7 @@
 return xy.inst_x
 res = self.meta_interp(f, [20])
 assert res == 134
-self.check_loops(getfield_gc=0, setfield_gc=1)
-self.check_loops(getfield_gc=1, setfield_gc=2, everywhere=True)
+self.check_resops(setfield_gc=2, getfield_gc=1)
 
 # --
 
@@ -248,8 +247,8 @@
 return xy2.inst_l1[2]
 res = self.meta_interp(f, [16])
 assert res == 3001 + 16 * 80
-self.check_loops(getfield_gc=0, setfield_gc=0,
- getarrayitem_gc=0, setarrayitem_gc=0)
+self.check_resops(setarrayitem_gc=0, setfield_gc=0,
+  getarrayitem_gc=0, getfield_gc=0)
 
 def test_synchronize_arrays_in_return(self):
 myjitdriver = JitDriver(greens = [], reds = ['n', 'xy2'],
@@ -279,8 +278,7 @@
 assert f(18) == 10360
 res = self.meta_interp(f, [18])
 assert res == 10360
-self.check_loops(getfield_gc=0, setfield_gc=0,
- getarrayitem_gc=0)
+self.check_resops(setfield_gc=0, getarrayitem_gc=0, getfield_gc=0)
 
 def test_array_length(self):
 myjitdriver = JitDriver(greens = [], reds = ['n', 'xy2'],
@@ -306,8 +304,8 @@
 return xy2.inst_l1[1]
 res = self.meta_interp(f, [18])
 assert res == 2941309 + 18
-self.check_loops(getfield_gc=0, setfield_gc=0,
- getarrayitem_gc=0, arraylen_gc=0)
+self.check_resops(setfield_gc=0, getarrayitem_gc=0,
+  arraylen_gc=0, getfield_gc=0)
 
 def test_residual_function(self):
 myjitdriver = JitDriver(greens = [], reds = ['n', 'xy2'],
@@ -340,8 +338,8 @@
 return xy2.inst_l1[1]
 res = self.meta_interp(f, [18])
 assert res == 2941309 + 18
-self.check_loops(getfield_gc=0, setfield_gc=0,
- getarrayitem_gc=0, arraylen_gc=1, call=1)
+self.check_resops(call=2, setfield_gc=0, getarrayitem_gc=0,
+  arraylen_gc=2, getfield_gc=0)
 
 def test_double_frame_array(self):
 myjitdriver = JitDriver(greens = [], reds = ['n', 'xy2', 'other'],
@@ -377,8 +375,8 @@
 expected = f(20)
 res = self.meta_interp(f, [20], enable_opts='')
 assert res == expected
-self.check_loops(getfield_gc=1, setfield_gc=0,
- arraylen_gc=1, getarrayitem_gc=1, setarrayitem_gc=1)
+self.check_resops(setarrayitem_gc=1, setfield_gc=0,
+  getarrayitem_gc=1, arraylen_gc=1, getfield_gc=1)
 
 # --
 
@@ -425,8 +423,7 @@
 assert f(18) == 10360
 res = self.meta_interp(f, [18])
 assert res == 10360
-self.check_loops(getfield_gc=0, setfield_gc=0,
- 

[pypy-commit] pypy jit-refactor-tests: fix indentation

2011-11-08 Thread hakanardo
Author: Hakan Ardo ha...@debian.org
Branch: jit-refactor-tests
Changeset: r48949:42eb7a0e
Date: 2011-11-08 15:55 +0100
http://bitbucket.org/pypy/pypy/changeset/42eb7a0e/

Log:fix indentation

diff --git a/pypy/jit/metainterp/test/test_virtualizable.py 
b/pypy/jit/metainterp/test/test_virtualizable.py
--- a/pypy/jit/metainterp/test/test_virtualizable.py
+++ b/pypy/jit/metainterp/test/test_virtualizable.py
@@ -1095,39 +1095,39 @@
 self.check_resops(new_with_vtable=0)
 
 def test_check_for_nonstandardness_only_once(self):
- myjitdriver = JitDriver(greens = [], reds = ['frame'],
- virtualizables = ['frame'])
+myjitdriver = JitDriver(greens = [], reds = ['frame'],
+virtualizables = ['frame'])
 
- class Frame(object):
- _virtualizable2_ = ['x', 'y', 'z']
+class Frame(object):
+_virtualizable2_ = ['x', 'y', 'z']
 
- def __init__(self, x, y, z=1):
- self = hint(self, access_directly=True)
- self.x = x
- self.y = y
- self.z = z
+def __init__(self, x, y, z=1):
+self = hint(self, access_directly=True)
+self.x = x
+self.y = y
+self.z = z
 
- class SomewhereElse:
- pass
- somewhere_else = SomewhereElse()
+class SomewhereElse:
+pass
+somewhere_else = SomewhereElse()
 
- def f(n):
- frame = Frame(n, 0)
- somewhere_else.top_frame = frame# escapes
- frame = hint(frame, access_directly=True)
- while frame.x  0:
- myjitdriver.can_enter_jit(frame=frame)
- myjitdriver.jit_merge_point(frame=frame)
- top_frame = somewhere_else.top_frame
- child_frame = Frame(frame.x, top_frame.z, 17)
- frame.y += child_frame.x
- frame.x -= top_frame.z
- return somewhere_else.top_frame.y
- 
- res = self.meta_interp(f, [10])
- assert res == 55
- self.check_resops(new_with_vtable=0, ptr_eq=1)
- self.check_history(ptr_eq=2)
+def f(n):
+frame = Frame(n, 0)
+somewhere_else.top_frame = frame# escapes
+frame = hint(frame, access_directly=True)
+while frame.x  0:
+myjitdriver.can_enter_jit(frame=frame)
+myjitdriver.jit_merge_point(frame=frame)
+top_frame = somewhere_else.top_frame
+child_frame = Frame(frame.x, top_frame.z, 17)
+frame.y += child_frame.x
+frame.x -= top_frame.z
+return somewhere_else.top_frame.y
+
+res = self.meta_interp(f, [10])
+assert res == 55
+self.check_resops(new_with_vtable=0, ptr_eq=1)
+self.check_history(ptr_eq=2)
 
 def test_virtual_child_frame_with_arrays(self):
 myjitdriver = JitDriver(greens = [], reds = ['frame'],
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy jit-refactor-tests: converted test

2011-11-08 Thread hakanardo
Author: Hakan Ardo ha...@debian.org
Branch: jit-refactor-tests
Changeset: r48950:4f2ecb448124
Date: 2011-11-08 16:03 +0100
http://bitbucket.org/pypy/pypy/changeset/4f2ecb448124/

Log:converted test

diff --git a/pypy/jit/metainterp/test/test_quasiimmut.py 
b/pypy/jit/metainterp/test/test_quasiimmut.py
--- a/pypy/jit/metainterp/test/test_quasiimmut.py
+++ b/pypy/jit/metainterp/test/test_quasiimmut.py
@@ -73,8 +73,7 @@
 #
 res = self.meta_interp(f, [100, 7])
 assert res == 700
-self.check_loops(guard_not_invalidated=2, getfield_gc=0,
- everywhere=True)
+self.check_resops(guard_not_invalidated=2, getfield_gc=0)
 #
 from pypy.jit.metainterp.warmspot import get_stats
 loops = get_stats().loops
@@ -103,7 +102,7 @@
 assert f(100, 7) == 721
 res = self.meta_interp(f, [100, 7])
 assert res == 721
-self.check_loops(guard_not_invalidated=0, getfield_gc=1)
+self.check_resops(guard_not_invalidated=0, getfield_gc=3)
 #
 from pypy.jit.metainterp.warmspot import get_stats
 loops = get_stats().loops
@@ -134,8 +133,7 @@
 #
 res = self.meta_interp(f, [100, 7])
 assert res == 700
-self.check_loops(guard_not_invalidated=2, getfield_gc=0,
- everywhere=True)
+self.check_resops(guard_not_invalidated=2, getfield_gc=0)
 
 def test_change_during_tracing_1(self):
 myjitdriver = JitDriver(greens=['foo'], reds=['x', 'total'])
@@ -160,7 +158,7 @@
 assert f(100, 7) == 721
 res = self.meta_interp(f, [100, 7])
 assert res == 721
-self.check_loops(guard_not_invalidated=0, getfield_gc=1)
+self.check_resops(guard_not_invalidated=0, getfield_gc=2)
 
 def test_change_during_tracing_2(self):
 myjitdriver = JitDriver(greens=['foo'], reds=['x', 'total'])
@@ -186,7 +184,7 @@
 assert f(100, 7) == 700
 res = self.meta_interp(f, [100, 7])
 assert res == 700
-self.check_loops(guard_not_invalidated=0, getfield_gc=1)
+self.check_resops(guard_not_invalidated=0, getfield_gc=2)
 
 def test_change_invalidate_reentering(self):
 myjitdriver = JitDriver(greens=['foo'], reds=['x', 'total'])
@@ -212,7 +210,7 @@
 assert g(100, 7) == 700707
 res = self.meta_interp(g, [100, 7])
 assert res == 700707
-self.check_loops(guard_not_invalidated=2, getfield_gc=0)
+self.check_resops(guard_not_invalidated=4, getfield_gc=0)
 
 def test_invalidate_while_running(self):
 jitdriver = JitDriver(greens=['foo'], reds=['i', 'total'])
@@ -324,8 +322,8 @@
 assert f(100, 15) == 3009
 res = self.meta_interp(f, [100, 15])
 assert res == 3009
-self.check_loops(guard_not_invalidated=4, getfield_gc=0,
- call_may_force=0, guard_not_forced=0)
+self.check_resops(guard_not_invalidated=8, guard_not_forced=0,
+  call_may_force=0, getfield_gc=0)
 
 def test_list_simple_1(self):
 myjitdriver = JitDriver(greens=['foo'], reds=['x', 'total'])
@@ -347,9 +345,8 @@
 #
 res = self.meta_interp(f, [100, 7])
 assert res == 700
-self.check_loops(guard_not_invalidated=2, getfield_gc=0,
- getarrayitem_gc=0, getarrayitem_gc_pure=0,
- everywhere=True)
+self.check_resops(getarrayitem_gc_pure=0, guard_not_invalidated=2,
+  getarrayitem_gc=0, getfield_gc=0)
 #
 from pypy.jit.metainterp.warmspot import get_stats
 loops = get_stats().loops
@@ -385,9 +382,8 @@
 #
 res = self.meta_interp(f, [100, 7])
 assert res == 714
-self.check_loops(guard_not_invalidated=2, getfield_gc=0,
- getarrayitem_gc=0, getarrayitem_gc_pure=0,
- arraylen_gc=0, everywhere=True)
+self.check_resops(getarrayitem_gc_pure=0, guard_not_invalidated=2,
+  arraylen_gc=0, getarrayitem_gc=0, getfield_gc=0)
 #
 from pypy.jit.metainterp.warmspot import get_stats
 loops = get_stats().loops
@@ -421,9 +417,8 @@
 #
 res = self.meta_interp(f, [100, 7])
 assert res == 700
-self.check_loops(guard_not_invalidated=2, getfield_gc=0,
- getarrayitem_gc=0, getarrayitem_gc_pure=0,
- everywhere=True)
+self.check_resops(guard_not_invalidated=2, getfield_gc=0,
+  getarrayitem_gc=0, getarrayitem_gc_pure=0)
 #
 from pypy.jit.metainterp.warmspot import get_stats
 loops = get_stats().loops
@@ -460,9 +455,9 @@
 assert f(100, 15) == 3009
 res = self.meta_interp(f, [100, 15])
 assert res == 3009
-self.check_loops(guard_not_invalidated=4, getfield_gc=0,
-  

[pypy-commit] pypy jit-refactor-tests: converted test

2011-11-08 Thread hakanardo
Author: Hakan Ardo ha...@debian.org
Branch: jit-refactor-tests
Changeset: r48951:88ca4d9cb01f
Date: 2011-11-08 16:07 +0100
http://bitbucket.org/pypy/pypy/changeset/88ca4d9cb01f/

Log:converted test

diff --git a/pypy/jit/metainterp/test/test_virtualref.py 
b/pypy/jit/metainterp/test/test_virtualref.py
--- a/pypy/jit/metainterp/test/test_virtualref.py
+++ b/pypy/jit/metainterp/test/test_virtualref.py
@@ -171,7 +171,7 @@
 return 1
 #
 self.meta_interp(f, [10])
-self.check_loops(new_with_vtable=1)   # the vref
+self.check_resops(new_with_vtable=2) # the vref
 self.check_aborted_count(0)
 
 def test_simple_all_removed(self):
@@ -205,8 +205,7 @@
 virtual_ref_finish(vref, xy)
 #
 self.meta_interp(f, [15])
-self.check_loops(new_with_vtable=0, # all virtualized
- new_array=0)
+self.check_resops(new_with_vtable=0, new_array=0)
 self.check_aborted_count(0)
 
 def test_simple_no_access(self):
@@ -242,7 +241,7 @@
 virtual_ref_finish(vref, xy)
 #
 self.meta_interp(f, [15])
-self.check_loops(new_with_vtable=1, # the vref: xy doesn't need to 
be forced
+self.check_resops(new_with_vtable=2, # the vref: xy doesn't need 
to be forced
  new_array=0)   # and neither xy.next1/2/3
 self.check_aborted_count(0)
 
@@ -280,8 +279,8 @@
 exctx.topframeref = vref_None
 #
 self.meta_interp(f, [15])
-self.check_loops(new_with_vtable=2,   # XY(), the vref
- new_array=3) # next1/2/3
+self.check_resops(new_with_vtable=4,   # XY(), the vref
+  new_array=6) # next1/2/3
 self.check_aborted_count(0)
 
 def test_simple_force_sometimes(self):
@@ -320,8 +319,8 @@
 #
 res = self.meta_interp(f, [30])
 assert res == 13
-self.check_loops(new_with_vtable=1,   # the vref, but not XY()
- new_array=0) # and neither next1/2/3
+self.check_resops(new_with_vtable=2,   # the vref, but not XY()
+  new_array=0) # and neither next1/2/3
 self.check_loop_count(1)
 self.check_aborted_count(0)
 
@@ -362,7 +361,7 @@
 #
 res = self.meta_interp(f, [30])
 assert res == 13
-self.check_loops(new_with_vtable=0, # all virtualized in the n!=13 loop
+self.check_resops(new_with_vtable=0, # all virtualized in the n!=13 
loop
  new_array=0)
 self.check_loop_count(1)
 self.check_aborted_count(0)
@@ -412,7 +411,7 @@
 res = self.meta_interp(f, [72])
 assert res == 6
 self.check_loop_count(2) # the loop and the bridge
-self.check_loops(new_with_vtable=2,  # loop: nothing; bridge: vref, xy
+self.check_resops(new_with_vtable=2,  # loop: nothing; bridge: vref, xy
  new_array=2)# bridge: next4, next5
 self.check_aborted_count(0)
 
@@ -442,8 +441,8 @@
 #
 res = self.meta_interp(f, [15])
 assert res == 1
-self.check_loops(new_with_vtable=2, # vref, xy
- new_array=1)   # next1
+self.check_resops(new_with_vtable=4, # vref, xy
+  new_array=2)   # next1
 self.check_aborted_count(0)
 
 def test_recursive_call_1(self):
@@ -543,7 +542,7 @@
 #
 res = self.meta_interp(f, [15])
 assert res == 1
-self.check_loops(new_with_vtable=2) # vref, xy
+self.check_resops(new_with_vtable=4) # vref, xy
 
 def test_cannot_use_invalid_virtualref(self):
 myjitdriver = JitDriver(greens = [], reds = ['n'])
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: Convert from __nonzero__ to __bool__.

2011-11-08 Thread alex_gaynor
Author: Alex Gaynor alex.gay...@gmail.com
Branch: py3k
Changeset: r48953:442dd206f22d
Date: 2011-11-08 11:25 -0500
http://bitbucket.org/pypy/pypy/changeset/442dd206f22d/

Log:Convert from __nonzero__ to __bool__.

diff --git a/lib_pypy/_ctypes/function.py b/lib_pypy/_ctypes/function.py
--- a/lib_pypy/_ctypes/function.py
+++ b/lib_pypy/_ctypes/function.py
@@ -157,11 +157,11 @@
 callable(restype)):
 raise TypeError(restype must be a type, a callable, or None)
 self._restype_ = restype
-
+
 def _delrestype(self):
 self._ptr = None
 del self._restype_
-
+
 restype = property(_getrestype, _setrestype, _delrestype)
 
 def _geterrcheck(self):
@@ -221,7 +221,7 @@
 self._check_argtypes_for_fastpath()
 return
 
-
+
 # A callback into python
 if callable(argument) and not argsl:
 self.callable = argument
@@ -274,7 +274,7 @@
 for argtype, arg in zip(argtypes, args)]
 return to_call(*args)
 return f
-
+
 def __call__(self, *args, **kwargs):
 argtypes = self._argtypes_
 if self.callable is not None:
@@ -405,7 +405,7 @@
 ffiargs = [argtype.get_ffi_argtype() for argtype in argtypes]
 ffires = restype.get_ffi_argtype()
 return _ffi.FuncPtr.fromaddr(ptr, '', ffiargs, ffires)
-
+
 cdll = self.dll._handle
 try:
 ffi_argtypes = [argtype.get_ffi_argtype() for argtype in argtypes]
@@ -439,7 +439,7 @@
 if isinstance(argtype, _CDataMeta):
 cobj, ffiparam = argtype.get_ffi_param(arg)
 return cobj, ffiparam, argtype
-
+
 if argtype is not None:
 arg = argtype.from_param(arg)
 if hasattr(arg, '_as_parameter_'):
@@ -570,7 +570,7 @@
 @staticmethod
 def _is_primitive(argtype):
 return argtype.__bases__[0] is _SimpleCData
-
+
 def _wrap_result(self, restype, result):
 
 Convert from low-level repr of the result to the high-level python
@@ -630,7 +630,7 @@
 
 return retval
 
-def __nonzero__(self):
+def __bool__(self):
 return self._com_index is not None or bool(self._buffer[0])
 
 def __del__(self):
diff --git a/lib_pypy/_ctypes/pointer.py b/lib_pypy/_ctypes/pointer.py
--- a/lib_pypy/_ctypes/pointer.py
+++ b/lib_pypy/_ctypes/pointer.py
@@ -111,7 +111,7 @@
 store_reference(self, index, cobj._objects)
 self._subarray(index)[0] = cobj._get_buffer_value()
 
-def __nonzero__(self):
+def __bool__(self):
 return self._buffer[0] != 0
 
 contents = property(getcontents, setcontents)
diff --git a/lib_pypy/_ctypes/primitive.py b/lib_pypy/_ctypes/primitive.py
--- a/lib_pypy/_ctypes/primitive.py
+++ b/lib_pypy/_ctypes/primitive.py
@@ -186,8 +186,8 @@
 elif value is None:
 value = 0
 self._buffer[0] = value
-result.value = property(_getvalue, _setvalue)
-
+result.value = property(_getvalue, _setvalue)
+
 elif tp == 'u':
 def _setvalue(self, val):
 if isinstance(val, str):
@@ -264,7 +264,7 @@
 def _as_ffi_pointer_(self, ffitype):
 return as_ffi_pointer(self, ffitype)
 result._as_ffi_pointer_ = _as_ffi_pointer_
-
+
 return result
 
 from_address = cdata_from_address
@@ -272,7 +272,7 @@
 def from_param(self, value):
 if isinstance(value, self):
 return value
-
+
 from_param_f = FROM_PARAM_BY_TYPE.get(self._type_)
 if from_param_f:
 res = from_param_f(self, value)
@@ -291,7 +291,7 @@
 if self.__bases__[0] is _SimpleCData:
 return output.value
 return output
-
+
 def _sizeofinstances(self):
 return _rawffi.sizeof(self._type_)
 
@@ -338,7 +338,7 @@
 return %s object at 0x%x % (type(self).__name__,
 id(self))
 
-def __nonzero__(self):
+def __bool__(self):
 return self._buffer[0] not in (0, '\x00')
 
 from _ctypes.function import CFuncPtr
diff --git a/lib_pypy/greenlet.py b/lib_pypy/greenlet.py
--- a/lib_pypy/greenlet.py
+++ b/lib_pypy/greenlet.py
@@ -87,7 +87,7 @@
 else:
 return args
 
-def __nonzero__(self):
+def __bool__(self):
 return self.__main or _continulet.is_pending(self)
 
 @property
diff --git a/pypy/interpreter/baseobjspace.py b/pypy/interpreter/baseobjspace.py
--- a/pypy/interpreter/baseobjspace.py
+++ b/pypy/interpreter/baseobjspace.py
@@ -1483,7 +1483,7 @@
 ('trunc',   'trunc', 1, ['__trunc__']),
 ('pos', 'pos',   1, ['__pos__']),
 ('neg', 'neg',   1, ['__neg__']),
-('nonzero', 'truth', 1, ['__nonzero__']),
+

[pypy-commit] pypy py3k: merged upstream

2011-11-08 Thread alex_gaynor
Author: Alex Gaynor alex.gay...@gmail.com
Branch: py3k
Changeset: r48954:5c7c60f852c7
Date: 2011-11-08 11:26 -0500
http://bitbucket.org/pypy/pypy/changeset/5c7c60f852c7/

Log:merged upstream

diff --git a/pypy/module/_io/test/test_textio.py 
b/pypy/module/_io/test/test_textio.py
--- a/pypy/module/_io/test/test_textio.py
+++ b/pypy/module/_io/test/test_textio.py
@@ -215,6 +215,26 @@
 # that subprocess.Popen() can have the required unbuffered
 # semantics with universal_newlines=True.
 import _io
+raw = self.get_MockRawIO()([b'abc', b'def', b'ghi\njkl\nopq\n'])
+txt = _io.TextIOWrapper(raw, encoding='ascii', newline='\n')
+# Reads
+assert txt.read(4) == 'abcd'
+assert txt.readline() == 'efghi\n'
+assert list(txt) == ['jkl\n', 'opq\n']
+
+def test_rawio_write_through(self):
+# Issue #12591: with write_through=True, writes don't need a flush
+import _io
+raw = self.get_MockRawIO()([b'abc', b'def', b'ghi\njkl\nopq\n'])
+txt = _io.TextIOWrapper(raw, encoding='ascii', newline='\n',
+write_through=True)
+txt.write('1')
+txt.write('23\n4')
+txt.write('5')
+assert b''.join(raw._write_stack) == b'123\n45'
+
+def w_get_MockRawIO(self):
+import _io
 class MockRawIO(_io._RawIOBase):
 def __init__(self, read_stack=()):
 self._read_stack = list(read_stack)
@@ -275,24 +295,7 @@
 except:
 self._extraneous_reads += 1
 return b
-
-raw = MockRawIO([b'abc', b'def', b'ghi\njkl\nopq\n'])
-txt = _io.TextIOWrapper(raw, encoding='ascii', newline='\n')
-# Reads
-assert txt.read(4) == 'abcd'
-assert txt.readline() == 'efghi\n'
-assert list(txt) == ['jkl\n', 'opq\n']
-#
-#def test_rawio_write_through(self):
-## Issue #12591: with write_through=True, writes don't need a flush
-#import _io
-raw = MockRawIO([b'abc', b'def', b'ghi\njkl\nopq\n'])
-txt = _io.TextIOWrapper(raw, encoding='ascii', newline='\n',
-write_through=True)
-txt.write('1')
-txt.write('23\n4')
-txt.write('5')
-assert b''.join(raw._write_stack) == b'123\n45'
+return MockRawIO
 
 
 class AppTestIncrementalNewlineDecoder:
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy ppc-jit-backend: (bivab, hager): Make function descriptor in case of 64 bit for the generated machine code.

2011-11-08 Thread hager
Author: hager sven.ha...@uni-duesseldorf.de
Branch: ppc-jit-backend
Changeset: r48955:dda7336a6e6d
Date: 2011-11-08 08:30 -0800
http://bitbucket.org/pypy/pypy/changeset/dda7336a6e6d/

Log:(bivab, hager): Make function descriptor in case of 64 bit for the
generated machine code.

diff --git a/pypy/jit/backend/ppc/ppcgen/codebuilder.py 
b/pypy/jit/backend/ppc/ppcgen/codebuilder.py
--- a/pypy/jit/backend/ppc/ppcgen/codebuilder.py
+++ b/pypy/jit/backend/ppc/ppcgen/codebuilder.py
@@ -1002,6 +1002,16 @@
 self.writechar(chr((word  8)  0xFF))
 self.writechar(chr(word  0xFF))
 
+def write64(self, word):
+self.writechar(chr((word  56)  0xFF))
+self.writechar(chr((word  48)  0xFF))
+self.writechar(chr((word  40)  0xFF))
+self.writechar(chr((word  32)  0xFF))
+self.writechar(chr((word  24)  0xFF))
+self.writechar(chr((word  16)  0xFF))
+self.writechar(chr((word  8)  0xFF))
+self.writechar(chr(word  0xFF))
+
 def currpos(self):
 return self.get_rel_pos()
 
diff --git a/pypy/jit/backend/ppc/ppcgen/ppc_assembler.py 
b/pypy/jit/backend/ppc/ppcgen/ppc_assembler.py
--- a/pypy/jit/backend/ppc/ppcgen/ppc_assembler.py
+++ b/pypy/jit/backend/ppc/ppcgen/ppc_assembler.py
@@ -410,7 +410,11 @@
 self.write_pending_failure_recoveries()
 loop_start = self.materialize_loop(looptoken, False)
 looptoken._ppc_bootstrap_code = loop_start
-looptoken.ppc_code = loop_start + start_pos
+real_start = loop_start + start_pos
+if IS_PPC_32:
+looptoken.ppc_code = real_start
+else:
+looptoken.ppc_code = self.gen_64_bit_func_descr(real_start)
 self.process_pending_guards(loop_start)
 self._teardown()
 
@@ -516,6 +520,14 @@
 regalloc.possibly_free_vars_for_op(op)
 regalloc._check_invariants()
 
+def gen_64_bit_func_descr(self, start_addr):
+mc = PPCBuilder()
+mc.write64(start_addr)
+mc.write64(0)
+mc.write64(0)
+return mc.materialize(self.cpu.asmmemmgr, [], 
+  self.cpu.gc_ll_descr.gcrootmap)
+
 def compute_frame_depth(self, regalloc):
 frame_depth = (GPR_SAVE_AREA# GPR space
+ WORD   # FORCE INDEX
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: added cmath.isfinite

2011-11-08 Thread alex_gaynor
Author: Alex Gaynor alex.gay...@gmail.com
Branch: py3k
Changeset: r48956:a2dc8ef2c638
Date: 2011-11-08 11:42 -0500
http://bitbucket.org/pypy/pypy/changeset/a2dc8ef2c638/

Log:added cmath.isfinite

diff --git a/pypy/module/cmath/__init__.py b/pypy/module/cmath/__init__.py
--- a/pypy/module/cmath/__init__.py
+++ b/pypy/module/cmath/__init__.py
@@ -29,7 +29,8 @@
 'phase': Return argument, also known as the phase angle, of a complex.,
 'isinf': Checks if the real or imaginary part of z is infinite.,
 'isnan': Checks if the real or imaginary part of z is not a number (NaN),
-}
+'isfinite': isfinite(z) - bool\nReturn True if both the real and 
imaginary parts of z are finite, else False.,
+}
 
 
 class Module(MixedModule):
diff --git a/pypy/module/cmath/interp_cmath.py 
b/pypy/module/cmath/interp_cmath.py
--- a/pypy/module/cmath/interp_cmath.py
+++ b/pypy/module/cmath/interp_cmath.py
@@ -1,33 +1,25 @@
 import math
 from math import fabs
-from pypy.rlib.objectmodel import specialize
-from pypy.rlib.rfloat import copysign, asinh, log1p, isinf, isnan
-from pypy.tool.sourcetools import func_with_new_name
+
 from pypy.interpreter.error import OperationError
 from pypy.interpreter.gateway import NoneNotWrapped
 from pypy.module.cmath import names_and_docstrings
-from pypy.module.cmath.constant import DBL_MIN, CM_SCALE_UP, CM_SCALE_DOWN
-from pypy.module.cmath.constant import CM_LARGE_DOUBLE, DBL_MANT_DIG
-from pypy.module.cmath.constant import M_LN2, M_LN10
-from pypy.module.cmath.constant import CM_SQRT_LARGE_DOUBLE, CM_SQRT_DBL_MIN
-from pypy.module.cmath.constant import CM_LOG_LARGE_DOUBLE
-from pypy.module.cmath.special_value import isfinite, special_type, INF, NAN
-from pypy.module.cmath.special_value import sqrt_special_values
-from pypy.module.cmath.special_value import acos_special_values
-from pypy.module.cmath.special_value import acosh_special_values
-from pypy.module.cmath.special_value import asinh_special_values
-from pypy.module.cmath.special_value import atanh_special_values
-from pypy.module.cmath.special_value import log_special_values
-from pypy.module.cmath.special_value import exp_special_values
-from pypy.module.cmath.special_value import cosh_special_values
-from pypy.module.cmath.special_value import sinh_special_values
-from pypy.module.cmath.special_value import tanh_special_values
-from pypy.module.cmath.special_value import rect_special_values
+from pypy.module.cmath.constant import (DBL_MIN, CM_SCALE_UP, CM_SCALE_DOWN,
+CM_LARGE_DOUBLE, DBL_MANT_DIG, M_LN2, M_LN10, CM_SQRT_LARGE_DOUBLE,
+CM_SQRT_DBL_MIN, CM_LOG_LARGE_DOUBLE)
+from pypy.module.cmath.special_value import (special_type, INF, NAN,
+sqrt_special_values, acos_special_values, acosh_special_values,
+asinh_special_values, atanh_special_values, log_special_values,
+exp_special_values, cosh_special_values, sinh_special_values,
+tanh_special_values, rect_special_values)
+from pypy.rlib.objectmodel import specialize
+from pypy.rlib.rfloat import copysign, asinh, log1p, isinf, isnan, isfinite
+from pypy.tool.sourcetools import func_with_new_name
+
 
 pi = math.pi
 e  = math.e
 
-
 @specialize.arg(0)
 def call_c_func(c_func, space, x, y):
 try:
@@ -579,3 +571,12 @@
 res = c_isnan(x, y)
 return space.newbool(res)
 wrapped_isnan.func_doc = names_and_docstrings['isnan']
+
+def c_isfinite(x, y):
+return isfinite(x) and isfinite(y)
+
+def wrapped_isfinite(space, w_z):
+x, y = space.unpackcomplex(w_z)
+res = c_isfinite(x, y)
+return space.newbool(res)
+wrapped_isfinite.func_doc = names_and_docstrings['isfinite']
diff --git a/pypy/module/cmath/special_value.py 
b/pypy/module/cmath/special_value.py
--- a/pypy/module/cmath/special_value.py
+++ b/pypy/module/cmath/special_value.py
@@ -32,9 +32,6 @@
 else:
 return ST_NZERO
 
-def isfinite(d):
-return not isinf(d) and not isnan(d)
-
 
 P   = math.pi
 P14 = 0.25 * math.pi
diff --git a/pypy/module/cmath/test/test_cmath.py 
b/pypy/module/cmath/test/test_cmath.py
--- a/pypy/module/cmath/test/test_cmath.py
+++ b/pypy/module/cmath/test/test_cmath.py
@@ -92,6 +92,18 @@
 assert cmath.isnan(complex(inf+nanj))
 assert cmath.isnan(complex(nan+infj))
 
+def test_isfinite(self):
+import cmath
+import math
+
+real_vals = [
+float('-inf'), -2.3, -0.0, 0.0, 2.3, float('inf'), float('nan')
+]
+for x in real_vals:
+for y in real_vals:
+z = complex(x, y)
+assert cmath.isfinite(z) == (math.isfinite(x) and 
math.isfinite(y))
+
 def test_user_defined_complex(self):
 import cmath
 class Foo(object):
diff --git a/pypy/module/math/__init__.py b/pypy/module/math/__init__.py
--- a/pypy/module/math/__init__.py
+++ b/pypy/module/math/__init__.py
@@ -8,8 +8,8 @@
 }
 
 interpleveldefs = {
-   'e'  : 'interp_math.get(space).w_e', 
-   'pi' : 

[pypy-commit] pypy win64_gborg: merge

2011-11-08 Thread ctismer
Author: Christian Tismer tis...@stackless.com
Branch: win64_gborg
Changeset: r48958:685959b8208e
Date: 2011-11-08 17:22 +0100
http://bitbucket.org/pypy/pypy/changeset/685959b8208e/

Log:merge

diff --git a/lib_pypy/_ctypes/pointer.py b/lib_pypy/_ctypes/pointer.py
--- a/lib_pypy/_ctypes/pointer.py
+++ b/lib_pypy/_ctypes/pointer.py
@@ -124,7 +124,8 @@
 # for now, we always allow types.pointer, else a lot of tests
 # break. We need to rethink how pointers are represented, though
 if my_ffitype is not ffitype and ffitype is not _ffi.types.void_p:
-raise ArgumentError, expected %s instance, got %s % (type(value), 
ffitype)
+raise ArgumentError(expected %s instance, got %s % (type(value),
+  ffitype))
 return value._get_buffer_value()
 
 def _cast_addr(obj, _, tp):
diff --git a/pypy/jit/codewriter/effectinfo.py 
b/pypy/jit/codewriter/effectinfo.py
--- a/pypy/jit/codewriter/effectinfo.py
+++ b/pypy/jit/codewriter/effectinfo.py
@@ -78,6 +78,9 @@
 #
 OS_MATH_SQRT= 100
 
+# for debugging:
+_OS_CANRAISE = set([OS_NONE, OS_STR2UNICODE, OS_LIBFFI_CALL])
+
 def __new__(cls, readonly_descrs_fields, readonly_descrs_arrays,
 write_descrs_fields, write_descrs_arrays,
 extraeffect=EF_CAN_RAISE,
@@ -116,6 +119,8 @@
 result.extraeffect = extraeffect
 result.can_invalidate = can_invalidate
 result.oopspecindex = oopspecindex
+if result.check_can_raise():
+assert oopspecindex in cls._OS_CANRAISE
 cls._cache[key] = result
 return result
 
@@ -125,6 +130,10 @@
 def check_can_invalidate(self):
 return self.can_invalidate
 
+def check_is_elidable(self):
+return (self.extraeffect == self.EF_ELIDABLE_CAN_RAISE or
+self.extraeffect == self.EF_ELIDABLE_CANNOT_RAISE)
+
 def check_forces_virtual_or_virtualizable(self):
 return self.extraeffect = self.EF_FORCES_VIRTUAL_OR_VIRTUALIZABLE
 
diff --git a/pypy/jit/codewriter/test/test_flatten.py 
b/pypy/jit/codewriter/test/test_flatten.py
--- a/pypy/jit/codewriter/test/test_flatten.py
+++ b/pypy/jit/codewriter/test/test_flatten.py
@@ -5,7 +5,7 @@
 from pypy.jit.codewriter.format import assert_format
 from pypy.jit.codewriter import longlong
 from pypy.jit.metainterp.history import AbstractDescr
-from pypy.rpython.lltypesystem import lltype, rclass, rstr
+from pypy.rpython.lltypesystem import lltype, rclass, rstr, rffi
 from pypy.objspace.flow.model import SpaceOperation, Variable, Constant
 from pypy.translator.unsimplify import varoftype
 from pypy.rlib.rarithmetic import ovfcheck, r_uint, r_longlong, r_ulonglong
@@ -743,7 +743,6 @@
 , transform=True)
 
 def test_force_cast(self):
-from pypy.rpython.lltypesystem import rffi
 # NB: we don't need to test for INT here, the logic in jtransform is
 # general enough so that if we have the below cases it should
 # generalize also to INT
@@ -849,7 +848,6 @@
transform=True)
 
 def test_force_cast_pointer(self):
-from pypy.rpython.lltypesystem import rffi
 def h(p):
 return rffi.cast(rffi.VOIDP, p)
 self.encoding_test(h, [lltype.nullptr(rffi.CCHARP.TO)], 
@@ -857,7 +855,6 @@
 , transform=True)
 
 def test_force_cast_floats(self):
-from pypy.rpython.lltypesystem import rffi
 # Caststs to lltype.Float
 def f(n):
 return rffi.cast(lltype.Float, n)
@@ -964,7 +961,6 @@
 , transform=True)
 
 def test_direct_ptradd(self):
-from pypy.rpython.lltypesystem import rffi
 def f(p, n):
 return lltype.direct_ptradd(p, n)
 self.encoding_test(f, [lltype.nullptr(rffi.CCHARP.TO), 123], 
@@ -975,7 +971,6 @@
 
 def check_force_cast(FROM, TO, operations, value):
 Check that the test is correctly written...
-from pypy.rpython.lltypesystem import rffi
 import re
 r = re.compile('(\w+) \%i\d, \$(-?\d+)')
 #
diff --git a/pypy/jit/metainterp/optimizeopt/test/test_util.py 
b/pypy/jit/metainterp/optimizeopt/test/test_util.py
--- a/pypy/jit/metainterp/optimizeopt/test/test_util.py
+++ b/pypy/jit/metainterp/optimizeopt/test/test_util.py
@@ -183,6 +183,7 @@
 can_invalidate=True))
 arraycopydescr = cpu.calldescrof(FUNC, FUNC.ARGS, FUNC.RESULT,
  EffectInfo([], [arraydescr], [], [arraydescr],
+EffectInfo.EF_CANNOT_RAISE,
 oopspecindex=EffectInfo.OS_ARRAYCOPY))
 
 
@@ -212,12 +213,14 @@
 _oopspecindex = getattr(EffectInfo, _os)
 locals()[_name] = \
 cpu.calldescrof(FUNC, FUNC.ARGS, FUNC.RESULT,
-EffectInfo([], [], [], [], oopspecindex=_oopspecindex))
+EffectInfo([], [], [], [], EffectInfo.EF_CANNOT_RAISE,
+  

[pypy-commit] pypy win64_gborg: merge

2011-11-08 Thread ctismer
Author: Christian Tismer tis...@stackless.com
Branch: win64_gborg
Changeset: r48957:8b324f7ce7a9
Date: 2011-11-08 17:21 +0100
http://bitbucket.org/pypy/pypy/changeset/8b324f7ce7a9/

Log:merge

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


[pypy-commit] pypy win64_gborg: all errors are gone from test_typed.py.

2011-11-08 Thread ctismer
Author: Christian Tismer tis...@stackless.com
Branch: win64_gborg
Changeset: r48959:ec8e923109d9
Date: 2011-11-08 18:10 +0100
http://bitbucket.org/pypy/pypy/changeset/ec8e923109d9/

Log:all errors are gone from test_typed.py. This was a major hassle
during the last two days. I was hunting an error which was caused by
the rfficache. On windows, it is hard to see any difference between
compiler configurations. All environment settings are identical. At
the moment, sys.maxind is the only thing that distinguishes the
platforms.

diff --git a/pypy/rpython/lltypesystem/rffi.py 
b/pypy/rpython/lltypesystem/rffi.py
--- a/pypy/rpython/lltypesystem/rffi.py
+++ b/pypy/rpython/lltypesystem/rffi.py
@@ -878,7 +878,7 @@
 size = llmemory.sizeof(tp)# a symbolic result in this case
 return size
 if isinstance(tp, lltype.Ptr) or tp is llmemory.Address:
-tp = ULONG # XXX!
+tp = lltype.Signed
 if tp is lltype.Char or tp is lltype.Bool:
 return 1
 if tp is lltype.UniChar:
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy ppc-jit-backend: (bivab, hager): Read function address out of function descriptor in case of 64 bit.

2011-11-08 Thread hager
Author: hager sven.ha...@uni-duesseldorf.de
Branch: ppc-jit-backend
Changeset: r48960:1445ebbaeb41
Date: 2011-11-08 09:17 -0800
http://bitbucket.org/pypy/pypy/changeset/1445ebbaeb41/

Log:(bivab, hager): Read function address out of function descriptor in
case of 64 bit.

diff --git a/pypy/jit/backend/ppc/ppcgen/ppc_assembler.py 
b/pypy/jit/backend/ppc/ppcgen/ppc_assembler.py
--- a/pypy/jit/backend/ppc/ppcgen/ppc_assembler.py
+++ b/pypy/jit/backend/ppc/ppcgen/ppc_assembler.py
@@ -300,7 +300,13 @@
 #
 decode_func_addr = llhelper(self.recovery_func_sign,
 self.failure_recovery_func)
-addr = rffi.cast(lltype.Signed, decode_func_addr)
+if IS_PPC_32:
+addr = rffi.cast(lltype.Signed, decode_func_addr)
+else:
+intp = lltype.Ptr(lltype.Array(lltype.Signed, hints={'nolength': 
True}))
+descr = rffi.cast(intp, decode_func_addr)
+addr = descr[0]
+
 #
 # load parameters into parameter registers
 mc.lwz(r.r3.value, r.SPP.value, 0) # address of state encoding 
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy win64_gborg: re-enabled rwin32

2011-11-08 Thread ctismer
Author: Christian Tismer tis...@stackless.com
Branch: win64_gborg
Changeset: r48961:e205679c19d1
Date: 2011-11-08 18:19 +0100
http://bitbucket.org/pypy/pypy/changeset/e205679c19d1/

Log:re-enabled rwin32

diff --git a/pypy/rpython/module/ll_os.py b/pypy/rpython/module/ll_os.py
--- a/pypy/rpython/module/ll_os.py
+++ b/pypy/rpython/module/ll_os.py
@@ -1747,8 +1747,7 @@
 # 
 # Support for the WindowsError exception
 
-# XXX temporarily disabled
-if 0 and sys.platform == 'win32':
+if sys.platform == 'win32':
 from pypy.rlib import rwin32
 
 class RegisterFormatError(BaseLazyRegistering):
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy win64_gborg: re-enabled rwin32

2011-11-08 Thread ctismer
Author: Christian Tismer tis...@stackless.com
Branch: win64_gborg
Changeset: r48962:c00873500c87
Date: 2011-11-08 18:23 +0100
http://bitbucket.org/pypy/pypy/changeset/c00873500c87/

Log:re-enabled rwin32

diff --git a/pypy/doc/discussion/win64_todo.txt 
b/pypy/doc/discussion/win64_todo.txt
--- a/pypy/doc/discussion/win64_todo.txt
+++ b/pypy/doc/discussion/win64_todo.txt
@@ -2,6 +2,7 @@
 ll_os.py has a problem with the file rwin32.py.
 Temporarily disabled for the win64_gborg branch. This needs to be
 investigated and re-enabled.
+Resolved, enabled.
 
 2011-11-05
 test_typed.py needs explicit tests to ensure that we
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Attempt at producing a Makefile compatible with nmake lldebug on Windows.

2011-11-08 Thread arigo
Author: Armin Rigo ar...@tunes.org
Branch: 
Changeset: r48963:e9f7368da478
Date: 2011-11-08 18:53 +0100
http://bitbucket.org/pypy/pypy/changeset/e9f7368da478/

Log:Attempt at producing a Makefile compatible with nmake lldebug on
Windows.

diff --git a/pypy/translator/c/genc.py b/pypy/translator/c/genc.py
--- a/pypy/translator/c/genc.py
+++ b/pypy/translator/c/genc.py
@@ -521,13 +521,13 @@
 rules = [
 ('clean', '', 'rm -f $(OBJECTS) $(TARGET) $(GCMAPFILES) 
$(ASMFILES) *.gc?? ../module_cache/*.gc??'),
 ('clean_noprof', '', 'rm -f $(OBJECTS) $(TARGET) $(GCMAPFILES) 
$(ASMFILES)'),
-('debug', '', '$(MAKE) CFLAGS=$(DEBUGFLAGS) -DRPY_ASSERT 
$(TARGET)'),
-('debug_exc', '', '$(MAKE) CFLAGS=$(DEBUGFLAGS) -DRPY_ASSERT 
-DDO_LOG_EXC $(TARGET)'),
-('debug_mem', '', '$(MAKE) CFLAGS=$(DEBUGFLAGS) -DRPY_ASSERT 
-DTRIVIAL_MALLOC_DEBUG $(TARGET)'),
+('debug', '', '$(MAKE) CFLAGS=$(DEBUGFLAGS) -DRPY_ASSERT 
debug_target'),
+('debug_exc', '', '$(MAKE) CFLAGS=$(DEBUGFLAGS) -DRPY_ASSERT 
-DDO_LOG_EXC debug_target'),
+('debug_mem', '', '$(MAKE) CFLAGS=$(DEBUGFLAGS) -DRPY_ASSERT 
-DTRIVIAL_MALLOC_DEBUG debug_target'),
 ('no_obmalloc', '', '$(MAKE) CFLAGS=-g -O2 -DRPY_ASSERT 
-DNO_OBMALLOC $(TARGET)'),
-('linuxmemchk', '', '$(MAKE) CFLAGS=$(DEBUGFLAGS) -DRPY_ASSERT 
-DLINUXMEMCHK $(TARGET)'),
+('linuxmemchk', '', '$(MAKE) CFLAGS=$(DEBUGFLAGS) -DRPY_ASSERT 
-DLINUXMEMCHK debug_target'),
 ('llsafer', '', '$(MAKE) CFLAGS=-O2 -DRPY_LL_ASSERT $(TARGET)'),
-('lldebug', '', '$(MAKE) CFLAGS=$(DEBUGFLAGS) -DRPY_ASSERT 
-DRPY_LL_ASSERT $(TARGET)'),
+('lldebug', '', '$(MAKE) CFLAGS=$(DEBUGFLAGS) -DRPY_ASSERT 
-DRPY_LL_ASSERT debug_target'),
 ('profile', '', '$(MAKE) CFLAGS=-g -O1 -pg $(CFLAGS) 
-fno-omit-frame-pointer LDFLAGS=-pg $(LDFLAGS) $(TARGET)'),
 ]
 if self.has_profopt():
@@ -554,7 +554,7 @@
 mk.definition('ASMLBLFILES', lblsfiles)
 mk.definition('GCMAPFILES', gcmapfiles)
 if sys.platform == 'win32':
-mk.definition('DEBUGFLAGS', '/Zi')
+mk.definition('DEBUGFLAGS', '/MD /Zi')
 else:
 mk.definition('DEBUGFLAGS', '-O2 -fomit-frame-pointer -g')
 
@@ -618,9 +618,13 @@
 
 else:
 if sys.platform == 'win32':
-mk.definition('DEBUGFLAGS', '/Zi')
+mk.definition('DEBUGFLAGS', '/MD /Zi')
 else:
 mk.definition('DEBUGFLAGS', '-O1 -g')
+if sys.platform == 'win32':
+mk.rule('debug_target', 'debugmode_$(DEFAULT_TARGET)')
+else:
+mk.rule('debug_target', '$(TARGET)')
 mk.write()
 #self.translator.platform,
 #   ,
diff --git a/pypy/translator/platform/windows.py 
b/pypy/translator/platform/windows.py
--- a/pypy/translator/platform/windows.py
+++ b/pypy/translator/platform/windows.py
@@ -294,6 +294,9 @@
['$(CC_LINK) /nologo $(LDFLAGS) $(LDFLAGSEXTRA) $(OBJECTS) 
$(LINKFILES) /out:$@ $(LIBDIRS) $(LIBS) /MANIFEST /MANIFESTFILE:$*.manifest',
 'mt.exe -nologo -manifest $*.manifest 
-outputresource:$@;1',
 ])
+m.rule('debugmode_$(TARGET)', '$(OBJECTS)',
+   ['$(CC_LINK) /nologo /DEBUG $(LDFLAGS) $(LDFLAGSEXTRA) 
$(OBJECTS) $(LINKFILES) /out:$@ $(LIBDIRS) $(LIBS)',
+])
 
 if shared:
 m.definition('SHARED_IMPORT_LIB', so_name.new(ext='lib').basename)
@@ -307,6 +310,9 @@
['$(CC_LINK) /nologo main.obj $(SHARED_IMPORT_LIB) /out:$@ 
/MANIFEST /MANIFESTFILE:$*.manifest',
 'mt.exe -nologo -manifest $*.manifest 
-outputresource:$@;1',
 ])
+m.rule('debugmode_$(DEFAULT_TARGET)', ['debugmode_$(TARGET)', 
'main.obj'],
+   ['$(CC_LINK) /nologo /DEBUG main.obj $(SHARED_IMPORT_LIB) 
/out:$@'
+])
 
 return m
 
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy win64_gborg: ll_os.times() works now

2011-11-08 Thread ctismer
Author: Christian Tismer tis...@stackless.com
Branch: win64_gborg
Changeset: r48964:1aa825cbc8de
Date: 2011-11-08 18:58 +0100
http://bitbucket.org/pypy/pypy/changeset/1aa825cbc8de/

Log:ll_os.times() works now

diff --git a/pypy/rpython/module/ll_os.py b/pypy/rpython/module/ll_os.py
--- a/pypy/rpython/module/ll_os.py
+++ b/pypy/rpython/module/ll_os.py
@@ -530,10 +530,10 @@
 # The fields of a FILETIME structure are the hi and lo parts
 # of a 64-bit value expressed in 100 nanosecond units
 # (of course).
-result = (pkernel.c_dwHighDateTime*429.4967296 +
-  pkernel.c_dwLowDateTime*1E-7,
-  puser.c_dwHighDateTime*429.4967296 +
-  puser.c_dwLowDateTime*1E-7,
+result = (rffi.cast(lltype.Signed, pkernel.c_dwHighDateTime) * 
429.4967296 +
+  rffi.cast(lltype.Signed, pkernel.c_dwLowDateTime) * 
1E-7,
+  rffi.cast(lltype.Signed, puser.c_dwHighDateTime) * 
429.4967296 +
+  rffi.cast(lltype.Signed, puser.c_dwLowDateTime) * 
1E-7,
   0, 0, 0)
 lltype.free(puser,   flavor='raw')
 lltype.free(pkernel, flavor='raw')
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy win64_gborg: merge

2011-11-08 Thread ctismer
Author: Christian Tismer tis...@stackless.com
Branch: win64_gborg
Changeset: r48965:51c332546797
Date: 2011-11-08 18:58 +0100
http://bitbucket.org/pypy/pypy/changeset/51c332546797/

Log:merge

diff --git a/pypy/translator/c/genc.py b/pypy/translator/c/genc.py
--- a/pypy/translator/c/genc.py
+++ b/pypy/translator/c/genc.py
@@ -521,13 +521,13 @@
 rules = [
 ('clean', '', 'rm -f $(OBJECTS) $(TARGET) $(GCMAPFILES) 
$(ASMFILES) *.gc?? ../module_cache/*.gc??'),
 ('clean_noprof', '', 'rm -f $(OBJECTS) $(TARGET) $(GCMAPFILES) 
$(ASMFILES)'),
-('debug', '', '$(MAKE) CFLAGS=$(DEBUGFLAGS) -DRPY_ASSERT 
$(TARGET)'),
-('debug_exc', '', '$(MAKE) CFLAGS=$(DEBUGFLAGS) -DRPY_ASSERT 
-DDO_LOG_EXC $(TARGET)'),
-('debug_mem', '', '$(MAKE) CFLAGS=$(DEBUGFLAGS) -DRPY_ASSERT 
-DTRIVIAL_MALLOC_DEBUG $(TARGET)'),
+('debug', '', '$(MAKE) CFLAGS=$(DEBUGFLAGS) -DRPY_ASSERT 
debug_target'),
+('debug_exc', '', '$(MAKE) CFLAGS=$(DEBUGFLAGS) -DRPY_ASSERT 
-DDO_LOG_EXC debug_target'),
+('debug_mem', '', '$(MAKE) CFLAGS=$(DEBUGFLAGS) -DRPY_ASSERT 
-DTRIVIAL_MALLOC_DEBUG debug_target'),
 ('no_obmalloc', '', '$(MAKE) CFLAGS=-g -O2 -DRPY_ASSERT 
-DNO_OBMALLOC $(TARGET)'),
-('linuxmemchk', '', '$(MAKE) CFLAGS=$(DEBUGFLAGS) -DRPY_ASSERT 
-DLINUXMEMCHK $(TARGET)'),
+('linuxmemchk', '', '$(MAKE) CFLAGS=$(DEBUGFLAGS) -DRPY_ASSERT 
-DLINUXMEMCHK debug_target'),
 ('llsafer', '', '$(MAKE) CFLAGS=-O2 -DRPY_LL_ASSERT $(TARGET)'),
-('lldebug', '', '$(MAKE) CFLAGS=$(DEBUGFLAGS) -DRPY_ASSERT 
-DRPY_LL_ASSERT $(TARGET)'),
+('lldebug', '', '$(MAKE) CFLAGS=$(DEBUGFLAGS) -DRPY_ASSERT 
-DRPY_LL_ASSERT debug_target'),
 ('profile', '', '$(MAKE) CFLAGS=-g -O1 -pg $(CFLAGS) 
-fno-omit-frame-pointer LDFLAGS=-pg $(LDFLAGS) $(TARGET)'),
 ]
 if self.has_profopt():
@@ -554,7 +554,7 @@
 mk.definition('ASMLBLFILES', lblsfiles)
 mk.definition('GCMAPFILES', gcmapfiles)
 if sys.platform == 'win32':
-mk.definition('DEBUGFLAGS', '/Zi')
+mk.definition('DEBUGFLAGS', '/MD /Zi')
 else:
 mk.definition('DEBUGFLAGS', '-O2 -fomit-frame-pointer -g')
 
@@ -618,9 +618,13 @@
 
 else:
 if sys.platform == 'win32':
-mk.definition('DEBUGFLAGS', '/Zi')
+mk.definition('DEBUGFLAGS', '/MD /Zi')
 else:
 mk.definition('DEBUGFLAGS', '-O1 -g')
+if sys.platform == 'win32':
+mk.rule('debug_target', 'debugmode_$(DEFAULT_TARGET)')
+else:
+mk.rule('debug_target', '$(TARGET)')
 mk.write()
 #self.translator.platform,
 #   ,
diff --git a/pypy/translator/platform/windows.py 
b/pypy/translator/platform/windows.py
--- a/pypy/translator/platform/windows.py
+++ b/pypy/translator/platform/windows.py
@@ -308,6 +308,9 @@
['$(CC_LINK) /nologo $(LDFLAGS) $(LDFLAGSEXTRA) $(OBJECTS) 
$(LINKFILES) /out:$@ $(LIBDIRS) $(LIBS) /MANIFEST /MANIFESTFILE:$*.manifest',
 'mt.exe -nologo -manifest $*.manifest 
-outputresource:$@;1',
 ])
+m.rule('debugmode_$(TARGET)', '$(OBJECTS)',
+   ['$(CC_LINK) /nologo /DEBUG $(LDFLAGS) $(LDFLAGSEXTRA) 
$(OBJECTS) $(LINKFILES) /out:$@ $(LIBDIRS) $(LIBS)',
+])
 
 if shared:
 m.definition('SHARED_IMPORT_LIB', so_name.new(ext='lib').basename)
@@ -321,6 +324,9 @@
['$(CC_LINK) /nologo main.obj $(SHARED_IMPORT_LIB) /out:$@ 
/MANIFEST /MANIFESTFILE:$*.manifest',
 'mt.exe -nologo -manifest $*.manifest 
-outputresource:$@;1',
 ])
+m.rule('debugmode_$(DEFAULT_TARGET)', ['debugmode_$(TARGET)', 
'main.obj'],
+   ['$(CC_LINK) /nologo /DEBUG main.obj $(SHARED_IMPORT_LIB) 
/out:$@'
+])
 
 return m
 
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy numpy-multidim: a skipped test

2011-11-08 Thread fijal
Author: Maciej Fijalkowski fij...@gmail.com
Branch: numpy-multidim
Changeset: r48966:24afd34cee15
Date: 2011-11-08 19:02 +0100
http://bitbucket.org/pypy/pypy/changeset/24afd34cee15/

Log:a skipped test

diff --git a/pypy/module/micronumpy/test/test_numarray.py 
b/pypy/module/micronumpy/test/test_numarray.py
--- a/pypy/module/micronumpy/test/test_numarray.py
+++ b/pypy/module/micronumpy/test/test_numarray.py
@@ -742,6 +742,14 @@
 a = array([[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]])
 assert (a + a)[1, 1] == 8
 
+def test_broadcast(self):
+skip(not working)
+import numpy
+a = numpy.zeros((100, 100))
+b = numpy.ones(100)
+a[:,:] = b
+assert a[13,15] == 1
+
 class AppTestSupport(object):
 def setup_class(cls):
 import struct
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy numpy-multidim: simplification, a new (and unused) class and some comments

2011-11-08 Thread fijal
Author: Maciej Fijalkowski fij...@gmail.com
Branch: numpy-multidim
Changeset: r48967:437d9d1f5a43
Date: 2011-11-08 19:10 +0100
http://bitbucket.org/pypy/pypy/changeset/437d9d1f5a43/

Log:simplification, a new (and unused) class and some comments

diff --git a/pypy/module/micronumpy/interp_numarray.py 
b/pypy/module/micronumpy/interp_numarray.py
--- a/pypy/module/micronumpy/interp_numarray.py
+++ b/pypy/module/micronumpy/interp_numarray.py
@@ -68,6 +68,14 @@
 dtype.setitem_w(space, arr.storage, i, w_elem)
 return arr
 
+class ArrayIndex(object):
+ An index into an array or view. Offset is a data offset, indexes
+are respective indexes in dimensions
+
+def __init__(self, indexes, offset):
+self.indexes = indexes
+self.offset = offset
+
 class BaseArray(Wrappable):
 _attrs_ = [invalidates, signature, shape]
 
@@ -287,9 +295,6 @@
 item += v
 return item
 
-def len_of_shape(self):
-return len(self.shape)
-
 def get_root_shape(self):
 return self.shape
 
@@ -297,7 +302,7 @@
  The result of getitem/setitem is a single item if w_idx
 is a list of scalars that match the size of shape
 
-shape_len = self.len_of_shape()
+shape_len = len(self.shape)
 if shape_len == 0:
 if not space.isinstance_w(w_idx, space.w_int):
 raise OperationError(space.w_IndexError, space.wrap(
@@ -583,10 +588,6 @@
 def __init__(self, parent, signature, chunks, shape):
 ViewArray.__init__(self, parent, signature, shape)
 self.chunks = chunks
-self.shape_reduction = 0
-for chunk in chunks:
-if chunk[-2] == 0:
-self.shape_reduction += 1
 
 def get_root_storage(self):
 return self.parent.get_concrete().get_root_storage()
@@ -615,9 +616,6 @@
 def setitem(self, item, value):
 self.parent.setitem(self.calc_index(item), value)
 
-def len_of_shape(self):
-return self.parent.len_of_shape() - self.shape_reduction
-
 def get_root_shape(self):
 return self.parent.get_root_shape()
 
@@ -704,6 +702,9 @@
 return ret.build()
 
 class NDimArray(BaseArray):
+ A class representing contiguous array. We know that each iteration
+by say ufunc will increase the data index by one
+
 def __init__(self, size, shape, dtype):
 BaseArray.__init__(self, shape)
 self.size = size
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: a failing optimizeopt test

2011-11-08 Thread alex_gaynor
Author: Alex Gaynor alex.gay...@gmail.com
Branch: 
Changeset: r48968:4cb1d062d413
Date: 2011-11-08 14:15 -0500
http://bitbucket.org/pypy/pypy/changeset/4cb1d062d413/

Log:a failing optimizeopt test

diff --git a/pypy/jit/metainterp/optimizeopt/test/test_optimizebasic.py 
b/pypy/jit/metainterp/optimizeopt/test/test_optimizebasic.py
--- a/pypy/jit/metainterp/optimizeopt/test/test_optimizebasic.py
+++ b/pypy/jit/metainterp/optimizeopt/test/test_optimizebasic.py
@@ -4999,6 +4999,33 @@
 
 self.optimize_loop(ops, expected)
 
+def test_known_equal_ints(self):
+ops = 
+[i0, i1, i2, p0]
+i3 = int_eq(i0, i1)
+guard_true(i3) []
+
+i4 = int_lt(i2, i0)
+guard_true(i4) []
+i5 = int_lt(i2, i1)
+guard_true(i5) []
+
+i6 = getarrayitem_gc(p0, i2)
+finish(i6)
+
+expected = 
+[i0, i1, i2, p0]
+i3 = int_eq(i0, i1)
+guard_true(i3) []
+
+i4 = int_lt(i2, i0)
+guard_true(i4) []
+
+i6 = getarrayitem_gc(p0, i3)
+finish(i6)
+
+self.optimize_loop(ops, expected)
+
 
 class TestLLtype(BaseTestOptimizeBasic, LLtypeMixin):
 pass
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: A non quadratic implementation of random.getrandbits(),

2011-11-08 Thread amauryfa
Author: Amaury Forgeot d'Arc amaur...@gmail.com
Branch: py3k
Changeset: r48969:a72479c34dae
Date: 2011-11-08 20:12 +0100
http://bitbucket.org/pypy/pypy/changeset/a72479c34dae/

Log:A non quadratic implementation of random.getrandbits(), badly needed
by test_zlib

diff --git a/pypy/module/_random/interp_random.py 
b/pypy/module/_random/interp_random.py
--- a/pypy/module/_random/interp_random.py
+++ b/pypy/module/_random/interp_random.py
@@ -2,8 +2,8 @@
 from pypy.interpreter.typedef import TypeDef
 from pypy.interpreter.gateway import NoneNotWrapped, interp2app, unwrap_spec
 from pypy.interpreter.baseobjspace import Wrappable
-from pypy.rlib.rarithmetic import r_uint, intmask
-from pypy.rlib import rrandom
+from pypy.rlib.rarithmetic import r_uint, r_longlong, intmask
+from pypy.rlib import rbigint, rrandom
 
 import time
 
@@ -83,31 +83,22 @@
 n = space.int_w(w_n)
 self._rnd.jumpahead(n)
 
+assert rbigint.SHIFT = 32
 @unwrap_spec(k=int)
 def getrandbits(self, space, k):
 if k = 0:
 strerror = space.wrap(number of bits must be greater than zero)
 raise OperationError(space.w_ValueError, strerror)
-bytes = ((k - 1) // 32 + 1) * 4
-bytesarray = [0] * bytes
-for i in range(0, bytes, 4):
-r = self._rnd.genrand32()
-if k  32:
-r = (32 - k)
-bytesarray[i + 0] = r  r_uint(0xff)
-bytesarray[i + 1] = (r  8)  r_uint(0xff)
-bytesarray[i + 2] = (r  16)  r_uint(0xff)
-bytesarray[i + 3] = (r  24)  r_uint(0xff)
-k -= 32
-
-# XXX so far this is quadratic
-w_result = space.newint(0)
-w_eight = space.newint(8)
-for i in range(len(bytesarray) - 1, -1, -1):
-byte = bytesarray[i]
-w_result = space.or_(space.lshift(w_result, w_eight),
- space.newint(intmask(byte)))
-return w_result
+needed = (k - 1) // rbigint.SHIFT + 1
+result = rbigint.rbigint([rbigint.NULLDIGIT] * needed, 1)
+for i in range(needed - 1):
+# This loses some random digits, but not too many since SHIFT=31
+value = self._rnd.genrand32()
+if i  needed - 1:
+result.setdigit(i, value  rbigint.MASK)
+else:
+result.setdigit(i, value  ((needed * rbigint.SHIFT) - k))
+return space.newlong_from_rbigint(result)
 
 
 W_Random.typedef = TypeDef(Random,
diff --git a/pypy/module/_random/test/test_random.py 
b/pypy/module/_random/test/test_random.py
--- a/pypy/module/_random/test/test_random.py
+++ b/pypy/module/_random/test/test_random.py
@@ -67,7 +67,7 @@
 for arg in [None, 0, 0L, 1, 1L, -1, -1L, 10**20, -(10**20),
 3.14, 1+2j, 'a', tuple('abc'), 0xffL]:
 rnd.seed(arg)
-for arg in [range(3), dict(one=1)]:
+for arg in [[1, 2, 3], dict(one=1)]:
 raises(TypeError, rnd.seed, arg)
 raises(TypeError, rnd.seed, 1, 2)
 raises(TypeError, type(rnd), [])
@@ -92,7 +92,10 @@
 def test_randbits(self):
 import _random
 rnd = _random.Random()
-for n in range(1, 10) + range(10, 1000, 15):
+for n in range(1, 10):
+k = rnd.getrandbits(n)
+assert 0 = k  2 ** n
+for n in range(10, 1000, 15):
 k = rnd.getrandbits(n)
 assert 0 = k  2 ** n
 
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy ppc-jit-backend: (edelsohn, hager): Some experiments in _gen_exit_path

2011-11-08 Thread hager
Author: hager sven.ha...@uni-duesseldorf.de
Branch: ppc-jit-backend
Changeset: r48970:83e046a36db5
Date: 2011-11-08 11:25 -0800
http://bitbucket.org/pypy/pypy/changeset/83e046a36db5/

Log:(edelsohn, hager): Some experiments in _gen_exit_path

diff --git a/pypy/jit/backend/ppc/ppcgen/ppc_assembler.py 
b/pypy/jit/backend/ppc/ppcgen/ppc_assembler.py
--- a/pypy/jit/backend/ppc/ppcgen/ppc_assembler.py
+++ b/pypy/jit/backend/ppc/ppcgen/ppc_assembler.py
@@ -306,15 +306,20 @@
 intp = lltype.Ptr(lltype.Array(lltype.Signed, hints={'nolength': 
True}))
 descr = rffi.cast(intp, decode_func_addr)
 addr = descr[0]
+r11_value = descr[2]
 
 #
 # load parameters into parameter registers
-mc.lwz(r.r3.value, r.SPP.value, 0) # address of state encoding 
+if IS_PPC_32:
+mc.lwz(r.r3.value, r.SPP.value, 0) # address of state encoding 
+else:
+mc.lwz(r.r3.value, r.SPP.value, 0) # address of state encoding 
 mc.mr(r.r4.value, r.SP.value)  # load stack pointer
 mc.mr(r.r5.value, r.SPP.value) # load spilling pointer
 #
 # load address of decoding function into r0
 mc.load_imm(r.r0, addr)
+mc.load_imm(r.r11, r11_value)
 # ... and branch there
 mc.mtctr(r.r0.value)
 mc.bctrl()
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy ppc-jit-backend: Remove typo from _gen_exit_path

2011-11-08 Thread hager
Author: hager sven.ha...@uni-duesseldorf.de
Branch: ppc-jit-backend
Changeset: r48971:03431c38f9c9
Date: 2011-11-08 11:34 -0800
http://bitbucket.org/pypy/pypy/changeset/03431c38f9c9/

Log:Remove typo from _gen_exit_path

diff --git a/pypy/jit/backend/ppc/ppcgen/ppc_assembler.py 
b/pypy/jit/backend/ppc/ppcgen/ppc_assembler.py
--- a/pypy/jit/backend/ppc/ppcgen/ppc_assembler.py
+++ b/pypy/jit/backend/ppc/ppcgen/ppc_assembler.py
@@ -313,7 +313,7 @@
 if IS_PPC_32:
 mc.lwz(r.r3.value, r.SPP.value, 0) # address of state encoding 
 else:
-mc.lwz(r.r3.value, r.SPP.value, 0) # address of state encoding 
+mc.ld(r.r3.value, r.SPP.value, 0) 
 mc.mr(r.r4.value, r.SP.value)  # load stack pointer
 mc.mr(r.r5.value, r.SPP.value) # load spilling pointer
 #
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy win64_gborg: ll_os.utimes works, too

2011-11-08 Thread ctismer
Author: Christian Tismer tis...@stackless.com
Branch: win64_gborg
Changeset: r48972:95c8b04b7cf8
Date: 2011-11-08 20:34 +0100
http://bitbucket.org/pypy/pypy/changeset/95c8b04b7cf8/

Log:ll_os.utimes works, too

diff --git a/pypy/rlib/rarithmetic.py b/pypy/rlib/rarithmetic.py
--- a/pypy/rlib/rarithmetic.py
+++ b/pypy/rlib/rarithmetic.py
@@ -471,6 +471,9 @@
 r_longlong = build_int('r_longlong', True, 64)
 r_ulonglong = build_int('r_ulonglong', False, 64)
 
+r_long = build_int('r_long', True, 32)
+r_ulong = build_int('r_ulong', False, 32)
+
 longlongmax = r_longlong(LONGLONG_TEST - 1)
 
 if r_longlong is not r_int:
@@ -478,6 +481,12 @@
 else:
 r_int64 = int
 
+# needed for ll_os_stat.time_t_to_FILE_TIME in the 64 bit case
+if r_long is not r_int:
+r_uint32 = r_ulong
+else:
+r_uint32 = r_uint
+
 
 # the 'float' C type
 
diff --git a/pypy/rpython/lltypesystem/lltype.py 
b/pypy/rpython/lltypesystem/lltype.py
--- a/pypy/rpython/lltypesystem/lltype.py
+++ b/pypy/rpython/lltypesystem/lltype.py
@@ -1,7 +1,8 @@
 import py
 from pypy.rlib.rarithmetic import (r_int, r_uint, intmask, r_singlefloat,
r_ulonglong, r_longlong, r_longfloat,
-   base_int, normalizedinttype, longlongmask)
+   base_int, normalizedinttype, longlongmask,
+   r_uint32)
 from pypy.rlib.objectmodel import Symbolic
 from pypy.tool.uid import Hashable
 from pypy.tool.identity_dict import identity_dict
diff --git a/pypy/rpython/module/ll_os.py b/pypy/rpython/module/ll_os.py
--- a/pypy/rpython/module/ll_os.py
+++ b/pypy/rpython/module/ll_os.py
@@ -402,7 +402,7 @@
 UTIMBUFP = lltype.Ptr(self.UTIMBUF)
 os_utime = self.llexternal('utime', [rffi.CCHARP, UTIMBUFP], rffi.INT)
 
-if not _WIM32:
+if not _WIN32:
 includes = ['sys/time.h']
 else:
 includes = ['time.h']
diff --git a/pypy/rpython/module/ll_os_stat.py 
b/pypy/rpython/module/ll_os_stat.py
--- a/pypy/rpython/module/ll_os_stat.py
+++ b/pypy/rpython/module/ll_os_stat.py
@@ -456,6 +456,6 @@
 
 def time_t_to_FILE_TIME(time, filetime):
 ft = lltype.r_longlong((time + secs_between_epochs) * 1000)
-filetime.c_dwHighDateTime = lltype.r_uint(ft  32)
-filetime.c_dwLowDateTime = lltype.r_uint(ft  lltype.r_uint(-1))
+filetime.c_dwHighDateTime = lltype.r_uint32(ft  32)
+filetime.c_dwLowDateTime = lltype.r_uint32(ft  lltype.r_uint(-1))
 
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy win64_gborg: merge

2011-11-08 Thread ctismer
Author: Christian Tismer tis...@stackless.com
Branch: win64_gborg
Changeset: r48973:689e57b43a04
Date: 2011-11-08 20:35 +0100
http://bitbucket.org/pypy/pypy/changeset/689e57b43a04/

Log:merge

diff --git a/pypy/jit/metainterp/optimizeopt/test/test_optimizebasic.py 
b/pypy/jit/metainterp/optimizeopt/test/test_optimizebasic.py
--- a/pypy/jit/metainterp/optimizeopt/test/test_optimizebasic.py
+++ b/pypy/jit/metainterp/optimizeopt/test/test_optimizebasic.py
@@ -4999,6 +4999,33 @@
 
 self.optimize_loop(ops, expected)
 
+def test_known_equal_ints(self):
+ops = 
+[i0, i1, i2, p0]
+i3 = int_eq(i0, i1)
+guard_true(i3) []
+
+i4 = int_lt(i2, i0)
+guard_true(i4) []
+i5 = int_lt(i2, i1)
+guard_true(i5) []
+
+i6 = getarrayitem_gc(p0, i2)
+finish(i6)
+
+expected = 
+[i0, i1, i2, p0]
+i3 = int_eq(i0, i1)
+guard_true(i3) []
+
+i4 = int_lt(i2, i0)
+guard_true(i4) []
+
+i6 = getarrayitem_gc(p0, i3)
+finish(i6)
+
+self.optimize_loop(ops, expected)
+
 
 class TestLLtype(BaseTestOptimizeBasic, LLtypeMixin):
 pass
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy win64_gborg: test_chdir is fixed now for win32

2011-11-08 Thread ctismer
Author: Christian Tismer tis...@stackless.com
Branch: win64_gborg
Changeset: r48974:82f5470affc1
Date: 2011-11-08 20:52 +0100
http://bitbucket.org/pypy/pypy/changeset/82f5470affc1/

Log:test_chdir is fixed now for win32

diff --git a/pypy/rpython/module/test/test_ll_os.py 
b/pypy/rpython/module/test/test_ll_os.py
--- a/pypy/rpython/module/test/test_ll_os.py
+++ b/pypy/rpython/module/test/test_ll_os.py
@@ -81,7 +81,8 @@
 import ctypes
 buf = ctypes.create_string_buffer(1000)
 ctypes.windll.kernel32.GetEnvironmentVariableA('=%c:' % pwd[0], buf, 
1000)
-assert str(buf.value) == pwd
+assert str(buf.value).lower() == pwd
+# ctypes returns the drive letter in uppercase, os.getcwd does not
 
 pwd = os.getcwd()
 try:
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pyrepl py3ksupport: merge from default

2011-11-08 Thread RonnyPfannschmidt
Author: Ronny Pfannschmidt ronny.pfannschm...@gmx.de
Branch: py3ksupport
Changeset: r157:2bb3de20db46
Date: 2011-11-08 22:56 +0100
http://bitbucket.org/pypy/pyrepl/changeset/2bb3de20db46/

Log:merge from default

diff --git a/pyrepl/readline.py b/pyrepl/readline.py
--- a/pyrepl/readline.py
+++ b/pyrepl/readline.py
@@ -231,7 +231,11 @@
 return ''.join(chars)
 
 def _histline(self, line):
-return unicode(line.rstrip('\n'), ENCODING)
+line = line.rstrip('\n')
+try:
+return unicode(line, ENCODING)
+except UnicodeDecodeError:   # bah, silently fall back...
+return unicode(line, 'utf-8')
 
 def get_history_length(self):
 return self.saved_history_length
@@ -268,7 +272,10 @@
 f = open(os.path.expanduser(filename), 'w')
 for entry in history:
 if isinstance(entry, unicode):
-entry = entry.encode(ENCODING)
+try:
+entry = entry.encode(ENCODING)
+except UnicodeEncodeError:   # bah, silently fall back...
+entry = entry.encode('utf-8')
 entry = entry.replace('\n', '\r\n')   # multiline history support
 f.write(entry + '\n')
 f.close()
@@ -395,9 +402,21 @@
 _wrapper.f_in = f_in
 _wrapper.f_out = f_out
 
-if hasattr(sys, '__raw_input__'):# PyPy
-_old_raw_input = sys.__raw_input__
+if '__pypy__' in sys.builtin_module_names:# PyPy
+
+def _old_raw_input(prompt=''):
+# sys.__raw_input__() is only called when stdin and stdout are
+# as expected and are ttys.  If it is the case, then get_reader()
+# should not really fail in _wrapper.raw_input().  If it still
+# does, then we will just cancel the redirection and call again
+# the built-in raw_input().
+try:
+del sys.__raw_input__
+except AttributeError:
+pass
+return raw_input(prompt)
 sys.__raw_input__ = _wrapper.raw_input
+
 else:
 # this is not really what readline.c does.  Better than nothing I guess
 import __builtin__
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy win64_gborg: all of test_ll_os works now (more than before is started win64 ; -)

2011-11-08 Thread ctismer
Author: Christian Tismer tis...@stackless.com
Branch: win64_gborg
Changeset: r48975:d4d34a4e70e5
Date: 2011-11-08 23:45 +0100
http://bitbucket.org/pypy/pypy/changeset/d4d34a4e70e5/

Log:all of test_ll_os works now (more than before is started win64 ;-)

diff --git a/pypy/rpython/lltypesystem/llmemory.py 
b/pypy/rpython/lltypesystem/llmemory.py
--- a/pypy/rpython/lltypesystem/llmemory.py
+++ b/pypy/rpython/lltypesystem/llmemory.py
@@ -57,7 +57,7 @@
 return ItemOffset %r %r % (self.TYPE, self.repeat)
 
 def __mul__(self, other):
-if not isinstance(other, int):
+if not isinstance(other, (int, long)):
 return NotImplemented
 return ItemOffset(self.TYPE, self.repeat * other)
 
diff --git a/pypy/rpython/lltypesystem/lltype.py 
b/pypy/rpython/lltypesystem/lltype.py
--- a/pypy/rpython/lltypesystem/lltype.py
+++ b/pypy/rpython/lltypesystem/lltype.py
@@ -1655,7 +1655,7 @@
 __slots__ = ('items',)
 
 def __init__(self, TYPE, n, initialization=None, parent=None, 
parentindex=None):
-if not isinstance(n, int):
+if not isinstance(n, (int, long)):
 raise TypeError, array length must be an int
 if n  0:
 raise ValueError, negative array length
diff --git a/pypy/rpython/module/test/test_ll_os.py 
b/pypy/rpython/module/test/test_ll_os.py
--- a/pypy/rpython/module/test/test_ll_os.py
+++ b/pypy/rpython/module/test/test_ll_os.py
@@ -80,7 +80,10 @@
 pwd = os.getcwd()
 import ctypes
 buf = ctypes.create_string_buffer(1000)
-ctypes.windll.kernel32.GetEnvironmentVariableA('=%c:' % pwd[0], buf, 
1000)
+len = ctypes.windll.kernel32.GetEnvironmentVariableA('=%c:' % pwd[0], 
buf, 1000)
+if (len == 0) and WINGDB_PYTHON in os.environ:
+# the ctypes call seems not to work in the Wing debugger
+return
 assert str(buf.value).lower() == pwd
 # ctypes returns the drive letter in uppercase, os.getcwd does not
 
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pyrepl py3ksupport: fix up keymap creation

2011-11-08 Thread RonnyPfannschmidt
Author: Ronny Pfannschmidt ronny.pfannschm...@gmx.de
Branch: py3ksupport
Changeset: r158:9de498f86d73
Date: 2011-11-08 23:59 +0100
http://bitbucket.org/pypy/pyrepl/changeset/9de498f86d73/

Log:fix up keymap creation

diff --git a/pyrepl/keymap.py b/pyrepl/keymap.py
--- a/pyrepl/keymap.py
+++ b/pyrepl/keymap.py
@@ -174,7 +174,7 @@
 r = {}
 import pprint
 for key, value in keymap.items():
-r.setdefault(key[0], {})[key[1:]] = value
+r.setdefault(key[:1], {})[key[1:]] = value
 for key, value in r.items():
 if empty in value:
 if len(value) != 1:
diff --git a/testing/test_keymap.py b/testing/test_keymap.py
new file mode 100644
--- /dev/null
+++ b/testing/test_keymap.py
@@ -0,0 +1,10 @@
+from pyrepl.keymap import compile_keymap
+
+
+def test_compile_keymap():
+k = compile_keymap({
+b'a': 'test',
+b'bc': 'test2',
+})
+
+assert k == {b'a': 'test', b'b': { b'c': 'test2'}}
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] Notification: pypy

2011-11-08 Thread Bitbucket
You have received a notification from Dan Colish.

Hi, I forked pypy. My fork is at https://bitbucket.org/dcolish/pypy.

--
Disable notifications at https://bitbucket.org/account/notifications/
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy win64_gborg: test_ll_os_stat works now as well

2011-11-08 Thread ctismer
Author: Christian Tismer tis...@stackless.com
Branch: win64_gborg
Changeset: r48976:10717241c974
Date: 2011-11-09 01:32 +0100
http://bitbucket.org/pypy/pypy/changeset/10717241c974/

Log:test_ll_os_stat works now as well

diff --git a/pypy/rpython/module/ll_os_stat.py 
b/pypy/rpython/module/ll_os_stat.py
--- a/pypy/rpython/module/ll_os_stat.py
+++ b/pypy/rpython/module/ll_os_stat.py
@@ -319,6 +319,7 @@
 assert len(STAT_FIELDS) == 10# no extra fields on Windows
 
 def attributes_to_mode(attributes):
+attributes = lltype.r_uint(attributes)
 m = 0
 if attributes  win32traits.FILE_ATTRIBUTE_DIRECTORY:
 m |= win32traits._S_IFDIR | 0111 # IFEXEC for user,group,other
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy win64_gborg: test_ll_os_stat works now, too. Hint: never assume 'c:\temp' exists. Use the environ!

2011-11-08 Thread ctismer
Author: Christian Tismer tis...@stackless.com
Branch: win64_gborg
Changeset: r48977:ede54430f3a2
Date: 2011-11-09 01:48 +0100
http://bitbucket.org/pypy/pypy/changeset/ede54430f3a2/

Log:test_ll_os_stat works now, too. Hint: never assume 'c:\temp' exists.
Use the environ!

diff --git a/pypy/rpython/module/test/test_ll_os_stat.py 
b/pypy/rpython/module/test/test_ll_os_stat.py
--- a/pypy/rpython/module/test/test_ll_os_stat.py
+++ b/pypy/rpython/module/test/test_ll_os_stat.py
@@ -26,7 +26,7 @@
 assert wstat(unicode(f)).st_mtime == expected
 
 check('c:/')
-check('c:/temp')
+check(os.environ['TEMP'])
 check('c:/pagefile.sys')
 
 def test_fstat(self):
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy win64_gborg: test_ll_time: test_time_sleep works

2011-11-08 Thread ctismer
Author: Christian Tismer tis...@stackless.com
Branch: win64_gborg
Changeset: r48978:4e6f08cf4321
Date: 2011-11-09 02:34 +0100
http://bitbucket.org/pypy/pypy/changeset/4e6f08cf4321/

Log:test_ll_time: test_time_sleep works

diff --git a/pypy/rlib/rarithmetic.py b/pypy/rlib/rarithmetic.py
--- a/pypy/rlib/rarithmetic.py
+++ b/pypy/rlib/rarithmetic.py
@@ -487,6 +487,8 @@
 else:
 r_uint32 = r_uint
 
+# needed for ll_time.time_sleep_llimpl
+maxint32 = int((1  31) -1)
 
 # the 'float' C type
 
diff --git a/pypy/rpython/module/ll_time.py b/pypy/rpython/module/ll_time.py
--- a/pypy/rpython/module/ll_time.py
+++ b/pypy/rpython/module/ll_time.py
@@ -9,7 +9,7 @@
 from pypy.rpython.lltypesystem import lltype
 from pypy.rpython.extfunc import BaseLazyRegistering, registering, extdef
 from pypy.rlib import rposix
-from pypy.rlib.rarithmetic import intmask
+from pypy.rlib.rarithmetic import intmask, maxint32
 from pypy.translator.tool.cbuild import ExternalCompilationInfo
 
 if sys.platform == 'win32':
@@ -177,7 +177,7 @@
 @registering(time.sleep)
 def register_time_sleep(self):
 if sys.platform == 'win32':
-MAX = sys.maxint
+MAX = maxint32
 Sleep = self.llexternal('Sleep', [rffi.ULONG], lltype.Void)
 def time_sleep_llimpl(secs):
 millisecs = secs * 1000.0
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: improve pep3120 support

2011-11-08 Thread pjenvey
Author: Philip Jenvey pjen...@underboss.org
Branch: py3k
Changeset: r48979:75461738f371
Date: 2011-11-08 17:48 -0800
http://bitbucket.org/pypy/pypy/changeset/75461738f371/

Log:improve pep3120 support

diff --git a/pypy/interpreter/astcompiler/test/test_astbuilder.py 
b/pypy/interpreter/astcompiler/test/test_astbuilder.py
--- a/pypy/interpreter/astcompiler/test/test_astbuilder.py
+++ b/pypy/interpreter/astcompiler/test/test_astbuilder.py
@@ -1039,6 +1039,17 @@
 assert isinstance(s, ast.Str)
 assert space.eq_w(s.s, space.wrap(sentence))
 
+def test_string_pep3120(self):
+space = self.space
+japan = u'#26085;#26412;'
+source = ufoo = '%s' % japan
+info = pyparse.CompileInfo(test, exec)
+tree = self.parser.parse_source(source.encode(utf-8), info)
+assert info.encoding == utf-8
+s = ast_from_node(space, tree, info).body[0].value
+assert isinstance(s, ast.Str)
+assert space.eq_w(s.s, space.wrap(japan))
+
 def test_number(self):
 def get_num(s):
 node = self.get_first_expr(s)
diff --git a/pypy/interpreter/pyparser/pyparse.py 
b/pypy/interpreter/pyparser/pyparse.py
--- a/pypy/interpreter/pyparser/pyparse.py
+++ b/pypy/interpreter/pyparser/pyparse.py
@@ -5,8 +5,6 @@
 
 
 def recode_to_utf8(space, bytes, encoding=None):
-if encoding is None:
-encoding = 'utf-8'
 if encoding == 'utf-8':
 return bytes
 w_text = space.call_method(space.wrapbytes(bytes), decode,
@@ -121,6 +119,8 @@
 textsrc = bytessrc
 else:
 enc = _normalize_encoding(_check_for_encoding(bytessrc))
+if enc is None:
+enc = 'utf-8'
 try:
 textsrc = recode_to_utf8(self.space, bytessrc, enc)
 except OperationError, e:
diff --git a/pypy/interpreter/pyparser/test/test_pyparse.py 
b/pypy/interpreter/pyparser/test/test_pyparse.py
--- a/pypy/interpreter/pyparser/test/test_pyparse.py
+++ b/pypy/interpreter/pyparser/test/test_pyparse.py
@@ -64,6 +64,11 @@
 assert exc.msg == ('ascii' codec can't decode byte 0xc3 
in position 16: ordinal not in range(128))
 
+def test_encoding_pep3120(self):
+info = pyparse.CompileInfo(test, exec)
+tree = self.parse(foo = '#26085;#26412;', info=info)
+assert info.encoding == 'utf-8'
+
 def test_syntax_error(self):
 parse = self.parse
 exc = py.test.raises(SyntaxError, parse, name another for).value
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: fix bytes' repr

2011-11-08 Thread pjenvey
Author: Philip Jenvey pjen...@underboss.org
Branch: py3k
Changeset: r48980:0357086d2dc0
Date: 2011-11-08 18:08 -0800
http://bitbucket.org/pypy/pypy/changeset/0357086d2dc0/

Log:fix bytes' repr

diff --git a/pypy/objspace/std/stringobject.py 
b/pypy/objspace/std/stringobject.py
--- a/pypy/objspace/std/stringobject.py
+++ b/pypy/objspace/std/stringobject.py
@@ -897,8 +897,9 @@
 
 def string_escape_encode(s, quote):
 
-buf = StringBuilder(len(s) + 2)
+buf = StringBuilder(len(s) + 3)
 
+buf.append('b')
 buf.append(quote)
 startslice = 0
 
diff --git a/pypy/objspace/std/test/test_stringobject.py 
b/pypy/objspace/std/test/test_stringobject.py
--- a/pypy/objspace/std/test/test_stringobject.py
+++ b/pypy/objspace/std/test/test_stringobject.py
@@ -618,23 +618,23 @@
 assert l == [52, 50]
 
 def test_repr(self):
-assert repr(b)   ==''
-assert repr(ba)  =='a'
-assert repr(b')  =='\''
-assert repr(b\') ==\\'\
-assert repr(b\) =='\'\''
-assert repr(b\t) =='\\t'
-assert repr(b\\) ==''
-assert repr(b'')   ==''
-assert repr(b'a')  =='a'
-assert repr(b'')  =='\'
-assert repr(b'\'') =='\''
-assert repr(b'\') =='\'
-assert repr(b'\t') =='\\t'
-assert repr(b'\\') ==''
-assert repr(b'''\)  =='\'\\\'\\\'\\\'\''
-assert repr(b\x13)   =='\\x13'
-assert repr(b\x02)   =='\\x02'
+assert repr(b)   ==b''
+assert repr(ba)  ==b'a'
+assert repr(b')  =='b\''
+assert repr(b\') ==b\\'\
+assert repr(b\) =='b\'\''
+assert repr(b\t) ==b'\\t'
+assert repr(b\\) ==b''
+assert repr(b'')   ==b''
+assert repr(b'a')  ==b'a'
+assert repr(b'')  ==b'\'
+assert repr(b'\'') =='b\''
+assert repr(b'\') ==b'\'
+assert repr(b'\t') ==b'\\t'
+assert repr(b'\\') ==b''
+assert repr(b'''\)  =='b\'\\\'\\\'\\\'\''
+assert repr(b\x13)   ==b'\\x13'
+assert repr(b\x02)   ==b'\\x02'
 
 def test_contains(self):
 assert b'' in b'abc'
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy win64_gborg: test_posix: test_open works

2011-11-08 Thread ctismer
Author: Christian Tismer tis...@stackless.com
Branch: win64_gborg
Changeset: r48981:d8a8d1ed4a04
Date: 2011-11-09 03:21 +0100
http://bitbucket.org/pypy/pypy/changeset/d8a8d1ed4a04/

Log:test_posix: test_open works

diff --git a/pypy/rpython/module/ll_os.py b/pypy/rpython/module/ll_os.py
--- a/pypy/rpython/module/ll_os.py
+++ b/pypy/rpython/module/ll_os.py
@@ -791,7 +791,7 @@
   [traits.CCHARP, rffi.INT, rffi.MODE_T],
   rffi.INT)
 def os_open_llimpl(path, flags, mode):
-result = rffi.cast(rffi.LONG, os_open(path, flags, mode))
+result = rffi.cast(lltype.Signed, os_open(path, flags, mode))
 if result == -1:
 raise OSError(rposix.get_errno(), os_open failed)
 return result
diff --git a/pypy/rpython/module/test/test_posix.py 
b/pypy/rpython/module/test/test_posix.py
--- a/pypy/rpython/module/test/test_posix.py
+++ b/pypy/rpython/module/test/test_posix.py
@@ -18,10 +18,10 @@
 
 def test_open(self):
 def f():
-ff = posix.open(path,posix.O_RDONLY,0777)
+ff = posix.open(path, posix.O_RDONLY, 0777)
 return ff
-func = self.interpret(f,[])
-assert type(func) == int
+func = self.interpret(f, [])
+assert isinstance(func, (int, long))
 
 def test_fstat(self):
 def fo(fi):
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy win64_gborg: test_posix: test_isatty works

2011-11-08 Thread ctismer
Author: Christian Tismer tis...@stackless.com
Branch: win64_gborg
Changeset: r48982:dc98b8e33da9
Date: 2011-11-09 03:32 +0100
http://bitbucket.org/pypy/pypy/changeset/dc98b8e33da9/

Log:test_posix: test_isatty works

diff --git a/pypy/rpython/module/ll_os.py b/pypy/rpython/module/ll_os.py
--- a/pypy/rpython/module/ll_os.py
+++ b/pypy/rpython/module/ll_os.py
@@ -1317,7 +1317,7 @@
 os_isatty = self.llexternal(underscore_on_windows+'isatty', 
[rffi.INT], rffi.INT)
 
 def isatty_llimpl(fd):
-res = rffi.cast(rffi.LONG, os_isatty(rffi.cast(rffi.INT, fd)))
+res = rffi.cast(lltype.Signed, os_isatty(rffi.cast(rffi.INT, fd)))
 return res != 0
 
 return extdef([int], bool, llimpl=isatty_llimpl,
diff --git a/pypy/rpython/module/test/test_posix.py 
b/pypy/rpython/module/test/test_posix.py
--- a/pypy/rpython/module/test/test_posix.py
+++ b/pypy/rpython/module/test/test_posix.py
@@ -65,21 +65,21 @@
 
 
 def test_lseek(self):
-def f(fi,pos):
-posix.lseek(fi,pos,0)
-fi = os.open(path,os.O_RDONLY,0777)
-func = self.interpret(f,[fi,5]) 
-res = os.read(fi,2)
+def f(fi, pos):
+posix.lseek(fi, pos, 0)
+fi = os.open(path, os.O_RDONLY, 0777)
+func = self.interpret(f, [fi, 5]) 
+res = os.read(fi, 2)
 assert res =='is'
 
 def test_isatty(self):
 def f(fi):
 posix.isatty(fi)
-fi = os.open(path,os.O_RDONLY,0777)
-func = self.interpret(f,[fi])
+fi = os.open(path, os.O_RDONLY, 0777)
+func = self.interpret(f, [fi])
 assert not func
 os.close(fi)
-func = self.interpret(f,[fi])
+func = self.interpret(f, [fi])
 assert not func
 
 def test_getcwd(self):
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy numpy-dtype-refactor: begin refactoring everything. nothing works.

2011-11-08 Thread alex_gaynor
Author: Alex Gaynor alex.gay...@gmail.com
Branch: numpy-dtype-refactor
Changeset: r48983:f9f4bedbab84
Date: 2011-11-08 22:22 -0500
http://bitbucket.org/pypy/pypy/changeset/f9f4bedbab84/

Log:begin refactoring everything. nothing works.

diff --git a/pypy/module/micronumpy/compile.py 
b/pypy/module/micronumpy/compile.py
--- a/pypy/module/micronumpy/compile.py
+++ b/pypy/module/micronumpy/compile.py
@@ -4,7 +4,8 @@
 
 
 from pypy.interpreter.baseobjspace import InternalSpaceCache, W_Root
-from pypy.module.micronumpy.interp_dtype import W_Float64Dtype, W_BoolDtype
+from pypy.module.micronumpy.interp_boxes import W_GenericBox
+from pypy.module.micronumpy.interp_dtype import get_dtype_cache
 from pypy.module.micronumpy.interp_numarray import (Scalar, BaseArray,
  descr_new_array, scalar_w, SingleDimArray)
 from pypy.module.micronumpy import interp_ufuncs
@@ -40,7 +41,7 @@
 def __init__(self):
 NOT_RPYTHON
 self.fromcache = InternalSpaceCache(self).getorbuild
-self.w_float64dtype = W_Float64Dtype(self)
+self.w_float64dtype = get_dtype_cache(self).w_float64dtype
 
 def issequence_w(self, w_obj):
 return isinstance(w_obj, ListObject) or isinstance(w_obj, 
SingleDimArray)
@@ -73,7 +74,7 @@
 return w_obj
 
 def float_w(self, w_obj):
-assert isinstance(w_obj, FloatObject)
+assert isinstance(w_obj, FloatObject)
 return w_obj.floatval
 
 def int_w(self, w_obj):
@@ -206,18 +207,18 @@
 elif self.name == '*':
 w_res = w_lhs.descr_mul(interp.space, w_rhs)
 elif self.name == '-':
-w_res = w_lhs.descr_sub(interp.space, w_rhs)
+w_res = w_lhs.descr_sub(interp.space, w_rhs)
 elif self.name == '-':
 if isinstance(w_rhs, Scalar):
 index = int(interp.space.float_w(
-w_rhs.value.wrap(interp.space)))
+w_rhs.value))
 dtype = interp.space.fromcache(W_Float64Dtype)
 return Scalar(dtype, w_lhs.get_concrete().eval(index))
 else:
 raise NotImplementedError
 else:
 raise NotImplementedError
-if not isinstance(w_res, BaseArray):
+if not isinstance(w_res, BaseArray) and not isinstance(w_res, 
W_GenericBox):
 dtype = interp.space.fromcache(W_Float64Dtype)
 w_res = scalar_w(interp.space, dtype, w_res)
 return w_res
@@ -236,8 +237,7 @@
 return space.wrap(self.v)
 
 def execute(self, interp):
-dtype = interp.space.fromcache(W_Float64Dtype)
-assert isinstance(dtype, W_Float64Dtype)
+dtype = get_dtype_cache(interp.space).w_float64dtype
 return Scalar(dtype, dtype.box(self.v))
 
 class RangeConstant(Node):
@@ -269,7 +269,7 @@
 
 def execute(self, interp):
 w_list = self.wrap(interp.space)
-dtype = interp.space.fromcache(W_Float64Dtype)
+dtype = get_dtype_cache(interp.space).w_float64dtype
 return descr_new_array(interp.space, None, w_list, w_dtype=dtype)
 
 def __repr__(self):
@@ -414,7 +414,7 @@
 assert lgt = 0
 rhs = self.parse_constant_or_identifier(l[1][:lgt])
 return l[0], rhs
-
+
 def parse_statement(self, line):
 if '=' in line:
 lhs, rhs = line.split(=)
@@ -422,7 +422,7 @@
 if '[' in lhs:
 name, index = self.parse_array_subscript(lhs)
 return ArrayAssignment(name, index, self.parse_expression(rhs))
-else: 
+else:
 return Assignment(lhs, self.parse_expression(rhs))
 else:
 return Execute(self.parse_expression(line))
diff --git a/pypy/module/micronumpy/interp_dtype.py 
b/pypy/module/micronumpy/interp_dtype.py
--- a/pypy/module/micronumpy/interp_dtype.py
+++ b/pypy/module/micronumpy/interp_dtype.py
@@ -1,519 +1,132 @@
-import functools
-import math
-
 from pypy.interpreter.baseobjspace import Wrappable
-from pypy.interpreter.error import OperationError
-from pypy.interpreter.gateway import interp2app
-from pypy.interpreter.typedef import TypeDef, interp_attrproperty, 
GetSetProperty
-from pypy.module.micronumpy import signature
-from pypy.objspace.std.floatobject import float2string
-from pypy.rlib import rarithmetic, rfloat
-from pypy.rlib.rarithmetic import LONG_BIT, widen
-from pypy.rlib.objectmodel import specialize, enforceargs
-from pypy.rlib.unroll import unrolling_iterable
+from pypy.module.micronumpy import types, signature
+from pypy.rlib.objectmodel import specialize
+from pypy.rlib.rarithmetic import LONG_BIT
 from pypy.rpython.lltypesystem import lltype, rffi
 
 
+STORAGE_TYPE = lltype.Array(lltype.Char, hints={nolength: True})
+
 UNSIGNEDLTR = u
 SIGNEDLTR = i
 BOOLLTR = b
 FLOATINGLTR = f
 
 class W_Dtype(Wrappable):
+def __init__(self, itemtype, num, kind):
+self.signature = signature.BaseSignature()
+

[pypy-commit] pypy numpy-dtype-refactor: more updates to code and tests

2011-11-08 Thread alex_gaynor
Author: Alex Gaynor alex.gay...@gmail.com
Branch: numpy-dtype-refactor
Changeset: r48984:b055942a4830
Date: 2011-11-08 23:26 -0500
http://bitbucket.org/pypy/pypy/changeset/b055942a4830/

Log:more updates to code and tests

diff --git a/pypy/module/micronumpy/compile.py 
b/pypy/module/micronumpy/compile.py
--- a/pypy/module/micronumpy/compile.py
+++ b/pypy/module/micronumpy/compile.py
@@ -4,7 +4,7 @@
 
 
 from pypy.interpreter.baseobjspace import InternalSpaceCache, W_Root
-from pypy.module.micronumpy.interp_boxes import W_GenericBox
+from pypy.module.micronumpy import interp_boxes
 from pypy.module.micronumpy.interp_dtype import get_dtype_cache
 from pypy.module.micronumpy.interp_numarray import (Scalar, BaseArray,
  descr_new_array, scalar_w, SingleDimArray)
@@ -70,8 +70,10 @@
 return obj.items
 
 def float(self, w_obj):
-assert isinstance(w_obj, FloatObject)
-return w_obj
+if isinstance(w_obj, FloatObject):
+return w_obj
+assert isinstance(w_obj, interp_boxes.W_FloatingBox)
+return FloatObject(w_obj.value)
 
 def float_w(self, w_obj):
 assert isinstance(w_obj, FloatObject)
@@ -172,8 +174,8 @@
 
 def execute(self, interp):
 arr = interp.variables[self.name]
-w_index = self.index.execute(interp).eval(0).wrap(interp.space)
-w_val = self.expr.execute(interp).eval(0).wrap(interp.space)
+w_index = self.index.execute(interp).eval(0)
+w_val = self.expr.execute(interp).eval(0)
 arr.descr_setitem(interp.space, w_index, w_val)
 
 def __repr__(self):
@@ -210,15 +212,15 @@
 w_res = w_lhs.descr_sub(interp.space, w_rhs)
 elif self.name == '-':
 if isinstance(w_rhs, Scalar):
-index = int(interp.space.float_w(
-w_rhs.value))
-dtype = interp.space.fromcache(W_Float64Dtype)
+index = 
int(interp.space.float_w(interp.space.float(w_rhs.value)))
+dtype = get_dtype_cache(interp.space).w_float64dtype
 return Scalar(dtype, w_lhs.get_concrete().eval(index))
 else:
 raise NotImplementedError
 else:
 raise NotImplementedError
-if not isinstance(w_res, BaseArray) and not isinstance(w_res, 
W_GenericBox):
+if (not isinstance(w_res, BaseArray) and
+not isinstance(w_res, interp_boxes.W_GenericBox)):
 dtype = interp.space.fromcache(W_Float64Dtype)
 w_res = scalar_w(interp.space, dtype, w_res)
 return w_res
@@ -246,8 +248,9 @@
 
 def execute(self, interp):
 w_list = interp.space.newlist(
-[interp.space.wrap(float(i)) for i in range(self.v)])
-dtype = interp.space.fromcache(W_Float64Dtype)
+[interp.space.wrap(float(i)) for i in range(self.v)]
+)
+dtype = get_dtype_cache(interp.space).w_float64dtype
 return descr_new_array(interp.space, None, w_list, w_dtype=dtype)
 
 def __repr__(self):
@@ -331,6 +334,8 @@
 dtype = interp.space.fromcache(W_Float64Dtype)
 elif isinstance(w_res, BoolObject):
 dtype = interp.space.fromcache(W_BoolDtype)
+elif isinstance(w_res, interp_boxes.W_GenericBox):
+dtype = w_res.descr_get_dtype(interp.space)
 else:
 dtype = None
 return scalar_w(interp.space, dtype, w_res)
diff --git a/pypy/module/micronumpy/interp_numarray.py 
b/pypy/module/micronumpy/interp_numarray.py
--- a/pypy/module/micronumpy/interp_numarray.py
+++ b/pypy/module/micronumpy/interp_numarray.py
@@ -309,7 +309,7 @@
 return scalar_w(space, dtype, w_obj)
 
 def scalar_w(space, dtype, w_obj):
-return Scalar(dtype, dtype.unwrap(space, w_obj))
+return Scalar(dtype, dtype.coerce(space, w_obj))
 
 class Scalar(BaseArray):
 
diff --git a/pypy/module/micronumpy/interp_ufuncs.py 
b/pypy/module/micronumpy/interp_ufuncs.py
--- a/pypy/module/micronumpy/interp_ufuncs.py
+++ b/pypy/module/micronumpy/interp_ufuncs.py
@@ -74,7 +74,7 @@
 new_sig = signature.Signature.find_sig([
 self.reduce_signature, obj.signature
 ])
-return self.reduce(new_sig, start, value, obj, dtype, size).wrap(space)
+return self.reduce(new_sig, start, value, obj, dtype, size)
 
 def reduce(self, signature, start, value, obj, dtype, size):
 i = start
@@ -235,7 +235,7 @@
 if dt.kind == interp_dtype.BOOLLTR or dt.kind == 
interp_dtype.SIGNEDLTR:
 return space.fromcache(interp_dtype.W_Int64Dtype)
 elif dt.kind == interp_dtype.FLOATINGLTR:
-return space.fromcache(interp_dtype.W_Float64Dtype)
+return interp_dtype.get_dtype_cache(space).w_float64dtype
 elif dt.kind == interp_dtype.UNSIGNEDLTR:
 return space.fromcache(interp_dtype.W_UInt64Dtype)
 else:
diff --git