Author: Armin Rigo <ar...@tunes.org>
Branch: 
Changeset: r84841:072b9ce9b3dd
Date: 2016-05-31 09:40 +0200
http://bitbucket.org/pypy/pypy/changeset/072b9ce9b3dd/

Log:    merge heads

diff --git a/.hgtags b/.hgtags
--- a/.hgtags
+++ b/.hgtags
@@ -23,3 +23,5 @@
 3260adbeba4a8b6659d1cc0d0b41f266769b74da release-5.1
 b0a649e90b6642251fb4a765fe5b27a97b1319a9 release-5.1.1
 80ef432a32d9baa4b3c5a54c215e8ebe499f6374 release-5.1.2
+40497617ae91caa1a394d8be6f9cd2de31cb0628 release-pypy3.3-v5.2
+40497617ae91caa1a394d8be6f9cd2de31cb0628 release-pypy3.3-v5.2
diff --git a/pypy/doc/release-pypy3.3-v5.2-alpha1.rst 
b/pypy/doc/release-pypy3.3-v5.2-alpha1.rst
--- a/pypy/doc/release-pypy3.3-v5.2-alpha1.rst
+++ b/pypy/doc/release-pypy3.3-v5.2-alpha1.rst
@@ -2,7 +2,7 @@
 PyPy3 v5.2 alpha 1
 ===================
 
-We're pleased to announce the first alpha release of PyPy3.3 5.2. This is the
+We're pleased to announce the first alpha release of PyPy3.3 v5.2. This is the
 first release of PyPy which targets Python 3.3 (3.3.5) compatibility.
 
 We would like to thank all of the people who donated_ to the `py3k proposal`_
@@ -10,7 +10,7 @@
 
 You can download the PyPy3.3 v5.2 alpha 1 release here:
 
-    http://pypy.org/download.html#pypy3.3-v5.2-alpha-1 XXX
+    http://pypy.org/download.html#python-3-3-5-compatible-pypy3-3-v5-2
 
 Highlights
 ==========
@@ -32,8 +32,8 @@
 CPython 2.7.10 and one day 3.3.5. It's fast due to its integrated tracing JIT
 compiler.
 
-We also welcome developers of other
-`dynamic languages`_ to see what RPython can do for them.
+We also welcome developers of other `dynamic languages`_ to see what RPython
+can do for them.
 
 This release supports:
 
@@ -46,8 +46,8 @@
 
   * **s390x** running Linux
 
-Please try it out and let us know what you think. We welcome feedback,
-we know you are using PyPy, please tell us about it!
+Please try it out and let us know what you think. We welcome feedback, we know
+you are using PyPy, please tell us about it!
 
 We'd especially like to thank these people for their contributions to this
 release:
diff --git a/pypy/doc/whatsnew-head.rst b/pypy/doc/whatsnew-head.rst
--- a/pypy/doc/whatsnew-head.rst
+++ b/pypy/doc/whatsnew-head.rst
@@ -122,3 +122,7 @@
 
 Move _numpypy headers into a directory so they are not picked up by upstream 
numpy, scipy
 This allows building upstream numpy and scipy in pypy via cpyext
+
+.. branch: traceviewer-common-merge-point-formats
+
+Teach RPython JIT's off-line traceviewer the most common ``debug_merge_point`` 
formats.
\ No newline at end of file
diff --git a/rpython/jit/tool/test/test_traceviewer.py 
b/rpython/jit/tool/test/test_traceviewer.py
--- a/rpython/jit/tool/test/test_traceviewer.py
+++ b/rpython/jit/tool/test/test_traceviewer.py
@@ -1,7 +1,8 @@
 import math
 import py
 from rpython.jit.tool.traceviewer import splitloops, FinalBlock, Block,\
-     split_one_loop, postprocess, main, get_gradient_color, guard_number
+     split_one_loop, postprocess, main, get_gradient_color, guard_number,\
+     find_name_key
 
 
 def test_gradient_color():
