[pure-lang-svn] SF.net SVN: pure-lang:[674] pure/trunk/runtime.cc
Status: Beta
Brought to you by:
agraef
|
From: <ag...@us...> - 2008-08-31 22:34:28
|
Revision: 674
http://pure-lang.svn.sourceforge.net/pure-lang/?rev=674&view=rev
Author: agraef
Date: 2008-08-31 22:34:35 +0000 (Sun, 31 Aug 2008)
Log Message:
-----------
Bugfixes in sentry code.
Modified Paths:
--------------
pure/trunk/runtime.cc
Modified: pure/trunk/runtime.cc
===================================================================
--- pure/trunk/runtime.cc 2008-08-31 00:19:52 UTC (rev 673)
+++ pure/trunk/runtime.cc 2008-08-31 22:34:35 UTC (rev 674)
@@ -133,19 +133,26 @@
return 0;
}
-static inline void free_sentry(pure_expr *x)
+static inline void call_sentry(pure_expr *x)
{
if (x->tag == EXPR::APP || x->tag == EXPR::PTR) {
pure_expr *s = x->data.x[2];
if (s) {
++x->refc;
pure_freenew(pure_apply2(s, x));
- pure_free(s);
--x->refc;
}
}
}
+static inline void free_sentry(pure_expr *x)
+{
+ if (x->tag == EXPR::APP || x->tag == EXPR::PTR) {
+ pure_expr *s = x->data.x[2];
+ if (s) pure_free(s);
+ }
+}
+
// Expression pointers are allocated in larger chunks for better performance.
// NOTE: Only internal fields get initialized by new_expr(), the remaining
// fields *must* be initialized as appropriate by the caller.
@@ -242,7 +249,7 @@
pure_expr *xp = 0, *y;
loop:
if (--x->refc == 0) {
- free_sentry(x);
+ call_sentry(x);
switch (x->tag) {
case EXPR::APP:
y = x->data.x[0];
@@ -269,10 +276,16 @@
}
}
while (xp && x == xp->data.x[1]) {
- if (x->refc == 0) free_expr(x);
+ if (x->refc == 0) {
+ free_sentry(x);
+ free_expr(x);
+ }
x = xp; xp = x->xp;
}
- if (x->refc == 0) free_expr(x);
+ if (x->refc == 0) {
+ free_sentry(x);
+ free_expr(x);
+ }
if (xp) {
x = xp->data.x[1];
goto loop;
@@ -288,7 +301,7 @@
void pure_free_internal(pure_expr *x)
{
if (--x->refc == 0) {
- free_sentry(x);
+ call_sentry(x);
switch (x->tag) {
case EXPR::APP:
pure_free_internal(x->data.x[0]);
@@ -310,6 +323,7 @@
if (x->data.clos) pure_free_clos(x);
break;
}
+ free_sentry(x);
free_expr(x);
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|