[pypy-svn] r65108 - in pypy/branch/pyjitpl5/pypy/jit/metainterp: . test
antocuni at codespeak.net
antocuni at codespeak.net
Wed May 6 17:40:22 CEST 2009
Author: antocuni
Date: Wed May 6 17:40:21 2009
New Revision: 65108
Modified:
pypy/branch/pyjitpl5/pypy/jit/metainterp/codewriter.py
pypy/branch/pyjitpl5/pypy/jit/metainterp/heaptracker.py
pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_virtualizable.py
pypy/branch/pyjitpl5/pypy/jit/metainterp/virtualizable.py
Log:
port jit support for virtualizables to ootype. Some tests are still failing
Modified: pypy/branch/pyjitpl5/pypy/jit/metainterp/codewriter.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/metainterp/codewriter.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/metainterp/codewriter.py Wed May 6 17:40:21 2009
@@ -11,7 +11,7 @@
from pypy.tool.udir import udir
from pypy.translator.simplify import get_funcobj, get_functype
from pypy.translator.backendopt.canraise import RaiseAnalyzer
-from pypy.jit.metainterp.typesystem import deref, arrayItem
+from pypy.jit.metainterp.typesystem import deref, arrayItem, fieldType
import py, sys
from pypy.tool.ansi_print import ansi_log
@@ -1152,9 +1152,9 @@
pass # for now
def serialize_op_promote_virtualizable(self, op):
- STRUCTTYPE = op.args[0].concretetype.TO
+ STRUCTTYPE = deref(op.args[0].concretetype)
argname = op.args[1].value
- FIELDTYPE = getattr(STRUCTTYPE, argname)
+ FIELDTYPE = fieldType(STRUCTTYPE, argname)
if FIELDTYPE != lltype.Void:
TOPSTRUCT = heaptracker.cast_vable_type(STRUCTTYPE)
metainterp_sd = self.codewriter.metainterp_sd
Modified: pypy/branch/pyjitpl5/pypy/jit/metainterp/heaptracker.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/metainterp/heaptracker.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/metainterp/heaptracker.py Wed May 6 17:40:21 2009
@@ -28,7 +28,13 @@
STRUCT = cast_vable_type(T.TO)
return lltype.cast_pointer(lltype.Ptr(STRUCT), p)
-def cast_vable_type(STRUCT):
+def cast_vable_type(STRUCT_OR_INST):
+ if isinstance(STRUCT_OR_INST, ootype.Instance):
+ return cast_vable_type_instance(STRUCT_OR_INST)
+ else:
+ return cast_vable_type_struct(STRUCT_OR_INST)
+
+def cast_vable_type_struct(STRUCT):
assert STRUCT._hints.get('virtualizable2'), \
"not a virtualizable2: %r" % (STRUCT,)
while True:
@@ -38,6 +44,17 @@
STRUCT = PARENT
return STRUCT
+def cast_vable_type_instance(INSTANCE):
+ assert INSTANCE._hints.get('virtualizable2'), \
+ "not a virtualizable2: %r" % (INSTANCE,)
+ while True:
+ PARENT = INSTANCE._superclass
+ if PARENT is None or not PARENT._hints.get('virtualizable2'):
+ break
+ INSTANCE = PARENT
+ return INSTANCE
+
+
def get_vtable_for_gcstruct(cpu, GCSTRUCT):
# xxx hack: from a GcStruct representing an instance's
# lowleveltype, return the corresponding vtable pointer.
Modified: pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_virtualizable.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_virtualizable.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_virtualizable.py Wed May 6 17:40:21 2009
@@ -608,10 +608,20 @@
self.check_loops(getfield_gc=0, setfield_gc=0, call=0)
-##class TestOOtype(ExplicitVirtualizableTests,
-## ImplicitVirtualizableTests,
-## OOJitMixin):
-## pass
+class TestOOtype(ExplicitVirtualizableTests,
+ ImplicitVirtualizableTests,
+ OOJitMixin):
+
+ def skip(self):
+ py.test.skip('in-progress')
+
+ test_virtual_on_virtualizable = skip
+ test_no_virtual_on_virtualizable = skip
+ test_virtualizable_hierarchy = skip
+ test_non_virtual_on_always_virtual = skip
+ test_external_pass = skip
+ test_pass_always_virtual_to_bridge = skip
+
class TestLLtype(ExplicitVirtualizableTests,
ImplicitVirtualizableTests,
Modified: pypy/branch/pyjitpl5/pypy/jit/metainterp/virtualizable.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/metainterp/virtualizable.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/metainterp/virtualizable.py Wed May 6 17:40:21 2009
@@ -1,6 +1,8 @@
from pypy.jit.metainterp import history
+from pypy.jit.metainterp.typesystem import llhelper, oohelper
from pypy.rpython.lltypesystem import lltype, llmemory
+from pypy.rpython.ootypesystem import ootype
from pypy.rpython.annlowlevel import llhelper, cast_base_ptr_to_instance
from pypy.annotation.model import lltype_to_annotation
from pypy.rlib.objectmodel import we_are_translated
@@ -10,11 +12,20 @@
def __init__(self, cpu, TOPSTRUCT, STRUCTTYPE):
"NOT_RPYTHON"
- self.virtuals = [cpu.fielddescrof(STRUCTTYPE, 'inst_' + name) for
- name in TOPSTRUCT._hints['virtuals']]
+ if cpu.is_oo:
+ prefix = 'o'
+ else:
+ prefix = 'inst_'
+ self.virtuals = [cpu.fielddescrof(STRUCTTYPE, prefix+name)
+ for name in TOPSTRUCT._hints['virtuals']]
self.fields = self.catch_all_fields(cpu, STRUCTTYPE)
def catch_all_fields(self, cpu, S):
+ if isinstance(S, ootype.OOType):
+ return self.catch_all_fields_ootype(cpu, S)
+ return self.catch_all_fields_lltype(cpu, S)
+
+ def catch_all_fields_lltype(self, cpu, S):
lst = []
p = S
while True:
@@ -26,3 +37,6 @@
return [cpu.fielddescrof(S, name) for name in lst if
name.startswith('inst_') and hasattr(S, name)]
+ def catch_all_fields_ootype(self, cpu, S):
+ lst = S._allfields().keys()
+ return [cpu.fielddescrof(S, name) for name in lst]
More information about the Pypy-commit
mailing list