@@ -103,3 +104,46 @@
         fname = py.path.local(__file__).join('..', 'f.pypylog.bz2')
         main(str(fname), False, view=False)
         # assert did not explode
+
+class TestMergPointStringExtraciton(object):
+
+    def test_find_name_key(self):
+        def find(s):
+            return find_name_key(FinalBlock(s, None))
+        assert find(r"debug_merge_point(0, 0, '<code object f5. file 'f.py'. 
line 34> #63 GET_ITER')") \
+            == (r"f5. file 'f.py'. line 34 #63 GET_ITER", r"<code object f5. 
file 'f.py'. line 34> #63 GET_ITER")
+        assert find(r"debug_merge_point(0, 0, '<code object f5. file 'f.py'. 
line 34> <generator>')") \
+            == (r"f5. file 'f.py'. line 34 <generator>", r"<code object f5. 
file 'f.py'. line 34> <generator>")
+        assert find(r"debug_merge_point(0, 0, 'cffi_callback <code object f5. 
file 'f.py'. line 34>')") \
+            == (r"f5. file 'f.py'. line 34 (cffi_callback)", r"cffi_callback 
<code object f5. file 'f.py'. line 34>")
+        assert find(r"debug_merge_point(0, 0, 'cffi_callback <?>')") \
+            == (r"? (cffi_callback)", r"cffi_callback <?>")
+        assert find(r"debug_merge_point(0, 0, 'cffi_call_python somestr')") \
+            == (r"somestr (cffi_call_python)", r"cffi_call_python somestr")
+        assert find(r"debug_merge_point(0, 0, '(SequenceableCollection >> 
#replaceFrom:to:with:startingAt:) [8]: 
<0x14>pushTemporaryVariableBytecode(4)')") \
+            == (r"SequenceableCollection>>#replaceFrom:to:with:startingAt: @ 8 
<pushTemporaryVariableBytecode>", r"(SequenceableCollection >> 
#replaceFrom:to:with:startingAt:) [8]: <0x14>pushTemporaryVariableBytecode(4)")
+        assert find(r"debug_merge_point(1, 4, '(Magnitude >> #min:max:) [0]: 
<0x70>pushReceiverBytecode')") \
+            == (r"Magnitude>>#min:max: @ 0 <pushReceiverBytecode>", 
r"(Magnitude >> #min:max:) [0]: <0x70>pushReceiverBytecode")
+        assert find(r"debug_merge_point(0, 0, '(#DoIt) [0]: 
<0x70>pushReceiverBytecode')") \
+            == (r"#DoIt @ 0 <pushReceiverBytecode>", r"(#DoIt) [0]: 
<0x70>pushReceiverBytecode")
+
+        assert find(r"debug_merge_point(0, 0, '54: LOAD LIST 4')") \
+            == (r"? @ 54 <LOAD LIST 4>", r"54: LOAD LIST 4")
+        assert find(r"debug_merge_point(0, 0, '44: LOAD_MEMBER_DOT function: 
barfoo')") \
+            == (r"barfoo @ 44 <LOAD_MEMBER_DOT>", r"44: LOAD_MEMBER_DOT 
function: barfoo")
+        assert find(r"debug_merge_point(0, 0, '87: end of opcodes')") \
+            == (r"? @ 87 <end of opcodes>", r"87: end of opcodes")
+        assert find(r"debug_merge_point(0, 0, 'Green_Ast is None')") \
+            == (r"Green_Ast is None", r"Green_Ast is None")
+        assert find(r"debug_merge_point(0, 0, 
'Label(safe_return_multi_vals:pycket.interpreter:565)')") \
+            == (r"Label(safe_return_multi_vals:pycket.interpreter:565)", 
r"Label(safe_return_multi_vals:pycket.interpreter:565)")
+        assert find(r"debug_merge_point(0, 0, '(*node2 item AppRand1_289 
AppRand2_116)')") \
+            == (r"(*node2 item AppRand1_289 AppRand2_116)", r"(*node2 item 
AppRand1_289 AppRand2_116)")
+        assert find(r"debug_merge_point(0, 0, '(let ([if_2417 (let 
([AppRand0_2026 (* Zr Zr)][AppRand1_1531 (* Zi Zi)]) (let ([AppRand0_2027 (+ 
AppRand0_2026 AppRand1_1531)]) (> AppRand0_2027 LIMIT-SQR)))]) (if if_2417 0 
(let ([if_2416 (= i ITERATIONS)]) (if if_2416 1 (let ([Zr199 (let 
([AppRand0_2041 (* Zr Zr)][AppRand1_1540 (* Zi Zi)]) (let ([AppRand0_2042 (- 
AppRand0_2041 AppRand1_1540)]) (+ AppRand0_2042 Cr)))][Zi206 (let 
([AppRand1_1541 (* Zr Zi)]) (let ([AppRand0_2043 (* 2.0 AppRand1_1541)]) (+ 
AppRand0_2043 Ci)))]) (let ([Zr211 (let ([AppRand0_2038 (* Zr199 
Zr199)][AppRand1_1538 (* Zi206 Zi206)]) (let ([AppRand0_2039 (- AppRand0_2038 
AppRand1_1538)]) (+ AppRand0_2039 Cr)))][Zi218 (let ([AppRand1_1539 (* Zr199 
Zi206)]) (let ([AppRand0_2040 (* 2.0 AppRand1_1539)]) (+ AppRand0_2040 Ci)))]) 
(let ([Zr223 (let ([AppRand0_2035 (* Zr211 Zr211)][AppRand1_1536 (* Zi218 
Zi218)]) (let ([AppRand0_2036 (- AppRand0_2035 AppRand1_1536)]) (+ 
AppRand0_2036 Cr)))][Zi230 (let ([AppRand1_1537 (* 
 Zr211 Zi218)]) (let ([AppRand0_2037 (* 2.0 AppRand1_1537)]) (+ AppRand0_2037 
Ci)))]) (let ([Zr235 (let ([AppRand0_2032 (* Zr223 Zr223)][AppRand1_1534 (* 
Zi230 Zi230)]) (let ([AppRand0_2033 (- AppRand0_2032 AppRand1_1534)]) (+ 
AppRand0_2033 Cr)))][Zi242 (let ([AppRand1_1535 (* Zr223 Zi230)]) (let 
([AppRand0_2034 (* 2.0 AppRand1_1535)]) (+ AppRand0_2034 Ci)))]) (let ([Zr247 
(let ([AppRand0_2029 (* Zr235 Zr235)][AppRand1_1532 (* Zi242 Zi242)]) (let 
([AppRand0_2030 (- AppRand0_2029 AppRand1_1532)]) (+ AppRand0_2030 Cr)))][Zi254 
(let ([AppRand1_1533 (* Zr235 Zi242)]) (let ([AppRand0_2031 (* 2.0 
AppRand1_1533)]) (+ AppRand0_2031 Ci)))]) (let ([AppRand0_2028 (+ i 5)]) (loop 
AppRand0_2028 Zr247 Zi254))))))))))) from (loop AppRand0_2028 Zr247 Zi254)')") \
+            == (r"(let ([if_2417 (let ([AppRand0_2026 (* Zr Zr)][AppRand1_1531 
(* ...", r"(let ([if_2417 (let ([AppRand0_2026 (* Zr Zr)][AppRand1_1531 (* Zi 
Zi)]) (let ([AppRand0_2027 (+ AppRand0_2026 AppRand1_1531)]) (> AppRand0_2027 
LIMIT-SQR)))]) (if if_2417 0 (let ([if_2416 (= i ITERATIONS)]) (if if_2416 1 
(let ([Zr199 (let ([AppRand0_2041 (* Zr Zr)][AppRand1_1540 (* Zi Zi)]) (let 
([AppRand0_2042 (- AppRand0_2041 AppRand1_1540)]) (+ AppRand0_2042 Cr)))][Zi206 
(let ([AppRand1_1541 (* Zr Zi)]) (let ([AppRand0_2043 (* 2.0 AppRand1_1541)]) 
(+ AppRand0_2043 Ci)))]) (let ([Zr211 (let ([AppRand0_2038 (* Zr199 
Zr199)][AppRand1_1538 (* Zi206 Zi206)]) (let ([AppRand0_2039 (- AppRand0_2038 
AppRand1_1538)]) (+ AppRand0_2039 Cr)))][Zi218 (let ([AppRand1_1539 (* Zr199 
Zi206)]) (let ([AppRand0_2040 (* 2.0 AppRand1_1539)]) (+ AppRand0_2040 Ci)))]) 
(let ([Zr223 (let ([AppRand0_2035 (* Zr211 Zr211)][AppRand1_1536 (* Zi218 
Zi218)]) (let ([AppRand0_2036 (- AppRand0_2035 AppRand1_1536)]) (+ AppRand0
 _2036 Cr)))][Zi230 (let ([AppRand1_1537 (* Zr211 Zi218)]) (let ([AppRand0_2037 
(* 2.0 AppRand1_1537)]) (+ AppRand0_2037 Ci)))]) (let ([Zr235 (let 
([AppRand0_2032 (* Zr223 Zr223)][AppRand1_1534 (* Zi230 Zi230)]) (let 
([AppRand0_2033 (- AppRand0_2032 AppRand1_1534)]) (+ AppRand0_2033 Cr)))][Zi242 
(let ([AppRand1_1535 (* Zr223 Zi230)]) (let ([AppRand0_2034 (* 2.0 
AppRand1_1535)]) (+ AppRand0_2034 Ci)))]) (let ([Zr247 (let ([AppRand0_2029 (* 
Zr235 Zr235)][AppRand1_1532 (* Zi242 Zi242)]) (let ([AppRand0_2030 (- 
AppRand0_2029 AppRand1_1532)]) (+ AppRand0_2030 Cr)))][Zi254 (let 
([AppRand1_1533 (* Zr235 Zi242)]) (let ([AppRand0_2031 (* 2.0 AppRand1_1533)]) 
(+ AppRand0_2031 Ci)))]) (let ([AppRand0_2028 (+ i 5)]) (loop AppRand0_2028 
Zr247 Zi254))))))))))) from (loop AppRand0_2028 Zr247 Zi254)")
+        assert find(r"debug_merge_point(0, 0, 'times at LOAD_SELF')") \
+            == (r"times at LOAD_SELF", r"times at LOAD_SELF")
+        assert find(r"debug_merge_point(1, 1, 'block in <main> at 
LOAD_DEREF')") \
+            == (r"block in <main> at LOAD_DEREF", r"block in <main> at 
LOAD_DEREF")
+        assert find(r"debug_merge_point(0, 0, '<main> at SEND')") \
+            == (r"<main> at SEND", r"<main> at SEND")
diff --git a/rpython/jit/tool/traceviewer.py b/rpython/jit/tool/traceviewer.py
--- a/rpython/jit/tool/traceviewer.py
+++ b/rpython/jit/tool/traceviewer.py
@@ -219,19 +219,78 @@
         counter += loop.count("\n") + 2
     return real_loops, allloops
 
+
+def find_name_key(l):
+    m = re.search("debug_merge_point\((?:\d+,\ )*'(.*)'(?:, \d+)*\)", 
l.content)
+    if m is None:
+        # default fallback
+        return '?', '?'
+    info = m.group(1)
+
+    # PyPy (pypy/module/pypyjit/interp_jit.py, pypy/interpreter/generator.py)
+    # '<code object f5. file 'f.py'. line 34> #63 GET_ITER'
+    # '<code object f5. file 'f.py'. line 34> <generator>'
+    m = re.search("^(<code object (.*?)> (.*?))$", info)
+    if m:
+        return m.group(2) + " " + m.group(3), m.group(1)
+
+    # PyPy cffi (pypy/module/_cffi_backend/ccallback.py)
+    # 'cffi_callback <code object f5. file 'f.py'. line 34>', 'cffi_callback 
<?>'
+    # 'cffi_call_python somestr'
+    m = re.search("^((cffi_callback) <code object (.*?)>)$", info)
+    if m:
+        return "%s (%s)" %(m.group(3), m.group(2)), m.group(1)
+    m = re.search("^((cffi_callback) <\?>)$", info)
+    if m:
+        return "? (%s)" %(m.group(2)), m.group(1)
+    m = re.search("^((cffi_call_python) (.*))$", info)
+    if m:
+        return "%s (%s)" %(m.group(3), m.group(2)), m.group(1)
+
+    # RSqueak/lang-smalltalk (spyvm/interpreter.py)
+    # '(SequenceableCollection >> #replaceFrom:to:with:startingAt:) [8]: 
<0x14>pushTemporaryVariableBytecode(4)'
+    m = re.search("^(\(((.+?) >> )?(#.*)\) \[(\d+)\].+?>(.*?)(?:\(\d+\))?)$", 
info)
+    if m:
+        if m.group(3):
+            return "%s>>%s @ %s <%s>" % (m.group(3), m.group(4), m.group(5), 
m.group(6)), m.group(1)
+        else:
+            return "%s @ %s <%s>" % (m.group(4), m.group(5), m.group(6)), 
m.group(1)
+
+    # lang-js (js/jscode.py)
+    # '54: LOAD LIST 4'
+    # '44: LOAD_MEMBER_DOT function: barfoo'
+    # '87: end of opcodes'
+    m = re.search("^((\d+): (.+?)(:? function: (.+?))?)$", info)
+    if m:
+        if m.group(5):
+            return "%s @ %s <%s>" % (m.group(5), m.group(2), m.group(3)), 
m.group(1)
+        else:
+            return "? @ %s <%s>" % (m.group(2), m.group(3)), m.group(1)
+
+    # pycket (pycket/interpreter.py) [sorted down because the s-exp is very 
generic]
+    # 'Green_Ast is None'
+    # 'Label(safe_return_multi_vals:pycket.interpreter:565)'
+    # '(*node2 item AppRand1_289 AppRand2_116)'
+    if info[0] == '(' and info[-1] == ')':
+        if len(info) > 64: #s-exp can be quite long
+            return info[:64] +'...', info
+
+    # info fallback (eg, rsre_jit, qoppy, but also
+    #  pyhaskell (pyhaskell/interpreter/haskell.py)
+    #  pyrolog (prolog/interpreter/continuation.py)
+    #  RPySOM/RTruffleSom (src/som/interpreter/interpreter.py)
+    #  Topaz (topaz/interpreter.py)
+    #  hippyvm (hippy/interpreter.py)
+    return info, info
+
 def postprocess_loop(loop, loops, memo, counts):
+
     if loop in memo:
         return
     memo.add(loop)
     if loop is None:
         return
-    m = re.search("debug_merge_point\((?:\d+,\ )*'(<code object (.*?)> 
(.*?))'", loop.content)
-    if m is None:
-        name = '?'
-        loop.key = '?'
-    else:
-        name = m.group(2) + " " + m.group(3)
-        loop.key = m.group(1)
+    name, loop.key = find_name_key(loop)
     opsno = loop.content.count("\n")
     lastline = loop.content[loop.content.rfind("\n", 0, len(loop.content) - 
2):]
     m = re.search('descr=<Loop(\d+)', lastline)
diff --git a/rpython/rlib/rarithmetic.py b/rpython/rlib/rarithmetic.py
--- a/rpython/rlib/rarithmetic.py
+++ b/rpython/rlib/rarithmetic.py
@@ -533,11 +533,15 @@
 
 if r_longlong is not r_int:
     r_int64 = r_longlong
+    r_uint64 = r_ulonglong
+    r_int32 = int # XXX: what about r_int
+    r_uint32 = r_uint
 else:
-    r_int64 = int
+    r_int64 = int # XXX: what about r_int
+    r_uint64 = r_uint # is r_ulonglong
+    r_int32 = build_int('r_int32', True, 32)     # also needed for 
rposix_stat.time_t_to_FILE_TIME in the 64 bit case
+    r_uint32 = build_int('r_uint32', False, 32)
 
-# needed for rposix_stat.time_t_to_FILE_TIME in the 64 bit case
-r_uint32 = build_int('r_uint32', False, 32)
 
 SHRT_MIN = -2**(_get_bitsize('h') - 1)
 SHRT_MAX = 2**(_get_bitsize('h') - 1) - 1
diff --git a/rpython/rlib/test/test_rarithmetic.py 
b/rpython/rlib/test/test_rarithmetic.py
--- a/rpython/rlib/test/test_rarithmetic.py
+++ b/rpython/rlib/test/test_rarithmetic.py
@@ -528,3 +528,56 @@
             py.test.raises(ParseStringError, string_to_int, s+'  ', base)
             py.test.raises(ParseStringError, string_to_int, '+'+s, base)
             py.test.raises(ParseStringError, string_to_int, '-'+s, base)
+
+class TestExplicitIntsizes:
+
+    _32_max =            2147483647
+    _32_min =           -2147483648
+    _32_umax =           4294967295
+    _64_max =   9223372036854775807
+    _64_min =  -9223372036854775808
+    _64_umax = 18446744073709551615
+
+    def test_explicit_32(self):
+
+        assert type(r_int32(0)) == r_int32
+        assert type(r_int32(self._32_max)) == r_int32
+        assert type(r_int32(self._32_min)) == r_int32
+
+        assert type(r_uint32(0)) == r_uint32
+        assert type(r_uint32(self._32_umax)) == r_uint32
+
+        with py.test.raises(OverflowError):
+            ovfcheck(r_int32(self._32_max) + r_int32(1))
+            ovfcheck(r_int32(self._32_min) - r_int32(1))
+
+        assert most_pos_value_of_same_type(r_int32(1)) == self._32_max
+        assert most_neg_value_of_same_type(r_int32(1)) == self._32_min
+
+        assert most_pos_value_of_same_type(r_uint32(1)) == self._32_umax
+        assert most_neg_value_of_same_type(r_uint32(1)) == 0
+
+        assert r_uint32(self._32_umax) + r_uint32(1) == r_uint32(0)
+        assert r_uint32(0) - r_uint32(1) == r_uint32(self._32_umax)
+
+    def test_explicit_64(self):
+
+        assert type(r_int64(0)) == r_int64
+        assert type(r_int64(self._64_max)) == r_int64
+        assert type(r_int64(self._64_min)) == r_int64
+
+        assert type(r_uint64(0)) == r_uint64
+        assert type(r_uint64(self._64_umax)) == r_uint64
+
+        with py.test.raises(OverflowError):
+            ovfcheck(r_int64(self._64_max) + r_int64(1))
+            ovfcheck(r_int64(self._64_min) - r_int64(1))
+
+        assert most_pos_value_of_same_type(r_int64(1)) == self._64_max
+        assert most_neg_value_of_same_type(r_int64(1)) == self._64_min
+
+        assert most_pos_value_of_same_type(r_uint64(1)) == self._64_umax
+        assert most_neg_value_of_same_type(r_uint64(1)) == 0
+
+        assert r_uint64(self._64_umax) + r_uint64(1) == r_uint64(0)
+        assert r_uint64(0) - r_uint64(1) == r_uint64(self._64_umax)
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to