[pypy-commit] pypy nonmovable-list: Translation, step 2
arigo
pypy.commits at gmail.com
Thu Jun 2 10:03:58 EDT 2016
Author: Armin Rigo <arigo at tunes.org>
Branch: nonmovable-list
Changeset: r84882:78452109814c
Date: 2016-06-02 16:00 +0200
http://bitbucket.org/pypy/pypy/changeset/78452109814c/
Log: Translation, step 2
diff --git a/rpython/memory/gc/base.py b/rpython/memory/gc/base.py
--- a/rpython/memory/gc/base.py
+++ b/rpython/memory/gc/base.py
@@ -184,7 +184,7 @@
def can_move(self, addr):
return False
- def malloc_fixedsize_nonmovable(self, typeid):
+ def malloc_fixed_or_varsize_nonmovable(self, typeid, length):
raise MemoryError
def pin(self, addr):
diff --git a/rpython/memory/gc/incminimark.py b/rpython/memory/gc/incminimark.py
--- a/rpython/memory/gc/incminimark.py
+++ b/rpython/memory/gc/incminimark.py
@@ -718,8 +718,9 @@
return llmemory.cast_adr_to_ptr(obj, llmemory.GCREF)
- def malloc_fixedsize_nonmovable(self, typeid):
- obj = self.external_malloc(typeid, 0, alloc_young=True)
+ def malloc_fixed_or_varsize_nonmovable(self, typeid, length):
+ # length==0 for fixedsize
+ obj = self.external_malloc(typeid, length, alloc_young=True)
return llmemory.cast_adr_to_ptr(obj, llmemory.GCREF)
diff --git a/rpython/memory/gc/minimark.py b/rpython/memory/gc/minimark.py
--- a/rpython/memory/gc/minimark.py
+++ b/rpython/memory/gc/minimark.py
@@ -628,8 +628,9 @@
return llmemory.cast_adr_to_ptr(obj, llmemory.GCREF)
- def malloc_fixedsize_nonmovable(self, typeid):
- obj = self.external_malloc(typeid, 0, alloc_young=True)
+ def malloc_fixed_or_varsize_nonmovable(self, typeid, length):
+ # length==0 for fixedsize
+ obj = self.external_malloc(typeid, length, alloc_young=True)
return llmemory.cast_adr_to_ptr(obj, llmemory.GCREF)
diff --git a/rpython/memory/gctransform/framework.py b/rpython/memory/gctransform/framework.py
--- a/rpython/memory/gctransform/framework.py
+++ b/rpython/memory/gctransform/framework.py
@@ -557,9 +557,10 @@
getfn(func,
[SomeAddress()],
annmodel.s_None)
- self.malloc_nonmovable_ptr = getfn(GCClass.malloc_fixedsize_nonmovable,
- [s_gc, s_typeid16],
- s_gcref)
+ self.malloc_nonmovable_ptr = getfn(
+ GCClass.malloc_fixed_or_varsize_nonmovable,
+ [s_gc, s_typeid16, annmodel.SomeInteger()],
+ s_gcref)
self.register_finalizer_ptr = getfn(GCClass.register_finalizer,
[s_gc,
@@ -800,12 +801,16 @@
c_has_light_finalizer = rmodel.inputconst(lltype.Bool,
has_light_finalizer)
+ is_varsize = op.opname.endswith('_varsize') or flags.get('varsize')
+
if flags.get('nonmovable'):
- assert op.opname == 'malloc'
- assert not flags.get('varsize')
+ if not is_varsize:
+ v_length = rmodel.inputconst(lltype.Signed, 0)
+ else:
+ v_length = op.args[-1]
malloc_ptr = self.malloc_nonmovable_ptr
- args = [self.c_const_gc, c_type_id]
- elif not op.opname.endswith('_varsize') and not flags.get('varsize'):
+ args = [self.c_const_gc, c_type_id, v_length]
+ elif not is_varsize:
zero = flags.get('zero', False)
if (self.malloc_fast_ptr is not None and
not c_has_finalizer.value and
diff --git a/rpython/rlib/test/test_rgc.py b/rpython/rlib/test/test_rgc.py
--- a/rpython/rlib/test/test_rgc.py
+++ b/rpython/rlib/test/test_rgc.py
@@ -286,6 +286,22 @@
#
# llinterp run
interpret(f, [35])
+ #
+ # compilation with the GC transformer
+ import subprocess
+ from rpython.translator.interactive import Translation
+ #
+ def main(argv):
+ f(len(argv))
+ print "OK!"
+ return 0
+ #
+ t = Translation(main, gc="incminimark")
+ t.disable(['backendopt'])
+ t.set_backend_extra_options(c_debug_defines=True)
+ exename = t.compile()
+ data = subprocess.check_output([str(exename), '.', '.', '.'])
+ assert data.strip().endswith('OK!')
# ____________________________________________________________
More information about the pypy-commit
mailing list