[pypy-commit] pypy ppc-jit-backend: Implemented STRLEN, STRGETITEM, STRSETITEM.

2011-10-25 Thread hager
Author: hager sven.ha...@uni-duesseldorf.de
Branch: ppc-jit-backend
Changeset: r48407:7c2f8272c677
Date: 2011-10-25 09:46 +0200
http://bitbucket.org/pypy/pypy/changeset/7c2f8272c677/

Log:Implemented STRLEN, STRGETITEM, STRSETITEM.

diff --git a/pypy/jit/backend/ppc/ppcgen/opassembler.py 
b/pypy/jit/backend/ppc/ppcgen/opassembler.py
--- a/pypy/jit/backend/ppc/ppcgen/opassembler.py
+++ b/pypy/jit/backend/ppc/ppcgen/opassembler.py
@@ -371,5 +371,32 @@
 signed = descr.is_item_signed()
 self._ensure_result_bit_extension(res, size, signed)
 
+# XXX 64 bit adjustment needed
+def emit_strlen(self, op, arglocs, regalloc):
+l0, l1, res = arglocs
+if l1.is_imm():
+self.mc.lwz(res.value, l0.value, l1.getint())
+else:
+self.mc.lwzx(res.value, l0.value, l1.value)
+
+def emit_strgetitem(self, op, arglocs, regalloc):
+res, base_loc, ofs_loc, basesize = arglocs
+if ofs_loc.is_imm():
+self.mc.addi(res.value, base_loc.value, ofs_loc.getint())
+else:
+self.mc.add(res.value, base_loc.value, ofs_loc.value)
+
+self.mc.load_imm(r.r0, basesize.value)
+self.mc.lbzx(res.value, res.value, r.r0.value)
+
+def emit_strsetitem(self, op, arglocs, regalloc):
+value_loc, base_loc, ofs_loc, basesize = arglocs
+if ofs_loc.is_imm():
+self.mc.addi(base_loc.value, base_loc.value, ofs_loc.getint())
+else:
+self.mc.add(base_loc.value, base_loc.value, ofs_loc.value)
+self.mc.load_imm(r.r0, basesize.value)
+self.mc.stbx(value_loc.value, base_loc.value, r.r0.value)
+
 def nop(self):
 self.mc.ori(0, 0, 0)
diff --git a/pypy/jit/backend/ppc/ppcgen/regalloc.py 
b/pypy/jit/backend/ppc/ppcgen/regalloc.py
--- a/pypy/jit/backend/ppc/ppcgen/regalloc.py
+++ b/pypy/jit/backend/ppc/ppcgen/regalloc.py
@@ -16,7 +16,8 @@
  BaseCallDescr, BaseSizeDescr
 from pypy.jit.metainterp.resoperation import rop
 from pypy.jit.backend.ppc.ppcgen import locations
-from pypy.rpython.lltypesystem import rffi, lltype
+from pypy.rpython.lltypesystem import rffi, lltype, rstr
+from pypy.jit.backend.llsupport import symbolic
 import pypy.jit.backend.ppc.ppcgen.register as r
 
 class TempInt(TempBox):
@@ -413,6 +414,67 @@
 self.possibly_free_var(op.result)
 return [res, base_loc, ofs_loc, imm(scale), imm(ofs)]
 
+def prepare_strlen(self, op):
+l0, box = self._ensure_value_is_boxed(op.getarg(0))
+boxes = [box]
+
+basesize, itemsize, ofs_length = symbolic.get_array_token(rstr.STR,
+ self.cpu.translate_support_code)
+ofs_box = ConstInt(ofs_length)
+imm_ofs = _check_imm_arg(ofs_box)
+
+if imm_ofs:
+l1 = self.make_sure_var_in_reg(ofs_box, boxes)
+else:
+l1, box1 = self._ensure_value_is_boxed(ofs_box, boxes)
+boxes.append(box1)
+
+self.possibly_free_vars(boxes)
+res = self.force_allocate_reg(op.result)
+self.possibly_free_var(op.result)
+return [l0, l1, res]
+
+def prepare_strgetitem(self, op):
+boxes = list(op.getarglist())
+base_loc, box = self._ensure_value_is_boxed(boxes[0])
+boxes.append(box)
+
+a1 = boxes[1]
+imm_a1 = _check_imm_arg(a1)
+if imm_a1:
+ofs_loc = self.make_sure_var_in_reg(a1, boxes)
+else:
+ofs_loc, box = self._ensure_value_is_boxed(a1, boxes)
+boxes.append(box)
+
+self.possibly_free_vars(boxes)
+res = self.force_allocate_reg(op.result)
+self.possibly_free_var(op.result)
+
+basesize, itemsize, ofs_length = symbolic.get_array_token(rstr.STR,
+ self.cpu.translate_support_code)
+assert itemsize == 1
+return [res, base_loc, ofs_loc, imm(basesize)]
+
+def prepare_strsetitem(self, op):
+boxes = list(op.getarglist())
+
+base_loc, box = self._ensure_value_is_boxed(boxes[0], boxes)
+boxes.append(box)
+
+ofs_loc, box = self._ensure_value_is_boxed(boxes[1], boxes)
+boxes.append(box)
+
+value_loc, box = self._ensure_value_is_boxed(boxes[2], boxes)
+boxes.append(box)
+
+self.possibly_free_vars(boxes)
+
+basesize, itemsize, ofs_length = symbolic.get_array_token(rstr.STR,
+ self.cpu.translate_support_code)
+assert itemsize == 1
+return [value_loc, base_loc, ofs_loc, imm(basesize)]
+
 # from ../x86/regalloc.py:791
 def _unpack_fielddescr(self, fielddescr):
 assert isinstance(fielddescr, BaseFieldDescr)
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] benchmarks default: improve cpython saver

2011-10-25 Thread fijal
Author: Maciej Fijalkowski fij...@gmail.com
Branch: 
Changeset: r148:05f934e964ab
Date: 2011-10-25 10:47 +0200
http://bitbucket.org/pypy/benchmarks/changeset/05f934e964ab/

Log:improve cpython saver

diff --git a/savecpython.py b/savecpython.py
--- a/savecpython.py
+++ b/savecpython.py
@@ -4,11 +4,13 @@
 import json
 import urllib, urllib2
 from datetime import datetime
+import optparse
 
 #SPEEDURL = 'http://127.0.0.1:8000/'
 SPEEDURL = 'http://speed.pypy.org/'
 
-def save(project, revision, results, options, executable, host, testing=False):
+def save(project, revision, results, options, executable, host, testing=False,
+ base=False):
 testparams = []
 #Parse data
 data = {}
@@ -20,9 +22,15 @@
 results = b[2]
 value = 0
 if res_type == SimpleComparisonResult:
-value = results['base_time']
+if base:
+value = results['base_time']
+else:
+value = results['changed_time']
 elif res_type == ComparisonResult:
-value = results['avg_base']
+if base:
+value = results['avg_base']
+else:
+value = results['avg_changed']
 else:
 print(ERROR: result type unknown  + b[1])
 return 1
@@ -36,7 +44,10 @@
 'result_date': current_date,
 }
 if res_type == ComparisonResult:
-data['std_dev'] = results['std_changed']
+if base:
+data['std_dev'] = results['std_base']
+else:
+data['std_dev'] = results['std_changed']
 if testing: testparams.append(data)
 else: send(data)
 if testing: return testparams
@@ -62,9 +73,19 @@
 response = '\n  The server couldn\'t fulfill the request\n'
 response += '  Error code: ' + str(e)
 print(Server (%s) response: %s\n % (SPEEDURL, response))
+if hasattr(e, 'fp'):
+print e.fp.read(), \n
 return 1
 return 0
 
 if __name__ == '__main__':
-results = json.load(open(sys.argv[1]))['results']
-save('cpython', 100, results, None, 'cpython', 'tannit', testing=False)
+parser = optparse.OptionParser()
+parser.add_option('-b', '--base', action='store_true',
+  help='take base values instead of modified')
+options, args = parser.parse_args(sys.argv)
+if len(args) != 2:
+print parser.usage
+sys.exit(1)
+results = json.load(open(args[1]))['results']
+save('cpython', 100, results, None, 'cpython', 'tannit', testing=False,
+ base=options.base)
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] benchmarks default: finish fighting

2011-10-25 Thread fijal
Author: Maciej Fijalkowski fij...@gmail.com
Branch: 
Changeset: r149:354e7ef9ccde
Date: 2011-10-25 10:59 +0200
http://bitbucket.org/pypy/benchmarks/changeset/354e7ef9ccde/

Log:finish fighting

diff --git a/savecpython.py b/savecpython.py
--- a/savecpython.py
+++ b/savecpython.py
@@ -21,11 +21,14 @@
 res_type = b[1]
 results = b[2]
 value = 0
-if res_type == SimpleComparisonResult:
+if res_type == SimpleComparisonResult or res_type == 'RawResult':
 if base:
-value = results['base_time']
+value = results['base_times']
 else:
-value = results['changed_time']
+value = results['changed_times']
+if value is None:
+continue
+value = value[0]
 elif res_type == ComparisonResult:
 if base:
 value = results['avg_base']
@@ -42,6 +45,7 @@
 'environment': host,
 'result_value': value,
 'result_date': current_date,
+'branch': 'default',
 }
 if res_type == ComparisonResult:
 if base:
@@ -82,10 +86,13 @@
 parser = optparse.OptionParser()
 parser.add_option('-b', '--base', action='store_true',
   help='take base values instead of modified')
+parser.add_option('--revision', help='revision number', type=int,
+  default=100)
 options, args = parser.parse_args(sys.argv)
 if len(args) != 2:
 print parser.usage
 sys.exit(1)
 results = json.load(open(args[1]))['results']
-save('cpython', 100, results, None, 'cpython', 'tannit', testing=False,
+save('cpython', options.revision, results, None, 'cpython', 'tannit',
+ testing=False,
  base=options.base)
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy arm-backend-2: there was a word missing here

2011-10-25 Thread bivab
Author: David Schneider david.schnei...@picle.org
Branch: arm-backend-2
Changeset: r48410:beae95ba795c
Date: 2011-10-13 17:54 +0200
http://bitbucket.org/pypy/pypy/changeset/beae95ba795c/

Log:there was a word missing here

diff --git a/pypy/jit/backend/arm/assembler.py 
b/pypy/jit/backend/arm/assembler.py
--- a/pypy/jit/backend/arm/assembler.py
+++ b/pypy/jit/backend/arm/assembler.py
@@ -740,7 +740,7 @@
 return l
 
 def _patch_sp_offset(self, pos, frame_depth):
-cb = OverwritingBuilder(self.mc, pos, 
OverwritingBuilder.size_of_gen_load_int)
+cb = OverwritingBuilder(self.mc, pos, 
OverwritingBuilder.size_of_gen_load_int+WORD)
 # Note: the frame_depth is one less than the value stored in the frame
 # manager
 if frame_depth == 1:
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy arm-backend-2: (arigo, bivab) refactor a bit and fix decode_inputargs when checking spilled floating point values

2011-10-25 Thread bivab
Author: David Schneider david.schnei...@picle.org
Branch: arm-backend-2
Changeset: r48411:744854db4b1c
Date: 2011-10-19 10:51 +0200
http://bitbucket.org/pypy/pypy/changeset/744854db4b1c/

Log:(arigo, bivab) refactor a bit and fix decode_inputargs when checking
spilled floating point values

diff --git a/pypy/jit/backend/arm/assembler.py 
b/pypy/jit/backend/arm/assembler.py
--- a/pypy/jit/backend/arm/assembler.py
+++ b/pypy/jit/backend/arm/assembler.py
@@ -36,6 +36,7 @@
 
 Encoding for locations in memory
 types:
+\xED = FLOAT
 \xEE = REF
 \xEF = INT
 location:
@@ -98,6 +99,7 @@
 self._regalloc = None
 self.mc = None
 self.pending_guards = None
+assert self.datablockwrapper is None
 
 def setup_once(self):
 # Addresses of functions called by new_xxx operations
@@ -267,16 +269,14 @@
 self.fail_force_index = frame_loc
 return descr
 
-def decode_inputargs(self, enc, inputargs, regalloc):
+def decode_inputargs(self, enc, regalloc):
 locs = []
 j = 0
-for i in range(len(inputargs)):
+while enc[j] != self.END_OF_LOCS:
 res = enc[j]
-if res == self.END_OF_LOCS:
-assert 0, 'reached end of encoded area'
-while res == self.EMPTY_LOC:
+if res == self.EMPTY_LOC:
 j += 1
-res = enc[j]
+continue
 
 assert res in [self.FLOAT_TYPE, self.INT_TYPE, self.REF_TYPE], 
'location type is not supported'
 res_type = res
@@ -286,10 +286,14 @@
 # XXX decode imm if necessary
 assert 0, 'Imm Locations are not supported'
 elif res == self.STACK_LOC:
-if res_type == FLOAT:
-assert 0, 'float on stack'
+if res_type == self.FLOAT_TYPE:
+t = FLOAT
+elif res_type == self.INT_TYPE:
+t = INT
+else:
+t = REF
 stack_loc = decode32(enc, j+1)
-loc = regalloc.frame_manager.frame_pos(stack_loc, INT)
+loc = regalloc.frame_manager.frame_pos(stack_loc, t)
 j += 4
 else: # REG_LOC
 if res_type == self.FLOAT_TYPE:
@@ -665,7 +669,8 @@
 
 sp_patch_location = self._prepare_sp_patch_position()
 frame_depth = faildescr._arm_frame_depth
-locs = self.decode_inputargs(enc, inputargs, regalloc)
+locs = self.decode_inputargs(enc, regalloc)
+assert len(inputargs) == len(locs)
 regalloc.update_bindings(locs, frame_depth, inputargs)
 
 self._walk_operations(operations, regalloc)
@@ -862,7 +867,7 @@
 self.mc.VLDR(loc.value, r.ip.value)
 
 def _mov_imm_to_loc(self, prev_loc, loc, cond=c.AL):
-if not loc.is_reg() and not (loc.is_stack() and loc.type == INT):
+if not loc.is_reg() and not (loc.is_stack() and loc.type != FLOAT):
 raise AssertionError(invalid target for move from imm value)
 if loc.is_reg():
 new_loc = loc
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy arm-backend-2: set the name of generated functions for floatint point operations

2011-10-25 Thread bivab
Author: David Schneider david.schnei...@picle.org
Branch: arm-backend-2
Changeset: r48412:411d754b81a2
Date: 2011-10-19 10:53 +0200
http://bitbucket.org/pypy/pypy/changeset/411d754b81a2/

Log:set the name of generated functions for floatint point operations

diff --git a/pypy/jit/backend/arm/helper/regalloc.py 
b/pypy/jit/backend/arm/helper/regalloc.py
--- a/pypy/jit/backend/arm/helper/regalloc.py
+++ b/pypy/jit/backend/arm/helper/regalloc.py
@@ -1,7 +1,7 @@
 from pypy.jit.backend.arm import conditions as c
 from pypy.jit.backend.arm import registers as r
 from pypy.jit.backend.arm.codebuilder import AbstractARMv7Builder
-from pypy.jit.metainterp.history import ConstInt, BoxInt, Box
+from pypy.jit.metainterp.history import ConstInt, BoxInt, Box, FLOAT
 from pypy.jit.metainterp.history import ConstInt
 
 # XXX create a version that does not need a ConstInt
@@ -56,7 +56,7 @@
 f.__name__ = name
 return f
 
-def prepare_float_op(base=True, float_result=True):
+def prepare_float_op(name=None, base=True, float_result=True):
 def f(self, op, fcond):
 locs = []
 loc1, box1 = self._ensure_value_is_boxed(op.getarg(0))
@@ -66,13 +66,13 @@
 locs.append(loc2)
 self.possibly_free_var(box2)
 self.possibly_free_var(box1)
-if float_result:
-res  = self.vfprm.force_allocate_reg(op.result)
-else:
-res  = self.rm.force_allocate_reg(op.result)
+res = self.force_allocate_reg(op.result)
+assert float_result == (op.result.type == FLOAT)
 self.possibly_free_var(op.result)
 locs.append(res)
 return locs
+if name:
+f.__name__ = name
 return f
 
 def prepare_op_by_helper_call(name):
diff --git a/pypy/jit/backend/arm/regalloc.py b/pypy/jit/backend/arm/regalloc.py
--- a/pypy/jit/backend/arm/regalloc.py
+++ b/pypy/jit/backend/arm/regalloc.py
@@ -1072,18 +1072,18 @@
 return size, scale, ofs, ofs_length, ptr
 
 
-prepare_op_float_add = prepare_float_op()
-prepare_op_float_sub = prepare_float_op()
-prepare_op_float_mul = prepare_float_op()
-prepare_op_float_truediv = prepare_float_op()
-prepare_op_float_lt = prepare_float_op(float_result=False)
-prepare_op_float_le = prepare_float_op(float_result=False)
-prepare_op_float_eq = prepare_float_op(float_result=False)
-prepare_op_float_ne = prepare_float_op(float_result=False)
-prepare_op_float_gt = prepare_float_op(float_result=False)
-prepare_op_float_ge = prepare_float_op(float_result=False)
-prepare_op_float_neg = prepare_float_op(base=False)
-prepare_op_float_abs = prepare_float_op(base=False)
+prepare_op_float_add = prepare_float_op(name='float_add')
+prepare_op_float_sub = prepare_float_op(name='float_sub')
+prepare_op_float_mul = prepare_float_op(name='float_mul')
+prepare_op_float_truediv = prepare_float_op(name='float_truediv')
+prepare_op_float_lt = prepare_float_op(float_result=False, name='float_lt')
+prepare_op_float_le = prepare_float_op(float_result=False, name='float_le')
+prepare_op_float_eq = prepare_float_op(float_result=False, name='float_eq')
+prepare_op_float_ne = prepare_float_op(float_result=False, name='float_ne')
+prepare_op_float_gt = prepare_float_op(float_result=False, name='float_gt')
+prepare_op_float_ge = prepare_float_op(float_result=False, name='float_ge')
+prepare_op_float_neg = prepare_float_op(base=False, name='float_neg')
+prepare_op_float_abs = prepare_float_op(base=False, name='float_abs')
 
 def prepare_op_math_sqrt(self, op, fcond):
 loc, box = self._ensure_value_is_boxed(op.getarg(1))
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy arm-backend-2: add some asserts

2011-10-25 Thread bivab
Author: David Schneider david.schnei...@picle.org
Branch: arm-backend-2
Changeset: r48417:8754b1a53808
Date: 2011-10-24 14:32 +0200
http://bitbucket.org/pypy/pypy/changeset/8754b1a53808/

Log:add some asserts

diff --git a/pypy/jit/backend/arm/opassembler.py 
b/pypy/jit/backend/arm/opassembler.py
--- a/pypy/jit/backend/arm/opassembler.py
+++ b/pypy/jit/backend/arm/opassembler.py
@@ -640,15 +640,16 @@
 
 def emit_op_setarrayitem_gc(self, op, arglocs, regalloc, fcond):
 value_loc, base_loc, ofs_loc, scale, ofs = arglocs
-
+assert ofs_loc.is_reg()
 if scale.value  0:
 scale_loc = r.ip
 self.mc.LSL_ri(r.ip.value, ofs_loc.value, scale.value)
 else:
 scale_loc = ofs_loc
 
+# add the base offset  
 if ofs.value  0:
-self.mc.ADD_ri(r.ip.value, scale_loc.value, ofs.value)
+self.mc.ADD_ri(r.ip.value, scale_loc.value, imm=ofs.value)
 scale_loc = r.ip
 
 if scale.value == 3:
@@ -670,11 +671,14 @@
 
 def emit_op_getarrayitem_gc(self, op, arglocs, regalloc, fcond):
 res, base_loc, ofs_loc, scale, ofs = arglocs
+assert ofs_loc.is_reg()
 if scale.value  0:
 scale_loc = r.ip
 self.mc.LSL_ri(r.ip.value, ofs_loc.value, scale.value)
 else:
 scale_loc = ofs_loc
+
+# add the base offset  
 if ofs.value  0:
 self.mc.ADD_ri(r.ip.value, scale_loc.value, imm=ofs.value)
 scale_loc = r.ip
diff --git a/pypy/jit/backend/arm/regalloc.py b/pypy/jit/backend/arm/regalloc.py
--- a/pypy/jit/backend/arm/regalloc.py
+++ b/pypy/jit/backend/arm/regalloc.py
@@ -692,7 +692,7 @@
 
 def prepare_op_setarrayitem_gc(self, op, fcond):
 a0, a1, a2 = boxes = list(op.getarglist())
-_, scale, ofs, _, ptr = self._unpack_arraydescr(op.getdescr())
+_, scale, base_ofs, _, ptr = self._unpack_arraydescr(op.getdescr())
 
 base_loc, base_box  = self._ensure_value_is_boxed(a0, boxes)
 boxes.append(base_box)
@@ -701,12 +701,13 @@
 value_loc, value_box = self._ensure_value_is_boxed(a2, boxes)
 boxes.append(value_box)
 self.possibly_free_vars(boxes)
-return [value_loc, base_loc, ofs_loc, imm(scale), imm(ofs)]
+assert _check_imm_arg(ConstInt(base_ofs))
+return [value_loc, base_loc, ofs_loc, imm(scale), imm(base_ofs)]
 prepare_op_setarrayitem_raw = prepare_op_setarrayitem_gc
 
 def prepare_op_getarrayitem_gc(self, op, fcond):
 a0, a1 = boxes = list(op.getarglist())
-_, scale, ofs, _, ptr = self._unpack_arraydescr(op.getdescr())
+_, scale, base_ofs, _, ptr = self._unpack_arraydescr(op.getdescr())
 
 base_loc, base_box  = self._ensure_value_is_boxed(a0, boxes)
 boxes.append(base_box)
@@ -715,7 +716,8 @@
 self.possibly_free_vars(boxes)
 res = self.force_allocate_reg(op.result)
 self.possibly_free_var(op.result)
-return [res, base_loc, ofs_loc, imm(scale), imm(ofs)]
+assert _check_imm_arg(ConstInt(base_ofs))
+return [res, base_loc, ofs_loc, imm(scale), imm(base_ofs)]
 
 prepare_op_getarrayitem_raw = prepare_op_getarrayitem_gc
 prepare_op_getarrayitem_gc_pure = prepare_op_getarrayitem_gc
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy arm-backend-2: merge guards with cmp ops for floats

2011-10-25 Thread bivab
Author: David Schneider david.schnei...@picle.org
Branch: arm-backend-2
Changeset: r48421:7b6405557495
Date: 2011-10-25 11:07 +0200
http://bitbucket.org/pypy/pypy/changeset/7b6405557495/

Log:merge guards with cmp ops for floats

diff --git a/pypy/jit/backend/arm/helper/assembler.py 
b/pypy/jit/backend/arm/helper/assembler.py
--- a/pypy/jit/backend/arm/helper/assembler.py
+++ b/pypy/jit/backend/arm/helper/assembler.py
@@ -100,6 +100,21 @@
 return fcond
 return f
 
+def gen_emit_float_cmp_op_guard(guard_cond):
+def f(self, op, guard, arglocs, regalloc, fcond):
+arg1 = arglocs[0]
+arg2 = arglocs[1]
+inv = c.get_opposite_of(guard_cond)
+self.mc.VCMP(arg1.value, arg2.value)
+self.mc.VMRS(cond=fcond)
+cond = guard_cond
+guard_opnum = guard.getopnum()
+if guard_opnum == rop.GUARD_FALSE:
+cond = inv
+self._emit_guard(guard, arglocs[2:], cond)
+return fcond
+return f
+
 class saved_registers(object):
 def __init__(self, assembler, regs_to_save, vfp_regs_to_save=None, 
regalloc=None):
 assert regalloc is None
diff --git a/pypy/jit/backend/arm/helper/regalloc.py 
b/pypy/jit/backend/arm/helper/regalloc.py
--- a/pypy/jit/backend/arm/helper/regalloc.py
+++ b/pypy/jit/backend/arm/helper/regalloc.py
@@ -56,21 +56,42 @@
 f.__name__ = name
 return f
 
-def prepare_float_op(name=None, base=True, float_result=True):
-def f(self, op, fcond):
-locs = []
-loc1, box1 = self._ensure_value_is_boxed(op.getarg(0))
-locs.append(loc1)
-if base:
-loc2, box2 = self._ensure_value_is_boxed(op.getarg(1))
-locs.append(loc2)
-self.possibly_free_var(box2)
-self.possibly_free_var(box1)
-res = self.force_allocate_reg(op.result)
-assert float_result == (op.result.type == FLOAT)
-self.possibly_free_var(op.result)
-locs.append(res)
-return locs
+def prepare_float_op(name=None, base=True, float_result=True, guard=False):
+if guard:
+def f(self, op, guard_op, fcond):
+locs = []
+loc1, box1 = self._ensure_value_is_boxed(op.getarg(0))
+locs.append(loc1)
+if base:
+loc2, box2 = self._ensure_value_is_boxed(op.getarg(1))
+locs.append(loc2)
+self.possibly_free_var(box2)
+self.possibly_free_var(box1)
+if guard_op is None:
+res = self.force_allocate_reg(op.result)
+assert float_result == (op.result.type == FLOAT)
+self.possibly_free_var(op.result)
+locs.append(res)
+return locs
+else:
+args = self._prepare_guard(guard_op, locs)
+self.possibly_free_vars(guard_op.getfailargs())
+return args
+else:
+def f(self, op, fcond):
+locs = []
+loc1, box1 = self._ensure_value_is_boxed(op.getarg(0))
+locs.append(loc1)
+if base:
+loc2, box2 = self._ensure_value_is_boxed(op.getarg(1))
+locs.append(loc2)
+self.possibly_free_var(box2)
+self.possibly_free_var(box1)
+res = self.force_allocate_reg(op.result)
+assert float_result == (op.result.type == FLOAT)
+self.possibly_free_var(op.result)
+locs.append(res)
+return locs
 if name:
 f.__name__ = name
 return f
diff --git a/pypy/jit/backend/arm/opassembler.py 
b/pypy/jit/backend/arm/opassembler.py
--- a/pypy/jit/backend/arm/opassembler.py
+++ b/pypy/jit/backend/arm/opassembler.py
@@ -14,6 +14,7 @@
 gen_emit_cmp_op_guard,
 gen_emit_float_op,
 gen_emit_float_cmp_op,
+
gen_emit_float_cmp_op_guard,
 gen_emit_unary_float_op, 
 saved_registers,
 count_reg_args)
@@ -1157,6 +1158,13 @@
 emit_op_float_gt = gen_emit_float_cmp_op(c.GT)
 emit_op_float_ge = gen_emit_float_cmp_op(c.GE)
 
+emit_guard_float_lt = gen_emit_float_cmp_op_guard(c.VFP_LT)
+emit_guard_float_le = gen_emit_float_cmp_op_guard(c.VFP_LE)
+emit_guard_float_eq = gen_emit_float_cmp_op_guard(c.EQ)
+emit_guard_float_ne = gen_emit_float_cmp_op_guard(c.NE)
+emit_guard_float_gt = gen_emit_float_cmp_op_guard(c.GT)
+emit_guard_float_ge = gen_emit_float_cmp_op_guard(c.GE)
+
 def emit_op_cast_float_to_int(self, op, arglocs, regalloc, fcond):
 arg, temp, res = arglocs
 self.mc.VCVT_float_to_int(temp.value, arg.value)
diff --git a/pypy/jit/backend/arm/regalloc.py 

[pypy-commit] pypy arm-backend-2: implement getinteriorfield_gc and setinteriorfield_gc

2011-10-25 Thread bivab
Author: David Schneider david.schnei...@picle.org
Branch: arm-backend-2
Changeset: r48415:6d558e62094e
Date: 2011-10-24 12:37 +0200
http://bitbucket.org/pypy/pypy/changeset/6d558e62094e/

Log:implement getinteriorfield_gc and setinteriorfield_gc

diff --git a/pypy/jit/backend/arm/opassembler.py 
b/pypy/jit/backend/arm/opassembler.py
--- a/pypy/jit/backend/arm/opassembler.py
+++ b/pypy/jit/backend/arm/opassembler.py
@@ -565,6 +565,64 @@
 emit_op_getfield_raw_pure = emit_op_getfield_gc
 emit_op_getfield_gc_pure = emit_op_getfield_gc
 
+def emit_op_getinteriorfield_gc(self, op, arglocs, regalloc, fcond):
+base_loc, index_loc, res_loc, ofs_loc, ofs, itemsize, fieldsize = 
arglocs
+self.mc.gen_load_int(r.ip.value, itemsize.value)
+self.mc.MUL(r.ip.value, index_loc.value, r.ip.value)
+if ofs.value  0:
+if ofs_loc.is_imm():
+self.mc.ADD_ri(r.ip.value, r.ip.value, ofs_loc.value)
+else:
+self.mc.ADD_rr(r.ip.value, r.ip.value, ofs_loc.value)
+
+if fieldsize.value == 8:
+# vldr only supports imm offsets
+# so if the ofset is too large we add it to the base and use an
+# offset of 0
+assert res_loc.is_vfp_reg()
+self.mc.ADD_rr(r.ip.value, base_loc.value, r.ip.value)
+self.mc.VLDR(res_loc.value, r.ip.value, 0)
+elif fieldsize.value == 4:
+self.mc.LDR_rr(res_loc.value, base_loc.value, r.ip.value)
+elif fieldsize.value == 2:
+self.mc.LDRH_rr(res_loc.value, base_loc.value, r.ip.value)
+elif fieldsize.value == 1:
+self.mc.LDRB_rr(res_loc.value, base_loc.value, r.ip.value)
+else:
+assert 0
+
+#XXX Hack, Hack, Hack
+if not we_are_translated():
+signed = op.getdescr().fielddescr.is_field_signed()
+self._ensure_result_bit_extension(res_loc, fieldsize.value, signed)
+return fcond
+
+def emit_op_setinteriorfield_gc(self, op, arglocs, regalloc, fcond):
+base_loc, index_loc, value_loc, ofs_loc, ofs, itemsize, fieldsize = 
arglocs
+self.mc.gen_load_int(r.ip.value, itemsize.value)
+self.mc.MUL(r.ip.value, index_loc.value, r.ip.value)
+if ofs.value  0:
+if ofs_loc.is_imm():
+self.mc.ADD_ri(r.ip.value, r.ip.value, ofs_loc.value)
+else:
+self.mc.ADD_rr(r.ip.value, r.ip.value, ofs_loc.value)
+if fieldsize.value == 8:
+# vstr only supports imm offsets
+# so if the ofset is too large we add it to the base and use an
+# offset of 0
+assert value_loc.is_vfp_reg()
+self.mc.ADD_rr(r.ip.value, base_loc.value, r.ip.value)
+self.mc.VSTR(value_loc.value, r.ip.value, 0)
+elif fieldsize.value == 4:
+self.mc.STR_rr(value_loc.value, base_loc.value, r.ip.value)
+elif fieldsize.value == 2:
+self.mc.STRH_rr(value_loc.value, base_loc.value, r.ip.value)
+elif fieldsize.value == 1:
+self.mc.STRB_rr(value_loc.value, base_loc.value, r.ip.value)
+else:
+assert 0
+return fcond
+
 
 
 
diff --git a/pypy/jit/backend/arm/regalloc.py b/pypy/jit/backend/arm/regalloc.py
--- a/pypy/jit/backend/arm/regalloc.py
+++ b/pypy/jit/backend/arm/regalloc.py
@@ -17,7 +17,8 @@
 INT, REF, FLOAT, LoopToken)
 from pypy.jit.metainterp.resoperation import rop
 from pypy.jit.backend.llsupport.descr import BaseFieldDescr, BaseArrayDescr, \
- BaseCallDescr, BaseSizeDescr
+ BaseCallDescr, BaseSizeDescr, \
+ InteriorFieldDescr
 from pypy.jit.backend.llsupport import symbolic
 from pypy.rpython.lltypesystem import lltype, rffi, rstr, llmemory
 from pypy.jit.codewriter import heaptracker
@@ -637,6 +638,46 @@
 prepare_op_getfield_raw_pure = prepare_op_getfield_gc
 prepare_op_getfield_gc_pure = prepare_op_getfield_gc
 
+def prepare_op_getinteriorfield_gc(self, op, fcond):
+t = self._unpack_interiorfielddescr(op.getdescr())
+ofs, itemsize, fieldsize, sign = t
+args = op.getarglist()
+base_loc, base_box = self._ensure_value_is_boxed(op.getarg(0), args)
+index_loc, index_box = self._ensure_value_is_boxed(op.getarg(1), args)
+c_ofs = ConstInt(ofs)
+if _check_imm_arg(c_ofs):
+ofs_loc = imm(ofs)
+else:
+ofs_loc, ofs_box = self._ensure_value_is_boxed(c_ofs, [base_box, 
index_box])
+self.possibly_free_var(ofs_box)
+self.possibly_free_vars(args)
+self.possibly_free_var(base_box)
+self.possibly_free_var(index_box)
+result_loc = self.force_allocate_reg(op.result)
+return [base_loc, index_loc, result_loc, ofs_loc, imm(ofs), 

[pypy-commit] pypy arm-backend-2: add cast_ptr_to_int and cast_int_to_ptr

2011-10-25 Thread bivab
Author: David Schneider david.schnei...@picle.org
Branch: arm-backend-2
Changeset: r48416:3bae2cc9ba15
Date: 2011-10-24 12:38 +0200
http://bitbucket.org/pypy/pypy/changeset/3bae2cc9ba15/

Log:add cast_ptr_to_int and cast_int_to_ptr

diff --git a/pypy/jit/backend/arm/opassembler.py 
b/pypy/jit/backend/arm/opassembler.py
--- a/pypy/jit/backend/arm/opassembler.py
+++ b/pypy/jit/backend/arm/opassembler.py
@@ -408,6 +408,9 @@
 self.mov_loc_loc(argloc, resloc)
 return fcond
 
+emit_op_cast_ptr_to_int = emit_op_same_as
+emit_op_cast_int_to_ptr = emit_op_same_as
+
 def emit_op_guard_no_exception(self, op, arglocs, regalloc, fcond):
 loc = arglocs[0]
 failargs = arglocs[1:]
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy arm-backend-2: forgot to add these methods

2011-10-25 Thread bivab
Author: David Schneider david.schnei...@picle.org
Branch: arm-backend-2
Changeset: r48419:0868f9fb2793
Date: 2011-10-24 15:58 +0200
http://bitbucket.org/pypy/pypy/changeset/0868f9fb2793/

Log:forgot to add these methods

diff --git a/pypy/jit/backend/arm/regalloc.py b/pypy/jit/backend/arm/regalloc.py
--- a/pypy/jit/backend/arm/regalloc.py
+++ b/pypy/jit/backend/arm/regalloc.py
@@ -850,6 +850,8 @@
 resloc = self.force_allocate_reg(op.result)
 self.possibly_free_var(op.result)
 return [argloc, resloc]
+prepare_op_cast_ptr_to_int = prepare_op_same_as
+prepare_op_cast_int_to_ptr = prepare_op_same_as
 
 def prepare_op_new(self, op, fcond):
 gc_ll_descr = self.assembler.cpu.gc_ll_descr
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy arm-backend-2: implement merging of comparison operations with following guards

2011-10-25 Thread bivab
Author: David Schneider david.schnei...@picle.org
Branch: arm-backend-2
Changeset: r48420:f29ee3944161
Date: 2011-10-24 17:14 +0200
http://bitbucket.org/pypy/pypy/changeset/f29ee3944161/

Log:implement merging of comparison operations with following guards

diff --git a/pypy/jit/backend/arm/assembler.py 
b/pypy/jit/backend/arm/assembler.py
--- a/pypy/jit/backend/arm/assembler.py
+++ b/pypy/jit/backend/arm/assembler.py
@@ -8,7 +8,10 @@
 from pypy.jit.backend.arm.arch import WORD, FUNC_ALIGN, PC_OFFSET, 
N_REGISTERS_SAVED_BY_MALLOC
 from pypy.jit.backend.arm.codebuilder import ARMv7Builder, OverwritingBuilder
 from pypy.jit.backend.arm.regalloc import (Regalloc, ARMFrameManager, 
ARMv7RegisterMananger,
-_check_imm_arg, TempInt, 
TempPtr)
+_check_imm_arg, TempInt,
+TempPtr,
+operations as regalloc_operations,
+operations_with_guard as 
regalloc_operations_with_guard)
 from pypy.jit.backend.arm.jump import remap_frame_layout
 from pypy.jit.backend.llsupport.regalloc import compute_vars_longevity, TempBox
 from pypy.jit.backend.llsupport.asmmemmgr import MachineDataBlockWrapper
@@ -791,34 +794,45 @@
 regalloc.possibly_free_vars_for_op(op)
 elif self.can_merge_with_next_guard(op, i, operations):
 regalloc.next_instruction()
-arglocs = regalloc.operations_with_guard[opnum](regalloc, op,
+arglocs = regalloc_operations_with_guard[opnum](regalloc, op,
 operations[i+1], fcond)
-fcond = self.operations_with_guard[opnum](self, op,
+fcond = asm_operations_with_guard[opnum](self, op,
 operations[i+1], arglocs, regalloc, 
fcond)
 elif not we_are_translated() and op.getopnum() == -124:
 regalloc.prepare_force_spill(op, fcond)
 else:
-arglocs = regalloc.operations[opnum](regalloc, op, fcond)
+arglocs = regalloc_operations[opnum](regalloc, op, fcond)
 if arglocs is not None:
-fcond = self.operations[opnum](self, op, arglocs, 
regalloc, fcond)
+fcond = asm_operations[opnum](self, op, arglocs, regalloc, 
fcond)
 if op.result:
 regalloc.possibly_free_var(op.result)
 regalloc.possibly_free_vars_for_op(op)
 regalloc._check_invariants()
 
+# from ../x86/regalloc.py
 def can_merge_with_next_guard(self, op, i, operations):
-num = op.getopnum()
-if num == rop.CALL_MAY_FORCE or num == rop.CALL_ASSEMBLER:
+if (op.getopnum() == rop.CALL_MAY_FORCE or
+op.getopnum() == rop.CALL_ASSEMBLER or
+op.getopnum() == rop.CALL_RELEASE_GIL):
 assert operations[i + 1].getopnum() == rop.GUARD_NOT_FORCED
 return True
-if num == rop.INT_MUL_OVF or num == rop.INT_ADD_OVF or num == 
rop.INT_SUB_OVF:
-opnum = operations[i + 1].getopnum()
-assert opnum  == rop.GUARD_OVERFLOW or opnum == 
rop.GUARD_NO_OVERFLOW
-return True
-if num == rop.CALL_RELEASE_GIL:
-return True
-return False
-
+if not op.is_comparison():
+if op.is_ovf():
+if (operations[i + 1].getopnum() != rop.GUARD_NO_OVERFLOW and
+operations[i + 1].getopnum() != rop.GUARD_OVERFLOW):
+not_implemented(int_xxx_ovf not followed by 
+guard_(no)_overflow)
+return True
+return False
+if (operations[i + 1].getopnum() != rop.GUARD_TRUE and
+operations[i + 1].getopnum() != rop.GUARD_FALSE):
+return False
+if operations[i + 1].getarg(0) is not op.result:
+return False
+if (self._regalloc.longevity[op.result][1]  i + 1 or
+op.result in operations[i + 1].getfailargs()):
+return False
+return True
 
 def _insert_checks(self, mc=None):
 if not we_are_translated():
@@ -1148,36 +1162,29 @@
 else:
 return 0
 
-def make_operation_list():
-def notimplemented(self, op, arglocs, regalloc, fcond):
-raise NotImplementedError, op
+def notimplemented(self, op, arglocs, regalloc, fcond):
+raise NotImplementedError, op
+def notimplemented_with_guard(self, op, guard_op, arglocs, regalloc, fcond):
+raise NotImplementedError, op
 
-operations = [None] * (rop._LAST+1)
-for key, value in rop.__dict__.items():
-key = key.lower()
-if key.startswith('_'):
-continue
-methname = 'emit_op_%s' % key
-if hasattr(AssemblerARM, methname):
-func = getattr(AssemblerARM, 

[pypy-commit] pypy ppc-jit-backend: Removed unnecessary operations in emit_unicodegetitem and emit_unicodesetitem.

2011-10-25 Thread hager
Author: hager sven.ha...@uni-duesseldorf.de
Branch: ppc-jit-backend
Changeset: r48423:2aa87669180f
Date: 2011-10-25 11:46 +0200
http://bitbucket.org/pypy/pypy/changeset/2aa87669180f/

Log:Removed unnecessary operations in emit_unicodegetitem and
emit_unicodesetitem.

diff --git a/pypy/jit/backend/ppc/ppcgen/opassembler.py 
b/pypy/jit/backend/ppc/ppcgen/opassembler.py
--- a/pypy/jit/backend/ppc/ppcgen/opassembler.py
+++ b/pypy/jit/backend/ppc/ppcgen/opassembler.py
@@ -408,12 +408,11 @@
 self.mc.li(r.r0.value, scale.value)
 self.mc.slw(ofs_loc.value, ofs_loc.value, r.r0.value)
 self.mc.add(res.value, base_loc.value, ofs_loc.value)
-self.mc.li(r.r0.value, basesize.value)
 
 if scale.value == 2:
-self.mc.lwzx(res.value, res.value, r.r0.value)
+self.mc.lwz(res.value, res.value, basesize.value)
 elif scale.value == 1:
-self.mc.lhzx(res.value, res.value, r.r0.value)
+self.mc.lhz(res.value, res.value, basesize.value)
 else:
 assert 0, itemsize.value
 
@@ -424,12 +423,11 @@
 self.mc.li(r.r0.value, scale.value)
 self.mc.slw(ofs_loc.value, ofs_loc.value, r.r0.value)
 self.mc.add(base_loc.value, base_loc.value, ofs_loc.value)
-self.mc.li(r.r0.value, basesize.value)
 
 if scale.value == 2:
-self.mc.stwx(value_loc.value, base_loc.value, r.r0.value)
+self.mc.stw(value_loc.value, base_loc.value, basesize.value)
 elif scale.value == 1:
-self.mc.sthx(value_loc.value, base_loc.value, r.r0.value)
+self.mc.sth(value_loc.value, base_loc.value, basesize.value)
 else:
 assert 0, itemsize.value
 
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy arm-backend-2: fix test

2011-10-25 Thread bivab
Author: David Schneider david.schnei...@picle.org
Branch: arm-backend-2
Changeset: r48427:2df0dec0a518
Date: 2011-10-25 12:11 +0200
http://bitbucket.org/pypy/pypy/changeset/2df0dec0a518/

Log:fix test

diff --git a/pypy/jit/backend/arm/test/test_runner.py 
b/pypy/jit/backend/arm/test/test_runner.py
--- a/pypy/jit/backend/arm/test/test_runner.py
+++ b/pypy/jit/backend/arm/test/test_runner.py
@@ -167,13 +167,13 @@
   ('y19', lltype.Signed), ('y20', lltype.Signed),
   ('float', lltype.Float)))
 
-T = lltype.GcStruct('T', ('parent', SFloat),
+TFloat = lltype.GcStruct('TFloat', ('parent', SFloat),
  ('next', lltype.Ptr(SFloat)))
 def test_float_field(self):
 if not self.cpu.supports_floats:
 py.test.skip('requires floats')
 floatdescr = self.cpu.fielddescrof(self.SFloat, 'float')
-t_box, T_box = self.alloc_instance(self.T)
+t_box, T_box = self.alloc_instance(self.TFloat)
 self.execute_operation(rop.SETFIELD_GC, [t_box, boxfloat(3.4)],
'void', descr=floatdescr)
 res = self.execute_operation(rop.GETFIELD_GC, [t_box],
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy arm-backend-2: add missing not_implemented implementation

2011-10-25 Thread bivab
Author: David Schneider david.schnei...@picle.org
Branch: arm-backend-2
Changeset: r48426:fccb38718397
Date: 2011-10-25 12:03 +0200
http://bitbucket.org/pypy/pypy/changeset/fccb38718397/

Log:add missing not_implemented implementation

diff --git a/pypy/jit/backend/arm/assembler.py 
b/pypy/jit/backend/arm/assembler.py
--- a/pypy/jit/backend/arm/assembler.py
+++ b/pypy/jit/backend/arm/assembler.py
@@ -1,4 +1,5 @@
 from __future__ import with_statement
+import os
 from pypy.jit.backend.arm.helper.assembler import saved_registers, 
count_reg_args, \
 decode32, encode32, \
 decode64, encode64
@@ -1162,13 +1163,17 @@
 else:
 return 0
 
-def notimplemented(self, op, arglocs, regalloc, fcond):
+def not_implemented(msg):
+os.write(2, '[ARM/asm] %s\n' % msg)
+raise NotImplementedError(msg)
+
+def notimplemented_op(self, op, arglocs, regalloc, fcond):
 raise NotImplementedError, op
-def notimplemented_with_guard(self, op, guard_op, arglocs, regalloc, fcond):
+def notimplemented_op_with_guard(self, op, guard_op, arglocs, regalloc, fcond):
 raise NotImplementedError, op
 
-asm_operations = [notimplemented] * (rop._LAST + 1)
-asm_operations_with_guard = [notimplemented_with_guard] * (rop._LAST + 1)
+asm_operations = [notimplemented_op] * (rop._LAST + 1)
+asm_operations_with_guard = [notimplemented_op_with_guard] * (rop._LAST + 1)
 
 for key, value in rop.__dict__.items():
 key = key.lower()
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: (fijal, arigo) Remove call to clear_all_weakrefs with an explanation. A test

2011-10-25 Thread fijal
Author: Maciej Fijalkowski fij...@gmail.com
Branch: 
Changeset: r48431:9079d6cb7394
Date: 2011-10-25 15:38 +0200
http://bitbucket.org/pypy/pypy/changeset/9079d6cb7394/

Log:(fijal, arigo) Remove call to clear_all_weakrefs with an
explanation. A test that might potentially fail with -A if things go
wrong.

diff --git a/pypy/module/array/interp_array.py 
b/pypy/module/array/interp_array.py
--- a/pypy/module/array/interp_array.py
+++ b/pypy/module/array/interp_array.py
@@ -211,7 +211,9 @@
 return result
 
 def __del__(self):
-self.clear_all_weakrefs()
+# note that we don't call clear_all_weakrefs here because
+# an array with freed buffer is ok to see - it's just empty with 0
+# length
 self.setlen(0)
 
 def setlen(self, size):
diff --git a/pypy/module/array/test/test_array.py 
b/pypy/module/array/test/test_array.py
--- a/pypy/module/array/test/test_array.py
+++ b/pypy/module/array/test/test_array.py
@@ -824,6 +824,22 @@
 r = weakref.ref(a)
 assert r() is a
 
+def test_subclass_del(self):
+import array, gc, weakref
+l = []
+
+class A(array.array):
+pass
+
+a = A('d')
+a.append(3.0)
+r = weakref.ref(a, lambda a: l.append(a()))
+del a
+gc.collect()
+assert l
+assert l[0] is None or len(l[0]) == 0
+
+
 class TestCPythonsOwnArray(BaseArrayTests):
 
 def setup_class(cls):
@@ -844,11 +860,7 @@
 cls.w_tempfile = cls.space.wrap(
 str(py.test.ensuretemp('array').join('tmpfile')))
 cls.w_maxint = cls.space.wrap(sys.maxint)
-
-
-
-
-
+
 def test_buffer_info(self):
 a = self.array('c', 'Hi!')
 bi = a.buffer_info()
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: merge default

2011-10-25 Thread fijal
Author: Maciej Fijalkowski fij...@gmail.com
Branch: 
Changeset: r48432:f5825eff38c3
Date: 2011-10-25 15:41 +0200
http://bitbucket.org/pypy/pypy/changeset/f5825eff38c3/

Log:merge default

diff --git a/pypy/jit/backend/x86/assembler.py 
b/pypy/jit/backend/x86/assembler.py
--- a/pypy/jit/backend/x86/assembler.py
+++ b/pypy/jit/backend/x86/assembler.py
@@ -1276,8 +1276,8 @@
 genop_int_ne = _cmpop(NE, NE)
 genop_int_gt = _cmpop(G, L)
 genop_int_ge = _cmpop(GE, LE)
-genop_ptr_eq = genop_int_eq
-genop_ptr_ne = genop_int_ne
+genop_ptr_eq = genop_instance_ptr_eq = genop_int_eq
+genop_ptr_ne = genop_instance_ptr_ne = genop_int_ne
 
 genop_float_lt = _cmpop_float('B', 'A')
 genop_float_le = _cmpop_float('BE', 'AE')
@@ -1297,8 +1297,8 @@
 genop_guard_int_ne = _cmpop_guard(NE, NE, E, E)
 genop_guard_int_gt = _cmpop_guard(G, L, LE, GE)
 genop_guard_int_ge = _cmpop_guard(GE, LE, L, G)
-genop_guard_ptr_eq = genop_guard_int_eq
-genop_guard_ptr_ne = genop_guard_int_ne
+genop_guard_ptr_eq = genop_guard_instance_ptr_eq = genop_guard_int_eq
+genop_guard_ptr_ne = genop_guard_instance_ptr_ne = genop_guard_int_ne
 
 genop_guard_uint_gt = _cmpop_guard(A, B, BE, AE)
 genop_guard_uint_lt = _cmpop_guard(B, A, AE, BE)
diff --git a/pypy/jit/backend/x86/regalloc.py b/pypy/jit/backend/x86/regalloc.py
--- a/pypy/jit/backend/x86/regalloc.py
+++ b/pypy/jit/backend/x86/regalloc.py
@@ -651,8 +651,8 @@
 consider_uint_lt = _consider_compop
 consider_uint_le = _consider_compop
 consider_uint_ge = _consider_compop
-consider_ptr_eq = _consider_compop
-consider_ptr_ne = _consider_compop
+consider_ptr_eq = consider_instance_ptr_eq = _consider_compop
+consider_ptr_ne = consider_instance_ptr_ne = _consider_compop
 
 def _consider_float_op(self, op):
 loc1 = self.xrm.loc(op.getarg(1))
diff --git a/pypy/jit/codewriter/jtransform.py 
b/pypy/jit/codewriter/jtransform.py
--- a/pypy/jit/codewriter/jtransform.py
+++ b/pypy/jit/codewriter/jtransform.py
@@ -800,6 +800,9 @@
 def _is_gc(self, v):
 return getattr(getattr(v.concretetype, TO, None), _gckind, ?) == 
'gc'
 
+def _is_rclass_instance(self, v):
+return lltype._castdepth(v.concretetype.TO, rclass.OBJECT) = 0
+
 def _rewrite_cmp_ptrs(self, op):
 if self._is_gc(op.args[0]):
 return op
@@ -817,11 +820,21 @@
 return self._rewrite_equality(op, 'int_is_true')
 
 def rewrite_op_ptr_eq(self, op):
-op1 = self._rewrite_equality(op, 'ptr_iszero')
+prefix = ''
+if self._is_rclass_instance(op.args[0]):
+assert self._is_rclass_instance(op.args[1])
+op = SpaceOperation('instance_ptr_eq', op.args, op.result)
+prefix = 'instance_'
+op1 = self._rewrite_equality(op, prefix + 'ptr_iszero')
 return self._rewrite_cmp_ptrs(op1)
 
 def rewrite_op_ptr_ne(self, op):
-op1 = self._rewrite_equality(op, 'ptr_nonzero')
+prefix = ''
+if self._is_rclass_instance(op.args[0]):
+assert self._is_rclass_instance(op.args[1])
+op = SpaceOperation('instance_ptr_ne', op.args, op.result)
+prefix = 'instance_'
+op1 = self._rewrite_equality(op, prefix + 'ptr_nonzero')
 return self._rewrite_cmp_ptrs(op1)
 
 rewrite_op_ptr_iszero = _rewrite_cmp_ptrs
diff --git a/pypy/jit/codewriter/test/test_jtransform.py 
b/pypy/jit/codewriter/test/test_jtransform.py
--- a/pypy/jit/codewriter/test/test_jtransform.py
+++ b/pypy/jit/codewriter/test/test_jtransform.py
@@ -576,10 +576,10 @@
 assert op1.args == [v2]
 
 def test_ptr_eq():
-v1 = varoftype(rclass.OBJECTPTR)
-v2 = varoftype(rclass.OBJECTPTR)
+v1 = varoftype(lltype.Ptr(rstr.STR))
+v2 = varoftype(lltype.Ptr(rstr.STR))
 v3 = varoftype(lltype.Bool)
-c0 = const(lltype.nullptr(rclass.OBJECT))
+c0 = const(lltype.nullptr(rstr.STR))
 #
 for opname, reducedname in [('ptr_eq', 'ptr_iszero'),
 ('ptr_ne', 'ptr_nonzero')]:
@@ -598,6 +598,31 @@
 assert op1.opname == reducedname
 assert op1.args == [v2]
 
+def test_instance_ptr_eq():
+v1 = varoftype(rclass.OBJECTPTR)
+v2 = varoftype(rclass.OBJECTPTR)
+v3 = varoftype(lltype.Bool)
+c0 = const(lltype.nullptr(rclass.OBJECT))
+
+for opname, newopname, reducedname in [
+('ptr_eq', 'instance_ptr_eq', 'instance_ptr_iszero'),
+('ptr_ne', 'instance_ptr_ne', 'instance_ptr_nonzero')
+]:
+op = SpaceOperation(opname, [v1, v2], v3)
+op1 = Transformer().rewrite_operation(op)
+assert op1.opname == newopname
+assert op1.args == [v1, v2]
+
+op = SpaceOperation(opname, [v1, c0], v3)
+op1 = Transformer().rewrite_operation(op)
+assert op1.opname == reducedname
+assert op1.args == [v1]
+
+op = SpaceOperation(opname, [c0, v1], v3)
+op1 = 

[pypy-commit] pypy lightweight-finalizers: remove traces of previous approach

2011-10-25 Thread fijal
Author: Maciej Fijalkowski fij...@gmail.com
Branch: lightweight-finalizers
Changeset: r48433:0554cbf80d3c
Date: 2011-10-25 16:05 +0200
http://bitbucket.org/pypy/pypy/changeset/0554cbf80d3c/

Log:remove traces of previous approach

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
@@ -363,7 +363,7 @@
 Struct._install_extras(self, **kwds)
 
 def _attach_runtime_type_info_funcptr(self, funcptr, destrptr,
-  customtraceptr, raw_mem_attr_name):
+  customtraceptr):
 if self._runtime_type_info is None:
 raise TypeError(attachRuntimeTypeInfo: %r must have been built 
 with the rtti=True argument % (self,))
@@ -399,8 +399,6 @@
 raise TypeError(expected a custom trace function 
 implementation, got: %s % customtraceptr)
 self._runtime_type_info.custom_trace_funcptr = customtraceptr
-if raw_mem_attr_name is not None:
-self._runtime_type_info.raw_mem_attr_name = raw_mem_attr_name
 
 class GcStruct(RttiStruct):
 _gckind = 'gc'
@@ -2060,12 +2058,11 @@
 return _ptr(PTRTYPE, oddint, solid=True)
 
 def attachRuntimeTypeInfo(GCSTRUCT, funcptr=None, destrptr=None,
-  customtraceptr=None, raw_mem_attr_name=None):
+  customtraceptr=None):
 if not isinstance(GCSTRUCT, RttiStruct):
 raise TypeError, expected a RttiStruct: %s % GCSTRUCT
 GCSTRUCT._attach_runtime_type_info_funcptr(funcptr, destrptr,
-   customtraceptr,
-   raw_mem_attr_name)
+   customtraceptr)
 return _ptr(Ptr(RuntimeTypeInfo), GCSTRUCT._runtime_type_info)
 
 def getRuntimeTypeInfo(GCSTRUCT):
