[pypy-svn] r53978 - in pypy/branch/jit-hotpath/pypy/jit: codegen/i386/test codegen/ia32/test codegen/llgraph codegen/llvm/test rainbow rainbow/test
antocuni at codespeak.net
antocuni at codespeak.net
Mon Apr 21 19:26:24 CEST 2008
Author: antocuni
Date: Mon Apr 21 19:26:23 2008
New Revision: 53978
Modified:
pypy/branch/jit-hotpath/pypy/jit/codegen/i386/test/test_genc_portal.py
pypy/branch/jit-hotpath/pypy/jit/codegen/ia32/test/test_genc_portal.py
pypy/branch/jit-hotpath/pypy/jit/codegen/llgraph/llimpl.py
pypy/branch/jit-hotpath/pypy/jit/codegen/llvm/test/test_genc_portal.py
pypy/branch/jit-hotpath/pypy/jit/rainbow/portal.py
pypy/branch/jit-hotpath/pypy/jit/rainbow/test/test_interpreter.py
pypy/branch/jit-hotpath/pypy/jit/rainbow/test/test_llinterp.py
pypy/branch/jit-hotpath/pypy/jit/rainbow/test/test_portal.py
Log:
port test_portal to ootype, first tests pass
Modified: pypy/branch/jit-hotpath/pypy/jit/codegen/i386/test/test_genc_portal.py
==============================================================================
--- pypy/branch/jit-hotpath/pypy/jit/codegen/i386/test/test_genc_portal.py (original)
+++ pypy/branch/jit-hotpath/pypy/jit/codegen/i386/test/test_genc_portal.py Mon Apr 21 19:26:23 2008
@@ -93,7 +93,7 @@
class TestPortal(I386PortalTestMixin,
- test_portal.TestPortal):
+ test_portal.TestPortalLLType):
# for the individual tests see
# ====> ../../../rainbow/test/test_portal.py
Modified: pypy/branch/jit-hotpath/pypy/jit/codegen/ia32/test/test_genc_portal.py
==============================================================================
--- pypy/branch/jit-hotpath/pypy/jit/codegen/ia32/test/test_genc_portal.py (original)
+++ pypy/branch/jit-hotpath/pypy/jit/codegen/ia32/test/test_genc_portal.py Mon Apr 21 19:26:23 2008
@@ -93,7 +93,7 @@
class TestPortal(I386PortalTestMixin,
- test_portal.TestPortal):
+ test_portal.TestPortalLLType):
# for the individual tests see
# ====> ../../../rainbow/test/test_portal.py
Modified: pypy/branch/jit-hotpath/pypy/jit/codegen/llgraph/llimpl.py
==============================================================================
--- pypy/branch/jit-hotpath/pypy/jit/codegen/llgraph/llimpl.py (original)
+++ pypy/branch/jit-hotpath/pypy/jit/codegen/llgraph/llimpl.py Mon Apr 21 19:26:23 2008
@@ -7,7 +7,7 @@
from pypy.rpython.lltypesystem import lltype, llmemory, rtupletype as llrtupletype
from pypy.rpython.ootypesystem import ootype, rtupletype as oortupletype
from pypy.objspace.flow import model as flowmodel
-from pypy.translator.simplify import eliminate_empty_blocks
+from pypy.translator.simplify import eliminate_empty_blocks, get_funcobj
from pypy.translator.unsimplify import varoftype
from pypy.rpython.module.support import LLSupport, OOSupport
from pypy.rpython.extregistry import ExtRegistryEntry
@@ -75,13 +75,19 @@
casting_link(graph.prereturnblock, [v1], graph.returnblock)
substartblock = flowmodel.Block(erasedinputargs)
casting_link(graph.startblock, inputargs, substartblock)
- fptr = lltype.functionptr(FUNCTYPE, name,
- graph=graph)
+ if isinstance(FUNCTYPE, lltype.FuncType):
+ fptr = lltype.functionptr(FUNCTYPE, name,
+ graph=graph)
+ else:
+ assert isinstance(FUNCTYPE, ootype.StaticMethod)
+ fptr = ootype.static_meth(FUNCTYPE, name,
+ graph=graph)
return genconst(fptr)
def _getgraph(gv_func):
- graph = _from_opaque(gv_func).value._obj.graph
- return graph
+ fnptr = _from_opaque(gv_func).value
+ graph = get_funcobj(fnptr).graph
+ return graph
def end(gv_func):
graph = _getgraph(gv_func)
Modified: pypy/branch/jit-hotpath/pypy/jit/codegen/llvm/test/test_genc_portal.py
==============================================================================
--- pypy/branch/jit-hotpath/pypy/jit/codegen/llvm/test/test_genc_portal.py (original)
+++ pypy/branch/jit-hotpath/pypy/jit/codegen/llvm/test/test_genc_portal.py Mon Apr 21 19:26:23 2008
@@ -9,7 +9,7 @@
RGenOp = RLLVMGenOp
class TestPortal(LLVMPortalTestMixin,
- test_portal.TestPortal):
+ test_portal.TestPortalLLType):
# for the individual tests see
# ====> ../../../timeshifter/test/test_portal.py
Modified: pypy/branch/jit-hotpath/pypy/jit/rainbow/portal.py
==============================================================================
--- pypy/branch/jit-hotpath/pypy/jit/rainbow/portal.py (original)
+++ pypy/branch/jit-hotpath/pypy/jit/rainbow/portal.py Mon Apr 21 19:26:23 2008
@@ -1,11 +1,13 @@
from pypy.jit.hintannotator.model import originalconcretetype
from pypy.jit.timeshifter import rvalue, rcontainer
+from pypy.jit.rainbow import typesystem
from pypy.objspace.flow import model as flowmodel
from pypy.rlib.objectmodel import we_are_translated
from pypy.rlib.unroll import unrolling_iterable
from pypy.rpython.annlowlevel import llhelper, cachedtype
from pypy.rpython.llinterp import LLInterpreter
from pypy.rpython.lltypesystem import lltype, llmemory
+from pypy.translator.simplify import get_funcobj
# graph transformations for transforming the portal graph(s)
class PortalRewriter(object):
@@ -17,6 +19,11 @@
self.codewriter = codewriter
self.RGenOp = RGenOp
self.translate_support_code = translate_support_code
+ if rtyper.type_system.name == 'lltypesystem':
+ self.ts = typesystem.llhelper
+ else:
+ self.ts = typesystem.oohelper
+
def rewrite(self, origportalgraph, portalgraph, view=False):
self.origportalgraph = origportalgraph
@@ -25,7 +32,8 @@
self.readportalgraph = None
self.make_args_specification()
self.PortalState = make_state_class(
- self.args_specification, self.RESIDUAL_FUNCTYPE, self.sigtoken,
+ self.args_specification, self.RESIDUAL_FUNCTYPE,
+ self.PTR_RESIDUAL_FUNCTYPE, self.sigtoken,
self.codewriter.all_graphs[self.portalgraph],
self.rtyper,
self.codewriter)
@@ -51,8 +59,8 @@
ARGS.extend(argdesc.residual_argtypes())
args_specification.append(arg_spec)
self.args_specification = args_specification
- self.RESIDUAL_FUNCTYPE = lltype.FuncType(ARGS, RESTYPE)
- self.PORTAL_FUNCTYPE = lltype.FuncType(ORIGARGS, RESTYPE)
+ self.RESIDUAL_FUNCTYPE, self.PTR_RESIDUAL_FUNCTYPE = self.ts.get_FuncType(ARGS, RESTYPE)
+ self.PORTAL_FUNCTYPE, self.PTR_PORTAL_FUNCTYPE = self.ts.get_FuncType(ORIGARGS, RESTYPE)
self.sigtoken = self.RGenOp.sigToken(self.RESIDUAL_FUNCTYPE)
def make_state_instance(self):
@@ -68,7 +76,7 @@
if not self.translate_support_code:
# this case is used for most tests: the jit stuff should be run
# directly to make these tests faster
- portal_entry_graph_ptr = llhelper(lltype.Ptr(self.PORTAL_FUNCTYPE),
+ portal_entry_graph_ptr = llhelper(self.PTR_PORTAL_FUNCTYPE,
self.portal_entry)
else:
# this translates portal_entry into low-level graphs, recursively
@@ -79,7 +87,7 @@
from pypy.annotation import model as annmodel
annhelper = annlowlevel.MixLevelHelperAnnotator(self.rtyper)
FUNC = self.PORTAL_FUNCTYPE
- RESFUNC = self.RESIDUAL_FUNCTYPE
+ PTR_RESFUNC = self.PTR_RESIDUAL_FUNCTYPE
args_s = [annmodel.lltype_to_annotation(ARG) for ARG in FUNC.ARGS]
s_result = annmodel.lltype_to_annotation(FUNC.RESULT)
self.portal_entry_graph = annhelper.getgraph(
@@ -92,14 +100,15 @@
return state.get_residual_fnptr()
self.get_residual_fnptr_graph = annhelper.getgraph(
ll_get_residual_fnptr, [],
- annmodel.lltype_to_annotation(lltype.Ptr(RESFUNC)))
+ annmodel.lltype_to_annotation(PTR_RESFUNC))
annhelper.finish()
# the following gives a pdb prompt when portal_entry raises an exception
- portal_entry_graph_ptr._obj.__dict__['_debugexc'] = True
+ fnobj = get_funcobj(portal_entry_graph_ptr)
+ fnobj.__dict__['_debugexc'] = True
# XXX hack hack hack
args = [flowmodel.Constant(portal_entry_graph_ptr,
- lltype.Ptr(self.PORTAL_FUNCTYPE))]
+ self.PTR_PORTAL_FUNCTYPE)]
args += self.origportalgraph.getargs()
result = flowmodel.Variable()
result.concretetype = self.origportalgraph.getreturnvar().concretetype
@@ -119,11 +128,12 @@
else:
residual_graph_ptr = llinterp.eval_graph(
self.get_residual_fnptr_graph, [])
- residual_graph = residual_graph_ptr._obj.graph
+ residual_graph = get_funcobj(residual_graph_ptr).graph
return residual_graph
-def make_state_class(args_specification, RESIDUAL_FUNCTYPE, sigtoken,
+def make_state_class(args_specification, RESIDUAL_FUNCTYPE,
+ PTR_RESIDUAL_FUNCTYPE, sigtoken,
portal_jitcode, rtyper, codewriter):
args_specification = unrolling_iterable(args_specification)
class PortalState(object):
@@ -194,12 +204,12 @@
gv_generated = self.compile(key, *args)
residualargs = self.make_residualargs(*args)
- fn = gv_generated.revealconst(lltype.Ptr(RESIDUAL_FUNCTYPE))
+ fn = gv_generated.revealconst(PTR_RESIDUAL_FUNCTYPE)
if not we_are_translated():
# run the generated code on top of the llinterp for testing
exc_data_ptr = codewriter.exceptiondesc.exc_data_ptr
llinterp = LLInterpreter(rtyper, exc_data_ptr=exc_data_ptr)
- res = llinterp.eval_graph(fn._obj.graph, residualargs)
+ res = llinterp.eval_graph(get_funcobj(fn).graph, residualargs)
return res
else:
return fn(*residualargs)
@@ -289,11 +299,11 @@
gv_generated = cache[key]
except KeyError:
return lltype.nullptr(RESIDUAL_FUNCTYPE)
- fn = gv_generated.revealconst(lltype.Ptr(RESIDUAL_FUNCTYPE))
+ fn = gv_generated.revealconst(PTR_RESIDUAL_FUNCTYPE)
return fn
def readallportals(self):
- return [gv_gen.revealconst(lltype.Ptr(RESIDUAL_FUNCTYPE))
+ return [gv_gen.revealconst(PTR_RESIDUAL_FUNCTYPE)
for gv_gen in self.cache.values()]
def get_residual_fnptr(self):
Modified: pypy/branch/jit-hotpath/pypy/jit/rainbow/test/test_interpreter.py
==============================================================================
--- pypy/branch/jit-hotpath/pypy/jit/rainbow/test/test_interpreter.py (original)
+++ pypy/branch/jit-hotpath/pypy/jit/rainbow/test/test_interpreter.py Mon Apr 21 19:26:23 2008
@@ -1,6 +1,6 @@
import py
from pypy.translator.translator import TranslationContext, graphof
-from pypy.translator.simplify import simplify_graph
+from pypy.translator.simplify import simplify_graph, get_funcobj
from pypy.jit.codegen.llgraph.rgenop import RGenOp as LLRGenOp
from pypy.jit.hintannotator.annotator import HintAnnotator
from pypy.jit.hintannotator.policy import StopAtXPolicy, HintAnnotatorPolicy
@@ -229,8 +229,8 @@
if jitstate is not None:
writer.interpreter.finish_jitstate(sigtoken)
builder.end()
- generated = gv_generated.revealconst(lltype.Ptr(self.RESIDUAL_FUNCTYPE))
- graph = generated._obj.graph
+ generated = gv_generated.revealconst(self.Ptr(self.RESIDUAL_FUNCTYPE))
+ graph = get_funcobj(generated).graph
self.residual_graph = graph
if conftest.option.view:
graph.show()
Modified: pypy/branch/jit-hotpath/pypy/jit/rainbow/test/test_llinterp.py
==============================================================================
--- pypy/branch/jit-hotpath/pypy/jit/rainbow/test/test_llinterp.py (original)
+++ pypy/branch/jit-hotpath/pypy/jit/rainbow/test/test_llinterp.py Mon Apr 21 19:26:23 2008
@@ -7,7 +7,7 @@
-class TestLLInterpreted(test_portal.TestPortal):
+class TestLLInterpreted(test_portal.TestPortalLLType):
translate_support_code = True
# for the individual tests see
Modified: pypy/branch/jit-hotpath/pypy/jit/rainbow/test/test_portal.py
==============================================================================
--- pypy/branch/jit-hotpath/pypy/jit/rainbow/test/test_portal.py (original)
+++ pypy/branch/jit-hotpath/pypy/jit/rainbow/test/test_portal.py Mon Apr 21 19:26:23 2008
@@ -82,7 +82,7 @@
return calls
-class TestPortal(PortalTest):
+class BaseTestPortal(PortalTest):
type_system = "lltype"
def test_simple(self):
@@ -601,3 +601,25 @@
res = self.timeshift_from_portal(ll_function, ll_function, [])
assert res == ll_function()
self.check_insns({})
+
+
+
+class TestPortalOOType(BaseTestPortal):
+ type_system = 'ootype'
+
+ def _skip(self):
+ py.test.skip('in progress')
+
+ test_dfa_compile2 = _skip
+ test_dfa_compile3 = _skip
+ test_method_call_nonpromote = _skip
+ test_method_call_promote = _skip
+ test_float_promote = _skip
+ test_isinstance = _skip
+ test_greenmethod_call_nonpromote = _skip
+ test_virt_obj_method_call_promote = _skip
+ test_simple_recursive_portal_call_with_exc = _skip
+
+class TestPortalLLType(BaseTestPortal):
+ type_system = 'lltype'
+
More information about the pypy-svn
mailing list