[pypy-commit] pypy default: merged upstream
alex_gaynor
noreply at buildbot.pypy.org
Mon Jan 16 18:16:25 CET 2012
Author: Alex Gaynor <alex.gaynor at gmail.com>
Branch:
Changeset: r51358:8688ce42472e
Date: 2012-01-16 18:16 +0100
http://bitbucket.org/pypy/pypy/changeset/8688ce42472e/
Log: merged upstream
diff --git a/pypy/rpython/lltypesystem/rclass.py b/pypy/rpython/lltypesystem/rclass.py
--- a/pypy/rpython/lltypesystem/rclass.py
+++ b/pypy/rpython/lltypesystem/rclass.py
@@ -510,7 +510,13 @@
ctype = inputconst(Void, self.object_type)
cflags = inputconst(Void, flags)
vlist = [ctype, cflags]
- vptr = llops.genop('malloc', vlist,
+ cnonmovable = self.classdef.classdesc.read_attribute(
+ '_alloc_nonmovable_', Constant(False))
+ if cnonmovable.value:
+ opname = 'malloc_nonmovable'
+ else:
+ opname = 'malloc'
+ vptr = llops.genop(opname, vlist,
resulttype = Ptr(self.object_type))
ctypeptr = inputconst(CLASSTYPE, self.rclass.getvtable())
self.setfield(vptr, '__class__', ctypeptr, llops)
diff --git a/pypy/rpython/test/test_rclass.py b/pypy/rpython/test/test_rclass.py
--- a/pypy/rpython/test/test_rclass.py
+++ b/pypy/rpython/test/test_rclass.py
@@ -1130,6 +1130,18 @@
assert sorted([u]) == [6] # 32-bit types
assert sorted([i, r, d, l]) == [2, 3, 4, 5] # 64-bit types
+ def test_nonmovable(self):
+ for (nonmovable, opname) in [(True, 'malloc_nonmovable'),
+ (False, 'malloc')]:
+ class A(object):
+ _alloc_nonmovable_ = nonmovable
+ def f():
+ return A()
+ t, typer, graph = self.gengraph(f, [])
+ assert summary(graph) == {opname: 1,
+ 'cast_pointer': 1,
+ 'setfield': 1}
+
class TestOOtype(BaseTestRclass, OORtypeMixin):
More information about the pypy-commit
mailing list