[pypy-svn] r65673 - in pypy/branch/pyjitpl5-experiments/pypy/jit/backend: llvm test
arigo at codespeak.net
arigo at codespeak.net
Mon Jun 8 21:44:04 CEST 2009
Author: arigo
Date: Mon Jun 8 21:44:02 2009
New Revision: 65673
Modified:
pypy/branch/pyjitpl5-experiments/pypy/jit/backend/llvm/compile.py
pypy/branch/pyjitpl5-experiments/pypy/jit/backend/llvm/runner.py
pypy/branch/pyjitpl5-experiments/pypy/jit/backend/test/runner_test.py
Log:
NEW_WITH_VTABLE.
Modified: pypy/branch/pyjitpl5-experiments/pypy/jit/backend/llvm/compile.py
==============================================================================
--- pypy/branch/pyjitpl5-experiments/pypy/jit/backend/llvm/compile.py (original)
+++ pypy/branch/pyjitpl5-experiments/pypy/jit/backend/llvm/compile.py Mon Jun 8 21:44:02 2009
@@ -676,6 +676,12 @@
lltype.free(arglist, flavor='raw')
self.vars[op.result] = res
+ def generate_NEW_WITH_VTABLE(self, op):
+ self.generate_NEW(op)
+ loc = self._generate_field_gep(op.result, self.cpu.vtable_descr)
+ value_ref = self.getintarg(op.args[0])
+ llvm_rffi.LLVMBuildStore(self.builder, value_ref, loc, "")
+
# ____________________________________________________________
class MissingOperation(Exception):
Modified: pypy/branch/pyjitpl5-experiments/pypy/jit/backend/llvm/runner.py
==============================================================================
--- pypy/branch/pyjitpl5-experiments/pypy/jit/backend/llvm/runner.py (original)
+++ pypy/branch/pyjitpl5-experiments/pypy/jit/backend/llvm/runner.py Mon Jun 8 21:44:02 2009
@@ -55,6 +55,7 @@
basesize, _, ofs_length = symbolic.get_array_token(
rstr.UNICODE, self.translate_support_code)
self._unicode_shape = basesize, ofs_length
+ self.vtable_descr = self.fielddescrof(rclass.OBJECT, 'typeptr')
def setup_once(self):
if not we_are_translated():
Modified: pypy/branch/pyjitpl5-experiments/pypy/jit/backend/test/runner_test.py
==============================================================================
--- pypy/branch/pyjitpl5-experiments/pypy/jit/backend/test/runner_test.py (original)
+++ pypy/branch/pyjitpl5-experiments/pypy/jit/backend/test/runner_test.py Mon Jun 8 21:44:02 2009
@@ -575,6 +575,27 @@
assert s.x == chr(190)
assert s.y == chr(150)
+ def test_new_with_vtable(self):
+ cpu = self.cpu
+ t_box, T_box = self.alloc_instance(self.T)
+ sizedescr = cpu.sizeof(self.T)
+ r1 = self.execute_operation(rop.NEW_WITH_VTABLE, [T_box], 'ptr',
+ descr=sizedescr)
+ r2 = self.execute_operation(rop.NEW_WITH_VTABLE, [T_box], 'ptr',
+ descr=sizedescr)
+ assert r1.value != r2.value
+ descr1 = cpu.fielddescrof(self.S, 'chr1')
+ descr2 = cpu.fielddescrof(self.S, 'chr2')
+ self.execute_operation(rop.SETFIELD_GC, [r1, BoxInt(150)],
+ 'void', descr=descr2)
+ self.execute_operation(rop.SETFIELD_GC, [r1, BoxInt(190)],
+ 'void', descr=descr1)
+ s = lltype.cast_opaque_ptr(lltype.Ptr(self.T), r1.value)
+ assert s.parent.chr1 == chr(190)
+ assert s.parent.chr2 == chr(150)
+ t = lltype.cast_opaque_ptr(lltype.Ptr(self.T), t_box.value)
+ assert s.parent.parent.typeptr == t.parent.parent.typeptr
+
class OOtypeBackendTest(BaseBackendTest):
More information about the Pypy-commit
mailing list