Author: Tim Felgentreff <[email protected]>
Branch:
Changeset: r38:6a1de2f8b293
Date: 2013-02-18 15:59 +0100
http://bitbucket.org/pypy/lang-smalltalk/changeset/6a1de2f8b293/
Log: (cfbolz, timfel) shadow invalidation on atput0 and atliteralput0
diff --git a/spyvm/model.py b/spyvm/model.py
--- a/spyvm/model.py
+++ b/spyvm/model.py
@@ -596,6 +596,7 @@
self.setheader(header)
else:
self.literals[index0-1] = w_value
+ self._shadow = None
def store(self, space, index0, w_v):
self.atput0(space, index0, w_v)
@@ -628,6 +629,7 @@
def setchar(self, index0, character):
assert index0 >= 0
self.bytes[index0] = character
+ self._shadow = None
# Use black magic to create w_nil without running the constructor,
# thus allowing it to be used even in the constructor of its own
diff --git a/spyvm/shadow.py b/spyvm/shadow.py
--- a/spyvm/shadow.py
+++ b/spyvm/shadow.py
@@ -712,3 +712,4 @@
def __init__(self, w_compiledmethod):
self.w_compiledmethod = w_compiledmethod
self.bytecode = "".join(w_compiledmethod.bytes)
+ self.literals = w_compiledmethod.literals
diff --git a/spyvm/test/test_shadow.py b/spyvm/test/test_shadow.py
--- a/spyvm/test/test_shadow.py
+++ b/spyvm/test/test_shadow.py
@@ -183,7 +183,23 @@
assert w_object._shadow is s_newobject
def test_compiledmethodshadow():
- w_compiledmethod = model.W_CompiledMethod()
+ from test_model import joinbits
+ header = joinbits([0,2,0,0,0,0],[9,8,1,6,4,1])
+
+ w_compiledmethod = model.W_CompiledMethod(3, header)
w_compiledmethod.setbytes(list("abc"))
shadow = w_compiledmethod.as_compiledmethod_get_shadow(space)
assert shadow.bytecode == "abc"
+
+ w_compiledmethod.literalatput0(space, 1, 17)
+ w_compiledmethod.literalatput0(space, 2, 41)
+ assert w_compiledmethod._shadow is None
+
+ shadow = w_compiledmethod.as_compiledmethod_get_shadow(space)
+ assert shadow.literals == [17, 41]
+
+ w_compiledmethod.atput0(space, 14, space.wrap_int(ord("x")))
+ assert w_compiledmethod._shadow is None
+
+ shadow = w_compiledmethod.as_compiledmethod_get_shadow(space)
+ assert shadow.bytecode == "abx"
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit