[pypy-svn] r26338 - in pypy/dist/pypy: rpython translator translator/c
mwh at codespeak.net
mwh at codespeak.net
Tue Apr 25 16:51:45 CEST 2006
Author: mwh
Date: Tue Apr 25 16:51:42 2006
New Revision: 26338
Modified:
pypy/dist/pypy/rpython/extfunctable.py
pypy/dist/pypy/translator/c/extfunc.py
pypy/dist/pypy/translator/translator.py
Log:
(mwh, some soothing words from cfbolz when life got too frustrating)
some avoidance of annotating helpers for external functions when the said
external functions will not be called. this isn't what i wanted to do, what i
wanted to do was to annotate the helper's code at the same time as annotating
the calling function but that lead to insanity.
Modified: pypy/dist/pypy/rpython/extfunctable.py
==============================================================================
--- pypy/dist/pypy/rpython/extfunctable.py (original)
+++ pypy/dist/pypy/rpython/extfunctable.py Tue Apr 25 16:51:42 2006
@@ -119,7 +119,15 @@
# _____________________________________________________________
-
+def record_call(func, args_s, symbol):
+ from pypy.annotation import bookkeeper
+ bk = bookkeeper.getbookkeeper()
+ # this would be nice!
+ #bk.pbc_call(bk.immutablevalue(func),
+ # bk.build_args("simple_call", args_s),
+ # emulated=True)
+ bk.annotator.translator._implicitly_called_by_externals.append(
+ (func, args_s, symbol))
def noneannotation(*args):
return None
@@ -130,14 +138,20 @@
def statannotation(*args):
from pypy.annotation.model import SomeInteger, SomeTuple
+ from pypy.rpython.module.ll_os import ll_stat_result
+ record_call(ll_stat_result, [SomeInteger()]*10, 'OS_STAT')
return SomeTuple((SomeInteger(),)*10)
def frexpannotation(*args):
from pypy.annotation.model import SomeInteger, SomeTuple, SomeFloat
+ from pypy.rpython.module.ll_math import ll_frexp_result
+ record_call(ll_frexp_result, (SomeFloat(), SomeInteger()), 'MATH_FREXP')
return SomeTuple((SomeFloat(), SomeInteger()))
def modfannotation(*args):
from pypy.annotation.model import SomeTuple, SomeFloat
+ from pypy.rpython.module.ll_math import ll_modf_result
+ record_call(ll_modf_result, (SomeFloat(), SomeFloat()), 'MATH_MODF')
return SomeTuple((SomeFloat(), SomeFloat()))
def strnullannotation(*args):
Modified: pypy/dist/pypy/translator/c/extfunc.py
==============================================================================
--- pypy/dist/pypy/translator/c/extfunc.py (original)
+++ pypy/dist/pypy/translator/c/extfunc.py Tue Apr 25 16:51:42 2006
@@ -126,48 +126,22 @@
def get_extfunc_helper_ptrs(db, rtyper, optimize=True):
- # XXX need some way of finding out if the externals needing have
- # been annotated -- db.externalfuncs gets filled out by
- # select_function_code_generator which is called from
- # FuncNode.__init__ (probably...) which is after this gets called.
- optimize = False
- def annotate(func, *argtypes):
- fptr = rtyper.annotate_helper(func, argtypes)
+
+ def annotate(func, args):
+ fptr = rtyper.annotate_helper(func, args)
db.helper2ptr[func] = fptr
return (func.__name__, fptr)
- r = []
-
- if ll_math.ll_math_frexp in db.externalfuncs or not optimize:
- r.append(annotate(ll_math.ll_frexp_result, lltype.Float, lltype.Signed))
-
- if ll_math.ll_math_modf in db.externalfuncs or not optimize:
- r.append(annotate(ll_math.ll_modf_result, lltype.Float, lltype.Float))
-
- if (ll_os.ll_os_stat in db.externalfuncs or
- ll_os.ll_os_fstat in db.externalfuncs or
- not optimize):
- r.append(annotate(ll_os.ll_stat_result, *([lltype.Signed] * 10)))
-
- return r
+ for func, args, symb in db.translator._implicitly_called_by_externals:
+ yield annotate(func, args)
def predeclare_extfunc_helpers(db, rtyper, optimize=True):
- def decl(f):
- return (f.__name__, db.helper2ptr[f])
-
- if ll_math.ll_math_frexp in db.externalfuncs or not optimize:
- yield decl(ll_math.ll_frexp_result)
- yield ('LL_NEED_MATH_FREXP', 1)
-
- if ll_math.ll_math_modf in db.externalfuncs or not optimize:
- yield decl(ll_math.ll_modf_result)
- yield ('LL_NEED_MATH_MODF', 1)
-
- if (ll_os.ll_os_stat in db.externalfuncs or
- ll_os.ll_os_fstat in db.externalfuncs or
- not optimize):
- yield decl(ll_os.ll_stat_result)
- yield ('LL_NEED_OS_STAT', 1)
+ def decl(func):
+ return (func.__name__, db.helper2ptr[func])
+
+ for func, args, symb in db.translator._implicitly_called_by_externals:
+ yield decl(func)
+ yield ('LL_NEED_' + symb, 1)
def predeclare_extfuncs(db, rtyper, optimize=True):
modules = {}
Modified: pypy/dist/pypy/translator/translator.py
==============================================================================
--- pypy/dist/pypy/translator/translator.py (original)
+++ pypy/dist/pypy/translator/translator.py Tue Apr 25 16:51:42 2006
@@ -34,6 +34,8 @@
self.callgraph = {} # {opaque_tag: (caller-graph, callee-graph)}
self._prebuilt_graphs = {} # only used by the pygame viewer
+ self._implicitly_called_by_externals = []
+
def buildflowgraph(self, func):
"""Get the flow graph for a function."""
if not isinstance(func, types.FunctionType):
More information about the Pypy-commit
mailing list