[pypy-svn] r40598 - in pypy/branch/jit-virtual-world/pypy: interpreter module/pypyjit

pedronis at codespeak.net pedronis at codespeak.net
Fri Mar 16 18:25:39 CET 2007


Author: pedronis
Date: Fri Mar 16 18:25:36 2007
New Revision: 40598

Modified:
   pypy/branch/jit-virtual-world/pypy/interpreter/function.py
   pypy/branch/jit-virtual-world/pypy/module/pypyjit/interp_jit.py
Log:
(arigo, pedronis)

use a hook for the code to grab a *constant* object code for builtins at compile time.




Modified: pypy/branch/jit-virtual-world/pypy/interpreter/function.py
==============================================================================
--- pypy/branch/jit-virtual-world/pypy/interpreter/function.py	(original)
+++ pypy/branch/jit-virtual-world/pypy/interpreter/function.py	Fri Mar 16 18:25:36 2007
@@ -10,7 +10,6 @@
 from pypy.interpreter.baseobjspace import Wrappable
 from pypy.interpreter.eval import Code
 from pypy.interpreter.argument import Arguments, ArgumentsFromValuestack
-from pypy.rlib.objectmodel import hint
 
 class Function(Wrappable):
     """A function is a code object captured with some environment:
@@ -35,13 +34,12 @@
 
     def call_args(self, args):
         return self.code.funcrun(self, args) # delegate activation to code
+
+    def getcode(self):
+        return self.code
     
     def funccall(self, *args_w): # speed hack
-        # uuuuuuuuuuuuaaaaaaaaaaaaaaaaaaaaaaa  jit wacking
-        from pypy.interpreter.gateway import BuiltinCode
-        code = hint(self, deepfreeze=True).code
-        if not isinstance(code, BuiltinCode): code = self.code
-        # end of said uuaa
+        code = self.getcode() # hook for the jit
         if len(args_w) == 0:
             w_res = code.fastcall_0(self.space, self)
             if w_res is not None:

Modified: pypy/branch/jit-virtual-world/pypy/module/pypyjit/interp_jit.py
==============================================================================
--- pypy/branch/jit-virtual-world/pypy/module/pypyjit/interp_jit.py	(original)
+++ pypy/branch/jit-virtual-world/pypy/module/pypyjit/interp_jit.py	Fri Mar 16 18:25:36 2007
@@ -8,18 +8,19 @@
 """
 import py
 import sys
+from pypy.tool.pairtype import extendabletype
 from pypy.rlib.rarithmetic import r_uint, intmask
-from pypy.rlib.objectmodel import hint
+from pypy.rlib.objectmodel import hint, _is_early_constant
 import pypy.interpreter.pyopcode   # for side-effects
 from pypy.interpreter.pycode import PyCode, CO_VARARGS, CO_VARKEYWORDS
 from pypy.interpreter.pyframe import PyFrame
+from pypy.interpreter.function import Function
 from pypy.interpreter.pyopcode import Return, Yield
 
 
 PyCode.jit_enable = False     # new default attribute
 super_dispatch = PyFrame.dispatch
 
-
 class __extend__(PyFrame):
 
     def dispatch(self, pycode, next_instr, ec):
@@ -124,6 +125,21 @@
 
 PORTAL = PyFrame.dispatch_jit
 
+class __extend__(Function):
+    __metaclass__ = extendabletype
+
+    def getcode(self):
+        # if the self is a compile time constant and if its code
+        # is a BuiltinCode => grab and return its code as a constant
+        if _is_early_constant(self):
+            from pypy.interpreter.gateway import BuiltinCode
+            code = hint(self, deepfreeze=True).code
+            if not isinstance(code, BuiltinCode): code = self.code
+        else:
+            code = self.code
+        return code
+        
+
 # ____________________________________________________________
 #
 # Public interface



More information about the Pypy-commit mailing list