[pypy-svn] r23138 - pypy/branch/genc-gc-refactoring
mwh at codespeak.net
mwh at codespeak.net
Wed Feb 8 12:47:27 CET 2006
Author: mwh
Date: Wed Feb 8 12:47:26 2006
New Revision: 23138
Modified:
pypy/branch/genc-gc-refactoring/gc.py
pypy/branch/genc-gc-refactoring/genc.py
pypy/branch/genc-gc-refactoring/node.py
Log:
delete large gobs of code.
Modified: pypy/branch/genc-gc-refactoring/gc.py
==============================================================================
--- pypy/branch/genc-gc-refactoring/gc.py (original)
+++ pypy/branch/genc-gc-refactoring/gc.py Wed Feb 8 12:47:26 2006
@@ -15,39 +15,6 @@
self.db = db
self.thread_enabled = thread_enabled
- def pyobj_incref(self, expr):
- return 'Py_XINCREF(%s);' % expr
-
- def pyobj_decref(self, expr):
- return 'Py_XDECREF(%s);' % expr
-
- def push_alive(self, expr, T):
- if isinstance(T, Ptr) and T._needsgc():
- if expr == 'NULL': # hum
- return ''
- if T.TO == PyObject:
- return self.pyobj_incref(expr)
- else:
- return self.push_alive_nopyobj(expr, T)
- return ''
-
- def pop_alive(self, expr, T):
- if isinstance(T, Ptr) and T._needsgc():
- if T.TO == PyObject:
- return self.pyobj_decref(expr)
- else:
- return self.pop_alive_nopyobj(expr, T)
- return ''
-
- def push_alive_nopyobj(self, expr, T):
- return ''
-
- def pop_alive_nopyobj(self, expr, T):
- return ''
-
- def push_alive_op_result(self, opname, expr, T):
- return ''
-
def gcheader_field_name(self, defnode):
return None
@@ -91,25 +58,8 @@
class RefcountingGcPolicy(BasicGcPolicy):
transformerclass = gctransform.RefcountingGCTransformer
- def push_alive_nopyobj(self, expr, T):
- defnode = self.db.gettypedefnode(T.TO)
- if defnode.gcheader is not None:
- return 'pypy_IncRf_%s(%s);' % (defnode.barename, expr)
-
- def pop_alive_nopyobj(self, expr, T):
- defnode = self.db.gettypedefnode(T.TO)
- if defnode.gcheader is not None:
- return 'pypy_DecRf_%s(%s);' % (defnode.barename, expr)
-
- def push_alive_op_result(self, opname, expr, T):
- if opname not in ('direct_call', 'indirect_call') and T != PyObjPtr:
- return self.push_alive(expr, T)
- return ''
-
- def gcheader_field_name(self, defnode):
- return 'refcount'
-
def common_gcheader_definition(self, defnode):
+# return ('refcount', lltype.Signed)
return 'long refcount;'
def common_after_definition(self, defnode):
Modified: pypy/branch/genc-gc-refactoring/genc.py
==============================================================================
--- pypy/branch/genc-gc-refactoring/genc.py (original)
+++ pypy/branch/genc-gc-refactoring/genc.py Wed Feb 8 12:47:26 2006
@@ -303,7 +303,7 @@
print >> fi, 'struct %s;' % node.name
print >> fi
for node in structdeflist:
- for line in node.definition(phase=1):
+ for line in node.definition():
print >> fi, line
print >> fi
print >> fi, '/***********************************************************/'
@@ -347,16 +347,6 @@
print >> fc
print >> fc, MARKER
- def render_nonempty(seq):
- lines = list(seq)
- if lines:
- print >> fc, '\n'.join(lines)
- print >> fc, MARKER
- return len(lines) + 1
- return 0
-
- for node in structdeflist:
- render_nonempty(node.definition(phase=2))
print >> fc, '/***********************************************************/'
fc.close()
@@ -428,7 +418,7 @@
print >> f, 'struct %s;' % node.name
print >> f
for node in structdeflist:
- for line in node.definition(phase=1):
+ for line in node.definition():
print >> f, line
print >> f
print >> f, '/***********************************************************/'
@@ -449,11 +439,7 @@
print >> f, line
print >> f, '#include "src/g_include.h"'
print >> f
- blank = False
- for node in structdeflist:
- for line in node.definition(phase=2):
- print >> f, line
- blank = True
+ blank = True
for node in database.globalcontainers():
if blank:
print >> f
Modified: pypy/branch/genc-gc-refactoring/node.py
==============================================================================
--- pypy/branch/genc-gc-refactoring/node.py (original)
+++ pypy/branch/genc-gc-refactoring/node.py Wed Feb 8 12:47:26 2006
@@ -54,24 +54,6 @@
gcpolicy = db.gcpolicy
- # look up the gcheader field
- if needs_gcheader(STRUCT):
- self.gcheader = gcpolicy.gcheader_field_name(self)
- elif isinstance(STRUCT, GcStruct):
- # gcheader in the first field
- T = self.c_struct_field_type(STRUCT._names[0])
- assert isinstance(T, GC_CONTAINER)
- firstdefnode = db.gettypedefnode(T)
- firstfieldname = self.c_struct_field_name(STRUCT._names[0])
- if firstdefnode.gcheader:
- self.gcheader = '%s.%s' % (firstfieldname, firstdefnode.gcheader)
- else:
- self.gcheader = None
-
- # give the gcpolicy a chance to do sanity checking or special preparation for
- # this case
- gcpolicy.prepare_nested_gcstruct(self, T)
-
def setup(self):
# this computes self.fields
self.fields = []
@@ -113,35 +95,30 @@
fldname = self.c_struct_field_name(fldname)
return '%s.%s' % (baseexpr, fldname)
- def definition(self, phase):
+ def definition(self):
gcpolicy = self.db.gcpolicy
- if phase == 1:
- yield 'struct %s {' % self.name
- # gcheader
- is_empty = True
- if needs_gcheader(self.STRUCT):
- line = gcpolicy.struct_gcheader_definition(self)
- if line:
- yield '\t' + line
- is_empty = False
-
- for name, typename in self.fields:
- line = '%s;' % cdecl(typename, name)
- if typename == PrimitiveType[Void]:
- line = '/* %s */' % line
- else:
- is_empty = False
+ yield 'struct %s {' % self.name
+ # gcheader
+ is_empty = True
+ if needs_gcheader(self.STRUCT):
+ line = gcpolicy.struct_gcheader_definition(self)
+ if line:
yield '\t' + line
- if is_empty:
- yield '\t' + 'int _dummy; /* this struct is empty */'
- yield '};'
-
- for line in gcpolicy.struct_after_definition(self):
- yield line
+ is_empty = False
- elif phase == 2:
- for line in gcpolicy.struct_implementationcode(self):
- yield line
+ for name, typename in self.fields:
+ line = '%s;' % cdecl(typename, name)
+ if typename == PrimitiveType[Void]:
+ line = '/* %s */' % line
+ else:
+ is_empty = False
+ yield '\t' + line
+ if is_empty:
+ yield '\t' + 'int _dummy; /* this struct is empty */'
+ yield '};'
+
+ for line in gcpolicy.struct_after_definition(self):
+ yield line
def visitor_lines(self, prefix, on_field):
STRUCT = self.STRUCT
@@ -208,28 +185,23 @@
def access_expr(self, baseexpr, index):
return '%s.items[%d]' % (baseexpr, index)
- def definition(self, phase):
+ def definition(self):
gcpolicy = self.db.gcpolicy
- if phase == 1:
- yield 'struct %s {' % self.name
- # gcheader
- if needs_gcheader(self.ARRAY):
- line = gcpolicy.array_gcheader_definition(self)
- if line:
- yield '\t' + line
- yield '\tlong length;'
- line = '%s;' % cdecl(self.itemtypename, 'items[%d]'% self.varlength)
- if self.ARRAY.OF is Void: # strange
- line = '/* %s */' % line
- yield '\t' + line
- yield '};'
-
- for line in gcpolicy.array_after_definition(self):
- yield line
+ yield 'struct %s {' % self.name
+ # gcheader
+ if needs_gcheader(self.ARRAY):
+ line = gcpolicy.array_gcheader_definition(self)
+ if line:
+ yield '\t' + line
+ yield '\tlong length;'
+ line = '%s;' % cdecl(self.itemtypename, 'items[%d]'% self.varlength)
+ if self.ARRAY.OF is Void: # strange
+ line = '/* %s */' % line
+ yield '\t' + line
+ yield '};'
- elif phase == 2:
- for line in gcpolicy.array_implementationcode(self):
- yield line
+ for line in gcpolicy.array_after_definition(self):
+ yield line
def visitor_lines(self, prefix, on_item):
ARRAY = self.ARRAY
@@ -279,7 +251,7 @@
def setup(self):
pass
- def definition(self, phase):
+ def definition(self):
return []
# ____________________________________________________________
More information about the Pypy-commit
mailing list