diff --git a/pypy/rpython/rtyper.py b/pypy/rpython/rtyper.py
--- a/pypy/rpython/rtyper.py
+++ b/pypy/rpython/rtyper.py
@@ -705,7 +705,7 @@
 return self.getcallable(graph)
 
 def attachRuntimeTypeInfoFunc(self, GCSTRUCT, func, ARG_GCSTRUCT=None,
-  destrptr=None, raw_mem_attr_name=None):
+  destrptr=None):
 self.call_all_setups()  # compute ForwardReferences now
 if ARG_GCSTRUCT is None:
 ARG_GCSTRUCT = GCSTRUCT
@@ -717,8 +717,7 @@
 raise TyperError(runtime type info function %r returns %r, 
  excepted Ptr(RuntimeTypeInfo) % (func, s))
 funcptr = self.getcallable(graph)
-attachRuntimeTypeInfo(GCSTRUCT, funcptr, destrptr, None,
-  raw_mem_attr_name)
+attachRuntimeTypeInfo(GCSTRUCT, funcptr, destrptr, None)
 
 # register operations from annotation model
 RPythonTyper._registeroperations(annmodel)
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy lightweight-finalizers: rename argument to malloc_fixedsize_clear to reflect what it really means

2011-10-25 Thread fijal
Author: Maciej Fijalkowski fij...@gmail.com
Branch: lightweight-finalizers
Changeset: r48434:cde38a4297fc
Date: 2011-10-25 16:11 +0200
http://bitbucket.org/pypy/pypy/changeset/cde38a4297fc/

Log:rename argument to malloc_fixedsize_clear to reflect what it really
means (it implies has_finalizer)

diff --git a/pypy/rpython/memory/gc/generation.py 
b/pypy/rpython/memory/gc/generation.py
--- a/pypy/rpython/memory/gc/generation.py
+++ b/pypy/rpython/memory/gc/generation.py
@@ -168,7 +168,7 @@
 
 def malloc_fixedsize_clear(self, typeid, size,
has_finalizer=False,
-   has_light_finalizer=False,
+   is_finalizer_light=False,
contains_weakptr=False):
 if (has_finalizer or
 (raw_malloc_usage(size)  self.lb_young_fixedsize and
diff --git a/pypy/rpython/memory/gc/marksweep.py 
b/pypy/rpython/memory/gc/marksweep.py
--- a/pypy/rpython/memory/gc/marksweep.py
+++ b/pypy/rpython/memory/gc/marksweep.py
@@ -93,7 +93,7 @@
 pass
 
 def malloc_fixedsize(self, typeid16, size,
- has_finalizer=False, has_light_finalizer=False,
+ has_finalizer=False, is_finalizer_light=False,
  contains_weakptr=False):
 self.maybe_collect()
 size_gc_header = self.gcheaderbuilder.size_gc_header
@@ -130,7 +130,7 @@
 
 def malloc_fixedsize_clear(self, typeid16, size,
has_finalizer=False,
-   has_light_finalizer=False,
+   is_finalizer_light=False,
contains_weakptr=False):
 self.maybe_collect()
 size_gc_header = self.gcheaderbuilder.size_gc_header
diff --git a/pypy/rpython/memory/gc/minimark.py 
b/pypy/rpython/memory/gc/minimark.py
--- a/pypy/rpython/memory/gc/minimark.py
+++ b/pypy/rpython/memory/gc/minimark.py
@@ -459,7 +459,7 @@
 
 def malloc_fixedsize_clear(self, typeid, size,
needs_finalizer=False,
-   has_light_finalizer=False,
+   is_finalizer_light=False,
contains_weakptr=False):
 size_gc_header = self.gcheaderbuilder.size_gc_header
 totalsize = size_gc_header + size
@@ -467,7 +467,7 @@
 #
 # If the object needs a finalizer, ask for a rawmalloc.
 # The following check should be constant-folded.
-if needs_finalizer and not has_light_finalizer:
+if needs_finalizer and not is_finalizer_light:
 ll_assert(not contains_weakptr,
  'needs_finalizer' and 'contains_weakptr' both specified)
 obj = self.external_malloc(typeid, 0, can_make_young=False)
@@ -498,7 +498,7 @@
 # Build the object.
 llarena.arena_reserve(result, totalsize)
 obj = result + size_gc_header
-if has_light_finalizer:
+if is_finalizer_light:
 self.young_objects_with_light_finalizers.append(obj)
 self.init_gc_object(result, typeid, flags=0)
 #
diff --git a/pypy/rpython/memory/gc/semispace.py 
b/pypy/rpython/memory/gc/semispace.py
--- a/pypy/rpython/memory/gc/semispace.py
+++ b/pypy/rpython/memory/gc/semispace.py
@@ -95,7 +95,7 @@
 
 def malloc_fixedsize_clear(self, typeid16, size,
has_finalizer=False,
-   has_light_finalizer=False,
+   is_finalizer_light=False,
contains_weakptr=False):
 size_gc_header = self.gcheaderbuilder.size_gc_header
 totalsize = size_gc_header + size
@@ -105,7 +105,7 @@
 llarena.arena_reserve(result, totalsize)
 self.init_gc_object(result, typeid16)
 self.free = result + totalsize
-if has_light_finalizer:
+if is_finalizer_light:
 self.objects_with_light_finalizers.append(result + size_gc_header)
 elif has_finalizer:
 self.objects_with_finalizers.append(result + size_gc_header)
diff --git a/pypy/rpython/memory/test/test_transformed_gc.py 
b/pypy/rpython/memory/test/test_transformed_gc.py
--- a/pypy/rpython/memory/test/test_transformed_gc.py
+++ b/pypy/rpython/memory/test/test_transformed_gc.py
@@ -807,7 +807,7 @@
 op.args = [Constant(type_id, llgroup.HALFWORD),
Constant(llmemory.sizeof(P), lltype.Signed),
Constant(False, lltype.Bool), # has_finalizer
-   Constant(False, lltype.Bool), # 
has_light_finalizer
+   Constant(False, lltype.Bool), # 
is_finalizer_light
Constant(False, lltype.Bool)] # contains_weakptr
 break
 else:
@@ -844,7 +844,7 @@
 

[pypy-commit] pypy lightweight-finalizers: a missed call

2011-10-25 Thread fijal
Author: Maciej Fijalkowski fij...@gmail.com
Branch: lightweight-finalizers
Changeset: r48436:fadf05e6c02a
Date: 2011-10-25 16:25 +0200
http://bitbucket.org/pypy/pypy/changeset/fadf05e6c02a/

Log:a missed call

diff --git a/pypy/rpython/memory/gc/generation.py 
b/pypy/rpython/memory/gc/generation.py
--- a/pypy/rpython/memory/gc/generation.py
+++ b/pypy/rpython/memory/gc/generation.py
@@ -181,6 +181,7 @@
 # non-simple case or object too big: don't use the nursery
 return SemiSpaceGC.malloc_fixedsize_clear(self, typeid, size,
   has_finalizer,
+  is_finalizer_light,
   contains_weakptr)
 size_gc_header = self.gcheaderbuilder.size_gc_header
 totalsize = size_gc_header + size
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy lightweight-finalizers: add a delete here

2011-10-25 Thread fijal
Author: Maciej Fijalkowski fij...@gmail.com
Branch: lightweight-finalizers
Changeset: r48437:98da45c0aeb5
Date: 2011-10-25 16:28 +0200
http://bitbucket.org/pypy/pypy/changeset/98da45c0aeb5/

Log:add a delete here

diff --git a/pypy/rpython/memory/gc/semispace.py 
b/pypy/rpython/memory/gc/semispace.py
--- a/pypy/rpython/memory/gc/semispace.py
+++ b/pypy/rpython/memory/gc/semispace.py
@@ -492,6 +492,7 @@
 else:
 finalizer = self.getfinalizer(self.get_type_id(obj))
 finalizer(obj, llmemory.NULL)
+self.objects_with_light_finalizers.delete()
 self.objects_with_light_finalizers = new_objects
 
 def deal_with_objects_with_finalizers(self, scan):
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy arm-backend-2: add names to the functions generated to emit code in the assembler

2011-10-25 Thread bivab
Author: David Schneider david.schnei...@picle.org
Branch: arm-backend-2
Changeset: r48438:e9b9f641f506
Date: 2011-10-25 16:30 +0200
http://bitbucket.org/pypy/pypy/changeset/e9b9f641f506/

Log:add names to the functions generated to emit code in the assembler

diff --git a/pypy/jit/backend/arm/helper/assembler.py 
b/pypy/jit/backend/arm/helper/assembler.py
--- a/pypy/jit/backend/arm/helper/assembler.py
+++ b/pypy/jit/backend/arm/helper/assembler.py
@@ -6,7 +6,7 @@
 from pypy.rlib.rarithmetic import r_uint, r_longlong, intmask
 from pypy.jit.metainterp.resoperation import rop
 
-def gen_emit_op_unary_cmp(true_cond, false_cond):
+def gen_emit_op_unary_cmp(name, true_cond, false_cond):
 def f(self, op, arglocs, regalloc, fcond):
 assert fcond is not None
 reg, res = arglocs
@@ -14,9 +14,10 @@
 self.mc.MOV_ri(res.value, 1, true_cond)
 self.mc.MOV_ri(res.value, 0, false_cond)
 return fcond
+f.__name__ = 'emit_op_%s' % name
 return f
 
-def gen_emit_op_ri(opname):
+def gen_emit_op_ri(name, opname):
 ri_op = getattr(AbstractARMv7Builder, '%s_ri' % opname)
 rr_op = getattr(AbstractARMv7Builder, '%s_rr' % opname)
 def f(self, op, arglocs, regalloc, fcond):
@@ -27,9 +28,10 @@
 else:
 rr_op(self.mc, res.value, l0.value, l1.value)
 return fcond
+f.__name__ = 'emit_op_%s' % name
 return f
 
-def gen_emit_op_by_helper_call(opname):
+def gen_emit_op_by_helper_call(name, opname):
 helper = getattr(AbstractARMv7Builder, opname)
 def f(self, op, arglocs, regalloc, fcond):
 assert fcond is not None
@@ -40,9 +42,10 @@
 with saved_registers(self.mc, regs, r.caller_vfp_resp):
 helper(self.mc, fcond)
 return fcond
+f.__name__ = 'emit_op_%s' % name
 return f
 
-def gen_emit_cmp_op(condition):
+def gen_emit_cmp_op(name, condition):
 def f(self, op, arglocs, regalloc, fcond):
 l0, l1, res = arglocs
 
@@ -54,9 +57,10 @@
 self.mc.MOV_ri(res.value, 1, cond=condition)
 self.mc.MOV_ri(res.value, 0, cond=inv)
 return fcond
+f.__name__ = 'emit_op_%s' % name
 return f
 
-def gen_emit_cmp_op_guard(condition):
+def gen_emit_cmp_op_guard(name, condition):
 def f(self, op, guard, arglocs, regalloc, fcond):
 l0 = arglocs[0]
 l1 = arglocs[1]
@@ -72,24 +76,27 @@
 cond = inv
 self._emit_guard(guard, arglocs[2:], cond)
 return fcond
+f.__name__ = 'emit_guard_%s' % name
+f.__name__ = 'emit_op_%s' % name
 return f
 
-def gen_emit_float_op(opname):
+def gen_emit_float_op(name, opname):
 op_rr = getattr(AbstractARMv7Builder, opname)
 def f(self, op, arglocs, regalloc, fcond):
 arg1, arg2, result = arglocs
 op_rr(self.mc, result.value, arg1.value, arg2.value)
 return fcond
 return f
-def gen_emit_unary_float_op(opname):
+def gen_emit_unary_float_op(name, opname):
 op_rr = getattr(AbstractARMv7Builder, opname)
 def f(self, op, arglocs, regalloc, fcond):
 arg1, result = arglocs
 op_rr(self.mc, result.value, arg1.value)
 return fcond
+f.__name__ = 'emit_op_%s' % name
 return f
 
-def gen_emit_float_cmp_op(cond):
+def gen_emit_float_cmp_op(name, cond):
 def f(self, op, arglocs, regalloc, fcond):
 arg1, arg2, res = arglocs
 inv = c.get_opposite_of(cond)
@@ -98,9 +105,10 @@
 self.mc.MOV_ri(res.value, 1, cond=cond)
 self.mc.MOV_ri(res.value, 0, cond=inv)
 return fcond
+f.__name__ = 'emit_op_%s' % name
 return f
 
-def gen_emit_float_cmp_op_guard(guard_cond):
+def gen_emit_float_cmp_op_guard(name, guard_cond):
 def f(self, op, guard, arglocs, regalloc, fcond):
 arg1 = arglocs[0]
 arg2 = arglocs[1]
@@ -113,6 +121,7 @@
 cond = inv
 self._emit_guard(guard, arglocs[2:], cond)
 return fcond
+f.__name__ = 'emit_guard_%s' % name
 return f
 
 class saved_registers(object):
diff --git a/pypy/jit/backend/arm/opassembler.py 
b/pypy/jit/backend/arm/opassembler.py
--- a/pypy/jit/backend/arm/opassembler.py
+++ b/pypy/jit/backend/arm/opassembler.py
@@ -9,6 +9,7 @@
 
 from pypy.jit.backend.arm.helper.assembler import (gen_emit_op_by_helper_call,
 gen_emit_op_unary_cmp,
+gen_emit_guard_unary_cmp,
 gen_emit_op_ri,
 gen_emit_cmp_op,
 gen_emit_cmp_op_guard,
@@ -117,45 +118,45 @@
 self._emit_guard_overflow(guard, arglocs[3:], fcond)
 return fcond
 
-emit_op_int_floordiv = gen_emit_op_by_helper_call('DIV')
-emit_op_int_mod = gen_emit_op_by_helper_call('MOD')
-emit_op_uint_floordiv = gen_emit_op_by_helper_call('UDIV')
+emit_op_int_floordiv = 

[pypy-commit] pypy lightweight-finalizers: remove unused imports

2011-10-25 Thread fijal
Author: Maciej Fijalkowski fij...@gmail.com
Branch: lightweight-finalizers
Changeset: r48440:e916dec7191d
Date: 2011-10-25 16:35 +0200
http://bitbucket.org/pypy/pypy/changeset/e916dec7191d/

Log:remove unused imports

diff --git a/pypy/rpython/test/test_rclass.py b/pypy/rpython/test/test_rclass.py
--- a/pypy/rpython/test/test_rclass.py
+++ b/pypy/rpython/test/test_rclass.py
@@ -3,8 +3,7 @@
 from pypy.translator.translator import TranslationContext, graphof
 from pypy.rpython.lltypesystem.lltype import *
 from pypy.rpython.ootypesystem import ootype
-from pypy.rlib.rarithmetic import intmask, r_longlong
-from pypy.rlib import rgc
+from pypy.rlib.rarithmetic import r_longlong
 from pypy.rpython.test.tool import BaseRtypingTest, LLRtypeMixin, OORtypeMixin
 from pypy.rpython.rclass import IR_IMMUTABLE, IR_IMMUTABLE_ARRAY
 from pypy.rpython.rclass import IR_QUASIIMMUTABLE, IR_QUASIIMMUTABLE_ARRAY
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] extradoc extradoc: add myself

2011-10-25 Thread fijal
Author: Maciej Fijalkowski fij...@gmail.com
Branch: extradoc
Changeset: r3938:1fc0097464a4
Date: 2011-10-25 16:54 +0200
http://bitbucket.org/pypy/extradoc/changeset/1fc0097464a4/

Log:add myself

diff --git a/sprintinfo/gothenburg-2011-2/people.txt 
b/sprintinfo/gothenburg-2011-2/people.txt
--- a/sprintinfo/gothenburg-2011-2/people.txt
+++ b/sprintinfo/gothenburg-2011-2/people.txt
@@ -11,6 +11,7 @@
 Jacob Hallen lives there
 Laura Creighton  lives there
 Armin Rigo   ?  ?
+Maciej Fija#322;kowski   2-8 Nov? vegetarian
 Antonio Cuni 4-10 november  Laura's and Jacob's
 H#229;kan Ard#246;   3-8?
 Sam Lade 1-9Hotel Poseidon
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy lightweight-finalizers: remove track_alloc_stop support, not needed any more

2011-10-25 Thread fijal
Author: Maciej Fijalkowski fij...@gmail.com
Branch: lightweight-finalizers
Changeset: r48441:d80d4e3f457a
Date: 2011-10-25 16:58 +0200
http://bitbucket.org/pypy/pypy/changeset/d80d4e3f457a/

Log:remove track_alloc_stop support, not needed any more

diff --git a/pypy/rpython/lltypesystem/lloperation.py 
b/pypy/rpython/lltypesystem/lloperation.py
--- a/pypy/rpython/lltypesystem/lloperation.py
+++ b/pypy/rpython/lltypesystem/lloperation.py
@@ -400,7 +400,7 @@
 'raw_store':LLOp(),
 'stack_malloc': LLOp(), # mmh
 'track_alloc_start':LLOp(),
-'track_alloc_stop': LLOp(canrun=True),
+'track_alloc_stop': LLOp(),
 'adr_add':  LLOp(canfold=True),
 'adr_sub':  LLOp(canfold=True),
 'adr_delta':LLOp(canfold=True),
diff --git a/pypy/rpython/lltypesystem/opimpl.py 
b/pypy/rpython/lltypesystem/opimpl.py
--- a/pypy/rpython/lltypesystem/opimpl.py
+++ b/pypy/rpython/lltypesystem/opimpl.py
@@ -4,7 +4,6 @@
 from pypy.rpython.lltypesystem import lltype, llmemory
 from pypy.rpython.lltypesystem.lloperation import opimpls
 from pypy.rlib import debug
-from pypy.tool import leakfinder
 
 # 
 # Implementation of the 'canfold' operations
@@ -599,9 +598,6 @@
 from pypy.rlib.rtimer import read_timestamp
 return read_timestamp()
 
-def op_track_alloc_stop(addr):
-leakfinder.remember_free(addr.ptr._obj)
-
 # 
 
 def get_op_impl(opname):
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy lightweight-finalizers: close merged branch

2011-10-25 Thread fijal
Author: Maciej Fijalkowski fij...@gmail.com
Branch: lightweight-finalizers
Changeset: r48443:630cc8b2cb4c
Date: 2011-10-25 17:00 +0200
http://bitbucket.org/pypy/pypy/changeset/630cc8b2cb4c/

Log:close merged branch

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


[pypy-commit] pypy default: Provide a hint that can be specified as a decorator - @rgc.is_light_finalizer

2011-10-25 Thread fijal
Author: Maciej Fijalkowski fij...@gmail.com
Branch: 
Changeset: r48445:9d13b202cb4b
Date: 2011-10-25 18:21 +0200
http://bitbucket.org/pypy/pypy/changeset/9d13b202cb4b/

Log:Provide a hint that can be specified as a decorator -
@rgc.is_light_finalizer

diff --git a/pypy/rlib/rgc.py b/pypy/rlib/rgc.py
--- a/pypy/rlib/rgc.py
+++ b/pypy/rlib/rgc.py
@@ -214,6 +214,10 @@
 func._gc_no_collect_ = True
 return func
 
+def is_light_finalizer(func):
+func._is_light_finalizer_ = True
+return func
+
 # 
 
 def get_rpy_roots():
diff --git a/pypy/rpython/memory/gctransform/framework.py 
b/pypy/rpython/memory/gctransform/framework.py
--- a/pypy/rpython/memory/gctransform/framework.py
+++ b/pypy/rpython/memory/gctransform/framework.py
@@ -1293,7 +1293,7 @@
 fptr = self.transformer.annotate_finalizer(ll_finalizer,
 [llmemory.Address, llmemory.Address], llmemory.Address)
 g = destrptr._obj.graph
-light = not FinalizerAnalyzer(self.translator).analyze_direct_call(g)
+light = not 
FinalizerAnalyzer(self.translator).analyze_light_finalizer(g)
 return fptr, light
 
 def make_custom_trace_funcptr_for_type(self, TYPE):
diff --git a/pypy/rpython/memory/gcwrapper.py b/pypy/rpython/memory/gcwrapper.py
--- a/pypy/rpython/memory/gcwrapper.py
+++ b/pypy/rpython/memory/gcwrapper.py
@@ -201,7 +201,7 @@
 
 assert not type_contains_pyobjs(TYPE), not implemented
 t = self.llinterp.typer.annotator.translator
-light = not FinalizerAnalyzer(t).analyze_direct_call(destrgraph)
+light = not FinalizerAnalyzer(t).analyze_light_finalizer(destrgraph)
 def ll_finalizer(addr, dummy):
 assert dummy == llmemory.NULL
 try:
diff --git a/pypy/translator/backendopt/finalizer.py 
b/pypy/translator/backendopt/finalizer.py
--- a/pypy/translator/backendopt/finalizer.py
+++ b/pypy/translator/backendopt/finalizer.py
@@ -2,6 +2,11 @@
 from pypy.translator.backendopt import graphanalyze
 from pypy.rpython.lltypesystem import lltype
 
+class FinalizerError(Exception):
+ __del__ marked as lightweight finalizer, but the analyzer did
+not agreed
+
+
 class FinalizerAnalyzer(graphanalyze.BoolGraphAnalyzer):
  Analyzer that determines whether a finalizer is lightweight enough
 so it can be called without all the complicated logic in the garbage
@@ -15,6 +20,13 @@
  'direct_ptradd', 'force_cast', 'track_alloc_stop',
  'raw_free']
 
+def analyze_light_finalizer(self, graph):
+result = self.analyze_direct_call(graph)
+if (result is self.top_result() and
+getattr(graph.func, '_is_light_finalizer_', False)):
+raise FinalizerError(FinalizerError.__doc__, graph)
+return result
+
 def analyze_simple_operation(self, op, graphinfo):
 if op.opname in self.ok_operations:
 return self.bottom_result()
diff --git a/pypy/translator/backendopt/test/test_finalizer.py 
b/pypy/translator/backendopt/test/test_finalizer.py
--- a/pypy/translator/backendopt/test/test_finalizer.py
+++ b/pypy/translator/backendopt/test/test_finalizer.py
@@ -1,11 +1,13 @@
 
 import py
-from pypy.translator.backendopt.finalizer import FinalizerAnalyzer
+from pypy.translator.backendopt.finalizer import FinalizerAnalyzer,\
+ FinalizerError
 from pypy.translator.translator import TranslationContext, graphof
 from pypy.translator.backendopt.all import backend_optimizations
 from pypy.translator.unsimplify import varoftype
 from pypy.rpython.lltypesystem import lltype, rffi
 from pypy.conftest import option
+from pypy.rlib import rgc
 
 
 class BaseFinalizerAnalyzerTests(object):
@@ -26,7 +28,7 @@
 t.view()
 a = FinalizerAnalyzer(t)
 fgraph = graphof(t, func_to_analyze)
-result = a.analyze_direct_call(fgraph)
+result = a.analyze_light_finalizer(fgraph)
 return result
 
 def test_nothing(self):
@@ -124,15 +126,17 @@
 r = self.analyze(f, [], A.__del__.im_func)
 assert r
 
-def test_os_call(self):
-py.test.skip(can allocate OSError, but also can raise, ignore for 
now)
-import os
-
-def f(i):
-os.close(i)
+def test_is_light_finalizer_decorator(self):
+S = lltype.GcStruct('S')
 
-r = self.analyze(f, [int], backendopt=True)
-assert not r
+@rgc.is_light_finalizer
+def f():
+lltype.malloc(S)
+@rgc.is_light_finalizer
+def g():
+pass
+self.analyze(g, []) # did not explode
+py.test.raises(FinalizerError, self.analyze, f, [])
 
 class TestOOType(BaseFinalizerAnalyzerTests):
 type_system = 'ootype'
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: I swear I did that change before - remove the incorrect usage of close

2011-10-25 Thread fijal
Author: Maciej Fijalkowski fij...@gmail.com
Branch: 
Changeset: r48446:2612cae35357
Date: 2011-10-25 19:00 +0200
http://bitbucket.org/pypy/pypy/changeset/2612cae35357/

Log:I swear I did that change before - remove the incorrect usage of
close introduced by chance when experimenting with closing urllib2
requests.

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 virtual-dicts: make the heapcache a bit smarter about how stuff escaped

2011-10-25 Thread alex_gaynor
Author: Alex Gaynor alex.gay...@gmail.com
Branch: virtual-dicts
Changeset: r48447:d58706c7bdb6
Date: 2011-10-25 14:33 -0400
http://bitbucket.org/pypy/pypy/changeset/d58706c7bdb6/

Log:make the heapcache a bit smarter about how stuff escaped

diff --git a/pypy/jit/metainterp/heapcache.py b/pypy/jit/metainterp/heapcache.py
--- a/pypy/jit/metainterp/heapcache.py
+++ b/pypy/jit/metainterp/heapcache.py
@@ -41,6 +41,13 @@
 self.dependencies.setdefault(box, []).append(valuebox)
 else:
 self._escape(valuebox)
+elif opnum == rop.SETARRAYITEM_GC:
+assert len(argboxes) == 3
+box, indexbox, valuebox = argboxes
+if self.is_unescaped(box) and self.is_unescaped(valuebox):
+self.dependencies.setdefault(box, []).append(valuebox)
+else:
+self._escape(valuebox)
 # GETFIELD_GC and MARK_OPAQUE_PTR doesn't escape their arguments
 elif opnum != rop.GETFIELD_GC and opnum != rop.MARK_OPAQUE_PTR:
 idx = 0
@@ -60,14 +67,11 @@
 self._escape(dep)
 
 def clear_caches(self, opnum, descr, argboxes):
-if opnum == rop.SETFIELD_GC:
-return
-if opnum == rop.SETARRAYITEM_GC:
-return
-if opnum == rop.SETFIELD_RAW:
-return
-if opnum == rop.SETARRAYITEM_RAW:
-return
+if (opnum == rop.SETFIELD_GC or
+opnum == rop.SETARRAYITEM_GC or
+opnum == rop.SETFIELD_RAW or
+opnum == rop.SETARRAYITEM_RAW or
+opnum == rop.SETINTERIORFIELD_GC):
 if rop._OVF_FIRST = opnum = rop._OVF_LAST:
 return
 if rop._NOSIDEEFFECT_FIRST = opnum = rop._NOSIDEEFFECT_LAST:
@@ -75,9 +79,9 @@
 if opnum == rop.CALL or opnum == rop.CALL_LOOPINVARIANT:
 effectinfo = descr.get_extra_info()
 ef = effectinfo.extraeffect
-if ef == effectinfo.EF_LOOPINVARIANT or \
-   ef == effectinfo.EF_ELIDABLE_CANNOT_RAISE or \
-   ef == effectinfo.EF_ELIDABLE_CAN_RAISE:
+if (ef == effectinfo.EF_LOOPINVARIANT or
+ef == effectinfo.EF_ELIDABLE_CANNOT_RAISE or
+ef == effectinfo.EF_ELIDABLE_CAN_RAISE):
 return
 # A special case for ll_arraycopy, because it is so common, and its
 # effects are so well defined.
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
@@ -3521,7 +3521,7 @@
 self.check_loops({int_sub: 1, int_gt: 1, guard_true: 1, jump: 
1})
 
 def test_virtual_opaque_ptr(self):
-myjitdriver = JitDriver(greens = [], reds=[n])
+myjitdriver = JitDriver(greens = [], reds = [n])
 erase, unerase = rerased.new_erasing_pair(x)
 @look_inside_iff(lambda x: isvirtual(x))
 def g(x):
@@ -3539,6 +3539,27 @@
 assert res == 0
 self.check_loops({int_sub: 1, int_gt: 1, guard_true: 1, jump: 
1})
 
+def test_virtual_opaque_dict(self):
+myjitdriver = JitDriver(greens = [], reds = [n])
+erase, unerase = rerased.new_erasing_pair(x)
+@look_inside_iff(lambda x: isvirtual(x))
+def g(x):
+return x[0][key] - 1
+def f(n):
+while n  0:
+myjitdriver.jit_merge_point(n=n)
+x = [{}]
+x[0][key] = n
+x[0][other key] = n
+y = erase(x)
+z = unerase(y)
+n = g(x)
+return n
+res = self.meta_interp(f, [10])
+assert res == 0
+self.check_loops({int_sub: 1, int_gt: 1, guard_true: 1, jump: 
1})
+
+
 
 class TestLLtype(BaseLLtypeTests, LLJitMixin):
 def test_tagged(self):
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy virtual-dicts: add a unittest for the previous commit

2011-10-25 Thread alex_gaynor
Author: Alex Gaynor alex.gay...@gmail.com
Branch: virtual-dicts
Changeset: r48448:c1dbbe1bd86e
Date: 2011-10-25 14:36 -0400
http://bitbucket.org/pypy/pypy/changeset/c1dbbe1bd86e/

Log:add a unittest for the previous commit

diff --git a/pypy/jit/metainterp/heapcache.py b/pypy/jit/metainterp/heapcache.py
--- a/pypy/jit/metainterp/heapcache.py
+++ b/pypy/jit/metainterp/heapcache.py
@@ -72,6 +72,7 @@
 opnum == rop.SETFIELD_RAW or
 opnum == rop.SETARRAYITEM_RAW or
 opnum == rop.SETINTERIORFIELD_GC):
