[pypy-svn] r31741 - in pypy/dist/pypy/jit: codegen/i386 codegen/i386/test codegen/llgraph timeshifter
ac at codespeak.net
ac at codespeak.net
Sun Aug 27 18:08:30 CEST 2006
Author: ac
Date: Sun Aug 27 18:08:29 2006
New Revision: 31741
Modified:
pypy/dist/pypy/jit/codegen/i386/ri386genop.py
pypy/dist/pypy/jit/codegen/i386/test/test_interp_ts.py
pypy/dist/pypy/jit/codegen/llgraph/rgenop.py
pypy/dist/pypy/jit/timeshifter/rcontainer.py
pypy/dist/pypy/jit/timeshifter/rtimeshift.py
Log:
(arre, pedronis)
start refactoring along the lines of:
genop('getfield', ...) -> genop_getfield((T, name),...)
for operations with special void/type arguments.
Modified: pypy/dist/pypy/jit/codegen/i386/ri386genop.py
==============================================================================
--- pypy/dist/pypy/jit/codegen/i386/ri386genop.py (original)
+++ pypy/dist/pypy/jit/codegen/i386/ri386genop.py Sun Aug 27 18:08:29 2006
@@ -116,6 +116,11 @@
return genmethod(args_gv, gv_RESTYPE)
genop._annspecialcase_ = 'specialize:arg(1)'
+ def genop_getfield(self, (T, name), gv_ptr):
+ offset = self.rgenop.offsetscomp.offsetof(T, name)
+ return self.emit_getfield(gv_ptr, offset)
+ genop_getfield._annspecialcase_ = 'specialize:arg(1)'
+
def close1(self):
return Link(self)
@@ -246,10 +251,8 @@
self.mc.MOVZX(eax, al)
return self.push(eax)
- def op_getfield(self, (gv_ptr, gv_offset), gv_RESTYPE):
+ def emit_getfield(self, gv_ptr, offset):
# XXX only for int fields
- assert isinstance(gv_offset, IntConst)
- offset = gv_offset.value
self.mc.MOV(edx, gv_ptr.operand(self))
return self.push(mem(edx, offset))
@@ -392,7 +395,8 @@
class RI386GenOp(AbstractRGenOp):
from pypy.jit.codegen.i386.codebuf import MachineCodeBlock
-
+ from pypy.rpython.lltypesystem import llmemory as offsetscomp
+
gv_IntWord = TypeConst('IntWord')
gv_Void = TypeConst('Void')
@@ -458,3 +462,4 @@
prologue.mc.JMP(rel32(block.startaddr))
self.close_mc(prologue.mc)
return FnPtrConst(prologue.startaddr, prologue.mc)
+
Modified: pypy/dist/pypy/jit/codegen/i386/test/test_interp_ts.py
==============================================================================
--- pypy/dist/pypy/jit/codegen/i386/test/test_interp_ts.py (original)
+++ pypy/dist/pypy/jit/codegen/i386/test/test_interp_ts.py Sun Aug 27 18:08:29 2006
@@ -10,10 +10,23 @@
def __eq__(self, other):
return True
+class OffsetComp(object):
+
+ def offsetof(T, name):
+ return list(T._names).index(name)
+ offsetof._annspecialcase_ = 'specialize:memo'
+ offsetof = staticmethod(offsetof)
+
+ def _freeze_(self):
+ return True
+
+_RI386GenOp = type('RI386GenOp', RI386GenOp.__bases__, dict(RI386GenOp.__dict__.iteritems()))
+del _RI386GenOp.offsetscomp
class TestTimeshiftI386LLInterp(test_timeshift.TestTimeshift):
- class RGenOp(RI386GenOp):
+ class RGenOp(_RI386GenOp):
from pypy.jit.codegen.i386.codebuf import LLTypeMachineCodeBlock as MachineCodeBlock
+ offsetscomp = OffsetComp()
def constFieldName(T, name):
return IntConst(list(T._names).index(name))
Modified: pypy/dist/pypy/jit/codegen/llgraph/rgenop.py
==============================================================================
--- pypy/dist/pypy/jit/codegen/llgraph/rgenop.py (original)
+++ pypy/dist/pypy/jit/codegen/llgraph/rgenop.py Sun Aug 27 18:08:29 2006
@@ -34,6 +34,13 @@
(gv_RESULT_TYPE or gv_Void).v))
genop._annspecialcase_ = 'specialize:arg(1)'
+ def genop_getfield(self, (T, name), gv_ptr):
+ vars_gv = [gv_ptr.v, llimpl.constFieldName(name)]
+ gv_RESULT = llimpl.constTYPE(getattr(T, name))
+ return LLVar(llimpl.genop(self.b, 'getfield', vars_gv,
+ gv_RESULT))
+ genop_getfield._annspecialcase_ = 'specialize:arg(1)'
+
def close1(self):
return LLLink(llimpl.closeblock1(self.b))
Modified: pypy/dist/pypy/jit/timeshifter/rcontainer.py
==============================================================================
--- pypy/dist/pypy/jit/timeshifter/rcontainer.py (original)
+++ pypy/dist/pypy/jit/timeshifter/rcontainer.py Sun Aug 27 18:08:29 2006
@@ -128,7 +128,8 @@
self.gv_resulttype = RGenOp.constTYPE(RES1)
self.fieldname = fieldname
self.fieldname_gv = [RGenOp.constFieldName(T, component)
- for T, component in accessors]
+ for T, component in accessors] # XXX kill me
+ self.accessors = accessors
self.fieldindex = index
self.gv_default = RGenOp.constPrebuiltGlobal(RES1._defl())
self.redboxcls = rvalue.ll_redboxcls(RES1)
Modified: pypy/dist/pypy/jit/timeshifter/rtimeshift.py
==============================================================================
--- pypy/dist/pypy/jit/timeshifter/rtimeshift.py (original)
+++ pypy/dist/pypy/jit/timeshifter/rtimeshift.py Sun Aug 27 18:08:29 2006
@@ -90,10 +90,8 @@
return rvalue.ll_fromvalue(jitstate, res)
assert isinstance(argbox, rvalue.PtrRedBox)
if argbox.content is None:
- op_args = [argbox.getgenvar(jitstate.curbuilder),
- fielddesc.fieldname_gv[-1]]
- genvar = jitstate.curbuilder.genop('getfield', op_args,
- fielddesc.gv_resulttype)
+ genvar = jitstate.curbuilder.genop_getfield(fielddesc.accessors[-1],
+ argbox.getgenvar(jitstate.curbuilder))
return fielddesc.redboxcls(fielddesc.gv_resulttype, genvar)
else:
return argbox.content.op_getfield(jitstate, fielddesc)
@@ -315,6 +313,10 @@
return self.block.genop(opname, args_gv, gv_resulttype)
genop._annspecialcase_ = 'specialize:arg(1)'
+ def genop_getfield(self, accessor, gv_ptr):
+ return self.block.genop_getfield(accessor, gv_ptr)
+ genop_getfield._annspecialcase_ = 'specialize:arg(1)'
+
def constTYPE(self, T):
return self.rgenop.constTYPE(T)
constTYPE._annspecialcase_ = 'specialize:arg(1)'
More information about the Pypy-commit
mailing list