[pypy-commit] pypy default: Translation fix
Author: Armin Rigo Branch: Changeset: r73743:987a3cad8bfd Date: 2014-09-29 10:26 +0200 http://bitbucket.org/pypy/pypy/changeset/987a3cad8bfd/ Log:Translation fix diff --git a/rpython/jit/backend/arm/assembler.py b/rpython/jit/backend/arm/assembler.py --- a/rpython/jit/backend/arm/assembler.py +++ b/rpython/jit/backend/arm/assembler.py @@ -931,6 +931,7 @@ guard, fcond) fcond = asm_operations_with_guard[opnum](self, op, guard, arglocs, regalloc, fcond) +assert fcond is not None regalloc.next_instruction() regalloc.possibly_free_vars_for_op(guard) regalloc.possibly_free_vars(guard.getfailargs()) @@ -941,6 +942,7 @@ if arglocs is not None: fcond = asm_operations[opnum](self, op, arglocs, regalloc, fcond) +assert fcond is not None if op.is_guard(): regalloc.possibly_free_vars(op.getfailargs()) if op.result: diff --git a/rpython/jit/backend/arm/opassembler.py b/rpython/jit/backend/arm/opassembler.py --- a/rpython/jit/backend/arm/opassembler.py +++ b/rpython/jit/backend/arm/opassembler.py @@ -1256,3 +1256,4 @@ [dstaddr_loc, imm(0), length_loc]) regalloc.rm.possibly_free_var(length_box) regalloc.rm.possibly_free_var(dstaddr_box) +return fcond ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: Optimize ZERO_ARRAY(const) followed by some number of SETARRAYITEM_GCs.
Author: Armin Rigo Branch: Changeset: r73744:1083964c3070 Date: 2014-09-29 11:16 +0200 http://bitbucket.org/pypy/pypy/changeset/1083964c3070/ Log:Optimize ZERO_ARRAY(const) followed by some number of SETARRAYITEM_GCs. diff --git a/rpython/jit/backend/arm/opassembler.py b/rpython/jit/backend/arm/opassembler.py --- a/rpython/jit/backend/arm/opassembler.py +++ b/rpython/jit/backend/arm/opassembler.py @@ -1180,6 +1180,9 @@ def emit_op_zero_array(self, op, arglocs, regalloc, fcond): from rpython.jit.backend.llsupport.descr import unpack_arraydescr assert len(arglocs) == 0 +length_box = op.getarg(2) +if isinstance(length_box, ConstInt) and length_box.getint() == 0: +return fcond # nothing to do itemsize, baseofs, _ = unpack_arraydescr(op.getdescr()) args = op.getarglist() base_loc = regalloc.rm.make_sure_var_in_reg(args[0], args) @@ -1191,7 +1194,6 @@ else: startindex_loc = regalloc.rm.make_sure_var_in_reg(sibox, args) startindex = -1 -length_box = op.getarg(2) # base_loc and startindex_loc are in two regs here (or they are # immediates). Compute the dstaddr_loc, which is the raw diff --git a/rpython/jit/backend/llsupport/rewrite.py b/rpython/jit/backend/llsupport/rewrite.py --- a/rpython/jit/backend/llsupport/rewrite.py +++ b/rpython/jit/backend/llsupport/rewrite.py @@ -48,7 +48,8 @@ self.known_lengths = {} self.write_barrier_applied = {} self.delayed_zero_setfields = {} -self.delayed_zero_setarrayitems = {} +self.last_zero_arrays = [] +self.setarrayitems_occurred = {} # {box: {set-of-indexes}} def rewrite(self, operations): # we can only remember one malloc since the next malloc can possibly @@ -81,6 +82,7 @@ self.handle_write_barrier_setinteriorfield(op) continue if op.getopnum() == rop.SETARRAYITEM_GC: +self.consider_setarrayitem_gc(op) self.handle_write_barrier_setarrayitem(op) continue else: @@ -89,6 +91,8 @@ # need to clal it if op.getopnum() == rop.SETFIELD_GC: self.consider_setfield_gc(op) +elif op.getopnum() == rop.SETARRAYITEM_GC: +self.consider_setarrayitem_gc(op) # -- call assembler --- if op.getopnum() == rop.CALL_ASSEMBLER: self.handle_call_assembler(op) @@ -146,6 +150,16 @@ except KeyError: pass +def consider_setarrayitem_gc(self, op): +array_box = op.getarg(0) +index_box = op.getarg(1) +if isinstance(array_box, BoxPtr) and isinstance(index_box, ConstInt): +try: +intset = self.setarrayitems_occurred[array_box] +except KeyError: +intset = self.setarrayitems_occurred[array_box] = {} +intset[index_box.getint()] = None + def clear_varsize_gc_fields(self, kind, descr, result, v_length, opnum): if self.gc_ll_descr.malloc_zero_filled: return @@ -216,18 +230,18 @@ self.clear_varsize_gc_fields(kind, op.getdescr(), op.result, v_length, op.getopnum()) -def handle_clear_array_contents(self, arraydescr, v_arr, v_length=None): -# XXX more work here to reduce or remove the ZERO_ARRAY in some cases -if v_length is None: -v_length = BoxInt() -o = ResOperation(rop.ARRAYLEN_GC, [v_arr], v_length, - descr=arraydescr) -self.newops.append(o) -elif isinstance(v_length, ConstInt) and v_length.getint() == 0: +def handle_clear_array_contents(self, arraydescr, v_arr, v_length): +assert v_length is not None +if isinstance(v_length, ConstInt) and v_length.getint() == 0: return +# the ZERO_ARRAY operation will be optimized according to what +# SETARRAYITEM_GC we see before the next allocation operation. +# See emit_pending_zeros(). o = ResOperation(rop.ZERO_ARRAY, [v_arr, self.c_zero, v_length], None, descr=arraydescr) self.newops.append(o) +if isinstance(v_length, ConstInt): +self.last_zero_arrays.append(o) def gen_malloc_frame(self, frame_info, frame, size_box): descrs = self.gc_ll_descr.getframedescrs(self.cpu) @@ -317,6 +331,31 @@ self.emit_pending_zeros() def emit_pending_zeros(self): +# First, try to rewrite the existing ZERO_ARRAY operations from +# the 'last_zero_arrays' list. Note that these operation objects +# are also already in 'newops', which is the point. +for op in self.last_zero_arrays: +assert op.getopnum() == rop.ZERO_ARRAY
[pypy-commit] stmgc c8-new-page-handling: actually *do* apply undo copies if we abort
Author: Remi Meier Branch: c8-new-page-handling Changeset: r1436:14164f0fc6a8 Date: 2014-09-29 16:09 +0200 http://bitbucket.org/pypy/stmgc/changeset/14164f0fc6a8/ Log:actually *do* apply undo copies if we abort diff --git a/c8/stm/core.c b/c8/stm/core.c --- a/c8/stm/core.c +++ b/c8/stm/core.c @@ -156,6 +156,8 @@ release_modified_objs_lock(copy_from_segnum); release_all_privatization_locks(); +dprintf(("handle_segfault_in_page: rev %lu to rev %lu\n", + src_version->rev_num, target_version->rev_num)); /* adapt revision of page to our revision: if our rev is higher than the page we copy from, everything is fine as we never read/modified the page anyway @@ -217,9 +219,9 @@ for (; undo < end; undo++) { fprintf(stderr, "obj %p, size %d, ofs %lu: ", undo->object, SLICE_SIZE(undo->slice), SLICE_OFFSET(undo->slice)); -long i; -for (i=0; islice); i += 8) -fprintf(stderr, " 0x%016lx", *(long *)(undo->backup + i)); +/* long i; */ +/* for (i=0; islice); i += 8) */ +/* fprintf(stderr, " 0x%016lx", *(long *)(undo->backup + i)); */ fprintf(stderr, "\n"); } } @@ -258,9 +260,8 @@ /* there is an inevitable transaction running */ release_modified_objs_lock(my_segnum); #if STM_TESTS -if (free_if_abort != (void *)-1) -free(free_if_abort); -stm_abort_transaction(); +needs_abort = true; +goto complete_work_and_possibly_abort; #endif abort(); /* XXX non-busy wait here or: XXX do we always need to wait? we should just @@ -310,6 +311,9 @@ release_modified_objs_lock(my_segnum); +#if STM_TESTS + complete_work_and_possibly_abort:; +#endif /* CORRECT LOCKING NEEDED XX */ int segnum; for (segnum = 0; segment_copied_from != 0; segnum++) { @@ -317,8 +321,10 @@ segment_copied_from &= ~(1UL << segnum); /* here we can actually have our own modified version, so make sure to only copy things that are not modified in our - segment... */ -copy_bk_objs_in_page_from(segnum, -1, true); + segment... (if we do not abort) */ +copy_bk_objs_in_page_from( +segnum, -1, /* any page */ +!needs_abort); /* if we abort, we still want to copy everything */ } } diff --git a/c8/test/test_basic.py b/c8/test/test_basic.py --- a/c8/test/test_basic.py +++ b/c8/test/test_basic.py @@ -783,3 +783,30 @@ # self.switch(0) # validate -> R2 assert stm_get_char(lp_char_5, 384 - 1) == 'i' + +def test_bug2(self): +lp_char_5 = stm_allocate_old(384) + +self.start_transaction() # R1 +stm_set_char(lp_char_5, 'i', 384 - 1, False) +stm_set_char(lp_char_5, 'i', HDR, False) +# +self.switch(1) +self.start_transaction() +# +# +self.switch(3) +self.start_transaction() # R1 +stm_set_char(lp_char_5, 'o', 384 - 1, False) # bk_copy +stm_set_char(lp_char_5, 'o', HDR, False) +self.commit_transaction() # R2 + +self.start_transaction() # R2 +stm_set_char(lp_char_5, 'r', 384 - 1, False) # bk_copy +stm_set_char(lp_char_5, 'r', HDR, False) +# +py.test.raises(Conflict, self.switch, 0) # abort modified objs +# +self.switch(1) # validate -> R2 + +assert stm_get_char(lp_char_5, 384 - 1) == 'o' diff --git a/c8/test/test_random.py b/c8/test/test_random.py --- a/c8/test/test_random.py +++ b/c8/test/test_random.py @@ -298,6 +298,7 @@ confl_set = other_trs.read_set & trs.write_set if confl_set: +assert not other_trs.inevitable # trs wins! other_trs.set_must_abort(objs_in_conflict=confl_set) assert not trs.check_must_abort() @@ -506,14 +507,16 @@ ex.do('#') # trs = new_thread_state.transaction_state -if trs is not None and not trs.inevitable: -if global_state.is_inevitable_transaction_running(): -trs.set_must_abort() -conflicts = trs is not None and trs.check_must_abort() +if trs and not trs.check_must_abort(): +global_state.check_if_can_become_inevitable(trs) +conflicts = trs and trs.check_must_abort() ex.thread_num = new_thread_state.num # +if conflicts: +ex.do("# objs_in_conflict=%s" % trs.objs_in_conflict) ex.do(raising_call(conflicts, "self.switch", new_thread_state.num)) + if conflicts: new_thread_state.abort_transaction() elif trs: __
[pypy-commit] stmgc c8-new-page-handling: we must not execute the STM part of the WB twice and make backup copies more than once
Author: Remi Meier Branch: c8-new-page-handling Changeset: r1437:4e523f10a999 Date: 2014-09-29 16:42 +0200 http://bitbucket.org/pypy/stmgc/changeset/4e523f10a999/ Log:we must not execute the STM part of the WB twice and make backup copies more than once diff --git a/c8/stm/core.c b/c8/stm/core.c --- a/c8/stm/core.c +++ b/c8/stm/core.c @@ -429,7 +429,22 @@ /* add to read set: */ stm_read(obj); -/* create backup copy (this may cause several page faults XXX): */ +/* XXX: add overflow number again? n^2 algorithm ahead... */ +struct list_s *list = STM_PSEGMENT->modified_old_objects; +int i, c = list_count(list); +for (i = 0; i < c; i += 3) { +if (list->items[i] == (uintptr_t)obj) { +/* already executed WB once in this transaction. do GC + part again: */ +obj->stm_flags &= ~GCFLAG_WRITE_BARRIER; +LIST_APPEND(STM_PSEGMENT->objects_pointing_to_nursery, obj); +return; +} +} + +/* create backup copy (this may cause several page faults + XXX: do backup later and maybe allow for having NO_ACCESS + pages around anyway (kind of card marking)): */ struct object_s *bk_obj = malloc(obj_size); memcpy(bk_obj, realobj, obj_size); @@ -468,7 +483,6 @@ update the shared page in stm_validate() except if it is the sole reader of it. But then we don't actually know which revision the page is at. */ /* XXX this is a temporary solution I suppose */ -int i; for (i = 0; i < NB_SEGMENTS; i++) { if (i == my_segnum) continue; @@ -708,12 +722,14 @@ undo->backup + SLICE_OFFSET(undo->slice), SLICE_SIZE(undo->slice)); -size_t obj_size = stmcb_size_rounded_up(undo->backup); +size_t obj_size = stmcb_size_rounded_up((struct object_s*)undo->backup); +dprintf(("reset_modified_from_backup_copies(%d): obj=%p off=%lu bk=%p obj_sz=%lu\n", + segment_num, obj, SLICE_OFFSET(undo->slice), undo->backup, obj_size)); + if (obj_size - SLICE_OFFSET(undo->slice) <= 4096UL) { /* only free bk copy once (last slice): */ free(undo->backup); -dprintf(("reset_modified_from_backup_copies(%d): obj=%p obj_sz=%lu\n", - segment_num, obj, obj_size)); +dprintf(("-> free(%p)\n", undo->backup)); } } diff --git a/c8/test/test_basic.py b/c8/test/test_basic.py --- a/c8/test/test_basic.py +++ b/c8/test/test_basic.py @@ -810,3 +810,20 @@ self.switch(1) # validate -> R2 assert stm_get_char(lp_char_5, 384 - 1) == 'o' + +def test_repeated_wb(self): +lp_char_5 = stm_allocate_old(384) + +self.start_transaction() +stm_set_char(lp_char_5, 'i', 384 - 1, False) +stm_set_char(lp_char_5, 'i', HDR, False) + +stm_minor_collect() + +stm_set_char(lp_char_5, 'j', 384 - 1, False) +stm_set_char(lp_char_5, 'j', HDR, False) + +self.abort_transaction() + +self.check_char_everywhere(lp_char_5, '\0', offset=HDR) +self.check_char_everywhere(lp_char_5, '\0', offset=384-1) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] extradoc extradoc: Add the beginning of my PyCon IE talk
Author: Romain Guillebert Branch: extradoc Changeset: r5414:8e809924b51f Date: 2014-09-24 17:11 +0200 http://bitbucket.org/pypy/extradoc/changeset/8e809924b51f/ Log:Add the beginning of my PyCon IE talk diff --git a/talk/pyconie2014/Makefile b/talk/pyconie2014/Makefile new file mode 100644 --- /dev/null +++ b/talk/pyconie2014/Makefile @@ -0,0 +1,18 @@ +# you can find rst2beamer.py here: +# https://bitbucket.org/antocuni/env/raw/default/bin/rst2beamer.py + +# WARNING: to work, it needs this patch for docutils +# https://sourceforge.net/tracker/?func=detail&atid=422032&aid=1459707&group_id=38414 + +talk.pdf: talk.rst author.latex stylesheet.latex + python `which rst2beamer.py` --stylesheet=stylesheet.latex --documentoptions=14pt talk.rst talk.latex || exit + #/home/antocuni/.virtualenvs/rst2beamer/bin/python `which rst2beamer.py` --stylesheet=stylesheet.latex --documentoptions=14pt talk.rst talk.latex || exit + sed 's/\\date{}/\\input{author.latex}/' -i talk.latex || exit + #sed 's/\\maketitle/\\input{title.latex}/' -i talk.latex || exit + pdflatex talk.latex || exit + +view: talk.pdf + evince talk.pdf & + +xpdf: talk.pdf + xpdf talk.pdf & diff --git a/talk/pyconie2014/author.latex b/talk/pyconie2014/author.latex new file mode 100644 --- /dev/null +++ b/talk/pyconie2014/author.latex @@ -0,0 +1,9 @@ +\definecolor{rrblitbackground}{rgb}{0.0, 0.0, 0.0} + +\title[PyPy : A fast Python Virtual Machine]{PyPy : A fast Python Virtual Machine} +\author[rguillebert] +{Romain Guillebert\\ +\includegraphics[width=80px]{../img/py-web-new.png}} + +\institute{Pycon IE} +\date{October 12th, 2014} diff --git a/talk/pyconie2014/beamerdefs.txt b/talk/pyconie2014/beamerdefs.txt new file mode 100644 --- /dev/null +++ b/talk/pyconie2014/beamerdefs.txt @@ -0,0 +1,108 @@ +.. colors +.. === + +.. role:: green +.. role:: red + + +.. general useful commands +.. === + +.. |pause| raw:: latex + + \pause + +.. |small| raw:: latex + + {\small + +.. |end_small| raw:: latex + + } + +.. |scriptsize| raw:: latex + + {\scriptsize + +.. |end_scriptsize| raw:: latex + + } + +.. |strike<| raw:: latex + + \sout{ + +.. closed bracket +.. === + +.. |>| raw:: latex + + } + + +.. example block +.. === + +.. |example<| raw:: latex + + \begin{exampleblock}{ + + +.. |end_example| raw:: latex + + \end{exampleblock} + + + +.. alert block +.. === + +.. |alert<| raw:: latex + + \begin{alertblock}{ + + +.. |end_alert| raw:: latex + + \end{alertblock} + + + +.. columns +.. === + +.. |column1| raw:: latex + + \begin{columns} + \begin{column}{0.45\textwidth} + +.. |column2| raw:: latex + + \end{column} + \begin{column}{0.45\textwidth} + + +.. |end_columns| raw:: latex + + \end{column} + \end{columns} + + + +.. |snake| image:: ../../img/py-web-new.png + :scale: 15% + + + +.. nested blocks +.. === + +.. |nested| raw:: latex + + \begin{columns} + \begin{column}{0.85\textwidth} + +.. |end_nested| raw:: latex + + \end{column} + \end{columns} diff --git a/talk/pyconie2014/speed.png b/talk/pyconie2014/speed.png new file mode 100644 index ..4640c76f8a665af1c414dc4c4ca22be3bd8ff360 GIT binary patch [cut] diff --git a/talk/pyconie2014/stylesheet.latex b/talk/pyconie2014/stylesheet.latex new file mode 100644 --- /dev/null +++ b/talk/pyconie2014/stylesheet.latex @@ -0,0 +1,9 @@ +\setbeamercovered{transparent} +\setbeamertemplate{navigation symbols}{} + +\definecolor{darkgreen}{rgb}{0, 0.5, 0.0} +\newcommand{\docutilsrolegreen}[1]{\color{darkgreen}#1\normalcolor} +\newcommand{\docutilsrolered}[1]{\color{red}#1\normalcolor} + +\newcommand{\green}[1]{\color{darkgreen}#1\normalcolor} +\newcommand{\red}[1]{\color{red}#1\normalcolor} diff --git a/talk/pyconie2014/talk.rst b/talk/pyconie2014/talk.rst new file mode 100644 --- /dev/null +++ b/talk/pyconie2014/talk.rst @@ -0,0 +1,34 @@ +PyPy : A fast Python Virtual Machine + + +Me +-- + +- rguillebert on twitter and irc + +- PyPy contributor since 2011 + +- NumPyPy contributor + +- Software consultant (hire me !) + +- Feel free to interrupt + +Introduction + + +- "PyPy is a fast, compliant alternative implementation of the Python language" + +- Aims to reach the best performance possible without changing the syntax or semantics + +- Supports x86, x86_64, ARM + +- Production ready + +- MIT Licensed + +Speed +- + +.. image:: speed.png + :scale: 37% ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] extradoc extradoc: Add myself
Author: Romain Guillebert Branch: extradoc Changeset: r5416:2cf1024f1867 Date: 2014-09-29 22:21 +0200 http://bitbucket.org/pypy/extradoc/changeset/2cf1024f1867/ Log:Add myself diff --git a/sprintinfo/warsaw-2014/people.txt b/sprintinfo/warsaw-2014/people.txt --- a/sprintinfo/warsaw-2014/people.txt +++ b/sprintinfo/warsaw-2014/people.txt @@ -10,4 +10,5 @@ Name Arrive/Depart Accomodation == === Armin Rigo 20/10-2X/10with fijal? +Romain Guillebert19/10-26-10??? == === ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] extradoc extradoc: Add more slides
Author: Romain Guillebert Branch: extradoc Changeset: r5415:1d748d9bdbc8 Date: 2014-09-29 22:20 +0200 http://bitbucket.org/pypy/extradoc/changeset/1d748d9bdbc8/ Log:Add more slides diff --git a/talk/pyconie2014/talk.rst b/talk/pyconie2014/talk.rst --- a/talk/pyconie2014/talk.rst +++ b/talk/pyconie2014/talk.rst @@ -1,3 +1,5 @@ +.. include:: beamerdefs.tx + PyPy : A fast Python Virtual Machine @@ -32,3 +34,43 @@ .. image:: speed.png :scale: 37% + +Speed +- + +- Automatically generated tracing just-in-time compiler + +- Generates efficient machine code based on runtime observations + +- Removes overhead when unnecessary + +- But these Python features remain available (pdb) + +RPython +--- + +- Subset of Python + +- Made for writting virtual machines + +- Takes care of garbage collection and JIT compilation + +- A VM written in RPython doesn't have to know about the garbage collector + +- Minimal help from the VM is needed in order to have an efficient JIT (a few annotations) + +Demo + + +- Real-time edge detection + +How +--- + +- Removes boxing, integer objects become machine integers + +- Specializes trace on types, helps speed-up method lookup + +- If the type of the object is different from the type in the trace, go back to the interpreter : "guard failure" + +- If a guard fails too many times, optimize the trace for the other types frequently encountered ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] extradoc extradoc: Add myself to the people coming to the Warsaw sprint.
Author: Manuel Jacob Branch: extradoc Changeset: r5417:8e3e7fcb1471 Date: 2014-09-29 23:45 +0200 http://bitbucket.org/pypy/extradoc/changeset/8e3e7fcb1471/ Log:Add myself to the people coming to the Warsaw sprint. diff --git a/sprintinfo/warsaw-2014/people.txt b/sprintinfo/warsaw-2014/people.txt --- a/sprintinfo/warsaw-2014/people.txt +++ b/sprintinfo/warsaw-2014/people.txt @@ -11,4 +11,5 @@ == === Armin Rigo 20/10-2X/10with fijal? Romain Guillebert19/10-26-10??? +Manuel Jacob 20/10-26/10? (shared hotel room?) == === ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit