Author: Tim Felgentreff <timfelgentr...@gmail.com> Branch: 64bit Changeset: r573:04dd02446fb4 Date: 2014-01-10 22:26 +0100 http://bitbucket.org/pypy/lang-smalltalk/changeset/04dd02446fb4/
Log: simplify some r_uint/r_uint32 distinctions. this 64bit vm still works ;) diff --git a/spyvm/display.py b/spyvm/display.py --- a/spyvm/display.py +++ b/spyvm/display.py @@ -1,4 +1,3 @@ -from rpython.rlib.rarithmetic import r_uint32 as r_uint from rpython.rtyper.lltypesystem import lltype, rffi from rpython.rlib.runicode import unicode_encode_utf_8 from rpython.rlib import jit diff --git a/spyvm/model.py b/spyvm/model.py --- a/spyvm/model.py +++ b/spyvm/model.py @@ -395,11 +395,11 @@ from rpython.rlib.rstruct.ieee import float_pack r = float_pack(self.value, 8) # C double if n0 == 0: - return space.wrap_uint(r_uint32(intmask(r >> 32))) + return space.wrap_positive_32bit_int(intmask(r >> 32)) else: # bounds-check for primitive access is done in the primitive assert n0 == 1 - return space.wrap_uint(r_uint32(intmask(r))) + return space.wrap_positive_32bit_int(intmask(r)) def store(self, space, n0, w_obj): from rpython.rlib.rstruct.ieee import float_unpack, float_pack @@ -974,7 +974,7 @@ class W_DisplayBitmap(W_AbstractObjectWithClassReference): _attrs_ = ['pixelbuffer', '_realsize', '_real_depth_buffer', 'display', '_depth'] - _immutable_fields_ = ['_realsize', 'display', '_depth'] + _immutable_fields_ = ['_realsize', 'display', '_depth', '_real_depth_buffer'] @staticmethod def create(space, w_class, size, depth, display): @@ -989,7 +989,6 @@ def __init__(self, space, w_class, size, depth, display): W_AbstractObjectWithClassReference.__init__(self, space, w_class) - # self._real_depth_buffer = lltype.malloc(rffi.CArray(rffi.UINT), size, flavor='raw') self._real_depth_buffer = [r_uint(0)] * size self.pixelbuffer = display.get_pixelbuffer() self._realsize = size diff --git a/spyvm/plugins/bitblt.py b/spyvm/plugins/bitblt.py --- a/spyvm/plugins/bitblt.py +++ b/spyvm/plugins/bitblt.py @@ -4,7 +4,7 @@ from spyvm.plugins.plugin import Plugin from rpython.rlib import jit, objectmodel -from rpython.rlib.rarithmetic import intmask, r_uint32, r_uint +from rpython.rlib.rarithmetic import intmask, r_uint BitBltPlugin = Plugin() @@ -264,19 +264,19 @@ destWord = self.dest.w_bits.getword(self.destIndex) mergeWord = self.mergeFn(halftoneWord, destWord) destWord = (destMask & mergeWord) | (destWord & (~destMask)) - self.dest.w_bits.setword(self.destIndex, r_uint32(destWord)) + self.dest.w_bits.setword(self.destIndex, destWord) self.destIndex += 1 destMask = BitBltShadow.AllOnes # the central horizontal loop requires no store masking if self.combinationRule == 3: # store rule requires no dest merging for word in range(2, self.nWords): - self.dest.w_bits.setword(self.destIndex, r_uint32(halftoneWord)) + self.dest.w_bits.setword(self.destIndex, halftoneWord) self.destIndex += 1 else: for word in range(2, self.nWords): destWord = self.dest.w_bits.getword(self.destIndex) mergeWord = self.mergeFn(halftoneWord, destWord) - self.dest.w_bits.setword(self.destIndex, r_uint32(mergeWord)) + self.dest.w_bits.setword(self.destIndex, mergeWord) self.destIndex += 1 # last word in row is masked if self.nWords > 1: @@ -284,7 +284,7 @@ destWord = self.dest.w_bits.getword(self.destIndex) mergeWord = self.mergeFn(halftoneWord, destWord) destWord = (destMask & mergeWord) | (destWord & (~destMask)) - self.dest.w_bits.setword(self.destIndex, r_uint32(destWord)) + self.dest.w_bits.setword(self.destIndex, destWord) self.destIndex += 1 self.destIndex += self.destDelta @@ -346,13 +346,13 @@ if self.destMask == BitBltShadow.AllOnes: # avoid read-modify-write self.dest.w_bits.setword( self.destIndex, - r_uint32(self.mergeFn(skewWord & halftoneWord, self.dest.w_bits.getword(self.destIndex))) + self.mergeFn(skewWord & halftoneWord, self.dest.w_bits.getword(self.destIndex)) ) else: # General version using dest masking destWord = self.dest.w_bits.getword(self.destIndex) mergeWord = self.mergeFn(skewWord & halftoneWord, destWord & self.destMask) destWord = (self.destMask & mergeWord) | (destWord & (~self.destMask)) - self.dest.w_bits.setword(self.destIndex, r_uint32(destWord)) + self.dest.w_bits.setword(self.destIndex, destWord) self.destIndex += 1 if (self.nWords == 2): # is the next word the last word? @@ -458,7 +458,7 @@ destWord = self.dest.w_bits.getword(self.destIndex) mergeWord = self.mergeFn(skewWord & halftoneWord, destWord) destWord = (destMask & mergeWord) | (destWord & (~destMask)) - self.dest.w_bits.setword(self.destIndex, r_uint32(destWord)) + self.dest.w_bits.setword(self.destIndex, destWord) # The central horizontal loop requires no store masking self.destIndex += hInc destMask = BitBltShadow.AllOnes @@ -468,12 +468,12 @@ if (self.hDir == -1): for word in range(2, self.nWords): thisWord = self.source.w_bits.getword(self.sourceIndex) - self.dest.w_bits.setword(self.destIndex, r_uint32(thisWord)) + self.dest.w_bits.setword(self.destIndex, thisWord) self.sourceIndex += hInc self.destIndex += hInc else: for word in range(2, self.nWords): - self.dest.w_bits.setword(self.destIndex, r_uint32(prevWord)) + self.dest.w_bits.setword(self.destIndex, prevWord) prevWord = self.source.w_bits.getword(self.sourceIndex) self.destIndex += hInc self.sourceIndex += hInc @@ -484,7 +484,7 @@ self.sourceIndex += hInc skewWord = self.rotate32bit(thisWord, prevWord, skewMask, notSkewMask, unskew) prevWord = thisWord - self.dest.w_bits.setword(self.destIndex, r_uint32(skewWord & halftoneWord)) + self.dest.w_bits.setword(self.destIndex, skewWord & halftoneWord) self.destIndex += hInc else: # Dest merging here... for word in range(2, self.nWords): @@ -493,7 +493,7 @@ skewWord = self.rotate32bit(thisWord, prevWord, skewMask, notSkewMask, unskew) prevWord = thisWord mergeWord = self.mergeFn(skewWord & halftoneWord, self.dest.w_bits.getword(self.destIndex)) - self.dest.w_bits.setword(self.destIndex, r_uint32(mergeWord)) + self.dest.w_bits.setword(self.destIndex, mergeWord) self.destIndex += hInc # last word with masking and all if (self.nWords > 1): @@ -507,7 +507,7 @@ destWord = self.dest.w_bits.getword(self.destIndex) mergeWord = self.mergeFn(skewWord & halftoneWord, destWord) destWord = (destMask & mergeWord) | (destWord & (~destMask)) - self.dest.w_bits.setword(self.destIndex, r_uint32(destWord)) + self.dest.w_bits.setword(self.destIndex, destWord) self.destIndex += hInc self.sourceIndex += self.sourceDelta self.destIndex += self.destDelta @@ -521,7 +521,6 @@ @objectmodel.specialize.arg_or_var(3) def merge(self, source_word, dest_word, combinationRule): - # assert isinstance(source_word, r_uint) and isinstance(dest_word, r_uint) if combinationRule == 0: return 0 elif combinationRule == 1: diff --git a/spyvm/plugins/fileplugin.py b/spyvm/plugins/fileplugin.py --- a/spyvm/plugins/fileplugin.py +++ b/spyvm/plugins/fileplugin.py @@ -154,6 +154,6 @@ def smalltalk_timestamp(space, sec_since_epoch): import time from spyvm.primitives import secs_between_1901_and_1970 - from rpython.rlib.rarithmetic import r_uint32 as r_uint - sec_since_1901 = r_uint(int(sec_since_epoch + secs_between_1901_and_1970)) + from rpython.rlib.rarithmetic import r_uint + sec_since_1901 = r_uint(sec_since_epoch + secs_between_1901_and_1970) return space.wrap_uint(sec_since_1901) diff --git a/spyvm/primitives.py b/spyvm/primitives.py --- a/spyvm/primitives.py +++ b/spyvm/primitives.py @@ -5,11 +5,11 @@ from spyvm import model, shadow from spyvm import constants, display from spyvm.error import PrimitiveFailedError, \ - PrimitiveNotYetWrittenError + PrimitiveNotYetWrittenError, WrappingError from spyvm import wrapper from rpython.rlib import rarithmetic, rfloat, unroll, jit -from rpython.rlib.rarithmetic import r_uint32, r_uint +from rpython.rlib.rarithmetic import r_uint def assert_bounds(n0, minimum, maximum): if not minimum <= n0 < maximum: @@ -247,9 +247,9 @@ # #bitShift: -- return the shifted value @expose_primitive(BIT_SHIFT, unwrap_spec=[object, int]) def func(interp, s_frame, receiver, argument): - # from rpython.rlib.rarithmetic import LONG_BIT + from rpython.rlib.rarithmetic import LONG_BIT # XXX: 32-bit images only! - LONG_BIT = 32 + # LONG_BIT = 32 if -LONG_BIT < argument < LONG_BIT: # overflow-checking done in lshift implementations if argument > 0: @@ -296,21 +296,16 @@ return w_res make_func(op) -# XXX: 32-bit only -def ovfcheck_float_to_int(x): - from rpython.rlib.rfloat import isnan - if isnan(x): - raise OverflowError - if -2147483649.0 < x < 2147483648.0: - return int(x) - raise OverflowError - @expose_primitive(FLOAT_TRUNCATED, unwrap_spec=[float]) def func(interp, s_frame, f): try: - return interp.space.wrap_int(ovfcheck_float_to_int(f)) + integer = rarithmetic.ovfcheck_float_to_int(f) except OverflowError: raise PrimitiveFailedError + try: + return interp.space.wrap_int(integer) # in 64bit VMs, this may fail + except WrappingError: + raise PrimitiveFailedError @expose_primitive(FLOAT_TIMES_TWO_POWER, unwrap_spec=[float, int]) def func(interp, s_frame, rcvr, arg): @@ -1043,7 +1038,7 @@ sec_since_epoch = r_uint(int(time.time())) # XXX: overflow check necessary? sec_since_1901 = sec_since_epoch + secs_between_1901_and_1970 - return interp.space.wrap_uint(r_uint32(sec_since_1901)) + return interp.space.wrap_uint(r_uint(sec_since_1901)) #____________________________________________________________________________ @@ -1085,12 +1080,9 @@ raise PrimitiveFailedError for i in xrange(w_arg.size()): w_arg.setchar(i, chr(new_value)) - elif isinstance(w_arg, model.W_WordsObject): + elif isinstance(w_arg, model.W_WordsObject) or isinstance(w_arg, model.W_DisplayBitmap): for i in xrange(w_arg.size()): - w_arg.setword(i, new_value) - elif isinstance(w_arg, model.W_DisplayBitmap): - for i in xrange(w_arg.size()): - w_arg.setword(i, r_uint32(new_value)) + w_arg.setword(i, r_uint(new_value)) else: raise PrimitiveFailedError return w_arg diff --git a/spyvm/shadow.py b/spyvm/shadow.py --- a/spyvm/shadow.py +++ b/spyvm/shadow.py @@ -2,7 +2,6 @@ from spyvm import model, constants, error, wrapper from rpython.tool.pairtype import extendabletype from rpython.rlib import rarithmetic, jit -from rpython.rlib.rarithmetic import r_uint def make_elidable_after_versioning(func): @@ -650,7 +649,7 @@ self._temps_and_stack = [None] * (stacksize + tempsize) for i in range(tempsize): self._temps_and_stack[i] = self.space.w_nil - self._stack_ptr = r_uint(tempsize) # we point after the last element + self._stack_ptr = rarithmetic.r_uint(tempsize) # we point after the last element # ______________________________________________________________________ # Stack Manipulation @@ -683,11 +682,11 @@ return self.peek(0) def set_top(self, value, position=0): - rpos = r_uint(position) + rpos = rarithmetic.r_uint(position) self._temps_and_stack[self._stack_ptr + ~rpos] = value def peek(self, idx): - rpos = r_uint(idx) + rpos = rarithmetic.r_uint(idx) return self._temps_and_stack[jit.promote(self._stack_ptr) + ~rpos] @jit.unroll_safe diff --git a/spyvm/squeakimage.py b/spyvm/squeakimage.py --- a/spyvm/squeakimage.py +++ b/spyvm/squeakimage.py @@ -558,7 +558,7 @@ return bytes[:stop] # omit odd bytes def get_ruints(self, required_len=-1): - from rpython.rlib.rarithmetic import r_uint32 as r_uint + from rpython.rlib.rarithmetic import r_uint words = [r_uint(x) for x in self.chunk.data] if required_len != -1 and len(words) != required_len: raise CorruptImageError("Expected %d words, got %d" % (required_len, len(words))) _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit