[pypy-svn] r62595 - in pypy/branch/pyjitpl5/pypy/jit/backend/llgraph: . test
arigo at codespeak.net
arigo at codespeak.net
Thu Mar 5 17:18:28 CET 2009
Author: arigo
Date: Thu Mar 5 17:18:27 2009
New Revision: 62595
Modified:
pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/llimpl.py
pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/runner.py
pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/test/test_llgraph.py
Log:
new_array.
Modified: pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/llimpl.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/llimpl.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/llimpl.py Thu Mar 5 17:18:27 2009
@@ -949,6 +949,11 @@
x = lltype.malloc(TYPE)
return cast_to_ptr(x)
+def do_new_array(arraydesc, count):
+ TYPE = symbolic.Size2Type[arraydesc/2]
+ x = lltype.malloc(TYPE, count)
+ return cast_to_ptr(x)
+
def do_setfield_gc_int(struct, fielddesc, newvalue, memocast):
STRUCT, fieldname = symbolic.TokenToField[fielddesc/2]
ptr = lltype.cast_opaque_ptr(lltype.Ptr(STRUCT), struct)
@@ -1047,4 +1052,5 @@
setannotation(do_getfield_raw_int, annmodel.SomeInteger())
setannotation(do_getfield_raw_ptr, annmodel.SomePtr(llmemory.GCREF))
setannotation(do_new, annmodel.SomePtr(llmemory.GCREF))
+setannotation(do_new_array, annmodel.SomePtr(llmemory.GCREF))
setannotation(do_setfield_gc_int, annmodel.s_None)
Modified: pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/runner.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/runner.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/runner.py Thu Mar 5 17:18:27 2009
@@ -367,6 +367,11 @@
self.memo_cast)
return history.BoxPtr(result)
+ def do_new_array(self, args):
+ size = args[0].getint()
+ count = args[1].getint()
+ return history.BoxPtr(llimpl.do_new_array(size, count))
+
class GuardFailed(object):
returns = False
Modified: pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/test/test_llgraph.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/test/test_llgraph.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/test/test_llgraph.py Thu Mar 5 17:18:27 2009
@@ -237,3 +237,9 @@
BoxInt(cpu.cast_adr_to_int(llmemory.cast_ptr_to_adr(vtable2)))])
assert isinstance(x, BoxPtr)
assert x.getptr(rclass.OBJECTPTR).typeptr == vtable2
+ #
+ arraydescr = cpu.arraydescrof(A)
+ x = cpu.do_new_array(
+ [BoxInt(arraydescr), BoxInt(7)])
+ assert isinstance(x, BoxPtr)
+ assert len(x.getptr(lltype.Ptr(A))) == 7
More information about the Pypy-commit
mailing list