[pypy-svn] r67286 - pypy/branch/pyjitpl5-c/pypy/jit/backend/c
arigo at codespeak.net
arigo at codespeak.net
Fri Aug 28 18:13:19 CEST 2009
Author: arigo
Date: Fri Aug 28 18:13:18 2009
New Revision: 67286
Modified:
pypy/branch/pyjitpl5-c/pypy/jit/backend/c/compile.py
pypy/branch/pyjitpl5-c/pypy/jit/backend/c/runner.py
Log:
Start working on Ptrs; test_same_as passes.
Modified: pypy/branch/pyjitpl5-c/pypy/jit/backend/c/compile.py
==============================================================================
--- pypy/branch/pyjitpl5-c/pypy/jit/backend/c/compile.py (original)
+++ pypy/branch/pyjitpl5-c/pypy/jit/backend/c/compile.py Fri Aug 28 18:13:18 2009
@@ -1,10 +1,11 @@
-from pypy.rpython.lltypesystem import lltype, rffi
+from pypy.rpython.lltypesystem import lltype, llmemory, rffi
from pypy.tool.udir import udir
from pypy.rlib import libffi
from pypy.rlib.objectmodel import we_are_translated
from pypy.jit.metainterp import resoperation, history
from pypy.jit.metainterp.resoperation import ResOperation, rop
-from pypy.jit.metainterp.history import AbstractDescr, Box, BoxInt, BoxPtr
+from pypy.jit.metainterp.history import AbstractDescr, Box, BoxInt, BoxPtr, INT
+from pypy.jit.metainterp.history import ConstPtr
import os
@@ -14,7 +15,8 @@
class Compiler:
FUNCPTR = lltype.Ptr(lltype.FuncType([], rffi.INT))
-
+ CHARPP = lltype.Ptr(lltype.Array(llmemory.GCREF, hints={'nolength': True}))
+
def __init__(self):
self.fn_counter = 0
self.filename_counter = 0
@@ -77,7 +79,10 @@
j = 0
for arg in inputargs:
self.argname[arg] = name = 'v%d' % j
- print >> f, 'long %s=_c_jit_al[%d];' % (name, j)
+ if arg.type == INT:
+ print >> f, 'long %s=_c_jit_al[%d];' % (name, j)
+ else:
+ print >> f, 'char*%s=_c_jit_ap[%d];' % (name, j)
j += 1
if simpleloop:
print >> f, 'while(1){'
@@ -105,7 +110,9 @@
handle = libffi.dlopen(fn, libffi.RTLD_GLOBAL | libffi.RTLD_NOW)
if self.c_jit_al is None:
c_jit_al = libffi.dlsym(handle, "_c_jit_al")
+ c_jit_ap = libffi.dlsym(handle, "_c_jit_ap")
self.c_jit_al = rffi.cast(rffi.LONGP, c_jit_al)
+ self.c_jit_ap = rffi.cast(self.CHARPP, c_jit_ap)
if funcname is not None:
c_func = libffi.dlsym(handle, funcname)
loop._c_jit_func = rffi.cast(self.FUNCPTR, c_func)
@@ -120,8 +127,10 @@
def vexpr(self, v):
if isinstance(v, Box):
return self.argname[v]
+ elif isinstance(v, ConstPtr):
+ return str(rffi.cast(lltype.Signed, v.value))
else:
- return str(v.get_())
+ return str(v.getint())
def generate(self, f, op, expr):
if op.result is None:
@@ -182,7 +191,11 @@
def generate_failure(self, f, op, return_expr):
assert op.opnum == rop.FAIL
for j in range(len(op.args)):
- print >> f, '_c_jit_al[%d]=%s;' % (j, self.vexpr(op.args[j]))
+ box = op.args[j]
+ if box.type == INT:
+ print >> f, '_c_jit_al[%d]=%s;' % (j, self.vexpr(box))
+ else:
+ print >> f, '_c_jit_ap[%d]=%s;' % (j, self.vexpr(box))
print >> f, 'return %s;' % return_expr
def generate_guard(self, f, op, expr):
Modified: pypy/branch/pyjitpl5-c/pypy/jit/backend/c/runner.py
==============================================================================
--- pypy/branch/pyjitpl5-c/pypy/jit/backend/c/runner.py (original)
+++ pypy/branch/pyjitpl5-c/pypy/jit/backend/c/runner.py Fri Aug 28 18:13:18 2009
@@ -1,4 +1,4 @@
-from pypy.rpython.lltypesystem import lltype, rffi
+from pypy.rpython.lltypesystem import lltype, llmemory, rffi
from pypy.jit.backend.model import AbstractCPU
from pypy.jit.backend.c.compile import Compiler, get_c_type, get_class_for_type
from pypy.jit.backend.c.compile import CallDescr
@@ -20,12 +20,18 @@
def set_future_value_int(self, index, intvalue):
self.compiler.c_jit_al[index] = intvalue
+ def set_future_value_ptr(self, index, ptrvalue):
+ self.compiler.c_jit_ap[index] = ptrvalue
+
def execute_operations(self, loop):
return self.compiler.run(loop)
def get_latest_value_int(self, index):
return self.compiler.c_jit_al[index]
+ def get_latest_value_ptr(self, index):
+ return self.compiler.c_jit_ap[index]
+
def calldescrof(self, FUNC, ARGS, RESULT):
args_cls = [get_class_for_type(ARG) for ARG in ARGS]
cls_result = get_class_for_type(RESULT)
@@ -53,9 +59,15 @@
else:
return BoxInt(self.get_latest_value_int(0))
+ def do_newstr(self, args, descr=None):
+ xxx#...
+
@staticmethod
def cast_adr_to_int(addr):
return rffi.cast(lltype.Signed, addr)
CPU = CCPU
+
+import pypy.jit.metainterp.executor
+pypy.jit.metainterp.executor.make_execute_list(CPU)
More information about the Pypy-commit
mailing list