[pypy-commit] pypy regalloc-playground: merge default
cfbolz
pypy.commits at gmail.com
Sun Aug 20 13:09:42 EDT 2017
Author: Carl Friedrich Bolz <cfbolz at gmx.de>
Branch: regalloc-playground
Changeset: r92190:7a89232328d8
Date: 2017-08-20 16:31 +0200
http://bitbucket.org/pypy/pypy/changeset/7a89232328d8/
Log: merge default
diff --git a/pypy/module/cpyext/sequence.py b/pypy/module/cpyext/sequence.py
--- a/pypy/module/cpyext/sequence.py
+++ b/pypy/module/cpyext/sequence.py
@@ -294,6 +294,23 @@
def getitems_fixedsize(self, w_list):
return self.getitems_unroll(w_list)
+ def copy_into(self, w_list, w_other):
+ w_other.strategy = self
+ w_other.lstorage = self.getstorage_copy(w_list)
+
+ def clone(self, w_list):
+ storage = self.getstorage_copy(w_list)
+ w_clone = W_ListObject.from_storage_and_strategy(self.space, storage,
+ self)
+ return w_clone
+
+ def getitems_copy(self, w_list):
+ return self.getitems(w_list) # getitems copies anyway
+
+ def getstorage_copy(self, w_list):
+ lst = self.getitems(w_list)
+ return self.erase(CPyListStorage(w_list.space, lst))
+
#------------------------------------------
# all these methods fail or switch strategy and then call ListObjectStrategy's method
@@ -301,23 +318,9 @@
w_list.switch_to_object_strategy()
w_list.strategy.setslice(w_list, start, stop, step, length)
- def get_sizehint(self):
- return -1
-
def init_from_list_w(self, w_list, list_w):
raise NotImplementedError
- def clone(self, w_list):
- storage = w_list.lstorage # lstorage is tuple, no need to clone
- w_clone = W_ListObject.from_storage_and_strategy(self.space, storage,
- self)
- w_clone.switch_to_object_strategy()
- return w_clone
-
- def copy_into(self, w_list, w_other):
- w_list.switch_to_object_strategy()
- w_list.strategy.copy_into(w_list, w_other)
-
def _resize_hint(self, w_list, hint):
pass
@@ -325,13 +328,6 @@
w_list.switch_to_object_strategy()
return w_list.strategy.find(w_list, w_item, start, stop)
- def getitems_copy(self, w_list):
- w_list.switch_to_object_strategy()
- return w_list.strategy.getitems_copy(w_list)
-
- def getstorage_copy(self, w_list):
- raise NotImplementedError
-
def append(self, w_list, w_item):
w_list.switch_to_object_strategy()
w_list.strategy.append(w_list, w_item)
diff --git a/pypy/module/cpyext/test/test_sequence.py b/pypy/module/cpyext/test/test_sequence.py
--- a/pypy/module/cpyext/test/test_sequence.py
+++ b/pypy/module/cpyext/test/test_sequence.py
@@ -226,6 +226,15 @@
w_l.inplace_mul(2)
assert space.int_w(space.len(w_l)) == 10
+ def test_getstorage_copy(self, space, api):
+ w = space.wrap
+ w_l = w([1, 2, 3, 4])
+ api.PySequence_Fast(w_l, "foo") # converts
+
+ w_l1 = w([])
+ space.setitem(w_l1, space.newslice(w(0), w(0), w(1)), w_l)
+ assert map(space.unwrap, space.unpackiterable(w_l1)) == [1, 2, 3, 4]
+
class AppTestSequenceObject(AppTestCpythonExtensionBase):
def test_fast(self):
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
@@ -1671,18 +1671,6 @@
else:
not_implemented("save_into_mem size = %d" % size)
- def _genop_getfield(self, op, arglocs, resloc):
- base_loc, ofs_loc, size_loc, sign_loc = arglocs
- assert isinstance(size_loc, ImmedLoc)
- source_addr = AddressLoc(base_loc, ofs_loc)
- self.load_from_mem(resloc, source_addr, size_loc, sign_loc)
-
- genop_getfield_gc_i = _genop_getfield
- genop_getfield_gc_r = _genop_getfield
- genop_getfield_gc_f = _genop_getfield
- genop_getfield_raw_i = _genop_getfield
- genop_getfield_raw_f = _genop_getfield
-
def _genop_gc_load(self, op, arglocs, resloc):
base_loc, ofs_loc, size_loc, sign_loc = arglocs
assert isinstance(size_loc, ImmedLoc)
diff --git a/rpython/jit/backend/x86/regalloc.py b/rpython/jit/backend/x86/regalloc.py
--- a/rpython/jit/backend/x86/regalloc.py
+++ b/rpython/jit/backend/x86/regalloc.py
@@ -1303,7 +1303,7 @@
self.rm.possibly_free_var(tmpbox_high)
def compute_hint_frame_locations(self, operations):
- # optimization only: fill in the 'hint_frame_locations' dictionary
+ # optimization only: fill in the 'hint_frame_pos' dictionary
# of 'fm' based on the JUMP at the end of the loop, by looking
# at where we would like the boxes to be after the jump.
op = operations[-1]
@@ -1318,7 +1318,7 @@
self._compute_hint_frame_locations_from_descr(descr)
#else:
# The loop ends in a JUMP going back to a LABEL in the same loop.
- # We cannot fill 'hint_frame_locations' immediately, but we can
+ # We cannot fill 'hint_frame_pos' immediately, but we can
# wait until the corresponding consider_label() to know where the
# we would like the boxes to be after the jump.
diff --git a/rpython/rlib/rposix.py b/rpython/rlib/rposix.py
--- a/rpython/rlib/rposix.py
+++ b/rpython/rlib/rposix.py
@@ -205,6 +205,18 @@
if not is_valid_fd(fd):
from errno import EBADF
raise OSError(EBADF, 'Bad file descriptor')
+
+ def _bound_for_write(fd, count):
+ if count > 32767 and c_isatty(fd):
+ # CPython Issue #11395, PyPy Issue #2636: the Windows console
+ # returns an error (12: not enough space error) on writing into
+ # stdout if stdout mode is binary and the length is greater than
+ # 66,000 bytes (or less, depending on heap usage). Can't easily
+ # test that, because we need 'fd' to be non-redirected...
+ count = 32767
+ elif count > 0x7fffffff:
+ count = 0x7fffffff
+ return count
else:
def is_valid_fd(fd):
return 1
@@ -213,6 +225,9 @@
def validate_fd(fd):
pass
+ def _bound_for_write(fd, count):
+ return count
+
def closerange(fd_low, fd_high):
# this behaves like os.closerange() from Python 2.6.
for fd in xrange(fd_low, fd_high):
@@ -449,6 +464,7 @@
def write(fd, data):
count = len(data)
validate_fd(fd)
+ count = _bound_for_write(fd, count)
with rffi.scoped_nonmovingbuffer(data) as buf:
return handle_posix_error('write', c_write(fd, buf, count))
diff --git a/rpython/rtyper/tool/rffi_platform.py b/rpython/rtyper/tool/rffi_platform.py
--- a/rpython/rtyper/tool/rffi_platform.py
+++ b/rpython/rtyper/tool/rffi_platform.py
@@ -710,7 +710,8 @@
size, _ = expected_size_and_sign
return lltype.FixedSizeArray(fieldtype.OF, size/_sizeof(fieldtype.OF))
raise TypeError("conflict between translating python and compiler field"
- " type %r for %r" % (fieldtype, fieldname))
+ " type %r for symbol %r, expected size+sign %r" % (
+ fieldtype, fieldname, expected_size_and_sign))
def expose_value_as_rpython(value):
if intmask(value) == value:
More information about the pypy-commit
mailing list