Author: Richard Plangger <[email protected]>
Branch: new-jit-log
Changeset: r85837:46a75e79ab0d
Date: 2016-07-24 12:22 +0200
http://bitbucket.org/pypy/pypy/changeset/46a75e79ab0d/
Log: merged default, applied changes to zarch assembler
diff --git a/lib-python/2.7/test/test_hash.py b/lib-python/2.7/test/test_hash.py
--- a/lib-python/2.7/test/test_hash.py
+++ b/lib-python/2.7/test/test_hash.py
@@ -174,7 +174,7 @@
class StringlikeHashRandomizationTests(HashRandomizationTests):
if check_impl_detail(pypy=True):
- EMPTY_STRING_HASH = -1
+ EMPTY_STRING_HASH = -2
else:
EMPTY_STRING_HASH = 0
diff --git a/pypy/doc/build.rst b/pypy/doc/build.rst
--- a/pypy/doc/build.rst
+++ b/pypy/doc/build.rst
@@ -104,27 +104,24 @@
apt-get install gcc make libffi-dev pkg-config libz-dev libbz2-dev \
libsqlite3-dev libncurses-dev libexpat1-dev libssl-dev libgdbm-dev \
- tk-dev libgc-dev liblzma-dev
-
-For the optional lzma module on PyPy3 you will also need ``liblzma-dev``.
+ tk-dev libgc-dev \
+ liblzma-dev # For lzma on PyPy3.
On Fedora::
dnf install gcc make libffi-devel pkgconfig zlib-devel bzip2-devel \
lib-sqlite3-devel ncurses-devel expat-devel openssl-devel tk-devel \
- gdbm-devel
-
-For the optional lzma module on PyPy3 you will also need ``xz-devel``.
+ gdbm-devel \
+ xz-devel # For lzma on PyPy3.
On SLES11::
zypper install gcc make python-devel pkg-config \
zlib-devel libopenssl-devel libbz2-devel sqlite3-devel \
- libexpat-devel libffi-devel python-curses
+ libexpat-devel libffi-devel python-curses \
+ xz-devel # For lzma on PyPy3.
(XXX plus the SLES11 version of libgdbm-dev and tk-dev)
-For the optional lzma module on PyPy3 you will also need ``xz-devel``.
-
On Mac OS X, most of these build-time dependencies are installed alongside
the Developer Tools. However, note that in order for the installation to
find them you may need to run::
diff --git a/pypy/module/cpyext/test/test_object.py
b/pypy/module/cpyext/test/test_object.py
--- a/pypy/module/cpyext/test/test_object.py
+++ b/pypy/module/cpyext/test/test_object.py
@@ -168,7 +168,7 @@
def test_hash(self, space, api):
assert api.PyObject_Hash(space.wrap(72)) == 72
- assert api.PyObject_Hash(space.wrap(-1)) == -1
+ assert api.PyObject_Hash(space.wrap(-1)) == -2
assert (api.PyObject_Hash(space.wrap([])) == -1 and
api.PyErr_Occurred() is space.w_TypeError)
api.PyErr_Clear()
diff --git a/pypy/objspace/descroperation.py b/pypy/objspace/descroperation.py
--- a/pypy/objspace/descroperation.py
+++ b/pypy/objspace/descroperation.py
@@ -409,7 +409,7 @@
if not e.match(space, space.w_StopIteration):
raise
return space.w_False
- if space.eq_w(w_next, w_item):
+ if space.eq_w(w_item, w_next):
return space.w_True
def hash(space, w_obj):
@@ -425,17 +425,25 @@
"'%T' objects are unhashable", w_obj)
w_result = space.get_and_call_function(w_hash, w_obj)
w_resulttype = space.type(w_result)
+
+ # issue 2346 : returns now -2 for hashing -1 like cpython
if space.is_w(w_resulttype, space.w_int):
+ if space.int_w(w_result) == -1:
+ return space.wrap(-2)
return w_result
- elif space.is_w(w_resulttype, space.w_long):
- return space.hash(w_result)
elif space.isinstance_w(w_result, space.w_int):
# be careful about subclasses of 'int'...
- return space.wrap(space.int_w(w_result))
+ int_result = space.int_w(w_result)
+ if int_result == -1:
+ int_result == -2
+ return space.wrap(int_result)
elif space.isinstance_w(w_result, space.w_long):
# be careful about subclasses of 'long'...
bigint = space.bigint_w(w_result)
- return space.wrap(bigint.hash())
+ h = bigint.hash()
+ if h == -1:
+ h = -2
+ return space.wrap(h)
else:
raise oefmt(space.w_TypeError,
"__hash__() should return an int or long")
diff --git a/pypy/objspace/std/listobject.py b/pypy/objspace/std/listobject.py
--- a/pypy/objspace/std/listobject.py
+++ b/pypy/objspace/std/listobject.py
@@ -795,7 +795,7 @@
tp = space.type(w_item)
while i < stop and i < w_list.length():
find_jmp.jit_merge_point(tp=tp)
- if space.eq_w(w_list.getitem(i), w_item):
+ if space.eq_w(w_item, w_list.getitem(i)):
return i
i += 1
raise ValueError
diff --git a/pypy/objspace/std/specialisedtupleobject.py
b/pypy/objspace/std/specialisedtupleobject.py
--- a/pypy/objspace/std/specialisedtupleobject.py
+++ b/pypy/objspace/std/specialisedtupleobject.py
@@ -62,6 +62,11 @@
value = getattr(self, 'value%s' % i)
if typetuple[i] == object:
y = space.int_w(space.hash(value))
+ elif typetuple[i] == int:
+ # mimic cpythons behavior of a hash value of -2 for -1
+ y = value
+ if y == -1:
+ y = -2
elif typetuple[i] == float:
# get the correct hash for float which is an
# integer & other less frequent cases
diff --git a/pypy/objspace/std/test/test_dictmultiobject.py
b/pypy/objspace/std/test/test_dictmultiobject.py
--- a/pypy/objspace/std/test/test_dictmultiobject.py
+++ b/pypy/objspace/std/test/test_dictmultiobject.py
@@ -948,6 +948,41 @@
helper(lambda x: x.viewkeys())
helper(lambda x: x.viewitems())
+ def test_contains(self):
+ logger = []
+
+ class Foo(object):
+
+ def __init__(self, value, name=None):
+ self.value = value
+ self.name = name or value
+
+ def __repr__(self):
+ return '<Foo %s>' % self.name
+
+ def __eq__(self, other):
+ logger.append((self, other))
+ return self.value == other.value
+
+ def __hash__(self):
+ return 42 # __eq__ will be used given all objects' hashes
clash
+
+ foo1, foo2, foo3 = Foo(1), Foo(2), Foo(3)
+ foo42 = Foo(42)
+ foo_dict = {foo1: 1, foo2: 1, foo3: 1}
+ del logger[:]
+ foo42 in foo_dict
+ logger_copy = set(logger[:]) # prevent re-evaluation during pytest
error print
+ assert logger_copy == {(foo3, foo42), (foo2, foo42), (foo1, foo42)}
+
+ del logger[:]
+ foo2_bis = Foo(2, '2 bis')
+ foo2_bis in foo_dict
+ logger_copy = set(logger[:]) # prevent re-evaluation during pytest
error print
+ assert (foo2, foo2_bis) in logger_copy
+ assert logger_copy.issubset({(foo1, foo2_bis), (foo2, foo2_bis),
(foo3, foo2_bis)})
+
+
class AppTestStrategies(object):
def setup_class(cls):
if cls.runappdirect:
diff --git a/pypy/objspace/std/test/test_iterobject.py
b/pypy/objspace/std/test/test_iterobject.py
--- a/pypy/objspace/std/test/test_iterobject.py
+++ b/pypy/objspace/std/test/test_iterobject.py
@@ -97,3 +97,32 @@
def test_no_len_on_xrange(self):
iterable = xrange(10)
raises(TypeError, len, iter(iterable))
+
+ def test_contains(self):
+ logger = []
+
+ class Foo(object):
+
+ def __init__(self, value, name=None):
+ self.value = value
+ self.name = name or value
+
+ def __repr__(self):
+ return '<Foo %s>' % self.name
+
+ def __eq__(self, other):
+ logger.append((self, other))
+ return self.value == other.value
+
+ foo1, foo2, foo3 = Foo(1), Foo(2), Foo(3)
+ foo42 = Foo(42)
+ foo_list = [foo1, foo2, foo3]
+ foo42 in (x for x in foo_list)
+ logger_copy = logger[:] # prevent re-evaluation during pytest error
print
+ assert logger_copy == [(foo42, foo1), (foo42, foo2), (foo42, foo3)]
+
+ del logger[:]
+ foo2_bis = Foo(2, '2 bis')
+ foo2_bis in (x for x in foo_list)
+ logger_copy = logger[:] # prevent re-evaluation during pytest error
print
+ assert logger_copy == [(foo2_bis, foo1), (foo2_bis, foo2)]
diff --git a/pypy/objspace/std/test/test_listobject.py
b/pypy/objspace/std/test/test_listobject.py
--- a/pypy/objspace/std/test/test_listobject.py
+++ b/pypy/objspace/std/test/test_listobject.py
@@ -503,6 +503,34 @@
assert not l.__contains__(-20)
assert not l.__contains__(-21)
+ logger = []
+
+ class Foo(object):
+
+ def __init__(self, value, name=None):
+ self.value = value
+ self.name = name or value
+
+ def __repr__(self):
+ return '<Foo %s>' % self.name
+
+ def __eq__(self, other):
+ logger.append((self, other))
+ return self.value == other.value
+
+ foo1, foo2, foo3 = Foo(1), Foo(2), Foo(3)
+ foo42 = Foo(42)
+ foo_list = [foo1, foo2, foo3]
+ foo42 in foo_list
+ logger_copy = logger[:] # prevent re-evaluation during pytest error
print
+ assert logger_copy == [(foo42, foo1), (foo42, foo2), (foo42, foo3)]
+
+ del logger[:]
+ foo2_bis = Foo(2, '2 bis')
+ foo2_bis in foo_list
+ logger_copy = logger[:] # prevent re-evaluation during pytest error
print
+ assert logger_copy == [(foo2_bis, foo1), (foo2_bis, foo2)]
+
def test_call_list(self):
assert list('') == []
assert list('abc') == ['a', 'b', 'c']
diff --git a/pypy/objspace/std/test/test_setobject.py
b/pypy/objspace/std/test/test_setobject.py
--- a/pypy/objspace/std/test/test_setobject.py
+++ b/pypy/objspace/std/test/test_setobject.py
@@ -532,6 +532,39 @@
assert (c in s) == (c in word)
raises(TypeError, s.__contains__, [])
+ logger = []
+
+ class Foo(object):
+
+ def __init__(self, value, name=None):
+ self.value = value
+ self.name = name or value
+
+ def __repr__(self):
+ return '<Foo %s>' % self.name
+
+ def __eq__(self, other):
+ logger.append((self, other))
+ return self.value == other.value
+
+ def __hash__(self):
+ return 42 # __eq__ will be used given all objects' hashes
clash
+
+ foo1, foo2, foo3 = Foo(1), Foo(2), Foo(3)
+ foo42 = Foo(42)
+ foo_set = {foo1, foo2, foo3}
+ del logger[:]
+ foo42 in foo_set
+ logger_copy = set(logger[:]) # prevent re-evaluation during pytest
error print
+ assert logger_copy == {(foo3, foo42), (foo2, foo42), (foo1, foo42)}
+
+ del logger[:]
+ foo2_bis = Foo(2, '2 bis')
+ foo2_bis in foo_set
+ logger_copy = set(logger[:]) # prevent re-evaluation during pytest
error print
+ assert (foo2, foo2_bis) in logger_copy
+ assert logger_copy.issubset({(foo1, foo2_bis), (foo2, foo2_bis),
(foo3, foo2_bis)})
+
def test_remove(self):
s = set('abc')
s.remove('a')
diff --git a/pypy/objspace/std/test/test_specialisedtupleobject.py
b/pypy/objspace/std/test/test_specialisedtupleobject.py
--- a/pypy/objspace/std/test/test_specialisedtupleobject.py
+++ b/pypy/objspace/std/test/test_specialisedtupleobject.py
@@ -177,6 +177,10 @@
assert hash(a) == hash((1L, 2L)) == hash((1.0, 2.0)) == hash((1.0, 2L))
+ x = (-1, -1)
+ y = tuple([-1, -1])
+ assert hash(x) == hash(y)
+
def test_getitem(self):
t = (5, 3)
assert (t)[0] == 5
diff --git a/pypy/objspace/std/test/test_tupleobject.py
b/pypy/objspace/std/test/test_tupleobject.py
--- a/pypy/objspace/std/test/test_tupleobject.py
+++ b/pypy/objspace/std/test/test_tupleobject.py
@@ -269,6 +269,34 @@
assert not 11 in t
assert not t in t
+ logger = []
+
+ class Foo(object):
+
+ def __init__(self, value, name=None):
+ self.value = value
+ self.name = name or value
+
+ def __repr__(self):
+ return '<Foo %s>' % self.name
+
+ def __eq__(self, other):
+ logger.append((self, other))
+ return self.value == other.value
+
+ foo1, foo2, foo3 = Foo(1), Foo(2), Foo(3)
+ foo42 = Foo(42)
+ foo_tuple = (foo1, foo2, foo3)
+ foo42 in foo_tuple
+ logger_copy = logger[:] # prevent re-evaluation during pytest error
print
+ assert logger_copy == [(foo42, foo1), (foo42, foo2), (foo42, foo3)]
+
+ del logger[:]
+ foo2_bis = Foo(2, '2 bis')
+ foo2_bis in foo_tuple
+ logger_copy = logger[:] # prevent re-evaluation during pytest error
print
+ assert logger_copy == [(foo2_bis, foo1), (foo2_bis, foo2)]
+
def test_add(self):
t0 = ()
t1 = (5, 3, 99)
diff --git a/pypy/objspace/std/tupleobject.py b/pypy/objspace/std/tupleobject.py
--- a/pypy/objspace/std/tupleobject.py
+++ b/pypy/objspace/std/tupleobject.py
@@ -153,7 +153,7 @@
@jit.unroll_safe
def _descr_contains_unroll_safe(self, space, w_obj):
for w_item in self.tolist():
- if space.eq_w(w_item, w_obj):
+ if space.eq_w(w_obj, w_item):
return space.w_True
return space.w_False
@@ -161,7 +161,7 @@
tp = space.type(w_obj)
for w_item in self.tolist():
contains_jmp.jit_merge_point(tp=tp)
- if space.eq_w(w_item, w_obj):
+ if space.eq_w(w_obj, w_item):
return space.w_True
return space.w_False
diff --git a/pypy/objspace/test/test_descriptor.py
b/pypy/objspace/test/test_descriptor.py
--- a/pypy/objspace/test/test_descriptor.py
+++ b/pypy/objspace/test/test_descriptor.py
@@ -141,3 +141,31 @@
return myint(15)
assert hash(I()) == 15
assert type(hash(I())) is int
+
+ # check hashing of -1 to -2
+ class myint(int):
+ pass
+ class mylong(long):
+ pass
+ class myfloat(float):
+ pass
+ class myHashClass(object):
+ def __hash__(self):
+ return -1
+ class myHashClass2(object):
+ def __hash__(self):
+ return -1L
+ class myHashClass3(object):
+ def __hash__(self):
+ return -10**100
+
+ assert hash(-1) == -2
+ assert hash(-1L) == -2
+ assert hash(-1.0) == -2
+ assert hash(-1 + 0j) == -2
+ assert hash(myint(-1)) == -2
+ assert hash(mylong(-1)) == -2
+ assert hash(myfloat(-1.0)) == -2
+ assert hash(myHashClass()) == -2
+ assert hash(myHashClass2()) == -2
+ assert hash(myHashClass3()) == hash(-10**100)
diff --git a/rpython/jit/backend/x86/assembler.py
b/rpython/jit/backend/x86/assembler.py
--- a/rpython/jit/backend/x86/assembler.py
+++ b/rpython/jit/backend/x86/assembler.py
@@ -539,15 +539,17 @@
looptoken._x86_fullsize = full_size
looptoken._x86_ops_offset = ops_offset
looptoken._ll_function_addr = rawstart + functionpos
+
if logger:
log = logger.log_trace(jl.MARK_TRACE_ASM, None, self.mc)
log.write(inputargs, operations, ops_offset=ops_offset)
# legacy
if logger.logger_ops:
- logger.logger_ops.log_loop(inputargs, operations, 0,
"rewritten",
- name=loopname, ops_offset=ops_offset)
-
+ logger.logger_ops.log_loop(inputargs, operations, 0,
+ "rewritten", name=loopname,
+ ops_offset=ops_offset)
+
self.fixup_target_tokens(rawstart)
self.teardown()
# oprofile support
diff --git a/rpython/jit/backend/zarch/assembler.py
b/rpython/jit/backend/zarch/assembler.py
--- a/rpython/jit/backend/zarch/assembler.py
+++ b/rpython/jit/backend/zarch/assembler.py
@@ -669,9 +669,16 @@
looptoken._zarch_rawstart = rawstart
looptoken._zarch_fullsize = full_size
looptoken._zarch_ops_offset = ops_offset
+
if logger:
- logger.log_loop(inputargs, operations, 0, "rewritten",
- name=loopname, ops_offset=ops_offset)
+ log = logger.log_trace(jl.MARK_TRACE_ASM, None, self.mc)
+ log.write(inputargs, operations, ops_offset=ops_offset)
+
+ # legacy
+ if logger.logger_ops:
+ logger.logger_ops.log_loop(inputargs, operations, 0,
+ "rewritten", name=loopname,
+ ops_offset=ops_offset)
self.fixup_target_tokens(rawstart)
self.teardown()
@@ -736,9 +743,18 @@
ops_offset = self.mc.ops_offset
frame_depth = max(self.current_clt.frame_info.jfi_frame_depth,
frame_depth_no_fixed_size + JITFRAME_FIXED_SIZE)
+
if logger:
- logger.log_bridge(inputargs, operations, "rewritten",
- ops_offset=ops_offset)
+ log = logger.log_trace(jl.MARK_TRACE_ASM, None, self.mc)
+ log.write(inputargs, operations, ops_offset)
+ # log that the already written bridge is stitched to a descr!
+ logger.log_patch_guard(descr_number, rawstart)
+
+ # legacy
+ if logger.logger_ops:
+ logger.logger_ops.log_bridge(inputargs, operations,
"rewritten",
+ faildescr, ops_offset=ops_offset)
+
self.fixup_target_tokens(rawstart)
self.update_frame_depth(frame_depth)
self.teardown()
diff --git a/rpython/rlib/rmmap.py b/rpython/rlib/rmmap.py
--- a/rpython/rlib/rmmap.py
+++ b/rpython/rlib/rmmap.py
@@ -960,5 +960,5 @@
rffi.cast(rffi.SIZE_T, map_size),
rffi.cast(DWORD, MEM_RESET),
rffi.cast(DWORD, PAGE_READWRITE))
- from rpython.rlib import debug
- debug.debug_print("madvise_free:", r)
+ #from rpython.rlib import debug
+ #debug.debug_print("madvise_free:", r)
diff --git a/rpython/translator/c/src/entrypoint.c
b/rpython/translator/c/src/entrypoint.c
--- a/rpython/translator/c/src/entrypoint.c
+++ b/rpython/translator/c/src/entrypoint.c
@@ -63,9 +63,10 @@
char *errmsg;
int i, exitcode;
-#if defined(MS_WINDOWS) && defined(RPY_SANDBOXED)
+#if defined(MS_WINDOWS)
_setmode(0, _O_BINARY);
_setmode(1, _O_BINARY);
+ _setmode(2, _O_BINARY);
#endif
#ifdef RPY_WITH_GIL
diff --git a/rpython/translator/c/test/test_standalone.py
b/rpython/translator/c/test/test_standalone.py
--- a/rpython/translator/c/test/test_standalone.py
+++ b/rpython/translator/c/test/test_standalone.py
@@ -6,7 +6,6 @@
from rpython.rlib.objectmodel import keepalive_until_here
from rpython.rlib.rarithmetic import r_longlong
from rpython.rlib.debug import ll_assert, have_debug_prints, debug_flush
-from rpython.rlib.jitlog import stats_flush_trace_counts
from rpython.rlib.debug import debug_print, debug_start, debug_stop
from rpython.rlib.debug import debug_offset, have_debug_prints_for
from rpython.rlib.entrypoint import entrypoint_highlevel, secondary_entrypoints
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit