Author: Alex Gaynor <[email protected]> Branch: extradoc Changeset: r4143:6a25e43bf857 Date: 2012-03-09 15:10 -0800 http://bitbucket.org/pypy/extradoc/changeset/6a25e43bf857/
Log: merged upstream diff --git a/planning/jit.txt b/planning/jit.txt --- a/planning/jit.txt +++ b/planning/jit.txt @@ -74,6 +74,9 @@ - optimize arraycopy also in the cases where one of the arrays is a virtual and short. This is seen a lot in translate.py +- calling string equality does not automatically promote the argument to + a constant. + PYTHON EXAMPLES --------------- @@ -90,18 +93,6 @@ BACKEND TASKS ------------- -- Look into avoiding double load of constant into register on 64bit. - In case we want to first read a value, increment it and store (for example), - we end up with double load of constant into register. Like: - - movabs 0xsomemem,r11 - mov (r11), r10 - add 0x1, r10 - movabs 0xsomemem,r11 - mov r10, (r11) - - (second movabs could have been avoided) - - Look into this: http://paste.pocoo.org/show/450051/ commenting out the first line of f makes ~30% improvement. This is due to the fact of reordering locals and valuestack when jumping across incompatible diff --git a/talk/pycon2012/jit/slides.tex b/talk/pycon2012/jit/slides.tex --- a/talk/pycon2012/jit/slides.tex +++ b/talk/pycon2012/jit/slides.tex @@ -207,6 +207,7 @@ \begin{verbatim} # arguments to loop [p0, p1, p2, p3, i4, p5, i6, i7, p8, p9, p10, p11, p12, p13] +# while i < limit #25 LOAD_FAST guard_value(i6, 3) guard_nonnull(p10) @@ -228,12 +229,13 @@ \begin{frame}[fragile]{JIT IR example - computing modulo} \footnotesize{ \begin{verbatim} +# n % i #37 LOAD_FAST guard_nonnull(p8) #40 LOAD_FAST #43 BINARY_MODULO guard_class(p8, W_IntObject) -i22 = getfield_gc_pure(p8, <W_IntObject.inst_intval>) +i22 = ((W_IntObject)p8)->inst_intval) i23 = int_is_zero(i18) guard_false(i23) i25 = int_eq(i22, -9223372036854775808) @@ -245,7 +247,7 @@ i31 = int_and(i18, i30) i32 = int_add(i26, i31) p34 = new_with_vtable(W_IntObject) -setfield_gc(p34, i32, <W_IntObject.inst_intval>) +((W_IntObject)p34)->inst_intval = i32 \end{verbatim} } \end{frame} @@ -253,6 +255,7 @@ \begin{frame}[fragile]{JIT IR example - check modulo} \footnotesize{ \begin{verbatim} +# if <modulo> == 0: #44 LOAD_CONST guard_value(p3, ConstPtr(ptr35)) #47 COMPARE_OP') @@ -266,14 +269,15 @@ \begin{frame}[fragile]{JIT IR example - finish loop} \footnotesize{ \begin{verbatim} +# i += 1 #57 LOAD_FAST #60 LOAD_FAST #63 INPLACE_ADD -i38 = getfield_gc_pure(p10, <W_IntObject.inst_intval>) +i38 = ((W_IntObject)p10)->inst_intval i40 = int_add_ovf(i38, 1) guard_no_overflow() p42 = new_with_vtable(W_IntObject) -setfield_gc(p42, i40, <W_IntObject.inst_intval>) +((W_IntObject)p42)->inst_inval = i40 #64 STORE_FAST #67 JUMP_ABSOLUTE \end{verbatim} @@ -369,6 +373,16 @@ \includegraphics[scale=.45]{instancemap.png} \end{frame} +\begin{frame}{Conclusion} +\begin{itemize} +\item JIT generated from RPython description of interpreter +\item metainterpreter traces hot loops and functions +\item optimizations remove indirection +\item adapt to new runtime information with bridges +\item interpreter optimized for JIT with special hints and data structures +\end{itemize} +\end{frame} + \begin{frame}[fragile]{Thank you} Questions? @@ -376,8 +390,10 @@ \begin{itemize} \item \#pypy on Freenode \item http://morepypy.blogspot.com +\item PyPy sprint +\item http://morepypy.blogspot.com \item [email protected] -\item The Architecture of Open Source Applications, Volume 2 +\item The Architecture of Open Source Applications, Volume 2 (coming out soon) \end{itemize} diff --git a/talk/pycon2012/qualcomm/Makefile b/talk/pycon2012/qualcomm/Makefile new file mode 100644 --- /dev/null +++ b/talk/pycon2012/qualcomm/Makefile @@ -0,0 +1,13 @@ + + +talk.pdf: talk.rst author.latex title.latex stylesheet.latex + rst2beamer.py --input-encoding=utf-8 --output-encoding=utf-8 --stylesheet=stylesheet.latex --documentoptions=14pt --theme=Warsaw 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 & + +clean: + rm -f talk.pdf talk.latex diff --git a/talk/pycon2012/qualcomm/author.latex b/talk/pycon2012/qualcomm/author.latex new file mode 100644 --- /dev/null +++ b/talk/pycon2012/qualcomm/author.latex @@ -0,0 +1,7 @@ +\definecolor{rrblitbackground}{rgb}{0.0, 0.0, 0.0} + +\title[PyPy]{Writing VMs using PyPy} +\author[fijal]{Maciej Fijałkowski, Alex Gaynor, Armin Rigo} + +\institute{Qualcomm 2012} +\date{8 March 2012} diff --git a/talk/pycon2012/qualcomm/stylesheet.latex b/talk/pycon2012/qualcomm/stylesheet.latex new file mode 100644 --- /dev/null +++ b/talk/pycon2012/qualcomm/stylesheet.latex @@ -0,0 +1,10 @@ +\usetheme{Warsaw} +\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/pycon2012/qualcomm/talk.pdf b/talk/pycon2012/qualcomm/talk.pdf new file mode 100644 index 0000000000000000000000000000000000000000..bed6b09fdeffae519362f1da5f10c7e6675149f6 GIT binary patch [cut] diff --git a/talk/pycon2012/qualcomm/talk.rst b/talk/pycon2012/qualcomm/talk.rst new file mode 100644 --- /dev/null +++ b/talk/pycon2012/qualcomm/talk.rst @@ -0,0 +1,60 @@ + +.. include:: ../tutorial/beamerdefs.txt + +=============================== +Building interpreters with PyPy +=============================== + +What is PyPy? +============= + +* a fast Python interpreter with a JIT + +* **a framework to write dynamic language interpreters** + +* an open source project on the BSD license + +* an agile project with contributors from all over the world + +A bit about the architecture +============================ + +* describe your VM in a **high level language** + +* implement your object model, types etc. + +* you get a **GC** and **JIT** for free + +|pause| + +* with a few hints for the JIT + +PyPy's architecture +=================== + +* RPython program, imported and initialized + +* transformed to control flow graphs + +* compiled do C -OR- JVM -OR- graphs for JIT + +* this is a very high-level overview + +JIT architecture +================ + +* works on the level of the **interpreter** + +* by design complete + +* from a single source code of the **interpreter** + +Links +===== + +* morepypy.blogspot.com + +* doc.pypy.org + +* #pypy on freenode + diff --git a/talk/pycon2012/qualcomm/title.latex b/talk/pycon2012/qualcomm/title.latex new file mode 100644 --- /dev/null +++ b/talk/pycon2012/qualcomm/title.latex @@ -0,0 +1,5 @@ +\begin{titlepage} +\begin{figure}[h] +\scalebox{0.8}{\includegraphics[width=80px]{../../img/py-web-new.png}} +\end{figure} +\end{titlepage} diff --git a/talk/pycon2012/tutorial/examples/05_obj_vs_dict.py b/talk/pycon2012/tutorial/examples/05_obj_vs_dict.py --- a/talk/pycon2012/tutorial/examples/05_obj_vs_dict.py +++ b/talk/pycon2012/tutorial/examples/05_obj_vs_dict.py @@ -9,7 +9,7 @@ a = A(1, 2, 3) s = 0 for i in range(SIZE): - s += a.a + a.b + a.c + s += getattr(a, 'a') + a.b + a.c return s def obj_bad(): diff --git a/talk/pycon2012/tutorial/examples/08_re_jit.py b/talk/pycon2012/tutorial/examples/08_re_jit.py new file mode 100644 --- /dev/null +++ b/talk/pycon2012/tutorial/examples/08_re_jit.py @@ -0,0 +1,20 @@ +import re +import timeit + +welcome = "Welcome to PyCon 2011\n" * 10 + +inc_year_re = re.compile("(?P<year>\d+)") + + +def inc_year(m): + return str(int(m.group('year')) + 1) + + +simple_re = re.compile("(?P<year>\d+)") + + +print "simple_replace", timeit.timeit(lambda: simple_re.sub("2012", welcome), + number=10000) + +print "inc_replace", timeit.timeit(lambda: inc_year_re.sub(inc_year, welcome), + number=10000) diff --git a/talk/pycon2012/tutorial/slides.pdf b/talk/pycon2012/tutorial/slides.pdf new file mode 100644 index 0000000000000000000000000000000000000000..a9659cab234f73faae419a58814eb03b1fbedd8a GIT binary patch [cut] _______________________________________________ pypy-commit mailing list [email protected] http://mail.python.org/mailman/listinfo/pypy-commit
