[pypy-svn] r66237 - in pypy/branch/pyjitpl5/pypy/jit: backend backend/llgraph metainterp metainterp/test
antocuni at codespeak.net
antocuni at codespeak.net
Wed Jul 15 16:17:20 CEST 2009
Author: antocuni
Date: Wed Jul 15 16:17:18 2009
New Revision: 66237
Modified:
pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/llimpl.py
pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/runner.py
pypy/branch/pyjitpl5/pypy/jit/backend/model.py
pypy/branch/pyjitpl5/pypy/jit/metainterp/pyjitpl.py
pypy/branch/pyjitpl5/pypy/jit/metainterp/resoperation.py
pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_basic.py
Log:
implement subclassof for ootype jit
Modified: pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/llimpl.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/llimpl.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/llimpl.py Wed Jul 15 16:17:18 2009
@@ -91,6 +91,7 @@
'oois' : (('ptr', 'ptr'), 'bool'),
'ooisnot' : (('ptr', 'ptr'), 'bool'),
'instanceof' : (('ptr',), 'bool'),
+ 'subclassof' : (('ptr', 'ptr'), 'bool'),
'setfield_gc' : (('ptr', 'intorptr'), None),
'getfield_gc' : (('ptr',), 'intorptr'),
'getfield_gc_pure': (('ptr',), 'intorptr'),
@@ -767,6 +768,9 @@
inst = ootype.cast_from_object(ootype.ROOT, obj)
return ootype.instanceof(inst, typedescr.TYPE)
+ def op_subclassof(self, *args):
+ raise NotImplementedError
+
def _cast_exception(self, exception):
return ootype.cast_from_object(ootype.Class, exception)
Modified: pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/runner.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/runner.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/runner.py Wed Jul 15 16:17:18 2009
@@ -469,6 +469,14 @@
assert len(args) == 1
return typedescr.instanceof(args[0])
+ def do_subclassof(self, args, descr):
+ assert len(args) == 2
+ box1, box2 = args
+ cls1 = ootype.cast_from_object(ootype.Class, box1.getobj())
+ cls2 = ootype.cast_from_object(ootype.Class, box2.getobj())
+ res = ootype.subclassof(cls1, cls2)
+ return history.BoxInt(res)
+
def do_getfield_gc(self, args, fielddescr):
assert isinstance(fielddescr, FieldDescr)
return fielddescr.getfield(args[0])
Modified: pypy/branch/pyjitpl5/pypy/jit/backend/model.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/backend/model.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/backend/model.py Wed Jul 15 16:17:18 2009
@@ -171,3 +171,6 @@
def do_instanceof(self, args, descr=None):
raise NotImplementedError
+
+ def do_subclassof(self, args, descr=None):
+ raise NotImplementedError
Modified: pypy/branch/pyjitpl5/pypy/jit/metainterp/pyjitpl.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/metainterp/pyjitpl.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/metainterp/pyjitpl.py Wed Jul 15 16:17:18 2009
@@ -322,6 +322,10 @@
def opimpl_instanceof(self, box, typedescr):
self.execute(rop.INSTANCEOF, [box], descr=typedescr)
+ @arguments("box", "box")
+ def opimpl_subclassof(self, box1, box2):
+ self.execute(rop.SUBCLASSOF, [box1, box2], descr=None)
+
@arguments("box")
def opimpl_ooidentityhash(self, box):
self.execute(rop.OOIDENTITYHASH, [box], descr=None)
Modified: pypy/branch/pyjitpl5/pypy/jit/metainterp/resoperation.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/metainterp/resoperation.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/metainterp/resoperation.py Wed Jul 15 16:17:18 2009
@@ -168,9 +168,10 @@
# ootype operations
OOIDENTITYHASH = 85
INSTANCEOF = 86
- OOSEND_PURE = 87
+ SUBCLASSOF = 87
+ OOSEND_PURE = 88
#
- _ALWAYS_PURE_LAST = 87 # ----- end of always_pure operations -----
+ _ALWAYS_PURE_LAST = 88 # ----- end of always_pure operations -----
GETARRAYITEM_GC = 120
GETFIELD_GC = 121
Modified: pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_basic.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_basic.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_basic.py Wed Jul 15 16:17:18 2009
@@ -729,6 +729,7 @@
self.meta_interp(f, [40, 0])
+
class TestOOtype(BasicTests, OOJitMixin):
def test_oohash(self):
@@ -779,6 +780,27 @@
def test_r_dict(self):
py.test.skip('in-progress')
+
+ def test_subclassof(self):
+ A = ootype.Instance("A", ootype.ROOT)
+ B = ootype.Instance("B", A)
+ clsA = ootype.runtimeClass(A)
+ clsB = ootype.runtimeClass(B)
+ def f(n):
+ if n:
+ obj = ootype.ooupcast(A, ootype.new(B))
+ else:
+ obj = ootype.new(A)
+ cls = ootype.classof(obj)
+ return ootype.subclassof(cls, clsB)
+
+ res = self.interp_operations(f, [True])
+ assert res
+ res = self.interp_operations(f, [False])
+ assert not res
+
+
+
class TestLLtype(BasicTests, LLJitMixin):
def test_oops_on_nongc(self):
More information about the Pypy-commit
mailing list