Author: Tim Felgentreff <[email protected]>
Branch:
Changeset: r582:2d567611e3c6
Date: 2014-01-16 14:11 +0100
http://bitbucket.org/pypy/lang-smalltalk/changeset/2d567611e3c6/
Log: make all tests green again
diff --git a/spyvm/constants.py b/spyvm/constants.py
--- a/spyvm/constants.py
+++ b/spyvm/constants.py
@@ -1,3 +1,4 @@
+import time
from rpython.rlib.jit import elidable
from spyvm.tool.bitmanipulation import splitter
@@ -186,3 +187,4 @@
MAX_LOOP_DEPTH = 100
INTERRUPT_COUNTER_SIZE = 10000
+CompileTime = int(time.time() * 1000)
diff --git a/spyvm/interpreter.py b/spyvm/interpreter.py
--- a/spyvm/interpreter.py
+++ b/spyvm/interpreter.py
@@ -43,7 +43,10 @@
self.space = space
self.image = image
self.image_name = image_name
- self.startup_time = time.time()
+ if image:
+ self.startup_time = image.startup_time
+ else:
+ self.startup_time = constants.CompileTime
self.max_stack_depth = max_stack_depth
self.remaining_stack_depth = max_stack_depth
self._loop = False
@@ -204,7 +207,7 @@
def time_now(self):
import time
from rpython.rlib.rarithmetic import intmask
- return intmask(int((time.time() - self.startup_time) * 1000) &
constants.TAGGED_MASK)
+ return intmask((int(time.time() * 1000) - self.startup_time) &
constants.TAGGED_MASK)
def padding(self, symbol=' '):
return symbol * (self.max_stack_depth - self.remaining_stack_depth)
diff --git a/spyvm/primitives.py b/spyvm/primitives.py
--- a/spyvm/primitives.py
+++ b/spyvm/primitives.py
@@ -645,8 +645,18 @@
@expose_primitive(BITBLT_COPY_BITS, clean_stack=False, no_result=True,
compiled_method=True)
def func(interp, s_frame, argcount, s_method):
- from spyvm.plugins.bitblt import BitBltPlugin
- return BitBltPlugin.call("primitiveCopyBits", interp, s_frame, argcount,
s_method)
+ from spyvm.interpreter import Return
+ try:
+ s_frame._sendSelfSelector(interp.image.w_simulateCopyBits, 0, interp)
+ except Return:
+ w_dest_form = w_rcvr.fetch(space, 0)
+ if w_dest_form.is_same_object(space.objtable['w_display']):
+ w_bitmap = w_dest_form.fetch(space, 0)
+ assert isinstance(w_bitmap, model.W_DisplayBitmap)
+ w_bitmap.flush_to_screen()
+ except shadow.MethodNotFound:
+ from spyvm.plugins.bitblt import BitBltPlugin
+ BitBltPlugin.call("primitiveCopyBits", interp, s_frame, argcount,
s_method)
@expose_primitive(BE_CURSOR)
def func(interp, s_frame, argcount):
diff --git a/spyvm/squeakimage.py b/spyvm/squeakimage.py
--- a/spyvm/squeakimage.py
+++ b/spyvm/squeakimage.py
@@ -1,6 +1,7 @@
import py
import os
import sys
+import time
from spyvm import constants
from spyvm import model
from spyvm.tool.bitmanipulation import splitter
@@ -377,6 +378,7 @@
self.version = reader.version
self.is_modern = reader.version.magic > 6502
self.run_spy_hacks(space)
+ self.startup_time = int(time.time() * 1000)
def run_spy_hacks(self, space):
pass
diff --git a/spyvm/test/test_bitblt.py b/spyvm/test/test_bitblt.py
--- a/spyvm/test/test_bitblt.py
+++ b/spyvm/test/test_bitblt.py
@@ -1,4 +1,5 @@
from spyvm import model, shadow, constants, interpreter, objspace
+from spyvm.plugins import bitblt
space = objspace.ObjSpace()
@@ -37,7 +38,7 @@
def test_bitBlt_values():
w_bb = model.W_PointersObject(space, space.w_Array, 15)
- w_bb.store(space, 0, make_form([], 1230, 20, 1))
+ w_bb.store(space, 0, make_form([0] * 1230 * 20, 1230, 20, 1))
w_bb.store(space, 1, w_bb.fetch(space, 0))
w_bb.store(space, 2, space.w_nil)
@@ -54,25 +55,26 @@
w_bb.store(space, 13, w(15)) # clip height
w_bb.store(space, 14, model.W_PointersObject(space, space.w_Array, 5)) #
color map
- s_bb = w_bb.as_bitblt_get_shadow(space)
- s_bb.clip_range()
- assert not (s_bb.w <= 0 or s_bb.h <= 0)
- s_bb.compute_masks()
- s_bb.check_overlap()
- s_bb.calculate_offsets()
+ s_bb = w_bb.as_special_get_shadow(space, bitblt.BitBltShadow)
+ s_bb.loadBitBlt()
+ s_bb.clipRange()
+ assert not (s_bb.width <= 0 or s_bb.height <= 0)
+ s_bb.destMaskAndPointerInit()
+ s_bb.checkSourceOverlap()
+ s_bb.sourceSkewAndPointerInit()
- assert s_bb.dest_x == 1
- assert s_bb.dest_y == 0
- assert s_bb.sx == 1218
- assert s_bb.sy == 0
- assert s_bb.dx == 1219
- assert s_bb.dy == 0
- assert s_bb.w == 1219
- assert s_bb.h == 15
- assert s_bb.h_dir == -1
- assert s_bb.v_dir == 1
- assert s_bb.source_delta == 79
- assert s_bb.dest_delta == 78
+ assert s_bb.destX == 1
+ assert s_bb.destY == 0
+ assert s_bb.sourceX == 0
+ assert s_bb.sourceY == 0
+ assert s_bb.destX == 1
+ assert s_bb.destY == 0
+ assert s_bb.width == 1220
+ assert s_bb.height == 15
+ assert s_bb.hDir == -1
+ assert s_bb.vDir == 1
+ assert s_bb.sourceDelta == 79
+ assert s_bb.destDelta == 78
assert s_bb.skew == 31
- assert s_bb.source_index == 38
- assert s_bb.dest_index == 38
\ No newline at end of file
+ assert s_bb.sourceIndex == 38
+ assert s_bb.destIndex == 38
diff --git a/spyvm/test/test_model.py b/spyvm/test/test_model.py
--- a/spyvm/test/test_model.py
+++ b/spyvm/test/test_model.py
@@ -367,14 +367,14 @@
assert bin(target.getword(0)) == bin(0x00FF00FF)
target.setword(0, r_uint(0xFF00FF00))
assert bin(target.getword(0)) == bin(0xFF00FF00)
- for i in xrange(8):
- assert target.pixelbuffer[i] == 0xff000000
- for i in xrange(8, 16):
- assert target.pixelbuffer[i] == 0xffffffff
- for i in xrange(16, 24):
- assert target.pixelbuffer[i] == 0xff000000
- for i in xrange(24, 32):
- assert target.pixelbuffer[i] == 0xffffffff
+ for i in xrange(2):
+ assert target.pixelbuffer[i] == 0x01010101
+ for i in xrange(2, 4):
+ assert target.pixelbuffer[i] == 0x0
+ for i in xrange(4, 6):
+ assert target.pixelbuffer[i] == 0x01010101
+ for i in xrange(6, 8):
+ assert target.pixelbuffer[i] == 0x0
def test_display_offset_computation():
@@ -387,9 +387,9 @@
dbitmap = model.W_DisplayBitmap.create(space, space.w_Array, 5, 1, d)
- assert dbitmap.compute_pos_and_line_end(0, 1) == (0, 18)
- assert dbitmap.compute_pos_and_line_end(1, 1) == (18, 36)
- assert dbitmap.size() == 5
+ assert dbitmap.compute_pos(0) == 0
+ assert dbitmap.compute_pos(1) == 8
+ assert dbitmap.size() == 5 * 8
@py.test.mark.skipif("socket.gethostname() == 'precise32'")
def test_weak_pointers():
diff --git a/spyvm/test/test_primitives.py b/spyvm/test/test_primitives.py
--- a/spyvm/test/test_primitives.py
+++ b/spyvm/test/test_primitives.py
@@ -4,6 +4,7 @@
from spyvm.primitives import prim_table, PrimitiveFailedError
from spyvm import model, shadow, interpreter
from spyvm import constants, primitives, objspace, wrapper, display
+from spyvm.plugins import bitblt
from rpython.rlib.rfloat import INFINITY, NAN, isinf, isnan
@@ -776,7 +777,7 @@
class DisplayFlush(Exception):
pass
- def flush_to_screen_mock(self):
+ def flush_to_screen_mock(self, force=False):
raise DisplayFlush
try:
@@ -810,7 +811,7 @@
try:
monkeypatch.setattr(w_frame._shadow, "_sendSelfSelector", perform_mock)
- monkeypatch.setattr(shadow.BitBltShadow, "sync_cache", sync_cache_mock)
+ monkeypatch.setattr(bitblt.BitBltShadow, "sync_cache", sync_cache_mock)
with py.test.raises(CallCopyBitsSimulation):
prim_table[primitives.BITBLT_COPY_BITS](interp,
w_frame.as_context_get_shadow(space), argument_count-1)
finally:
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit