[pypy-svn] r65056 - in pypy/branch/pyjitpl5/pypy: jit/backend/cli jit/backend/cli/test translator/cli/src
antocuni at codespeak.net
antocuni at codespeak.net
Tue May 5 14:14:26 CEST 2009
Author: antocuni
Date: Tue May 5 14:14:25 2009
New Revision: 65056
Added:
pypy/branch/pyjitpl5/pypy/jit/backend/cli/test/test_zrpy_basic.py (contents, props changed)
Modified:
pypy/branch/pyjitpl5/pypy/jit/backend/cli/method.py
pypy/branch/pyjitpl5/pypy/jit/backend/cli/runner.py
pypy/branch/pyjitpl5/pypy/translator/cli/src/pypylib.cs
Log:
lot of translation fixes. First translated tests pass
Modified: pypy/branch/pyjitpl5/pypy/jit/backend/cli/method.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/backend/cli/method.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/backend/cli/method.py Tue May 5 14:14:25 2009
@@ -92,8 +92,9 @@
self.name = name
self.loop = loop
self.boxes = {} # box --> local var
- self.failing_ops = {} # index --> op
- self.branches = [] # (Label, operations)
+ self.failing_ops = [] # index --> op
+ self.branches = []
+ self.branchlabels = []
self.consts = {} # object --> index
self.meth_wrapper = self._get_meth_wrapper()
self.il = self.meth_wrapper.get_il_generator()
@@ -117,7 +118,8 @@
for av_const, i in self.consts.iteritems():
consts[i] = dotnet.cast_to_native_object(av_const.getobj())
# build the delegate
- self.func = self.meth_wrapper.create_delegate(delegatetype, consts)
+ func = self.meth_wrapper.create_delegate(delegatetype, consts)
+ self.func = dotnet.clidowncast(func, LoopDelegate)
def _get_meth_wrapper(self):
restype = dotnet.class2type(cVoid)
@@ -141,11 +143,10 @@
def get_index_for_failing_op(self, op):
try:
- return self.failing_ops[op]
- except KeyError:
- i = len(self.failing_ops)
- self.failing_ops[i] = op
- return i
+ return self.failing_ops.index(op)
+ except ValueError:
+ self.failing_ops.append(op)
+ return len(self.failing_ops)-1
def get_index_for_constant(self, obj):
try:
@@ -157,10 +158,11 @@
def newbranch(self, op):
# sanity check, maybe we can remove it later
- for _, myop in self.branches:
+ for myop in self.branches:
assert myop is not op
il_label = self.il.DefineLabel()
- self.branches.append((il_label, op))
+ self.branches.append(op)
+ self.branchlabels.append(il_label)
return il_label
def get_inputarg_field(self, type):
@@ -208,8 +210,13 @@
def emit_branches(self):
while self.branches:
branches = self.branches
+ branchlabels = self.branchlabels
self.branches = []
- for il_label, op in branches:
+ self.branchlabels = []
+ assert len(branches) == len(branchlabels)
+ for i in range(len(branches)):
+ op = branches[i]
+ il_label = branchlabels[i]
self.il.MarkLabel(il_label)
self.emit_operations(op.suboperations)
Modified: pypy/branch/pyjitpl5/pypy/jit/backend/cli/runner.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/backend/cli/runner.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/backend/cli/runner.py Tue May 5 14:14:25 2009
@@ -25,8 +25,13 @@
assert rtyper.type_system.name == "ootypesystem"
self.stats = stats
self.translate_support_code = translate_support_code
- self.inputargs = InputArgs()
+ self.inputargs = None
+ def get_inputargs(self):
+ if self.inputargs is None:
+ self.inputargs = InputArgs()
+ return self.inputargs
+
@cached_method('_callcache')
def calldescrof(self, FUNC, ARGS, RESULT):
return StaticMethDescr(FUNC, ARGS, RESULT)
@@ -51,35 +56,37 @@
def execute_operations(self, loop):
meth = loop._cli_meth
- meth.func(self.inputargs)
- return meth.failing_ops[self.inputargs.failed_op]
+ meth.func(self.get_inputargs())
+ return meth.failing_ops[self.inputargs.get_failed_op()]
def set_future_value_int(self, index, intvalue):
- self.inputargs.ints[index] = intvalue
+ self.get_inputargs().set_int(index, intvalue)
def set_future_value_obj(self, index, objvalue):
- self.inputargs.objs[index] = objvalue
+ obj = dotnet.cast_to_native_object(objvalue)
+ self.get_inputargs().set_obj(index, obj)
def get_latest_value_int(self, index):
- return self.inputargs.ints[index]
+ return self.get_inputargs().get_int(index)
def get_latest_value_obj(self, index):
- return self.inputargs.objs[index]
+ obj = self.get_inputargs().get_obj(index)
+ return dotnet.cast_from_native_object(obj)
def get_exception(self):
- exc_value = self.inputargs.exc_value
+ exc_value = self.get_inputargs().get_exc_value()
if exc_value:
assert False, 'TODO'
return ootype.cast_to_object(ootype.nullruntimeclass)
def get_exc_value(self):
- if self.inputargs.exc_value:
+ if self.get_inputargs().get_exc_value():
assert False, 'TODO'
else:
return ootype.NULL
def clear_exception(self):
- self.inputargs.exc_value = None
+ self.get_inputargs().set_exc_value(None)
def set_overflow_error(self):
raise NotImplementedError
@@ -94,6 +101,12 @@
assert len(args) == 1 # but we don't need it, so ignore
return typedescr.create()
+ def do_runtimenew(self, args, descr):
+ classbox = args[0]
+ classobj = ootype.cast_from_object(ootype.Class, classbox.getobj())
+ res = ootype.runtimenew(classobj)
+ return BoxObj(ootype.cast_to_object(res))
+
def do_getfield_gc(self, args, fielddescr):
assert isinstance(fielddescr, FieldDescr)
return fielddescr.getfield(args[0])
Added: pypy/branch/pyjitpl5/pypy/jit/backend/cli/test/test_zrpy_basic.py
==============================================================================
--- (empty file)
+++ pypy/branch/pyjitpl5/pypy/jit/backend/cli/test/test_zrpy_basic.py Tue May 5 14:14:25 2009
@@ -0,0 +1,28 @@
+import py
+from pypy.jit.backend.cli.runner import CliCPU
+from pypy.jit.backend.test.support import CliCompiledMixin
+from pypy.jit.metainterp.test.test_basic import BasicTests
+
+class CliTranslatedJitMixin(CliCompiledMixin):
+ CPUClass = CliCPU
+
+ def meta_interp(self, *args, **kwds):
+ from pypy.jit.metainterp.simple_optimize import Optimizer
+ kwds['optimizer'] = Optimizer
+ return CliCompiledMixin.meta_interp(self, *args, **kwds)
+
+
+class TestBasic(CliTranslatedJitMixin, BasicTests):
+ # for the individual tests see
+ # ====> ../../../metainterp/test/test_basic.py
+
+ def skip(self):
+ py.test.skip('in-progress')
+
+ test_constant_across_mp = skip
+ test_stopatxpolicy = skip
+ test_print = skip
+ test_bridge_from_interpreter = skip
+ test_bridge_from_interpreter_2 = skip
+ test_bridge_from_interpreter_3 = skip
+ test_bridge_from_interpreter_4 = skip
Modified: pypy/branch/pyjitpl5/pypy/translator/cli/src/pypylib.cs
==============================================================================
--- pypy/branch/pyjitpl5/pypy/translator/cli/src/pypylib.cs (original)
+++ pypy/branch/pyjitpl5/pypy/translator/cli/src/pypylib.cs Tue May 5 14:14:25 2009
@@ -115,9 +115,44 @@
public int[] ints = new int[32];
public float[] floats = new float[32];
public object[] objs = new object[32];
- public Exception exc_value = null;
+ public object exc_value = null;
public int failed_op = -1;
+ public int get_int(int i)
+ {
+ return ints[i];
+ }
+
+ public void set_int(int i, int n)
+ {
+ ints[i] = n;
+ }
+
+ public object get_obj(int i)
+ {
+ return objs[i];
+ }
+
+ public void set_obj(int i, object o)
+ {
+ objs[i] = o;
+ }
+
+ public object get_exc_value()
+ {
+ return exc_value;
+ }
+
+ public void set_exc_value(object v)
+ {
+ exc_value = v;
+ }
+
+ public int get_failed_op()
+ {
+ return failed_op;
+ }
+
public void ensure_ints(int n)
{
if (ints.Length < n)
More information about the Pypy-commit
mailing list