2009-11-16
2009-11-16 23:59:33 by Martin Stjernholm <mast@lysator.liu.se>
-
c84aaaca8a77307a792fae03ff4803c6d08ebfda
(33 lines)
(+30/-3)
[
Show
| Annotate
]
Branch: 7.9
Added block_strings option to Pike.count_memory.
Rev: src/gc.c:1.334
2:
|| This file is part of Pike. For copyright information see COPYRIGHT.
|| Pike is distributed under GPL, LGPL and MPL. See the file COPYING
|| for more information.
- || $Id: gc.c,v 1.333 2009/11/11 20:22:19 mast Exp $
+ || $Id: gc.c,v 1.334 2009/11/16 23:59:33 mast Exp $
*/
#include "global.h"
2453: Inside #if defined(PIKE_DEBUG)
if (!*(INT32 *) a)
gc_fatal(a, 0, "Marked a thing without refs.\n");
if (m->weak_refs < 0)
- gc_fatal(a, 0, "Marking thing scheduled for weak free.\n");
+ gc_fatal(a, 0, "Marked a thing scheduled for weak free.\n");
#endif
if (Pike_in_gc == GC_PASS_ZAP_WEAK) {
4311:
* blocked because they are acyclic and don't contain refs to anything
* but strings and other types. */
+ static int mc_block_strings;
+
static int mc_enqueued_noninternal;
/* Set whenever something is enqueued in MC_PASS_LOOKAHEAD that isn't
* internal already. This is used to detect whether another
4710:
assert (mc_ref_from->la_count != ((unsigned INT16) -1) >> 1);
#endif
+ if (mc_block_strings > 0 &&
+ visit_fn == (visit_thing_fn *) &visit_string) {
+ MC_DEBUG_MSG (ref_to, "ignored string");
+ return;
+ }
+
ref_from_flags = mc_ref_from->flags;
/* Create mc_marker if necessary. */
4785:
/* Handle the target becoming internal. */
- if (ref_to->int_refs == *(INT32 *) thing) {
+ if (ref_to->int_refs == *(INT32 *) thing ||
+ (mc_block_strings < 0 &&
+ visit_fn == (visit_thing_fn *) &visit_string)) {
assert (!(ref_to_flags & MC_FLAG_INTERNAL));
assert (!(ref_to_flags & MC_FLAG_INT_VISITED));
ref_to_flags |= MC_FLAG_INTERNAL;
5104:
*! blocked things are still recursed and memory counted if they
*! are given as arguments or only got internal references.
*!
+ *! @member int block_strings
+ *! If positive then strings are always excluded (except any
+ *! given directly in @[things]), if negative they are always
+ *! included. Otherwise they are counted if they have no other
+ *! refs, but note that since strings are shared they might get
+ *! refs from other unrelated parts of the program.
+ *!
*! @member int block_pike_cycle_depth
*! Do not heed @expr{pike_cycle_depth@} values found in
*! objects. This is implicit if the lookahead is negative.
5222:
mc_block_lookahead = mc_block_lookahead_default;
mc_block_pike_cycle_depth = 0;
+ mc_block_strings = 0;
if (Pike_sp[-args].type == T_MAPPING) {
struct mapping *opts = Pike_sp[-args].u.mapping;
5256:
CHECK_BLOCK_FLAG ("block_objects", BIT_OBJECT);
CHECK_BLOCK_FLAG ("block_programs", BIT_PROGRAM);
+ MAKE_CONST_STRING (ind, "block_strings");
+ if ((val = low_mapping_string_lookup (opts, ind))) {
+ if (val->type != T_INT)
+ SIMPLE_ARG_ERROR ("count_memory", 1,
+ "\"block_strings\" must be an integer.");
+ mc_block_strings = val->u.integer > 0 ? 1 : val->u.integer < 0 ? -1 : 0;
+ }
+
MAKE_CONST_STRING (ind, "block_pike_cycle_depth");
if ((val = low_mapping_string_lookup (opts, ind)) && !UNSAFE_IS_ZERO (val))
mc_block_pike_cycle_depth = 1;