Author: wenzhuman <[email protected]>
Branch: gc_no_cleanup_nursery
Changeset: r72337:6dd33f47d74f
Date: 2014-07-03 12:48 +0000
http://bitbucket.org/pypy/pypy/changeset/6dd33f47d74f/
Log: simplify the malloc method logic
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
@@ -151,14 +151,14 @@
assert not needs_finalizer
itemsize = self.varsize_item_sizes(typeid)
offset_to_length = self.varsize_offset_to_length(typeid)
- if not hasattr(self, 'malloc_varsize'):
+ if self.malloc_zero_filled:
malloc_varsize = self.malloc_varsize_clear
else:
malloc_varsize = self.malloc_varsize
ref = malloc_varsize(typeid, length, size, itemsize,
offset_to_length)
else:
- if not hasattr(self, 'malloc_fixedsize'):
+ if self.malloc_zero_filled:
malloc_fixedsize = self.malloc_fixedsize_clear
else:
malloc_fixedsize = self.malloc_fixedsize
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
@@ -273,7 +273,11 @@
s_gcref = SomePtr(llmemory.GCREF)
gcdata = self.gcdata
translator = self.translator
- if hasattr(GCClass, 'malloc_fixedsize_clear'):
+ #use the GC flag to find which malloc method to use
+ #malloc_zero_filled == Ture -> malloc_fixedsize/varsize_clear
+ #malloc_zero_filled == Flase -> malloc_fixedsize/varsize
+ malloc_fixedsize_meth = None
+ if GCClass.malloc_zero_filled:
malloc_fixedsize_clear_meth =
GCClass.malloc_fixedsize_clear.im_func
self.malloc_fixedsize_clear_ptr = getfn(
malloc_fixedsize_clear_meth,
@@ -283,8 +287,13 @@
annmodel.SomeBool(),
annmodel.SomeBool()], s_gcref,
inline = False)
+ self.malloc_fixedsize_ptr = self.malloc_fixedsize_clear_ptr
+ self.malloc_varsize_ptr = getfn(
+ GCClass.malloc_varsize_clear.im_func,
+ [s_gc, s_typeid16]
+ + [annmodel.SomeInteger(nonneg=True) for i in range(4)],
s_gcref)
- if hasattr(GCClass, 'malloc_fixedsize'):
+ else:
malloc_fixedsize_meth = GCClass.malloc_fixedsize.im_func
self.malloc_fixedsize_ptr = getfn(
malloc_fixedsize_meth,
@@ -294,19 +303,11 @@
annmodel.SomeBool(),
annmodel.SomeBool()], s_gcref,
inline = False)
- else:
- malloc_fixedsize_meth = None
- self.malloc_fixedsize_ptr = self.malloc_fixedsize_clear_ptr
- if hasattr(GCClass, 'malloc_varsize'):
- self.malloc_varsize_ptr = getfn(
+ self.malloc_varsize_ptr = getfn(
GCClass.malloc_varsize.im_func,
[s_gc, s_typeid16]
+ [annmodel.SomeInteger(nonneg=True) for i in range(4)],
s_gcref)
- else:
- self.malloc_varsize_ptr = getfn(
- GCClass.malloc_varsize_clear.im_func,
- [s_gc, s_typeid16]
- + [annmodel.SomeInteger(nonneg=True) for i in range(4)],
s_gcref)
+
self.collect_ptr = getfn(GCClass.collect.im_func,
[s_gc, annmodel.SomeInteger()], annmodel.s_None)
self.can_move_ptr = getfn(GCClass.can_move.im_func,
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit