[pypy-svn] r62593 - in pypy/branch/pyjitpl5/pypy/jit/backend/llgraph: . test
arigo at codespeak.net
arigo at codespeak.net
Thu Mar 5 17:00:16 CET 2009
Author: arigo
Date: Thu Mar 5 17:00:14 2009
New Revision: 62593
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:
do_new.
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:00:14 2009
@@ -934,6 +934,11 @@
x = getattr(ptr, fieldname)
return cast_to_ptr(x)
+def do_new(size):
+ TYPE = symbolic.Size2Type[size]
+ x = lltype.malloc(TYPE)
+ return cast_to_ptr(x)
+
# ____________________________________________________________
@@ -1024,3 +1029,4 @@
setannotation(do_getfield_gc_ptr, annmodel.SomePtr(llmemory.GCREF))
setannotation(do_getfield_raw_int, annmodel.SomeInteger())
setannotation(do_getfield_raw_ptr, annmodel.SomePtr(llmemory.GCREF))
+setannotation(do_new, annmodel.SomePtr(llmemory.GCREF))
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:00:14 2009
@@ -354,6 +354,10 @@
fielddescr,
self.memo_cast))
+ def do_new(self, args):
+ size = args[0].getint()
+ return history.BoxPtr(llimpl.do_new(size))
+
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:00:14 2009
@@ -223,3 +223,9 @@
BoxInt(descrfld_ry)])
assert isinstance(x, BoxPtr)
assert x.getptr(lltype.Ptr(A)) == a
+ #
+ descrsize = cpu.sizeof(S)
+ x = cpu.do_new(
+ [BoxInt(descrsize)])
+ assert isinstance(x, BoxPtr)
+ x.getptr(lltype.Ptr(S))
More information about the Pypy-commit
mailing list