[pypy-svn] r40554 - in pypy/branch/jit-virtual-world/pypy: interpreter jit/goal objspace/std translator/goal
arigo at codespeak.net
arigo at codespeak.net
Thu Mar 15 19:24:01 CET 2007
Author: arigo
Date: Thu Mar 15 19:23:57 2007
New Revision: 40554
Modified:
pypy/branch/jit-virtual-world/pypy/interpreter/function.py
pypy/branch/jit-virtual-world/pypy/interpreter/gateway.py
pypy/branch/jit-virtual-world/pypy/jit/goal/jitstep.py
pypy/branch/jit-virtual-world/pypy/objspace/std/multimethod.py
pypy/branch/jit-virtual-world/pypy/objspace/std/objspace.py
pypy/branch/jit-virtual-world/pypy/objspace/std/typeobject.py
pypy/branch/jit-virtual-world/pypy/translator/goal/ann_override.py
Log:
(same guys)
Enough hints to produce good code (yay! yay! yay!) from a Python function
that does nothing else but a chain of additions between integers.
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 Thu Mar 15 19:23:57 2007
@@ -10,6 +10,7 @@
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:
@@ -36,26 +37,31 @@
return self.code.funcrun(self, args) # delegate activation to 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
if len(args_w) == 0:
- w_res = self.code.fastcall_0(self.space, self)
+ w_res = code.fastcall_0(self.space, self)
if w_res is not None:
return w_res
elif len(args_w) == 1:
- w_res = self.code.fastcall_1(self.space, self, args_w[0])
+ w_res = code.fastcall_1(self.space, self, args_w[0])
if w_res is not None:
return w_res
elif len(args_w) == 2:
- w_res = self.code.fastcall_2(self.space, self, args_w[0],
+ w_res = code.fastcall_2(self.space, self, args_w[0],
args_w[1])
if w_res is not None:
return w_res
elif len(args_w) == 3:
- w_res = self.code.fastcall_3(self.space, self, args_w[0],
+ w_res = code.fastcall_3(self.space, self, args_w[0],
args_w[1], args_w[2])
if w_res is not None:
return w_res
elif len(args_w) == 4:
- w_res = self.code.fastcall_4(self.space, self, args_w[0],
+ w_res = code.fastcall_4(self.space, self, args_w[0],
args_w[1], args_w[2], args_w[3])
if w_res is not None:
return w_res
Modified: pypy/branch/jit-virtual-world/pypy/interpreter/gateway.py
==============================================================================
--- pypy/branch/jit-virtual-world/pypy/interpreter/gateway.py (original)
+++ pypy/branch/jit-virtual-world/pypy/interpreter/gateway.py Thu Mar 15 19:23:57 2007
@@ -19,6 +19,7 @@
from pypy.interpreter.baseobjspace import Wrappable, SpaceCache, DescrMismatch
from pypy.interpreter.argument import Arguments, AbstractArguments
from pypy.tool.sourcetools import NiceCompile, compile2
+from pypy.rlib.objectmodel import hint
# internal non-translatable parts:
import py
@@ -520,6 +521,7 @@
class BuiltinCode0(BuiltinCode):
def fastcall_0(self, space, w_func):
+ self = hint(self, deepfreeze=True)
try:
w_result = self.fastfunc_0(space)
except KeyboardInterrupt:
@@ -535,6 +537,7 @@
class BuiltinCode1(BuiltinCode):
def fastcall_1(self, space, w_func, w1):
+ self = hint(self, deepfreeze=True)
try:
w_result = self.fastfunc_1(space, w1)
except KeyboardInterrupt:
@@ -555,6 +558,7 @@
class BuiltinCode2(BuiltinCode):
def fastcall_2(self, space, w_func, w1, w2):
+ self = hint(self, deepfreeze=True)
try:
w_result = self.fastfunc_2(space, w1, w2)
except KeyboardInterrupt:
@@ -575,6 +579,7 @@
class BuiltinCode3(BuiltinCode):
def fastcall_3(self, space, func, w1, w2, w3):
+ self = hint(self, deepfreeze=True)
try:
w_result = self.fastfunc_3(space, w1, w2, w3)
except KeyboardInterrupt:
@@ -595,6 +600,7 @@
class BuiltinCode4(BuiltinCode):
def fastcall_4(self, space, func, w1, w2, w3, w4):
+ self = hint(self, deepfreeze=True)
try:
w_result = self.fastfunc_4(space, w1, w2, w3, w4)
except KeyboardInterrupt:
Modified: pypy/branch/jit-virtual-world/pypy/jit/goal/jitstep.py
==============================================================================
--- pypy/branch/jit-virtual-world/pypy/jit/goal/jitstep.py (original)
+++ pypy/branch/jit-virtual-world/pypy/jit/goal/jitstep.py Thu Mar 15 19:23:57 2007
@@ -118,7 +118,8 @@
seepath(pypy.objspace.descroperation._invoke_binop,
pypy.objspace.descroperation._check_notimplemented)
seepath(pypy.objspace.descroperation.DescrOperation.add,
- pypy.objspace.std.Space.type)
+ pypy.objspace.std.Space.type,
+ pypy.objspace.std.Space.gettypeobject)
#seepath(pypy.objspace.descroperation.DescrOperation.xxx,
# pypy.objspace.std.typeobject.W_TypeObject.lookup,
# pypy.objspace.std.typeobject.W_TypeObject.getdictvalue_w)
@@ -126,7 +127,9 @@
pypy.objspace.std.typeobject.W_TypeObject.lookup_where,
pypy.objspace.std.typeobject.W_TypeObject.getdictvalue_w)
seepath(pypy.objspace.std.typeobject.W_TypeObject.lookup_where,
- is_heaptype)
+ pypy.objspace.std.typeobject.W_TypeObject.is_heaptype)
+ seepath(pypy.objspace.descroperation.DescrOperation.add,
+ pypy.objspace.std.Space.is_w)
dontsee(pypy.interpreter.pyframe.PyFrame.execute_frame)
# --------------------
Modified: pypy/branch/jit-virtual-world/pypy/objspace/std/multimethod.py
==============================================================================
--- pypy/branch/jit-virtual-world/pypy/objspace/std/multimethod.py (original)
+++ pypy/branch/jit-virtual-world/pypy/objspace/std/multimethod.py Thu Mar 15 19:23:57 2007
@@ -749,9 +749,9 @@
attrname = self.mrdtable.attrname
exprfn = "%d" % master_index
for n in range(self.multimethod.arity-1):
- exprfn = "indexarray.items[%s + arg%d.%s]" % (exprfn, n, attrname)
+ exprfn = "hint(indexarray.items, deepfreeze=True)[%s + arg%d.%s]" % (exprfn, n, attrname)
n = self.multimethod.arity-1
- exprfn = "funcarray.items[(%s + arg%d.%s) & mmmask]" % (exprfn, n,
+ exprfn = "hint(funcarray.items, deepfreeze=True)[(%s + arg%d.%s) & mmmask]" % (exprfn, n,
attrname)
expr = Call(exprfn, self.fnargs)
entry = self.build_funcentry([self.prefix, '0_perform_call'],
@@ -794,6 +794,8 @@
bodylines.append(' pass')
bodylines.append('return %s' % expr(calllist[-1]))
+ from pypy.rlib.objectmodel import hint
+ miniglobals['hint'] = hint
entry = FuncEntry(bodylines, miniglobals, fallback)
key = entry.key()
try:
Modified: pypy/branch/jit-virtual-world/pypy/objspace/std/objspace.py
==============================================================================
--- pypy/branch/jit-virtual-world/pypy/objspace/std/objspace.py (original)
+++ pypy/branch/jit-virtual-world/pypy/objspace/std/objspace.py Thu Mar 15 19:23:57 2007
@@ -13,7 +13,7 @@
from pypy.objspace.descroperation import DescrOperation
from pypy.objspace.std import stdtypedef
from pypy.rlib.rarithmetic import base_int
-from pypy.rlib.objectmodel import we_are_translated
+from pypy.rlib.objectmodel import we_are_translated, hint
import sys
import os
import __builtin__
@@ -463,6 +463,7 @@
return W_SeqIterObject(w_obj)
def type(self, w_obj):
+ hint(w_obj.__class__, promote=True)
return w_obj.getclass(self)
def lookup(self, w_obj, name):
Modified: pypy/branch/jit-virtual-world/pypy/objspace/std/typeobject.py
==============================================================================
--- pypy/branch/jit-virtual-world/pypy/objspace/std/typeobject.py (original)
+++ pypy/branch/jit-virtual-world/pypy/objspace/std/typeobject.py Thu Mar 15 19:23:57 2007
@@ -6,7 +6,7 @@
from pypy.objspace.std.stdtypedef import std_dict_descr, issubtypedef, Member
from pypy.objspace.std.objecttype import object_typedef
from pypy.objspace.std.dictproxyobject import W_DictProxyObject
-from pypy.rlib.objectmodel import we_are_translated
+from pypy.rlib.objectmodel import we_are_translated, hint
from copy_reg import _HEAPTYPE
@@ -387,6 +387,7 @@
raise UnwrapError(w_self)
def is_heaptype(w_self):
+ w_self = hint(w_self, deepfreeze=True)
return w_self.__flags__&_HEAPTYPE
def get_module(w_self):
Modified: pypy/branch/jit-virtual-world/pypy/translator/goal/ann_override.py
==============================================================================
--- pypy/branch/jit-virtual-world/pypy/translator/goal/ann_override.py (original)
+++ pypy/branch/jit-virtual-world/pypy/translator/goal/ann_override.py Thu Mar 15 19:23:57 2007
@@ -152,16 +152,20 @@
return
CACHED_LOOKUP = """
+from pypy.rlib.objectmodel import hint
def lookup_%(attr)s(space, w_obj, name):
w_type = space.type(w_obj)
if not w_type.is_heaptype():
+ w_type = hint(w_type, deepfreeze=True)
return w_type.cached_%(attr)s
return w_type.lookup("%(attr)s")
"""
CACHED_LOOKUP_IN_TYPE_WHERE = """
+from pypy.rlib.objectmodel import hint
def lookup_in_type_where_%(attr)s(space, w_type, name):
if not w_type.is_heaptype():
+ w_type = hint(w_type, deepfreeze=True)
return w_type.cached_where_%(attr)s
return w_type.lookup_where("%(attr)s")
"""
More information about the Pypy-commit
mailing list