gawk-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gawk-diffs] [SCM] gawk branch, master, updated. gawk-4.1.0-3822-g7c3ad2


From: Andrew J. Schorr
Subject: [gawk-diffs] [SCM] gawk branch, master, updated. gawk-4.1.0-3822-g7c3ad2b
Date: Tue, 10 Sep 2019 09:43:57 -0400 (EDT)

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "gawk".

The branch, master has been updated
       via  7c3ad2bf3d4c5cac82146b3359134137bc6d83ff (commit)
      from  abc7fc68f8ce227db5a1ce881a8f065577c764dd (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.sv.gnu.org/cgit/gawk.git/commit/?id=7c3ad2bf3d4c5cac82146b3359134137bc6d83ff

commit 7c3ad2bf3d4c5cac82146b3359134137bc6d83ff
Author: Andrew J. Schorr <address@hidden>
Date:   Tue Sep 10 09:43:04 2019 -0400

    Update the typeof(PROCINFO) hack to return memory highwater and active 
counts.

diff --git a/ChangeLog b/ChangeLog
index 081f07d..5e9363b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2019-09-10         Andrew J. Schorr      <address@hidden>
+
+       * awk.h (block_header): Remove cnt field and replace it with
+       highwater. If MEMDEBUG is defined, add active counter.
+       * node.c (r_getblock): The cnt field was replaced by active. Update
+       highwater as appropriate.
+       (r_freeblock): Decrement the active counter (renamed from cnt).
+       (more_blocks): Bump the highwater counter (renamed from cnt).
+       * builtin.c (do_typeof): When providing PROCINFO debug memory stats,
+       replace count_<blah> with <blah>_active and <blah>_highwater. When
+       MEMDEBUG is not set, we calculate the active value by subtracting the
+       number of elements in the free list from the highwater value.
+
 2019-09-01         Arnold D. Robbins     <address@hidden>
 
        * profile.c (pp_list, pp_concat): Fix use-after-free errors
diff --git a/awk.h b/awk.h
index b55b048..dc86a45 100644
--- a/awk.h
+++ b/awk.h
@@ -1062,7 +1062,10 @@ struct block_header {
        struct block_item *freep;
        size_t size;
        const char *name;
-       long cnt;
+       long highwater;
+#ifdef MEMDEBUG
+       long active;
+#endif
 };
 
 enum block_id {
diff --git a/builtin.c b/builtin.c
index 4694390..0bd94bf 100644
--- a/builtin.c
+++ b/builtin.c
@@ -4055,10 +4055,35 @@ do_typeof(int nargs)
                                int i;
                                for (i = 0; i < BLOCK_MAX; i++) {
                                        char *p;
-                                       size_t l = 6 + strlen(nextfree[i].name);
-                                       emalloc(p, char *, l+1, "do_typeof");
-                                       sprintf(p, "count_%s", 
nextfree[i].name);
-                                       assoc_set(dbg, make_str_node(p, l, 
ALREADY_MALLOCED), make_number((AWKNUM) (nextfree[i].cnt)));
+                                       size_t nl = strlen(nextfree[i].name);
+                                       /*
+                                        * save values before we create new
+                                        * array elements so that we have a
+                                        * snapshot at a consistent moment in
+                                        * time
+                                        */
+                                       long hw = nextfree[i].highwater;
+                                       long active;
+#ifdef MEMDEBUG
+                                       active = nextfree[i].active;
+#else
+                                       active = hw;
+                                       {
+                                               struct block_item *ip;
+                                               for (ip = nextfree[i].freep; 
ip; ip = ip->freep)
+                                                       active--;
+                                       }
+#endif
+
+#define SETVAL(X, V) { \
+       size_t l = nl + sizeof(#X);     \
+       emalloc(p, char *, l+1, "do_typeof");   \
+       sprintf(p, "%s_" #X, nextfree[i].name); \
+       assoc_set(dbg, make_str_node(p, l, ALREADY_MALLOCED), 
make_number((AWKNUM) (V)));       \
+}
+                                       SETVAL(highwater, hw)
+                                       SETVAL(active, active)
+#undef SETVAL
                                }
                        }
                }
diff --git a/node.c b/node.c
index 5333e84..c99af12 100644
--- a/node.c
+++ b/node.c
@@ -1041,14 +1041,16 @@ r_getblock(int id)
 {
        void *res;
        emalloc(res, void *, nextfree[id].size, "getblock");
-       nextfree[id].cnt++;
+       nextfree[id].active++;
+       if (nextfree[id].highwater < nextfree[id].active)
+               nextfree[id].highwater = nextfree[id].active;
        return res;
 }
 
 void
 r_freeblock(void *p, int id)
 {
-       nextfree[id].cnt--;
+       nextfree[id].active--;
        free(p);
 }
 
@@ -1081,7 +1083,7 @@ more_blocks(int id)
                np->freep = next;
        }
        nextfree[id].freep = freep->freep;
-       nextfree[id].cnt += BLOCKCHUNK;
+       nextfree[id].highwater += BLOCKCHUNK;
        return freep;
 }
 

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog | 13 +++++++++++++
 awk.h     |  5 ++++-
 builtin.c | 33 +++++++++++++++++++++++++++++----
 node.c    |  8 +++++---
 4 files changed, 51 insertions(+), 8 deletions(-)


hooks/post-receive
-- 
gawk



reply via email to

[Prev in Thread] Current Thread [Next in Thread]