Permalink
Browse files

Merge branch 'master' of git://github.com/Pawel834/parrot into mem_limit

  • Loading branch information...
2 parents c386dfd + f4d0d67 commit 532335e8f558ea3a9d4115c8a34c4880b358e7fa @Whiteknight Whiteknight committed Nov 28, 2011
@@ -426,6 +426,7 @@ Parrot_cmd_options(void)
{ 'O', 'O', OPTION_optional_FLAG, { "--optimize" } },
{ 'R', 'R', OPTION_required_FLAG, { "--runcore" } },
{ 'g', 'g', OPTION_required_FLAG, { "--gc" } },
+ { '\0', OPT_MEM_LIMIT, OPTION_required_FLAG, { "--mem-limit" } },
{ '\0', OPT_GC_NURSERY_SIZE, OPTION_required_FLAG, { "--gc-nursery-size" } },
{ '\0', OPT_GC_DYNAMIC_THRESHOLD, OPTION_required_FLAG, { "--gc-dynamic-threshold" } },
{ '\0', OPT_GC_MIN_THRESHOLD, OPTION_required_FLAG, { "--gc-min-threshold" } },
@@ -515,7 +516,6 @@ parseflags_minimal(ARGMOD(Parrot_Init_Args * initargs), int argc, ARGIN(const ch
exit(EXIT_FAILURE);
}
break;
-
case OPT_HASH_SEED:
if (opt.opt_arg && is_all_hex_digits(opt.opt_arg)) {
initargs->hash_seed = strtoul(opt.opt_arg, NULL, 16);
@@ -526,6 +526,17 @@ parseflags_minimal(ARGMOD(Parrot_Init_Args * initargs), int argc, ARGIN(const ch
exit(EXIT_FAILURE);
}
break;
+ case OPT_MEM_LIMIT:
+ if (opt.opt_arg && is_all_digits(opt.opt_arg)) {
+ initargs->gc_max_allocate = strtoul(opt.opt_arg, NULL, 10)
+ * 1024;
+ }
+ else {
+ fprintf(stderr, "error: invalid memory limit specified:"
+ "'%s'\n", opt.opt_arg);
+ exit(EXIT_FAILURE);
+ }
+ break;
default:
break;
}
@@ -292,7 +292,7 @@
.sub '__show_help_and_exit' :subid('WSubId_3') :anon
- set $S1, "parrot [Options] <file> [<program options...>]\n Options:\n -h --help\n -V --version\n -I --include add path to include search\n -L --library add path to library search\n --hash-seed F00F specify hex value to use as hash seed\n -X --dynext add path to dynamic extension search\n <Run core options>\n -R --runcore slow|bounds|fast|subprof\n -R --runcore trace|profiling|gcdebug\n -t --trace [flags]\n <VM options>\n -D --parrot-debug[=HEXFLAGS]\n --help-debug\n -w --warnings\n -G --no-gc\n -g --gc ms2|gms|ms|inf set GC type\n <GC MS2 options>\n --gc-dynamic-threshold=percentage maximum memory wasted by GC\n --gc-min-threshold=KB\n <GC GMS options>\n --gc-nursery-size=percent of sysmem size of gen0 (default 2)\n --gc-debug\n --leak-test|--destroy-at-end\n -. --wait Read a keystroke before starting\n --runtime-prefix\n <Compiler options>\n -d --imcc-debug[=HEXFLAGS]\n -v --verbose\n -E --pre-process-only\n -o --output=FILE\n --output-pbc\n -O --optimize[=LEVEL]\n -a --pasm\n -c --pbc\n -r --run-pbc\n -y --yydebug\n <Language options>\nsee docs/running.pod for more\n"
+ set $S1, "parrot [Options] <file> [<program options...>]\n Options:\n -h --help\n -V --version\n -I --include add path to include search\n -L --library add path to library search\n --hash-seed F00F specify hex value to use as hash seed\n -X --dynext add path to dynamic extension search\n <Run core options>\n -R --runcore slow|bounds|fast|subprof\n -R --runcore trace|profiling|gcdebug\n -t --trace [flags]\n <VM options>\n -D --parrot-debug[=HEXFLAGS]\n --help-debug\n -w --warnings\n -G --no-gc\n -g --gc ms2|gms|ms|inf set GC type\n <GC MS2 options>\n --gc-dynamic-threshold=percentage maximum memory wasted by GC\n --gc-min-threshold=KB\n <GC GMS options>\n --gc-nursery-size=percent of sysmem size of gen0 (default 2)\n --mem-limit=KB maximum amount of memory allocated by GC\n --gc-debug\n --leak-test|--destroy-at-end\n -. --wait Read a keystroke before starting\n --runtime-prefix\n <Compiler options>\n -d --imcc-debug[=HEXFLAGS]\n -v --verbose\n -E --pre-process-only\n -o --output=FILE\n --output-pbc\n -O --optimize[=LEVEL]\n -a --pasm\n -c --pbc\n -r --run-pbc\n -y --yydebug\n <Language options>\nsee docs/running.pod for more\n"
say $S1
exit 0
@@ -206,6 +206,7 @@ parrot [Options] <file> [<program options...>]
--gc-min-threshold=KB
<GC GMS options>
--gc-nursery-size=percent of sysmem size of gen0 (default 2)
+ --mem-limit=KB maximum amount of memory allocated by GC
--gc-debug
--leak-test|--destroy-at-end
-. --wait Read a keystroke before starting
@@ -61,6 +61,7 @@ typedef struct _Parrot_Init_Args {
Parrot_Float4 gc_nursery_size;
Parrot_Int gc_dynamic_threshold;
Parrot_Int gc_min_threshold;
+ Parrot_Int gc_max_allocate;
Parrot_UInt hash_seed;
} Parrot_Init_Args;
@@ -39,6 +39,7 @@ typedef struct _Parrot_GC_Init_Args {
Parrot_Float4 nursery_size;
Parrot_Int dynamic_threshold;
Parrot_Int min_threshold;
+ Parrot_Int max_allocate;
} Parrot_GC_Init_Args;
typedef enum _gc_sys_type_enum {
@@ -49,6 +49,7 @@ struct longopt_opt_info {
#define OPT_GC_DYNAMIC_THRESHOLD 134
#define OPT_GC_MIN_THRESHOLD 135
#define OPT_GC_NURSERY_SIZE 136
+#define OPT_MEM_LIMIT 137
/* HEADERIZER BEGIN: src/longopt.c */
/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
View
@@ -142,6 +142,7 @@ Parrot_api_make_interpreter(Parrot_PMC parent, Parrot_Int flags,
gc_args.nursery_size = args->gc_nursery_size;
gc_args.dynamic_threshold = args->gc_dynamic_threshold;
gc_args.min_threshold = args->gc_min_threshold;
+ gc_args.max_allocate = args->gc_max_allocate;
if (args->hash_seed)
interp_raw->hash_seed = args->hash_seed;
View
@@ -187,6 +187,9 @@ typedef struct MarkSweep_GC {
/* During GC phase - which generation we are collecting */
size_t gen_to_collect;
+ /* Maximum amount of memory allocated by the GC */
+ size_t max_allocate;
+
/* GC blocking */
UINTVAL gc_mark_block_level; /* How many outstanding GC block
requests are there? */
@@ -748,6 +751,8 @@ Parrot_gc_gms_init(PARROT_INTERP, ARGIN(Parrot_GC_Init_Args *args))
*/
self->gc_threshold = Parrot_sysmem_amount(interp) * nursery_size / 100;
+ self->max_allocate = args->max_allocate;
+
Parrot_gc_str_initialize(interp, &self->string_gc);
}

0 comments on commit 532335e

Please sign in to comment.