[pypy-commit] lang-smalltalk storage-refactoring-virtual-pc: graft changes from 64bit branch onto master
timfel
noreply at buildbot.pypy.org
Wed Jul 9 16:18:17 CEST 2014
Author: Tim Felgentreff <timfelgentreff at gmail.com>
Branch: storage-refactoring-virtual-pc
Changeset: r870:2eead83ddd0a
Date: 2014-02-07 13:12 +0100
http://bitbucket.org/pypy/lang-smalltalk/changeset/2eead83ddd0a/
Log: graft changes from 64bit branch onto master
diff --git a/spyvm/constants.py b/spyvm/constants.py
--- a/spyvm/constants.py
+++ b/spyvm/constants.py
@@ -146,7 +146,7 @@
"timerSemaphore" : SO_TIMER_SEMAPHORE,
}
-LONG_BIT = 32
+from rpython.rlib.rarithmetic import LONG_BIT
TAGGED_MAXINT = 2 ** (LONG_BIT - 2) - 1
TAGGED_MININT = -2 ** (LONG_BIT - 2)
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_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/interpreter.py b/spyvm/interpreter.py
--- a/spyvm/interpreter.py
+++ b/spyvm/interpreter.py
@@ -93,6 +93,7 @@
s_new_context = p.s_new_context
def loop_bytecodes(self, s_context, fresh_context=False, may_context_switch=True):
+ assert isinstance(s_context, ContextPartShadow)
if not jit.we_are_jitted() and may_context_switch:
self.quick_check_for_interrupt(s_context)
method = s_context.w_method()
diff --git a/spyvm/model.py b/spyvm/model.py
--- a/spyvm/model.py
+++ b/spyvm/model.py
@@ -15,17 +15,33 @@
that create W_PointersObjects of correct size with attached shadows.
"""
import sys, weakref
+<<<<<<< local
from spyvm import constants, error, version, storage_statistics
from spyvm.version import elidable_for_version, constant_for_version, constant_for_version_arg
+=======
+from spyvm import constants, error, system
+>>>>>>> other
from rpython.rlib import rrandom, objectmodel, jit, signature
+<<<<<<< local
from rpython.rlib.rarithmetic import intmask, r_uint, r_int
from rpython.rlib.debug import make_sure_not_resized
+=======
+from rpython.rlib.rarithmetic import intmask, r_uint32, r_uint, r_int
+>>>>>>> other
from rpython.tool.pairtype import extendabletype
from rpython.rlib.objectmodel import instantiate, compute_hash, import_from_mixin, we_are_translated
from rpython.rtyper.lltypesystem import lltype, rffi
from rsdl import RSDL, RSDL_helper
+
+if system.IS_64BIT:
+ from rpython.rlib.rarithmetic import widen
+else:
+ def widen(x):
+ return x
+
+
class W_Object(object):
"""Root of Squeak model, abstract."""
_attrs_ = [] # no RPython-level instance variables allowed in W_Object
@@ -216,7 +232,7 @@
return isinstance(self.value, int) and self.value < 0x8000
def lshift(self, space, shift):
- from rpython.rlib.rarithmetic import ovfcheck, intmask, r_uint
+ from rpython.rlib.rarithmetic import ovfcheck, intmask
# shift > 0, therefore the highest bit of upperbound is not set,
# i.e. upperbound is positive
upperbound = intmask(r_uint(-1) >> shift)
@@ -359,7 +375,6 @@
return space.wrap_int((self.value >> shift) & mask)
def unwrap_uint(self, space):
- from rpython.rlib.rarithmetic import r_uint
return r_uint(self.value)
def clone(self, space):
@@ -469,11 +484,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_uint(intmask(r >> 32)))
+ return space.wrap_uint(r_uint32(intmask(r >> 32)))
else:
# bounds-check for primitive access is done in the primitive
assert n0 == 1
- return space.wrap_uint(r_uint(intmask(r)))
+ return space.wrap_uint(r_uint32(intmask(r)))
def store(self, space, n0, w_obj):
from rpython.rlib.rstruct.ieee import float_unpack, float_pack
@@ -799,14 +814,19 @@
byte0 = ord(self.getchar(byte_index0))
byte1 = ord(self.getchar(byte_index0 + 1)) << 8
if byte1 & 0x8000 != 0:
- byte1 = intmask(r_uint(0xffff0000) | r_uint(byte1))
+ byte1 = intmask(widen(r_uint32(0xffff0000)) | widen(r_uint32(byte1)))
return space.wrap_int(byte1 | byte0)
def short_atput0(self, space, index0, w_value):
from rpython.rlib.rarithmetic import int_between
i_value = space.unwrap_int(w_value)
- if not int_between(-0x8000, i_value, 0x8000):
- raise error.PrimitiveFailedError
+ if constants.LONG_BIT == 64:
+ if (not int_between(0, i_value, 0x8000) and
+ not int_between(0, i_value ^ (0xffffffff), 0x8000)):
+ raise error.PrimitiveFailedError
+ else:
+ if not int_between(-0x8000, i_value, 0x8000):
+ raise error.PrimitiveFailedError
byte_index0 = index0 * 2
byte0 = i_value & 0xff
byte1 = (i_value & 0xff00) >> 8
@@ -938,20 +958,25 @@
else:
short = (word >> 16) & 0xffff
if short & 0x8000 != 0:
- short = r_uint(0xffff0000) | r_uint(short)
+ short = widen(r_uint32(0xffff0000)) | short
return space.wrap_int(intmask(short))
def short_atput0(self, space, index0, w_value):
from rpython.rlib.rarithmetic import int_between
i_value = space.unwrap_int(w_value)
- if not int_between(-0x8000, i_value, 0x8000):
- raise error.PrimitiveFailedError
+ if constants.LONG_BIT == 64:
+ if (not int_between(0, i_value, 0x8000) and
+ not int_between(0, i_value ^ (0xffffffff), 0x8000)):
+ raise error.PrimitiveFailedError
+ else:
+ if not int_between(-0x8000, i_value, 0x8000):
+ raise error.PrimitiveFailedError
word_index0 = index0 / 2
- word = intmask(self.getword(word_index0))
+ word = intmask(r_uint32(self.getword(word_index0)))
if index0 % 2 == 0:
- word = intmask(r_uint(word) & r_uint(0xffff0000)) | (i_value & 0xffff)
+ word = intmask(widen(r_uint32(word)) & widen(r_uint32(0xffff0000))) | (i_value & 0xffff)
else:
- word = (i_value << 16) | (word & 0xffff)
+ word = intmask(r_uint32((i_value << 16) | (word & 0xffff)))
value = r_uint(word)
self.setword(word_index0, value)
@@ -1020,11 +1045,16 @@
class W_DisplayBitmap(W_AbstractObjectWithClassReference):
_attrs_ = ['pixelbuffer', '_realsize', '_real_depth_buffer', 'display', '_depth']
+<<<<<<< local
_immutable_fields_ = ['_realsize', 'display', '_depth']
repr_classname = "W_DisplayBitmap"
pixelbuffer = None
+=======
+ _immutable_fields_ = ['_realsize', 'display', '_depth', '_real_depth_buffer']
+
+>>>>>>> other
@staticmethod
def create(space, w_class, size, depth, display):
if depth < 8:
@@ -1041,7 +1071,7 @@
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._realsize = size
self.display = display
self._depth = depth
@@ -1052,7 +1082,7 @@
def atput0(self, space, index0, w_value):
word = space.unwrap_uint(w_value)
- self.setword(index0, word)
+ self.setword(index0, r_uint(word))
def flush_to_screen(self):
self.display.flip()
@@ -1077,7 +1107,7 @@
def setword(self, n, word):
self._real_depth_buffer[n] = word
- self.display.get_pixelbuffer()[n] = word
+ self.display.get_pixelbuffer()[n] = r_uint32(word)
def is_array_object(self):
return True
@@ -1116,14 +1146,14 @@
((msb & mask) << 11)
)
- self.display.get_pixelbuffer()[n] = r_uint(lsb | (msb << 16))
+ self.display.get_pixelbuffer()[n] = r_uint32(lsb | (msb << 16))
class W_8BitDisplayBitmap(W_DisplayBitmap):
repr_classname = "W_8BitDisplayBitmap"
def setword(self, n, word):
self._real_depth_buffer[n] = word
- self.display.get_pixelbuffer()[n] = r_uint(
+ self.display.get_pixelbuffer()[n] = r_uint32(
(word >> 24) |
((word >> 8) & 0x0000ff00) |
((word << 8) & 0x00ff0000) |
@@ -1136,7 +1166,7 @@
@jit.unroll_safe
def setword(self, n, word):
self._real_depth_buffer[n] = word
- word = r_uint(word)
+ nWord = r_uint(word)
pos = self.compute_pos(n)
assert self._depth <= 4
rshift = 32 - self._depth
@@ -1145,10 +1175,10 @@
return
mapword = r_uint(0)
for i in xrange(4):
- pixel = r_uint(word) >> rshift
+ pixel = r_uint(nWord) >> rshift
mapword |= (r_uint(pixel) << (i * 8))
- word <<= self._depth
- self.display.get_pixelbuffer()[pos] = mapword
+ nWord <<= self._depth
+ self.display.get_pixelbuffer()[pos] = r_uint32(mapword)
pos += 1
def compute_pos(self, n):
diff --git a/spyvm/objspace.py b/spyvm/objspace.py
--- a/spyvm/objspace.py
+++ b/spyvm/objspace.py
@@ -1,6 +1,10 @@
import os
+<<<<<<< local
from spyvm import constants, model, shadow, wrapper, version
+=======
+from spyvm import constants, model, shadow, wrapper, system
+>>>>>>> other
from spyvm.error import UnwrappingError, WrappingError, PrimitiveFailedError
from rpython.rlib import jit, rpath
from rpython.rlib.objectmodel import instantiate, specialize
@@ -23,7 +27,7 @@
self.make_bootstrap_objects()
def find_executable(self, executable):
- if os.sep in executable or (os.name == "nt" and ":" in executable):
+ if os.sep in executable or (system.IS_WINDOWS and ":" in executable):
return executable
path = os.environ.get("PATH")
if path:
@@ -107,9 +111,8 @@
# methods for wrapping and unwrapping stuff
def wrap_int(self, val):
- from spyvm import constants
- assert isinstance(val, int)
- # we don't do tagging
+ if not isinstance(val, int):
+ raise WrappingError
return model.W_SmallInteger(val)
def wrap_uint(self, val):
diff --git a/spyvm/plugins/bitblt.py b/spyvm/plugins/bitblt.py
--- a/spyvm/plugins/bitblt.py
+++ b/spyvm/plugins/bitblt.py
@@ -17,7 +17,7 @@
raise PrimitiveFailedError("BitBlt primitive not called in BitBlt object!")
# only allow combinationRules 0-41
- combinationRule = interp.space.unwrap_positive_32bit_int(w_rcvr.fetch(interp.space, 3))
+ combinationRule = interp.space.unwrap_int(w_rcvr.fetch(interp.space, 3))
if combinationRule > 41:
raise PrimitiveFailedError("Missing combinationRule %d" % combinationRule)
diff --git a/spyvm/primitives.py b/spyvm/primitives.py
--- a/spyvm/primitives.py
+++ b/spyvm/primitives.py
@@ -5,7 +5,7 @@
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
@@ -300,9 +300,13 @@
@expose_primitive(FLOAT_TRUNCATED, unwrap_spec=[float])
def func(interp, s_frame, f):
try:
- return interp.space.wrap_int(rarithmetic.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):
@@ -647,17 +651,22 @@
def func(interp, s_frame, argcount, w_method):
from spyvm.interpreter import Return
w_rcvr = s_frame.peek(0)
- try:
- s_frame._sendSelfSelector(interp.image.w_simulateCopyBits, 0, interp)
- except Return:
- w_dest_form = w_rcvr.fetch(interp.space, 0)
- w_display = interp.space.objtable['w_display']
- if w_dest_form.is_same_object(w_display):
- w_bitmap = w_display.fetch(interp.space, 0)
- assert isinstance(w_bitmap, model.W_DisplayBitmap)
- w_bitmap.flush_to_screen()
- return w_rcvr
- except shadow.MethodNotFound:
+ w_display = interp.space.objtable['w_display']
+ if interp.space.unwrap_int(w_display.fetch(interp.space, 3)) == 1:
+ try:
+ s_frame._sendSelfSelector(interp.image.w_simulateCopyBits, 0, interp)
+ except Return:
+ w_dest_form = w_rcvr.fetch(interp.space, 0)
+ if w_dest_form.is_same_object(w_display):
+ w_bitmap = w_display.fetch(interp.space, 0)
+ assert isinstance(w_bitmap, model.W_DisplayBitmap)
+ w_bitmap.flush_to_screen()
+ return w_rcvr
+ except shadow.MethodNotFound:
+ from spyvm.plugins.bitblt import BitBltPlugin
+ BitBltPlugin.call("primitiveCopyBits", interp, s_frame, argcount, s_method)
+ return w_rcvr
+ else:
from spyvm.plugins.bitblt import BitBltPlugin
BitBltPlugin.call("primitiveCopyBits", interp, s_frame, argcount, w_method)
return w_rcvr
@@ -872,6 +881,15 @@
w_rcvr.w_class = w_arg_class
+
+if constants.LONG_BIT == 32:
+ def callIProxy(signature, interp, s_frame, argcount, s_method):
+ from spyvm.interpreter_proxy import IProxy
+ return IProxy.call(signature, interp, s_frame, argcount, s_method)
+else:
+ def callIProxy(signature, interp, s_frame, argcount, s_method):
+ raise PrimitiveFailedError
+
@expose_primitive(EXTERNAL_CALL, clean_stack=False, no_result=True, compiled_method=True)
def func(interp, s_frame, argcount, w_method):
space = interp.space
@@ -898,8 +916,12 @@
from spyvm.plugins.vmdebugging import DebuggingPlugin
return DebuggingPlugin.call(signature[1], interp, s_frame, argcount, w_method)
else:
+<<<<<<< local
from spyvm.interpreter_proxy import IProxy
return IProxy.call(signature, interp, s_frame, argcount, w_method)
+=======
+ return callIProxy(signature, interp, s_frame, argcount, s_method)
+>>>>>>> other
raise PrimitiveFailedError
@expose_primitive(COMPILED_METHOD_FLUSH_CACHE, unwrap_spec=[object])
@@ -1073,7 +1095,7 @@
sec_since_epoch = rarithmetic.r_uint(time.time())
# XXX: overflow check necessary?
sec_since_1901 = sec_since_epoch + secs_between_1901_and_1970
- return interp.space.wrap_uint(sec_since_1901)
+ return interp.space.wrap_uint(rarithmetic.r_uint(sec_since_1901))
#____________________________________________________________________________
@@ -1117,7 +1139,7 @@
w_arg.setchar(i, chr(new_value))
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)
+ w_arg.setword(i, rarithmetic.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
@@ -692,7 +692,7 @@
# === Sender ===
def store_s_sender(self, s_sender, raiseError=True):
- assert s_sender is jit.vref_None or isinstance(s_sender, jit.DirectVRef)
+ # assert s_sender is jit.vref_None or isinstance(s_sender, jit.DirectVRef)
self._s_sender = s_sender
if raiseError:
raise error.SenderChainManipulation(self)
@@ -700,12 +700,12 @@
def restore_s_sender(self, s_direct):
if self._s_sender is not jit.vref_None:
# virtual sender wasn't already cleared by e.g. mark_returned
- self._s_sender = s_direct
+ self._s_sender = jit.non_virtual_ref(s_direct)
def w_sender(self):
- if self._s_sender is None:
+ if self._s_sender is jit.vref_None:
return self.space.w_nil
- return self._s_sender.w_self()
+ return self.s_sender().w_self()
def s_sender(self):
return self._s_sender()
diff --git a/spyvm/squeakimage.py b/spyvm/squeakimage.py
--- a/spyvm/squeakimage.py
+++ b/spyvm/squeakimage.py
@@ -386,12 +386,20 @@
self.startup_time = time.time()
def run_spy_hacks(self, space):
+<<<<<<< local
pass
# w_display = space.objtable["w_display"]
# if w_display is not None and not w_display.is_nil(space):
# if space.unwrap_int(w_display.fetch(space, 3)) < 8:
# # non-native indexed color depth not well supported
# w_display.store(space, 3, space.wrap_int(8))
+=======
+ if constants.LONG_BIT == 64:
+ w_display = space.objtable["w_display"]
+ if w_display is not None and w_display is not space.w_nil:
+ if space.unwrap_int(w_display.fetch(space, 3)) < 32:
+ w_display.store(space, 3, space.wrap_int(32))
+>>>>>>> other
def find_symbol(self, space, reader, symbol):
w_dnu = self.special(constants.SO_DOES_NOT_UNDERSTAND)
diff --git a/targetimageloadingsmalltalk.py b/targetimageloadingsmalltalk.py
--- a/targetimageloadingsmalltalk.py
+++ b/targetimageloadingsmalltalk.py
@@ -6,9 +6,12 @@
from rpython.rlib import jit, rpath
from spyvm import model, interpreter, squeakimage, objspace, wrapper,\
+<<<<<<< local
error, shadow, storage_statistics, constants
+=======
+ error, shadow, system
+>>>>>>> other
from spyvm.tool.analyseimage import create_image
-from spyvm.interpreter_proxy import VirtualMachine
def print_result(w_result):
# This will also print contents of strings/symbols/numbers
@@ -253,6 +256,9 @@
# driver.config.translation.gc = "stmgc"
# driver.config.translation.gcrootfinder = "stm"
from rpython.rlib import rgc
+ driver.exe_name = "rsqueakvm"
+ if system.IS_64BIT:
+ driver.exe_name += "-64"
if hasattr(rgc, "stm_is_enabled"):
driver.config.translation.stm = True
driver.config.translation.thread = True
More information about the pypy-commit
mailing list