+return
 if rop._OVF_FIRST = opnum = rop._OVF_LAST:
 return
 if rop._NOSIDEEFFECT_FIRST = opnum = rop._NOSIDEEFFECT_LAST:
diff --git a/pypy/jit/metainterp/test/test_heapcache.py 
b/pypy/jit/metainterp/test/test_heapcache.py
--- a/pypy/jit/metainterp/test/test_heapcache.py
+++ b/pypy/jit/metainterp/test/test_heapcache.py
@@ -371,3 +371,17 @@
 assert h.is_unescaped(box1)
 h.invalidate_caches(rop.SETARRAYITEM_GC, None, [box2, index1, box1])
 assert not h.is_unescaped(box1)
+
+h = HeapCache()
+h.new_array(box1, lengthbox1)
+h.new(box2)
+assert h.is_unescaped(box1)
+assert h.is_unescaped(box2)
+h.invalidate_caches(rop.SETARRAYITEM_GC, None, [box1, lengthbox2, 
box2])
+assert h.is_unescaped(box1)
+assert h.is_unescaped(box2)
+h.invalidate_caches(
+rop.CALL, FakeCallDescr(FakeEffektinfo.EF_RANDOM_EFFECTS), [box1]
+)
+assert not h.is_unescaped(box1)
+assert not h.is_unescaped(box2)
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy virtual-dicts: merged default

2011-10-25 Thread alex_gaynor
Author: Alex Gaynor alex.gay...@gmail.com
Branch: virtual-dicts
Changeset: r48449:d876b901547e
Date: 2011-10-25 14:38 -0400
http://bitbucket.org/pypy/pypy/changeset/d876b901547e/

Log:merged default

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
 
diff --git a/pypy/jit/backend/llsupport/gc.py b/pypy/jit/backend/llsupport/gc.py
--- a/pypy/jit/backend/llsupport/gc.py
+++ b/pypy/jit/backend/llsupport/gc.py
@@ -649,10 +649,13 @@
 def malloc_basic(size, tid):
 type_id = llop.extract_ushort(llgroup.HALFWORD, tid)
 has_finalizer = bool(tid  (1llgroup.HALFSHIFT))
+has_light_finalizer = bool(tid  (1(llgroup.HALFSHIFT + 1)))
 check_typeid(type_id)
 res = llop1.do_malloc_fixedsize_clear(llmemory.GCREF,
   type_id, size,
-  has_finalizer, False)
+  has_finalizer,
+  has_light_finalizer,
+  False)
 # In case the operation above failed, we are returning NULL
 # from this function to assembler.  There is also an RPython
 # exception set, typically MemoryError; but it's easier and
@@ -723,7 +726,7 @@
 # also use it to allocate varsized objects.  The tid
 # and possibly the length are both set afterward.
 gcref = llop1.do_malloc_fixedsize_clear(llmemory.GCREF,
-0, size, False, False)
+0, size, False, False, False)
 return rffi.cast(lltype.Signed, gcref)
 self.malloc_slowpath = malloc_slowpath
 self.MALLOC_SLOWPATH = lltype.FuncType([lltype.Signed], lltype.Signed)
@@ -747,7 +750,9 @@
 type_id = self.layoutbuilder.get_type_id(S)
 assert not self.layoutbuilder.is_weakref_type(S)
 has_finalizer = bool(self.layoutbuilder.has_finalizer(S))
-flags = int(has_finalizer)  llgroup.HALFSHIFT
+has_light_finalizer = bool(self.layoutbuilder.has_light_finalizer(S))
+flags = (int(has_finalizer)  llgroup.HALFSHIFT |
+ int(has_light_finalizer)  (llgroup.HALFSHIFT + 1))
 descr.tid = llop.combine_ushort(lltype.Signed, type_id, flags)
 
 def init_array_descr(self, A, descr):
diff --git a/pypy/jit/backend/llsupport/test/test_gc.py 
b/pypy/jit/backend/llsupport/test/test_gc.py
--- a/pypy/jit/backend/llsupport/test/test_gc.py
+++ b/pypy/jit/backend/llsupport/test/test_gc.py
@@ -247,11 +247,12 @@
 self.record = []
 
 def do_malloc_fixedsize_clear(self, RESTYPE, type_id, size,
-  has_finalizer, contains_weakptr):
+  has_finalizer, has_light_finalizer,
+  contains_weakptr):
 assert not contains_weakptr
 p = llmemory.raw_malloc(size)
 p = llmemory.cast_adr_to_ptr(p, RESTYPE)
-flags = int(has_finalizer)  16
+flags = (int(has_finalizer)  16) | (int(has_light_finalizer)  17)
 tid = llop.combine_ushort(lltype.Signed, type_id, flags)
 self.record.append((fixedsize, repr(size), tid, p))
 return p
diff --git a/pypy/module/_socket/interp_socket.py 
b/pypy/module/_socket/interp_socket.py
--- a/pypy/module/_socket/interp_socket.py
+++ b/pypy/module/_socket/interp_socket.py
@@ -19,7 +19,7 @@
 class W_RSocket(Wrappable, RSocket):
 def __del__(self):
 self.clear_all_weakrefs()
-self.close()
+RSocket.__del__(self)
 
 def accept_w(self, space):
 accept() - (socket object, address info)
diff --git a/pypy/module/array/interp_array.py 
b/pypy/module/array/interp_array.py
--- a/pypy/module/array/interp_array.py
+++ b/pypy/module/array/interp_array.py
@@ -211,7 +211,9 @@
 return result
 
 def __del__(self):
-self.clear_all_weakrefs()
+# note that we don't call clear_all_weakrefs here because
+# an array with freed buffer is ok to see - it's just empty with 0
+# length
 self.setlen(0)
 
 def setlen(self, size):
diff --git a/pypy/module/array/test/test_array.py 
b/pypy/module/array/test/test_array.py
--- a/pypy/module/array/test/test_array.py
+++ b/pypy/module/array/test/test_array.py
@@ -824,6 +824,22 @@
 r 

[pypy-commit] pypy jit-simplify-backendintf: A branch to simplify the backend interface, killing set_future_value_xx().

2011-10-25 Thread arigo
Author: Armin Rigo ar...@tunes.org
Branch: jit-simplify-backendintf
Changeset: r48450:26419ef5e993
Date: 2011-10-25 20:07 +0200
http://bitbucket.org/pypy/pypy/changeset/26419ef5e993/

Log:A branch to simplify the backend interface, killing
set_future_value_xx().

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


[pypy-commit] pypy jit-simplify-backendintf: Change the interface and fix the llgraph backend.

2011-10-25 Thread arigo
Author: Armin Rigo ar...@tunes.org
Branch: jit-simplify-backendintf
Changeset: r48451:6e1590cee5e1
Date: 2011-10-25 20:30 +0200
http://bitbucket.org/pypy/pypy/changeset/6e1590cee5e1/

Log:Change the interface and fix the llgraph backend.

diff --git a/pypy/jit/backend/llgraph/runner.py 
b/pypy/jit/backend/llgraph/runner.py
--- a/pypy/jit/backend/llgraph/runner.py
+++ b/pypy/jit/backend/llgraph/runner.py
@@ -257,22 +257,25 @@
 self.latest_frame = frame
 return fail_index
 
-def execute_token(self, loop_token):
+def execute_token(self, loop_token, *args):
 Calls the assembler generated for the given loop.
 Returns the ResOperation that failed, of type rop.FAIL.
 
+# XXX RPythonize me
+for index, x in enumerate(args):
+TYPE = lltype.typeOf(x)
+if TYPE == lltype.Signed:
+llimpl.set_future_value_int(index, x)
+elif TYPE == llmemory.GCREF:
+llimpl.set_future_value_ref(index, x)
+elif TYPE == longlong.FLOATSTORAGE:
+llimpl.set_future_value_float(index, x)
+else:
+raise ValueError(TYPE)
+#
 fail_index = self._execute_token(loop_token)
 return self.get_fail_descr_from_number(fail_index)
 
-def set_future_value_int(self, index, intvalue):
-llimpl.set_future_value_int(index, intvalue)
-
-def set_future_value_ref(self, index, objvalue):
-llimpl.set_future_value_ref(index, objvalue)
-
-def set_future_value_float(self, index, floatvalue):
-llimpl.set_future_value_float(index, floatvalue)
-
 def get_latest_value_int(self, index):
 return llimpl.frame_int_getvalue(self.latest_frame, index)
 
diff --git a/pypy/jit/backend/model.py b/pypy/jit/backend/model.py
--- a/pypy/jit/backend/model.py
+++ b/pypy/jit/backend/model.py
@@ -84,26 +84,16 @@
 Print a disassembled version of looptoken to stdout
 raise NotImplementedError
 
-def execute_token(self, looptoken):
+def execute_token(self, looptoken, *args):
 Execute the generated code referenced by the looptoken.
 Returns the descr of the last executed operation: either the one
 attached to the failing guard, or the one attached to the FINISH.
-Use set_future_value_xxx() before, and get_latest_value_xxx() after.
+Use get_latest_value_xxx() afterwards to read the result(s).
+(This method is automatically specialized by the front-end if
+needed, for various types and numbers of *args.)
 
 raise NotImplementedError
 
-def set_future_value_int(self, index, intvalue):
-Set the value for the index'th argument for the loop to run.
-raise NotImplementedError
-
-def set_future_value_float(self, index, floatvalue):
-Set the value for the index'th argument for the loop to run.
-raise NotImplementedError
-
-def set_future_value_ref(self, index, objvalue):
-Set the value for the index'th argument for the loop to run.
-raise NotImplementedError
-
 def get_latest_value_int(self, index):
 Returns the value for the index'th argument to the
 last executed operation (from 'fail_args' if it was a guard,
diff --git a/pypy/jit/backend/test/runner_test.py 
b/pypy/jit/backend/test/runner_test.py
--- a/pypy/jit/backend/test/runner_test.py
+++ b/pypy/jit/backend/test/runner_test.py
@@ -34,20 +34,17 @@
 descr)
 looptoken = LoopToken()
 self.cpu.compile_loop(inputargs, operations, looptoken)
-j = 0
+args = []
 for box in inputargs:
 if isinstance(box, BoxInt):
-self.cpu.set_future_value_int(j, box.getint())
-j += 1
+args.append(box.getint())
 elif isinstance(box, (BoxPtr, BoxObj)):
-self.cpu.set_future_value_ref(j, box.getref_base())
-j += 1
+args.append(box.getref_base())
 elif isinstance(box, BoxFloat):
-self.cpu.set_future_value_float(j, box.getfloatstorage())
-j += 1
+args.append(box.getfloatstorage())
 else:
 raise NotImplementedError(box)
-res = self.cpu.execute_token(looptoken)
+res = self.cpu.execute_token(looptoken, *args)
 if res is operations[-1].getdescr():
 self.guard_failed = False
 else:
@@ -108,8 +105,7 @@
 inputargs = [i0]
 looptoken = LoopToken()
 self.cpu.compile_loop(inputargs, operations, looptoken)
-self.cpu.set_future_value_int(0, 2)
-fail = self.cpu.execute_token(looptoken)
+fail = self.cpu.execute_token(looptoken, 2)
 res = self.cpu.get_latest_value_int(0)
 assert res == 3
 assert fail.identifier == 1
@@ -129,8 +125,7 @@
 

[pypy-commit] pypy default: Make this test closer to what was intended.

2011-10-25 Thread arigo
Author: Armin Rigo ar...@tunes.org
Branch: 
Changeset: r48452:9a4ee13149cd
Date: 2011-10-25 15:54 +0200
http://bitbucket.org/pypy/pypy/changeset/9a4ee13149cd/

Log:Make this test closer to what was intended.

diff --git a/pypy/jit/backend/llsupport/test/test_gc.py 
b/pypy/jit/backend/llsupport/test/test_gc.py
--- a/pypy/jit/backend/llsupport/test/test_gc.py
+++ b/pypy/jit/backend/llsupport/test/test_gc.py
@@ -250,10 +250,11 @@
   has_finalizer, has_light_finalizer,
   contains_weakptr):
 assert not contains_weakptr
+assert not has_finalizer   # in these tests
+assert not has_light_finalizer # in these tests
 p = llmemory.raw_malloc(size)
 p = llmemory.cast_adr_to_ptr(p, RESTYPE)
-flags = (int(has_finalizer)  16) | (int(has_light_finalizer)  17)
-tid = llop.combine_ushort(lltype.Signed, type_id, flags)
+tid = llop.combine_ushort(lltype.Signed, type_id, 0)
 self.record.append((fixedsize, repr(size), tid, p))
 return p
 
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy ppc-jit-backend: More PPC64 support for arraylen_gc, setarrayitem_gc, getarrayitem_gc

2011-10-25 Thread edelsoh
Author: edelsoh
Branch: ppc-jit-backend
Changeset: r48453:d4c1290fd460
Date: 2011-10-25 15:23 -0400
http://bitbucket.org/pypy/pypy/changeset/d4c1290fd460/

Log:More PPC64 support for arraylen_gc, setarrayitem_gc, getarrayitem_gc

diff --git a/pypy/jit/backend/ppc/ppcgen/opassembler.py 
b/pypy/jit/backend/ppc/ppcgen/opassembler.py
--- a/pypy/jit/backend/ppc/ppcgen/opassembler.py
+++ b/pypy/jit/backend/ppc/ppcgen/opassembler.py
@@ -222,9 +222,15 @@
 offset = locs[2]
 if offset is not None:
 if offset.is_imm():
-self.mc.lwz(r.r0.value, locs[0].value, offset.value)
+if IS_PPC_32:
+self.mc.lwz(r.r0.value, locs[0].value, offset.value)
+else:
+self.mc.ld(r.r0.value, locs[0].value, offset.value)
 else:
-self.mc.lwzx(r.r0.value, locs[0].value, offset.value)
+if IS_PPC_32:
+self.mc.lwzx(r.r0.value, locs[0].value, offset.value)
+else:
+self.mc.ldx(r.r0.value, locs[0].value, offset.value)
 self.mc.cmp(r.r0.value, locs[1].value)
 else:
 assert 0, not implemented yet
@@ -313,7 +319,10 @@
 # XXX 64 bit adjustment
 def emit_arraylen_gc(self, op, arglocs, regalloc):
 res, base_loc, ofs = arglocs
-self.mc.lwz(res.value, base_loc.value, ofs.value)
+if IS_PPC_32:
+self.mc.lwz(res.value, base_loc.value, ofs.value)
+else:
+self.mc.ld(res.value, base_loc.value, ofs.value)
 
 # XXX 64 bit adjustment
 def emit_setarrayitem_gc(self, op, arglocs, regalloc):
@@ -330,7 +339,7 @@
 scale_loc = r.r0
 
 if scale.value == 3:
-assert 0, not implemented yet
+self.mc.stdx(value_loc.value, base_loc.value, scale_loc.value)
 elif scale.value == 2:
 self.mc.stwx(value_loc.value, base_loc.value, scale_loc.value)
 elif scale.value == 1:
@@ -354,7 +363,7 @@
 scale_loc = r.r0
 
 if scale.value == 3:
-assert 0, not implemented yet
+self.mc.ldx(res.value, base_loc.value, scale_loc.value)
 elif scale.value == 2:
 self.mc.lwzx(res.value, base_loc.value, scale_loc.value)
 elif scale.value == 1:
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy virtual-dicts: fix a really emberassing typo

2011-10-25 Thread alex_gaynor
Author: Alex Gaynor alex.gay...@gmail.com
Branch: virtual-dicts
Changeset: r48454:6283d742ab74
Date: 2011-10-25 16:20 -0400
http://bitbucket.org/pypy/pypy/changeset/6283d742ab74/

Log:fix a really emberassing typo

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
@@ -3616,7 +3616,7 @@
 res = self.meta_interp(main, [False, 100, True], taggedpointers=True)
 
 def test_rerased(self):
-eraseX, uneraseX = rerased,new_erasing_pair(X)
+eraseX, uneraseX = rerased.new_erasing_pair(X)
 #
 class X:
 def __init__(self, a, b):
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: progress towards get/set interiorfield in test_ll_random

2011-10-25 Thread fijal
Author: Maciej Fijalkowski fij...@gmail.com
Branch: 
Changeset: r48455:de02b302dd89
Date: 2011-10-25 22:32 +0200
http://bitbucket.org/pypy/pypy/changeset/de02b302dd89/

Log:progress towards get/set interiorfield in test_ll_random

diff --git a/pypy/jit/backend/test/test_ll_random.py 
b/pypy/jit/backend/test/test_ll_random.py
--- a/pypy/jit/backend/test/test_ll_random.py
+++ b/pypy/jit/backend/test/test_ll_random.py
@@ -28,16 +28,27 @@
 fork.structure_types_and_vtables = self.structure_types_and_vtables
 return fork
 
-def get_structptr_var(self, r, must_have_vtable=False, type=lltype.Struct):
+def _choose_ptr_vars(self, from_, type, array_of_structs):
+ptrvars = []
+for i in range(len(from_)):
+v, S = from_[i][:2]
+if not isinstance(S, type):
+continue
+if (isinstance(S, lltype.Array) and
+isinstance(S.OF, lltype.Struct) == array_of_structs):
+ptrvars.append((v, S))
+return ptrvars
+
+def get_structptr_var(self, r, must_have_vtable=False, type=lltype.Struct,
+  array_of_structs=False):
 while True:
-ptrvars = [(v, S) for (v, S) in self.ptrvars
-  if isinstance(S, type)]
+ptrvars = self._choose_ptr_vars(self.ptrvars, type,
+array_of_structs)
 if ptrvars and r.random()  0.8:
 v, S = r.choice(ptrvars)
 else:
-prebuilt_ptr_consts = [(v, S)
- for (v, S, _) in self.prebuilt_ptr_consts
- if isinstance(S, type)]
+prebuilt_ptr_consts = self._choose_ptr_vars(
+self.prebuilt_ptr_consts, type, array_of_structs)
 if prebuilt_ptr_consts and r.random()  0.7:
 v, S = r.choice(prebuilt_ptr_consts)
 else:
@@ -48,7 +59,8 @@
 has_vtable=must_have_vtable)
 else:
 # create a new constant array
