[pypy-svn] r56414 - in pypy/branch/oo-jit/pypy/jit/rainbow: . test
antocuni at codespeak.net
antocuni at codespeak.net
Thu Jul 10 15:21:36 CEST 2008
Author: antocuni
Date: Thu Jul 10 15:21:33 2008
New Revision: 56414
Modified:
pypy/branch/oo-jit/pypy/jit/rainbow/codewriter.py
pypy/branch/oo-jit/pypy/jit/rainbow/interpreter.py
pypy/branch/oo-jit/pypy/jit/rainbow/test/test_interpreter.py
pypy/branch/oo-jit/pypy/jit/rainbow/test/test_promotion.py
Log:
make sure to remember x.__class__ after a promote_class.
Right now it's a complete hack on ootype, but since these things will
change as soon as we merge the less-meta-instances branch, it's not
worth to spend more time on it.
Modified: pypy/branch/oo-jit/pypy/jit/rainbow/codewriter.py
==============================================================================
--- pypy/branch/oo-jit/pypy/jit/rainbow/codewriter.py (original)
+++ pypy/branch/oo-jit/pypy/jit/rainbow/codewriter.py Thu Jul 10 15:21:33 2008
@@ -1001,10 +1001,17 @@
check=False)
fielddescindex = self.fielddesc_position(self.OBJECT,
self.classfieldname)
+ # hack hack hack, which will go away when we merge less-meta-instances
+ if self.__class__.__name__ == 'OOTypeBytecodeWriter':
+ fielddescindex2 = self.fielddesc_position(v_obj.concretetype, 'meta')
+ else:
+ fielddescindex2 = fielddescindex
+
self.emit("assert_class")
self.emit(self.serialize_oparg("red", v_obj))
self.emit(g_class)
self.emit(fielddescindex)
+ self.emit(fielddescindex2)
self.register_redvar(result)
Modified: pypy/branch/oo-jit/pypy/jit/rainbow/interpreter.py
==============================================================================
--- pypy/branch/oo-jit/pypy/jit/rainbow/interpreter.py (original)
+++ pypy/branch/oo-jit/pypy/jit/rainbow/interpreter.py Thu Jul 10 15:21:33 2008
@@ -629,12 +629,16 @@
assert gv_switchvar.is_const
self.green_result(gv_switchvar)
- @arguments("red", "green", "fielddesc", returns="red")
- def opimpl_assert_class(self, objbox, gv_class, fielddesc):
+ @arguments("red", "green", "fielddesc", "fielddesc", returns="red")
+ def opimpl_assert_class(self, objbox, gv_class, fielddesc, fielddesc2):
if isinstance(objbox.content, rcontainer.VirtualStruct):
return objbox
classbox = self.PtrRedBox(gv_class)
objbox.remember_field(fielddesc, classbox)
+
+ # hack hack, see comments in codewriter.py
+ if fielddesc2 != fielddesc:
+ objbox.remember_field(fielddesc2, classbox)
return objbox
@arguments()
Modified: pypy/branch/oo-jit/pypy/jit/rainbow/test/test_interpreter.py
==============================================================================
--- pypy/branch/oo-jit/pypy/jit/rainbow/test/test_interpreter.py (original)
+++ pypy/branch/oo-jit/pypy/jit/rainbow/test/test_interpreter.py Thu Jul 10 15:21:33 2008
@@ -300,11 +300,12 @@
assert oops.get(name, 0) == count
def check_flexswitches(self, expected_count):
+ from pypy.rpython.ootypesystem import rclass
residual_graph = self.get_residual_graph()
count = 0
for block in residual_graph.iterblocks():
if (isinstance(block.exitswitch, Variable) and
- block.exitswitch.concretetype is lltype.Signed):
+ block.exitswitch.concretetype in (lltype.Signed, rclass.CLASSTYPE)):
count += 1
assert count == expected_count
@@ -2307,6 +2308,7 @@
replace = {
'getfield': 'oogetfield',
'setfield': 'oosetfield',
+ 'malloc': 'new',
}
insns = insns.copy()
Modified: pypy/branch/oo-jit/pypy/jit/rainbow/test/test_promotion.py
==============================================================================
--- pypy/branch/oo-jit/pypy/jit/rainbow/test/test_promotion.py (original)
+++ pypy/branch/oo-jit/pypy/jit/rainbow/test/test_promotion.py Thu Jul 10 15:21:33 2008
@@ -497,7 +497,7 @@
res = self.interpret(ll_function, [20, True], [], policy=StopAtXPolicy(make_obj))
assert res == 42
self.check_insns(malloc=0)
- self.check_insns(new=0)
+ self.check_flexswitches(3)
def test_promote_class_vstruct(self):
class A:
@@ -511,7 +511,25 @@
res = self.interpret(ll_function, [], [])
assert res == 42
self.check_insns(malloc=0)
- self.check_insns(new=0)
+
+ def test_read___class___after_promotion(self):
+ class A:
+ pass
+ class B(A):
+ pass
+
+ def make_obj(flag):
+ return flag and A() or B()
+
+ def ll_function(flag):
+ hint(None, global_merge_point=True)
+ obj = make_obj(flag)
+ promoted_obj = hint(obj, promote_class=True)
+ cls = promoted_obj.__class__
+ return cls is A
+
+ res = self.interpret(ll_function, [True], [], policy=StopAtXPolicy(make_obj))
+ self.check_flexswitches(2)
class TestLLType(BaseTestPromotion):
type_system = "lltype"
More information about the Pypy-commit
mailing list