Author: Armin Rigo <[email protected]>
Branch: concurrent-marksweep
Changeset: r47972:f1e3e612ab8a
Date: 2011-10-12 14:30 +0200
http://bitbucket.org/pypy/pypy/changeset/f1e3e612ab8a/

Log:    Merge 3f26c4717b82 and 7cd9093a53f9 from branch 'lltrace'.

diff --git a/pypy/translator/c/funcgen.py b/pypy/translator/c/funcgen.py
--- a/pypy/translator/c/funcgen.py
+++ b/pypy/translator/c/funcgen.py
@@ -477,13 +477,18 @@
             result = '/* %s */' % result
         return result
 
-    def generic_set(self, op, targetexpr):
+    def generic_set(self, op, targetexpr, gckind):
         newvalue = self.expr(op.args[-1], special_case_void=False)
         result = '%s = %s;' % (targetexpr, newvalue)
         T = self.lltypemap(op.args[-1])
         if T is Void:
             result = '/* %s */' % result
+        elif gckind == 'gc':
+            mark = FunctionCodeGenerator._TRACE_MARK + 1
+            FunctionCodeGenerator._TRACE_MARK = mark
+            result = '%s RPyTraceSet(%s, %d);' % (result, targetexpr, mark)
         return result
+    _TRACE_MARK = 0
 
     def OP_GETFIELD(self, op, ampersand=''):
         assert isinstance(op.args[1], Constant)
@@ -503,7 +508,7 @@
         expr = structdef.ptr_access_expr(self.expr(op.args[0]),
                                          op.args[1].value,
                                          baseexpr_is_const)
-        return self.generic_set(op, expr)
+        return self.generic_set(op, expr, STRUCT._gckind)
 
     def OP_GETSUBSTRUCT(self, op):
         RESULT = self.lltypemap(op.result).TO
@@ -533,7 +538,8 @@
         ptr = self.expr(op.args[0])
         index = self.expr(op.args[1])
         arraydef = self.db.gettypedefnode(ARRAY)
-        return self.generic_set(op, arraydef.itemindex_access_expr(ptr, index))
+        return self.generic_set(op, arraydef.itemindex_access_expr(ptr, index),
+                                ARRAY._gckind)
     OP_BARE_SETARRAYITEM = OP_SETARRAYITEM
 
     def OP_GETARRAYSUBSTRUCT(self, op):
@@ -575,7 +581,9 @@
         return self.generic_get(op, self.interior_expr(op.args))
 
     def OP_BARE_SETINTERIORFIELD(self, op):
-        return self.generic_set(op, self.interior_expr(op.args[:-1]))
+        STRUCT = self.lltypemap(op.args[0]).TO
+        return self.generic_set(op, self.interior_expr(op.args[:-1]),
+                                STRUCT._gckind)
 
     def OP_GETINTERIORARRAYSIZE(self, op):
         expr, ARRAY = self.interior_expr(op.args, True)
diff --git a/pypy/translator/c/genc.py b/pypy/translator/c/genc.py
--- a/pypy/translator/c/genc.py
+++ b/pypy/translator/c/genc.py
@@ -552,6 +552,7 @@
             ('linuxmemchk', '', '$(MAKE) CFLAGS="$(DEBUGFLAGS) -DRPY_ASSERT 
-DLINUXMEMCHK" $(TARGET)'),
             ('llsafer', '', '$(MAKE) CFLAGS="-O2 -DRPY_LL_ASSERT" $(TARGET)'),
             ('lldebug', '', '$(MAKE) CFLAGS="$(DEBUGFLAGS) -DRPY_ASSERT 
-DRPY_LL_ASSERT" $(TARGET)'),
+            ('lltrace', '', '$(MAKE) CFLAGS="$(DEBUGFLAGS) -DRPY_ASSERT 
-DRPY_LL_ASSERT -DRPY_LL_TRACE" $(TARGET)'),
             ('profile', '', '$(MAKE) CFLAGS="-g -O1 -pg $(CFLAGS) 
-fno-omit-frame-pointer" LDFLAGS="-pg $(LDFLAGS)" $(TARGET)'),
             ]
         if self.has_profopt():
diff --git a/pypy/translator/c/src/debug_lltrace.h 
b/pypy/translator/c/src/debug_lltrace.h
new file mode 100644
--- /dev/null
+++ b/pypy/translator/c/src/debug_lltrace.h
@@ -0,0 +1,65 @@
+
+void _RPyTraceSet(void *addr, long newvalue, long mark);
+
+
+#ifndef RPY_LL_TRACE /****************************************/
+
+
+#  define RPY_IS_TRACING           0
+#  define RPyTraceSet(ptr, mark)   /* nothing */
+#  ifndef PYPY_NOT_MAIN_FILE
+void _RPyTraceSet(void *addr, long newvalue, long mark) { }
+#  endif
+
+
+#else /*******************************************************/
+
+
+#  define RPY_IS_TRACING           1
+#  define RPyTraceSet(ptr, mark)   _RPyTraceSet(&(ptr), (long)(ptr), mark)
+
+#  ifndef PYPY_NOT_MAIN_FILE
+
+struct _RPyTrace_s {
+  long mark;
+  void *addr;
+  long newvalue;
+};
+
+static struct _RPyTrace_s *_RPyTrace_start   = NULL;
+static struct _RPyTrace_s *_RPyTrace_stop    = NULL;
+static struct _RPyTrace_s *_RPyTrace_current = NULL;
+static const long _RPyTrace_default_size = 134217728;
+
+void _RPyTrace_WrapAround(void)
+{
+  if (_RPyTrace_start == NULL)
+    {
+      char *csize = getenv("PYPYTRACEBUF");
+      long size = csize ? atol(csize) : 0;
+      if (size <= 1)
+        size = _RPyTrace_default_size;
+      _RPyTrace_start = malloc(size * sizeof(struct _RPyTrace_s));
+      RPyAssert(_RPyTrace_start, "not enough memory to allocate the trace");
+      _RPyTrace_stop = _RPyTrace_start + size;
+    }
+  _RPyTrace_current = _RPyTrace_start;
+  fprintf(stderr, "lltrace: buffer from %p to %p, size %ld entries\n",
+          _RPyTrace_start, _RPyTrace_stop,
+          (long)(_RPyTrace_stop - _RPyTrace_start));
+}
+
+void _RPyTraceSet(void *addr, long newvalue, long mark)
+{
+  if (_RPyTrace_current == _RPyTrace_stop)
+    _RPyTrace_WrapAround();
+  _RPyTrace_current->mark = mark;
+  _RPyTrace_current->addr = addr;
+  _RPyTrace_current->newvalue = newvalue;
+  ++_RPyTrace_current;
+}
+
+#  endif
+
+
+#endif /******************************************************/
diff --git a/pypy/translator/c/src/g_include.h 
b/pypy/translator/c/src/g_include.h
--- a/pypy/translator/c/src/g_include.h
+++ b/pypy/translator/c/src/g_include.h
@@ -46,6 +46,7 @@
 #  include "src/rtyper.h"
 #  include "src/debug_traceback.h"
 #  include "src/debug_alloc.h"
+#  include "src/debug_lltrace.h"
 #  include "src/ll_os.h"
 #  include "src/ll_strtod.h"
 #endif
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to