-p = self.get_random_array(r)
+p = self.get_random_array(r,
+must_be_array_of_structs=array_of_structs)
 S = lltype.typeOf(p).TO
 v = ConstPtr(lltype.cast_opaque_ptr(llmemory.GCREF, p))
 self.prebuilt_ptr_consts.append((v, S,
@@ -74,7 +86,8 @@
 TYPE = lltype.Signed
 return TYPE
 
-def get_random_structure_type(self, r, with_vtable=None, cache=True):
+def get_random_structure_type(self, r, with_vtable=None, cache=True,
+  type=lltype.GcStruct):
 if cache and self.structure_types and r.random()  0.5:
 return r.choice(self.structure_types)
 fields = []
@@ -85,7 +98,7 @@
 for i in range(r.randrange(1, 5)):
 TYPE = self.get_random_primitive_type(r)
 fields.append(('f%d' % i, TYPE))
-S = lltype.GcStruct('S%d' % self.counter, *fields, **kwds)
+S = type('S%d' % self.counter, *fields, **kwds)
 self.counter += 1
 if cache:
 self.structure_types.append(S)
@@ -125,17 +138,29 @@
 setattr(p, fieldname, rffi.cast(TYPE, r.random_integer()))
 return p
 
-def get_random_array_type(self, r):
-TYPE = self.get_random_primitive_type(r)
+def get_random_array_type(self, r, can_be_array_of_struct=False,
+  must_be_array_of_structs=False):
+if ((can_be_array_of_struct and r.random()  0.1) or
+must_be_array_of_structs):
+TYPE = self.get_random_structure_type(r, cache=False,
+  type=lltype.Struct)
+else:
+TYPE = self.get_random_primitive_type(r)
 return lltype.GcArray(TYPE)
 
-def get_random_array(self, r):
-A = self.get_random_array_type(r)
+def get_random_array(self, r, must_be_array_of_structs=False):
+A = self.get_random_array_type(r,
+   must_be_array_of_structs=must_be_array_of_structs)
 length = (r.random_integer() // 15) % 300  # length: between 0 and 299
# likely to be small
 p = lltype.malloc(A, length)
-for i in range(length):
-p[i] = rffi.cast(A.OF, r.random_integer())
+if isinstance(A.OF, lltype.Primitive):
+for i in range(length):
+p[i] = rffi.cast(A.OF, r.random_integer())
+else:
+for i in range(length):
+for fname, TP in A.OF._flds.iteritems():
+setattr(p[i], fname, rffi.cast(TP, r.random_integer()))
 return p
 
 def get_index(self, length, r):
@@ -220,7 +245,7 @@
 
 class 

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

2011-10-25 Thread edelsohn
Author: edelsohn
Branch: ppc-jit-backend
Changeset: r48457:c58fa0a4d970
Date: 2011-10-25 16:36 -0400
http://bitbucket.org/pypy/pypy/changeset/c58fa0a4d970/

Log:Add PPC64 support for strlen

diff --git a/pypy/jit/backend/ppc/ppcgen/opassembler.py 
b/pypy/jit/backend/ppc/ppcgen/opassembler.py
--- a/pypy/jit/backend/ppc/ppcgen/opassembler.py
+++ b/pypy/jit/backend/ppc/ppcgen/opassembler.py
@@ -384,9 +384,15 @@
 def emit_strlen(self, op, arglocs, regalloc):
 l0, l1, res = arglocs
 if l1.is_imm():
-self.mc.lwz(res.value, l0.value, l1.getint())
+if IS_PPC_32:
+self.mc.lwz(res.value, l0.value, l1.getint())
+else:
+self.mc.ld(res.value, l0.value, l1.getint())
 else:
-self.mc.lwzx(res.value, l0.value, l1.value)
+if IS_PPC_32:
+self.mc.lwzx(res.value, l0.value, l1.value)
+else:
+self.mc.ldx(res.value, l0.value, l1.value)
 
 def emit_strgetitem(self, op, arglocs, regalloc):
 res, base_loc, ofs_loc, basesize = arglocs
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Typo

2011-10-25 Thread arigo
Author: Armin Rigo ar...@tunes.org
Branch: 
Changeset: r48459:89631bbf04fe
Date: 2011-10-25 22:38 +0200
http://bitbucket.org/pypy/pypy/changeset/89631bbf04fe/

Log:Typo

diff --git a/pypy/jit/backend/test/test_ll_random.py 
b/pypy/jit/backend/test/test_ll_random.py
--- a/pypy/jit/backend/test/test_ll_random.py
+++ b/pypy/jit/backend/test/test_ll_random.py
@@ -652,7 +652,7 @@
 OPERATIONS.append(GetFieldOperation(rop.GETFIELD_GC))
 OPERATIONS.append(GetInteriorFieldOperation(rop.GETINTERIORFIELD_GC))
 OPERATIONS.append(SetFieldOperation(rop.SETFIELD_GC))
-#OPERATIONS.append(SetInteriorFieldOperation(rop.GETINTERIORFIELD_GC))
+#OPERATIONS.append(SetInteriorFieldOperation(rop.SETINTERIORFIELD_GC))
 OPERATIONS.append(NewOperation(rop.NEW))
 OPERATIONS.append(NewOperation(rop.NEW_WITH_VTABLE))
 
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy jit-simplify-backendintf: Fix the front-end. Some reduction in the total

2011-10-25 Thread arigo
Author: Armin Rigo ar...@tunes.org
Branch: jit-simplify-backendintf
Changeset: r48458:cce408b68723
Date: 2011-10-25 22:04 +0200
http://bitbucket.org/pypy/pypy/changeset/cce408b68723/

Log:Fix the front-end. Some reduction in the total number of lines, but
due to a change --- when tracing is done, we raise
ContinueRunningNormally instead of building the arguments directly
for the next iteration, including virtuals --- a number of tests
fail now :-(

diff --git a/pypy/jit/metainterp/blackhole.py b/pypy/jit/metainterp/blackhole.py
--- a/pypy/jit/metainterp/blackhole.py
+++ b/pypy/jit/metainterp/blackhole.py
@@ -1500,7 +1500,6 @@
 all_virtuals=None):
 from pypy.jit.metainterp.resume import blackhole_from_resumedata
 #debug_start('jit-blackhole')
-metainterp_sd.profiler.start_blackhole()
 blackholeinterp = blackhole_from_resumedata(
 metainterp_sd.blackholeinterpbuilder,
 jitdriver_sd,
@@ -1514,10 +1513,9 @@
 current_exc = blackholeinterp._prepare_resume_from_failure(
 resumedescr.guard_opnum, dont_change_position)
 
-try:
-_run_forever(blackholeinterp, current_exc)
-finally:
-metainterp_sd.profiler.end_blackhole()
+#try:
+_run_forever(blackholeinterp, current_exc)
+#finally:
 #debug_stop('jit-blackhole')
 
 def convert_and_run_from_pyjitpl(metainterp, raising_exception=False):
@@ -1525,7 +1523,6 @@
 # 'metainterp.framestack'.
 #debug_start('jit-blackhole')
 metainterp_sd = metainterp.staticdata
-metainterp_sd.profiler.start_blackhole()
 nextbh = None
 for frame in metainterp.framestack:
 curbh = metainterp_sd.blackholeinterpbuilder.acquire_interp()
@@ -1542,8 +1539,7 @@
 firstbh.exception_last_value = current_exc
 current_exc = lltype.nullptr(rclass.OBJECTPTR.TO)
 #
-try:
-_run_forever(firstbh, current_exc)
-finally:
-metainterp_sd.profiler.end_blackhole()
+#try:
+_run_forever(firstbh, current_exc)
+#finally:
 #debug_stop('jit-blackhole')
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
@@ -340,12 +340,11 @@
 
 def handle_fail(self, metainterp_sd, jitdriver_sd):
 if self.must_compile(metainterp_sd, jitdriver_sd):
-return self._trace_and_compile_from_bridge(metainterp_sd,
-   jitdriver_sd)
+self._trace_and_compile_from_bridge(metainterp_sd, jitdriver_sd)
 else:
 from pypy.jit.metainterp.blackhole import resume_in_blackhole
 resume_in_blackhole(metainterp_sd, jitdriver_sd, self)
-assert 0, unreachable
+assert 0, unreachable
 
 def _trace_and_compile_from_bridge(self, metainterp_sd, jitdriver_sd):
 # 'jitdriver_sd' corresponds to the outermost one, i.e. the one
@@ -354,7 +353,7 @@
 # jitdrivers.
 from pypy.jit.metainterp.pyjitpl import MetaInterp
 metainterp = MetaInterp(metainterp_sd, jitdriver_sd)
-return metainterp.handle_guard_failure(self)
+metainterp.handle_guard_failure(self)
 _trace_and_compile_from_bridge._dont_inline_ = True
 
 def must_compile(self, metainterp_sd, jitdriver_sd):
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
@@ -123,9 +123,6 @@
 def sort_key(self):
 raise NotImplementedError
 
-def set_future_value(self, cpu, j):
-raise NotImplementedError
-
 def nonnull(self):
 raise NotImplementedError
 
@@ -288,9 +285,6 @@
 def _get_hash_(self):
 return make_hashable_int(self.value)
 
-def set_future_value(self, cpu, j):
-cpu.set_future_value_int(j, self.value)
-
 def same_constant(self, other):
 if isinstance(other, ConstInt):
 return self.value == other.value
@@ -328,9 +322,6 @@
 def _get_hash_(self):
 return longlong.gethash(self.value)
 
-def set_future_value(self, cpu, j):
-cpu.set_future_value_float(j, self.value)
-
 def same_constant(self, other):
 if isinstance(other, ConstFloat):
 return self.value == other.value
@@ -377,9 +368,6 @@
 def getaddr(self):
 return llmemory.cast_ptr_to_adr(self.value)
 
-def set_future_value(self, cpu, j):
-cpu.set_future_value_ref(j, self.value)
-
 def same_constant(self, other):
 if isinstance(other, ConstPtr):
 return self.value == other.value
@@ -431,9 +419,6 @@
 else:
 return 0
 
-def set_future_value(self, cpu, j):
-cpu.set_future_value_ref(j, self.value)
-
 ##def getaddr(self):
 ### so far this is used only when calling
 ### CodeWriter.IndirectCallset.bytecode_for_address.  We don't need a

[pypy-commit] pypy virtual-dicts: ptr_eq and ptr_ne don't escape things.

2011-10-25 Thread alex_gaynor
Author: Alex Gaynor alex.gay...@gmail.com
Branch: virtual-dicts
Changeset: r48460:8dfa8646de2c
Date: 2011-10-25 16:42 -0400
http://bitbucket.org/pypy/pypy/changeset/8dfa8646de2c/

Log:ptr_eq and ptr_ne don't escape things.

diff --git a/pypy/jit/metainterp/heapcache.py b/pypy/jit/metainterp/heapcache.py
--- a/pypy/jit/metainterp/heapcache.py
+++ b/pypy/jit/metainterp/heapcache.py
@@ -48,8 +48,12 @@
 self.dependencies.setdefault(box, []).append(valuebox)
 else:
 self._escape(valuebox)
-# GETFIELD_GC and MARK_OPAQUE_PTR doesn't escape their arguments
-elif opnum != rop.GETFIELD_GC and opnum != rop.MARK_OPAQUE_PTR:
+# GETFIELD_GC, MARK_OPAQUE_PTR, PTR_EQ, and PTR_NE don't escape their
+# arguments
+elif (opnum != rop.GETFIELD_GC and
+  opnum != rop.MARK_OPAQUE_PTR and
+  opnum != rop.PTR_EQ and
+  opnum != rop.PTR_NE):
 idx = 0
 for box in argboxes:
 # setarrayitem_gc don't escape its first argument
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy releasegil-effectinfo: Initial JIT test for the manifestation of this issue.

2011-10-25 Thread fijal
Author: Maciej Fijalkowski fij...@gmail.com
Branch: releasegil-effectinfo
Changeset: r48461:ce357df2a5c2
Date: 2011-07-18 23:45 +0200
http://bitbucket.org/pypy/pypy/changeset/ce357df2a5c2/

Log:Initial JIT test for the manifestation of this issue.

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
@@ -2619,5 +2619,42 @@
 self.meta_interp(f, [], enable_opts='')
 self.check_loops(new_with_vtable=1)
 
+
+def test_release_gil_flush_heap_cache(self):
+from pypy.rpython.lltypesystem import rffi
+
+T = rffi.CArrayPtr(rffi.TIME_T)
+
+external = rffi.llexternal(time, [T], rffi.TIME_T, threadsafe=True)
+class Lock(object):
+@dont_look_inside
+def acquire(self):
+external(lltype.nullptr(T.TO))
+@dont_look_inside
+def release(self):
+external(lltype.nullptr(T.TO))
+def dealloc(self):
+pass
+@dont_look_inside
+def get_lst():
+return [0]
+myjitdriver = JitDriver(greens=[], reds=[n, l, lock])
+def f(n):
+lock = Lock()
+l = 0
+while n  0:
+myjitdriver.jit_merge_point(lock=lock, l=l, n=n)
+x = get_lst()
+l += len(x)
+lock.acquire()
+# Thist must not reuse the previous one.
+n -= len(x)
+lock.release()
+lock.dealloc()
+return n
+res = self.meta_interp(f, [10])
+self.check_loops(arraylen_gc=2)
+
+
 class TestLLtype(BaseLLtypeTests, LLJitMixin):
 pass
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: look into mmap

2011-10-25 Thread fijal
Author: Maciej Fijalkowski fij...@gmail.com
Branch: 
Changeset: r48462:fc37961a668f
Date: 2011-10-25 23:17 +0200
http://bitbucket.org/pypy/pypy/changeset/fc37961a668f/

Log:look into mmap

diff --git a/pypy/module/pypyjit/policy.py b/pypy/module/pypyjit/policy.py
--- a/pypy/module/pypyjit/policy.py
+++ b/pypy/module/pypyjit/policy.py
@@ -16,7 +16,8 @@
 if modname in ['pypyjit', 'signal', 'micronumpy', 'math', 'exceptions',
'imp', 'sys', 'array', '_ffi', 'itertools', 'operator',
'posix', '_socket', '_sre', '_lsprof', '_weakref',
-   '__pypy__', 'cStringIO', '_collections', 'struct']:
+   '__pypy__', 'cStringIO', '_collections', 'struct',
+   'mmap']:
 return True
 return False
 
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy virtual-dicts: copy{str, unicode}content can't affect heap caches

2011-10-25 Thread alex_gaynor
Author: Alex Gaynor alex.gay...@gmail.com
Branch: virtual-dicts
Changeset: r48463:90eed59807bd
Date: 2011-10-25 17:27 -0400
http://bitbucket.org/pypy/pypy/changeset/90eed59807bd/

Log:copy{str,unicode}content can't affect heap caches

diff --git a/pypy/jit/metainterp/heapcache.py b/pypy/jit/metainterp/heapcache.py
--- a/pypy/jit/metainterp/heapcache.py
+++ b/pypy/jit/metainterp/heapcache.py
@@ -75,7 +75,9 @@
 opnum == rop.SETARRAYITEM_GC or
 opnum == rop.SETFIELD_RAW or
 opnum == rop.SETARRAYITEM_RAW or
-opnum == rop.SETINTERIORFIELD_GC):
+opnum == rop.SETINTERIORFIELD_GC or
+opnum == rop.COPYSTRCONTENT or
+opnum == rop.COPYUNICODECONTENT):
 return
 if rop._OVF_FIRST = opnum = rop._OVF_LAST:
 return
diff --git a/pypy/jit/metainterp/test/test_tracingopts.py 
b/pypy/jit/metainterp/test/test_tracingopts.py
--- a/pypy/jit/metainterp/test/test_tracingopts.py
+++ b/pypy/jit/metainterp/test/test_tracingopts.py
@@ -3,6 +3,7 @@
 from pypy.jit.metainterp.test.support import LLJitMixin
 from pypy.rlib import jit
 from pypy.rlib.rarithmetic import ovfcheck
+from pypy.rlib.rstring import StringBuilder
 
 import py
 
@@ -590,4 +591,14 @@
 assert res == 4
 self.check_operations_history(int_add_ovf=0)
 res = self.interp_operations(fn, [sys.maxint])
-assert res == 12
\ No newline at end of file
+assert res == 12
+
+def test_copy_str_content(self):
+def fn(n):
+a = StringBuilder()
+x = [1]
+a.append(hello world)
+return x[0]
+res = self.interp_operations(fn, [0])
+assert res == 1
+self.check_operations_history(getarrayitem_gc=0, 
getarrayitem_gc_pure=0 )
\ No newline at end of file
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy releasegil-effectinfo: close long abandoned branch

2011-10-25 Thread fijal
Author: Maciej Fijalkowski fij...@gmail.com
Branch: releasegil-effectinfo
Changeset: r48464:48639d927f25
Date: 2011-10-25 23:30 +0200
http://bitbucket.org/pypy/pypy/changeset/48639d927f25/

Log:close long abandoned branch

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


[pypy-commit] pypy default: I fixed this ages ago.

2011-10-25 Thread gutworth
Author: Benjamin Peterson benja...@python.org
Branch: 
Changeset: r48465:7eea9ac595bd
Date: 2011-10-25 20:59 -0400
http://bitbucket.org/pypy/pypy/changeset/7eea9ac595bd/

Log:I fixed this ages ago.

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
@@ -959,8 +959,6 @@
 os_ftruncate(rffi.cast(rffi.INT, fd),
  rffi.cast(rffi.LONGLONG, length)))
 if res  0:
-# Note: for consistency we raise OSError, but CPython
-# raises IOError here
 raise OSError(rposix.get_errno(), os_ftruncate failed)
 
 return extdef([int, r_longlong], s_None,
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: make the test for time.sleep with negative values fail (Issue922)

2011-10-25 Thread timo_jbo
Author: Timo Paulssen timona...@perpetuum-immobile.de
Branch: 
Changeset: r48466:1ee24bbb619b
Date: 2011-10-26 02:57 +0200
http://bitbucket.org/pypy/pypy/changeset/1ee24bbb619b/

Log:make the test for time.sleep with negative values fail (Issue922)

diff --git a/pypy/module/rctime/test/test_rctime.py 
b/pypy/module/rctime/test/test_rctime.py
--- a/pypy/module/rctime/test/test_rctime.py
+++ b/pypy/module/rctime/test/test_rctime.py
@@ -21,7 +21,8 @@
 import os
 raises(TypeError, rctime.sleep, foo)
 rctime.sleep(1.2345)
-
+raises(IOError, rctime.sleep, -1.0)
+
 def test_clock(self):
 import time as rctime
 rctime.clock()
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: raise an IOError when sleeping for negative time (Issue922)

2011-10-25 Thread timo_jbo
Author: Timo Paulssen timona...@perpetuum-immobile.de
Branch: 
Changeset: r48467:b5bd720602fb
Date: 2011-10-26 03:00 +0200
http://bitbucket.org/pypy/pypy/changeset/b5bd720602fb/

Log:raise an IOError when sleeping for negative time (Issue922)

diff --git a/pypy/module/rctime/interp_time.py 
b/pypy/module/rctime/interp_time.py
--- a/pypy/module/rctime/interp_time.py
+++ b/pypy/module/rctime/interp_time.py
@@ -245,6 +245,9 @@
 if sys.platform != 'win32':
 @unwrap_spec(secs=float)
 def sleep(space, secs):
+if secs  0:
+raise space.OperationError(space.w_IOError,
+   space.wrap(Invalid argument: negative 
time in sleep))
 pytime.sleep(secs)
 else:
 from pypy.rlib import rwin32
@@ -265,6 +268,9 @@
OSError(EINTR, sleep() interrupted))
 @unwrap_spec(secs=float)
 def sleep(space, secs):
+if secs  0:
+raise space.OperationError(space.w_IOError,
+   space.wrap(Invalid argument: negative 
time in sleep))
 # as decreed by Guido, only the main thread can be
 # interrupted.
 main_thread = space.fromcache(State).main_thread
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Merge heads

2011-10-25 Thread timo_jbo
Author: Timo Paulssen timona...@perpetuum-immobile.de
Branch: 
Changeset: r48468:c0c84696f00b
Date: 2011-10-26 03:01 +0200
http://bitbucket.org/pypy/pypy/changeset/c0c84696f00b/

Log:Merge heads

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
@@ -959,8 +959,6 @@
 os_ftruncate(rffi.cast(rffi.INT, fd),
  rffi.cast(rffi.LONGLONG, length)))
 if res  0:
-# Note: for consistency we raise OSError, but CPython
-# raises IOError here
 raise OSError(rposix.get_errno(), os_ftruncate failed)
 
 return extdef([int, r_longlong], s_None,
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit