[svn:parrot] r41309 - in branches/kill_jit: . compilers/imcc config/auto config/auto/sizes config/gen/makefiles docs docs/book/draft docs/book/pct docs/dev docs/pdds examples/embed examples/languages/abc examples/languages/squaak examples/pge include/parrot ports/cpan ports/cygwin ports/debian ports/fedora ports/mandriva ports/suse runtime/parrot/languages runtime/parrot/library/Math src src/call src/gc src/interp src/ops src/pmc src/runcore t/compilers/tge t/oo t/pmc t/src t/tools t/tools/ops2pm/samples tools/dev tools/util
darbelo at svn.parrot.org
darbelo at svn.parrot.org
Wed Sep 16 21:23:01 UTC 2009
Author: darbelo
Date: Wed Sep 16 21:22:58 2009
New Revision: 41309
URL: https://trac.parrot.org/parrot/changeset/41309
Log:
Pull changes from trunk.
Deleted:
branches/kill_jit/include/parrot/pic.h
branches/kill_jit/src/gc/generational_ms.c
branches/kill_jit/src/gc/incremental_ms.c
branches/kill_jit/src/ops/pic.ops
branches/kill_jit/src/pic_jit.c
Modified:
branches/kill_jit/ (props changed)
branches/kill_jit/DEPRECATED.pod
branches/kill_jit/MANIFEST
branches/kill_jit/PBC_COMPAT
branches/kill_jit/compilers/imcc/imc.h
branches/kill_jit/compilers/imcc/imcc.l
branches/kill_jit/compilers/imcc/imclexer.c
branches/kill_jit/compilers/imcc/pbc.c
branches/kill_jit/config/auto/headers.pm
branches/kill_jit/config/auto/msvc.pm
branches/kill_jit/config/auto/sizes/intval_maxmin_c.in (props changed)
branches/kill_jit/config/gen/makefiles/root.in
branches/kill_jit/docs/book/draft/README (props changed)
branches/kill_jit/docs/book/draft/appa_glossary.pod (props changed)
branches/kill_jit/docs/book/draft/appb_patch_submission.pod (props changed)
branches/kill_jit/docs/book/draft/appc_command_line_options.pod (props changed)
branches/kill_jit/docs/book/draft/appd_build_options.pod (props changed)
branches/kill_jit/docs/book/draft/appe_source_code.pod (props changed)
branches/kill_jit/docs/book/draft/ch01_introduction.pod (props changed)
branches/kill_jit/docs/book/draft/ch02_getting_started.pod (props changed)
branches/kill_jit/docs/book/draft/ch07_dynpmcs.pod (props changed)
branches/kill_jit/docs/book/draft/ch08_dynops.pod (props changed)
branches/kill_jit/docs/book/draft/ch10_opcode_reference.pod (props changed)
branches/kill_jit/docs/book/draft/ch11_directive_reference.pod (props changed)
branches/kill_jit/docs/book/draft/ch12_operator_reference.pod (props changed)
branches/kill_jit/docs/book/draft/chXX_hlls.pod (props changed)
branches/kill_jit/docs/book/draft/chXX_library.pod (props changed)
branches/kill_jit/docs/book/draft/chXX_testing_and_debugging.pod (props changed)
branches/kill_jit/docs/book/pct/ch01_introduction.pod (props changed)
branches/kill_jit/docs/book/pct/ch02_getting_started.pod (props changed)
branches/kill_jit/docs/book/pct/ch03_compiler_tools.pod (props changed)
branches/kill_jit/docs/book/pct/ch04_pge.pod (props changed)
branches/kill_jit/docs/book/pct/ch05_nqp.pod (props changed)
branches/kill_jit/docs/dev/c_functions.pod (props changed)
branches/kill_jit/docs/memory_internals.pod
branches/kill_jit/docs/pdds/pdd09_gc.pod
branches/kill_jit/docs/pdds/pdd30_install.pod (props changed)
branches/kill_jit/examples/embed/cotorra.c (props changed)
branches/kill_jit/examples/languages/abc/ (props changed)
branches/kill_jit/examples/languages/squaak/ (props changed)
branches/kill_jit/examples/pge/demo.pir (props changed)
branches/kill_jit/include/parrot/call.h (props changed)
branches/kill_jit/include/parrot/compiler.h
branches/kill_jit/include/parrot/gc_api.h (contents, props changed)
branches/kill_jit/include/parrot/interpreter.h
branches/kill_jit/include/parrot/oo.h
branches/kill_jit/include/parrot/packfile.h
branches/kill_jit/include/parrot/parrot.h
branches/kill_jit/include/parrot/pobj.h
branches/kill_jit/include/parrot/runcore_api.h (props changed)
branches/kill_jit/include/parrot/runcore_profiling.h (props changed)
branches/kill_jit/include/parrot/runcore_trace.h (props changed)
branches/kill_jit/include/parrot/settings.h
branches/kill_jit/ports/cpan/pause_guide.pod (props changed)
branches/kill_jit/ports/cygwin/parrot-1.0.0-1.cygport (props changed)
branches/kill_jit/ports/debian/libparrot-dev.install.in (props changed)
branches/kill_jit/ports/debian/libparrot.install.in (props changed)
branches/kill_jit/ports/debian/parrot-doc.install.in (props changed)
branches/kill_jit/ports/debian/parrot.install.in (props changed)
branches/kill_jit/ports/fedora/parrot.spec.fedora (props changed)
branches/kill_jit/ports/mandriva/parrot.spec.mandriva (props changed)
branches/kill_jit/ports/suse/parrot.spec.suse (props changed)
branches/kill_jit/runtime/parrot/languages/ (props changed)
branches/kill_jit/runtime/parrot/library/Math/Rand.pir (props changed)
branches/kill_jit/src/call/ops.c (props changed)
branches/kill_jit/src/call/pcc.c (props changed)
branches/kill_jit/src/gc/alloc_memory.c (props changed)
branches/kill_jit/src/gc/alloc_resources.c (contents, props changed)
branches/kill_jit/src/gc/api.c (contents, props changed)
branches/kill_jit/src/gc/gc_inf.c
branches/kill_jit/src/gc/gc_malloc.c
branches/kill_jit/src/gc/gc_ms.c
branches/kill_jit/src/gc/gc_private.h
branches/kill_jit/src/gc/malloc.c (props changed)
branches/kill_jit/src/gc/malloc_trace.c (props changed)
branches/kill_jit/src/gc/mark_sweep.c (contents, props changed)
branches/kill_jit/src/gc/res_lea.c
branches/kill_jit/src/gc/system.c (contents, props changed)
branches/kill_jit/src/hash.c
branches/kill_jit/src/interp/inter_cb.c (props changed)
branches/kill_jit/src/interp/inter_create.c (contents, props changed)
branches/kill_jit/src/interp/inter_misc.c (contents, props changed)
branches/kill_jit/src/jit.c
branches/kill_jit/src/list.c
branches/kill_jit/src/ops/ops.num
branches/kill_jit/src/packfile.c
branches/kill_jit/src/parrot_debugger.c
branches/kill_jit/src/pbc_merge.c
branches/kill_jit/src/pmc/default.pmc
branches/kill_jit/src/pmc/eval.pmc
branches/kill_jit/src/pmc/fixedpmcarray.pmc
branches/kill_jit/src/pmc/fixedstringarray.pmc
branches/kill_jit/src/pmc/resizablepmcarray.pmc
branches/kill_jit/src/pmc/resizablestringarray.pmc
branches/kill_jit/src/pmc_freeze.c
branches/kill_jit/src/runcore/cores.c (contents, props changed)
branches/kill_jit/src/runcore/main.c (contents, props changed)
branches/kill_jit/src/runcore/profiling.c (props changed)
branches/kill_jit/src/runcore/trace.c (props changed)
branches/kill_jit/t/compilers/tge/NoneGrammar.tg (props changed)
branches/kill_jit/t/oo/root_new.t (props changed)
branches/kill_jit/t/pmc/namespace-old.t (props changed)
branches/kill_jit/t/src/embed.t (props changed)
branches/kill_jit/t/tools/ops2pm/samples/core_ops.original
branches/kill_jit/t/tools/pbc_dump.t
branches/kill_jit/tools/dev/fetch_languages.pl (props changed)
branches/kill_jit/tools/dev/mk_gitignore.pl (props changed)
branches/kill_jit/tools/util/perlcritic-cage.conf (props changed)
Modified: branches/kill_jit/DEPRECATED.pod
==============================================================================
--- branches/kill_jit/DEPRECATED.pod Wed Sep 16 20:55:27 2009 (r41308)
+++ branches/kill_jit/DEPRECATED.pod Wed Sep 16 21:22:58 2009 (r41309)
@@ -153,14 +153,6 @@
L<http://rt.perl.org/rt3/Ticket/Display.html?id=60626>
-=item src/pic.c and src/pic_jit.c [eligible in 1.1]
-
-These two files were a thin prototype implementation of Polymorphic Inline
-Caching that only ever applied to 4 opcodes, one of which has now been removed.
-The files (and all functions in them) are deprecated, and will be removed.
-
-L<http://rt.perl.org/rt3/Ticket/Display.html?id=60048>
-
=item Subs marked with C<:vtable>/C<:method> aren't in namespace [eligible in 1.1]
Subs marked with C<:vtable> or C<:method> flags are no longer given a
Modified: branches/kill_jit/MANIFEST
==============================================================================
--- branches/kill_jit/MANIFEST Wed Sep 16 20:55:27 2009 (r41308)
+++ branches/kill_jit/MANIFEST Wed Sep 16 21:22:58 2009 (r41309)
@@ -1,7 +1,7 @@
# ex: set ro:
# $Id$
#
-# generated by tools/dev/mk_manifest_and_skip.pl Wed Sep 16 00:00:53 2009 UT
+# generated by tools/dev/mk_manifest_and_skip.pl Wed Sep 16 21:14:43 2009 UT
#
# See below for documentation on the format of this file.
#
@@ -232,6 +232,7 @@
config/auto/env/test_setenv_c.in []
config/auto/env/test_unsetenv_c.in []
config/auto/format.pm []
+config/auto/frames.pm []
config/auto/funcptr.pm []
config/auto/funcptr/test_c.in []
config/auto/gc.pm []
@@ -996,7 +997,6 @@
include/parrot/oplib.h [main]include
include/parrot/packfile.h [main]include
include/parrot/parrot.h [main]include
-include/parrot/pic.h [main]include
include/parrot/pmc.h [main]include
include/parrot/pmc_freeze.h [main]include
include/parrot/pobj.h [main]include
@@ -1286,8 +1286,6 @@
src/gc/gc_malloc.c []
src/gc/gc_ms.c []
src/gc/gc_private.h []
-src/gc/generational_ms.c []
-src/gc/incremental_ms.c []
src/gc/malloc.c []
src/gc/malloc_trace.c []
src/gc/mark_sweep.c []
@@ -1319,13 +1317,6 @@
src/jit/i386/exec_dep.h []
src/jit/i386/jit_defs.c []
src/jit/i386/jit_emit.h []
-src/jit/ppc/asm.s []
-src/jit/ppc/core.jit []
-src/jit/ppc/exec_dep.c []
-src/jit/ppc/exec_dep.h []
-src/jit/ppc/jit_defs.c []
-src/jit/ppc/jit_emit.h []
-src/jit/ppc/ppc-linux.s []
src/jit_debug.c []
src/jit_debug_xcoff.c []
src/key.c []
@@ -1348,7 +1339,6 @@
src/ops/object.ops []
src/ops/ops.num [devel]src
src/ops/ops.skip []
-src/ops/pic.ops []
src/ops/pmc.ops []
src/ops/set.ops []
src/ops/string.ops []
@@ -1363,7 +1353,6 @@
src/pbc_dump.c []
src/pbc_merge.c []
src/pic.c []
-src/pic_jit.c []
src/pmc.c []
src/pmc/addrregistry.pmc [devel]src
src/pmc/array.pmc [devel]src
Modified: branches/kill_jit/PBC_COMPAT
==============================================================================
--- branches/kill_jit/PBC_COMPAT Wed Sep 16 20:55:27 2009 (r41308)
+++ branches/kill_jit/PBC_COMPAT Wed Sep 16 21:22:58 2009 (r41309)
@@ -27,6 +27,7 @@
# please insert tab separated entries at the top of the list
+5.2 2009.09.16 darbelo remove pic.ops
5.2 2009.08.06 dukeleto remove Random PMC
5.1 2009.08.06 cotto remove branch_cs opcode
5.0 2009.07.21 cotto released 1.4.0
Modified: branches/kill_jit/compilers/imcc/imc.h
==============================================================================
--- branches/kill_jit/compilers/imcc/imc.h Wed Sep 16 20:55:27 2009 (r41308)
+++ branches/kill_jit/compilers/imcc/imc.h Wed Sep 16 21:22:58 2009 (r41309)
@@ -573,7 +573,6 @@
struct code_segment_t *prev; /* previous code segment */
struct code_segment_t *next; /* next code segment */
SymHash key_consts; /* this seg's cached key constants */
- int pic_idx; /* next index of PIC */
} code_segment_t;
typedef struct _imcc_globals_t {
Modified: branches/kill_jit/compilers/imcc/imcc.l
==============================================================================
--- branches/kill_jit/compilers/imcc/imcc.l Wed Sep 16 20:55:27 2009 (r41308)
+++ branches/kill_jit/compilers/imcc/imcc.l Wed Sep 16 21:22:58 2009 (r41309)
@@ -519,9 +519,10 @@
}
<emit,INITIAL>{DOT}{LETTER}{LETTERDIGIT}* {
- char * const macro_name = yytext + 1;
-
- if (!expand_macro(interp, macro_name, yyscanner)) {
+ char * const macro_name = mem_sys_strdup(yytext + 1);
+ int failed = expand_macro(interp, macro_name, yyscanner);
+ mem_sys_free(macro_name);
+ if (! failed) {
yyless(1);
return DOT;
}
Modified: branches/kill_jit/compilers/imcc/imclexer.c
==============================================================================
--- branches/kill_jit/compilers/imcc/imclexer.c Wed Sep 16 20:55:27 2009 (r41308)
+++ branches/kill_jit/compilers/imcc/imclexer.c Wed Sep 16 21:22:58 2009 (r41309)
@@ -3618,9 +3618,10 @@
YY_RULE_SETUP
#line 521 "compilers/imcc/imcc.l"
{
- char * const macro_name = yytext + 1;
-
- if (!expand_macro(interp, macro_name, yyscanner)) {
+ char * const macro_name = mem_sys_strdup(yytext + 1);
+ int failed = expand_macro(interp, macro_name, yyscanner);
+ mem_sys_free(macro_name);
+ if (! failed) {
yyless(1);
return DOT;
}
@@ -3628,32 +3629,32 @@
YY_BREAK
case 117:
YY_RULE_SETUP
-#line 532 "compilers/imcc/imcc.l"
+#line 533 "compilers/imcc/imcc.l"
DUP_AND_RET(valp, FLOATC);
YY_BREAK
case 118:
YY_RULE_SETUP
-#line 533 "compilers/imcc/imcc.l"
+#line 534 "compilers/imcc/imcc.l"
DUP_AND_RET(valp, INTC);
YY_BREAK
case 119:
YY_RULE_SETUP
-#line 534 "compilers/imcc/imcc.l"
+#line 535 "compilers/imcc/imcc.l"
DUP_AND_RET(valp, INTC);
YY_BREAK
case 120:
YY_RULE_SETUP
-#line 535 "compilers/imcc/imcc.l"
+#line 536 "compilers/imcc/imcc.l"
DUP_AND_RET(valp, INTC);
YY_BREAK
case 121:
YY_RULE_SETUP
-#line 536 "compilers/imcc/imcc.l"
+#line 537 "compilers/imcc/imcc.l"
DUP_AND_RET(valp, INTC);
YY_BREAK
case 122:
YY_RULE_SETUP
-#line 538 "compilers/imcc/imcc.l"
+#line 539 "compilers/imcc/imcc.l"
{
valp->s = mem_sys_strdup(yytext);
@@ -3666,7 +3667,7 @@
YY_BREAK
case 123:
YY_RULE_SETUP
-#line 548 "compilers/imcc/imcc.l"
+#line 549 "compilers/imcc/imcc.l"
{
valp->s = mem_sys_strdup(yytext);
@@ -3676,7 +3677,7 @@
YY_BREAK
case 124:
YY_RULE_SETUP
-#line 555 "compilers/imcc/imcc.l"
+#line 556 "compilers/imcc/imcc.l"
{
macro_frame_t *frame;
@@ -3707,7 +3708,7 @@
YY_BREAK
case 125:
YY_RULE_SETUP
-#line 583 "compilers/imcc/imcc.l"
+#line 584 "compilers/imcc/imcc.l"
{
/* charset:"..." */
valp->s = mem_sys_strdup(yytext);
@@ -3718,7 +3719,7 @@
YY_BREAK
case 126:
YY_RULE_SETUP
-#line 591 "compilers/imcc/imcc.l"
+#line 592 "compilers/imcc/imcc.l"
{
if (valp) (valp)->s = yytext;
if (IMCC_INFO(interp)->state->pasm_file)
@@ -3729,7 +3730,7 @@
YY_BREAK
case 127:
YY_RULE_SETUP
-#line 599 "compilers/imcc/imcc.l"
+#line 600 "compilers/imcc/imcc.l"
{
if (valp) (valp)->s = yytext;
if (IMCC_INFO(interp)->state->pasm_file)
@@ -3740,7 +3741,7 @@
YY_BREAK
case 128:
YY_RULE_SETUP
-#line 607 "compilers/imcc/imcc.l"
+#line 608 "compilers/imcc/imcc.l"
{
if (valp) (valp)->s = yytext;
if (IMCC_INFO(interp)->state->pasm_file)
@@ -3751,7 +3752,7 @@
YY_BREAK
case 129:
YY_RULE_SETUP
-#line 615 "compilers/imcc/imcc.l"
+#line 616 "compilers/imcc/imcc.l"
{
if (valp) (valp)->s = yytext;
if (IMCC_INFO(interp)->state->pasm_file)
@@ -3762,7 +3763,7 @@
YY_BREAK
case 130:
YY_RULE_SETUP
-#line 623 "compilers/imcc/imcc.l"
+#line 624 "compilers/imcc/imcc.l"
{
IMCC_fataly(interp, EXCEPTION_SYNTAX_ERROR,
"'%s' is not a valid register name", yytext);
@@ -3770,7 +3771,7 @@
YY_BREAK
case 131:
YY_RULE_SETUP
-#line 628 "compilers/imcc/imcc.l"
+#line 629 "compilers/imcc/imcc.l"
{
if (IMCC_INFO(interp)->state->pasm_file == 0)
IMCC_fataly(interp, EXCEPTION_SYNTAX_ERROR,
@@ -3784,7 +3785,7 @@
YY_BREAK
case 132:
YY_RULE_SETUP
-#line 639 "compilers/imcc/imcc.l"
+#line 640 "compilers/imcc/imcc.l"
{
if (!IMCC_INFO(interp)->is_def) {
SymReg *r = find_sym(interp, yytext);
@@ -3815,19 +3816,19 @@
YY_BREAK
case 133:
YY_RULE_SETUP
-#line 668 "compilers/imcc/imcc.l"
+#line 669 "compilers/imcc/imcc.l"
/* skip */;
YY_BREAK
case 134:
YY_RULE_SETUP
-#line 670 "compilers/imcc/imcc.l"
+#line 671 "compilers/imcc/imcc.l"
{
/* catch all except for state macro */
return yytext[0];
}
YY_BREAK
case YY_STATE_EOF(emit):
-#line 675 "compilers/imcc/imcc.l"
+#line 676 "compilers/imcc/imcc.l"
{
BEGIN(INITIAL);
@@ -3840,18 +3841,18 @@
}
YY_BREAK
case YY_STATE_EOF(INITIAL):
-#line 686 "compilers/imcc/imcc.l"
+#line 687 "compilers/imcc/imcc.l"
yyterminate();
YY_BREAK
case 135:
YY_RULE_SETUP
-#line 688 "compilers/imcc/imcc.l"
+#line 689 "compilers/imcc/imcc.l"
DUP_AND_RET(valp, ENDM);
YY_BREAK
case 136:
/* rule 136 can match eol */
YY_RULE_SETUP
-#line 690 "compilers/imcc/imcc.l"
+#line 691 "compilers/imcc/imcc.l"
{
IMCC_INFO(interp)->line++;
DUP_AND_RET(valp, '\n');
@@ -3859,12 +3860,12 @@
YY_BREAK
case 137:
YY_RULE_SETUP
-#line 695 "compilers/imcc/imcc.l"
+#line 696 "compilers/imcc/imcc.l"
return LABEL;
YY_BREAK
case 138:
YY_RULE_SETUP
-#line 697 "compilers/imcc/imcc.l"
+#line 698 "compilers/imcc/imcc.l"
{
if (yylex(valp,yyscanner,interp) != LABEL)
@@ -3891,7 +3892,7 @@
YY_BREAK
case 139:
YY_RULE_SETUP
-#line 721 "compilers/imcc/imcc.l"
+#line 722 "compilers/imcc/imcc.l"
{
if (valp) {
const size_t len = strlen(IMCC_INFO(interp)->cur_macro_name) + yyleng + 12;
@@ -3910,49 +3911,49 @@
YY_BREAK
case 140:
YY_RULE_SETUP
-#line 737 "compilers/imcc/imcc.l"
+#line 738 "compilers/imcc/imcc.l"
/* skip leading ws */;
YY_BREAK
case 141:
YY_RULE_SETUP
-#line 738 "compilers/imcc/imcc.l"
+#line 739 "compilers/imcc/imcc.l"
DUP_AND_RET(valp, ' ');
YY_BREAK
case 142:
YY_RULE_SETUP
-#line 739 "compilers/imcc/imcc.l"
+#line 740 "compilers/imcc/imcc.l"
DUP_AND_RET(valp, REG);
YY_BREAK
case 143:
YY_RULE_SETUP
-#line 740 "compilers/imcc/imcc.l"
+#line 741 "compilers/imcc/imcc.l"
DUP_AND_RET(valp, REG);
YY_BREAK
case 144:
YY_RULE_SETUP
-#line 741 "compilers/imcc/imcc.l"
+#line 742 "compilers/imcc/imcc.l"
DUP_AND_RET(valp, IDENTIFIER);
YY_BREAK
case 145:
YY_RULE_SETUP
-#line 742 "compilers/imcc/imcc.l"
+#line 743 "compilers/imcc/imcc.l"
DUP_AND_RET(valp, MACRO);
YY_BREAK
case 146:
YY_RULE_SETUP
-#line 743 "compilers/imcc/imcc.l"
+#line 744 "compilers/imcc/imcc.l"
DUP_AND_RET(valp, yytext[0]);
YY_BREAK
case YY_STATE_EOF(macro):
-#line 744 "compilers/imcc/imcc.l"
+#line 745 "compilers/imcc/imcc.l"
yyterminate();
YY_BREAK
case 147:
YY_RULE_SETUP
-#line 746 "compilers/imcc/imcc.l"
+#line 747 "compilers/imcc/imcc.l"
ECHO;
YY_BREAK
-#line 3956 "compilers/imcc/imclexer.c"
+#line 3957 "compilers/imcc/imclexer.c"
case YY_STATE_EOF(pod):
case YY_STATE_EOF(cmt1):
case YY_STATE_EOF(cmt2):
@@ -5154,7 +5155,7 @@
#define YYTABLES_NAME "yytables"
-#line 746 "compilers/imcc/imcc.l"
+#line 747 "compilers/imcc/imcc.l"
Modified: branches/kill_jit/compilers/imcc/pbc.c
==============================================================================
--- branches/kill_jit/compilers/imcc/pbc.c Wed Sep 16 20:55:27 2009 (r41308)
+++ branches/kill_jit/compilers/imcc/pbc.c Wed Sep 16 21:22:58 2009 (r41309)
@@ -2018,24 +2018,14 @@
constant_folding(interp, unit);
store_sub_size(interp, code_size, ins_size);
- /*
- * allocate code and pic_index
- *
- * pic_index is half the size of the code, as one PIC-cacheable opcode
- * is at least two opcodes wide - see below how to further decrease
- * this storage
- */
+ /* allocate code */
interp->code->base.data = (opcode_t *)
mem_sys_realloc(interp->code->base.data, bytes);
/* reallocating this removes its mmaped-ness; needs encapsulation */
interp->code->base.pf->is_mmap_ped = 0;
- interp->code->pic_index->data = (opcode_t *)
- mem_sys_realloc(interp->code->pic_index->data, bytes / 2);
-
interp->code->base.size = oldsize + code_size;
- interp->code->pic_index->size = (oldsize + code_size) / 2;
IMCC_INFO(interp)->pc = (opcode_t *)interp->code->base.data + oldsize;
IMCC_INFO(interp)->npc = 0;
@@ -2160,21 +2150,6 @@
op = (opcode_t)ins->opnum;
- /* add PIC idx */
- if (parrot_PIC_op_is_cached(op)) {
- const size_t offs = IMCC_INFO(interp)->pc - interp->code->base.data;
- /*
- * for pic_idx fitting into a short, we could
- * further reduce the size by storing shorts
- * the relation code_size / pic_index_size could
- * indicate the used storage
- *
- * drawback: if we reach 0xffff, we'd have to resize again
- */
- interp->code->pic_index->data[offs / 2] =
- ++IMCC_INFO(interp)->globals->cs->pic_idx;
- }
-
/* Start generating the bytecode */
*(IMCC_INFO(interp)->pc)++ = op;
Modified: branches/kill_jit/config/auto/headers.pm
==============================================================================
--- branches/kill_jit/config/auto/headers.pm Wed Sep 16 20:55:27 2009 (r41308)
+++ branches/kill_jit/config/auto/headers.pm Wed Sep 16 21:22:58 2009 (r41309)
@@ -104,6 +104,16 @@
if ( $conf->data->get_p5('OSNAME') eq "msys" ) {
push @extra_headers, qw(sysmman.h netdb.h);
}
+
+ if ( $conf->data->get_p5('OSNAME') eq "MSWin32" ) {
+ # Microsoft provides two annotations mechanisms. __declspec, which has been
+ # around for a while, and Microsoft's standard source code annotation
+ # language (SAL), introduced with Visual C++ 8.0.
+ # See <http://msdn2.microsoft.com/en-us/library/ms235402(VS.80).aspx>,
+ # <http://msdn2.microsoft.com/en-us/library/dabb5z75(VS.80).aspx>.
+ push @extra_headers, qw(sal.h);
+ }
+
return @extra_headers;
}
Modified: branches/kill_jit/config/auto/msvc.pm
==============================================================================
--- branches/kill_jit/config/auto/msvc.pm Wed Sep 16 20:55:27 2009 (r41308)
+++ branches/kill_jit/config/auto/msvc.pm Wed Sep 16 21:22:58 2009 (r41309)
@@ -90,13 +90,6 @@
# To disable deprecation, use _CRT_SECURE_NO_DEPRECATE. See online help
# for details.
$conf->data->add( " ", "ccflags", "-D_CRT_SECURE_NO_DEPRECATE" );
-
- # Microsoft provides two annotations mechanisms. __declspec, which has been
- # around for a while, and Microsoft's standard source code annotation
- # language (SAL), introduced with Visual C++ 8.0.
- # See <http://msdn2.microsoft.com/en-us/library/ms235402(VS.80).aspx>,
- # <http://msdn2.microsoft.com/en-us/library/dabb5z75(VS.80).aspx>.
- $conf->data->set( HAS_MSVC_SAL => 1 );
}
return 1;
}
Modified: branches/kill_jit/config/gen/makefiles/root.in
==============================================================================
--- branches/kill_jit/config/gen/makefiles/root.in Wed Sep 16 20:55:27 2009 (r41308)
+++ branches/kill_jit/config/gen/makefiles/root.in Wed Sep 16 21:22:58 2009 (r41309)
@@ -419,8 +419,6 @@
$(SRC_DIR)/extend_vtable$(O) \
$(SRC_DIR)/gc/alloc_memory$(O) \
$(SRC_DIR)/gc/api$(O) \
- $(SRC_DIR)/gc/generational_ms$(O) \
- $(SRC_DIR)/gc/incremental_ms$(O) \
$(SRC_DIR)/gc/gc_ms$(O) \
$(SRC_DIR)/gc/gc_inf$(O) \
$(SRC_DIR)/gc/mark_sweep$(O) \
@@ -1076,10 +1074,6 @@
$(SRC_DIR)/gc/api$(O) : $(GENERAL_H_FILES) $(SRC_DIR)/gc/gc_private.h
-$(SRC_DIR)/gc/generational_ms$(O) : $(GENERAL_H_FILES)
-
-$(SRC_DIR)/gc/incremental_ms$(O) : $(GENERAL_H_FILES)
-
$(SRC_DIR)/gc/alloc_resources$(O) : $(GENERAL_H_FILES)
$(SRC_DIR)/gc/res_lea$(O) : $(GENERAL_H_FILES)
@@ -1162,9 +1156,6 @@
$(SRC_DIR)/main$(O) : $(SRC_DIR)/main.c $(GENERAL_H_FILES)
-$(SRC_DIR)/pic$(O) : $(GENERAL_H_FILES) $(SRC_DIR)/pmc/pmc_fixedintegerarray.h \
- $(SRC_DIR)/pmc/pmc_continuation.h
-
$(SRC_DIR)/multidispatch$(O) : $(GENERAL_H_FILES) $(SRC_DIR)/multidispatch.str \
$(SRC_DIR)/pmc/pmc_nci.h $(SRC_DIR)/pmc/pmc_sub.h
@@ -1225,8 +1216,6 @@
$(OPS_DIR)/core_ops$(O) : $(GENERAL_H_FILES) $(OPS_DIR)/core_ops.c \
$(SRC_DIR)/pmc/pmc_continuation.h $(SRC_DIR)/pmc/pmc_parrotlibrary.h
-$(OPS_DIR)/pic.ops : $(SRC_DIR)/pmc/pmc_fixedintegerarray.h
-
# core_ops depends upon config.h so that it gets updated along with
# updates to config.h's version numbers
Modified: branches/kill_jit/docs/memory_internals.pod
==============================================================================
--- branches/kill_jit/docs/memory_internals.pod Wed Sep 16 20:55:27 2009 (r41308)
+++ branches/kill_jit/docs/memory_internals.pod Wed Sep 16 21:22:58 2009 (r41309)
@@ -51,31 +51,31 @@
typedef struct Interp {
...
- struct Arenas *arena_base;
+ struct Memory_Pools *mem_pools;
...
} Interp;
All object-like things that get allocated during the execution of parrot
-bytecode are managed from the C<arena_base> member of the interpreter
+bytecode are managed from the C<mem_pools> member of the interpreter
structure.
-=head1 Arenas
+=head1 Memory Pools
-C<struct Arenas> holds pointers to a variety of different kinds of managed
+C<struct Memory_Pools> holds pointers to a variety of different kinds of managed
memory. A simplification looks similar to this:
- typedef struct Arenas {
- struct Memory_Pool *memory_pool;
+ typedef struct Memory_Pools {
+ struct Var_Size_Pool *memory_pool;
...
- struct Small_Object_Pool * header_pool;
- struct Small_Object_Pool ** sized_pools;
- } Arenas;
+ struct Fixed_Size_Pool * header_pool;
+ struct Fixed_Size_Pool ** sized_pools;
+ } Memory_Pools;
C<memory_pool> and C<header_pool> are variable and fixed sized pool pointers
-respectively. These are just two examples, there are other C<Memory_Pool>s
-and C<Small_Object_Pool>s in the Parrot system. Pools of type
-C<struct Memory_Pool> are for variable-size objects, such as constant string
-buffers. Pools of type C<struct Small_Object_Pool> are for fixed-size objects
+respectively. These are just two examples, there are other C<Var_Size_Pool>s
+and C<Fixed_Size_Pool>s in the Parrot system. Pools of type
+C<struct Var_Size_Pool> are for variable-size objects, such as constant string
+buffers. Pools of type C<struct Fixed_Size_Pool> are for fixed-size objects
such as headers or PMCs.
=head1 Fixed sized items
@@ -135,28 +135,18 @@
flags are stored in C<PObj-E<gt>flags>, meaning that each PMC must be accessed
during the mark run.
-An alternative approach is to store the GC-Flags together somewhere, such as
-in the individual arenas, as a packed array of bits. This approach, called
-cardmarking, should be indicated by defining the preprocessor variable
-C<ARENA_GC_FLAGS> to 1.
-
-{{ ARENA_GC_FLAGS (nee ARENA_DOD_FLAGS) seems to have been deprecated or
-changed without concomitant update to this document. Someone should figure out
-what this macro used to be and whether it's still relevant. -cotto }}
-
F<pobj.h> provides macros to facilitate referencing individual object flags:
C<gc_flag_SET>, C<gc_flag_CLEAR> and C<gc_flag_TEST>. They make up a portable
way of manipulating the GC-relevant object flags.
=head1 Variable sized items
-Variable-sized items do not exist by themselves, they are always preceded by
-a buffer structure that contains information about them. These buffer
-structures are described above, and the C<UnionVal cache> item typically
-points to the memory block that contains the data. The variable-sized data
-items are managed in two different pools: the C<memory_pool>, which contains
-a general mish-mash of data types, and the C<constant_string_pool> which
-contains immutable string buffers used by programs running on Parrot.
+Variable-sized items do not exist by themselves, they are always wrapped by
+a buffer structure that contains a pointer to the data information about them.
+The variable-sized data items are managed in two different pools: the
+C<memory_pool>, which contains a general mish-mash of data types, and the
+C<constant_string_pool> which contains immutable string buffers used by
+programs running on Parrot.
Here, different memory allocation schemes jump in:
@@ -221,11 +211,6 @@
once. Both allocation schemes therefore use a part of the allocated string to
do this bookkeeping.
-Copying GC uses a C<Buffer_Tail> after the end of the actual variable length
-string and marks such COW strings with C<TAIL_moved> and stores the new address
-in the buffer header, so other users of this string can be updated to reuse the
-same string (RT#47764 one or all other users?).
-
The C<malloc()>/C<free()> approach stores a refcount at C<bufstart>. During the
mark phase all dead users increment the refcount, living users set it to an
huge value. When freeing the buffer, the string is only freed if the refcount
@@ -233,9 +218,9 @@
=head1 Simplified Figure
- +--------+
- +------------------<---| Arenas |<-----------+
- | +--------+-->--+ |
+ +--------------+
+ +--------------<---| Memory Pools |<---------+
+ | +--------------+---+ |
| | |
| +------+ +-----------+ | +=============+
| | S0 |<---| Registers |<--)--| Interpreter |
@@ -249,8 +234,8 @@
+-------+ | | Buffer 2 | | ..String... |<--| Block 2 |
| . | | +----------+ +--------------+ +---------+
+-------+ | | ... | ^ ^ | ... |
- Small Obj | +----------+ | | +---------+
- Pool +-->| Buffer N |--------+----+ Memory Pool
+Fixed Size | +----------+ | | +---------+
+ Pool +-->| Buffer N |--------+----+ Var Size Pool
+----------+
Buffer Memory Block
@@ -261,9 +246,9 @@
=head1 FILES
-mark_sweep.[ch], src/gc/pools.c, resources.[ch], res_lea.c, src/gc/api.c,
-string.[ch], pobj.h. Other garbage collector implementations may use separate
-files as well.
+src/gc/api.c, src/gc/gc_private.h, pobj.h, mark_sweep.[ch],
+alloc_resources.[ch], res_lea.c, string.[ch]. Other garbage collector
+implementations may use separate files as well.
=head1 BUGS
Modified: branches/kill_jit/docs/pdds/pdd09_gc.pod
==============================================================================
--- branches/kill_jit/docs/pdds/pdd09_gc.pod Wed Sep 16 20:55:27 2009 (r41308)
+++ branches/kill_jit/docs/pdds/pdd09_gc.pod Wed Sep 16 21:22:58 2009 (r41309)
@@ -49,18 +49,6 @@
In this GC scheme, after all reachable objects are marked as live, a sweep
through the object arenas collects all unmarked objects.
-=head3 Mark-and-don't-sweep
-
-In this scheme, all objects are marked black (live) when created. White
-objects are free memory available for allocation. When no white objects remain
-(out of memory), the black objects are all changed to white, and a marking
-process runs to mark all reachable objects as live. Any unreachable objects
-are left white, and available for allocation.
-
-In some implementations, the change from black to white is made by simply
-changing the interpretation of the mark bit, for example, from 1 == black to 1
-== white.
-
=head3 Copying collection
In this scheme, live objects are copied into a new memory region. The entire
@@ -162,11 +150,11 @@
=head3 Terminology
A GC run is composed of two distinct operations: Finding objects which are
-dead (the "trace" phase) and freeing dead objects for later reuse (the
-"sweep" phase). The sweep phase is also known as the collection phase. The
-trace phase is also known as the "mark phase" and less frequently as the
-"dead object detection" phase. The use of the term "dead object detection"
-and its acronym DOD has been deprecated.
+dead (the "trace" or "mark" phase) and freeing dead objects for later reuse
+(the "sweep" phase). The sweep phase is also known as the collection phase.
+The trace phase is less frequently known as the "dead object detection" phase.
+The use of the term "dead object detection" and its acronym DOD has been
+deprecated.
=head3 Initial Marking
@@ -291,41 +279,44 @@
resources. The arena structures and arena creation routines are common across
most GC cores, and some GC cores also share mark routines.
-The main interpreter structure has an arena_base member, which is a pointer to
-an Arenas struct.
+The main interpreter structure has an mem_pools member, which is a pointer to
+an Memory_Pools struct.
-=head4 The Arenas structure
+=head4 The Memory_Pools structure
-The Arenas structure contains pointers to a variety of memory pools, each used
-for a specific purpose. Two are Memory_Pool pointers (memory_pool,
-constant_string_pool), and six are Small_Object_Pool structures (pmc_pool,
+The C<Memory_Pools> structure contains pointers to a variety of memory pools,
+each used for a specific purpose. Two are Var_Size_Pool pointers (memory_pool,
+constant_string_pool), and six are Fixed_Size_Pool structures (pmc_pool,
constant_pmc_pool, constant_string_header_pool).
-The Arenas structure holds function pointers for the core defined interface of
-the currently active GC subsystem: C<init_pool>, C<do_gc_mark>,
+The C<Memory_Pools> structure holds function pointers for the core defined
+interface of the currently active GC subsystem: C<init_pool>, C<do_gc_mark>,
C<finalize_gc_system>. It holds various accounting information for the GC
subsystem, including how many GC runs have been completed, amount of memory
allocated since the last run, and total memory allocated. This accounting
information is updated by the GC system. The current block level for GC mark
-and sweep phases is stored in the Arenas structure. (See L<Blocking GC>.)
+and sweep phases is stored in the C<Memory_Pools> structure.
+(See L<Blocking GC>.)
The pointer C<void *gc_private> is reserved for use by the currently active GC
subsystem (with freedom for variation between GC implementations).
-=head4 The Memory_Pool structure
+=head4 The Var_Size_Pool structure
-The Memory_Pool structure is a simple memory pool. It contains a pointer to
-the top block of the allocated pool, the total allocated size of the pool, the
-block size, and some details on the reclamation characteristics of the pool.
-
-=head4 The Small_Object_Pool structure
-
-The Small_Object_Pool structure is a richer memory pool for object allocation.
-It tracks details like the number of allocated and free objects in the pool, a
-list of free objects, and for the generational GC implementation maintains
-linked lists of white, black, and gray PMCs. It contains a pointer to a simple
-Memory_Pool (the base storage of the pool). It holds function pointers for
-adding and retrieving free objects in the pool, and for allocating objects.
+The C<Var_Size_Pool> structure is a simple memory pool. It contains a pointer
+to the top block of the allocated pool, the total allocated size of the pool,
+the block size, and some details on the reclamation characteristics of the
+pool.
+
+=head4 The Fixed_Size_Pool structure
+
+The C<Fixed_Size_Pool> structure is a richer memory pool for object
+allocation. It tracks details like the number of allocated and free objects
+in the pool, a list of free objects, and for the generational GC
+implementation maintains linked lists of white, black, and gray PMCs. It
+contains a pointer to a simple C<Var_Size_Pool> (the base storage of the
+pool). It holds function pointers for adding and retrieving free objects in
+the pool, and for allocating objects.
=head3 Internal API
@@ -343,7 +334,7 @@
Each GC core declares an initialization routine as a function pointer,
which is installed in F<src/memory.c:mem_setup_allocator()> after
-creating C<arena_base> in the interpreter struct.
+creating C<mem_pools> in the interpreter struct.
=over 4
@@ -352,22 +343,23 @@
A routine to initialize the GC system named C<XXX>.
The initialization code is responsible for the creation of the header pools
-and fills the function pointer slots in the interpreter's C<arena_base>
+and fills the function pointer slots in the interpreter's C<mem_pools>
member.
=back
-=head4 Arenas structure function pointers
+=head4 Memory_Pools structure function pointers
-Each GC system declares 3 function pointers, stored in the Arenas structure.
+Each GC system declares 3 function pointers, stored in the Memory_Pools
+structure.
=over 4
=item C<void (*init_gc_system) (Interp *)>
Initialize the GC system. Install the additional function pointers into
-the Arenas structure, and prepare any private storage to be used by
-the GC in the Arenas->gc_private field.
+the Memory_Pools structure, and prepare any private storage to be used by
+the GC in the Memory_Pools->gc_private field.
=item C<void (*do_gc_mark) (Interp *, int flags)>
@@ -432,23 +424,23 @@
All PMCs must be swept, and PMCs with custom destroy VTABLE methods must have
those called.
-=item C<void (*init_pool) (Interp *, Small_Object_Pool *)>
+=item C<void (*init_pool) (Interp *, Fixed_Size_Pool *)>
-Initialize the given pool. Populates the C<Small_Object_Pool> structure with
+Initialize the given pool. Populates the C<Fixed_Size_Pool> structure with
initial values, and sets a series of function pointers for working with the
pool. The function pointers used with the pool are discussed next.
=back
-=head4 Small_Object_Pool function pointers
+=head4 Fixed_Size_Pool function pointers
-Each GC core defines 4 function pointers stored in the C<Small_Object_Pool>
+Each GC core defines 4 function pointers stored in the C<Fixed_Size_Pool>
structures. These function pointers are used throughout Parrot to implement
basic behaviors for the pool.
=over 4
-=item C<PObj * (*get_free_object) (Interp *, Small_Object_Pool*)>
+=item C<PObj * (*get_free_object) (Interp *, Fixed_Size_Pool*)>
Get a free object from the pool. This function returns one free object from
the given pool and removes that object from the pool's free list. PObject
@@ -456,20 +448,20 @@
itself, if any. If the pool is a buffer header pool all other object memory
is zeroed.
-=item C<void (*add_free_object) (Interp *, Small_Object_Pool *, PObj *);>
+=item C<void (*add_free_object) (Interp *, Fixed_Size_Pool *, PObj *);>
Add a freed object to the pool's free list. This function is most often called
internally to the GC itself to add items to the free list after a sweep, or
when a new arena is created to add the new items to the free list. It does
not need to be used in this way, however.
-=item C<void (*alloc_objects) (Interp *, Small_Object_Pool *);>
+=item C<void (*alloc_objects) (Interp *, Fixed_Size_Pool *);>
Allocate a new arena of objects for the pool. Initialize the new arena and add
all new objects to the pool's free list. Some collectors implement a growth
factor which increases the size of each new allocated arena.
-=item C<void (*more_objects) (Interp *, Small_Object_Pool *);>
+=item C<void (*more_objects) (Interp *, Fixed_Size_Pool *);>
Reallocation for additional objects. It has the same signature as
C<alloc_objects>, and in some GC cores the same function pointer is used for
Modified: branches/kill_jit/include/parrot/compiler.h
==============================================================================
--- branches/kill_jit/include/parrot/compiler.h Wed Sep 16 20:55:27 2009 (r41308)
+++ branches/kill_jit/include/parrot/compiler.h Wed Sep 16 21:22:58 2009 (r41309)
@@ -103,25 +103,21 @@
*/
#define UNUSED(a) /*@-noeffect*/if (0) (void)(a)/*@=noeffect*/;
-/* 64-bit CL has some problems, so this section here is going to try to fix them */
-#ifdef PARROT_HAS_MSVC_SAL
-# ifdef _WIN64
- /* CL64 can't seem to find sal.h, so take that out of the equation */
-# undef PARROT_HAS_MSVC_SAL
- /* CL64 complains about not finding _iob, so this might fix it */
-
-
-# endif
-#endif
-
-#ifdef PARROT_HAS_MSVC_SAL
+#ifdef PARROT_HAS_HEADER_SAL
+/*
+ * Microsoft provides two annotations mechanisms. __declspec, which has been
+ * around for a while, and Microsoft's standard source code annotation
+ * language (SAL), introduced with Visual C++ 8.0.
+ * See <http://msdn2.microsoft.com/en-us/library/ms235402(VS.80).aspx>,
+ * <http://msdn2.microsoft.com/en-us/library/dabb5z75(VS.80).aspx>.
+ */
# include <sal.h>
# define PARROT_CAN_RETURN_NULL /*@null@*/ __maybenull
# define PARROT_CANNOT_RETURN_NULL /*@notnull@*/ __notnull
#else
# define PARROT_CAN_RETURN_NULL /*@null@*/
# define PARROT_CANNOT_RETURN_NULL /*@notnull@*/
-#endif
+#endif /* PARROT_HAS_HEADER_SAL */
#define PARROT_DEPRECATED __attribute__deprecated__
@@ -146,7 +142,7 @@
/* Function argument instrumentation */
/* For explanations of the annotations, see http://www.splint.org/manual/manual.html */
-#ifdef PARROT_HAS_MSVC_SAL
+#ifdef PARROT_HAS_HEADER_SAL
# define NOTNULL(x) /*@notnull@*/ __notnull x
/* The pointer passed may not be NULL */
Modified: branches/kill_jit/include/parrot/gc_api.h
==============================================================================
--- branches/kill_jit/include/parrot/gc_api.h Wed Sep 16 20:55:27 2009 (r41308)
+++ branches/kill_jit/include/parrot/gc_api.h Wed Sep 16 21:22:58 2009 (r41309)
@@ -43,31 +43,11 @@
POOL_ALL = 0x07
} pool_iter_enum;
-struct Small_Object_Pool;
-struct Small_Object_Arena;
-struct Arenas;
-
-typedef int (*pool_iter_fn)(PARROT_INTERP, struct Small_Object_Pool *, int, void*);
-
-typedef struct Memory_Block {
- size_t free;
- size_t size;
- struct Memory_Block *prev;
- struct Memory_Block *next;
- char *start;
- char *top;
-} Memory_Block;
-
-typedef struct Memory_Pool {
- Memory_Block *top_block;
- void (*compact)(PARROT_INTERP, struct Memory_Pool *);
- size_t minimum_block_size;
- size_t total_allocated; /* total bytes allocated to this pool */
- size_t guaranteed_reclaimable; /* bytes that can definitely be reclaimed*/
- size_t possibly_reclaimable; /* bytes that can possibly be reclaimed
- * (above plus COW-freed bytes) */
- FLOATVAL reclaim_factor; /* minimum percentage we will reclaim */
-} Memory_Pool;
+struct Memory_Block;
+struct Var_Size_Pool;
+struct Fixed_Size_Pool;
+struct Fixed_Size_Arena;
+struct Memory_Pools;
typedef enum {
GC_TRACE_FULL = 1,
@@ -75,25 +55,12 @@
GC_TRACE_SYSTEM_ONLY = 3
} Parrot_gc_trace_type;
-typedef void (*add_free_object_fn_type)(PARROT_INTERP, struct Small_Object_Pool *, void *);
-typedef void * (*get_free_object_fn_type)(PARROT_INTERP, struct Small_Object_Pool *);
-typedef void (*alloc_objects_fn_type)(PARROT_INTERP, struct Small_Object_Pool *);
-typedef void (*gc_object_fn_type)(PARROT_INTERP, struct Small_Object_Pool *, PObj *);
+typedef int (*pool_iter_fn)(PARROT_INTERP, struct Fixed_Size_Pool *, int, void*);
+typedef void (*add_free_object_fn_type)(PARROT_INTERP, struct Fixed_Size_Pool *, void *);
+typedef void * (*get_free_object_fn_type)(PARROT_INTERP, struct Fixed_Size_Pool *);
+typedef void (*alloc_objects_fn_type)(PARROT_INTERP, struct Fixed_Size_Pool *);
+typedef void (*gc_object_fn_type)(PARROT_INTERP, struct Fixed_Size_Pool *, PObj *);
-/*
- * macros used in arena scan code to convert from object pointers
- * to arena pointers ...
- */
-
-#if PARROT_GC_GMS
-# define GC_HEADER_SIZE (sizeof (Gc_gms_hdr))
-# define PObj_to_ARENA(o) PObj_to_GMSH(o)
-# define ARENA_to_PObj(p) GMSH_to_PObj((Gc_gms_hdr*)(p))
-#else
-# define GC_HEADER_SIZE 0
-# define PObj_to_ARENA(o) (o)
-# define ARENA_to_PObj(p) (p)
-#endif
/* &gen_from_enum(interpinfo.pasm) prefix(INTERPINFO_) */
@@ -481,41 +448,6 @@
void Parrot_gc_inf_init(PARROT_INTERP);
-/* write barrier */
-#if PARROT_GC_MS
-# define GC_WRITE_BARRIER(interp, agg, old, _new) do { } while (0)
-# define GC_WRITE_BARRIER_KEY(interp, agg, old, old_key, _new, new_key) do { } while (0)
-#endif
-
-#if PARROT_GC_GMS
-# define GC_WRITE_BARRIER(interp, agg, old, _new) do { \
- UINTVAL gen_agg, gen_new; \
- if (!(_new) || PMC_IS_NULL(_new)) \
- break; \
- gen_agg = PObj_to_GMSH(agg)->gen->gen_no; \
- gen_new = PObj_to_GMSH(_new)->gen->gen_no; \
- if (gen_agg < gen_new) \
- parrot_gc_gms_wb((interp), (agg), (old), (_new)); \
-} while (0)
-
-# define GC_WRITE_BARRIER_KEY(interp, agg, old, old_key, _new, new_key) do { \
- UINTVAL gen_agg, gen_new, gen_key; \
- if (!(_new) || PMC_IS_NULL(_new)) \
- break; \
- gen_agg = PObj_to_GMSH(agg)->gen->gen_no; \
- gen_new = PObj_to_GMSH(_new)->gen->gen_no; \
- gen_key = PObj_to_GMSH(new_key)->gen->gen_no; \
- if (gen_agg < gen_new || gen_agg < gen_key) \
- parrot_gc_gms_wb_key((interp), (agg), (old), (old_key), (_new), (new_key)); \
-} while (0)
-
-#endif
-
-#if PARROT_GC_INF
-# define GC_WRITE_BARRIER(interp, agg, old, _new) do { } while (0)
-# define GC_WRITE_BARRIER_KEY(interp, agg, old, old_key, _new, new_key) do { } while (0)
-#endif
-
#endif /* PARROT_GC_API_H_GUARD */
/*
Modified: branches/kill_jit/include/parrot/interpreter.h
==============================================================================
--- branches/kill_jit/include/parrot/interpreter.h Wed Sep 16 20:55:27 2009 (r41308)
+++ branches/kill_jit/include/parrot/interpreter.h Wed Sep 16 21:22:58 2009 (r41309)
@@ -183,16 +183,20 @@
int n_free_slots; /* amount of allocated */
} context_mem;
-
struct _handler_node_t; /* forward def - exit.h */
/* The actual interpreter structure */
struct parrot_interp_t {
PMC *ctx; /* current Context */
- struct Arenas *arena_base; /* Pointer to this interpreter's
+ struct Memory_Pools *mem_pools; /* Pointer to this interpreter's
* arena */
+ struct GC_Subsystem *gc_sys; /*functions and data specific
+ to current GC subsystem*/
+
+ PMC *gc_registry; /* root set of registered PMCs */
+
PMC *class_hash; /* Hash of classes */
VTABLE **vtables; /* array of vtable ptrs */
int n_vtable_max; /* highest used type */
@@ -263,7 +267,6 @@
/* 8: PMC *PBC_Libs Hash of load_bytecode cde */
/* 9: PMC *Executable String PMC with name from argv[0]. */
- PMC *gc_registry; /* root set of registered PMCs */
PMC *HLL_info; /* HLL names and types */
PMC *HLL_namespace; /* cache of HLL toplevel ns */
@@ -294,7 +297,6 @@
UINTVAL recursion_limit; /* Sub call resursion limit */
- UINTVAL gc_generation; /* GC generation number */
opcode_t *current_args; /* ptr into code w/ set_args op */
opcode_t *current_params; /* ... w/ get_params op */
Modified: branches/kill_jit/include/parrot/oo.h
==============================================================================
--- branches/kill_jit/include/parrot/oo.h Wed Sep 16 20:55:27 2009 (r41308)
+++ branches/kill_jit/include/parrot/oo.h Wed Sep 16 21:22:58 2009 (r41309)
@@ -32,7 +32,7 @@
#define get_attrib_num(x, y) ((PMC **)(x))[(y)]
#define set_attrib_num(o, x, y, z) \
do { \
- GC_WRITE_BARRIER(interp, (o), ((PMC **)(x))[y], (z)); \
+ Parrot_gc_write_barrier(interp, (o), ((PMC **)(x))[y], (z)); \
((PMC **)(x))[(y)] = (z); \
} while (0)
Modified: branches/kill_jit/include/parrot/packfile.h
==============================================================================
--- branches/kill_jit/include/parrot/packfile.h Wed Sep 16 20:55:27 2009 (r41308)
+++ branches/kill_jit/include/parrot/packfile.h Wed Sep 16 21:22:58 2009 (r41309)
@@ -266,8 +266,6 @@
PackFile_Segment base;
Prederef prederef; /* The predereferenced code and info */
struct Parrot_jit_info_t *jit_info; /* JITs data */
- Parrot_PIC_store *pic_store; /* PIC storage */
- PackFile_Segment *pic_index; /* segment of indices into store */
struct PackFile_Debug *debugs;
PackFile_ConstTable *const_table;
PackFile_FixupTable *fixups;
Modified: branches/kill_jit/include/parrot/parrot.h
==============================================================================
--- branches/kill_jit/include/parrot/parrot.h Wed Sep 16 20:55:27 2009 (r41308)
+++ branches/kill_jit/include/parrot/parrot.h Wed Sep 16 21:22:58 2009 (r41309)
@@ -271,7 +271,6 @@
#include "parrot/exceptions.h"
#include "parrot/warnings.h"
#include "parrot/memory.h"
-#include "parrot/pic.h"
#include "parrot/packfile.h"
#include "parrot/io.h"
#include "parrot/op.h"
Deleted: branches/kill_jit/include/parrot/pic.h
==============================================================================
--- branches/kill_jit/include/parrot/pic.h Wed Sep 16 21:22:58 2009 (r41308)
+++ /dev/null 00:00:00 1970 (deleted)
@@ -1,204 +0,0 @@
-/* pic.h
- * Copyright (C) 2005, Parrot Foundation.
- * SVN Info
- * $Id$
- * Overview:
- * This is the api header for the pic subsystem
- * Data Structure and Algorithms:
- * History:
- * Notes:
- * References:
- */
-
-#ifndef PARROT_PIC_H_GUARD
-#define PARROT_PIC_H_GUARD
-
-#include "parrot/runcore_api.h"
-
-/*
- * one cache slot
- *
- * if types exceed 16 bits or for general MMD function calls an
- * extended cache slot is needed with more type entries
- */
-typedef struct Parrot_pic_lru_t {
- union {
- INTVAL type; /* for MMD left << 16 | right type */
- PMC *signature; /* arg passing signature */
- } u;
- union {
- funcptr_t real_function; /* the actual C code */
- PMC *sub; /* or a Sub PMC */
- PMC **pattr; /* attribute location */
- } f;
-} Parrot_PIC_lru;
-
-/*
- * PIC 3 more cache slots
- */
-typedef struct Parrot_pic_t {
- Parrot_PIC_lru lru[3]; /* PIC - three more cache entries */
- INTVAL miss_count; /* how many misses */
-} Parrot_PIC;
-
-/*
- * the main used MIC one cache slot - 4 words size
- */
-typedef struct Parrot_mic_t {
- Parrot_PIC_lru lru; /* MIC - one cache */
- union {
- STRING *method; /* for callmethod */
- INTVAL func_nr; /* MMD function number */
- STRING *attribute; /* obj.attribute */
- PMC *sig; /* arg passing */
- } m;
- Parrot_PIC *pic; /* more cache entries */
-} Parrot_MIC;
-
-/*
- * memory is managed by this structure hanging off a
- * PackFile_ByteCode segment
- */
-typedef struct Parrot_pic_store_t {
- struct Parrot_pic_store_t *prev; /* prev pic_store */
- size_t usable; /* size of usable memory: */
- Parrot_PIC *pic; /* from rear */
- Parrot_MIC *mic; /* idx access to allocated MICs */
- size_t n_mics; /* range check, debugging mainly */
-} Parrot_PIC_store;
-
-typedef int (*arg_pass_f)(PARROT_INTERP, PMC *sig,
- char *src_base, void **src_pc, char *dest_base, void **dest_pc);
-
-/* more or less private interfaces */
-
-/* HEADERIZER BEGIN: src/pic.c */
-/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
-
-PARROT_WARN_UNUSED_RESULT
-PARROT_CANNOT_RETURN_NULL
-Parrot_MIC* parrot_PIC_alloc_mic(const PARROT_INTERP, size_t n);
-
-PARROT_WARN_UNUSED_RESULT
-PARROT_CANNOT_RETURN_NULL
-Parrot_PIC* parrot_PIC_alloc_pic(PARROT_INTERP)
- __attribute__nonnull__(1);
-
-void parrot_PIC_alloc_store(ARGOUT(PackFile_ByteCode *cs), size_t n)
- __attribute__nonnull__(1)
- FUNC_MODIFIES(*cs);
-
-PARROT_WARN_UNUSED_RESULT
-int parrot_pic_check_sig(PARROT_INTERP,
- ARGIN(PMC *sig1),
- ARGIN(PMC *sig2),
- ARGOUT(int *type))
- __attribute__nonnull__(1)
- __attribute__nonnull__(2)
- __attribute__nonnull__(3)
- __attribute__nonnull__(4)
- FUNC_MODIFIES(*type);
-
-void parrot_PIC_destroy(ARGMOD(PackFile_ByteCode *cs))
- __attribute__nonnull__(1)
- FUNC_MODIFIES(*cs);
-
-void parrot_pic_find_infix_v_pp(PARROT_INTERP,
- ARGIN(PMC *left),
- ARGIN(PMC *right),
- ARGOUT(Parrot_MIC *mic),
- ARGOUT(opcode_t *cur_opcode))
- __attribute__nonnull__(1)
- __attribute__nonnull__(2)
- __attribute__nonnull__(3)
- __attribute__nonnull__(4)
- __attribute__nonnull__(5)
- FUNC_MODIFIES(*mic)
- FUNC_MODIFIES(*cur_opcode);
-
-PARROT_CONST_FUNCTION
-int parrot_PIC_op_is_cached(int op_code);
-
-PARROT_WARN_UNUSED_RESULT
-PARROT_CAN_RETURN_NULL
-void * parrot_pic_opcode(PARROT_INTERP, INTVAL op)
- __attribute__nonnull__(1);
-
-void parrot_PIC_prederef(PARROT_INTERP,
- opcode_t op,
- ARGOUT(void **pc_pred),
- ARGIN(Parrot_runcore_t *core))
- __attribute__nonnull__(1)
- __attribute__nonnull__(3)
- __attribute__nonnull__(4)
- FUNC_MODIFIES(*pc_pred);
-
-#define ASSERT_ARGS_parrot_PIC_alloc_mic __attribute__unused__ int _ASSERT_ARGS_CHECK = 0
-#define ASSERT_ARGS_parrot_PIC_alloc_pic __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp)
-#define ASSERT_ARGS_parrot_PIC_alloc_store __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(cs)
-#define ASSERT_ARGS_parrot_pic_check_sig __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(sig1) \
- || PARROT_ASSERT_ARG(sig2) \
- || PARROT_ASSERT_ARG(type)
-#define ASSERT_ARGS_parrot_PIC_destroy __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(cs)
-#define ASSERT_ARGS_parrot_pic_find_infix_v_pp __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(left) \
- || PARROT_ASSERT_ARG(right) \
- || PARROT_ASSERT_ARG(mic) \
- || PARROT_ASSERT_ARG(cur_opcode)
-#define ASSERT_ARGS_parrot_PIC_op_is_cached __attribute__unused__ int _ASSERT_ARGS_CHECK = 0
-#define ASSERT_ARGS_parrot_pic_opcode __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp)
-#define ASSERT_ARGS_parrot_PIC_prederef __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(pc_pred) \
- || PARROT_ASSERT_ARG(core)
-/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
-/* HEADERIZER END: src/pic.c */
-
-
-/* HEADERIZER BEGIN: src/pic_jit.c */
-/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
-
-PARROT_WARN_UNUSED_RESULT
-int parrot_pic_is_safe_to_jit(PARROT_INTERP,
- ARGIN(PMC *sub_pmc),
- ARGIN(PMC *sig_args),
- ARGIN(PMC *sig_results),
- ARGOUT(int *flags))
- __attribute__nonnull__(1)
- __attribute__nonnull__(2)
- __attribute__nonnull__(3)
- __attribute__nonnull__(4)
- __attribute__nonnull__(5)
- FUNC_MODIFIES(*flags);
-
-funcptr_t parrot_pic_JIT_sub(PARROT_INTERP, ARGIN(PMC *sub_pmc), int flags)
- __attribute__nonnull__(1)
- __attribute__nonnull__(2);
-
-#define ASSERT_ARGS_parrot_pic_is_safe_to_jit __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(sub_pmc) \
- || PARROT_ASSERT_ARG(sig_args) \
- || PARROT_ASSERT_ARG(sig_results) \
- || PARROT_ASSERT_ARG(flags)
-#define ASSERT_ARGS_parrot_pic_JIT_sub __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(sub_pmc)
-/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
-/* HEADERIZER END: src/pic_jit.c */
-
-#endif /* PARROT_PIC_H_GUARD */
-
-/*
- * Local variables:
- * c-file-style: "parrot"
- * End:
- * vim: expandtab shiftwidth=4:
- */
Modified: branches/kill_jit/include/parrot/pobj.h
==============================================================================
--- branches/kill_jit/include/parrot/pobj.h Wed Sep 16 20:55:27 2009 (r41308)
+++ branches/kill_jit/include/parrot/pobj.h Wed Sep 16 21:22:58 2009 (r41309)
@@ -316,14 +316,6 @@
#define PObj_custom_destroy_TEST(o) PObj_flag_TEST(custom_destroy, o)
#define PObj_custom_destroy_CLEAR(o) PObj_flag_CLEAR(custom_destroy, o)
-/*******************************************************
- * DEPRECATED -- use PObj_custom_destroy_FOO() instead *
- *******************************************************/
-#define PObj_active_destroy_FLAG PObj_custom_destroy_FLAG
-#define PObj_active_destroy_SET(o) PObj_flag_SET(custom_destroy, o)
-#define PObj_active_destroy_TEST(o) PObj_flag_TEST(custom_destroy, o)
-#define PObj_active_destroy_CLEAR(o) PObj_flag_CLEAR(custom_destroy, o)
-
#define PObj_is_class_SET(o) PObj_flag_SET(is_class, o)
#define PObj_is_class_TEST(o) PObj_flag_TEST(is_class, o)
#define PObj_is_class_CLEAR(o) PObj_flag_CLEAR(is_class, o)
@@ -367,6 +359,15 @@
PObj_custom_destroy_SET(o); \
} while (0)
+/*******************************************************
+ * DEPRECATED -- use PObj_custom_destroy_FOO() instead *
+ *******************************************************/
+#define PObj_active_destroy_FLAG PObj_custom_destroy_FLAG
+#define PObj_active_destroy_SET(o) PObj_flag_SET(custom_destroy, o)
+#define PObj_active_destroy_TEST(o) PObj_flag_TEST(custom_destroy, o)
+#define PObj_active_destroy_CLEAR(o) PObj_flag_CLEAR(custom_destroy, o)
+
+
#endif /* PARROT_POBJ_H_GUARD */
/*
Modified: branches/kill_jit/include/parrot/settings.h
==============================================================================
--- branches/kill_jit/include/parrot/settings.h Wed Sep 16 20:55:27 2009 (r41308)
+++ branches/kill_jit/include/parrot/settings.h Wed Sep 16 21:22:58 2009 (r41309)
@@ -35,42 +35,11 @@
#endif /* DISABLE_GC_DEBUG */
/*
- * GC_SUBSYSTEM selection
- * 0 ... MS stop-the-world mark & sweep
- * 1 ... IMS incremental mark & sweep
- * 2 ... GMS generational mark & sweep
- * 3 ... INF infinite memory "collector"
- *
- * Please note that only 0 and 3 currently work (and INF doesn't really
- * "work").
+ * GC_DEFAULT_TYPE selection
+ * MS -- stop-the-world mark & sweep
+ * INF -- infinite memory "collector"
*/
-
-#define PARROT_GC_SUBSYSTEM 0
-
-#if PARROT_GC_SUBSYSTEM == 0
-# define PARROT_GC_MS 1
-# define PARROT_GC_IMS 0
-# define PARROT_GC_GMS 0
-# define PARROT_GC_INF 0
-#endif
-#if PARROT_GC_SUBSYSTEM == 1
-# define PARROT_GC_MS 0
-# define PARROT_GC_IMS 1
-# define PARROT_GC_GMS 0
-# define PARROT_GC_INF 0
-#endif
-#if PARROT_GC_SUBSYSTEM == 2
-# define PARROT_GC_MS 0
-# define PARROT_GC_IMS 0
-# define PARROT_GC_GMS 1
-# define PARROT_GC_INF 0
-#endif
-#if PARROT_GC_SUBSYSTEM == 3
-# define PARROT_GC_MS 0
-# define PARROT_GC_IMS 0
-# define PARROT_GC_GMS 0
-# define PARROT_GC_INF 1
-#endif
+#define PARROT_GC_DEFAULT_TYPE MS
/*
* JIT/i386 can use the CGP run core for external functions instead
Modified: branches/kill_jit/src/gc/alloc_resources.c
==============================================================================
--- branches/kill_jit/src/gc/alloc_resources.c Wed Sep 16 20:55:27 2009 (r41308)
+++ branches/kill_jit/src/gc/alloc_resources.c Wed Sep 16 21:22:58 2009 (r41309)
@@ -32,7 +32,7 @@
#define POOL_SIZE 65536 * 2
-typedef void (*compact_f) (Interp *, Memory_Pool *);
+typedef void (*compact_f) (Interp *, Variable_Size_Pool *);
/* HEADERIZER HFILE: src/gc/gc_private.h */
@@ -41,7 +41,7 @@
static void alloc_new_block(PARROT_INTERP,
size_t size,
- ARGMOD(Memory_Pool *pool),
+ ARGMOD(Variable_Size_Pool *pool),
ARGIN(const char *why))
__attribute__nonnull__(1)
__attribute__nonnull__(3)
@@ -54,16 +54,16 @@
__attribute__nonnull__(1)
__attribute__nonnull__(2);
-static void check_memory_pool(ARGMOD(Memory_Pool *pool))
+static void check_fixed_size_obj_pool(ARGMOD(Fixed_Size_Pool * pool))
__attribute__nonnull__(1)
- FUNC_MODIFIES(*pool);
+ FUNC_MODIFIES(* pool);
static void check_memory_system(PARROT_INTERP)
__attribute__nonnull__(1);
-static void check_small_object_pool(ARGMOD(Small_Object_Pool * pool))
+static void check_var_size_obj_pool(ARGMOD(Variable_Size_Pool *pool))
__attribute__nonnull__(1)
- FUNC_MODIFIES(* pool);
+ FUNC_MODIFIES(*pool);
static void debug_print_buf(PARROT_INTERP, ARGIN(const Buffer *b))
__attribute__nonnull__(1)
@@ -71,7 +71,7 @@
PARROT_MALLOC
PARROT_CANNOT_RETURN_NULL
-static Memory_Pool * new_memory_pool(
+static Variable_Size_Pool * new_memory_pool(
size_t min_block,
NULLOK(compact_f compact));
@@ -82,11 +82,11 @@
#define ASSERT_ARGS_buffer_location __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp) \
|| PARROT_ASSERT_ARG(b)
-#define ASSERT_ARGS_check_memory_pool __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+#define ASSERT_ARGS_check_fixed_size_obj_pool __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(pool)
#define ASSERT_ARGS_check_memory_system __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp)
-#define ASSERT_ARGS_check_small_object_pool __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+#define ASSERT_ARGS_check_var_size_obj_pool __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(pool)
#define ASSERT_ARGS_debug_print_buf __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp) \
@@ -98,8 +98,8 @@
/*
-=item C<static void alloc_new_block(PARROT_INTERP, size_t size, Memory_Pool
-*pool, const char *why)>
+=item C<static void alloc_new_block(PARROT_INTERP, size_t size,
+Variable_Size_Pool *pool, const char *why)>
Allocate a new memory block. We allocate either the requested size or the
default size, whichever is larger. Add the new block to the given memory
@@ -110,7 +110,7 @@
*/
static void
-alloc_new_block(PARROT_INTERP, size_t size, ARGMOD(Memory_Pool *pool),
+alloc_new_block(PARROT_INTERP, size_t size, ARGMOD(Variable_Size_Pool *pool),
ARGIN(const char *why))
{
ASSERT_ARGS(alloc_new_block)
@@ -143,7 +143,7 @@
new_block->top = new_block->start;
/* Note that we've allocated it */
- interp->arena_base->memory_allocated += alloc_size;
+ interp->mem_pools->memory_allocated += alloc_size;
/* If this is for a public pool, add it to the list */
new_block->prev = pool->top_block;
@@ -158,7 +158,8 @@
/*
-=item C<void * mem_allocate(PARROT_INTERP, size_t size, Memory_Pool *pool)>
+=item C<void * mem_allocate(PARROT_INTERP, size_t size, Variable_Size_Pool
+*pool)>
Allocates memory for headers.
@@ -196,7 +197,7 @@
PARROT_MALLOC
PARROT_CANNOT_RETURN_NULL
void *
-mem_allocate(PARROT_INTERP, size_t size, ARGMOD(Memory_Pool *pool))
+mem_allocate(PARROT_INTERP, size_t size, ARGMOD(Variable_Size_Pool *pool))
{
ASSERT_ARGS(mem_allocate)
void *return_val;
@@ -213,20 +214,20 @@
* TODO pass required allocation size to the GC system,
* so that collection can be skipped if needed
*/
- if (!interp->arena_base->gc_mark_block_level
- && interp->arena_base->mem_allocs_since_last_collect) {
+ if (!interp->mem_pools->gc_mark_block_level
+ && interp->mem_pools->mem_allocs_since_last_collect) {
Parrot_gc_mark_and_sweep(interp, GC_trace_stack_FLAG);
-#if !PARROT_GC_IMS && !PARROT_GC_INF
- /* Compact the pool if allowed and worthwhile */
- if (pool->compact) {
- /* don't bother reclaiming if it's just chicken feed */
- if ((pool->possibly_reclaimable * pool->reclaim_factor +
- pool->guaranteed_reclaimable) > size) {
- (*pool->compact) (interp, pool);
- }
+ if (interp->gc_sys->sys_type != INF) {
+ /* Compact the pool if allowed and worthwhile */
+ if (pool->compact) {
+ /* don't bother reclaiming if it's only a small amount */
+ if ((pool->possibly_reclaimable * pool->reclaim_factor +
+ pool->guaranteed_reclaimable) > size) {
+ (*pool->compact) (interp, pool);
+ }
+ }
}
-#endif
}
if (pool->top_block->free < size) {
if (pool->minimum_block_size < 65536 * 16)
@@ -239,7 +240,7 @@
*/
alloc_new_block(interp, size, pool, "compact failed");
- interp->arena_base->mem_allocs_since_last_collect++;
+ interp->mem_pools->mem_allocs_since_last_collect++;
if (pool->top_block->free < size) {
fprintf(stderr, "out of mem\n");
@@ -319,7 +320,7 @@
=over 4
-=item C<void compact_pool(PARROT_INTERP, Memory_Pool *pool)>
+=item C<void compact_pool(PARROT_INTERP, Variable_Size_Pool *pool)>
Compact the string buffer pool. Does not perform a GC scan, or mark items
as being alive in any way.
@@ -329,7 +330,7 @@
*/
void
-compact_pool(PARROT_INTERP, ARGMOD(Memory_Pool *pool))
+compact_pool(PARROT_INTERP, ARGMOD(Variable_Size_Pool *pool))
{
ASSERT_ARGS(compact_pool)
INTVAL j;
@@ -338,19 +339,19 @@
Memory_Block *new_block; /* A pointer to our working block */
char *cur_spot; /* Where we're currently copying to */
- Small_Object_Arena *cur_buffer_arena;
- Arenas * const arena_base = interp->arena_base;
+ Fixed_Size_Arena *cur_buffer_arena;
+ Memory_Pools * const mem_pools = interp->mem_pools;
/* Bail if we're blocked */
- if (arena_base->gc_sweep_block_level)
+ if (mem_pools->gc_sweep_block_level)
return;
- ++arena_base->gc_sweep_block_level;
+ ++mem_pools->gc_sweep_block_level;
/* We're collecting */
- arena_base->mem_allocs_since_last_collect = 0;
- arena_base->header_allocs_since_last_collect = 0;
- arena_base->gc_collect_runs++;
+ mem_pools->mem_allocs_since_last_collect = 0;
+ mem_pools->header_allocs_since_last_collect = 0;
+ mem_pools->gc_collect_runs++;
/* total - reclaimable == currently used. Add a minimum block to the
* current amount, so we can avoid having to allocate it in the future. */
@@ -402,8 +403,8 @@
cur_spot = new_block->start;
/* Run through all the Buffer header pools and copy */
- for (j = (INTVAL)arena_base->num_sized - 1; j >= 0; --j) {
- Small_Object_Pool * const header_pool = arena_base->sized_header_pools[j];
+ for (j = (INTVAL)mem_pools->num_sized - 1; j >= 0; --j) {
+ Fixed_Size_Pool * const header_pool = mem_pools->sized_header_pools[j];
UINTVAL object_size;
if (!header_pool)
@@ -414,7 +415,7 @@
for (cur_buffer_arena = header_pool->last_Arena;
cur_buffer_arena;
cur_buffer_arena = cur_buffer_arena->prev) {
- Buffer *b = (Buffer *)ARENA_to_PObj(cur_buffer_arena->start_objects);
+ Buffer *b = (Buffer *) cur_buffer_arena->start_objects;
UINTVAL i;
const size_t objects_end = cur_buffer_arena->used;
@@ -518,7 +519,7 @@
/* How much is free. That's the total size minus the amount we used */
new_block->free = new_block->size - (new_block->top - new_block->start);
- arena_base->memory_collected += (new_block->top - new_block->start);
+ mem_pools->memory_collected += (new_block->top - new_block->start);
/* Now we're done. We're already on the pool's free list, so let us be the
* only one on the free list and free the rest */
@@ -531,7 +532,7 @@
Memory_Block * const next_block = cur_block->prev;
/* Note that we don't have it any more */
- arena_base->memory_allocated -= cur_block->size;
+ mem_pools->memory_allocated -= cur_block->size;
/* We know the pool body and pool header are a single chunk, so
* this is enough to get rid of 'em both */
@@ -547,7 +548,7 @@
pool->guaranteed_reclaimable = 0;
pool->possibly_reclaimable = 0;
- --arena_base->gc_sweep_block_level;
+ --mem_pools->gc_sweep_block_level;
}
/*
@@ -636,10 +637,10 @@
=over 4
-=item C<static Memory_Pool * new_memory_pool(size_t min_block, compact_f
+=item C<static Variable_Size_Pool * new_memory_pool(size_t min_block, compact_f
compact)>
-Allocate a new C<Memory_Pool> structures, and set some initial values.
+Allocate a new C<Variable_Size_Pool> structures, and set some initial values.
return a pointer to the new pool.
=cut
@@ -648,11 +649,11 @@
PARROT_MALLOC
PARROT_CANNOT_RETURN_NULL
-static Memory_Pool *
+static Variable_Size_Pool *
new_memory_pool(size_t min_block, NULLOK(compact_f compact))
{
ASSERT_ARGS(new_memory_pool)
- Memory_Pool * const pool = mem_internal_allocate_typed(Memory_Pool);
+ Variable_Size_Pool * const pool = mem_internal_allocate_typed(Variable_Size_Pool);
pool->top_block = NULL;
pool->compact = compact;
@@ -667,9 +668,9 @@
/*
-=item C<void initialize_memory_pools(PARROT_INTERP)>
+=item C<void initialize_var_size_pools(PARROT_INTERP)>
-Initialize the managed memory pools. Parrot maintains two C<Memory_Pool>
+Initialize the managed memory pools. Parrot maintains two C<Variable_Size_Pool>
structures, the general memory pool and the constant string pool. Create
and initialize both pool structures, and allocate initial blocks of memory
for both.
@@ -679,23 +680,23 @@
*/
void
-initialize_memory_pools(PARROT_INTERP)
+initialize_var_size_pools(PARROT_INTERP)
{
- ASSERT_ARGS(initialize_memory_pools)
- Arenas * const arena_base = interp->arena_base;
+ ASSERT_ARGS(initialize_var_size_pools)
+ Memory_Pools * const mem_pools = interp->mem_pools;
- arena_base->memory_pool = new_memory_pool(POOL_SIZE, &compact_pool);
- alloc_new_block(interp, POOL_SIZE, arena_base->memory_pool, "init");
+ mem_pools->memory_pool = new_memory_pool(POOL_SIZE, &compact_pool);
+ alloc_new_block(interp, POOL_SIZE, mem_pools->memory_pool, "init");
/* Constant strings - not compacted */
- arena_base->constant_string_pool = new_memory_pool(POOL_SIZE, NULL);
- alloc_new_block(interp, POOL_SIZE, arena_base->constant_string_pool, "init");
+ mem_pools->constant_string_pool = new_memory_pool(POOL_SIZE, NULL);
+ alloc_new_block(interp, POOL_SIZE, mem_pools->constant_string_pool, "init");
}
/*
-=item C<void merge_pools(Memory_Pool *dest, Memory_Pool *source)>
+=item C<void merge_pools(Variable_Size_Pool *dest, Variable_Size_Pool *source)>
Merge two memory pools together. Do this by moving all memory blocks
from the C<*source> pool into the C<*dest> pool. The C<source> pool
@@ -706,7 +707,7 @@
*/
void
-merge_pools(ARGMOD(Memory_Pool *dest), ARGMOD(Memory_Pool *source))
+merge_pools(ARGMOD(Variable_Size_Pool *dest), ARGMOD(Variable_Size_Pool *source))
{
ASSERT_ARGS(merge_pools)
Memory_Block *cur_block;
@@ -753,25 +754,25 @@
{
ASSERT_ARGS(check_memory_system)
size_t i;
- Arenas * const arena_base = interp->arena_base;
+ Memory_Pools * const mem_pools = interp->mem_pools;
- check_memory_pool(arena_base->memory_pool);
- check_memory_pool(arena_base->constant_string_pool);
- check_small_object_pool(arena_base->pmc_pool);
- check_small_object_pool(arena_base->constant_pmc_pool);
- check_small_object_pool(arena_base->string_header_pool);
- check_small_object_pool(arena_base->constant_string_header_pool);
+ check_var_size_obj_pool(mem_pools->memory_pool);
+ check_var_size_obj_pool(mem_pools->constant_string_pool);
+ check_fixed_size_obj_pool(mem_pools->pmc_pool);
+ check_fixed_size_obj_pool(mem_pools->constant_pmc_pool);
+ check_fixed_size_obj_pool(mem_pools->string_header_pool);
+ check_fixed_size_obj_pool(mem_pools->constant_string_header_pool);
- for (i = 0; i < arena_base->num_sized; i++) {
- Small_Object_Pool * pool = arena_base->sized_header_pools[i];
- if (pool != NULL && pool != arena_base->string_header_pool)
- check_small_object_pool(pool);
+ for (i = 0; i < mem_pools->num_sized; i++) {
+ Fixed_Size_Pool * pool = mem_pools->sized_header_pools[i];
+ if (pool != NULL && pool != mem_pools->string_header_pool)
+ check_fixed_size_obj_pool(pool);
}
}
/*
-=item C<static void check_small_object_pool(Small_Object_Pool * pool)>
+=item C<static void check_fixed_size_obj_pool(Fixed_Size_Pool * pool)>
Checks a small object pool, if it contains buffer it checks the buffers also.
@@ -780,12 +781,12 @@
*/
static void
-check_small_object_pool(ARGMOD(Small_Object_Pool * pool))
+check_fixed_size_obj_pool(ARGMOD(Fixed_Size_Pool * pool))
{
- ASSERT_ARGS(check_small_object_pool)
+ ASSERT_ARGS(check_fixed_size_obj_pool)
size_t total_objects;
size_t last_free_list_count;
- Small_Object_Arena * arena_walker;
+ Fixed_Size_Arena * arena_walker;
size_t free_objects;
PObj * object;
size_t i;
@@ -850,7 +851,7 @@
/*
-=item C<static void check_memory_pool(Memory_Pool *pool)>
+=item C<static void check_var_size_obj_pool(Variable_Size_Pool *pool)>
Checks a memory pool, containing buffer data
@@ -859,9 +860,9 @@
*/
static void
-check_memory_pool(ARGMOD(Memory_Pool *pool))
+check_var_size_obj_pool(ARGMOD(Variable_Size_Pool *pool))
{
- ASSERT_ARGS(check_memory_pool)
+ ASSERT_ARGS(check_var_size_obj_pool)
size_t count;
Memory_Block * block_walker;
count = 10000000; /*detect unendless loop just use big enough number*/
@@ -883,7 +884,7 @@
/*
-=item C<void check_buffer_ptr(Buffer * pobj, Memory_Pool * pool)>
+=item C<void check_buffer_ptr(Buffer * pobj, Variable_Size_Pool * pool)>
Checks wether the buffer is within the bounds of the memory pool
@@ -892,7 +893,7 @@
*/
void
-check_buffer_ptr(ARGMOD(Buffer * pobj), ARGMOD(Memory_Pool * pool))
+check_buffer_ptr(ARGMOD(Buffer * pobj), ARGMOD(Variable_Size_Pool * pool))
{
ASSERT_ARGS(check_buffer_ptr)
Memory_Block * cur_block = pool->top_block;
Modified: branches/kill_jit/src/gc/api.c
==============================================================================
--- branches/kill_jit/src/gc/api.c Wed Sep 16 20:55:27 2009 (r41308)
+++ branches/kill_jit/src/gc/api.c Wed Sep 16 21:22:58 2009 (r41309)
@@ -45,7 +45,7 @@
=item F<src/gc/alloc_resources.c>
This file implements handling logic for strings and arbitrary-sized memory
-buffers. String storage is managed by special Memory_Pool structures, and use
+buffers. String storage is managed by special Variable_Size_Pool structures, and use
a separate compacting garbage collector to keep track of them.
=item F<src/gc/incremental_ms.c>
@@ -101,29 +101,29 @@
/* HEADERIZER BEGIN: static */
/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
-static void cleanup_next_for_GC_pool(ARGIN(Small_Object_Pool *pool))
+static void cleanup_next_for_GC_pool(ARGIN(Fixed_Size_Pool *pool))
__attribute__nonnull__(1);
static void fix_pmc_syncs(
ARGMOD(Interp *dest_interp),
- ARGIN(Small_Object_Pool *pool))
+ ARGIN(Fixed_Size_Pool *pool))
__attribute__nonnull__(1)
__attribute__nonnull__(2)
FUNC_MODIFIES(*dest_interp);
-static void free_pool(ARGMOD(Small_Object_Pool *pool))
+static void free_pool(ARGMOD(Fixed_Size_Pool *pool))
__attribute__nonnull__(1)
FUNC_MODIFIES(*pool);
PARROT_WARN_UNUSED_RESULT
PARROT_CANNOT_RETURN_NULL
-static void * get_free_buffer(PARROT_INTERP, ARGIN(Small_Object_Pool *pool))
+static void * get_free_buffer(PARROT_INTERP, ARGIN(Fixed_Size_Pool *pool))
__attribute__nonnull__(1)
__attribute__nonnull__(2);
static void Parrot_gc_merge_buffer_pools(PARROT_INTERP,
- ARGMOD(Small_Object_Pool *dest),
- ARGMOD(Small_Object_Pool *source))
+ ARGMOD(Fixed_Size_Pool *dest),
+ ARGMOD(Fixed_Size_Pool *source))
__attribute__nonnull__(1)
__attribute__nonnull__(2)
__attribute__nonnull__(3)
@@ -131,7 +131,7 @@
FUNC_MODIFIES(*source);
static int sweep_cb_buf(PARROT_INTERP,
- ARGMOD(Small_Object_Pool *pool),
+ ARGMOD(Fixed_Size_Pool *pool),
SHIM(int flag),
ARGIN(void *arg))
__attribute__nonnull__(1)
@@ -140,7 +140,7 @@
FUNC_MODIFIES(*pool);
static int sweep_cb_pmc(PARROT_INTERP,
- ARGMOD(Small_Object_Pool *pool),
+ ARGMOD(Fixed_Size_Pool *pool),
SHIM(int flag),
SHIM(void *arg))
__attribute__nonnull__(1)
@@ -196,28 +196,21 @@
{
ASSERT_ARGS(Parrot_gc_mark_PObj_alive)
/* TODO: Have each core register a ->pobject_lives function pointer in the
- Arenas struct, and call that pointer directly instead of having a messy
+ Memory_Pools struct, and call that pointer directly instead of having a messy
set of #if preparser conditions. */
-#if PARROT_GC_GMS
- do {
- if (!PObj_live_TEST(obj) && \
- PObj_to_GMSH(obj)->gen->gen_no >= interp->gc_generation) \
- parrot_gc_gms_Parrot_gc_mark_PObj_alive(interp, obj); \
- } while (0);
-#else /* not PARROT_GC_GMS */
/* if object is live or on free list return */
if (PObj_is_live_or_free_TESTALL(obj))
return;
-# if ! DISABLE_GC_DEBUG
-# if GC_VERBOSE
+#if ! DISABLE_GC_DEBUG
+# if GC_VERBOSE
if (CONSERVATIVE_POINTER_CHASING)
fprintf(stderr, "GC Warning! Unanchored %s %p found in system areas \n",
PObj_is_PMC_TEST(obj) ? "PMC" : "Buffer", obj);
-# endif
# endif
+#endif
/* mark it live */
PObj_live_SET(obj);
@@ -232,13 +225,13 @@
else if (PMC_metadata(p))
Parrot_gc_mark_PObj_alive(interp, (PObj*)PMC_metadata(p));
}
-# if GC_VERBOSE
+#if GC_VERBOSE
/* buffer GC_DEBUG stuff */
if (GC_DEBUG(interp) && PObj_report_TEST(obj))
fprintf(stderr, "GC: buffer %p pointing to %p marked live\n",
obj, Buffer_bufstart((Buffer *)obj));
-# endif
-#endif /* PARROT_GC_GMS */
+#endif
+
}
/*
@@ -261,28 +254,37 @@
{
ASSERT_ARGS(Parrot_gc_initialize)
- interp->arena_base = mem_allocate_zeroed_typed(Arenas);
- interp->arena_base->num_sized = 0;
- interp->arena_base->num_attribs = 0;
- interp->arena_base->attrib_pools = NULL;
- interp->arena_base->sized_header_pools = NULL;
+ interp->mem_pools = mem_allocate_zeroed_typed(Memory_Pools);
+ interp->mem_pools->num_sized = 0;
+ interp->mem_pools->num_attribs = 0;
+ interp->mem_pools->attrib_pools = NULL;
+ interp->mem_pools->sized_header_pools = NULL;
+
interp->lo_var_ptr = stacktop;
-#if PARROT_GC_MS
- Parrot_gc_ms_init(interp);
-#endif
-#if PARROT_GC_IMS
- Parrot_gc_ims_init(interp);
-#endif
-#if PARROT_GC_GMS
- Parrot_gc_gms_init(interp);
-#endif
-#if PARROT_GC_INF
- Parrot_gc_inf_init(interp);
-#endif
+ interp->gc_sys = mem_allocate_zeroed_typed(GC_Subsystem);
+
+ /*TODO: add ability to specify GC core at command line w/ --gc= */
+ if (0) /*If they chose sys_type with the --gc command line switch,*/
+ ; /* set sys_type to value they gave */
+ else
+ interp->gc_sys->sys_type = PARROT_GC_DEFAULT_TYPE;
+
+ /*Call appropriate initialization function for GC subsystem*/
+ switch (interp->gc_sys->sys_type) {
+ case MS:
+ Parrot_gc_ms_init(interp);
+ break;
+ case INF:
+ Parrot_gc_inf_init(interp);
+ break;
+ default:
+ /*die horribly because of invalid GC core specified*/
+ break;
+ }
- initialize_memory_pools(interp);
- initialize_header_pools(interp);
+ initialize_var_size_pools(interp);
+ initialize_fixed_size_pools(interp);
}
/*
@@ -300,8 +302,8 @@
Parrot_gc_finalize(PARROT_INTERP)
{
ASSERT_ARGS(Parrot_gc_finalize)
- if (interp->arena_base->finalize_gc_system)
- interp->arena_base->finalize_gc_system(interp);
+ if (interp->gc_sys->finalize_gc_system)
+ interp->gc_sys->finalize_gc_system(interp);
}
@@ -323,9 +325,9 @@
Parrot_gc_new_pmc_header(PARROT_INTERP, UINTVAL flags)
{
ASSERT_ARGS(Parrot_gc_new_pmc_header)
- Small_Object_Pool * const pool = flags & PObj_constant_FLAG
- ? interp->arena_base->constant_pmc_pool
- : interp->arena_base->pmc_pool;
+ Fixed_Size_Pool * const pool = flags & PObj_constant_FLAG
+ ? interp->mem_pools->constant_pmc_pool
+ : interp->mem_pools->pmc_pool;
PMC * const pmc = (PMC *)pool->get_free_object(interp, pool);
if (!pmc)
@@ -358,8 +360,8 @@
Parrot_gc_free_pmc_header(PARROT_INTERP, ARGMOD(PMC *pmc))
{
ASSERT_ARGS(Parrot_gc_free_pmc_header)
- Small_Object_Pool * const pool = (PObj_constant_TEST(pmc)) ?
- interp->arena_base->constant_pmc_pool : interp->arena_base->pmc_pool;
+ Fixed_Size_Pool * const pool = (PObj_constant_TEST(pmc)) ?
+ interp->mem_pools->constant_pmc_pool : interp->mem_pools->pmc_pool;
Parrot_pmc_destroy(interp, pmc);
@@ -443,8 +445,8 @@
STRING * const string = (STRING *)get_free_buffer(interp,
(flags & PObj_constant_FLAG)
- ? interp->arena_base->constant_string_header_pool
- : interp->arena_base->string_header_pool);
+ ? interp->mem_pools->constant_string_header_pool
+ : interp->mem_pools->string_header_pool);
if (!string)
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_ALLOCATION_ERROR,
"Parrot VM: STRING allocation failed!\n");
@@ -471,7 +473,7 @@
{
ASSERT_ARGS(Parrot_gc_free_string_header)
if (!PObj_constant_TEST(s)) {
- Small_Object_Pool * const pool = interp->arena_base->string_header_pool;
+ Fixed_Size_Pool * const pool = interp->mem_pools->string_header_pool;
pool->add_free_object(interp, pool, s);
}
}
@@ -496,14 +498,14 @@
{
ASSERT_ARGS(Parrot_gc_new_bufferlike_header)
- Small_Object_Pool * const pool = get_bufferlike_pool(interp, size);
+ Fixed_Size_Pool * const pool = get_bufferlike_pool(interp, size);
return get_free_buffer(interp, pool);
}
/*
-=item C<static void * get_free_buffer(PARROT_INTERP, Small_Object_Pool *pool)>
+=item C<static void * get_free_buffer(PARROT_INTERP, Fixed_Size_Pool *pool)>
Gets a free object or buffer from the given C<pool> and returns it. If the
object is larger then a standard C<PObj> structure, all additional memory is
@@ -516,7 +518,7 @@
PARROT_WARN_UNUSED_RESULT
PARROT_CANNOT_RETURN_NULL
static void *
-get_free_buffer(PARROT_INTERP, ARGIN(Small_Object_Pool *pool))
+get_free_buffer(PARROT_INTERP, ARGIN(Fixed_Size_Pool *pool))
{
ASSERT_ARGS(get_free_buffer)
Buffer * const buffer = (Buffer *)pool->get_free_object(interp, pool);
@@ -525,9 +527,9 @@
Buffer_bufstart(buffer) = NULL;
Buffer_buflen(buffer) = 0;
- if (pool->object_size - GC_HEADER_SIZE > sizeof (Buffer))
+ if (pool->object_size > sizeof (Buffer))
memset(buffer + 1, 0,
- pool->object_size - sizeof (Buffer) - GC_HEADER_SIZE);
+ pool->object_size - sizeof (Buffer));
return buffer;
}
@@ -549,7 +551,7 @@
size_t size)
{
ASSERT_ARGS(Parrot_gc_free_bufferlike_header)
- Small_Object_Pool * const pool = get_bufferlike_pool(interp, size);
+ Fixed_Size_Pool * const pool = get_bufferlike_pool(interp, size);
pool->add_free_object(interp, pool, obj);
}
@@ -578,7 +580,7 @@
Buffer_bufstart(buffer) = NULL;
new_size = aligned_size(buffer, size);
mem = (char *)mem_allocate(interp, new_size,
- interp->arena_base->memory_pool);
+ interp->mem_pools->memory_pool);
mem = aligned_mem(buffer, mem);
Buffer_bufstart(buffer) = mem;
if (PObj_is_COWable_TEST(buffer))
@@ -608,7 +610,7 @@
ASSERT_ARGS(Parrot_gc_reallocate_buffer_storage)
size_t copysize;
char *mem;
- Memory_Pool * const pool = interp->arena_base->memory_pool;
+ Variable_Size_Pool * const pool = interp->mem_pools->memory_pool;
size_t new_size, needed, old_size;
/*
@@ -679,7 +681,7 @@
{
ASSERT_ARGS(Parrot_gc_allocate_string_storage)
size_t new_size;
- Memory_Pool *pool;
+ Variable_Size_Pool *pool;
char *mem;
Buffer_buflen(str) = 0;
@@ -693,8 +695,8 @@
return;
pool = PObj_constant_TEST(str)
- ? interp->arena_base->constant_string_pool
- : interp->arena_base->memory_pool;
+ ? interp->mem_pools->constant_string_pool
+ : interp->mem_pools->memory_pool;
new_size = aligned_string_size(size);
mem = (char *)mem_allocate(interp, new_size, pool);
@@ -726,10 +728,10 @@
char *mem, *oldmem;
size_t new_size, needed, old_size;
- Memory_Pool * const pool =
+ Variable_Size_Pool * const pool =
PObj_constant_TEST(str)
- ? interp->arena_base->constant_string_pool
- : interp->arena_base->memory_pool;
+ ? interp->mem_pools->constant_string_pool
+ : interp->mem_pools->memory_pool;
/* if the requested size is smaller then buflen, we are done */
if (newsize <= Buffer_buflen(str))
@@ -792,7 +794,7 @@
Parrot_gc_mark_and_sweep(PARROT_INTERP, UINTVAL flags)
{
ASSERT_ARGS(Parrot_gc_mark_and_sweep)
- interp->arena_base->do_gc_mark(interp, flags);
+ interp->gc_sys->do_gc_mark(interp, flags);
}
/*
@@ -811,7 +813,7 @@
Parrot_gc_compact_memory_pool(PARROT_INTERP)
{
ASSERT_ARGS(Parrot_gc_compact_memory_pool)
- compact_pool(interp, interp->arena_base->memory_pool);
+ compact_pool(interp, interp->mem_pools->memory_pool);
}
/*
@@ -832,8 +834,8 @@
{
ASSERT_ARGS(Parrot_gc_merge_header_pools)
- Arenas * const dest_arena = dest_interp->arena_base;
- Arenas * const source_arena = source_interp->arena_base;
+ Memory_Pools * const dest_arena = dest_interp->mem_pools;
+ Memory_Pools * const source_arena = source_interp->mem_pools;
UINTVAL i;
/* heavily borrowed from forall_header_pools */
@@ -855,7 +857,7 @@
if (i >= dest_arena->num_sized
|| !dest_arena->sized_header_pools[i]) {
- Small_Object_Pool *ignored = get_bufferlike_pool(dest_interp,
+ Fixed_Size_Pool *ignored = get_bufferlike_pool(dest_interp,
i * sizeof (void *));
UNUSED(ignored);
PARROT_ASSERT(dest_arena->sized_header_pools[i]);
@@ -869,8 +871,8 @@
/*
-=item C<static void Parrot_gc_merge_buffer_pools(PARROT_INTERP,
-Small_Object_Pool *dest, Small_Object_Pool *source)>
+=item C<static void Parrot_gc_merge_buffer_pools(PARROT_INTERP, Fixed_Size_Pool
+*dest, Fixed_Size_Pool *source)>
Merge pool C<source> into pool C<dest>. Combines the free lists directly,
moves all arenas to the new pool, and remove the old pool. To merge, the
@@ -883,10 +885,10 @@
static void
Parrot_gc_merge_buffer_pools(PARROT_INTERP,
- ARGMOD(Small_Object_Pool *dest), ARGMOD(Small_Object_Pool *source))
+ ARGMOD(Fixed_Size_Pool *dest), ARGMOD(Fixed_Size_Pool *source))
{
ASSERT_ARGS(Parrot_gc_merge_buffer_pools)
- Small_Object_Arena *cur_arena;
+ Fixed_Size_Arena *cur_arena;
GC_MS_PObj_Wrapper *free_list_end;
PARROT_ASSERT(dest->object_size == source->object_size);
@@ -913,7 +915,7 @@
while (cur_arena) {
size_t total_objects;
- Small_Object_Arena * const next_arena = cur_arena->prev;
+ Fixed_Size_Arena * const next_arena = cur_arena->prev;
cur_arena->next = cur_arena->prev = NULL;
@@ -937,7 +939,7 @@
/*
-=item C<static void fix_pmc_syncs(Interp *dest_interp, Small_Object_Pool *pool)>
+=item C<static void fix_pmc_syncs(Interp *dest_interp, Fixed_Size_Pool *pool)>
Walks through the given arena, looking for all live and shared PMCs,
transferring their sync values to the destination interpreter.
@@ -947,14 +949,14 @@
*/
static void
-fix_pmc_syncs(ARGMOD(Interp *dest_interp), ARGIN(Small_Object_Pool *pool))
+fix_pmc_syncs(ARGMOD(Interp *dest_interp), ARGIN(Fixed_Size_Pool *pool))
{
ASSERT_ARGS(fix_pmc_syncs)
- Small_Object_Arena *cur_arena;
+ Fixed_Size_Arena *cur_arena;
const UINTVAL object_size = pool->object_size;
for (cur_arena = pool->last_Arena; cur_arena; cur_arena = cur_arena->prev) {
- PMC *p = (PMC *)((char*)cur_arena->start_objects + GC_HEADER_SIZE);
+ PMC *p = (PMC *)((char*)cur_arena->start_objects);
size_t i;
for (i = 0; i < cur_arena->used; i++) {
@@ -981,7 +983,7 @@
Performs a garbage collection sweep on all pools, then frees them. Calls
C<header_pools_iterate_callback> to loop over all the pools, passing
C<sweep_cb_pmc> and C<sweep_cb_buf> callback routines. Frees the array of sized
-header pointers in the C<Arenas> structure too.
+header pointers in the C<Memory_Pools> structure too.
=cut
@@ -1013,12 +1015,12 @@
(void *)pass, sweep_cb_buf);
}
- mem_internal_free(interp->arena_base->sized_header_pools);
+ mem_internal_free(interp->mem_pools->sized_header_pools);
- if (interp->arena_base->attrib_pools) {
+ if (interp->mem_pools->attrib_pools) {
unsigned int i;
- for (i = 0; i < interp->arena_base->num_attribs; i++) {
- PMC_Attribute_Pool *pool = interp->arena_base->attrib_pools[i];
+ for (i = 0; i < interp->mem_pools->num_attribs; i++) {
+ PMC_Attribute_Pool *pool = interp->mem_pools->attrib_pools[i];
PMC_Attribute_Arena *arena;
if (!pool)
@@ -1034,17 +1036,17 @@
mem_internal_free(pool);
}
- mem_internal_free(interp->arena_base->attrib_pools);
+ mem_internal_free(interp->mem_pools->attrib_pools);
}
- interp->arena_base->attrib_pools = NULL;
- interp->arena_base->sized_header_pools = NULL;
+ interp->mem_pools->attrib_pools = NULL;
+ interp->mem_pools->sized_header_pools = NULL;
}
/*
-=item C<static int sweep_cb_pmc(PARROT_INTERP, Small_Object_Pool *pool, int
-flag, void *arg)>
+=item C<static int sweep_cb_pmc(PARROT_INTERP, Fixed_Size_Pool *pool, int flag,
+void *arg)>
Performs a garbage collection sweep of the given pmc pool, then frees it. Calls
C<Parrot_gc_sweep_pool> to perform the sweep, and C<free_pool> to free the pool and
@@ -1055,9 +1057,10 @@
*/
static int
-sweep_cb_pmc(PARROT_INTERP, ARGMOD(Small_Object_Pool *pool),
+sweep_cb_pmc(PARROT_INTERP, ARGMOD(Fixed_Size_Pool *pool),
SHIM(int flag), SHIM(void *arg))
{
+ ASSERT_ARGS(sweep_cb_pmc)
Parrot_gc_sweep_pool(interp, pool);
free_pool(pool);
return 0;
@@ -1065,8 +1068,8 @@
/*
-=item C<static int sweep_cb_buf(PARROT_INTERP, Small_Object_Pool *pool, int
-flag, void *arg)>
+=item C<static int sweep_cb_buf(PARROT_INTERP, Fixed_Size_Pool *pool, int flag,
+void *arg)>
Performs a final garbage collection sweep, then frees the pool. Calls
C<Parrot_gc_sweep_pool> to perform the sweep, and C<free_pool> to free the pool and
@@ -1077,9 +1080,10 @@
*/
static int
-sweep_cb_buf(PARROT_INTERP, ARGMOD(Small_Object_Pool *pool), SHIM(int flag),
+sweep_cb_buf(PARROT_INTERP, ARGMOD(Fixed_Size_Pool *pool), SHIM(int flag),
ARGIN(void *arg))
{
+ ASSERT_ARGS(sweep_cb_buf)
#ifdef GC_IS_MALLOC
const int pass = (int)(INTVAL)arg;
@@ -1101,7 +1105,7 @@
/*
-=item C<static void free_pool(Small_Object_Pool *pool)>
+=item C<static void free_pool(Fixed_Size_Pool *pool)>
Frees a pool and all of its arenas. Loops through the list of arenas backwards
and returns each to the memory manager. Then, frees the pool structure itself.
@@ -1111,13 +1115,13 @@
*/
static void
-free_pool(ARGMOD(Small_Object_Pool *pool))
+free_pool(ARGMOD(Fixed_Size_Pool *pool))
{
ASSERT_ARGS(free_pool)
- Small_Object_Arena *cur_arena;
+ Fixed_Size_Arena *cur_arena;
for (cur_arena = pool->last_Arena; cur_arena;) {
- Small_Object_Arena * const next = cur_arena->prev;
+ Fixed_Size_Arena * const next = cur_arena->prev;
mem_internal_free(cur_arena->start_objects);
mem_internal_free(cur_arena);
cur_arena = next;
@@ -1145,9 +1149,9 @@
int i;
for (i = 0; i < 2; i++) {
- Memory_Pool * const pool = i ?
- interp->arena_base->constant_string_pool :
- interp->arena_base->memory_pool;
+ Variable_Size_Pool * const pool = i ?
+ interp->mem_pools->constant_string_pool :
+ interp->mem_pools->memory_pool;
Memory_Block *cur_block;
cur_block = pool->top_block;
@@ -1178,7 +1182,7 @@
Parrot_gc_ptr_in_memory_pool(PARROT_INTERP, ARGIN(void *bufstart))
{
ASSERT_ARGS(Parrot_gc_ptr_in_memory_pool)
- Memory_Pool * const pool = interp->arena_base->memory_pool;
+ Variable_Size_Pool * const pool = interp->mem_pools->memory_pool;
Memory_Block * cur_block = pool->top_block;
while (cur_block) {
@@ -1206,8 +1210,8 @@
Parrot_gc_ptr_is_pmc(PARROT_INTERP, ARGIN(void *ptr))
{
ASSERT_ARGS(Parrot_gc_ptr_is_pmc)
- return contained_in_pool(interp->arena_base->pmc_pool, ptr) ||
- contained_in_pool(interp->arena_base->constant_pmc_pool, ptr);
+ return contained_in_pool(interp, interp->mem_pools->pmc_pool, ptr) ||
+ contained_in_pool(interp, interp->mem_pools->constant_pmc_pool, ptr);
}
/*
@@ -1226,11 +1230,10 @@
{
ASSERT_ARGS(Parrot_gc_get_pmc_index)
UINTVAL id = 1; /* first PMC in first arena */
- Small_Object_Arena *arena;
- Small_Object_Pool *pool;
+ Fixed_Size_Arena *arena;
+ Fixed_Size_Pool *pool;
- pmc = (PMC*)PObj_to_ARENA(pmc);
- pool = interp->arena_base->pmc_pool;
+ pool = interp->mem_pools->pmc_pool;
for (arena = pool->last_Arena; arena; arena = arena->prev) {
const ptrdiff_t ptr_diff = (ptrdiff_t)pmc - (ptrdiff_t)arena->start_objects;
if (ptr_diff >= 0 && ptr_diff <
@@ -1242,7 +1245,7 @@
id += arena->total_objects;
}
- pool = interp->arena_base->constant_pmc_pool;
+ pool = interp->mem_pools->constant_pmc_pool;
for (arena = pool->last_Arena; arena; arena = arena->prev) {
const ptrdiff_t ptr_diff = (ptrdiff_t)pmc - (ptrdiff_t)arena->start_objects;
if (ptr_diff >= 0 && ptr_diff <
@@ -1272,13 +1275,13 @@
Parrot_gc_cleanup_next_for_GC(PARROT_INTERP)
{
ASSERT_ARGS(Parrot_gc_cleanup_next_for_GC)
- cleanup_next_for_GC_pool(interp->arena_base->pmc_pool);
- cleanup_next_for_GC_pool(interp->arena_base->constant_pmc_pool);
+ cleanup_next_for_GC_pool(interp->mem_pools->pmc_pool);
+ cleanup_next_for_GC_pool(interp->mem_pools->constant_pmc_pool);
}
/*
-=item C<static void cleanup_next_for_GC_pool(Small_Object_Pool *pool)>
+=item C<static void cleanup_next_for_GC_pool(Fixed_Size_Pool *pool)>
Sets all the C<next_for_GC> pointers to C<NULL>.
@@ -1287,10 +1290,10 @@
*/
static void
-cleanup_next_for_GC_pool(ARGIN(Small_Object_Pool *pool))
+cleanup_next_for_GC_pool(ARGIN(Fixed_Size_Pool *pool))
{
ASSERT_ARGS(cleanup_next_for_GC_pool)
- Small_Object_Arena *arena;
+ Fixed_Size_Arena *arena;
for (arena = pool->last_Arena; arena; arena = arena->prev) {
PMC *p = (PMC *)arena->start_objects;
@@ -1320,10 +1323,10 @@
{
ASSERT_ARGS(Parrot_gc_active_sized_buffers)
int j, ret = 0;
- const Arenas * const arena_base = interp->arena_base;
- for (j = 0; j < (INTVAL)arena_base->num_sized; j++) {
- Small_Object_Pool * const header_pool =
- arena_base->sized_header_pools[j];
+ const Memory_Pools * const mem_pools = interp->mem_pools;
+ for (j = 0; j < (INTVAL)mem_pools->num_sized; j++) {
+ Fixed_Size_Pool * const header_pool =
+ mem_pools->sized_header_pools[j];
if (header_pool)
ret += header_pool->total_objects -
header_pool->num_free_objects;
@@ -1346,10 +1349,10 @@
{
ASSERT_ARGS(Parrot_gc_total_sized_buffers)
int j, ret = 0;
- const Arenas * const arena_base = interp->arena_base;
- for (j = 0; j < (INTVAL)arena_base->num_sized; j++) {
- Small_Object_Pool * const header_pool =
- arena_base->sized_header_pools[j];
+ const Memory_Pools * const mem_pools = interp->mem_pools;
+ for (j = 0; j < (INTVAL)mem_pools->num_sized; j++) {
+ Fixed_Size_Pool * const header_pool =
+ mem_pools->sized_header_pools[j];
if (header_pool)
ret += header_pool->total_objects;
}
@@ -1370,9 +1373,9 @@
Parrot_gc_active_pmcs(PARROT_INTERP)
{
ASSERT_ARGS(Parrot_gc_active_pmcs)
- const Arenas * const arena_base = interp->arena_base;
- return arena_base->pmc_pool->total_objects -
- arena_base->pmc_pool->num_free_objects;
+ const Memory_Pools * const mem_pools = interp->mem_pools;
+ return mem_pools->pmc_pool->total_objects -
+ mem_pools->pmc_pool->num_free_objects;
}
/*
@@ -1389,8 +1392,8 @@
Parrot_gc_total_pmcs(PARROT_INTERP)
{
ASSERT_ARGS(Parrot_gc_total_pmcs)
- const Arenas * const arena_base = interp->arena_base;
- return arena_base->pmc_pool->total_objects;
+ const Memory_Pools * const mem_pools = interp->mem_pools;
+ return mem_pools->pmc_pool->total_objects;
}
/*
@@ -1431,64 +1434,64 @@
Parrot_gc_count_mark_runs(PARROT_INTERP)
{
ASSERT_ARGS(Parrot_gc_count_mark_runs)
- const Arenas * const arena_base = interp->arena_base;
- return arena_base->gc_mark_runs;
+ const Memory_Pools * const mem_pools = interp->mem_pools;
+ return mem_pools->gc_mark_runs;
}
size_t
Parrot_gc_count_collect_runs(PARROT_INTERP)
{
ASSERT_ARGS(Parrot_gc_count_collect_runs)
- const Arenas * const arena_base = interp->arena_base;
- return arena_base->gc_collect_runs;
+ const Memory_Pools * const mem_pools = interp->mem_pools;
+ return mem_pools->gc_collect_runs;
}
size_t
Parrot_gc_count_lazy_mark_runs(PARROT_INTERP)
{
ASSERT_ARGS(Parrot_gc_count_lazy_mark_runs)
- const Arenas * const arena_base = interp->arena_base;
- return arena_base->gc_lazy_mark_runs;;
+ const Memory_Pools * const mem_pools = interp->mem_pools;
+ return mem_pools->gc_lazy_mark_runs;;
}
size_t
Parrot_gc_total_memory_allocated(PARROT_INTERP)
{
ASSERT_ARGS(Parrot_gc_total_memory_allocated)
- const Arenas * const arena_base = interp->arena_base;
- return arena_base->memory_allocated;
+ const Memory_Pools * const mem_pools = interp->mem_pools;
+ return mem_pools->memory_allocated;
}
size_t
Parrot_gc_headers_alloc_since_last_collect(PARROT_INTERP)
{
ASSERT_ARGS(Parrot_gc_headers_alloc_since_last_collect)
- const Arenas * const arena_base = interp->arena_base;
- return arena_base->header_allocs_since_last_collect;
+ const Memory_Pools * const mem_pools = interp->mem_pools;
+ return mem_pools->header_allocs_since_last_collect;
}
size_t
Parrot_gc_mem_alloc_since_last_collect(PARROT_INTERP)
{
ASSERT_ARGS(Parrot_gc_mem_alloc_since_last_collect)
- const Arenas * const arena_base = interp->arena_base;
- return arena_base->mem_allocs_since_last_collect;
+ const Memory_Pools * const mem_pools = interp->mem_pools;
+ return mem_pools->mem_allocs_since_last_collect;
}
UINTVAL
Parrot_gc_total_copied(PARROT_INTERP)
{
ASSERT_ARGS(Parrot_gc_total_copied)
- const Arenas * const arena_base = interp->arena_base;
- return arena_base->memory_collected;
+ const Memory_Pools * const mem_pools = interp->mem_pools;
+ return mem_pools->memory_collected;
}
UINTVAL
Parrot_gc_impatient_pmcs(PARROT_INTERP)
{
ASSERT_ARGS(Parrot_gc_impatient_pmcs)
- const Arenas * const arena_base = interp->arena_base;
- return arena_base->num_early_gc_PMCs;
+ const Memory_Pools * const mem_pools = interp->mem_pools;
+ return mem_pools->num_early_gc_PMCs;
}
/*
@@ -1531,7 +1534,7 @@
Parrot_block_GC_mark(PARROT_INTERP)
{
ASSERT_ARGS(Parrot_block_GC_mark)
- interp->arena_base->gc_mark_block_level++;
+ interp->mem_pools->gc_mark_block_level++;
Parrot_shared_gc_block(interp);
}
@@ -1540,8 +1543,8 @@
Parrot_unblock_GC_mark(PARROT_INTERP)
{
ASSERT_ARGS(Parrot_unblock_GC_mark)
- if (interp->arena_base->gc_mark_block_level) {
- interp->arena_base->gc_mark_block_level--;
+ if (interp->mem_pools->gc_mark_block_level) {
+ interp->mem_pools->gc_mark_block_level--;
Parrot_shared_gc_unblock(interp);
}
}
@@ -1551,7 +1554,7 @@
Parrot_block_GC_sweep(PARROT_INTERP)
{
ASSERT_ARGS(Parrot_block_GC_sweep)
- interp->arena_base->gc_sweep_block_level++;
+ interp->mem_pools->gc_sweep_block_level++;
}
PARROT_EXPORT
@@ -1559,8 +1562,8 @@
Parrot_unblock_GC_sweep(PARROT_INTERP)
{
ASSERT_ARGS(Parrot_unblock_GC_sweep)
- if (interp->arena_base->gc_sweep_block_level)
- interp->arena_base->gc_sweep_block_level--;
+ if (interp->mem_pools->gc_sweep_block_level)
+ interp->mem_pools->gc_sweep_block_level--;
}
PARROT_EXPORT
@@ -1568,7 +1571,7 @@
Parrot_is_blocked_GC_mark(PARROT_INTERP)
{
ASSERT_ARGS(Parrot_is_blocked_GC_mark)
- return interp->arena_base->gc_mark_block_level;
+ return interp->mem_pools->gc_mark_block_level;
}
PARROT_EXPORT
@@ -1576,15 +1579,15 @@
Parrot_is_blocked_GC_sweep(PARROT_INTERP)
{
ASSERT_ARGS(Parrot_is_blocked_GC_sweep)
- return interp->arena_base->gc_sweep_block_level;
+ return interp->mem_pools->gc_sweep_block_level;
}
void
Parrot_gc_completely_unblock(PARROT_INTERP)
{
ASSERT_ARGS(Parrot_gc_completely_unblock)
- interp->arena_base->gc_mark_block_level = 0;
- interp->arena_base->gc_sweep_block_level = 0;
+ interp->mem_pools->gc_mark_block_level = 0;
+ interp->mem_pools->gc_sweep_block_level = 0;
}
/*
@@ -1602,9 +1605,10 @@
{
ASSERT_ARGS(Parrot_gc_pmc_needs_early_collection)
PObj_needs_early_gc_SET(pmc);
- ++interp->arena_base->num_early_gc_PMCs;
+ ++interp->mem_pools->num_early_gc_PMCs;
}
+
/*
=item C<void * Parrot_gc_allocate_pmc_attributes(PARROT_INTERP, PMC *pmc)>
@@ -1652,10 +1656,11 @@
void * const data = PMC_data(pmc);
if (data) {
+
#if GC_USE_FIXED_SIZE_ALLOCATOR
const size_t attr_size = pmc->vtable->attr_size;
const size_t item_size = attr_size < sizeof (void *) ? sizeof (void *) : attr_size;
- PMC_Attribute_Pool ** const pools = interp->arena_base->attrib_pools;
+ PMC_Attribute_Pool ** const pools = interp->mem_pools->attrib_pools;
const size_t idx = item_size - sizeof (void *);
Parrot_gc_free_attributes_from_pool(interp, pools[idx], data);
#else
@@ -1699,10 +1704,12 @@
Parrot_gc_free_fixed_size_storage(PARROT_INTERP, size_t size, ARGMOD(void *data))
{
ASSERT_ARGS(Parrot_gc_free_fixed_size_storage)
+
const size_t item_size = size < sizeof (void *) ? sizeof (void *) : size;
const size_t idx = size - sizeof (void *);
- PMC_Attribute_Pool ** const pools = interp->arena_base->attrib_pools;
+ PMC_Attribute_Pool ** const pools = interp->mem_pools->attrib_pools;
Parrot_gc_free_attributes_from_pool(interp, pools[idx], data);
+
}
/*
Modified: branches/kill_jit/src/gc/gc_inf.c
==============================================================================
--- branches/kill_jit/src/gc/gc_inf.c Wed Sep 16 20:55:27 2009 (r41308)
+++ branches/kill_jit/src/gc/gc_inf.c Wed Sep 16 21:22:58 2009 (r41309)
@@ -38,30 +38,29 @@
/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
static void gc_inf_add_free_object(SHIM_INTERP,
- ARGMOD(Small_Object_Pool *pool),
+ ARGMOD(Fixed_Size_Pool *pool),
ARGIN(void *to_add))
__attribute__nonnull__(2)
__attribute__nonnull__(3)
FUNC_MODIFIES(*pool);
-static void gc_inf_alloc_objects(SHIM_INTERP,
- ARGMOD(Small_Object_Pool *pool))
+static void gc_inf_alloc_objects(SHIM_INTERP, ARGMOD(Fixed_Size_Pool *pool))
__attribute__nonnull__(2)
FUNC_MODIFIES(*pool);
PARROT_CANNOT_RETURN_NULL
static void * gc_inf_get_free_object(SHIM_INTERP,
- ARGMOD(Small_Object_Pool *pool))
+ ARGMOD(Fixed_Size_Pool *pool))
__attribute__nonnull__(2)
FUNC_MODIFIES(*pool);
static void gc_inf_mark_and_sweep(SHIM_INTERP, UINTVAL flags);
static void gc_inf_more_traceable_objects(SHIM_INTERP,
- ARGMOD(Small_Object_Pool *pool))
+ ARGMOD(Fixed_Size_Pool *pool))
__attribute__nonnull__(2)
FUNC_MODIFIES(*pool);
-static void gc_inf_pool_init(SHIM_INTERP, ARGMOD(Small_Object_Pool *pool))
+static void gc_inf_pool_init(SHIM_INTERP, ARGMOD(Fixed_Size_Pool *pool))
__attribute__nonnull__(2)
FUNC_MODIFIES(*pool);
@@ -112,8 +111,8 @@
/*
-=item C<static void gc_inf_add_free_object(PARROT_INTERP, Small_Object_Pool
-*pool, void *to_add)>
+=item C<static void gc_inf_add_free_object(PARROT_INTERP, Fixed_Size_Pool *pool,
+void *to_add)>
Manually frees a chunk of memory. Normally this would return the memory
to the free list of the pool, but in this case we just return it to the
@@ -128,7 +127,7 @@
*/
static void
-gc_inf_add_free_object(SHIM_INTERP, ARGMOD(Small_Object_Pool *pool),
+gc_inf_add_free_object(SHIM_INTERP, ARGMOD(Fixed_Size_Pool *pool),
ARGIN(void *to_add))
{
ASSERT_ARGS(gc_inf_add_free_object)
@@ -138,7 +137,7 @@
/*
-=item C<static void * gc_inf_get_free_object(PARROT_INTERP, Small_Object_Pool
+=item C<static void * gc_inf_get_free_object(PARROT_INTERP, Fixed_Size_Pool
*pool)>
Gets a new object from the pool. Each pool specifies an object size in
@@ -161,7 +160,7 @@
PARROT_CANNOT_RETURN_NULL
static void *
-gc_inf_get_free_object(SHIM_INTERP, ARGMOD(Small_Object_Pool *pool))
+gc_inf_get_free_object(SHIM_INTERP, ARGMOD(Fixed_Size_Pool *pool))
{
ASSERT_ARGS(gc_inf_get_free_object)
return calloc(pool->object_size, 1);
@@ -169,8 +168,7 @@
/*
-=item C<static void gc_inf_alloc_objects(PARROT_INTERP, Small_Object_Pool
-*pool)>
+=item C<static void gc_inf_alloc_objects(PARROT_INTERP, Fixed_Size_Pool *pool)>
Allocates a new arena of objects from the system. This function is only
really used internally by the core, the API functions don't need to call
@@ -184,7 +182,7 @@
*/
static void
-gc_inf_alloc_objects(SHIM_INTERP, ARGMOD(Small_Object_Pool *pool))
+gc_inf_alloc_objects(SHIM_INTERP, ARGMOD(Fixed_Size_Pool *pool))
{
ASSERT_ARGS(gc_inf_alloc_objects)
UNUSED(pool);
@@ -192,8 +190,8 @@
/*
-=item C<static void gc_inf_more_traceable_objects(PARROT_INTERP,
-Small_Object_Pool *pool)>
+=item C<static void gc_inf_more_traceable_objects(PARROT_INTERP, Fixed_Size_Pool
+*pool)>
Would normally try to find new traceable objects by first running a GC sweep
and then allocating a new arena from the system. Neither of these are
@@ -208,7 +206,7 @@
*/
static void
-gc_inf_more_traceable_objects(SHIM_INTERP, ARGMOD(Small_Object_Pool *pool))
+gc_inf_more_traceable_objects(SHIM_INTERP, ARGMOD(Fixed_Size_Pool *pool))
{
ASSERT_ARGS(gc_inf_more_traceable_objects)
UNUSED(pool);
@@ -216,14 +214,14 @@
/*
-=item C<static void gc_inf_pool_init(PARROT_INTERP, Small_Object_Pool *pool)>
+=item C<static void gc_inf_pool_init(PARROT_INTERP, Fixed_Size_Pool *pool)>
Initializes the function pointers in a new pool. When a new pool is created
we assign several function pointers to it for managing memory in the pool.
In this way we can treat different pools differently if they have special
management needs. In general all PObj-like pools are treated the same.
-This function is mostly called from the function C<initialize_header_pools>
+This function is mostly called from the function C<initialize_fixed_size_pools>
in F<src/gc/mark_sweep.c> at Parrot startup.
=cut
@@ -231,7 +229,7 @@
*/
static void
-gc_inf_pool_init(SHIM_INTERP, ARGMOD(Small_Object_Pool *pool))
+gc_inf_pool_init(SHIM_INTERP, ARGMOD(Fixed_Size_Pool *pool))
{
ASSERT_ARGS(gc_inf_pool_init)
pool->add_free_object = gc_inf_add_free_object;
@@ -245,7 +243,7 @@
=item C<void Parrot_gc_inf_init(PARROT_INTERP)>
Initializes the infinite memory collector. Installs the necessary function
-pointers into the Arenas structure. The two most important are the
+pointers into the Memory_Pools structure. The two most important are the
C<mark_and_sweep> and C<pool_init> functions. C<finalize_gc_system> function
will be called at Parrot exit and will shut down the GC system if things
need to be flushed/closed/deactivated/freed/etc. It can be set to NULL if no
@@ -259,11 +257,10 @@
Parrot_gc_inf_init(PARROT_INTERP)
{
ASSERT_ARGS(Parrot_gc_inf_init)
- Arenas * const arena_base = interp->arena_base;
- arena_base->do_gc_mark = gc_inf_mark_and_sweep;
- arena_base->finalize_gc_system = NULL;
- arena_base->init_pool = gc_inf_pool_init;
+ interp->gc_sys->do_gc_mark = gc_inf_mark_and_sweep;
+ interp->gc_sys->finalize_gc_system = NULL;
+ interp->gc_sys->init_pool = gc_inf_pool_init;
}
Modified: branches/kill_jit/src/gc/gc_malloc.c
==============================================================================
--- branches/kill_jit/src/gc/gc_malloc.c Wed Sep 16 20:55:27 2009 (r41308)
+++ branches/kill_jit/src/gc/gc_malloc.c Wed Sep 16 21:22:58 2009 (r41309)
@@ -28,14 +28,14 @@
/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
static void clear_cow(PARROT_INTERP,
- ARGMOD(Small_Object_Pool *pool),
+ ARGMOD(Fixed_Size_Pool *pool),
int cleanup)
__attribute__nonnull__(1)
__attribute__nonnull__(2)
FUNC_MODIFIES(*pool);
static int sweep_cb(PARROT_INTERP,
- ARGMOD(Small_Object_Pool *pool),
+ ARGMOD(Fixed_Size_Pool *pool),
int flag,
ARGMOD(void *arg))
__attribute__nonnull__(1)
@@ -45,7 +45,7 @@
FUNC_MODIFIES(*arg);
static void used_cow(PARROT_INTERP,
- ARGMOD(Small_Object_Pool *pool),
+ ARGMOD(Fixed_Size_Pool *pool),
int cleanup)
__attribute__nonnull__(1)
__attribute__nonnull__(2)
@@ -58,7 +58,7 @@
/*
-=item C<static int sweep_cb(PARROT_INTERP, Small_Object_Pool *pool, int flag, void *arg)>
+=item C<static int sweep_cb(PARROT_INTERP, Fixed_Size_Pool *pool, int flag, void *arg)>
Sweeps the given pool for the MS collector. This function also ends
the profiling timer, if profiling is enabled. Returns the total number
@@ -69,7 +69,7 @@
*/
static int
-sweep_cb(PARROT_INTERP, ARGMOD(Small_Object_Pool *pool), int flag,
+sweep_cb(PARROT_INTERP, ARGMOD(Fixed_Size_Pool *pool), int flag,
ARGMOD(void *arg))
{
int * const total_free = (int *) arg;
@@ -90,7 +90,7 @@
/*
-=item C<static void clear_cow(PARROT_INTERP, Small_Object_Pool *pool, int cleanup)>
+=item C<static void clear_cow(PARROT_INTERP, Fixed_Size_Pool *pool, int cleanup)>
Clears the COW ref count.
@@ -99,10 +99,10 @@
*/
static void
-clear_cow(PARROT_INTERP, ARGMOD(Small_Object_Pool *pool), int cleanup)
+clear_cow(PARROT_INTERP, ARGMOD(Fixed_Size_Pool *pool), int cleanup)
{
const UINTVAL object_size = pool->object_size;
- Small_Object_Arena *cur_arena;
+ Fixed_Size_Arena *cur_arena;
/* clear refcount for COWable objects. */
for (cur_arena = pool->last_Arena;
@@ -136,7 +136,7 @@
/*
-=item C<static void used_cow(PARROT_INTERP, Small_Object_Pool *pool, int cleanup)>
+=item C<static void used_cow(PARROT_INTERP, Fixed_Size_Pool *pool, int cleanup)>
Finds other users of COW's C<bufstart>.
@@ -145,10 +145,10 @@
*/
static void
-used_cow(PARROT_INTERP, ARGMOD(Small_Object_Pool *pool), int cleanup)
+used_cow(PARROT_INTERP, ARGMOD(Fixed_Size_Pool *pool), int cleanup)
{
const UINTVAL object_size = pool->object_size;
- Small_Object_Arena *cur_arena;
+ Fixed_Size_Arena *cur_arena;
for (cur_arena = pool->last_Arena;
NULL != cur_arena; cur_arena = cur_arena->prev) {
Modified: branches/kill_jit/src/gc/gc_ms.c
==============================================================================
--- branches/kill_jit/src/gc/gc_ms.c Wed Sep 16 20:55:27 2009 (r41308)
+++ branches/kill_jit/src/gc/gc_ms.c Wed Sep 16 21:22:58 2009 (r41309)
@@ -23,26 +23,27 @@
/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
static void gc_ms_add_free_object(SHIM_INTERP,
- ARGMOD(Small_Object_Pool *pool),
+ ARGMOD(Fixed_Size_Pool *pool),
ARGIN(void *to_add))
__attribute__nonnull__(2)
__attribute__nonnull__(3)
FUNC_MODIFIES(*pool);
static void gc_ms_alloc_objects(PARROT_INTERP,
- ARGMOD(Small_Object_Pool *pool))
+ ARGMOD(Fixed_Size_Pool *pool))
__attribute__nonnull__(1)
__attribute__nonnull__(2)
FUNC_MODIFIES(*pool);
-static void gc_ms_finalize(PARROT_INTERP, ARGIN(Arenas * const arena_base))
+static void gc_ms_finalize(PARROT_INTERP,
+ ARGIN(Memory_Pools * const mem_pools))
__attribute__nonnull__(1)
__attribute__nonnull__(2);
PARROT_CANNOT_RETURN_NULL
PARROT_WARN_UNUSED_RESULT
static void * gc_ms_get_free_object(PARROT_INTERP,
- ARGMOD(Small_Object_Pool *pool))
+ ARGMOD(Fixed_Size_Pool *pool))
__attribute__nonnull__(1)
__attribute__nonnull__(2)
FUNC_MODIFIES(*pool);
@@ -51,17 +52,17 @@
__attribute__nonnull__(1);
static void gc_ms_more_traceable_objects(PARROT_INTERP,
- ARGMOD(Small_Object_Pool *pool))
+ ARGMOD(Fixed_Size_Pool *pool))
__attribute__nonnull__(1)
__attribute__nonnull__(2)
FUNC_MODIFIES(*pool);
-static void gc_ms_pool_init(SHIM_INTERP, ARGMOD(Small_Object_Pool *pool))
+static void gc_ms_pool_init(SHIM_INTERP, ARGMOD(Fixed_Size_Pool *pool))
__attribute__nonnull__(2)
FUNC_MODIFIES(*pool);
static int gc_ms_sweep_cb(PARROT_INTERP,
- ARGMOD(Small_Object_Pool *pool),
+ ARGMOD(Fixed_Size_Pool *pool),
int flag,
ARGMOD(void *arg))
__attribute__nonnull__(1)
@@ -82,7 +83,7 @@
|| PARROT_ASSERT_ARG(pool)
#define ASSERT_ARGS_gc_ms_finalize __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(arena_base)
+ || PARROT_ASSERT_ARG(mem_pools)
#define ASSERT_ARGS_gc_ms_get_free_object __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp) \
|| PARROT_ASSERT_ARG(pool)
@@ -123,11 +124,11 @@
Parrot_gc_ms_init(PARROT_INTERP)
{
ASSERT_ARGS(Parrot_gc_ms_init)
- Arenas * const arena_base = interp->arena_base;
- arena_base->do_gc_mark = gc_ms_mark_and_sweep;
- arena_base->finalize_gc_system = NULL;
- arena_base->init_pool = gc_ms_pool_init;
+ interp->gc_sys->do_gc_mark = gc_ms_mark_and_sweep;
+ interp->gc_sys->finalize_gc_system = NULL;
+ interp->gc_sys->init_pool = gc_ms_pool_init;
+
}
/*
@@ -144,25 +145,25 @@
gc_ms_mark_and_sweep(PARROT_INTERP, UINTVAL flags)
{
ASSERT_ARGS(gc_ms_mark_and_sweep)
- Arenas * const arena_base = interp->arena_base;
+ Memory_Pools * const mem_pools = interp->mem_pools;
int total_free = 0;
- if (arena_base->gc_mark_block_level)
+ if (mem_pools->gc_mark_block_level)
return;
if (interp->pdb && interp->pdb->debugger) {
/* The debugger could have performed a mark. Make sure everything is
marked dead here, so that when we sweep it all gets collected */
- Parrot_gc_clear_live_bits(interp, arena_base->pmc_pool);
+ Parrot_gc_clear_live_bits(interp, mem_pools->pmc_pool);
}
if (flags & GC_finish_FLAG) {
- gc_ms_finalize(interp, arena_base);
+ gc_ms_finalize(interp, mem_pools);
return;
}
- ++arena_base->gc_mark_block_level;
- arena_base->lazy_gc = flags & GC_lazy_FLAG;
+ ++mem_pools->gc_mark_block_level;
+ mem_pools->lazy_gc = flags & GC_lazy_FLAG;
/* tell the threading system that we're doing GC mark */
pt_gc_start_mark(interp);
@@ -176,8 +177,8 @@
if (gc_ms_trace_active_PMCs(interp, (flags & GC_trace_stack_FLAG)
? GC_TRACE_FULL : GC_TRACE_ROOT_ONLY)) {
- arena_base->gc_trace_ptr = NULL;
- arena_base->gc_mark_ptr = NULL;
+ mem_pools->gc_trace_ptr = NULL;
+ mem_pools->gc_mark_ptr = NULL;
/* We've done the mark, now do the sweep. Pass the sweep callback
function to the PMC pool and all the sized pools. */
@@ -186,23 +187,24 @@
}
else {
- ++arena_base->gc_lazy_mark_runs;
+ ++mem_pools->gc_lazy_mark_runs;
- Parrot_gc_clear_live_bits(interp, arena_base->pmc_pool);
+ Parrot_gc_clear_live_bits(interp, mem_pools->pmc_pool);
}
pt_gc_stop_mark(interp);
/* Note it */
- arena_base->gc_mark_runs++;
- --arena_base->gc_mark_block_level;
+ mem_pools->gc_mark_runs++;
+ --mem_pools->gc_mark_block_level;
return;
}
/*
-=item C<static void gc_ms_finalize(PARROT_INTERP, Arenas * const arena_base)>
+=item C<static void gc_ms_finalize(PARROT_INTERP, Memory_Pools * const
+mem_pools)>
Perform the finalization run, freeing all PMCs.
@@ -211,23 +213,23 @@
*/
static void
-gc_ms_finalize(PARROT_INTERP, ARGIN(Arenas * const arena_base))
+gc_ms_finalize(PARROT_INTERP, ARGIN(Memory_Pools * const mem_pools))
{
ASSERT_ARGS(gc_ms_finalize)
- Parrot_gc_clear_live_bits(interp, arena_base->pmc_pool);
- Parrot_gc_clear_live_bits(interp, arena_base->constant_pmc_pool);
+ Parrot_gc_clear_live_bits(interp, mem_pools->pmc_pool);
+ Parrot_gc_clear_live_bits(interp, mem_pools->constant_pmc_pool);
/* keep the scheduler and its kids alive for Task-like PMCs to destroy
* themselves; run a sweep to collect them */
if (interp->scheduler) {
Parrot_gc_mark_PObj_alive(interp, (PObj *)interp->scheduler);
VTABLE_mark(interp, interp->scheduler);
- Parrot_gc_sweep_pool(interp, interp->arena_base->pmc_pool);
+ Parrot_gc_sweep_pool(interp, interp->mem_pools->pmc_pool);
}
/* now sweep everything that's left */
- Parrot_gc_sweep_pool(interp, interp->arena_base->pmc_pool);
- Parrot_gc_sweep_pool(interp, interp->arena_base->constant_pmc_pool);
+ Parrot_gc_sweep_pool(interp, interp->mem_pools->pmc_pool);
+ Parrot_gc_sweep_pool(interp, interp->mem_pools->constant_pmc_pool);
}
@@ -258,7 +260,7 @@
/*
-=item C<static int gc_ms_sweep_cb(PARROT_INTERP, Small_Object_Pool *pool, int
+=item C<static int gc_ms_sweep_cb(PARROT_INTERP, Fixed_Size_Pool *pool, int
flag, void *arg)>
Sweeps the given pool for the MS collector. This function also ends
@@ -270,7 +272,7 @@
*/
static int
-gc_ms_sweep_cb(PARROT_INTERP, ARGMOD(Small_Object_Pool *pool), int flag,
+gc_ms_sweep_cb(PARROT_INTERP, ARGMOD(Fixed_Size_Pool *pool), int flag,
ARGMOD(void *arg))
{
ASSERT_ARGS(gc_ms_sweep_cb)
@@ -291,7 +293,7 @@
=over 4
-=item C<static void gc_ms_pool_init(PARROT_INTERP, Small_Object_Pool *pool)>
+=item C<static void gc_ms_pool_init(PARROT_INTERP, Fixed_Size_Pool *pool)>
Initialize a memory pool for the MS garbage collector system. Sets the
function pointers necessary to perform basic operations on a pool, such
@@ -302,7 +304,7 @@
*/
static void
-gc_ms_pool_init(SHIM_INTERP, ARGMOD(Small_Object_Pool *pool))
+gc_ms_pool_init(SHIM_INTERP, ARGMOD(Fixed_Size_Pool *pool))
{
ASSERT_ARGS(gc_ms_pool_init)
pool->add_free_object = gc_ms_add_free_object;
@@ -313,8 +315,8 @@
/*
-=item C<static void gc_ms_more_traceable_objects(PARROT_INTERP,
-Small_Object_Pool *pool)>
+=item C<static void gc_ms_more_traceable_objects(PARROT_INTERP, Fixed_Size_Pool
+*pool)>
We're out of traceable objects. First we try a GC run to free some up. If
that doesn't work, allocate a new arena.
@@ -324,14 +326,14 @@
*/
static void
-gc_ms_more_traceable_objects(PARROT_INTERP, ARGMOD(Small_Object_Pool *pool))
+gc_ms_more_traceable_objects(PARROT_INTERP, ARGMOD(Fixed_Size_Pool *pool))
{
ASSERT_ARGS(gc_ms_more_traceable_objects)
if (pool->skip)
pool->skip = 0;
else {
- Small_Object_Arena * const arena = pool->last_Arena;
+ Fixed_Size_Arena * const arena = pool->last_Arena;
if (arena
&& arena->used == arena->total_objects)
Parrot_gc_mark_and_sweep(interp, GC_trace_stack_FLAG);
@@ -351,8 +353,8 @@
/*
-=item C<static void gc_ms_add_free_object(PARROT_INTERP, Small_Object_Pool
-*pool, void *to_add)>
+=item C<static void gc_ms_add_free_object(PARROT_INTERP, Fixed_Size_Pool *pool,
+void *to_add)>
Add an unused object back to the pool's free list for later reuse. Set
the PObj flags to indicate that the item is free.
@@ -362,7 +364,7 @@
*/
static void
-gc_ms_add_free_object(SHIM_INTERP, ARGMOD(Small_Object_Pool *pool),
+gc_ms_add_free_object(SHIM_INTERP, ARGMOD(Fixed_Size_Pool *pool),
ARGIN(void *to_add))
{
ASSERT_ARGS(gc_ms_add_free_object)
@@ -376,7 +378,7 @@
/*
-=item C<static void * gc_ms_get_free_object(PARROT_INTERP, Small_Object_Pool
+=item C<static void * gc_ms_get_free_object(PARROT_INTERP, Fixed_Size_Pool
*pool)>
Free object allocator for the MS garbage collector system. If there are no
@@ -391,7 +393,7 @@
PARROT_CANNOT_RETURN_NULL
PARROT_WARN_UNUSED_RESULT
static void *
-gc_ms_get_free_object(PARROT_INTERP, ARGMOD(Small_Object_Pool *pool))
+gc_ms_get_free_object(PARROT_INTERP, ARGMOD(Fixed_Size_Pool *pool))
{
ASSERT_ARGS(gc_ms_get_free_object)
PObj *ptr;
@@ -404,7 +406,7 @@
}
if (!free_list) {
- Small_Object_Arena * const arena = pool->last_Arena;
+ Fixed_Size_Arena * const arena = pool->last_Arena;
ptr = (PObj *)pool->newfree;
pool->newfree = (void *)((char *)pool->newfree + pool->object_size);
arena->used++;
@@ -440,7 +442,7 @@
/*
-=item C<static void gc_ms_alloc_objects(PARROT_INTERP, Small_Object_Pool *pool)>
+=item C<static void gc_ms_alloc_objects(PARROT_INTERP, Fixed_Size_Pool *pool)>
New arena allocator function for the MS garbage collector system. Allocates
and initializes a new memory arena in the given pool. Adds all the new
@@ -451,13 +453,13 @@
*/
static void
-gc_ms_alloc_objects(PARROT_INTERP, ARGMOD(Small_Object_Pool *pool))
+gc_ms_alloc_objects(PARROT_INTERP, ARGMOD(Fixed_Size_Pool *pool))
{
ASSERT_ARGS(gc_ms_alloc_objects)
/* Setup memory for the new objects */
- Small_Object_Arena * const new_arena =
- mem_internal_allocate_typed(Small_Object_Arena);
+ Fixed_Size_Arena * const new_arena =
+ mem_internal_allocate_typed(Fixed_Size_Arena);
const size_t size = pool->object_size * pool->objects_per_alloc;
size_t alloc_size;
Modified: branches/kill_jit/src/gc/gc_private.h
==============================================================================
--- branches/kill_jit/src/gc/gc_private.h Wed Sep 16 20:55:27 2009 (r41308)
+++ branches/kill_jit/src/gc/gc_private.h Wed Sep 16 21:22:58 2009 (r41309)
@@ -86,13 +86,60 @@
struct GC_MS_PObj_Wrapper * next_ptr;
} GC_MS_PObj_Wrapper;
-typedef struct Small_Object_Arena {
+
+typedef enum _gc_sys_type_enum {
+ MS, /*mark and sweep*/
+ INF /*infinite memory core*/
+} gc_sys_type_enum;
+
+typedef struct GC_Subsystem {
+ /* Which GC subsystem are we using? See PARROT_GC_DEFAULT_TYPE in
+ * include/parrot/settings.h for possible values */
+ gc_sys_type_enum sys_type;
+
+ /** Function hooks that each subsystem MUST provide */
+ void (*do_gc_mark)(PARROT_INTERP, UINTVAL flags);
+ void (*finalize_gc_system) (PARROT_INTERP);
+ void (*init_pool)(PARROT_INTERP, struct Fixed_Size_Pool *);
+
+ /*Function hooks that GC systems can CHOOSE to provide if they need them
+ *These will be called via the GC API functions Parrot_gc_func_name
+ *e.g. read barrier && write barrier hooks can go here later ...*/
+
+ /* Holds system-specific data structures
+ * unused right now, but this is where it should go if we need them ...
+ union {
+ } gc_private;
+ */
+} GC_Subsystem;
+
+typedef struct Memory_Block {
+ size_t free;
+ size_t size;
+ struct Memory_Block *prev;
+ struct Memory_Block *next;
+ char *start;
+ char *top;
+} Memory_Block;
+
+typedef struct Variable_Size_Pool {
+ Memory_Block *top_block;
+ void (*compact)(PARROT_INTERP, struct Variable_Size_Pool *);
+ size_t minimum_block_size;
+ size_t total_allocated; /* total bytes allocated to this pool */
+ size_t guaranteed_reclaimable; /* bytes that can definitely be reclaimed*/
+ size_t possibly_reclaimable; /* bytes that can possibly be reclaimed
+ * (above plus COW-freed bytes) */
+ FLOATVAL reclaim_factor; /* minimum percentage we will reclaim */
+} Variable_Size_Pool;
+
+typedef struct Fixed_Size_Arena {
size_t used;
size_t total_objects;
- struct Small_Object_Arena *prev;
- struct Small_Object_Arena *next;
+ struct Fixed_Size_Arena *prev;
+ struct Fixed_Size_Arena *next;
void *start_objects;
-} Small_Object_Arena;
+} Fixed_Size_Arena;
typedef struct PMC_Attribute_Free_List {
struct PMC_Attribute_Free_List * next;
@@ -103,61 +150,6 @@
struct PMC_Attribute_Arena * prev;
} PMC_Attribute_Arena;
-#if PARROT_GC_GMS
-/*
- * all objects have this header in front of the actual
- * object pointer. The prev/next pointers chain all existing
- * objects for one pool (sizeclass) together.
- *
- * XXX this could lead to unaligned FLOATVALs in the adjacent PMC
- * if that's true either insert a dummy or reorder PMC members
- * ??? How is that possible?
- */
-typedef struct _gc_gms_hdr {
- struct _gc_gms_hdr *prev;
- struct _gc_gms_hdr *next;
- struct _gc_gms_gen *gen;
- void *gc_dummy_align; /* see above */
-} Gc_gms_hdr;
-
-# define PObj_to_GMSH(o) (((Gc_gms_hdr*)(o))-1)
-# define GMSH_to_PObj(p) ((PObj*) ((p)+1))
-
-/* the structure uses 2 ptrs itself */
-# define GC_GMS_STORE_SIZE (64-2)
-
-typedef struct _gc_gms_hdr_store {
- struct _gc_gms_hdr_store *next;
- Gc_gms_hdr **ptr; /* insert location */
- Gc_gms_hdr * (store[GC_GMS_STORE_SIZE]); /* array of hdr pointers */
-} Gc_gms_hdr_store;
-
-typedef struct _gc_gms_hdr_list {
- Gc_gms_hdr_store *first;
- Gc_gms_hdr_store *last;
-} Gc_gms_hdr_list;
-
-
-/*
- * all objects belong to one generation
- */
-typedef struct _gc_gms_gen {
- UINTVAL gen_no; /* generation number */
- UINTVAL timely_destruct_obj_sofar; /* sum up to this generation */
- UINTVAL black_color; /* live color of this generation */
- struct _gc_gms_hdr *first; /* first header in this generation */
- struct _gc_gms_hdr *last; /* last header in this generation */
- struct _gc_gms_hdr *fin; /* need destruction/finalization */
- struct Small_Object_Pool *pool; /* where this generation belongs to */
- Gc_gms_hdr_list igp; /* IGPs for this generation */
- UINTVAL n_possibly_dead; /* overwritten count */
- UINTVAL n_objects; /* live objects count */
- struct _gc_gms_gen *prev;
- struct _gc_gms_gen *next;
-} Gc_gms_gen;
-
-#endif /* PARROT_GC_GMS */
-
typedef struct PMC_Attribute_Pool {
size_t attr_size;
size_t total_objects;
@@ -172,71 +164,65 @@
} PMC_Attribute_Pool;
/* Tracked resource pool */
-typedef struct Small_Object_Pool {
- Small_Object_Arena *last_Arena;
- /* Size in bytes of an individual pool item. This size may include
- * a GC-system specific GC header.
- * See the macros below.
- */
+typedef struct Fixed_Size_Pool {
+
+ struct Variable_Size_Pool *mem_pool;
+ /* Size in bytes of an individual pool item. This size may include
+ * a GC-system specific GC header. */
size_t object_size;
- size_t objects_per_alloc;
- size_t total_objects;
+
+ size_t start_arena_memory;
+ size_t end_arena_memory;
+
+ Fixed_Size_Arena *last_Arena;
+ GC_MS_PObj_Wrapper * free_list;
size_t num_free_objects; /* number of resources in the free pool */
+ size_t total_objects;
+
+ PARROT_OBSERVER const char *name;
+
+ size_t objects_per_alloc;
+
int skip;
size_t replenish_level;
- GC_MS_PObj_Wrapper * free_list;
- /* adds a free object to the pool's free list */
- add_free_object_fn_type add_free_object;
- get_free_object_fn_type get_free_object;
- alloc_objects_fn_type alloc_objects;
+
+ add_free_object_fn_type add_free_object; /* adds a free object to
+ the pool's free list */
+ get_free_object_fn_type get_free_object; /* gets and removes a free
+ object from the pool's
+ free list */
+ alloc_objects_fn_type alloc_objects; /* allocates more objects */
alloc_objects_fn_type more_objects;
gc_object_fn_type gc_object;
- /* gets and removes a free object from the pool's free list */
- /* allocates more objects */
- struct Memory_Pool *mem_pool;
- size_t start_arena_memory;
- size_t end_arena_memory;
- PARROT_OBSERVER const char *name;
+
+ /* Contains GC system-specific data structures ... unused at the moment,
+ * but this is where it should go when we need it ...
+ union {
+ } gc_private;
+ */
+
#if GC_USE_LAZY_ALLOCATOR
void *newfree;
void *newlast;
#endif
-#if PARROT_GC_GMS
- struct _gc_gms_hdr marker; /* limit of list */
- struct _gc_gms_hdr *black; /* alive */
- struct _gc_gms_hdr *black_fin; /* alive, needs destruction */
- struct _gc_gms_hdr *gray; /* to be scanned */
- struct _gc_gms_hdr *white; /* unprocessed */
- struct _gc_gms_hdr *white_fin; /* unprocesse, needs destruction */
- struct _gc_gms_gen *first_gen; /* linked list of generations */
- struct _gc_gms_gen *last_gen;
+} Fixed_Size_Pool;
-#endif
-} Small_Object_Pool;
-
-typedef struct Arenas {
- Memory_Pool *memory_pool;
- Memory_Pool *constant_string_pool;
- struct Small_Object_Pool *string_header_pool;
- struct Small_Object_Pool *pmc_pool;
- struct Small_Object_Pool *constant_pmc_pool;
- struct Small_Object_Pool *constant_string_header_pool;
- struct Small_Object_Pool **sized_header_pools;
+typedef struct Memory_Pools {
+ Variable_Size_Pool *memory_pool;
+ Variable_Size_Pool *constant_string_pool;
+ struct Fixed_Size_Pool *string_header_pool;
+ struct Fixed_Size_Pool *pmc_pool;
+ struct Fixed_Size_Pool *constant_pmc_pool;
+ struct Fixed_Size_Pool *constant_string_header_pool;
+ struct Fixed_Size_Pool **sized_header_pools;
size_t num_sized;
PMC_Attribute_Pool **attrib_pools;
size_t num_attribs;
- /*
- * function slots that each subsystem must provide
- */
- void (*do_gc_mark)(PARROT_INTERP, UINTVAL flags);
- void (*finalize_gc_system) (PARROT_INTERP);
- void (*init_pool)(PARROT_INTERP, struct Small_Object_Pool *);
- /*
- * statistics for GC
- */
+
+ /** statistics for GC **/
size_t gc_mark_runs; /* Number of times we've done a mark run*/
size_t gc_lazy_mark_runs; /* Number of successful lazy mark runs */
size_t gc_collect_runs; /* Number of times we've done a memory
@@ -275,7 +261,7 @@
* private data for the GC subsystem
*/
void * gc_private; /* gc subsystem data */
-} Arenas;
+} Memory_Pools;
/* HEADERIZER BEGIN: src/gc/system.c */
@@ -289,98 +275,20 @@
/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
/* HEADERIZER END: src/gc/system.c */
-/* HEADERIZER BEGIN: src/gc/generational_ms.c */
-/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
-
-PARROT_EXPORT
-void Parrot_gc_gms_init(PARROT_INTERP)
- __attribute__nonnull__(1);
-
-PARROT_EXPORT
-void parrot_gc_gms_Parrot_gc_mark_PObj_alive(PARROT_INTERP,
- ARGMOD(PObj *obj))
- __attribute__nonnull__(1)
- __attribute__nonnull__(2)
- FUNC_MODIFIES(*obj);
-
-void parrot_gc_gms_wb(PARROT_INTERP,
- ARGIN(PMC *agg),
- ARGIN(void *old),
- ARGIN(void *_new))
- __attribute__nonnull__(1)
- __attribute__nonnull__(2)
- __attribute__nonnull__(3)
- __attribute__nonnull__(4);
-
-void parrot_gc_gms_wb_key(PARROT_INTERP,
- ARGIN(PMC *agg),
- ARGIN(void *old),
- ARGIN(void *old_key),
- ARGIN(void *_new),
- ARGIN(void *new_key))
- __attribute__nonnull__(1)
- __attribute__nonnull__(2)
- __attribute__nonnull__(3)
- __attribute__nonnull__(4)
- __attribute__nonnull__(5)
- __attribute__nonnull__(6);
-
-#define ASSERT_ARGS_Parrot_gc_gms_init __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp)
-#define ASSERT_ARGS_parrot_gc_gms_Parrot_gc_mark_PObj_alive \
- __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(obj)
-#define ASSERT_ARGS_parrot_gc_gms_wb __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(agg) \
- || PARROT_ASSERT_ARG(old) \
- || PARROT_ASSERT_ARG(_new)
-#define ASSERT_ARGS_parrot_gc_gms_wb_key __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(agg) \
- || PARROT_ASSERT_ARG(old) \
- || PARROT_ASSERT_ARG(old_key) \
- || PARROT_ASSERT_ARG(_new) \
- || PARROT_ASSERT_ARG(new_key)
-/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
-/* HEADERIZER END: src/gc/generational_ms.c */
-
-/* HEADERIZER BEGIN: src/gc/incremental_ms.c */
-/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
-
-void Parrot_gc_ims_init(PARROT_INTERP)
- __attribute__nonnull__(1);
-
-void Parrot_gc_ims_wb(PARROT_INTERP, ARGMOD(PMC *agg), ARGMOD(PMC *_new))
- __attribute__nonnull__(1)
- __attribute__nonnull__(2)
- __attribute__nonnull__(3)
- FUNC_MODIFIES(*agg)
- FUNC_MODIFIES(*_new);
-
-#define ASSERT_ARGS_Parrot_gc_ims_init __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp)
-#define ASSERT_ARGS_Parrot_gc_ims_wb __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(agg) \
- || PARROT_ASSERT_ARG(_new)
-/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
-/* HEADERIZER END: src/gc/incremental_ms.c */
-
/* HEADERIZER BEGIN: src/gc/mark_sweep.c */
/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
PARROT_WARN_UNUSED_RESULT
-INTVAL contained_in_pool(
- ARGIN(const Small_Object_Pool *pool),
+INTVAL contained_in_pool(PARROT_INTERP,
+ ARGIN(const Fixed_Size_Pool *pool),
ARGIN(const void *ptr))
__attribute__nonnull__(1)
- __attribute__nonnull__(2);
+ __attribute__nonnull__(2)
+ __attribute__nonnull__(3);
PARROT_WARN_UNUSED_RESULT
PARROT_CANNOT_RETURN_NULL
-Small_Object_Pool * get_bufferlike_pool(PARROT_INTERP, size_t buffer_size)
+Fixed_Size_Pool * get_bufferlike_pool(PARROT_INTERP, size_t buffer_size)
__attribute__nonnull__(1);
PARROT_IGNORABLE_RESULT
@@ -392,7 +300,7 @@
__attribute__nonnull__(1)
__attribute__nonnull__(4);
-void initialize_header_pools(PARROT_INTERP)
+void initialize_fixed_size_pools(PARROT_INTERP)
__attribute__nonnull__(1);
void mark_special(PARROT_INTERP, ARGIN(PMC *obj))
@@ -400,8 +308,8 @@
__attribute__nonnull__(2);
void Parrot_add_to_free_list(PARROT_INTERP,
- ARGMOD(Small_Object_Pool *pool),
- ARGMOD(Small_Object_Arena *arena))
+ ARGMOD(Fixed_Size_Pool *pool),
+ ARGMOD(Fixed_Size_Arena *arena))
__attribute__nonnull__(1)
__attribute__nonnull__(2)
__attribute__nonnull__(3)
@@ -409,8 +317,8 @@
FUNC_MODIFIES(*arena);
void Parrot_append_arena_in_pool(PARROT_INTERP,
- ARGMOD(Small_Object_Pool *pool),
- ARGMOD(Small_Object_Arena *new_arena),
+ ARGMOD(Fixed_Size_Pool *pool),
+ ARGMOD(Fixed_Size_Arena *new_arena),
size_t size)
__attribute__nonnull__(1)
__attribute__nonnull__(2)
@@ -419,7 +327,7 @@
FUNC_MODIFIES(*new_arena);
void Parrot_gc_clear_live_bits(PARROT_INTERP,
- ARGIN(const Small_Object_Pool *pool))
+ ARGIN(const Fixed_Size_Pool *pool))
__attribute__nonnull__(1)
__attribute__nonnull__(2);
@@ -447,7 +355,7 @@
void Parrot_gc_run_init(PARROT_INTERP)
__attribute__nonnull__(1);
-void Parrot_gc_sweep_pool(PARROT_INTERP, ARGMOD(Small_Object_Pool *pool))
+void Parrot_gc_sweep_pool(PARROT_INTERP, ARGMOD(Fixed_Size_Pool *pool))
__attribute__nonnull__(1)
__attribute__nonnull__(2)
FUNC_MODIFIES(*pool);
@@ -459,14 +367,15 @@
__attribute__nonnull__(1);
#define ASSERT_ARGS_contained_in_pool __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(pool) \
+ PARROT_ASSERT_ARG(interp) \
+ || PARROT_ASSERT_ARG(pool) \
|| PARROT_ASSERT_ARG(ptr)
#define ASSERT_ARGS_get_bufferlike_pool __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp)
#define ASSERT_ARGS_header_pools_iterate_callback __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp) \
|| PARROT_ASSERT_ARG(func)
-#define ASSERT_ARGS_initialize_header_pools __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+#define ASSERT_ARGS_initialize_fixed_size_pools __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp)
#define ASSERT_ARGS_mark_special __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp) \
@@ -510,7 +419,7 @@
PARROT_WARN_UNUSED_RESULT
PARROT_CANNOT_RETURN_NULL
-Small_Object_Pool * get_bufferlike_pool(PARROT_INTERP, size_t buffer_size)
+Fixed_Size_Pool * get_bufferlike_pool(PARROT_INTERP, size_t buffer_size)
__attribute__nonnull__(1);
PARROT_IGNORABLE_RESULT
@@ -522,7 +431,7 @@
__attribute__nonnull__(1)
__attribute__nonnull__(4);
-void initialize_header_pools(PARROT_INTERP)
+void initialize_fixed_size_pools(PARROT_INTERP)
__attribute__nonnull__(1);
#define ASSERT_ARGS_get_bufferlike_pool __attribute__unused__ int _ASSERT_ARGS_CHECK = \
@@ -530,7 +439,7 @@
#define ASSERT_ARGS_header_pools_iterate_callback __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp) \
|| PARROT_ASSERT_ARG(func)
-#define ASSERT_ARGS_initialize_header_pools __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+#define ASSERT_ARGS_initialize_fixed_size_pools __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp)
/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
/* HEADERIZER END: src/gc/pools.c */
@@ -553,28 +462,34 @@
PARROT_WARN_UNUSED_RESULT
size_t aligned_string_size(size_t len);
-void check_buffer_ptr(ARGMOD(Buffer * pobj), ARGMOD(Memory_Pool * pool))
+void check_buffer_ptr(
+ ARGMOD(Buffer * pobj),
+ ARGMOD(Variable_Size_Pool * pool))
__attribute__nonnull__(1)
__attribute__nonnull__(2)
FUNC_MODIFIES(* pobj)
FUNC_MODIFIES(* pool);
-void compact_pool(PARROT_INTERP, ARGMOD(Memory_Pool *pool))
+void compact_pool(PARROT_INTERP, ARGMOD(Variable_Size_Pool *pool))
__attribute__nonnull__(1)
__attribute__nonnull__(2)
FUNC_MODIFIES(*pool);
-void initialize_memory_pools(PARROT_INTERP)
+void initialize_var_size_pools(PARROT_INTERP)
__attribute__nonnull__(1);
PARROT_MALLOC
PARROT_CANNOT_RETURN_NULL
-void * mem_allocate(PARROT_INTERP, size_t size, ARGMOD(Memory_Pool *pool))
+void * mem_allocate(PARROT_INTERP,
+ size_t size,
+ ARGMOD(Variable_Size_Pool *pool))
__attribute__nonnull__(1)
__attribute__nonnull__(3)
FUNC_MODIFIES(*pool);
-void merge_pools(ARGMOD(Memory_Pool *dest), ARGMOD(Memory_Pool *source))
+void merge_pools(
+ ARGMOD(Variable_Size_Pool *dest),
+ ARGMOD(Variable_Size_Pool *source))
__attribute__nonnull__(1)
__attribute__nonnull__(2)
FUNC_MODIFIES(*dest)
@@ -592,7 +507,7 @@
#define ASSERT_ARGS_compact_pool __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp) \
|| PARROT_ASSERT_ARG(pool)
-#define ASSERT_ARGS_initialize_memory_pools __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+#define ASSERT_ARGS_initialize_var_size_pools __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp)
#define ASSERT_ARGS_mem_allocate __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp) \
@@ -604,83 +519,6 @@
/* HEADERIZER END: src/gc/alloc_resources.c */
/* GC subsystem init functions */
-/* HEADERIZER BEGIN: src/gc/generational_ms.c */
-/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
-
-PARROT_EXPORT
-void Parrot_gc_gms_init(PARROT_INTERP)
- __attribute__nonnull__(1);
-
-PARROT_EXPORT
-void parrot_gc_gms_Parrot_gc_mark_PObj_alive(PARROT_INTERP, ARGMOD(PObj *obj))
- __attribute__nonnull__(1)
- __attribute__nonnull__(2)
- FUNC_MODIFIES(*obj);
-
-void parrot_gc_gms_wb(PARROT_INTERP,
- ARGIN(PMC *agg),
- ARGIN(void *old),
- ARGIN(void *_new))
- __attribute__nonnull__(1)
- __attribute__nonnull__(2)
- __attribute__nonnull__(3)
- __attribute__nonnull__(4);
-
-void parrot_gc_gms_wb_key(PARROT_INTERP,
- ARGIN(PMC *agg),
- ARGIN(void *old),
- ARGIN(void *old_key),
- ARGIN(void *_new),
- ARGIN(void *new_key))
- __attribute__nonnull__(1)
- __attribute__nonnull__(2)
- __attribute__nonnull__(3)
- __attribute__nonnull__(4)
- __attribute__nonnull__(5)
- __attribute__nonnull__(6);
-
-#define ASSERT_ARGS_Parrot_gc_gms_init __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp)
-#define ASSERT_ARGS_parrot_gc_gms_Parrot_gc_mark_PObj_alive __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(obj)
-#define ASSERT_ARGS_parrot_gc_gms_wb __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(agg) \
- || PARROT_ASSERT_ARG(old) \
- || PARROT_ASSERT_ARG(_new)
-#define ASSERT_ARGS_parrot_gc_gms_wb_key __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(agg) \
- || PARROT_ASSERT_ARG(old) \
- || PARROT_ASSERT_ARG(old_key) \
- || PARROT_ASSERT_ARG(_new) \
- || PARROT_ASSERT_ARG(new_key)
-/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
-/* HEADERIZER END: src/gc/generational_ms.c */
-
-/* HEADERIZER BEGIN: src/gc/incremental_ms.c */
-/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
-
-void Parrot_gc_ims_init(PARROT_INTERP)
- __attribute__nonnull__(1);
-
-void Parrot_gc_ims_wb(PARROT_INTERP, ARGMOD(PMC *agg), ARGMOD(PMC *_new))
- __attribute__nonnull__(1)
- __attribute__nonnull__(2)
- __attribute__nonnull__(3)
- FUNC_MODIFIES(*agg)
- FUNC_MODIFIES(*_new);
-
-#define ASSERT_ARGS_Parrot_gc_ims_init __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp)
-#define ASSERT_ARGS_Parrot_gc_ims_wb __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(agg) \
- || PARROT_ASSERT_ARG(_new)
-/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
-/* HEADERIZER END: src/gc/incremental_ms.c */
-
/* HEADERIZER BEGIN: src/gc/gc_ms.c */
/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
Deleted: branches/kill_jit/src/gc/generational_ms.c
==============================================================================
--- branches/kill_jit/src/gc/generational_ms.c Wed Sep 16 21:22:58 2009 (r41308)
+++ /dev/null 00:00:00 1970 (deleted)
@@ -1,1974 +0,0 @@
-/*
-Copyright (C) 2001-2009, Parrot Foundation.
-$Id$
-
-=head1 NAME
-
-src/gc/generational_ms.c - Generational mark and sweep garbage collection
-
-=head1 OVERVIEW
-
-The following comments describe a generational garbage collection
-scheme for Parrot.
-
-Keywords:
-
- - non-copying, mark & sweep
- - generational
- - implicit reclamation, treadmill
-
-=head1 DESCRIPTION
-
-A plain mark & sweep collector performs work depending on the amount
-of all allocated objects. The advantage of a generational GC is
-achieved by not processing all objects. This is based on the weak
-generational hypothesis, which states that young objects are likely to
-die early. Old objects, which have survived a few GC cycles tend to be
-long-lived.
-
-The terms young and old objects imply that there is some ordering in
-object creation time and the ordering is also followed by object
-references.
-
-Specifically object references have to follow the marking direction.
-In pure functional programming languages this can be a very simple
-scheme:
-
- +------------+ object references
- v |
- old .... young .... youngest
- |
- <-------- scan direction
-
-If (simplified) the only reference-like operation of the interpreter
-is:
-
- cons = (car, cdr)
-
-and the object references "car" and "cdr" are created prior to the
-"aggregate" "cons", all object references point always to older
-objects. By scanning from the youngest to the oldest objects, all
-non-marked objects can be reclaimed immediately. And the scan can be
-aborted at any time after some processing, creating a generational GC
-in a trivial way.
-
-But the programming languages we are serving are working basically the
-other direction, when it comes to object history:
-
- @a[$i] = $n
-
-A reference operation like this needs first an aggregate and then the
-contents of it. So the scan direction is from old objects to younger
-ones. In such a scheme it's a bit more complicated to skip parts of
-the objects.
-
-To take advantage of not processing all the objects, these are divided
-into generations, e.g.:
-
- old young := nursery
- generation 0 generation 1
-
-A mark phase now processes the root set and only objects from the
-young generation. When all objects are either referenced by the root
-set or only by the young generation, the algorithm is correct and
-complete.
-
-But there is of course the possibilty that a young object is
-stored into an aggregate of an older generation. This case is tracked
-by the write barrier, which remembers all such operations in the IGP
-(inter generational pointer) list. When now generation 1 is marked,
-the IGP list can be considered as an extension to the root set, so
-that again all live objects of the young generation are detected.
-
-
-=head2 Structures
-
-=over 4
-
-=item C<typedef struct _gc_gms_gen Gc_gms_gen>
-
-Describes the state of one generation for one pool.
-
-=item C<typedef struct _gc_gms_hdr Gc_gms_hdr>
-
-This header is in front of all Parrot objects. It forms a doubly-linked
-list of all objects in one pool and points to its generation.
-
-=item PObj_to_GMSH(o)
-
-=item GMSH_to_PObj(p)
-
-These two macros convert from and to headers and objects.
-
-=item C<typedef struct _gc_gms_hdr_list Gc_gms_hdr_list>
-
-A chained list of headers used e.g. for the IGP list.
-
-=back
-
-=cut
-
-*/
-
-#include "parrot/parrot.h"
-#include "parrot/gc_api.h"
-
-#if PARROT_GC_GMS
-
-typedef struct Gc_gms_private {
- UINTVAL current_gen_no; /* the nursery generation number */
-} Gc_gms_private;
-
-/* HEADERIZER HFILE: src/gc/gc_private.h */
-
-/* HEADERIZER BEGIN: static */
-/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
-
-static int end_cycle_cb(PARROT_INTERP,
- ARGMOD(Small_Object_Pool *pool),
- int flag,
- SHIM(void *arg))
- __attribute__nonnull__(1)
- __attribute__nonnull__(2)
- FUNC_MODIFIES(*pool);
-
-static void gc_gms_add_free_object(PARROT_INTERP,
- SHIM(Small_Object_Pool *pool),
- SHIM(PObj *to_add))
- __attribute__nonnull__(1);
-
-static void gc_gms_alloc_objects(PARROT_INTERP,
- ARGMOD(Small_Object_Pool *pool))
- __attribute__nonnull__(1)
- __attribute__nonnull__(2)
- FUNC_MODIFIES(*pool);
-
-static void gc_gms_chain_objects(PARROT_INTERP,
- ARGMOD(Small_Object_Pool *pool),
- ARGIN(Small_Object_Arena *new_arena),
- size_t real_size)
- __attribute__nonnull__(1)
- __attribute__nonnull__(2)
- __attribute__nonnull__(3)
- FUNC_MODIFIES(*pool);
-
-static void gc_gms_clear_hdr_list(PARROT_INTERP, ARGMOD(Gc_gms_hdr_list *l))
- __attribute__nonnull__(1)
- __attribute__nonnull__(2)
- FUNC_MODIFIES(*l);
-
-static void gc_gms_clear_igp(PARROT_INTERP, ARGIN(Gc_gms_gen *gen))
- __attribute__nonnull__(1)
- __attribute__nonnull__(2);
-
-PARROT_MALLOC
-PARROT_CANNOT_RETURN_NULL
-static Gc_gms_gen * gc_gms_create_gen(PARROT_INTERP,
- ARGMOD(Small_Object_Pool *pool),
- size_t gen_no)
- __attribute__nonnull__(1)
- __attribute__nonnull__(2)
- FUNC_MODIFIES(*pool);
-
-static void gc_gms_end_cycle(PARROT_INTERP)
- __attribute__nonnull__(1);
-
-PARROT_WARN_UNUSED_RESULT
-PARROT_CANNOT_RETURN_NULL
-static Gc_gms_gen * gc_gms_find_gen(PARROT_INTERP,
- ARGIN(const Gc_gms_hdr *h),
- UINTVAL gen_no)
- __attribute__nonnull__(1)
- __attribute__nonnull__(2);
-
-PARROT_WARN_UNUSED_RESULT
-PARROT_CANNOT_RETURN_NULL
-static PObj * gc_gms_get_free_object(PARROT_INTERP,
- ARGMOD(Small_Object_Pool *pool))
- __attribute__nonnull__(1)
- __attribute__nonnull__(2)
- FUNC_MODIFIES(*pool);
-
-static void gc_gms_init_gen(PARROT_INTERP, ARGMOD(Small_Object_Pool *pool))
- __attribute__nonnull__(1)
- __attribute__nonnull__(2)
- FUNC_MODIFIES(*pool);
-
-static void gc_gms_init_mark(PARROT_INTERP)
- __attribute__nonnull__(1);
-
-static void gc_gms_merge_gen(PARROT_INTERP,
- ARGMOD(Small_Object_Pool *pool),
- int flag,
- SHIM(Gc_gms_plan *plan))
- __attribute__nonnull__(1)
- __attribute__nonnull__(2)
- FUNC_MODIFIES(*pool);
-
-static void gc_gms_more_objects(PARROT_INTERP,
- ARGMOD(Small_Object_Pool *pool))
- __attribute__nonnull__(1)
- __attribute__nonnull__(2)
- FUNC_MODIFIES(*pool);
-
-static void gc_gms_pool_init(PARROT_INTERP, ARGMOD(Small_Object_Pool *pool))
- __attribute__nonnull__(1)
- __attribute__nonnull__(2)
- FUNC_MODIFIES(*pool);
-
-static void gc_gms_promote(PARROT_INTERP,
- ARGIN(Gc_gms_hdr *h),
- UINTVAL gen_no)
- __attribute__nonnull__(1)
- __attribute__nonnull__(2);
-
-static void gc_gms_set_gen(PARROT_INTERP)
- __attribute__nonnull__(1);
-
-static void gc_gms_setto_black(PARROT_INTERP,
- ARGMOD(Gc_gms_hdr *h),
- int priority)
- __attribute__nonnull__(1)
- __attribute__nonnull__(2)
- FUNC_MODIFIES(*h);
-
-static void gc_gms_setto_gray(PARROT_INTERP,
- ARGIN(Gc_gms_hdr *h),
- int priority)
- __attribute__nonnull__(1)
- __attribute__nonnull__(2);
-
-static void gc_gms_store_hdr_list(PARROT_INTERP,
- ARGMOD(Gc_gms_hdr_list *l),
- ARGIN(Gc_gms_hdr *h))
- __attribute__nonnull__(1)
- __attribute__nonnull__(2)
- __attribute__nonnull__(3)
- FUNC_MODIFIES(*l);
-
-static void gc_gms_store_igp(PARROT_INTERP, ARGIN(Gc_gms_hdr *h))
- __attribute__nonnull__(1)
- __attribute__nonnull__(2);
-
-static void gc_gms_sweep(PARROT_INTERP)
- __attribute__nonnull__(1);
-
-static int gc_gms_trace_children(PARROT_INTERP)
- __attribute__nonnull__(1);
-
-static int gc_gms_trace_root(PARROT_INTERP, int trace_stack)
- __attribute__nonnull__(1);
-
-static void gc_gms_use_gen(PARROT_INTERP,
- ARGMOD(Small_Object_Pool *pool),
- int flag,
- ARGIN(const Gc_gms_plan *plan))
- __attribute__nonnull__(1)
- __attribute__nonnull__(2)
- __attribute__nonnull__(4)
- FUNC_MODIFIES(*pool);
-
-static void gms_debug_verify(PARROT_INTERP,
- ARGMOD(Small_Object_Pool *pool),
- ARGIN(const char *action))
- __attribute__nonnull__(1)
- __attribute__nonnull__(2)
- __attribute__nonnull__(3)
- FUNC_MODIFIES(*pool);
-
-static int init_mark_cb(PARROT_INTERP,
- ARGMOD(Small_Object_Pool *pool),
- int flag,
- ARGIN(void *arg))
- __attribute__nonnull__(1)
- __attribute__nonnull__(2)
- __attribute__nonnull__(4)
- FUNC_MODIFIES(*pool);
-
-static void parrot_gc_gms_deinit(PARROT_INTERP)
- __attribute__nonnull__(1);
-
-static void parrot_gc_gms_run(PARROT_INTERP, UINTVAL flags)
- __attribute__nonnull__(1);
-
-PARROT_WARN_UNUSED_RESULT
-static int set_gen_cb(PARROT_INTERP,
- ARGIN(Small_Object_Pool *pool),
- int flag,
- ARGIN(void *arg))
- __attribute__nonnull__(1)
- __attribute__nonnull__(2)
- __attribute__nonnull__(4);
-
-static int sweep_cb_buf(PARROT_INTERP,
- ARGMOD(Small_Object_Pool *pool),
- int flag,
- SHIM(void *arg))
- __attribute__nonnull__(1)
- __attribute__nonnull__(2)
- FUNC_MODIFIES(*pool);
-
-static int sweep_cb_pmc(PARROT_INTERP,
- ARGIN(Small_Object_Pool *pool),
- int flag,
- SHIM(void *arg))
- __attribute__nonnull__(1)
- __attribute__nonnull__(2);
-
-static int trace_children_cb(PARROT_INTERP,
- ARGIN(Small_Object_Pool *pool),
- int flag,
- SHIM(void *arg))
- __attribute__nonnull__(1)
- __attribute__nonnull__(2);
-
-static int trace_igp_cb(PARROT_INTERP,
- ARGIN(Small_Object_Pool *pool),
- int flag,
- SHIM(void *arg))
- __attribute__nonnull__(1)
- __attribute__nonnull__(2);
-
-#define ASSERT_ARGS_end_cycle_cb __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(pool)
-#define ASSERT_ARGS_gc_gms_add_free_object __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp)
-#define ASSERT_ARGS_gc_gms_alloc_objects __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(pool)
-#define ASSERT_ARGS_gc_gms_chain_objects __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(pool) \
- || PARROT_ASSERT_ARG(new_arena)
-#define ASSERT_ARGS_gc_gms_clear_hdr_list __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(l)
-#define ASSERT_ARGS_gc_gms_clear_igp __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(gen)
-#define ASSERT_ARGS_gc_gms_create_gen __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(pool)
-#define ASSERT_ARGS_gc_gms_end_cycle __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp)
-#define ASSERT_ARGS_gc_gms_find_gen __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(h)
-#define ASSERT_ARGS_gc_gms_get_free_object __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(pool)
-#define ASSERT_ARGS_gc_gms_init_gen __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(pool)
-#define ASSERT_ARGS_gc_gms_init_mark __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp)
-#define ASSERT_ARGS_gc_gms_merge_gen __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(pool)
-#define ASSERT_ARGS_gc_gms_more_objects __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(pool)
-#define ASSERT_ARGS_gc_gms_pool_init __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(pool)
-#define ASSERT_ARGS_gc_gms_promote __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(h)
-#define ASSERT_ARGS_gc_gms_set_gen __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp)
-#define ASSERT_ARGS_gc_gms_setto_black __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(h)
-#define ASSERT_ARGS_gc_gms_setto_gray __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(h)
-#define ASSERT_ARGS_gc_gms_store_hdr_list __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(l) \
- || PARROT_ASSERT_ARG(h)
-#define ASSERT_ARGS_gc_gms_store_igp __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(h)
-#define ASSERT_ARGS_gc_gms_sweep __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp)
-#define ASSERT_ARGS_gc_gms_trace_children __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp)
-#define ASSERT_ARGS_gc_gms_trace_root __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp)
-#define ASSERT_ARGS_gc_gms_use_gen __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(pool) \
- || PARROT_ASSERT_ARG(plan)
-#define ASSERT_ARGS_gms_debug_verify __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(pool) \
- || PARROT_ASSERT_ARG(action)
-#define ASSERT_ARGS_init_mark_cb __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(pool) \
- || PARROT_ASSERT_ARG(arg)
-#define ASSERT_ARGS_parrot_gc_gms_deinit __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp)
-#define ASSERT_ARGS_parrot_gc_gms_run __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp)
-#define ASSERT_ARGS_set_gen_cb __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(pool) \
- || PARROT_ASSERT_ARG(arg)
-#define ASSERT_ARGS_sweep_cb_buf __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(pool)
-#define ASSERT_ARGS_sweep_cb_pmc __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(pool)
-#define ASSERT_ARGS_trace_children_cb __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(pool)
-#define ASSERT_ARGS_trace_igp_cb __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(pool)
-/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
-/* HEADERIZER END: static */
-
-
-/*
-
-=pod
-
- * XXX
-
-Main problem TODO 1):
-
- [ PCont ] ... continuation object in old generation
- |
- v
- [ Stack chunk ] --> [ e.g. P register frame ] ... new generation
-
-By pushing a new stack chunk onto the (old) existing stack frame,
-we'd need a WRITE_BARRIER that promotes the stack chunk to the old
-generation of the continuation.
-This would also need an IGP entry for the stack chunk buffer. But -
-as buffers aren't really containers in Parrot - this isn't possible.
-
-To get that right, the code needs better support by the running
-interpreter.
- - never promote continuations (and stacks) in the current stack frame
- to an old generation
- - create scope_enter / scope_exit opcodes
-
-A scope_enter happens on a subroutine call *and' with new_pad /
-push_pad opcodes. Each lexical scope must have its distinct register
-frame, else timely destruction can't work.
-If the frame needs active destruction, the old frame should be
-converted to the (new-1) generation, the inner frame is the nursery.
-On scope exit the newest (nursery) generation is collected and the
-current generation number is reset back to (new-1).
-
-If the scope_enter doesn't indicate timely destruction, generation
-promoting should be done only, if object statistics indicate the
-presence of a fair amount of live objects.
-
-TODO 2) in lazy sweep
-If timely destruction didn't find (all) eager objects, go back to
-older generations, until all these objects have been seen.
-
-TODO 3) interpreter startup
-After all internal structures are created, promote interpreter state
-into initial first old generation by running one GC cycle before
-program execution begins (or just treat all objects as being alive).
-
-=cut
-
-*/
-
-/*
- * call code to verify chain of pointers after each change
- * this is very expensive, but should be used during development
- */
-# define GC_GMS_DEBUG 0
-
-# define UNITS_PER_ALLOC_GROWTH_FACTOR 1.75
-# define POOL_MAX_BYTES 65536*128
-
-/*
-
-=head2 Initialization functions
-
-=over 4
-
-=item C<static void parrot_gc_gms_deinit(PARROT_INTERP)>
-
-Free used resources.
-
-=cut
-
-*/
-
-static void
-parrot_gc_gms_deinit(PARROT_INTERP)
-{
- ASSERT_ARGS(parrot_gc_gms_deinit)
- Arenas * const arena_base = interp->arena_base;
-
- /*
- * TODO free generations
- */
- mem_sys_free(arena_base->gc_private);
- arena_base->gc_private = NULL;
-}
-
-/*
-
-=item C<static void gc_gms_pool_init(PARROT_INTERP, Small_Object_Pool *pool)>
-
-Initialize pool variables. This function must set the pool function pointers
-for C<add_free_object>, C<get_free_object>, C<alloc_objects>, and
-C<more_objects>.
-
-=cut
-
-*/
-
-static void
-gc_gms_pool_init(PARROT_INTERP, ARGMOD(Small_Object_Pool *pool))
-{
- ASSERT_ARGS(gc_gms_pool_init)
- pool->add_free_object = gc_gms_add_free_object;
- pool->get_free_object = gc_gms_get_free_object;
- pool->alloc_objects = gc_gms_alloc_objects;
- pool->more_objects = gc_gms_more_objects;
-
- /* initialize generations */
- gc_gms_init_gen(interp, pool);
- pool->white = pool->white_fin = pool->free_list = &pool->marker;
-
- pool->object_size += sizeof (Gc_gms_hdr);
-}
-
-/*
-
-=item C<void Parrot_gc_gms_init(PARROT_INTERP)>
-
-Initialize the state structures of the gc system. Called immediately before
-creation of memory pools.
-
-=cut
-
-*/
-
-PARROT_EXPORT
-void
-Parrot_gc_gms_init(PARROT_INTERP)
-{
- ASSERT_ARGS(Parrot_gc_gms_init)
- Arenas * const arena_base = interp->arena_base;
-
- arena_base->gc_private = mem_sys_allocate_zeroed(sizeof (Gc_gms_private));
-
- /*
- * set function hooks according to pdd09
- */
- arena_base->do_gc_mark = parrot_gc_gms_run;
- arena_base->finalize_gc_system = parrot_gc_gms_deinit;
- arena_base->init_pool = gc_gms_pool_init;
-
-}
-
-/*
-
-=back
-
-=head2 Interface functions
-
-=over 4
-
-=item C<static void gc_gms_add_free_object(PARROT_INTERP, Small_Object_Pool
-*pool, PObj *to_add)>
-
-Unused. White (dead) objects are added in a bunch to the free_list.
-
-=cut
-
-*/
-
-static void
-gc_gms_add_free_object(PARROT_INTERP, SHIM(Small_Object_Pool *pool),
- SHIM(PObj *to_add))
-{
- ASSERT_ARGS(gc_gms_add_free_object)
- Parrot_ex_throw_from_c_args(interp, NULL, 1, "gms abuse");
-}
-
-
-/*
-
-=item C<static void gc_gms_chain_objects(PARROT_INTERP, Small_Object_Pool *pool,
-Small_Object_Arena *new_arena, size_t real_size)>
-
-TODO: interfere custom_destroy and put these items into a
-separate white area, so that a sweep has just to run through these
-objects
-
-Header chain layout:
-- all objects are chained together forming a circular list
-- pool->marker is the "anchor" of the circle (shown twice below)
-
- 1) object allocation
-
- 1a) one bunch of allocated objects was consumed: the free ptr did
- hit the marker
-
- +===+---+---+---+---+---+===+
- I M I w | w | w | w | w I M I
- + +---+---+---+---+---+ +
- ^ ^
- | |
- white free == marker
-
- All these pointer ranges include the first element, but not the last one.
-
- [white ... free_list) is the list of all whites
-
- 1b) after allocating another bunch of objects
-
- +===+---+---+---+---+---+---+---+---+---+---+===+
- I M I w | w | w | w | w | f | f | f | f | f I M I
- + +---+---+---+---+---+---+---+---+---+---+ +
- ^ ^ ^
- | | |
- white free marker
-
-=cut
-
-*/
-
-static void
-gc_gms_chain_objects(PARROT_INTERP, ARGMOD(Small_Object_Pool *pool),
- ARGIN(Small_Object_Arena *new_arena), size_t real_size)
-{
- ASSERT_ARGS(gc_gms_chain_objects)
- Gc_gms_hdr *next, *prev;
- size_t i, n;
-
- Gc_gms_hdr *p = new_arena->start_objects;
- Gc_gms_hdr * const marker = &pool->marker;
-
- PARROT_ASSERT(pool->free_list == marker);
-
- /* update pool statistics */
- n = new_arena->total_objects;
- pool->total_objects += n;
- pool->num_free_objects += n;
- new_arena->used = n;
- /* initially all is pointing to marker */
- if (pool->white == marker) {
- /* set origin of first allocation */
- marker->next = p;
- p->prev = marker;
- pool->white = pool->white_fin = p;
- prev = marker;
- }
- else
- prev = marker->prev;
- /* chain objects together by inserting to the left of marker */
-
- /* point to end of last object */
- p = (void*) ((char*) p + real_size * n);
- next = marker;
- for (i = 0; i < n; ++i) {
- p = (void*) ((char *)p - real_size);
- p->next = next;
- next->prev = p;
-# ifndef NDEBUG
- p->gen = (void *)0xdeadbeef;
-# endif
- next = p;
- }
- PARROT_ASSERT(p == new_arena->start_objects);
- p->prev = prev;
- prev->next = p;
- pool->free_list = p;
- PARROT_ASSERT(p != marker);
-}
-
-/*
-
-=item C<static void gc_gms_alloc_objects(PARROT_INTERP, Small_Object_Pool
-*pool)>
-
-Allocate new objects for the given pool.
-
-=cut
-
-*/
-
-static void
-gc_gms_alloc_objects(PARROT_INTERP, ARGMOD(Small_Object_Pool *pool))
-{
- ASSERT_ARGS(gc_gms_alloc_objects)
- const size_t real_size = pool->object_size;
- Small_Object_Arena * const new_arena = mem_internal_allocate(sizeof (Small_Object_Arena));
- const size_t size = real_size * pool->objects_per_alloc;
-
- new_arena->start_objects = mem_internal_allocate(size);
- /* insert arena in list */
- Parrot_append_arena_in_pool(interp, pool, new_arena, size);
- /* create chain of objects, set free pointer */
- gc_gms_chain_objects(interp, pool, new_arena, real_size);
-
- /* allocate more next time */
- pool->objects_per_alloc = (UINTVAL) pool->objects_per_alloc *
- UNITS_PER_ALLOC_GROWTH_FACTOR;
- size = real_size * pool->objects_per_alloc;
- if (size > POOL_MAX_BYTES) {
- pool->objects_per_alloc = POOL_MAX_BYTES / real_size;
- }
-}
-
-/*
-
-=item C<static void gc_gms_more_objects(PARROT_INTERP, Small_Object_Pool *pool)>
-
-Run a GC cycle or allocate new objects for the given pool.
-
-=cut
-
-*/
-
-static void
-gc_gms_more_objects(PARROT_INTERP, ARGMOD(Small_Object_Pool *pool))
-{
- ASSERT_ARGS(gc_gms_more_objects)
- if (pool->skip)
- pool->skip = 0;
- else if (pool->last_Arena) {
- Parrot_gc_mark_and_sweep(interp, GC_trace_stack_FLAG);
- if (pool->num_free_objects <= pool->replenish_level)
- pool->skip = 1;
- }
-
- if (pool->free_list == &pool->marker) {
- (*pool->alloc_objects) (interp, pool);
- }
-}
-
-/*
-
-=item C<static PObj * gc_gms_get_free_object(PARROT_INTERP, Small_Object_Pool
-*pool)>
-
-Get a new object off the free_list in the given pool.
-
-2) object consumption
- the free ptr moves towards the marker
-
-=cut
-
-*/
-
-PARROT_WARN_UNUSED_RESULT
-PARROT_CANNOT_RETURN_NULL
-static PObj *
-gc_gms_get_free_object(PARROT_INTERP, ARGMOD(Small_Object_Pool *pool))
-{
- ASSERT_ARGS(gc_gms_get_free_object)
- PObj *ptr;
- Gc_gms_hdr *hdr;
-
- hdr = pool->free_list;
- if (hdr == &pool->marker)
- (pool->more_objects)(interp, pool);
-
- hdr = pool->free_list;
- pool->free_list = hdr->next;
- hdr->gen = pool->last_gen;
- ptr = GMSH_to_PObj(hdr);
- PObj_flags_SETTO((PObj*) ptr, 0);
- return ptr;
-}
-
-/*
-
-=back
-
-=head2 Generation handling functions
-
-overall header chain layout
-
- gen 0 gen 1 ... gen N
- marker [first last) [first last) ... [first last) marker
-
-The last (youngest) generation N holds these (pool) pointers:
-
- [ black ... gray ) during marking
- [ gray ... white ) during marking
- [ white ... free_list ) allocated items
- [ free_list ... marker ) free items
-
-The black, white, and generation ranges have additionally (TODO)
-*fin variants, which refer to PMCs that need destruction/finalization.
-These are always in front of the ranges to be processed first.
-
-=over 4
-
-=item C<static Gc_gms_gen * gc_gms_create_gen(PARROT_INTERP, Small_Object_Pool
-*pool, size_t gen_no)>
-
-Create a generation structure for the given generation number.
-
-=cut
-
-*/
-
-PARROT_MALLOC
-PARROT_CANNOT_RETURN_NULL
-static Gc_gms_gen *
-gc_gms_create_gen(PARROT_INTERP, ARGMOD(Small_Object_Pool *pool), size_t gen_no)
-{
- ASSERT_ARGS(gc_gms_create_gen)
- Gc_gms_gen * const gen = mem_sys_allocate(sizeof (*gen));
-
- gen->gen_no = gen_no;
- gen->pool = pool;
- gen->timely_destruct_obj_sofar = 0;
- gen->black_color = b_PObj_live_FLAG;
- gen->prev = NULL;
- gen->next = NULL;
- gen->first = gen->last = gen->fin = &pool->marker;
- gen->igp.first = NULL;
- gen->igp.last = NULL;
-
- return gen;
-}
-
-/*
-
-=item C<static void gc_gms_init_gen(PARROT_INTERP, Small_Object_Pool *pool)>
-
-Initalize the generation system by creating the first two generations.
-
-=cut
-
-*/
-
-static void
-gc_gms_init_gen(PARROT_INTERP, ARGMOD(Small_Object_Pool *pool))
-{
- ASSERT_ARGS(gc_gms_init_gen)
- Gc_gms_private *gmsp;
- /*
- * Generations are numbered beginning at zero
- * 0 ... oldest
- * 1 ... next oldest
- *
- * If a constant hash PMC refers to non-constant header buffers or
- * items, these items can be placed in the constant generation 0
- * XXX: OTOH this would work only for this GC subsystem.
- */
- pool->first_gen = gc_gms_create_gen(interp, pool, 0);
- pool->last_gen = pool->first_gen;
- gmsp = interp->arena_base->gc_private;
- gmsp->current_gen_no = 0;
-}
-
-/*
-
-=item C<static Gc_gms_gen * gc_gms_find_gen(PARROT_INTERP, const Gc_gms_hdr *h,
-UINTVAL gen_no)>
-
-Finds the generation associated with the given header and generation number.
-
-=cut
-
-*/
-
-PARROT_WARN_UNUSED_RESULT
-PARROT_CANNOT_RETURN_NULL
-static Gc_gms_gen *
-gc_gms_find_gen(PARROT_INTERP, ARGIN(const Gc_gms_hdr *h), UINTVAL gen_no)
-{
- ASSERT_ARGS(gc_gms_find_gen)
- Gc_gms_gen *gen;
- const Small_Object_Pool * const pool = h->gen->pool;
-
- PARROT_ASSERT(pool);
-
- for (gen = pool->first_gen; gen; gen = gen->next) {
- if (gen_no == gen->gen_no)
- return gen;
- if (gen->gen_no > gen_no) {
- gen = NULL;
- break;
- }
- }
- /* we could create generations lazily - not all object sizes
- * might exist in every generation
- *
- * TODO insert generation
- */
- Parrot_ex_throw_from_c_args(interp, NULL, 1,
- "generation %d not found for hdr %p", gen_no, h);
-}
-
-/*
-
-=item C<static void gc_gms_promote(PARROT_INTERP, Gc_gms_hdr *h, UINTVAL
-gen_no)>
-
-Promote the header to the specified generation.
-
-=cut
-
-*/
-
-static void
-gc_gms_promote(PARROT_INTERP, ARGIN(Gc_gms_hdr *h), UINTVAL gen_no)
-{
- ASSERT_ARGS(gc_gms_promote)
- Gc_gms_gen *gen;
- Gc_gms_hdr *prev, *next;
- Small_Object_Pool * const pool = h->gen->pool;
-
- /* unsnap from current generation */
- prev = h->prev;
- next = h->next;
- if (h == pool->white) {
- pool->white = next;
- }
- prev->next = next;
- next->prev = prev;
-
- /* locate generation pointer */
- gen = gc_gms_find_gen(interp, h, gen_no);
- PARROT_ASSERT(gen->last);
- PARROT_ASSERT(gen->first);
-
- /* TODO if it needs destroy put it in front */
- next = gen->last;
- if (h == next)
- next = gen->last = h->next;
- prev = next->prev;
- if (gen->first == &pool->marker)
- gen->first = h;
- h->prev = prev;
- h->next = next;
- prev->next = h;
- next->prev = h;
-# if GC_GMS_DEBUG
- gms_debug_verify(interp, pool, "promote");
-# endif
-}
-
-/*
-
-=item C<static void gc_gms_store_hdr_list(PARROT_INTERP, Gc_gms_hdr_list *l,
-Gc_gms_hdr *h)>
-
-Store the header into the header list.
-
-=cut
-
-*/
-
-static void
-gc_gms_store_hdr_list(PARROT_INTERP, ARGMOD(Gc_gms_hdr_list *l), ARGIN(Gc_gms_hdr *h))
-{
- ASSERT_ARGS(gc_gms_store_hdr_list)
- Gc_gms_hdr_store * const s = l->last;
-
- /* if it's not created or if it's full allocate new store */
- if (!s || s->ptr == &s->store[GC_GMS_STORE_SIZE]) {
- s = mem_sys_allocate(sizeof (Gc_gms_hdr_store));
- s->ptr = &s->store[0];
- s->next = NULL;
- /* chain new store to old one */
- if (l->first) {
- PARROT_ASSERT(l->last);
- l->last->next = s;
- }
- else {
- l->first = s;
- }
- l->last = s;
- }
- *(s->ptr)++ = h;
-}
-
-/*
-
-=item C<static void gc_gms_clear_hdr_list(PARROT_INTERP, Gc_gms_hdr_list *l)>
-
-Clear the header list and free it's memory to the OS.
-
-=cut
-
-*/
-
-static void
-gc_gms_clear_hdr_list(PARROT_INTERP, ARGMOD(Gc_gms_hdr_list *l))
-{
- ASSERT_ARGS(gc_gms_clear_hdr_list)
- Gc_gms_hdr_store *s, *next;
-
- for (s = l->first; s; s = next) {
- next = s->next;
- mem_sys_free(s);
- }
- l->first = l->last = NULL;
-}
-
-/*
-
-=item C<static void gc_gms_store_igp(PARROT_INTERP, Gc_gms_hdr *h)>
-
-Add the header to the inter-generational pointer list of it's generation.
-
-=cut
-
-*/
-
-static void
-gc_gms_store_igp(PARROT_INTERP, ARGIN(Gc_gms_hdr *h))
-{
- ASSERT_ARGS(gc_gms_store_igp)
- Gc_gms_gen * const gen = h->gen;
- Gc_gms_hdr_list * const igp = &gen->igp;
-
- gc_gms_store_hdr_list(interp, igp, h);
-}
-
-/*
-
-=item C<static void gc_gms_clear_igp(PARROT_INTERP, Gc_gms_gen *gen)>
-
-Clear the inter-generational pointer list of the given generation.
-
-=cut
-
-*/
-
-static void
-gc_gms_clear_igp(PARROT_INTERP, ARGIN(Gc_gms_gen *gen))
-{
- ASSERT_ARGS(gc_gms_clear_igp)
- Gc_gms_hdr_list * const igp = &gen->igp;
-
- gc_gms_clear_hdr_list(interp, igp);
-}
-
-/*
-
-=item C<void parrot_gc_gms_wb(PARROT_INTERP, PMC *agg, void *old, void *_new)>
-
-Called by the write barrier. The aggregate belongs to an older generation
-then the I<new> value written into it. Put the header of the new value
-onto the IGP list for the current generation, if it contains pointers
-to other items, and promote it to the old generation.
-
-=cut
-
-*/
-
-void
-parrot_gc_gms_wb(PARROT_INTERP, ARGIN(PMC *agg), ARGIN(void *old),
- ARGIN(void *_new))
-{
- ASSERT_ARGS(parrot_gc_gms_wb)
- Gc_gms_hdr * const nh = PObj_to_GMSH(_new);
- Gc_gms_hdr * const ah = PObj_to_GMSH(agg);
-
- /* if this may be an aggregate store it in IGP list, thus making
- * it a possible root for this generation
- */
- if (PObj_is_PMC_TEST((PObj *)_new))
- gc_gms_store_igp(interp, nh);
-
- /* promote RHS to old generation of aggregate */
- gc_gms_promote(interp, nh, ah->gen->gen_no);
-
- /*
- * TODO check old - its overwritten, increment overwrite count,
- * if it's an aggregate all contents *may* be dead now, so
- * increment overwrite count by elements
- */
-}
-
-/*
-
-=item C<void parrot_gc_gms_wb_key(PARROT_INTERP, PMC *agg, void *old, void
-*old_key, void *_new, void *new_key)>
-
-=cut
-
-*/
-
-void
-parrot_gc_gms_wb_key(PARROT_INTERP, ARGIN(PMC *agg), ARGIN(void *old),
- ARGIN(void *old_key), ARGIN(void *_new), ARGIN(void *new_key))
-{
- ASSERT_ARGS(parrot_gc_gms_wb_key)
- Gc_gms_hdr *nh, *ah;
-
- /* handle hash values */
- parrot_gc_gms_wb(interp, agg, old, _new);
-
- /* if hash keys are PObj* then promote new key too */
-
- /* TODO: check if key is a PObj */
-
- nh = PObj_to_GMSH(new_key);
- ah = PObj_to_GMSH(agg);
-
- /* promote new key to old generation of aggregate */
- gc_gms_promote(interp, nh, ah->gen->gen_no);
-}
-
-typedef struct Gc_gms_plan {
- int merge_gen;
- int gen_no;
-} Gc_gms_plan;
-
-/*
-
-=item C<static void gc_gms_merge_gen(PARROT_INTERP, Small_Object_Pool *pool, int
-flag, Gc_gms_plan *plan)>
-
-Merge black pointers to the previous generation, and update the free list.
-
-=cut
-
-*/
-
-static void
-gc_gms_merge_gen(PARROT_INTERP, ARGMOD(Small_Object_Pool *pool),
- int flag, SHIM(Gc_gms_plan *plan))
-{
- ASSERT_ARGS(gc_gms_merge_gen)
- Gc_gms_hdr *h;
-
- /* run through the blacks and set their generation pointer
- * to the previous generation
- */
- Gc_gms_gen * const gen = pool->last_gen;
- Gc_gms_gen * const prev = gen->prev;
-
- for (h = pool->black; h != pool->free_list; h = h->next) {
- h->gen = prev;
- /* TODO update statistics */
- /* TODO merge hdrs that need finalization */
- }
- prev->last = pool->free_list;
- /*
- * clear IGP for gen
- */
- gc_gms_clear_igp(interp, gen);
-}
-
-/*
-
-=item C<static void gc_gms_use_gen(PARROT_INTERP, Small_Object_Pool *pool, int
-flag, const Gc_gms_plan *plan)>
-
-Specify what generation to use by default.
-
-=cut
-
-*/
-
-static void
-gc_gms_use_gen(PARROT_INTERP, ARGMOD(Small_Object_Pool *pool),
- int flag, ARGIN(const Gc_gms_plan *plan))
-{
- ASSERT_ARGS(gc_gms_use_gen)
- Gc_gms_gen *gen, *prev;
- UINTVAL next_gen;
-
- /* set hdr pointers in last generation */
- gen = pool->last_gen;
- gen->first = pool->black;
- gen->fin = pool->black_fin;
- gen->last = pool->free_list;
-
- /* create and append a new generation */
- next_gen = plan->gen_no + 1;
- gen = gc_gms_create_gen(interp, pool, next_gen);
- prev = pool->last_gen;
- pool->last_gen = gen;
- prev->next = gen;
- gen->prev = prev;
-
- /* set generation in interpreter */
- interp->gc_generation = next_gen;
-}
-
-/*
-
-=item C<static int set_gen_cb(PARROT_INTERP, Small_Object_Pool *pool, int flag,
-void *arg)>
-
-Set the generation to use, merging if necessary.
-
-=cut
-
-*/
-
-PARROT_WARN_UNUSED_RESULT
-static int
-set_gen_cb(PARROT_INTERP, ARGIN(Small_Object_Pool *pool), int flag, ARGIN(void *arg))
-{
- ASSERT_ARGS(set_gen_cb)
- Gc_gms_plan * const plan = (Gc_gms_plan *)arg;
-
- if (plan->merge_gen)
- gc_gms_merge_gen(interp, pool, flag, plan);
- else
- gc_gms_use_gen(interp, pool, flag, plan);
- return 0;
-}
-
-/*
-
-=item C<static void gc_gms_set_gen(PARROT_INTERP)>
-
-Setup the generations, deciding what to do based on the plan and moving
-headers around as necessary.
-
-=cut
-
-*/
-
-static void
-gc_gms_set_gen(PARROT_INTERP)
-{
- ASSERT_ARGS(gc_gms_set_gen)
- Gc_gms_plan plan;
- Gc_gms_private *gmsp;
- /*
- * there are these basic plans
- * 1) Use the black as the next old generation
- * 2) Merge the blacks to the existing older generation
- * The plan to use depends on the interpreter, specifically, if
- * we are doing a lazy run, entering a new scope, or what not.
- * 3) If we are leaving a scope (denoted by a lazy GC run
- * and we had created one or more generations in this scope
- * go back by resetting the generation number to the outer
- * scope's generation
- * 4) Check the overwrite count of older generations. If there is
- * a significant percentage of possibly dead objects, scan
- * older generations too.
- *
- * TODO only 1 and 2 done for now
- * 3) and 4) need to reset live flags of the previous generation(s)
- * or better use the per-generation black_color for marking
- */
- gmsp = interp->arena_base->gc_private;
- plan.merge_gen = 0;
- plan.gen_no = gmsp->current_gen_no;
- if (gmsp->current_gen_no > 0)
- plan.merge_gen = 1;
- else
- gmsp->current_gen_no = 1;
- header_pools_iterate_callback(interp, POOL_ALL, &plan, set_gen_cb);
-}
-
-/*
-
-=back
-
-=head2 Marking functions
-
-Header chain layout
-
-Init: gray := black := white
-
- 3) marking the root set
-
- 3a) the white 'h' is to be set to gray to be scanned for children
-
- +---+---+---+---+---+---+-> +---+->
- | b | b | g | g | g | w | h |
- +---+---+---+---+---+---+ <-+---+
- ^ ^ ^
- | | |
- black gray white
-
- 3b) DFS if 'h' needs timely destruction
-
- +---+---+---+---+---+---+---+->
- | b | b | h | g | g | g | w
- +---+---+---+---+---+---+---+
- ^ ^ ^
- | | |
- black gray white
-
-
- 3c) BFS in the normal case
-
- +---+---+---+---+---+---+---+->
- | b | b | g | g | g | h | w
- +---+---+---+---+---+---+---+
- ^ ^ ^
- | | |
- black gray white
-
- 3d) the white is a scalar and immediately blackened
-
-
- +---+---+---+---+---+---+---+->
- | b | b | h | g | g | g | w
- +---+---+---+---+---+---+---+
- ^ ^ ^
- | | |
- black gray white
-
- 3e) blacken the gray 'h' during trace_children
-
- +---+---+---+---+---+---+---+->
- | b | b | h | g | g | g | w
- +---+---+---+---+---+---+---+
- ^ ^ ^
- | | |
- black gray white
-
-
- +---+---+---+---+---+---+---+->
- | b | b | h | g | g | g | w
- +---+---+---+---+---+---+---+
- ^ ^ ^
- | | |
- black gray white
-
-=over 4
-
-=cut
-
-*/
-
-/*
-
-=item C<static void gc_gms_setto_gray(PARROT_INTERP, Gc_gms_hdr *h, int
-priority)>
-
-Set the white header C<h> to gray.
-
-=cut
-
-*/
-
-static void
-gc_gms_setto_gray(PARROT_INTERP, ARGIN(Gc_gms_hdr *h), int priority)
-{
- ASSERT_ARGS(gc_gms_setto_gray)
- Small_Object_Pool * const pool = h->gen->pool;
- /*
- * TODO high_priority like in src/gc/api.c
- */
- /*
- * if the white is adjacent to gray, move pointer
- */
- if (pool->white == h && (!priority || pool->white == pool->gray))
- pool->white = h->next;
- else {
- Gc_gms_hdr *next, *prev;
-
- prev = h->prev;
- next = h->next;
- if (h == pool->white)
- pool->white = next;
- prev->next = next;
- next->prev = prev;
-
- if (priority) {
- /* insert at gray */
- next = pool->gray; /* DFS */
- pool->gray = h;
- }
- else {
- /* insert before white */
- next = pool->white; /* BFS */
- }
- prev = next->prev;
- h->next = next;
- h->prev = prev;
- next->prev = h;
- prev->next = h;
-
- /* if there wasn't any gray or black before */
- if (pool->gray == pool->white) {
- pool->gray = h;
- if (pool->black == pool->white) {
- pool->black = h;
- }
- }
- }
- PARROT_ASSERT(h != pool->white);
- /* verify all these pointer moves */
-# if GC_GMS_DEBUG
- gms_debug_verify(interp, pool, "to_gray");
-# endif
-}
-
-/*
-
-=item C<static void gc_gms_setto_black(PARROT_INTERP, Gc_gms_hdr *h, int
-priority)>
-
-Set the white header C<h> to black.
-
-=cut
-
-*/
-
-static void
-gc_gms_setto_black(PARROT_INTERP, ARGMOD(Gc_gms_hdr *h), int priority)
-{
- ASSERT_ARGS(gc_gms_setto_black)
- Small_Object_Pool * const pool = h->gen->pool;
-
- /*
- * TODO high_priority like src/gc/api.c
- * TODO if h needs destructions insert in front of chain
- */
- /*
- * if the white is adjacent to black, move pointer
- */
- if (pool->black == h) {
- PARROT_ASSERT(pool->gray == h);
- PARROT_ASSERT(pool->white == h);
- pool->white = h->next;
- pool->gray = h->next;
- }
- else {
- Gc_gms_hdr *next, *prev;
-
- prev = h->prev;
- next = h->next;
- if (h == pool->white) {
- pool->white = next;
- if (h == pool->gray)
- pool->gray = next;
- }
- prev->next = next;
- next->prev = prev;
-
- /* insert before gray */
- next = pool->gray;
- prev = next->prev;
- h->next = next;
- h->prev = prev;
- next->prev = h;
- prev->next = h;
- if (pool->black == pool->gray) {
- pool->black = h;
- }
- }
- PARROT_ASSERT(h != pool->white);
- PARROT_ASSERT(h != pool->gray);
-# if GC_GMS_DEBUG
- gms_debug_verify(interp, pool, "to_black");
-# endif
-}
-
-/*
-
-=item C<void parrot_gc_gms_Parrot_gc_mark_PObj_alive(PARROT_INTERP, PObj *obj)>
-
-Set the object live - called by the Parrot_gc_mark_PObj_alive macro
-
-=cut
-
-*/
-
-PARROT_EXPORT
-void
-parrot_gc_gms_Parrot_gc_mark_PObj_alive(PARROT_INTERP, ARGMOD(PObj *obj))
-{
- ASSERT_ARGS(parrot_gc_gms_Parrot_gc_mark_PObj_alive)
- Gc_gms_hdr *h;
- int priority;
-
- PObj_live_SET(obj);
- priority = PObj_needs_early_gc_TEST(obj);
- if (priority)
- ++interp->arena_base->num_early_PMCs_seen;
- h = PObj_to_GMSH(obj);
- /* unsnap it from white, put it into gray or black */
- if (PObj_is_PMC_TEST(obj))
- gc_gms_setto_gray(interp, h, priority);
- else
- gc_gms_setto_black(interp, h, priority);
-}
-
-/*
-
-=item C<static int init_mark_cb(PARROT_INTERP, Small_Object_Pool *pool, int
-flag, void *arg)>
-
-Initialization callback, initialize all the pointers.
-
-=cut
-
-*/
-
-static int
-init_mark_cb(PARROT_INTERP, ARGMOD(Small_Object_Pool *pool), int flag, ARGIN(void *arg))
-{
- ASSERT_ARGS(init_mark_cb)
- pool->gray = pool->black = pool->black_fin = pool->white;
-# if GC_GMS_DEBUG
- gms_debug_verify(interp, pool, "init_mark");
-# endif
- return 0;
-}
-
-/*
-
-=item C<static void gc_gms_init_mark(PARROT_INTERP)>
-
-Initialize the mark phase of GC.
-
-=cut
-
-*/
-
-static void
-gc_gms_init_mark(PARROT_INTERP)
-{
- ASSERT_ARGS(gc_gms_init_mark)
- Arenas * const arena_base = interp->arena_base;
-
- arena_base->gc_trace_ptr = NULL;
- arena_base->gc_mark_start = NULL;
- arena_base->num_early_PMCs_seen = 0;
- arena_base->num_extended_PMCs = 0;
-
- header_pools_iterate_callback(interp, POOL_ALL, 0, init_mark_cb);
-}
-
-/*
-
-=item C<static int trace_igp_cb(PARROT_INTERP, Small_Object_Pool *pool, int
-flag, void *arg)>
-
-Trace through the IGP of the pool to find alive items that are pointing
-to items in other generations.
-
-=cut
-
-*/
-
-static int
-trace_igp_cb(PARROT_INTERP, ARGIN(Small_Object_Pool *pool), int flag, SHIM(void *arg))
-{
- ASSERT_ARGS(trace_igp_cb)
- Gc_gms_hdr_store *s;
- Gc_gms_gen * const gen = pool->last_gen;
- Gc_gms_hdr_list * const igp = &gen->igp;
-
- for (s = igp->first; s; s = s->next) {
- const Gc_gms_hdr **p;
- for (p = s->store; p < s->ptr; ++p) {
- Gc_gms_hdr * const h = *p;
- Parrot_gc_mark_PObj_alive(interp, GMSH_to_PObj(h));
- }
- }
- return 0;
-}
-
-/*
-
-=item C<static int gc_gms_trace_root(PARROT_INTERP, int trace_stack)>
-
-Trace the root set. If C<trace_stack> is true, trace system areas.
-
-=cut
-
-*/
-
-static int
-gc_gms_trace_root(PARROT_INTERP, int trace_stack)
-{
- ASSERT_ARGS(gc_gms_trace_root)
- const int ret = Parrot_gc_trace_root(interp, trace_stack);
-
- if (ret == 0)
- return 0;
- header_pools_iterate_callback(interp, POOL_ALL, 0, trace_igp_cb);
- return ret;
-}
-
-/*
-
-=item C<static int trace_children_cb(PARROT_INTERP, Small_Object_Pool *pool, int
-flag, void *arg)>
-
-Trace through child objects
-
-=cut
-
-*/
-
-static int
-trace_children_cb(PARROT_INTERP, ARGIN(Small_Object_Pool *pool), int flag, SHIM(void *arg))
-{
- ASSERT_ARGS(trace_children_cb)
- Arenas * const arena_base = interp->arena_base;
- const int lazy_gc = arena_base->lazy_gc;
- Gc_gms_hdr *h;
-
- for (h = pool->gray; h != pool->white;) {
- PMC * const current = (PMC*)GMSH_to_PObj(h);
- UINTVAL bits;
-
- if (lazy_gc && arena_base->num_early_PMCs_seen >=
- arena_base->num_early_gc_PMCs) {
- return 1;
- }
- /* TODO propagate flag in Parrot_gc_mark_PObj_alive */
- arena_base->gc_trace_ptr = current;
- if (!PObj_needs_early_gc_TEST(current))
- PObj_high_priority_gc_CLEAR(current);
-
- /* mark children */
- if (PObj_custom_mark_TEST(current)) {
- VTABLE_mark(interp, current);
- }
- if (h != pool->gray) {
- /* if a gray was inserted DFS, it is next */
- h = pool->gray;
- }
- else {
- h = h->next;
- pool->gray = h;
- }
- }
- return 0;
-}
-
-/*
-
-=item C<static int gc_gms_trace_children(PARROT_INTERP)>
-
-Traverse gray objects: mark and blacken. Returns 0 if the trace was aborted
-lazily.
-
-=cut
-
-*/
-
-static int
-gc_gms_trace_children(PARROT_INTERP)
-{
- ASSERT_ARGS(gc_gms_trace_children)
- return !header_pools_iterate_callback(interp, POOL_PMC, 0,
- trace_children_cb);
-}
-
-/*
-
-=item C<static int sweep_cb_pmc(PARROT_INTERP, Small_Object_Pool *pool, int
-flag, void *arg)>
-
-move everything from white up to the free_list to the free_list
-scan for active destroy objects
-TODO put these in front of the pool at pool->white_fin
-
-=cut
-
-*/
-
-static int
-sweep_cb_pmc(PARROT_INTERP, ARGIN(Small_Object_Pool *pool), int flag, SHIM(void *arg))
-{
- ASSERT_ARGS(sweep_cb_pmc)
- Gc_gms_hdr *h;
- Arenas * const arena_base = interp->arena_base;
-
- /* TODO object stats */
-
- for (h = pool->white; h != pool->free_list; h = h->next) {
- PMC * const obj = (PMC*)GMSH_to_PObj(h);
- if (PObj_needs_early_gc_TEST(obj))
- --arena_base->num_early_gc_PMCs;
- if (PObj_custom_destroy_TEST(obj))
- VTABLE_destroy(interp, (PMC *)obj);
- }
- pool->free_list = pool->white;
- return 0;
-}
-
-/*
-
-=item C<static int sweep_cb_buf(PARROT_INTERP, Small_Object_Pool *pool, int
-flag, void *arg)>
-
-Sweep the buffer pool, freeing things that are dead.
-
-=cut
-
-*/
-
-static int
-sweep_cb_buf(PARROT_INTERP, ARGMOD(Small_Object_Pool *pool), int flag, SHIM(void *arg))
-{
- ASSERT_ARGS(sweep_cb_buf)
- Gc_gms_hdr *h;
-
- /* TODO object stats */
-
- for (h = pool->white; h != pool->free_list; h = h->next) {
- PObj * const obj = GMSH_to_PObj(h);
- /*
- * this is ugly, we still have to sweep all buffers
- */
- if (PObj_sysmem_TEST(obj) && PObj_bufstart(obj)) {
- /* has sysmem allocated, e.g. Parrot_str_pin */
- mem_sys_free(PObj_bufstart(obj));
- PObj_bufstart(obj) = NULL;
- PObj_buflen(obj) = 0;
- }
- else {
-# ifdef GC_IS_MALLOC
- /* free allocated space at (int*)bufstart - 1,
- * but not if it is used COW or external
- */
- if (PObj_bufstart(obj) &&
- !PObj_is_external_or_free_TESTALL(obj)) {
- if (PObj_COW_TEST(obj)) {
- INTVAL *refcount = PObj_bufrefcountptr(obj);
-
- if (!--(*refcount))
- free(refcount); /* the actual bufstart */
- }
- else
- free(PObj_bufrefcountptr(obj));
- }
-# else
- /*
- * XXX Jarkko did report that on irix pool->mem_pool
- * was NULL, which really shouldn't happen
- */
- if (pool->mem_pool) {
- if (!PObj_COW_TEST(obj)) {
- ((Memory_Pool *)
- pool->mem_pool)->guaranteed_reclaimable +=
- PObj_buflen(obj);
- }
- ((Memory_Pool *)
- pool->mem_pool)->possibly_reclaimable +=
- PObj_buflen(obj);
- }
-# endif
- PObj_buflen(obj) = 0;
- }
- }
- pool->free_list = pool->white;
- return 0;
-}
-
-/*
-
-=item C<static void gc_gms_sweep(PARROT_INTERP)>
-
-Free unused resources, put white objects onto free_list.
-
-=cut
-
-*/
-
-static void
-gc_gms_sweep(PARROT_INTERP)
-{
- ASSERT_ARGS(gc_gms_sweep)
- header_pools_iterate_callback(interp, POOL_PMC, 0, sweep_cb_pmc);
- header_pools_iterate_callback(interp, POOL_BUFFER, 0, sweep_cb_buf);
-}
-
-/*
-
-=item C<static int end_cycle_cb(PARROT_INTERP, Small_Object_Pool *pool, int
-flag, void *arg)>
-
-Reset the pointers in the pool at the end of the cycle.
-
-=cut
-
-*/
-
-static int
-end_cycle_cb(PARROT_INTERP, ARGMOD(Small_Object_Pool *pool), int flag, SHIM(void *arg))
-{
- ASSERT_ARGS(end_cycle_cb)
- Gc_gms_hdr *h;
- /*
- * clear live flags
- * TODO just swap black and white
- */
- if (!pool->black || pool->black == &pool->marker)
- return 0;
- for (h = pool->black; h != pool->white; h = h->next)
- PObj_live_CLEAR(GMSH_to_PObj(h));
- pool->black = pool->black_fin = pool->gray = pool->white;
- return 0;
-}
-
-/*
-
-=item C<static void gc_gms_end_cycle(PARROT_INTERP)>
-
-End the cycle, resetting pointers in all pools.
-
-=cut
-
-*/
-
-static void
-gc_gms_end_cycle(PARROT_INTERP)
-{
- ASSERT_ARGS(gc_gms_end_cycle)
- header_pools_iterate_callback(interp, POOL_ALL, 0, end_cycle_cb);
-}
-
-/*
-
-=back
-
-=head2 Interface function main entry
-
-=over 4
-
-=item C<static void parrot_gc_gms_run(PARROT_INTERP, UINTVAL flags)>
-
-Interface to C<Parrot_gc_mark_and_sweep>. C<flags> is one of:
-
- GC_lazy_FLAG ... timely destruction
- GC_finish_FLAG ... run a final sweep to destruct objects at
- interpreter shutdown
-
-=cut
-
-*/
-
-static void
-parrot_gc_gms_run(PARROT_INTERP, UINTVAL flags)
-{
- ASSERT_ARGS(parrot_gc_gms_run)
- Arenas * const arena_base = interp->arena_base;
- Gc_gms_private *g_gms;
-
- if (arena_base->gc_mark_block_level) {
- return;
- }
- ++arena_base->gc_mark_block_level;
- g_gms = arena_base->gc_private;
- if (flags & GC_finish_FLAG) {
- Small_Object_Pool * const pool = arena_base->pmc_pool;
-
- pool->white = pool->marker.next;
- /* XXX need to sweep over objects that have finalizers only */
- header_pools_iterate_callback(interp, POOL_PMC, 0, sweep_cb_pmc);
- gc_gms_end_cycle(interp);
- --arena_base->gc_mark_block_level;
- return;
- }
-
- /* normal or lazy mark run */
- arena_base->gc_mark_runs++;
- arena_base->lazy_gc = (flags & GC_lazy_FLAG);
- gc_gms_init_mark(interp);
- if (gc_gms_trace_root(interp, !arena_base->lazy_gc) &&
- gc_gms_trace_children(interp)) {
- gc_gms_sweep(interp);
- gc_gms_set_gen(interp);
- }
- else {
- /*
- * successful lazy mark run
- */
- ++arena_base->gc_lazy_mark_runs;
- }
- gc_gms_end_cycle(interp);
- --arena_base->gc_mark_block_level;
-}
-
-/*
-
-=item C<static void gms_debug_verify(PARROT_INTERP, Small_Object_Pool *pool,
-const char *action)>
-
-Debug function, check that everything is right.
-
-=cut
-
-*/
-
-# if GC_GMS_DEBUG
-static void
-gms_debug_verify(PARROT_INTERP, ARGMOD(Small_Object_Pool *pool), ARGIN(const char *action))
-{
- ASSERT_ARGS(gms_debug_verify)
- Gc_gms_hdr *h;
- int bf, gf, wf, ff;
- size_t i;
-
- const size_t n = pool->total_objects;
-
- bf = gf = wf = ff = 0;
-
-
- for (i = 0, h = &pool->marker; i <= n + 10; ++i) {
- if (i && h == &pool->marker)
- break;
- if (h == pool->black)
- bf++;
- if (h == pool->gray)
- gf++;
- if (h == pool->white)
- wf++;
- if (h == pool->free_list)
- ff++;
- h = h->next;
- }
- if (i != n + 1)
- fprintf(stderr, "gms_verify %s: chain corrupt %u objs %u total\n",
- action, i, n);
- if (bf != 1)
- fprintf(stderr, "gms_verify %s: found %u blacks\n", action, bf);
- if (gf != 1)
- fprintf(stderr, "gms_verify %s: found %u grays\n", action, gf);
- if (wf != 1)
- fprintf(stderr, "gms_verify %s: found %u whites\n", action, wf);
- if (ff != 1)
- fprintf(stderr, "gms_verify %s: found %u frees\n", action, ff);
-}
-
-
-# endif /* GC_GMS_DEBUG */
-
-#endif /* PARROT_GC_GMS */
-
-/*
-
-=back
-
-=head1 SEE ALSO
-
-F<src/gc/api.c>, F<include/parrot/gc_api.h>, F<include/parrot/pobj.h>,
-F<src/gc/incremental_ms.c>
-
-=head1 HISTORY
-
-Initial version by leo (2005.01.12 - 2005.01.30)
-
-=cut
-
-*/
-
-
-/*
- * Local variables:
- * c-file-style: "parrot"
- * End:
- * vim: expandtab shiftwidth=4:
- */
Deleted: branches/kill_jit/src/gc/incremental_ms.c
==============================================================================
--- branches/kill_jit/src/gc/incremental_ms.c Wed Sep 16 21:22:58 2009 (r41308)
+++ /dev/null 00:00:00 1970 (deleted)
@@ -1,1150 +0,0 @@
-/*
-Copyright (C) 2001-2009, Parrot Foundation.
-$Id$
-
-=head1 NAME
-
-src/gc/incremental_ms.c - Incremental mark and sweep garbage collection
-
-=head1 DESCRIPTION
-
-The following comments describe a new garbage collection scheme for
-Parrot.
-
-The scheme of this algorithm is described in the literature with these
-keywords:
-
- - non-copying, mark & sweep
- - incremental
- - realtime
- - incremental update with write barrier
-
-Further we might try this optimization
-
- - treadmill optimization or
- - implict reclamation
-
-=head1 Drawbacks of the current mark and sweep collector.
-
- * can take arbitrary time to complete (1s for 1 Meg objects)
- * can't be used in multi-threaded Parrot
- * works fast for plain (non-aggregate) objects but suffers badly
- for nested aggregates or HLL objects
- * the sweep phase takes time proportional to the allocated storage
-
-=head1 INCREMENTAL GARBAGE COLLECTION
-
-=head2 Terms
-
-=over 4
-
-=item object
-
-An item like a buffer header or a PMC which is managed by Parrot's
-dynamic memory system.
-
-=item aggregate
-
-An object that possibly holds references to other objects. For example
-an array, hash, or reference PMC.
-
-=item tri-color marking
-
-All objects have one of three colors: white, grey, or black.
-
-At the beginning of a GC mark run all objects are white (not yet visited).
-During marking objects are greyed (visited - found alive), but their
-contents isn't yet scanned. A fully scanned grey object gets finally
-colored black. It will not again be rescanned in this run.
-
-Only aggregates can be grey, non-containers are blackened immediately.
-
-Objects on the free-list are sometimes denoted having the color off-white
-or ecru.
-
-=item GC
-
-In Parrot tree the copying garbage collector that recycles string and
-buffer memory. Configure.pl has a switch to use a malloc library instead,
-which makes string and buffer memory non-moving.
-
-=item collector
-
-The reclamation system.
-
-=item mutator
-
-The normal operation of the program which may or may not change the
-collectors view of objects.
-
-=item incremental
-
-Garbage collection and normal program operation is interleaved. This
-guarantees short and bounded pause times. Garbage collection doesn't
-significantly interrupt program execution, collector and mutator are
-running pseudo-parallel.
-
-=item root set
-
-All structures in the interpreter that might point to objects. E.g.
-stacks, globals, and of course the registers. All objects the
-interpreter works with, are directly or indirectly reachable starting
-from the root set.
-
-=item the tri-color invariant
-
-At no time a black object may reference a white one directly. Actually
-this is the strong incarnation of the invariant - all paths from black
-objects to white objects lead over at least one grey object.
-
-The weak tri-color invariant is: there is at least one such path to a
-white object, so that it's reachable.
-
-The strong invariant is the basic idea of mark and sweep too. But as the
-mutator isn't running during mark phase, the invariant is never violated.
-
-Due to this invariant, after the root set has been marked and when all
-greyed objects are marked (blackened), the white objects have to be
-dead.
-
-=item paint it black
-
-Or, which color do new objects have?
-
-Actually this should be tunable. Or it depends. If objects are born
-white and die immediately, they get collected in the same GC cycle. OTOH
-when these objects are stored into an existing (black) array, we have to
-do more work to keep the tri-color invariant valid.
-
-Anyway, when allocating new objects white, the collector must run more
-often or must do more work per increment to make the algorithm stop
-somewhen.
-
-=item write barrier
-
-To keep the tri-color invariant valid all pointer stores into black
-objects have to be tracked. If a white object would be stored into a
-black array, and this object isn't refered to by another object it would
-get collected. The write barrier greys the white object, so that it get
-scanned later or alternatively greys the aggregate for a rescan. The latter
-can be better, if a sequence of such stores would happen.
-
-=back
-
-=head2 Data structure overview
-
-The incremental mark and sweep collector has an additional structure in
-the arena_base that keeps track of the collector's state. Pool and arena
-structures are unchanged. Only the allocation of new arena blocks is done
-much more fine grained in e.g. 8K blocks.
-
-=head2 Implicit reclamation (optional)
-
-=over 4
-
-=item from-space
-
-The graph of all objects found live during the last collection.
-
-=item to-space
-
-The work area of the collector. During marking live objects are "moved"
-from the from-space into the to-space. This is the same as the text_for_GC
-list used in src/gc/api.c. The to-space is initially empty. During marking
-it gets greyed and finally all reachable objects are black.
-
-=item free-list
-
-New objects are allocated from the free-list. The free-list is adjacent
-to the to-space. Allocating a new objects thus means, moving the free
-pointer one word forward and paint the new object black.
-
-=back
-
-All objects get two additional pointers (forward, backward) and are
-arranged like in this scheme:
-
-
- <-- allocation direction marking -->
- | |
- [w] <--> [w] <--> [b] <--> [b] <--> [g] <--> [g] <--> [w] <-> [w]
-
- ^ ^ ^ ^
- | | | |
- free-list-ptr to-space scan-pointer from-space
-
-Objects get "moved" during collection by rearranging the doubly-linked
-object pointers. At the end of a mark run (when the last grey object is
-blackened), the from-space and the free-list are merged serving
-as the new free-list of the next GC cycle. This operation is just a few
-pointer manipulations that replaces the sweep phase of a mark and sweep
-collector.
-
-=head2 Phases of operation
-
-=over 4
-
-=item a) initialization
-
-After interpreter creation the GC system is initialized by marking
-parts of the root set (globals, internal structures).
-
-=item b) program operation
-
-For each bunch of allocated objects (A) the collector does k.A work, for
-some constant k > 1. As new objects are allocated black the number of
-whites is reduced steadily. This means that the throttle factor k could
-be less then one too, but this could highly increase average memory usage.
-
-To keep the memory usage limited k > 1 must hold.
-
-=item c) near the end of a mark phase
-
-The rest of the root set is scanned, i.e. the registers. By deferring
-scanning of registers all temporaries that might have exist somewhen
-just stay unscanned - they will be collected in this mark phase, if
-we allocate new objects white or in the next mark phase.
-
-=item d) finishing a mark phase
-
-The current sweep of the whole arena is done, or with implicit reclamation:
-
-Garbage gets appended to the free-list by merging the unscanned
-from-space with the free-list, these objects are all considered white.
-All other items are in the to-space and are black. These objects
-constitute the from-space of the new collection cycle.
-
-Now he meaning of the black bit is reversed effectively setting the new
-from-space to white.
-
-The next mark phase is initialized in one step a) and the new cycle starts.
-
-Alternatively the mutator could run and allocate objects for some time,
-without starting the collector again, if there are plenty of free objects on
-all free-lists.
-
-=item e) collect buffer memory
-
-Finally, we might trigger a collect run on string and buffer memory if
-there is an impending shortage of resources. While the copying compactor
-is rather independent of the collector that cleans object headers, it's
-more efficient to collect buffer memory when the live information is
-accurate. This avoids copying of dead buffer memory.
-
-=back
-
-=head2 Comparison with our current mark and sweep collector
-
- MS ... mark and sweep (stop-the-world)
- IMS ... incremental mark and sweep
- IMIR .. incremental mark implicit reclamation
-
- MS IMS IMIR
- ------------------------------------------------------------------------
- operation stop-the-world incremental incremental
- time per mark phase unbounded bounded bounded
- size overhead 1 word 1 word 2 words
- time overhead O(2*live + dead) O(2*live + dead) O(live) 2)
-
-Notes:
-
- 2) it should be possible to mark containers at once by using the
- information of the from-space pointers and tracking changes
- to the aggregate.
-
-=head2 Implementation details and unsorted remarks
-
-=over 4
-
-=item the object graph
-
-The MS and IMS scheme use the next_for_GC pointer for keeping track of
-references. This interferes with the freeze functionality, which can use
-the same pointer to keep track of visited objects.
-
-IMIR has a dedicated pointer pair to build the object graph.
-
-=item Greying objects
-
-Greying objects is done depth-first. This has much better cache locality
-then visiting an object again much later. In the picture above this means
-that grey objects are inserted at the left end of the mark chain immediately
-to the right of the object that gets blackened.
-
-=item big aggregates
-
-Greying has to be done in increments. Big aggregates can't have a mark
-vtable that could run arbitrarily long. This means that the GC system
-must know the layout of arrays, hashes, and objects. This is currently
-true for arrays and objects but not for hashes. But the latter need some
-refactoring of internals anyway.
-
-To avoid visiting all aggregate elements, it could be better to track
-the graph of old aggregates by using a write barrier for all writes into
-the array. This would basically create a generational collector. The old
-generation (the aggregate) isn't scanned. But changes to this "old
-generation" are tracked and reflected in the collectors graph of
-objects.
-
-=item timely destruction
-
-The interpreter arena has a count of currently active objects that need
-timely destruction. When during scope exit an high priority sweep is
-triggered, we have basically two cases:
-
-1) all of these objects were already seen in this mark phase - the scope
-exit can continue.
-
-2) Not all objects were seen - they might be alive or not. This means
-that the mark phase must run to the end to decide, if these objects are
-alive (or again until all are found alive).
-
-To increase performance its likely that we need some additional
-information that keeps track of the location of such objects and just
-try to mark paths to objects that need timely destruction.
-
-=item concurrent or parallel collection
-
-As the described algorithm is already incremental its well-suited for
-parallel collection in a multi-threaded Parrot. The work of greying
-objects can be done in parallel by atomically handling a bunch of
-objects to another thread. After doing some increments of marking, these
-objects then get returned to the shared to-space. The parallel
-collection is finished when the last object is blackened and all threads
-have reached the thread barrier rendezvous point. (Please note the very
-different meaning of barrier here).
-
-But also a single-threaded Parrot can vastly take advantage by running
-increments of the collection during waiting for I/O completion or during
-a sleep opcode.
-
-=back
-
-=head1 FUNCTIONS
-
-=over 4
-
-=cut
-
-*/
-
-#include "parrot/parrot.h"
-#include "parrot/gc_api.h"
-#include "gc_private.h"
-
-/* HEADERIZER HFILE: src/gc/gc_private.h */
-
-/* HEADERIZER BEGIN: static */
-/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
-
-static int collect_cb(PARROT_INTERP,
- ARGMOD(Small_Object_Pool *pool),
- SHIM(int flag),
- ARGIN(void *arg))
- __attribute__nonnull__(1)
- __attribute__nonnull__(2)
- __attribute__nonnull__(4)
- FUNC_MODIFIES(*pool);
-
-static void gc_ims_add_free_object(PARROT_INTERP,
- ARGMOD(Small_Object_Pool *pool),
- ARGOUT(void *to_add))
- __attribute__nonnull__(1)
- __attribute__nonnull__(2)
- __attribute__nonnull__(3)
- FUNC_MODIFIES(*pool)
- FUNC_MODIFIES(*to_add);
-
-static void gc_ims_alloc_objects(PARROT_INTERP,
- ARGMOD(Small_Object_Pool *pool))
- __attribute__nonnull__(1)
- __attribute__nonnull__(2)
- FUNC_MODIFIES(*pool);
-
-PARROT_CANNOT_RETURN_NULL
-PARROT_WARN_UNUSED_RESULT
-static void * gc_ims_get_free_object(PARROT_INTERP,
- ARGMOD(Small_Object_Pool *pool))
- __attribute__nonnull__(1)
- __attribute__nonnull__(2)
- FUNC_MODIFIES(*pool);
-
-static void gc_ims_pool_init(SHIM_INTERP, ARGMOD(Small_Object_Pool *pool))
- __attribute__nonnull__(2)
- FUNC_MODIFIES(*pool);
-
-static int parrot_gc_ims_collect(PARROT_INTERP, int check_only)
- __attribute__nonnull__(1);
-
-static void parrot_gc_ims_deinit(PARROT_INTERP)
- __attribute__nonnull__(1);
-
-static void parrot_gc_ims_mark(PARROT_INTERP)
- __attribute__nonnull__(1);
-
-static void parrot_gc_ims_reinit(PARROT_INTERP)
- __attribute__nonnull__(1);
-
-static void parrot_gc_ims_run(PARROT_INTERP, UINTVAL flags)
- __attribute__nonnull__(1);
-
-static void parrot_gc_ims_run_increment(PARROT_INTERP)
- __attribute__nonnull__(1);
-
-static void parrot_gc_ims_sweep(PARROT_INTERP)
- __attribute__nonnull__(1);
-
-static int sweep_cb(PARROT_INTERP,
- ARGMOD(Small_Object_Pool *pool),
- int flag,
- ARGIN(void *arg))
- __attribute__nonnull__(1)
- __attribute__nonnull__(2)
- __attribute__nonnull__(4)
- FUNC_MODIFIES(*pool);
-
-#define ASSERT_ARGS_collect_cb __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(pool) \
- || PARROT_ASSERT_ARG(arg)
-#define ASSERT_ARGS_gc_ims_add_free_object __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(pool) \
- || PARROT_ASSERT_ARG(to_add)
-#define ASSERT_ARGS_gc_ims_alloc_objects __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(pool)
-#define ASSERT_ARGS_gc_ims_get_free_object __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(pool)
-#define ASSERT_ARGS_gc_ims_pool_init __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(pool)
-#define ASSERT_ARGS_parrot_gc_ims_collect __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp)
-#define ASSERT_ARGS_parrot_gc_ims_deinit __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp)
-#define ASSERT_ARGS_parrot_gc_ims_mark __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp)
-#define ASSERT_ARGS_parrot_gc_ims_reinit __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp)
-#define ASSERT_ARGS_parrot_gc_ims_run __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp)
-#define ASSERT_ARGS_parrot_gc_ims_run_increment __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp)
-#define ASSERT_ARGS_parrot_gc_ims_sweep __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp)
-#define ASSERT_ARGS_sweep_cb __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(pool) \
- || PARROT_ASSERT_ARG(arg)
-/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
-/* HEADERIZER END: static */
-
-
-/* size of one arena */
-#define ALLOCATION_BLOCK_SIZE 8192
-
-/*
- * each ALLOCATIONS_INIT allocations of any object an incremental
- * step is triggered
- */
-#define ALLOCATIONS_INIT 1024*4
-
-/* a mark step does allocations * throttle work */
-#define THROTTLE 1.3
-
-/*
- * if we have at the end total * refill free objects
- * we just do nothing
- */
-#define REFILL_FACTOR 0.5
-
-/*
- * we run the copying collector, if memory pool statistics indicate
- * that this amount of the total size could be freed
- *
- * This factor also depends on the allocation color of buffer headers,
- * which is set to black now. So we are always one mark phase behind
- * and the statistics are rather wrong.
- */
-#define MEM_POOL_RECLAIM 0.2
-
-#if 0
-# define IMS_DEBUG(x) fprintf (x)
-#else
-# define IMS_DEBUG(x)
-#endif
-
-typedef enum { /* these states have to be in execution order */
- GC_IMS_INITIAL, /* memory subsystem setup */
- GC_IMS_STARTING, /* wait for gc_block_level to clear */
- GC_IMS_RE_INIT, /* start of normal operation - mark root */
- GC_IMS_MARKING, /* mark children */
- GC_IMS_START_SWEEP, /* mark finished, start sweep buffers */
- GC_IMS_SWEEP, /* sweep buffers */
- GC_IMS_COLLECT, /* collect buffer memory */
- GC_IMS_FINISHED, /* update statistics */
- GC_IMS_CONSUMING, /* when we have plenty of free objects */
- GC_IMS_DEAD /* gc is already shutdown */
-
-} gc_ims_state_enum;
-
-typedef struct Gc_ims_private {
- gc_ims_state_enum state;
- size_t allocations; /* get_free_object count */
- size_t alloc_trigger; /* after this number of allocations a gc
- increment is triggered */
- double throttle; /* throttle * allocations per increment work */
- size_t increments; /* increment count */
- int lazy; /* timely destruction run */
- size_t n_objects; /* live count of prev run */
- size_t n_extended_PMCs;/* PMCs found during mark_special */
-} Gc_ims_private;
-
-
-/*
-
-=item C<static void gc_ims_add_free_object(PARROT_INTERP, Small_Object_Pool
-*pool, void *to_add)>
-
-Add object C<to_add> to the free_list in the given pool.
-C<pool->num_free_objects> has to be updated by the caller.
-
-=cut
-
-*/
-
-static void
-gc_ims_add_free_object(PARROT_INTERP, ARGMOD(Small_Object_Pool *pool), ARGOUT(void *to_add))
-{
- ASSERT_ARGS(gc_ims_add_free_object)
- *(void **)to_add = pool->free_list;
- pool->free_list = (GC_MS_PObj_Wrapper*)to_add;
-#if DISABLE_GC_DEBUG
- UNUSED(interp);
-#else
- if (GC_DEBUG(interp) && pool == interp->arena_base->pmc_pool) {
- PMC * const p = (PMC *)to_add;
- p->vtable = interp->vtables[enum_class_Null];
- }
-#endif
-}
-
-/*
-
-=item C<static void * gc_ims_get_free_object(PARROT_INTERP, Small_Object_Pool
-*pool)>
-
-Get a new object off the free_list in the given pool.
-
-=cut
-
-*/
-
-PARROT_CANNOT_RETURN_NULL
-PARROT_WARN_UNUSED_RESULT
-static void *
-gc_ims_get_free_object(PARROT_INTERP, ARGMOD(Small_Object_Pool *pool))
-{
- ASSERT_ARGS(gc_ims_get_free_object)
- PObj *ptr;
- Arenas * const arena_base = interp->arena_base;
- Gc_ims_private * const g_ims = (Gc_ims_private *)arena_base->gc_private;
-
- if (++g_ims->allocations >= g_ims->alloc_trigger) {
- g_ims->allocations = 0;
- parrot_gc_ims_run_increment(interp);
- }
-
- /* if we don't have any objects */
- if (!pool->free_list)
- (*pool->alloc_objects) (interp, pool);
-
- ptr = (PObj *)pool->free_list;
- pool->free_list = (GC_MS_PObj_Wrapper*)(*(void **)ptr);
-
- /*
- * buffers are born black, PMCs not yet?
- * XXX this does not solve the problem of storing keys in hashes
- * in the next mark phase (if the key isn't marked elsewhere ?)
- */
- PObj_flags_SETTO(ptr, pool == arena_base->pmc_pool ? 0 : PObj_live_FLAG);
- --pool->num_free_objects;
- return (void *)ptr;
-}
-
-
-/*
-
-=item C<static void gc_ims_alloc_objects(PARROT_INTERP, Small_Object_Pool
-*pool)>
-
-Allocate new objects for the given pool.
-
-=cut
-
-*/
-
-static void
-gc_ims_alloc_objects(PARROT_INTERP, ARGMOD(Small_Object_Pool *pool))
-{
- ASSERT_ARGS(gc_ims_alloc_objects)
- Small_Object_Arena *new_arena;
- size_t size;
-
- pool->objects_per_alloc = ALLOCATION_BLOCK_SIZE / pool->object_size;
-
- /* Setup memory for the new objects */
- new_arena = mem_allocate_typed(Small_Object_Arena);
- size = ALLOCATION_BLOCK_SIZE;
- new_arena->start_objects = mem_sys_allocate(size);
-
- Parrot_append_arena_in_pool(interp, pool, new_arena, size);
-
- Parrot_add_to_free_list(interp, pool, new_arena);
-}
-
-
-/*
-
-=item C<static void gc_ims_pool_init(PARROT_INTERP, Small_Object_Pool *pool)>
-
-Initializes a pool by setting the appropriate function pointers to add, get,
-and allocate objects.
-
-=cut
-
-*/
-
-static void
-gc_ims_pool_init(SHIM_INTERP, ARGMOD(Small_Object_Pool *pool))
-{
- ASSERT_ARGS(gc_ims_pool_init)
- pool->add_free_object = gc_ims_add_free_object;
- pool->get_free_object = gc_ims_get_free_object;
- pool->alloc_objects = gc_ims_alloc_objects;
- pool->more_objects = pool->alloc_objects;
-}
-
-
-/*
-
-=item C<static void parrot_gc_ims_deinit(PARROT_INTERP)>
-
-Shuts down this GC system.
-
-=cut
-
-*/
-
-static void
-parrot_gc_ims_deinit(PARROT_INTERP)
-{
- ASSERT_ARGS(parrot_gc_ims_deinit)
- Arenas * const arena_base = interp->arena_base;
-
- mem_sys_free(arena_base->gc_private);
- arena_base->gc_private = NULL;
-}
-
-
-/*
-
-=item C<void Parrot_gc_ims_init(PARROT_INTERP)>
-
-Initialize the state structures of the gc system. Called immediately before
-creation of memory pools. This function must set the function pointers
-for C<add_free_object_fn>, C<get_free_object_fn>, C<alloc_objects_fn>, and
-C<more_objects_fn>.
-
-=cut
-
-*/
-
-void
-Parrot_gc_ims_init(PARROT_INTERP)
-{
- ASSERT_ARGS(Parrot_gc_ims_init)
- Arenas * const arena_base = interp->arena_base;
- arena_base->gc_private = mem_allocate_zeroed_typed(Gc_ims_private);
-
- /* set function hooks according to pdd09 */
-
- arena_base->do_gc_mark = parrot_gc_ims_run;
- arena_base->finalize_gc_system = parrot_gc_ims_deinit;
- arena_base->init_pool = gc_ims_pool_init;
-
- /* run init state */
- parrot_gc_ims_run_increment(interp);
-}
-
-
-/*
-
-=item C<static void parrot_gc_ims_reinit(PARROT_INTERP)>
-
-Reinitialize the collector for the next collection cycle.
-
-=cut
-
-*/
-
-static void
-parrot_gc_ims_reinit(PARROT_INTERP)
-{
- ASSERT_ARGS(parrot_gc_ims_reinit)
- Gc_ims_private *g_ims;
- Arenas * const arena_base = interp->arena_base;
-
- arena_base->lazy_gc = 0;
- Parrot_gc_run_init(interp);
-
- /*
- * trace root set w/o system areas
- * TODO also skip volatile roots
- */
- Parrot_gc_trace_root(interp, GC_TRACE_ROOT_ONLY);
-
- g_ims = (Gc_ims_private *)arena_base->gc_private;
- g_ims->state = GC_IMS_MARKING;
-
-}
-
-
-/*
-
-=item C<static void parrot_gc_ims_mark(PARROT_INTERP)>
-
-Mark a bunch of children.
-
-The work depends on item counts with and without a next_for_GC field.
-The former are marked immediately, only the latter need real work here.
-
-=cut
-
-*/
-
-static void
-parrot_gc_ims_mark(PARROT_INTERP)
-{
- ASSERT_ARGS(parrot_gc_ims_mark)
- size_t todo;
- double work_factor;
- PMC *next;
-
- Arenas * const arena_base = (Arenas *)interp->arena_base;
- Gc_ims_private * const g_ims = (Gc_ims_private *)arena_base->gc_private;
-
- /* use statistics from the previous run */
- if (g_ims->n_objects)
- work_factor = (double)g_ims->n_extended_PMCs / g_ims->n_objects;
- else
- work_factor = 1.0;
-
- todo = (size_t)(g_ims->alloc_trigger * g_ims->throttle * work_factor);
-
- PARROT_ASSERT(arena_base->lazy_gc == 0);
- Parrot_gc_trace_children(interp, todo);
-
- /* check if we are finished with marking -- the end is self-referential */
- next = arena_base->gc_mark_start;
-
- if (next == PMC_next_for_GC(next))
- g_ims->state = GC_IMS_START_SWEEP;
-}
-
-
-/*
-
-=item C<static int sweep_cb(PARROT_INTERP, Small_Object_Pool *pool, int flag,
-void *arg)>
-
-Callback to sweep a header pool (see header_pools_iterate_callback).
-
-=cut
-
-*/
-
-static int
-sweep_cb(PARROT_INTERP, ARGMOD(Small_Object_Pool *pool), int flag, ARGIN(void *arg))
-{
- ASSERT_ARGS(sweep_cb)
- int * const n_obj = (int *)arg;
-
- Parrot_gc_sweep_pool(interp, pool);
-
- *n_obj += pool->total_objects - pool->num_free_objects;
-
- return 0;
-}
-
-
-/*
-
-=item C<static void parrot_gc_ims_sweep(PARROT_INTERP)>
-
-Free unused objects in all header pools.
-
-TODO split work per pool.
-
-=cut
-
-*/
-
-static void
-parrot_gc_ims_sweep(PARROT_INTERP)
-{
- ASSERT_ARGS(parrot_gc_ims_sweep)
- Arenas * const arena_base = interp->arena_base;
- Gc_ims_private *g_ims = (Gc_ims_private *)arena_base->gc_private;
- size_t n_objects;
- int ignored;
-
- IMS_DEBUG((stderr, "\nSWEEP\n"));
-
- /*
- * as we are now gonna kill objects, make sure that we
- * have traced the current stack
- * except for a lazy run, which is invoked from the run loop
- */
-
- /* TODO mark volatile roots */
- Parrot_gc_trace_root(interp, g_ims->lazy ? GC_TRACE_ROOT_ONLY
- : GC_TRACE_FULL);
-
- /* mark (again) rest of children */
- Parrot_gc_trace_children(interp, (size_t) -1);
-
- /* now sweep all */
- n_objects = 0;
- ignored = header_pools_iterate_callback(interp, POOL_BUFFER | POOL_PMC,
- (void*)&n_objects, sweep_cb);
- UNUSED(ignored);
-
- g_ims->state = GC_IMS_COLLECT;
- g_ims->n_objects = n_objects;
-}
-
-
-/*
-
-=item C<static int collect_cb(PARROT_INTERP, Small_Object_Pool *pool, int flag,
-void *arg)>
-
-Callback to collect a header pool (see header_pools_iterate_callback).
-
-=cut
-
-*/
-
-#if !defined(GC_IS_MALLOC) || !GC_IS_MALLOC
-
-static int
-collect_cb(PARROT_INTERP, ARGMOD(Small_Object_Pool *pool), SHIM(int flag), ARGIN(void *arg))
-{
- ASSERT_ARGS(collect_cb)
- const int check_only = (int)(INTVAL)arg;
- Memory_Pool * const mem_pool = pool->mem_pool;
-
- /* check if there is an associated memory pool */
- if (!mem_pool)
- return 0;
-
- /* and if the memory pool supports compaction */
- if (!mem_pool->compact)
- return 0;
-
- /*
- * several header pools can share one memory pool
- * if that pool is already compacted, the following is zero
- */
- if (!mem_pool->guaranteed_reclaimable)
- return 0;
-
- /* check used size */
- if ((mem_pool->possibly_reclaimable * mem_pool->reclaim_factor +
- mem_pool->guaranteed_reclaimable) >=
- mem_pool->total_allocated * MEM_POOL_RECLAIM) {
- IMS_DEBUG((stderr, "COMPACT\n"));
- if (check_only)
- return 1;
- mem_pool->compact(interp, mem_pool);
- }
-
- return 0;
-}
-
-#endif
-
-
-/*
-
-=item C<static int parrot_gc_ims_collect(PARROT_INTERP, int check_only)>
-
-Run the copying collector in memory pools, if it could yield some free memory.
-
-=cut
-
-*/
-
-static int
-parrot_gc_ims_collect(PARROT_INTERP, int check_only)
-{
- ASSERT_ARGS(parrot_gc_ims_collect)
-#if defined(GC_IS_MALLOC) && GC_IS_MALLOC
- UNUSED(interp);
- UNUSED(check_only);
-#else
- Arenas * const arena_base = interp->arena_base;
- Gc_ims_private *g_ims;
- int ret;
-
- g_ims = (Gc_ims_private *)arena_base->gc_private;
-
- ret = header_pools_iterate_callback(interp, POOL_BUFFER,
- (void *)(long)check_only, collect_cb);
-
- if (ret)
- return ret;
-
- if (check_only)
- return 0;
-
- g_ims->state = GC_IMS_FINISHED;
-#endif
- return 0;
-}
-
-
-/*
-
-=item C<static void parrot_gc_ims_run_increment(PARROT_INTERP)>
-
-Run one increment of collection. This function is triggered by object
-allocation.
-
-=cut
-
-*/
-
-static void
-parrot_gc_ims_run_increment(PARROT_INTERP)
-{
- ASSERT_ARGS(parrot_gc_ims_run_increment)
- Arenas * const arena_base = interp->arena_base;
- Gc_ims_private * const g_ims = (Gc_ims_private *)arena_base->gc_private;
-
- if (arena_base->gc_mark_block_level || g_ims->state == GC_IMS_DEAD)
- return;
-
- ++g_ims->increments;
- IMS_DEBUG((stderr, "state = %d => ", g_ims->state));
-
- switch (g_ims->state) {
- case GC_IMS_INITIAL:
- g_ims->state = GC_IMS_STARTING;
- g_ims->alloc_trigger = ALLOCATIONS_INIT;
- g_ims->throttle = THROTTLE;
- break;
- case GC_IMS_STARTING:
- /* fall through and start */
- /* FALLTHRU */
- case GC_IMS_RE_INIT:
- parrot_gc_ims_reinit(interp);
- break;
-
- case GC_IMS_MARKING:
- parrot_gc_ims_mark(interp);
- break;
-
- case GC_IMS_START_SWEEP:
- g_ims->state = GC_IMS_SWEEP;
- /* fall through */
- case GC_IMS_SWEEP:
- parrot_gc_ims_sweep(interp);
- /* fall through */
- case GC_IMS_COLLECT:
- (void)parrot_gc_ims_collect(interp, 0);
- break;
- case GC_IMS_FINISHED:
- ++arena_base->gc_mark_runs;
- g_ims->state = GC_IMS_CONSUMING;
- /* fall through */
- case GC_IMS_CONSUMING:
- /*
- * This currently looks only at PMCs and string_headers.
- * There shouldn't be other pools that could run out of
- * headers independent of PMCs
- */
- if (arena_base->pmc_pool->num_free_objects <
- arena_base->pmc_pool->total_objects * REFILL_FACTOR) {
- g_ims->state = GC_IMS_STARTING;
- }
- else if (arena_base->string_header_pool->num_free_objects <
- arena_base->string_header_pool->total_objects *
- REFILL_FACTOR) {
- g_ims->state = GC_IMS_STARTING;
- }
- break;
- default:
- PANIC(interp, "Unknown state in gc_ims");
- }
-
- IMS_DEBUG((stderr, "%d\n", g_ims->state));
-}
-
-
-/*
-
-=item C<static void parrot_gc_ims_run(PARROT_INTERP, UINTVAL flags)>
-
-Interface to C<Parrot_gc_mark_and_sweep>. C<flags> is one of:
-
- GC_lazy_FLAG ... timely destruction
- GC_finish_FLAG ... run until live bits are clear
-
-=cut
-
-*/
-
-static void
-parrot_gc_ims_run(PARROT_INTERP, UINTVAL flags)
-{
- ASSERT_ARGS(parrot_gc_ims_run)
- int lazy;
- Arenas * const arena_base = interp->arena_base;
- Gc_ims_private * const g_ims = (Gc_ims_private *)arena_base->gc_private;
-
- if (arena_base->gc_mark_block_level || g_ims->state == GC_IMS_DEAD)
- return;
-
- if (flags & GC_finish_FLAG) {
- /*
- * called from really_destroy. This interpreter is gonna die.
- * The destruction includes a sweep over PMCs, so that
- * destructors/finalizers are called.
- *
- * Be sure live bits are clear.
- */
- if (g_ims->state >= GC_IMS_RE_INIT || g_ims->state < GC_IMS_FINISHED)
- Parrot_gc_clear_live_bits(interp, arena_base->pmc_pool);
-
- Parrot_gc_sweep_pool(interp, interp->arena_base->pmc_pool);
- g_ims->state = GC_IMS_DEAD;
-
- return;
- }
-
- /* make the test happy that checks the count ;) */
- arena_base->gc_mark_runs++;
-
- lazy = flags & GC_lazy_FLAG;
-
- if (!lazy) {
- /* run a full cycle
- * TODO if we are called from mem_allocate() in src/resources.c:
- * * pass needed size
- * * test examples/benchmarks/gc_header_new.pasm
- */
- if (!parrot_gc_ims_collect(interp, 1)) {
- parrot_gc_ims_run_increment(interp);
- return;
- }
-
- if (g_ims->state >= GC_IMS_FINISHED)
- g_ims->state = GC_IMS_STARTING;
-
- while (1) {
- parrot_gc_ims_run_increment(interp);
- if (g_ims->state > GC_IMS_COLLECT)
- break;
- }
-
- return;
- }
-
- /* lazy GC handling */
- IMS_DEBUG((stderr, "\nLAZY state = %d\n", g_ims->state));
- g_ims->lazy = lazy;
-
- if (g_ims->state >= GC_IMS_COLLECT) {
- /* we are beyond sweep, timely destruction is done */
- if (arena_base->num_early_PMCs_seen >= arena_base->num_early_gc_PMCs)
- return;
-
- /* when not all seen, start a fresh cycle */
- g_ims->state = GC_IMS_RE_INIT;
-
- /* run init, which clears lazy seen counter */
- parrot_gc_ims_run_increment(interp);
- }
-
- /*
- * run through all steps until we see enough PMCs that need timely
- * destruction or we finished sweeping
- */
- while (arena_base->num_early_PMCs_seen < arena_base->num_early_gc_PMCs) {
- parrot_gc_ims_run_increment(interp);
- if (g_ims->state >= GC_IMS_COLLECT)
- break;
- }
-
- /* if we stopped early, the lazy run was successful */
- if (g_ims->state < GC_IMS_COLLECT)
- ++arena_base->gc_lazy_mark_runs;
-
- g_ims->lazy = 0;
-}
-
-
-/*
-
-=item C<void Parrot_gc_ims_wb(PARROT_INTERP, PMC *agg, PMC *_new)>
-
-Write barrier called by the GC_WRITE_BARRIER macro. Always when storing
-a white object into a black aggregate, either the object must
-be greyed or the aggregate must be rescanned -- so grey it.
-
-=cut
-
-*/
-
-#define GC_IMS_GREY_NEW 1
-
-void
-Parrot_gc_ims_wb(PARROT_INTERP, ARGMOD(PMC *agg), ARGMOD(PMC *_new))
-{
- ASSERT_ARGS(Parrot_gc_ims_wb)
-#if GC_IMS_GREY_NEW
- IMS_DEBUG((stderr, "%d agg %p mark %p\n",
- ((Gc_ims_private *)interp->arena_base->
- gc_private)->state, agg, _new));
- Parrot_gc_mark_PObj_alive(interp, (PObj*)_new);
-#else
- PObj_get_FLAGS(agg) &= ~ (PObj_live_FLAG|PObj_custom_GC_FLAG);
- Parrot_gc_mark_PObj_alive(interp, (PObj*)agg);
-#endif
-}
-
-/*
-
-=back
-
-=head1 SEE ALSO
-
-F<src/gc/api.c>, F<include/parrot/gc_api.h>, F<include/parrot/pobj.h>,
-
-=head1 HISTORY
-
-Initial version by leo (2004.08.12 - 2004.08.15)
-
-=cut
-
-*/
-
-/*
- * Local variables:
- * c-file-style: "parrot"
- * End:
- * vim: expandtab shiftwidth=4:
- */
Modified: branches/kill_jit/src/gc/mark_sweep.c
==============================================================================
--- branches/kill_jit/src/gc/mark_sweep.c Wed Sep 16 20:55:27 2009 (r41308)
+++ branches/kill_jit/src/gc/mark_sweep.c Wed Sep 16 21:22:58 2009 (r41309)
@@ -32,7 +32,7 @@
/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
static void free_buffer(SHIM_INTERP,
- ARGMOD(Small_Object_Pool *pool),
+ ARGMOD(Fixed_Size_Pool *pool),
ARGMOD(Buffer *b))
__attribute__nonnull__(2)
__attribute__nonnull__(3)
@@ -40,13 +40,13 @@
FUNC_MODIFIES(*b);
static void free_buffer_malloc(SHIM_INTERP,
- SHIM(Small_Object_Pool *pool),
+ SHIM(Fixed_Size_Pool *pool),
ARGMOD(Buffer *b))
__attribute__nonnull__(3)
FUNC_MODIFIES(*b);
static void free_pmc_in_pool(PARROT_INTERP,
- SHIM(Small_Object_Pool *pool),
+ SHIM(Fixed_Size_Pool *pool),
ARGMOD(PObj *p))
__attribute__nonnull__(1)
__attribute__nonnull__(3)
@@ -54,24 +54,24 @@
PARROT_WARN_UNUSED_RESULT
PARROT_CANNOT_RETURN_NULL
-static Small_Object_Pool * new_bufferlike_pool(PARROT_INTERP,
+static Fixed_Size_Pool * new_bufferlike_pool(PARROT_INTERP,
size_t actual_buffer_size)
__attribute__nonnull__(1);
-PARROT_WARN_UNUSED_RESULT
-PARROT_CANNOT_RETURN_NULL
-static Small_Object_Pool * new_pmc_pool(PARROT_INTERP)
- __attribute__nonnull__(1);
-
PARROT_MALLOC
PARROT_CANNOT_RETURN_NULL
-static Small_Object_Pool * new_small_object_pool(
+static Fixed_Size_Pool * new_fixed_size_obj_pool(
size_t object_size,
size_t objects_per_alloc);
PARROT_WARN_UNUSED_RESULT
PARROT_CANNOT_RETURN_NULL
-static Small_Object_Pool * new_string_pool(PARROT_INTERP, INTVAL constant)
+static Fixed_Size_Pool * new_pmc_pool(PARROT_INTERP)
+ __attribute__nonnull__(1);
+
+PARROT_WARN_UNUSED_RESULT
+PARROT_CANNOT_RETURN_NULL
+static Fixed_Size_Pool * new_string_pool(PARROT_INTERP, INTVAL constant)
__attribute__nonnull__(1);
static void Parrot_gc_allocate_new_attributes_arena(PARROT_INTERP,
@@ -95,9 +95,9 @@
|| PARROT_ASSERT_ARG(p)
#define ASSERT_ARGS_new_bufferlike_pool __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp)
+#define ASSERT_ARGS_new_fixed_size_obj_pool __attribute__unused__ int _ASSERT_ARGS_CHECK = 0
#define ASSERT_ARGS_new_pmc_pool __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp)
-#define ASSERT_ARGS_new_small_object_pool __attribute__unused__ int _ASSERT_ARGS_CHECK = 0
#define ASSERT_ARGS_new_string_pool __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp)
#define ASSERT_ARGS_Parrot_gc_allocate_new_attributes_arena \
@@ -117,7 +117,7 @@
=item C<void Parrot_gc_run_init(PARROT_INTERP)>
Prepares the collector for a mark & sweep GC run. Initializes the various
-fields in the Arenas structure that need to be zeroed out prior to the
+fields in the Memory_Pools structure that need to be zeroed out prior to the
mark phase.
=cut
@@ -128,11 +128,11 @@
Parrot_gc_run_init(PARROT_INTERP)
{
ASSERT_ARGS(Parrot_gc_run_init)
- Arenas * const arena_base = interp->arena_base;
+ Memory_Pools * const mem_pools = interp->mem_pools;
- arena_base->gc_trace_ptr = NULL;
- arena_base->gc_mark_start = NULL;
- arena_base->num_early_PMCs_seen = 0;
+ mem_pools->gc_trace_ptr = NULL;
+ mem_pools->gc_mark_start = NULL;
+ mem_pools->num_early_PMCs_seen = 0;
}
/*
@@ -169,7 +169,7 @@
Parrot_gc_trace_root(PARROT_INTERP, Parrot_gc_trace_type trace)
{
ASSERT_ARGS(Parrot_gc_trace_root)
- Arenas * const arena_base = interp->arena_base;
+ Memory_Pools * const mem_pools = interp->mem_pools;
PObj *obj;
/* note: adding locals here did cause increased GC runs */
@@ -181,9 +181,9 @@
}
/* We have to start somewhere; the interpreter globals is a good place */
- if (!arena_base->gc_mark_start) {
- arena_base->gc_mark_start
- = arena_base->gc_mark_ptr
+ if (!mem_pools->gc_mark_start) {
+ mem_pools->gc_mark_start
+ = mem_pools->gc_mark_ptr
= interp->iglobals;
}
@@ -241,8 +241,8 @@
/* quick check to see if we have already marked all impatient PMCs. If we
have, return 0 and exit here. This will alert other parts of the GC
that if we are in a lazy run we can just stop it. */
- if (arena_base->lazy_gc
- && arena_base->num_early_PMCs_seen >= arena_base->num_early_gc_PMCs)
+ if (mem_pools->lazy_gc
+ && mem_pools->num_early_PMCs_seen >= mem_pools->num_early_gc_PMCs)
return 0;
return 1;
@@ -251,7 +251,7 @@
/*
-=item C<void Parrot_gc_sweep_pool(PARROT_INTERP, Small_Object_Pool *pool)>
+=item C<void Parrot_gc_sweep_pool(PARROT_INTERP, Fixed_Size_Pool *pool)>
Puts any buffers/PMCs that are marked as "dead" or "black" onto the pool
free list. If C<GC_IS_MALLOC>, bufstart gets freed too, if possible. Avoids
@@ -262,7 +262,7 @@
*/
void
-Parrot_gc_sweep_pool(PARROT_INTERP, ARGMOD(Small_Object_Pool *pool))
+Parrot_gc_sweep_pool(PARROT_INTERP, ARGMOD(Fixed_Size_Pool *pool))
{
ASSERT_ARGS(Parrot_gc_sweep_pool)
PObj *b;
@@ -270,7 +270,7 @@
UINTVAL total_used = 0;
const UINTVAL object_size = pool->object_size;
- Small_Object_Arena *cur_arena;
+ Fixed_Size_Arena *cur_arena;
gc_object_fn_type gc_object = pool->gc_object;
#if GC_VERBOSE
@@ -346,8 +346,8 @@
/*
-=item C<INTVAL contained_in_pool(const Small_Object_Pool *pool, const void
-*ptr)>
+=item C<INTVAL contained_in_pool(PARROT_INTERP, const Fixed_Size_Pool *pool,
+const void *ptr)>
Returns whether the given C<*ptr> points to a location in C<pool>.
@@ -357,12 +357,10 @@
PARROT_WARN_UNUSED_RESULT
INTVAL
-contained_in_pool(ARGIN(const Small_Object_Pool *pool), ARGIN(const void *ptr))
+contained_in_pool(PARROT_INTERP, ARGIN(const Fixed_Size_Pool *pool), ARGIN(const void *ptr))
{
ASSERT_ARGS(contained_in_pool)
- const Small_Object_Arena *arena;
-
- ptr = PObj_to_ARENA(ptr);
+ const Fixed_Size_Arena *arena;
for (arena = pool->last_Arena; arena; arena = arena->prev) {
const ptrdiff_t ptr_diff =
@@ -394,7 +392,7 @@
{
ASSERT_ARGS(mark_special)
int hi_prio;
- Arenas *arena_base;
+ Memory_Pools *mem_pools;
/*
* If the object is shared, we have to use the arena and gc
@@ -411,25 +409,25 @@
interp = PMC_sync(obj)->owner;
PARROT_ASSERT(interp);
- if (!interp->arena_base->gc_mark_ptr)
- interp->arena_base->gc_mark_ptr = obj;
+ if (!interp->mem_pools->gc_mark_ptr)
+ interp->mem_pools->gc_mark_ptr = obj;
}
- arena_base = interp->arena_base;
+ mem_pools = interp->mem_pools;
if (PObj_needs_early_gc_TEST(obj))
- ++arena_base->num_early_PMCs_seen;
+ ++mem_pools->num_early_PMCs_seen;
- if (PObj_high_priority_gc_TEST(obj) && arena_base->gc_trace_ptr) {
+ if (PObj_high_priority_gc_TEST(obj) && mem_pools->gc_trace_ptr) {
/* set obj's parent to high priority */
- PObj_high_priority_gc_SET(arena_base->gc_trace_ptr);
+ PObj_high_priority_gc_SET(mem_pools->gc_trace_ptr);
hi_prio = 1;
}
else
hi_prio = 0;
{
- PMC * const tptr = arena_base->gc_trace_ptr;
+ PMC * const tptr = mem_pools->gc_trace_ptr;
/*
* XXX this basically invalidates the high-priority marking
* of PMCs by putting all PMCs onto the front of the list.
@@ -451,11 +449,11 @@
}
else {
/* put it on the end of the list */
- PMC_next_for_GC(arena_base->gc_mark_ptr) = obj;
+ PMC_next_for_GC(mem_pools->gc_mark_ptr) = obj;
/* Explicitly make the tail of the linked list be
* self-referential */
- arena_base->gc_mark_ptr = PMC_next_for_GC(obj) = obj;
+ mem_pools->gc_mark_ptr = PMC_next_for_GC(obj) = obj;
}
}
if (PObj_custom_mark_TEST(obj)) {
@@ -468,7 +466,7 @@
/*
-=item C<void Parrot_gc_clear_live_bits(PARROT_INTERP, const Small_Object_Pool
+=item C<void Parrot_gc_clear_live_bits(PARROT_INTERP, const Fixed_Size_Pool
*pool)>
Resets the PMC pool, so all objects are marked as "White". This
@@ -480,10 +478,10 @@
*/
void
-Parrot_gc_clear_live_bits(PARROT_INTERP, ARGIN(const Small_Object_Pool *pool))
+Parrot_gc_clear_live_bits(PARROT_INTERP, ARGIN(const Fixed_Size_Pool *pool))
{
ASSERT_ARGS(Parrot_gc_clear_live_bits)
- Small_Object_Arena *arena;
+ Fixed_Size_Arena *arena;
const UINTVAL object_size = pool->object_size;
for (arena = pool->last_Arena; arena; arena = arena->prev) {
@@ -514,9 +512,9 @@
Parrot_gc_trace_children(PARROT_INTERP, size_t how_many)
{
ASSERT_ARGS(Parrot_gc_trace_children)
- Arenas * const arena_base = interp->arena_base;
- const int lazy_gc = arena_base->lazy_gc;
- PMC *current = arena_base->gc_mark_start;
+ Memory_Pools * const mem_pools = interp->mem_pools;
+ const int lazy_gc = mem_pools->lazy_gc;
+ PMC *current = mem_pools->gc_mark_start;
/*
* First phase of mark is finished. Now if we are the owner
@@ -532,13 +530,13 @@
do {
PMC *next;
- if (lazy_gc && arena_base->num_early_PMCs_seen >=
- arena_base->num_early_gc_PMCs) {
+ if (lazy_gc && mem_pools->num_early_PMCs_seen >=
+ mem_pools->num_early_gc_PMCs) {
return 0;
}
PARROT_ASSERT(current);
- arena_base->gc_trace_ptr = current;
+ mem_pools->gc_trace_ptr = current;
/* short-term hack to color objects black */
PObj_get_FLAGS(current) |= PObj_custom_GC_FLAG;
@@ -564,16 +562,16 @@
current = next;
} while (--how_many > 0);
- arena_base->gc_mark_start = current;
- arena_base->gc_trace_ptr = NULL;
+ mem_pools->gc_mark_start = current;
+ mem_pools->gc_trace_ptr = NULL;
return 1;
}
/*
-=item C<void Parrot_add_to_free_list(PARROT_INTERP, Small_Object_Pool *pool,
-Small_Object_Arena *arena)>
+=item C<void Parrot_add_to_free_list(PARROT_INTERP, Fixed_Size_Pool *pool,
+Fixed_Size_Arena *arena)>
Adds the objects in the newly allocated C<arena> to the free list of the pool.
@@ -583,8 +581,8 @@
void
Parrot_add_to_free_list(PARROT_INTERP,
- ARGMOD(Small_Object_Pool *pool),
- ARGMOD(Small_Object_Arena *arena))
+ ARGMOD(Fixed_Size_Pool *pool),
+ ARGMOD(Fixed_Size_Arena *arena))
{
ASSERT_ARGS(Parrot_add_to_free_list)
UINTVAL i;
@@ -616,8 +614,8 @@
/*
-=item C<void Parrot_append_arena_in_pool(PARROT_INTERP, Small_Object_Pool *pool,
-Small_Object_Arena *new_arena, size_t size)>
+=item C<void Parrot_append_arena_in_pool(PARROT_INTERP, Fixed_Size_Pool *pool,
+Fixed_Size_Arena *new_arena, size_t size)>
Insert the new arena into the pool's structure. Arenas are stored in a
linked list, so add the new arena to the list. Set information in the
@@ -629,8 +627,8 @@
void
Parrot_append_arena_in_pool(PARROT_INTERP,
- ARGMOD(Small_Object_Pool *pool),
- ARGMOD(Small_Object_Arena *new_arena), size_t size)
+ ARGMOD(Fixed_Size_Pool *pool),
+ ARGMOD(Fixed_Size_Arena *new_arena), size_t size)
{
ASSERT_ARGS(Parrot_append_arena_in_pool)
@@ -652,7 +650,7 @@
new_arena->prev->next = new_arena;
pool->last_Arena = new_arena;
- interp->arena_base->header_allocs_since_last_collect++;
+ interp->mem_pools->header_allocs_since_last_collect++;
}
/*
@@ -663,7 +661,7 @@
=over 4
-=item C<static Small_Object_Pool * new_pmc_pool(PARROT_INTERP)>
+=item C<static Fixed_Size_Pool * new_pmc_pool(PARROT_INTERP)>
Creates and initializes a new pool for PMCs and returns it.
@@ -673,25 +671,25 @@
PARROT_WARN_UNUSED_RESULT
PARROT_CANNOT_RETURN_NULL
-static Small_Object_Pool *
+static Fixed_Size_Pool *
new_pmc_pool(PARROT_INTERP)
{
ASSERT_ARGS(new_pmc_pool)
const int num_headers = PMC_HEADERS_PER_ALLOC;
- Small_Object_Pool * const pmc_pool =
- new_small_object_pool(sizeof (PMC), num_headers);
+ Fixed_Size_Pool * const pmc_pool =
+ new_fixed_size_obj_pool(sizeof (PMC), num_headers);
pmc_pool->mem_pool = NULL;
pmc_pool->gc_object = free_pmc_in_pool;
- (interp->arena_base->init_pool)(interp, pmc_pool);
+ (interp->gc_sys->init_pool)(interp, pmc_pool);
return pmc_pool;
}
/*
-=item C<static void free_pmc_in_pool(PARROT_INTERP, Small_Object_Pool *pool,
-PObj *p)>
+=item C<static void free_pmc_in_pool(PARROT_INTERP, Fixed_Size_Pool *pool, PObj
+*p)>
Frees a PMC that is no longer being used. Calls a custom C<destroy> VTABLE
method if one is available.
@@ -701,16 +699,16 @@
*/
static void
-free_pmc_in_pool(PARROT_INTERP, SHIM(Small_Object_Pool *pool),
+free_pmc_in_pool(PARROT_INTERP, SHIM(Fixed_Size_Pool *pool),
ARGMOD(PObj *p))
{
ASSERT_ARGS(free_pmc_in_pool)
PMC * const pmc = (PMC *)p;
- Arenas * const arena_base = interp->arena_base;
+ Memory_Pools * const mem_pools = interp->mem_pools;
/* TODO collect objects with finalizers */
if (PObj_needs_early_gc_TEST(p))
- --arena_base->num_early_gc_PMCs;
+ --mem_pools->num_early_gc_PMCs;
Parrot_pmc_destroy(interp, pmc);
}
@@ -718,7 +716,7 @@
/*
-=item C<static Small_Object_Pool * new_bufferlike_pool(PARROT_INTERP, size_t
+=item C<static Fixed_Size_Pool * new_bufferlike_pool(PARROT_INTERP, size_t
actual_buffer_size)>
Creates a new pool for buffer-like structures. This is called from
@@ -730,15 +728,15 @@
PARROT_WARN_UNUSED_RESULT
PARROT_CANNOT_RETURN_NULL
-static Small_Object_Pool *
+static Fixed_Size_Pool *
new_bufferlike_pool(PARROT_INTERP, size_t actual_buffer_size)
{
ASSERT_ARGS(new_bufferlike_pool)
const int num_headers = BUFFER_HEADERS_PER_ALLOC;
const size_t buffer_size =
(actual_buffer_size + sizeof (void *) - 1) & ~(sizeof (void *) - 1);
- Small_Object_Pool * const pool =
- new_small_object_pool(buffer_size, num_headers);
+ Fixed_Size_Pool * const pool =
+ new_fixed_size_obj_pool(buffer_size, num_headers);
#ifdef GC_IS_MALLOC
pool->gc_object = free_buffer_malloc;
@@ -746,17 +744,17 @@
pool->gc_object = (gc_object_fn_type)free_buffer;
#endif
- pool->mem_pool = interp->arena_base->memory_pool;
- (interp->arena_base->init_pool)(interp, pool);
+ pool->mem_pool = interp->mem_pools->memory_pool;
+ (interp->gc_sys->init_pool)(interp, pool);
return pool;
}
/*
-=item C<static Small_Object_Pool * new_small_object_pool(size_t object_size,
+=item C<static Fixed_Size_Pool * new_fixed_size_obj_pool(size_t object_size,
size_t objects_per_alloc)>
-Creates a new C<Small_Object_Pool> and returns a pointer to it.
+Creates a new C<Fixed_Size_Pool> and returns a pointer to it.
Initializes the pool structure based on the size of objects in the
pool and the number of items to allocate in each arena.
@@ -766,12 +764,12 @@
PARROT_MALLOC
PARROT_CANNOT_RETURN_NULL
-static Small_Object_Pool *
-new_small_object_pool(size_t object_size, size_t objects_per_alloc)
+static Fixed_Size_Pool *
+new_fixed_size_obj_pool(size_t object_size, size_t objects_per_alloc)
{
- ASSERT_ARGS(new_small_object_pool)
- Small_Object_Pool * const pool =
- mem_internal_allocate_zeroed_typed(Small_Object_Pool);
+ ASSERT_ARGS(new_fixed_size_obj_pool)
+ Fixed_Size_Pool * const pool =
+ mem_internal_allocate_zeroed_typed(Fixed_Size_Pool);
pool->last_Arena = NULL;
pool->free_list = NULL;
@@ -788,7 +786,7 @@
/*
-=item C<static Small_Object_Pool * new_string_pool(PARROT_INTERP, INTVAL
+=item C<static Fixed_Size_Pool * new_string_pool(PARROT_INTERP, INTVAL
constant)>
Creates a new pool for C<STRING>s and returns it. This calls
@@ -800,15 +798,15 @@
PARROT_WARN_UNUSED_RESULT
PARROT_CANNOT_RETURN_NULL
-static Small_Object_Pool *
+static Fixed_Size_Pool *
new_string_pool(PARROT_INTERP, INTVAL constant)
{
ASSERT_ARGS(new_string_pool)
- Small_Object_Pool *pool;
+ Fixed_Size_Pool *pool;
if (constant) {
pool = new_bufferlike_pool(interp, sizeof (STRING));
pool->gc_object = NULL;
- pool->mem_pool = interp->arena_base->constant_string_pool;
+ pool->mem_pool = interp->mem_pools->constant_string_pool;
}
else
pool = get_bufferlike_pool(interp, sizeof (STRING));
@@ -820,7 +818,7 @@
/*
-=item C<static void free_buffer_malloc(PARROT_INTERP, Small_Object_Pool *pool,
+=item C<static void free_buffer_malloc(PARROT_INTERP, Fixed_Size_Pool *pool,
Buffer *b)>
Frees the given buffer, returning the storage space to the operating system
@@ -832,7 +830,7 @@
*/
static void
-free_buffer_malloc(SHIM_INTERP, SHIM(Small_Object_Pool *pool),
+free_buffer_malloc(SHIM_INTERP, SHIM(Fixed_Size_Pool *pool),
ARGMOD(Buffer *b))
{
ASSERT_ARGS(free_buffer_malloc)
@@ -856,7 +854,7 @@
/*
-=item C<static void free_buffer(PARROT_INTERP, Small_Object_Pool *pool, Buffer
+=item C<static void free_buffer(PARROT_INTERP, Fixed_Size_Pool *pool, Buffer
*b)>
Frees a buffer, returning it to the memory pool for Parrot to possibly
@@ -867,10 +865,10 @@
*/
static void
-free_buffer(SHIM_INTERP, ARGMOD(Small_Object_Pool *pool), ARGMOD(Buffer *b))
+free_buffer(SHIM_INTERP, ARGMOD(Fixed_Size_Pool *pool), ARGMOD(Buffer *b))
{
ASSERT_ARGS(free_buffer)
- Memory_Pool * const mem_pool = (Memory_Pool *)pool->mem_pool;
+ Variable_Size_Pool * const mem_pool = (Variable_Size_Pool *)pool->mem_pool;
/* XXX Jarkko reported that on irix pool->mem_pool was NULL, which really
* shouldn't happen */
@@ -887,7 +885,7 @@
/*
-=item C<Small_Object_Pool * get_bufferlike_pool(PARROT_INTERP, size_t
+=item C<Fixed_Size_Pool * get_bufferlike_pool(PARROT_INTERP, size_t
buffer_size)>
Makes and return a bufferlike header pool for objects of a given size. If a
@@ -900,12 +898,12 @@
PARROT_WARN_UNUSED_RESULT
PARROT_CANNOT_RETURN_NULL
-Small_Object_Pool *
+Fixed_Size_Pool *
get_bufferlike_pool(PARROT_INTERP, size_t buffer_size)
{
ASSERT_ARGS(get_bufferlike_pool)
- Small_Object_Pool **sized_pools = interp->arena_base->sized_header_pools;
- const UINTVAL num_old = interp->arena_base->num_sized;
+ Fixed_Size_Pool **sized_pools = interp->mem_pools->sized_header_pools;
+ const UINTVAL num_old = interp->mem_pools->num_sized;
const UINTVAL idx = GET_SIZED_POOL_IDX(buffer_size);
/* Expands the array of sized resource pools, if necessary */
@@ -915,12 +913,12 @@
same debugging behavior as mem_internal_realloc, we would
need to add a new function/macro for
mem_internal_realloc_zeroed, to mirror mem_sys_realloc_zeroed. */
- sized_pools = (Small_Object_Pool **)mem_internal_realloc(sized_pools,
+ sized_pools = (Fixed_Size_Pool **)mem_internal_realloc(sized_pools,
num_new * sizeof (void *));
memset(sized_pools + num_old, 0, sizeof (void *) * (num_new - num_old));
- interp->arena_base->sized_header_pools = sized_pools;
- interp->arena_base->num_sized = num_new;
+ interp->mem_pools->sized_header_pools = sized_pools;
+ interp->mem_pools->num_sized = num_new;
}
if (sized_pools[idx] == NULL)
@@ -931,7 +929,7 @@
/*
-=item C<void initialize_header_pools(PARROT_INTERP)>
+=item C<void initialize_fixed_size_pools(PARROT_INTERP)>
The initialization routine for the interpreter's header pools. Initializes
pools for string headers, constant string headers, buffers, PMCs and
@@ -945,14 +943,14 @@
*/
void
-initialize_header_pools(PARROT_INTERP)
+initialize_fixed_size_pools(PARROT_INTERP)
{
- ASSERT_ARGS(initialize_header_pools)
- Arenas * const arena_base = interp->arena_base;
+ ASSERT_ARGS(initialize_fixed_size_pools)
+ Memory_Pools * const mem_pools = interp->mem_pools;
/* Init the constant string header pool */
- arena_base->constant_string_header_pool = new_string_pool(interp, 1);
- arena_base->constant_string_header_pool->name = "constant_string_header";
+ mem_pools->constant_string_header_pool = new_string_pool(interp, 1);
+ mem_pools->constant_string_header_pool->name = "constant_string_header";
/* Init the buffer header pool
*
@@ -961,17 +959,17 @@
* new_*_header */
/* Init the string header pool */
- arena_base->string_header_pool = new_string_pool(interp, 0);
- arena_base->string_header_pool->name = "string_header";
+ mem_pools->string_header_pool = new_string_pool(interp, 0);
+ mem_pools->string_header_pool->name = "string_header";
/* Init the PMC header pool */
- arena_base->pmc_pool = new_pmc_pool(interp);
- arena_base->pmc_pool->name = "pmc";
+ mem_pools->pmc_pool = new_pmc_pool(interp);
+ mem_pools->pmc_pool->name = "pmc";
/* constant PMCs */
- arena_base->constant_pmc_pool = new_pmc_pool(interp);
- arena_base->constant_pmc_pool->name = "constant_pmc";
- arena_base->constant_pmc_pool->objects_per_alloc =
+ mem_pools->constant_pmc_pool = new_pmc_pool(interp);
+ mem_pools->constant_pmc_pool->name = "constant_pmc";
+ mem_pools->constant_pmc_pool->objects_per_alloc =
CONSTANT_PMC_HEADERS_PER_ALLOC;
}
@@ -1007,7 +1005,7 @@
=item pool_iter_fn
-Called with C<(Parrot_Interp, Small_Object_Pool *, int flag, void *arg)>. If
+Called with C<(Parrot_Interp, Fixed_Size_Pool *, int flag, void *arg)>. If
the function returns a non-zero value, iteration will stop.
=back
@@ -1022,12 +1020,12 @@
NOTNULL(pool_iter_fn func))
{
ASSERT_ARGS(header_pools_iterate_callback)
- Arenas * const arena_base = interp->arena_base;
+ Memory_Pools * const mem_pools = interp->mem_pools;
if (flag & POOL_PMC) {
- Small_Object_Pool *pool = flag & POOL_CONST
- ? arena_base->constant_pmc_pool
- : arena_base->pmc_pool;
+ Fixed_Size_Pool *pool = flag & POOL_CONST
+ ? mem_pools->constant_pmc_pool
+ : mem_pools->pmc_pool;
const int ret_val = (func)(interp, pool,
flag & (POOL_PMC | POOL_CONST) , arg);
@@ -1041,15 +1039,15 @@
if (flag & POOL_CONST) {
const int ret_val = (func)(interp,
- arena_base->constant_string_header_pool,
+ mem_pools->constant_string_header_pool,
POOL_BUFFER | POOL_CONST, arg);
if (ret_val)
return ret_val;
}
- for (i = interp->arena_base->num_sized - 1; i >= 0; --i) {
- Small_Object_Pool * const pool = arena_base->sized_header_pools[i];
+ for (i = interp->mem_pools->num_sized - 1; i >= 0; --i) {
+ Fixed_Size_Pool * const pool = mem_pools->sized_header_pools[i];
if (pool) {
const int ret_val = (func)(interp, pool, POOL_BUFFER, arg);
@@ -1195,8 +1193,8 @@
{
ASSERT_ARGS(Parrot_gc_get_attribute_pool)
- Arenas * const arenas = interp->arena_base;
- PMC_Attribute_Pool **pools = arenas->attrib_pools;
+ Memory_Pools * const mem_pools = interp->mem_pools;
+ PMC_Attribute_Pool **pools = mem_pools->attrib_pools;
const size_t size = (attrib_size < sizeof (void *))
? sizeof (void *)
: attrib_size;
@@ -1209,20 +1207,21 @@
number of resizes. 8 is just an arbitrary number */
pools = (PMC_Attribute_Pool **)mem_internal_allocate(total_size);
memset(pools, 0, total_size);
- arenas->attrib_pools = pools;
- arenas->num_attribs = total_length;
+
+ mem_pools->attrib_pools = pools;
+ mem_pools->num_attribs = total_length;
}
- if (arenas->num_attribs <= idx) {
+ if (mem_pools->num_attribs <= idx) {
const size_t total_length = idx + GC_ATTRIB_POOLS_HEADROOM;
const size_t total_size = total_length * sizeof (void *);
- const size_t current_size = arenas->num_attribs;
+ const size_t current_size = mem_pools->num_attribs;
const size_t diff = total_length - current_size;
pools = (PMC_Attribute_Pool **)mem_internal_realloc(pools, total_size);
memset(pools + current_size, 0, diff * sizeof (void *));
- arenas->attrib_pools = pools;
- arenas->num_attribs = total_length;
+ mem_pools->attrib_pools = pools;
+ mem_pools->num_attribs = total_length;
}
if (!pools[idx])
Modified: branches/kill_jit/src/gc/res_lea.c
==============================================================================
--- branches/kill_jit/src/gc/res_lea.c Wed Sep 16 20:55:27 2009 (r41308)
+++ branches/kill_jit/src/gc/res_lea.c Wed Sep 16 21:22:58 2009 (r41309)
@@ -46,10 +46,10 @@
Parrot_gc_compact_memory_pool(PARROT_INTERP)
{
ASSERT_ARGS(parrot_go_collect)
- if (interp->arena_base->gc_sweep_block_level) {
+ if (interp->mem_pools->gc_sweep_block_level) {
return;
}
- interp->arena_base->gc_collect_runs++; /* fake it */
+ interp->mem_pools->gc_collect_runs++; /* fake it */
}
/*
@@ -239,7 +239,7 @@
/*
-=item C<void initialize_memory_pools(PARROT_INTERP)>
+=item C<void initialize_var_size_pools(PARROT_INTERP)>
Does nothing.
@@ -248,9 +248,9 @@
*/
void
-initialize_memory_pools(PARROT_INTERP)
+initialize_var_size_pools(PARROT_INTERP)
{
- ASSERT_ARGS(parrot_initialize_memory_pools)
+ ASSERT_ARGS(parrot_initialize_var_size_pools)
}
/*
Modified: branches/kill_jit/src/gc/system.c
==============================================================================
--- branches/kill_jit/src/gc/system.c Wed Sep 16 20:55:27 2009 (r41308)
+++ branches/kill_jit/src/gc/system.c Wed Sep 16 21:22:58 2009 (r41309)
@@ -263,14 +263,14 @@
get_max_buffer_address(PARROT_INTERP)
{
ASSERT_ARGS(get_max_buffer_address)
- Arenas * const arena_base = interp->arena_base;
+ Memory_Pools * const mem_pools = interp->mem_pools;
size_t max = 0;
UINTVAL i;
- for (i = 0; i < arena_base->num_sized; i++) {
- if (arena_base->sized_header_pools[i]) {
- if (arena_base->sized_header_pools[i]->end_arena_memory > max)
- max = arena_base->sized_header_pools[i]->end_arena_memory;
+ for (i = 0; i < mem_pools->num_sized; i++) {
+ if (mem_pools->sized_header_pools[i]) {
+ if (mem_pools->sized_header_pools[i]->end_arena_memory > max)
+ max = mem_pools->sized_header_pools[i]->end_arena_memory;
}
}
@@ -298,15 +298,15 @@
get_min_buffer_address(PARROT_INTERP)
{
ASSERT_ARGS(get_min_buffer_address)
- Arenas * const arena_base = interp->arena_base;
+ Memory_Pools * const mem_pools = interp->mem_pools;
size_t min = (size_t) -1;
UINTVAL i;
- for (i = 0; i < arena_base->num_sized; i++) {
- if (arena_base->sized_header_pools[i]
- && arena_base->sized_header_pools[i]->start_arena_memory) {
- if (arena_base->sized_header_pools[i]->start_arena_memory < min)
- min = arena_base->sized_header_pools[i]->start_arena_memory;
+ for (i = 0; i < mem_pools->num_sized; i++) {
+ if (mem_pools->sized_header_pools[i]
+ && mem_pools->sized_header_pools[i]->start_arena_memory) {
+ if (mem_pools->sized_header_pools[i]->start_arena_memory < min)
+ min = mem_pools->sized_header_pools[i]->start_arena_memory;
}
}
@@ -329,7 +329,7 @@
get_max_pmc_address(PARROT_INTERP)
{
ASSERT_ARGS(get_max_pmc_address)
- return interp->arena_base->pmc_pool->end_arena_memory;
+ return interp->mem_pools->pmc_pool->end_arena_memory;
}
@@ -350,7 +350,7 @@
get_min_pmc_address(PARROT_INTERP)
{
ASSERT_ARGS(get_min_pmc_address)
- return interp->arena_base->pmc_pool->start_arena_memory;
+ return interp->mem_pools->pmc_pool->start_arena_memory;
}
@@ -484,12 +484,12 @@
is_buffer_ptr(PARROT_INTERP, ARGIN(const void *ptr))
{
ASSERT_ARGS(is_buffer_ptr)
- Arenas * const arena_base = interp->arena_base;
+ Memory_Pools * const mem_pools = interp->mem_pools;
UINTVAL i;
- for (i = 0; i < arena_base->num_sized; i++) {
- if (arena_base->sized_header_pools[i]
- && contained_in_pool(arena_base->sized_header_pools[i], ptr))
+ for (i = 0; i < mem_pools->num_sized; i++) {
+ if (mem_pools->sized_header_pools[i]
+ && contained_in_pool(interp, mem_pools->sized_header_pools[i], ptr))
return 1;
}
@@ -512,7 +512,7 @@
is_pmc_ptr(PARROT_INTERP, ARGIN(const void *ptr))
{
ASSERT_ARGS(is_pmc_ptr)
- return contained_in_pool(interp->arena_base->pmc_pool, ptr);
+ return contained_in_pool(interp, interp->mem_pools->pmc_pool, ptr);
}
Modified: branches/kill_jit/src/hash.c
==============================================================================
--- branches/kill_jit/src/hash.c Wed Sep 16 20:55:27 2009 (r41308)
+++ branches/kill_jit/src/hash.c Wed Sep 16 21:22:58 2009 (r41309)
@@ -1302,19 +1302,9 @@
bucket = bucket->next;
}
- if (bucket) {
- if (hash->entry_type == enum_type_PMC && hash->container) {
- GC_WRITE_BARRIER_KEY(interp, hash->container,
- (PMC *)bucket->value, bucket->key, (PMC *)value, key);
- }
-
+ if (bucket)
bucket->value = value;
- }
else {
- if (hash->entry_type == enum_type_PMC && hash->container) {
- GC_WRITE_BARRIER_KEY(interp, hash->container,
- NULL, NULL, (PMC *)value, key);
- }
bucket = hash->free_list;
@@ -1422,8 +1412,9 @@
"hash corruption: type = %d\n", hash->entry_type);
};
- if (key)
+ if (key){
parrot_hash_put(interp, dest, key, valtmp);
+ }
}
}
Modified: branches/kill_jit/src/interp/inter_create.c
==============================================================================
--- branches/kill_jit/src/interp/inter_create.c Wed Sep 16 20:55:27 2009 (r41308)
+++ branches/kill_jit/src/interp/inter_create.c Wed Sep 16 21:22:58 2009 (r41309)
@@ -413,8 +413,8 @@
Parrot_gc_destroy_memory_pools(interp);
/* mem subsystem is dead now */
- mem_sys_free(interp->arena_base);
- interp->arena_base = NULL;
+ mem_sys_free(interp->mem_pools);
+ interp->mem_pools = NULL;
/* cache structure */
destroy_object_cache(interp);
Modified: branches/kill_jit/src/interp/inter_misc.c
==============================================================================
--- branches/kill_jit/src/interp/inter_misc.c Wed Sep 16 20:55:27 2009 (r41308)
+++ branches/kill_jit/src/interp/inter_misc.c Wed Sep 16 21:22:58 2009 (r41309)
@@ -22,6 +22,7 @@
#include "parrot/parrot.h"
#include "inter_misc.str"
#include "../compilers/imcc/imc.h"
+#include "parrot/runcore_api.h"
#include "parrot/has_header.h"
Modified: branches/kill_jit/src/jit.c
==============================================================================
--- branches/kill_jit/src/jit.c Wed Sep 16 20:55:27 2009 (r41308)
+++ branches/kill_jit/src/jit.c Wed Sep 16 21:22:58 2009 (r41309)
@@ -1628,7 +1628,9 @@
PARROT_ASSERT(*cur_op == PARROT_OP_get_results_pc);
/* now emit the call - use special op for this */
- (op_func[PARROT_OP_pic_callr___pc].fn)(jit_info, interp);
+ /* Don't want to fix it. JIT on chopping block.
+ * (op_func[PARROT_OP_pic_callr___pc].fn)(jit_info, interp);
+ */
/* and the get_results */
(op_func[*cur_op].fn)(jit_info, interp);
Modified: branches/kill_jit/src/list.c
==============================================================================
--- branches/kill_jit/src/list.c Wed Sep 16 20:55:27 2009 (r41308)
+++ branches/kill_jit/src/list.c Wed Sep 16 21:22:58 2009 (r41309)
@@ -383,10 +383,6 @@
Parrot_gc_allocate_buffer_storage_aligned(interp, (Buffer *)chunk, size);
memset(Buffer_bufstart((Buffer*)chunk), 0, size);
- /* see also src/hash.c */
- if (list->container)
- GC_WRITE_BARRIER(interp, list->container, 0, chunk);
-
Parrot_unblock_GC_mark(interp);
/* Parrot_unblock_GC_sweep(interp); */
@@ -515,10 +511,6 @@
Parrot_gc_reallocate_buffer_storage(interp, (Buffer *)prev,
MAX_ITEMS * list->item_size);
- if (list->container) {
- GC_WRITE_BARRIER(interp, list->container, 0, prev);
- }
-
mem_sys_memmove(
(char *) Buffer_bufstart(&prev->data) +
prev->items * list->item_size,
@@ -536,9 +528,7 @@
else {
Parrot_gc_reallocate_buffer_storage(interp, (Buffer *)prev,
(prev->items + chunk->items) * list->item_size);
- if (list->container) {
- GC_WRITE_BARRIER(interp, list->container, 0, prev);
- }
+
mem_sys_memmove(
(char *) Buffer_bufstart(&prev->data) +
prev->items * list->item_size,
@@ -636,10 +626,6 @@
Parrot_gc_reallocate_buffer_storage(interp, (Buffer *)list,
len * sizeof (List_chunk *));
- if (list->container) {
- GC_WRITE_BARRIER(interp, list->container, 0, list);
- }
-
list->collect_runs = Parrot_gc_count_collect_runs(interp);
}
@@ -1135,10 +1121,6 @@
Parrot_gc_reallocate_buffer_storage(interp, (Buffer *)chunk,
chunk->items * list->item_size);
- if (list->container) {
- GC_WRITE_BARRIER(interp, list->container, 0, chunk);
- }
-
chunk->flags |= no_power_2;
chunk->flags &= ~sparse;
}
@@ -1155,10 +1137,6 @@
Parrot_gc_reallocate_buffer_storage(interp, (Buffer *)chunk,
chunk->items * list->item_size);
- if (list->container) {
- GC_WRITE_BARRIER(interp, list->container, 0, chunk);
- }
-
chunk->flags &= ~sparse;
if (n3) {
@@ -1246,11 +1224,6 @@
((FLOATVAL *) Buffer_bufstart(&chunk->data))[idx] = *(FLOATVAL *)item;
break;
case enum_type_PMC:
- if (list->container) {
- GC_WRITE_BARRIER(interp, list->container,
- ((PMC **) Buffer_bufstart(&chunk->data))[idx],
- (PMC *)item);
- }
((PMC **) Buffer_bufstart(&chunk->data))[idx] = (PMC *)item;
break;
case enum_type_STRING:
@@ -1333,9 +1306,9 @@
{
ASSERT_ARGS(list_append)
/* initially, list may be empty, also used by assign */
- while (idx >= list->cap)
+ while (idx >= list->cap){
add_chunk_at_end(interp, list, idx);
-
+ }
list_set(interp, list, item, type, idx);
/* invariant: prepare for next push */
Modified: branches/kill_jit/src/ops/ops.num
==============================================================================
--- branches/kill_jit/src/ops/ops.num Wed Sep 16 20:55:27 2009 (r41308)
+++ branches/kill_jit/src/ops/ops.num Wed Sep 16 21:22:58 2009 (r41309)
@@ -803,479 +803,474 @@
inspect_p_pc_s 779
inspect_p_p_sc 780
inspect_p_pc_sc 781
-pic_infix___ic_p_p 782
-pic_inline_sub___ic_p_p 783
-pic_get_params___pc 784
-pic_set_returns___pc 785
-pic_callr___pc 786
-new_p_s 787
-new_p_sc 788
-new_p_s_p 789
-new_p_sc_p 790
-new_p_s_pc 791
-new_p_sc_pc 792
-new_p_p 793
-new_p_pc 794
-new_p_p_p 795
-new_p_pc_p 796
-new_p_p_pc 797
-new_p_pc_pc 798
-root_new_p_p 799
-root_new_p_pc 800
-root_new_p_p_p 801
-root_new_p_pc_p 802
-root_new_p_p_pc 803
-root_new_p_pc_pc 804
-typeof_s_p 805
-typeof_p_p 806
-get_repr_s_p 807
-find_method_p_p_s 808
-find_method_p_p_sc 809
-defined_i_p 810
-defined_i_p_ki 811
-defined_i_p_kic 812
-defined_i_p_k 813
-defined_i_p_kc 814
-exists_i_p_ki 815
-exists_i_p_kic 816
-exists_i_p_k 817
-exists_i_p_kc 818
-delete_p_k 819
-delete_p_kc 820
-delete_p_ki 821
-delete_p_kic 822
-elements_i_p 823
-push_p_i 824
-push_p_ic 825
-push_p_n 826
-push_p_nc 827
-push_p_s 828
-push_p_sc 829
-push_p_p 830
-pop_i_p 831
-pop_n_p 832
-pop_s_p 833
-pop_p_p 834
-unshift_p_i 835
-unshift_p_ic 836
-unshift_p_n 837
-unshift_p_nc 838
-unshift_p_s 839
-unshift_p_sc 840
-unshift_p_p 841
-shift_i_p 842
-shift_n_p 843
-shift_s_p 844
-shift_p_p 845
-splice_p_p_i_i 846
-splice_p_p_ic_i 847
-splice_p_p_i_ic 848
-splice_p_p_ic_ic 849
-setprop_p_s_p 850
-setprop_p_sc_p 851
-getprop_p_s_p 852
-getprop_p_sc_p 853
-delprop_p_s 854
-delprop_p_sc 855
-prophash_p_p 856
-freeze_s_p 857
-thaw_p_s 858
-thaw_p_sc 859
-add_multi_s_s_p 860
-add_multi_sc_s_p 861
-add_multi_s_sc_p 862
-add_multi_sc_sc_p 863
-find_multi_p_s_s 864
-find_multi_p_sc_s 865
-find_multi_p_s_sc 866
-find_multi_p_sc_sc 867
-register_p 868
-unregister_p 869
-box_p_i 870
-box_p_ic 871
-box_p_n 872
-box_p_nc 873
-box_p_s 874
-box_p_sc 875
-iter_p_p 876
-morph_p_p 877
-morph_p_pc 878
-clone_s_s 879
-clone_s_sc 880
-exchange_i_i 881
-exchange_p_p 882
-exchange_n_n 883
-exchange_s_s 884
-set_i_i 885
-set_i_ic 886
-set_i_n 887
-set_i_nc 888
-set_i_s 889
-set_i_sc 890
-set_n_n 891
-set_n_nc 892
-set_n_i 893
-set_n_ic 894
-set_n_s 895
-set_n_sc 896
-set_n_p 897
-set_s_p 898
-set_s_s 899
-set_s_sc 900
-set_s_i 901
-set_s_ic 902
-set_s_n 903
-set_s_nc 904
-set_p_pc 905
-set_p_p 906
-set_p_i 907
-set_p_ic 908
-set_p_n 909
-set_p_nc 910
-set_p_s 911
-set_p_sc 912
-set_i_p 913
-assign_p_p 914
-assign_p_i 915
-assign_p_ic 916
-assign_p_n 917
-assign_p_nc 918
-assign_p_s 919
-assign_p_sc 920
-assign_s_s 921
-assign_s_sc 922
-setref_p_p 923
-deref_p_p 924
-setp_ind_i_p 925
-setp_ind_ic_p 926
-setn_ind_i_n 927
-setn_ind_ic_n 928
-setn_ind_i_nc 929
-setn_ind_ic_nc 930
-sets_ind_i_s 931
-sets_ind_ic_s 932
-sets_ind_i_sc 933
-sets_ind_ic_sc 934
-seti_ind_i_i 935
-seti_ind_ic_i 936
-seti_ind_i_ic 937
-seti_ind_ic_ic 938
-set_p_ki_i 939
-set_p_kic_i 940
-set_p_ki_ic 941
-set_p_kic_ic 942
-set_p_ki_n 943
-set_p_kic_n 944
-set_p_ki_nc 945
-set_p_kic_nc 946
-set_p_ki_s 947
-set_p_kic_s 948
-set_p_ki_sc 949
-set_p_kic_sc 950
-set_p_ki_p 951
-set_p_kic_p 952
-set_i_p_ki 953
-set_i_p_kic 954
-set_n_p_ki 955
-set_n_p_kic 956
-set_s_p_ki 957
-set_s_p_kic 958
-set_p_p_ki 959
-set_p_p_kic 960
-set_p_k_i 961
-set_p_kc_i 962
-set_p_k_ic 963
-set_p_kc_ic 964
-set_p_k_n 965
-set_p_kc_n 966
-set_p_k_nc 967
-set_p_kc_nc 968
-set_p_k_s 969
-set_p_kc_s 970
-set_p_k_sc 971
-set_p_kc_sc 972
-set_p_k_p 973
-set_p_kc_p 974
-set_i_p_k 975
-set_i_p_kc 976
-set_n_p_k 977
-set_n_p_kc 978
-set_s_p_k 979
-set_s_p_kc 980
-set_p_p_k 981
-set_p_p_kc 982
-clone_p_p 983
-clone_p_p_p 984
-clone_p_p_pc 985
-copy_p_p 986
-null_s 987
-null_i 988
-null_p 989
-null_n 990
-cleari 991
-clearn 992
-clears 993
-clearp 994
-ord_i_s 995
-ord_i_sc 996
-ord_i_s_i 997
-ord_i_sc_i 998
-ord_i_s_ic 999
-ord_i_sc_ic 1000
-chr_s_i 1001
-chr_s_ic 1002
-chopn_s_i 1003
-chopn_s_ic 1004
-chopn_s_s_i 1005
-chopn_s_sc_i 1006
-chopn_s_s_ic 1007
-chopn_s_sc_ic 1008
-concat_s_s 1009
-concat_s_sc 1010
-concat_p_p 1011
-concat_p_s 1012
-concat_p_sc 1013
-concat_s_s_s 1014
-concat_s_sc_s 1015
-concat_s_s_sc 1016
-concat_p_p_s 1017
-concat_p_p_sc 1018
-concat_p_p_p 1019
-repeat_s_s_i 1020
-repeat_s_sc_i 1021
-repeat_s_s_ic 1022
-repeat_s_sc_ic 1023
-repeat_p_p_i 1024
-repeat_p_p_ic 1025
-repeat_p_p_p 1026
-repeat_p_i 1027
-repeat_p_ic 1028
-repeat_p_p 1029
-length_i_s 1030
-length_i_sc 1031
-bytelength_i_s 1032
-bytelength_i_sc 1033
-pin_s 1034
-unpin_s 1035
-substr_s_s_i 1036
-substr_s_sc_i 1037
-substr_s_s_ic 1038
-substr_s_sc_ic 1039
-substr_s_s_i_i 1040
-substr_s_sc_i_i 1041
-substr_s_s_ic_i 1042
-substr_s_sc_ic_i 1043
-substr_s_s_i_ic 1044
-substr_s_sc_i_ic 1045
-substr_s_s_ic_ic 1046
-substr_s_sc_ic_ic 1047
-substr_s_s_i_i_s 1048
-substr_s_s_ic_i_s 1049
-substr_s_s_i_ic_s 1050
-substr_s_s_ic_ic_s 1051
-substr_s_s_i_i_sc 1052
-substr_s_s_ic_i_sc 1053
-substr_s_s_i_ic_sc 1054
-substr_s_s_ic_ic_sc 1055
-substr_s_i_i_s 1056
-substr_s_ic_i_s 1057
-substr_s_i_ic_s 1058
-substr_s_ic_ic_s 1059
-substr_s_i_i_sc 1060
-substr_s_ic_i_sc 1061
-substr_s_i_ic_sc 1062
-substr_s_ic_ic_sc 1063
-substr_s_p_i_i 1064
-substr_s_p_ic_i 1065
-substr_s_p_i_ic 1066
-substr_s_p_ic_ic 1067
-index_i_s_s 1068
-index_i_sc_s 1069
-index_i_s_sc 1070
-index_i_sc_sc 1071
-index_i_s_s_i 1072
-index_i_sc_s_i 1073
-index_i_s_sc_i 1074
-index_i_sc_sc_i 1075
-index_i_s_s_ic 1076
-index_i_sc_s_ic 1077
-index_i_s_sc_ic 1078
-index_i_sc_sc_ic 1079
-sprintf_s_s_p 1080
-sprintf_s_sc_p 1081
-sprintf_p_p_p 1082
-new_s 1083
-new_s_i 1084
-new_s_ic 1085
-stringinfo_i_s_i 1086
-stringinfo_i_sc_i 1087
-stringinfo_i_s_ic 1088
-stringinfo_i_sc_ic 1089
-upcase_s_s 1090
-upcase_s_sc 1091
-upcase_s 1092
-downcase_s_s 1093
-downcase_s_sc 1094
-downcase_s 1095
-titlecase_s_s 1096
-titlecase_s_sc 1097
-titlecase_s 1098
-join_s_s_p 1099
-join_s_sc_p 1100
-split_p_s_s 1101
-split_p_sc_s 1102
-split_p_s_sc 1103
-split_p_sc_sc 1104
-charset_i_s 1105
-charset_i_sc 1106
-charsetname_s_i 1107
-charsetname_s_ic 1108
-find_charset_i_s 1109
-find_charset_i_sc 1110
-trans_charset_s_i 1111
-trans_charset_s_ic 1112
-trans_charset_s_s_i 1113
-trans_charset_s_sc_i 1114
-trans_charset_s_s_ic 1115
-trans_charset_s_sc_ic 1116
-encoding_i_s 1117
-encoding_i_sc 1118
-encodingname_s_i 1119
-encodingname_s_ic 1120
-find_encoding_i_s 1121
-find_encoding_i_sc 1122
-trans_encoding_s_i 1123
-trans_encoding_s_ic 1124
-trans_encoding_s_s_i 1125
-trans_encoding_s_sc_i 1126
-trans_encoding_s_s_ic 1127
-trans_encoding_s_sc_ic 1128
-is_cclass_i_i_s_i 1129
-is_cclass_i_ic_s_i 1130
-is_cclass_i_i_sc_i 1131
-is_cclass_i_ic_sc_i 1132
-is_cclass_i_i_s_ic 1133
-is_cclass_i_ic_s_ic 1134
-is_cclass_i_i_sc_ic 1135
-is_cclass_i_ic_sc_ic 1136
-find_cclass_i_i_s_i_i 1137
-find_cclass_i_ic_s_i_i 1138
-find_cclass_i_i_sc_i_i 1139
-find_cclass_i_ic_sc_i_i 1140
-find_cclass_i_i_s_ic_i 1141
-find_cclass_i_ic_s_ic_i 1142
-find_cclass_i_i_sc_ic_i 1143
-find_cclass_i_ic_sc_ic_i 1144
-find_cclass_i_i_s_i_ic 1145
-find_cclass_i_ic_s_i_ic 1146
-find_cclass_i_i_sc_i_ic 1147
-find_cclass_i_ic_sc_i_ic 1148
-find_cclass_i_i_s_ic_ic 1149
-find_cclass_i_ic_s_ic_ic 1150
-find_cclass_i_i_sc_ic_ic 1151
-find_cclass_i_ic_sc_ic_ic 1152
-find_not_cclass_i_i_s_i_i 1153
-find_not_cclass_i_ic_s_i_i 1154
-find_not_cclass_i_i_sc_i_i 1155
-find_not_cclass_i_ic_sc_i_i 1156
-find_not_cclass_i_i_s_ic_i 1157
-find_not_cclass_i_ic_s_ic_i 1158
-find_not_cclass_i_i_sc_ic_i 1159
-find_not_cclass_i_ic_sc_ic_i 1160
-find_not_cclass_i_i_s_i_ic 1161
-find_not_cclass_i_ic_s_i_ic 1162
-find_not_cclass_i_i_sc_i_ic 1163
-find_not_cclass_i_ic_sc_i_ic 1164
-find_not_cclass_i_i_s_ic_ic 1165
-find_not_cclass_i_ic_s_ic_ic 1166
-find_not_cclass_i_i_sc_ic_ic 1167
-find_not_cclass_i_ic_sc_ic_ic 1168
-escape_s_s 1169
-compose_s_s 1170
-compose_s_sc 1171
-spawnw_i_s 1172
-spawnw_i_sc 1173
-spawnw_i_p 1174
-err_i 1175
-err_s 1176
-err_s_i 1177
-err_s_ic 1178
-time_i 1179
-time_n 1180
-gmtime_s_i 1181
-gmtime_s_ic 1182
-localtime_s_i 1183
-localtime_s_ic 1184
-decodetime_p_i 1185
-decodetime_p_ic 1186
-decodelocaltime_p_i 1187
-decodelocaltime_p_ic 1188
-sysinfo_s_i 1189
-sysinfo_s_ic 1190
-sysinfo_i_i 1191
-sysinfo_i_ic 1192
-sleep_i 1193
-sleep_ic 1194
-sleep_n 1195
-sleep_nc 1196
-sizeof_i_i 1197
-sizeof_i_ic 1198
-store_lex_s_p 1199
-store_lex_sc_p 1200
-find_lex_p_s 1201
-find_lex_p_sc 1202
-find_caller_lex_p_s 1203
-find_caller_lex_p_sc 1204
-get_namespace_p 1205
-get_namespace_p_p 1206
-get_namespace_p_pc 1207
-get_hll_namespace_p 1208
-get_hll_namespace_p_p 1209
-get_hll_namespace_p_pc 1210
-get_root_namespace_p 1211
-get_root_namespace_p_p 1212
-get_root_namespace_p_pc 1213
-get_global_p_s 1214
-get_global_p_sc 1215
-get_global_p_p_s 1216
-get_global_p_pc_s 1217
-get_global_p_p_sc 1218
-get_global_p_pc_sc 1219
-get_hll_global_p_s 1220
-get_hll_global_p_sc 1221
-get_hll_global_p_p_s 1222
-get_hll_global_p_pc_s 1223
-get_hll_global_p_p_sc 1224
-get_hll_global_p_pc_sc 1225
-get_root_global_p_s 1226
-get_root_global_p_sc 1227
-get_root_global_p_p_s 1228
-get_root_global_p_pc_s 1229
-get_root_global_p_p_sc 1230
-get_root_global_p_pc_sc 1231
-set_global_s_p 1232
-set_global_sc_p 1233
-set_global_p_s_p 1234
-set_global_pc_s_p 1235
-set_global_p_sc_p 1236
-set_global_pc_sc_p 1237
-set_hll_global_s_p 1238
-set_hll_global_sc_p 1239
-set_hll_global_p_s_p 1240
-set_hll_global_pc_s_p 1241
-set_hll_global_p_sc_p 1242
-set_hll_global_pc_sc_p 1243
-set_root_global_s_p 1244
-set_root_global_sc_p 1245
-set_root_global_p_s_p 1246
-set_root_global_pc_s_p 1247
-set_root_global_p_sc_p 1248
-set_root_global_pc_sc_p 1249
-find_name_p_s 1250
-find_name_p_sc 1251
-find_sub_not_null_p_s 1252
-find_sub_not_null_p_sc 1253
-store_dynamic_lex_s_p 1254
-store_dynamic_lex_sc_p 1255
-find_dynamic_lex_p_s 1256
-find_dynamic_lex_p_sc 1257
+new_p_s 782
+new_p_sc 783
+new_p_s_p 784
+new_p_sc_p 785
+new_p_s_pc 786
+new_p_sc_pc 787
+new_p_p 788
+new_p_pc 789
+new_p_p_p 790
+new_p_pc_p 791
+new_p_p_pc 792
+new_p_pc_pc 793
+root_new_p_p 794
+root_new_p_pc 795
+root_new_p_p_p 796
+root_new_p_pc_p 797
+root_new_p_p_pc 798
+root_new_p_pc_pc 799
+typeof_s_p 800
+typeof_p_p 801
+get_repr_s_p 802
+find_method_p_p_s 803
+find_method_p_p_sc 804
+defined_i_p 805
+defined_i_p_ki 806
+defined_i_p_kic 807
+defined_i_p_k 808
+defined_i_p_kc 809
+exists_i_p_ki 810
+exists_i_p_kic 811
+exists_i_p_k 812
+exists_i_p_kc 813
+delete_p_k 814
+delete_p_kc 815
+delete_p_ki 816
+delete_p_kic 817
+elements_i_p 818
+push_p_i 819
+push_p_ic 820
+push_p_n 821
+push_p_nc 822
+push_p_s 823
+push_p_sc 824
+push_p_p 825
+pop_i_p 826
+pop_n_p 827
+pop_s_p 828
+pop_p_p 829
+unshift_p_i 830
+unshift_p_ic 831
+unshift_p_n 832
+unshift_p_nc 833
+unshift_p_s 834
+unshift_p_sc 835
+unshift_p_p 836
+shift_i_p 837
+shift_n_p 838
+shift_s_p 839
+shift_p_p 840
+splice_p_p_i_i 841
+splice_p_p_ic_i 842
+splice_p_p_i_ic 843
+splice_p_p_ic_ic 844
+setprop_p_s_p 845
+setprop_p_sc_p 846
+getprop_p_s_p 847
+getprop_p_sc_p 848
+delprop_p_s 849
+delprop_p_sc 850
+prophash_p_p 851
+freeze_s_p 852
+thaw_p_s 853
+thaw_p_sc 854
+add_multi_s_s_p 855
+add_multi_sc_s_p 856
+add_multi_s_sc_p 857
+add_multi_sc_sc_p 858
+find_multi_p_s_s 859
+find_multi_p_sc_s 860
+find_multi_p_s_sc 861
+find_multi_p_sc_sc 862
+register_p 863
+unregister_p 864
+box_p_i 865
+box_p_ic 866
+box_p_n 867
+box_p_nc 868
+box_p_s 869
+box_p_sc 870
+iter_p_p 871
+morph_p_p 872
+morph_p_pc 873
+clone_s_s 874
+clone_s_sc 875
+exchange_i_i 876
+exchange_p_p 877
+exchange_n_n 878
+exchange_s_s 879
+set_i_i 880
+set_i_ic 881
+set_i_n 882
+set_i_nc 883
+set_i_s 884
+set_i_sc 885
+set_n_n 886
+set_n_nc 887
+set_n_i 888
+set_n_ic 889
+set_n_s 890
+set_n_sc 891
+set_n_p 892
+set_s_p 893
+set_s_s 894
+set_s_sc 895
+set_s_i 896
+set_s_ic 897
+set_s_n 898
+set_s_nc 899
+set_p_pc 900
+set_p_p 901
+set_p_i 902
+set_p_ic 903
+set_p_n 904
+set_p_nc 905
+set_p_s 906
+set_p_sc 907
+set_i_p 908
+assign_p_p 909
+assign_p_i 910
+assign_p_ic 911
+assign_p_n 912
+assign_p_nc 913
+assign_p_s 914
+assign_p_sc 915
+assign_s_s 916
+assign_s_sc 917
+setref_p_p 918
+deref_p_p 919
+setp_ind_i_p 920
+setp_ind_ic_p 921
+setn_ind_i_n 922
+setn_ind_ic_n 923
+setn_ind_i_nc 924
+setn_ind_ic_nc 925
+sets_ind_i_s 926
+sets_ind_ic_s 927
+sets_ind_i_sc 928
+sets_ind_ic_sc 929
+seti_ind_i_i 930
+seti_ind_ic_i 931
+seti_ind_i_ic 932
+seti_ind_ic_ic 933
+set_p_ki_i 934
+set_p_kic_i 935
+set_p_ki_ic 936
+set_p_kic_ic 937
+set_p_ki_n 938
+set_p_kic_n 939
+set_p_ki_nc 940
+set_p_kic_nc 941
+set_p_ki_s 942
+set_p_kic_s 943
+set_p_ki_sc 944
+set_p_kic_sc 945
+set_p_ki_p 946
+set_p_kic_p 947
+set_i_p_ki 948
+set_i_p_kic 949
+set_n_p_ki 950
+set_n_p_kic 951
+set_s_p_ki 952
+set_s_p_kic 953
+set_p_p_ki 954
+set_p_p_kic 955
+set_p_k_i 956
+set_p_kc_i 957
+set_p_k_ic 958
+set_p_kc_ic 959
+set_p_k_n 960
+set_p_kc_n 961
+set_p_k_nc 962
+set_p_kc_nc 963
+set_p_k_s 964
+set_p_kc_s 965
+set_p_k_sc 966
+set_p_kc_sc 967
+set_p_k_p 968
+set_p_kc_p 969
+set_i_p_k 970
+set_i_p_kc 971
+set_n_p_k 972
+set_n_p_kc 973
+set_s_p_k 974
+set_s_p_kc 975
+set_p_p_k 976
+set_p_p_kc 977
+clone_p_p 978
+clone_p_p_p 979
+clone_p_p_pc 980
+copy_p_p 981
+null_s 982
+null_i 983
+null_p 984
+null_n 985
+cleari 986
+clearn 987
+clears 988
+clearp 989
+ord_i_s 990
+ord_i_sc 991
+ord_i_s_i 992
+ord_i_sc_i 993
+ord_i_s_ic 994
+ord_i_sc_ic 995
+chr_s_i 996
+chr_s_ic 997
+chopn_s_i 998
+chopn_s_ic 999
+chopn_s_s_i 1000
+chopn_s_sc_i 1001
+chopn_s_s_ic 1002
+chopn_s_sc_ic 1003
+concat_s_s 1004
+concat_s_sc 1005
+concat_p_p 1006
+concat_p_s 1007
+concat_p_sc 1008
+concat_s_s_s 1009
+concat_s_sc_s 1010
+concat_s_s_sc 1011
+concat_p_p_s 1012
+concat_p_p_sc 1013
+concat_p_p_p 1014
+repeat_s_s_i 1015
+repeat_s_sc_i 1016
+repeat_s_s_ic 1017
+repeat_s_sc_ic 1018
+repeat_p_p_i 1019
+repeat_p_p_ic 1020
+repeat_p_p_p 1021
+repeat_p_i 1022
+repeat_p_ic 1023
+repeat_p_p 1024
+length_i_s 1025
+length_i_sc 1026
+bytelength_i_s 1027
+bytelength_i_sc 1028
+pin_s 1029
+unpin_s 1030
+substr_s_s_i 1031
+substr_s_sc_i 1032
+substr_s_s_ic 1033
+substr_s_sc_ic 1034
+substr_s_s_i_i 1035
+substr_s_sc_i_i 1036
+substr_s_s_ic_i 1037
+substr_s_sc_ic_i 1038
+substr_s_s_i_ic 1039
+substr_s_sc_i_ic 1040
+substr_s_s_ic_ic 1041
+substr_s_sc_ic_ic 1042
+substr_s_s_i_i_s 1043
+substr_s_s_ic_i_s 1044
+substr_s_s_i_ic_s 1045
+substr_s_s_ic_ic_s 1046
+substr_s_s_i_i_sc 1047
+substr_s_s_ic_i_sc 1048
+substr_s_s_i_ic_sc 1049
+substr_s_s_ic_ic_sc 1050
+substr_s_i_i_s 1051
+substr_s_ic_i_s 1052
+substr_s_i_ic_s 1053
+substr_s_ic_ic_s 1054
+substr_s_i_i_sc 1055
+substr_s_ic_i_sc 1056
+substr_s_i_ic_sc 1057
+substr_s_ic_ic_sc 1058
+substr_s_p_i_i 1059
+substr_s_p_ic_i 1060
+substr_s_p_i_ic 1061
+substr_s_p_ic_ic 1062
+index_i_s_s 1063
+index_i_sc_s 1064
+index_i_s_sc 1065
+index_i_sc_sc 1066
+index_i_s_s_i 1067
+index_i_sc_s_i 1068
+index_i_s_sc_i 1069
+index_i_sc_sc_i 1070
+index_i_s_s_ic 1071
+index_i_sc_s_ic 1072
+index_i_s_sc_ic 1073
+index_i_sc_sc_ic 1074
+sprintf_s_s_p 1075
+sprintf_s_sc_p 1076
+sprintf_p_p_p 1077
+new_s 1078
+new_s_i 1079
+new_s_ic 1080
+stringinfo_i_s_i 1081
+stringinfo_i_sc_i 1082
+stringinfo_i_s_ic 1083
+stringinfo_i_sc_ic 1084
+upcase_s_s 1085
+upcase_s_sc 1086
+upcase_s 1087
+downcase_s_s 1088
+downcase_s_sc 1089
+downcase_s 1090
+titlecase_s_s 1091
+titlecase_s_sc 1092
+titlecase_s 1093
+join_s_s_p 1094
+join_s_sc_p 1095
+split_p_s_s 1096
+split_p_sc_s 1097
+split_p_s_sc 1098
+split_p_sc_sc 1099
+charset_i_s 1100
+charset_i_sc 1101
+charsetname_s_i 1102
+charsetname_s_ic 1103
+find_charset_i_s 1104
+find_charset_i_sc 1105
+trans_charset_s_i 1106
+trans_charset_s_ic 1107
+trans_charset_s_s_i 1108
+trans_charset_s_sc_i 1109
+trans_charset_s_s_ic 1110
+trans_charset_s_sc_ic 1111
+encoding_i_s 1112
+encoding_i_sc 1113
+encodingname_s_i 1114
+encodingname_s_ic 1115
+find_encoding_i_s 1116
+find_encoding_i_sc 1117
+trans_encoding_s_i 1118
+trans_encoding_s_ic 1119
+trans_encoding_s_s_i 1120
+trans_encoding_s_sc_i 1121
+trans_encoding_s_s_ic 1122
+trans_encoding_s_sc_ic 1123
+is_cclass_i_i_s_i 1124
+is_cclass_i_ic_s_i 1125
+is_cclass_i_i_sc_i 1126
+is_cclass_i_ic_sc_i 1127
+is_cclass_i_i_s_ic 1128
+is_cclass_i_ic_s_ic 1129
+is_cclass_i_i_sc_ic 1130
+is_cclass_i_ic_sc_ic 1131
+find_cclass_i_i_s_i_i 1132
+find_cclass_i_ic_s_i_i 1133
+find_cclass_i_i_sc_i_i 1134
+find_cclass_i_ic_sc_i_i 1135
+find_cclass_i_i_s_ic_i 1136
+find_cclass_i_ic_s_ic_i 1137
+find_cclass_i_i_sc_ic_i 1138
+find_cclass_i_ic_sc_ic_i 1139
+find_cclass_i_i_s_i_ic 1140
+find_cclass_i_ic_s_i_ic 1141
+find_cclass_i_i_sc_i_ic 1142
+find_cclass_i_ic_sc_i_ic 1143
+find_cclass_i_i_s_ic_ic 1144
+find_cclass_i_ic_s_ic_ic 1145
+find_cclass_i_i_sc_ic_ic 1146
+find_cclass_i_ic_sc_ic_ic 1147
+find_not_cclass_i_i_s_i_i 1148
+find_not_cclass_i_ic_s_i_i 1149
+find_not_cclass_i_i_sc_i_i 1150
+find_not_cclass_i_ic_sc_i_i 1151
+find_not_cclass_i_i_s_ic_i 1152
+find_not_cclass_i_ic_s_ic_i 1153
+find_not_cclass_i_i_sc_ic_i 1154
+find_not_cclass_i_ic_sc_ic_i 1155
+find_not_cclass_i_i_s_i_ic 1156
+find_not_cclass_i_ic_s_i_ic 1157
+find_not_cclass_i_i_sc_i_ic 1158
+find_not_cclass_i_ic_sc_i_ic 1159
+find_not_cclass_i_i_s_ic_ic 1160
+find_not_cclass_i_ic_s_ic_ic 1161
+find_not_cclass_i_i_sc_ic_ic 1162
+find_not_cclass_i_ic_sc_ic_ic 1163
+escape_s_s 1164
+compose_s_s 1165
+compose_s_sc 1166
+spawnw_i_s 1167
+spawnw_i_sc 1168
+spawnw_i_p 1169
+err_i 1170
+err_s 1171
+err_s_i 1172
+err_s_ic 1173
+time_i 1174
+time_n 1175
+gmtime_s_i 1176
+gmtime_s_ic 1177
+localtime_s_i 1178
+localtime_s_ic 1179
+decodetime_p_i 1180
+decodetime_p_ic 1181
+decodelocaltime_p_i 1182
+decodelocaltime_p_ic 1183
+sysinfo_s_i 1184
+sysinfo_s_ic 1185
+sysinfo_i_i 1186
+sysinfo_i_ic 1187
+sleep_i 1188
+sleep_ic 1189
+sleep_n 1190
+sleep_nc 1191
+sizeof_i_i 1192
+sizeof_i_ic 1193
+store_lex_s_p 1194
+store_lex_sc_p 1195
+store_dynamic_lex_s_p 1196
+store_dynamic_lex_sc_p 1197
+find_lex_p_s 1198
+find_lex_p_sc 1199
+find_dynamic_lex_p_s 1200
+find_dynamic_lex_p_sc 1201
+find_caller_lex_p_s 1202
+find_caller_lex_p_sc 1203
+get_namespace_p 1204
+get_namespace_p_p 1205
+get_namespace_p_pc 1206
+get_hll_namespace_p 1207
+get_hll_namespace_p_p 1208
+get_hll_namespace_p_pc 1209
+get_root_namespace_p 1210
+get_root_namespace_p_p 1211
+get_root_namespace_p_pc 1212
+get_global_p_s 1213
+get_global_p_sc 1214
+get_global_p_p_s 1215
+get_global_p_pc_s 1216
+get_global_p_p_sc 1217
+get_global_p_pc_sc 1218
+get_hll_global_p_s 1219
+get_hll_global_p_sc 1220
+get_hll_global_p_p_s 1221
+get_hll_global_p_pc_s 1222
+get_hll_global_p_p_sc 1223
+get_hll_global_p_pc_sc 1224
+get_root_global_p_s 1225
+get_root_global_p_sc 1226
+get_root_global_p_p_s 1227
+get_root_global_p_pc_s 1228
+get_root_global_p_p_sc 1229
+get_root_global_p_pc_sc 1230
+set_global_s_p 1231
+set_global_sc_p 1232
+set_global_p_s_p 1233
+set_global_pc_s_p 1234
+set_global_p_sc_p 1235
+set_global_pc_sc_p 1236
+set_hll_global_s_p 1237
+set_hll_global_sc_p 1238
+set_hll_global_p_s_p 1239
+set_hll_global_pc_s_p 1240
+set_hll_global_p_sc_p 1241
+set_hll_global_pc_sc_p 1242
+set_root_global_s_p 1243
+set_root_global_sc_p 1244
+set_root_global_p_s_p 1245
+set_root_global_pc_s_p 1246
+set_root_global_p_sc_p 1247
+set_root_global_pc_sc_p 1248
+find_name_p_s 1249
+find_name_p_sc 1250
+find_sub_not_null_p_s 1251
+find_sub_not_null_p_sc 1252
Deleted: branches/kill_jit/src/ops/pic.ops
==============================================================================
--- branches/kill_jit/src/ops/pic.ops Wed Sep 16 21:22:58 2009 (r41308)
+++ /dev/null 00:00:00 1970 (deleted)
@@ -1,323 +0,0 @@
-/*
- * $Id$
-** pic.ops
-*/
-
-BEGIN_OPS_PREAMBLE
-#include "parrot/oplib/ops.h"
-#include "../src/pmc/pmc_fixedintegerarray.h"
-
-typedef opcode_t* (*interface_f)(Interp*, INTVAL*, void **);
-END_OPS_PREAMBLE
-
-=head1 NAME
-
-pic.ops - PIC (Polymorphic Inline Cache) Opcodes [deprecated]
-
-=cut
-
-=head1 DESCRIPTION
-
-During predereferencing opcodes that allow caching are rewritten so that
-equivalent opcodes in this file are used. User code MUST never emit these
-opcodes directly.
-
-=head2 General infix operations
-
-These operations take an infix operation number and PMC arguments.
-
-=cut
-
-=over 4
-
-=item B<pic_infix__>(inconst INT, invar PMC, invar PMC)
-
-One for fun and MOPS.
-
-=cut
-
-inline op pic_infix__(inconst INT, invar PMC, invar PMC) :pic :flow {
- Parrot_MIC *mic;
- Parrot_PIC_lru *lru;
- PMC *left, *right;
- INTVAL lr_types;
-
- mic = (Parrot_MIC *) cur_opcode[1];
- left = $2;
- right = $3;
- lru = &mic->lru;
- lr_types = (VTABLE_type(interp, left) << 16) | VTABLE_type(interp, right);
- if (lru->u.type == lr_types) {
-runit_v_pp:
- ((mmd_f_v_pp)lru->f.real_function)(interp, left, right);
- goto NEXT();
- }
- if (mic->pic) {
- lru = mic->pic->lru;
- if (lru->u.type == lr_types)
- goto runit_v_pp;
- if (++lru->u.type == lr_types)
- goto runit_v_pp;
- if (++lru->u.type == lr_types)
- goto runit_v_pp;
- mic->pic->miss_count++;
- /*
- * RT#42353 if we got too often here just do a dynamic lookup
- */
- }
- parrot_pic_find_infix_v_pp(interp, left, right, mic, cur_opcode);
- /* rerun this opcode */
- goto OFFSET(0);
-}
-
-=item B<pic_inline_sub__>(inconst INT, invar PMC, invar PMC)
-
-And for more fun an inlined variant too.
-
-=cut
-
-inline op pic_inline_sub__(inconst INT, invar PMC, invar PMC) :pic {
- Parrot_MIC *mic;
- Parrot_PIC_lru *lru;
- PMC *left, *right;
- INTVAL lr_types, lt, rt;
-
- left = $2;
- mic = (Parrot_MIC *) cur_opcode[1];
- lt = VTABLE_type(interp, left);
- right = $3;
- lru = &mic->lru;
- rt = VTABLE_type(interp, right);
- lr_types = (lt << 16) | rt;
- if (lru->u.type == lr_types) {
- INTVAL a = VTABLE_get_integer(interp, left);
- INTVAL b = VTABLE_get_integer(interp, right);
- INTVAL c = a - b;
- if ((c^a) >= 0 || (c^~b) >= 0) {
- VTABLE_set_integer_native(interp, left, c);
- }
- else {
- if (PARROT_ERRORS_test(interp, PARROT_ERRORS_OVERFLOW_FLAG)) {
- opcode_t *handler = Parrot_ex_throw_from_op_args(interp, NULL,
- EXCEPTION_ERR_OVERFLOW,
- "Integer overflow");
- goto ADDRESS(handler);
- }
- /* #RT42354 preserve type system */
- VTABLE_morph(interp, left, interp->vtables[enum_class_BigInt]->pmc_class);
- VTABLE_set_integer_native(interp, left, a);
- $2 = VTABLE_subtract_int(interp, left, b, left);
- }
- }
- else {
- ((void**)cur_opcode)[0] =
- parrot_pic_opcode(interp, PARROT_OP_pic_infix___ic_p_p);
- goto OFFSET(0);
- }
-}
-
-=item B<pic_get_params__>(inconst PMC /* , ... */)
-
-Fetch function parameters for this subroutine.
-
-=item B<pic_set_returns__>(inconst PMC /* , ... */)
-
-Return values to caller.
-
-=cut
-
-inline op pic_get_params__(inconst PMC) :pic :flow {
- Parrot_MIC *mic;
- Parrot_PIC_lru *lru;
- PMC *sig, *ccont;
- opcode_t *src_pc;
- void **src_pred;
- PMC *caller_ctx, *ctx;
- int n;
-
- /* avoid load dependencies - intermix derefs
- * - yes, confusing but faster
- */
- ctx = CURRENT_CONTEXT(interp);
- src_pc = interp->current_args;
- mic = (Parrot_MIC *) cur_opcode[1];
- caller_ctx = Parrot_pcc_get_caller_ctx(interp, ctx);
- if (src_pc) {
- src_pred = (void**) src_pc - Parrot_pcc_get_pred_offset(interp, caller_ctx);
- sig = (PMC*)(src_pred[1]);
- }
- else {
- sig = NULL;
- src_pred = NULL; /* just for gcc */
- }
- lru = &mic->lru;
- if (lru->u.signature == sig) {
- if (sig) {
- n = ((arg_pass_f)lru->f.real_function)(interp, sig,
- (char*)Parrot_pcc_get_regs_ni(interp, caller_ctx)->regs_i, src_pred,
- _reg_base, (void**)cur_opcode);
- }
- else
- n = 2;
- ccont = Parrot_pcc_get_continuation(interp, ctx);
- if (PObj_get_FLAGS(ccont) & SUB_FLAG_TAILCALL) {
- PObj_get_FLAGS(ccont) &= ~SUB_FLAG_TAILCALL;
- Parrot_pcc_dec_recursion_depth(interp, ctx);
- Parrot_pcc_set_caller_ctx(interp, ctx,
- Parrot_pcc_get_caller_ctx(interp, caller_ctx));
- interp->current_args = NULL;
- }
-
- goto OFFSET(n);
- }
- /* no match redo plain opcode */
- ((void**)cur_opcode)[0] =
- parrot_pic_opcode(interp, PARROT_OP_get_params_pc);
- ((void**)cur_opcode)[1] = mic->m.sig;
- goto OFFSET(0);
-}
-
-inline op pic_set_returns__(inconst PMC) :pic :flow {
- Parrot_MIC *mic;
- Parrot_PIC_lru *lru;
- PMC *sig, *ccont;
- opcode_t *dest_pc;
- void **dest_pred;
- PMC *caller_ctx, *ctx;
- Parrot_Continuation_attributes *cc;
- int n;
-
- ctx = CURRENT_CONTEXT(interp);
- mic = (Parrot_MIC *) cur_opcode[1];
- ccont = Parrot_pcc_get_continuation(interp, ctx);
- cc = PMC_cont(ccont);
- if (!cc->address) {
- interp->current_returns = CUR_OPCODE;
- n = VTABLE_get_integer(interp, mic->m.sig);
- goto OFFSET(n + 2);
- }
- caller_ctx = cc->to_ctx;
- interp->current_args = NULL;
- dest_pc = Parrot_pcc_get_results(interp, caller_ctx);
- if (dest_pc) {
- dest_pred = (void**) dest_pc - Parrot_pcc_get_pred_offset(interp, caller_ctx);
- sig = (PMC*)(dest_pred[1]);
- }
- else {
- sig = NULL;
- dest_pred = NULL;
- }
- lru = &mic->lru;
- if (lru->u.signature == sig) {
- if (sig) {
- n = ((arg_pass_f)lru->f.real_function)(interp, mic->m.sig,
- _reg_base, (void**)cur_opcode,
- (char*)Parrot_pcc_get_regs_ni(interp, caller_ctx)->regs_i, dest_pred);
- }
- else
- n = 2;
- goto OFFSET(n);
- }
- /* no match redo plain opcode */
- ((void**)cur_opcode)[0] =
- parrot_pic_opcode(interp, PARROT_OP_set_returns_pc);
- ((void**)cur_opcode)[1] = mic->m.sig;
- goto OFFSET(0);
-}
-
-=item B<pic_callr__>(inconst PMC)
-
-Call the function $1 as C<pc = func(interp, 0, **args)>. args[0] holds the
-address of the function result, args[1..] are function arguments, both
-according to the C<get_results> and C<set_args> opcodes. The function is
-a C interface function (or NCI) or a JITed PIR function. args[n+1] holds the
-C<pc> of the next opcode and is usually just returned.
-
-=cut
-
-inline op pic_callr__(inconst PMC) :pic :flow {
- Parrot_MIC *mic;
- Parrot_PIC_lru *lru;
- void *args[6]; /* RT#42355 ARG_MAX */
- PMC *ctx;
- opcode_t *pc;
- void **pred_pc;
- INTVAL i, n_args, *sig_bits;
- PMC *sig;
-
- ctx = CURRENT_CONTEXT(interp);
- mic = (Parrot_MIC *) cur_opcode[1];
- /* get_results */
- pc = Parrot_pcc_get_results(interp, ctx);
- if (pc) {
- pred_pc = (void**) pc - Parrot_pcc_get_pred_offset(interp, ctx);
- sig = (PMC*)(pred_pc[1]);
- ASSERT_SIG_PMC(sig);
- PARROT_ASSERT(VTABLE_elements(interp, sig) <= 1);
- args[0] = VTABLE_elements(interp, sig) ?
- (_reg_base + ((opcode_t*)pred_pc)[2]) : NULL;
- }
- else
- args[0] = NULL;
- /* set_args */
- n_args = 0;
- sig = mic->m.sig;
- ASSERT_SIG_PMC(sig);
- n_args = VTABLE_elements(interp, sig);
- GETATTR_FixedIntegerArray_int_array(interp, sig, sig_bits);
- for (i = 0; i < n_args; ++i) {
- switch (sig_bits[i]) {
- case PARROT_ARG_INTVAL:
- args[1 + i] = (void*)*(INTVAL*)(_reg_base +
- ((opcode_t*)cur_opcode)[2 + i]);
- break;
- case PARROT_ARG_INTVAL|PARROT_ARG_CONSTANT:
- case PARROT_ARG_FLOATVAL|PARROT_ARG_CONSTANT:
- args[1 + i] = (void**)cur_opcode[2 + i];
- break;
- case PARROT_ARG_FLOATVAL:
- args[1 + i] = (_reg_base +
- ((opcode_t*)cur_opcode)[2 + i]);
- break;
- default:
- {
- opcode_t *handler = Parrot_ex_throw_from_op_args(interp, NULL,
- EXCEPTION_INVALID_OPERATION,
- "unhandled sig_bits");
- goto ADDRESS(handler);
- }
- }
- }
- /* set_args(); set_p_pc; get_results(1), x; invokecc_p */
- pc = CUR_OPCODE + 2 + n_args + 3 + 3 + 2;
- args[1 + n_args] = pc;
- lru = &mic->lru;
- /* RT#42356 verify $1 didn't change */
- (void) ((interface_f)lru->f.real_function)(interp, sig_bits, args);
- goto ADDRESS(pc);
-}
-
-=back
-
-=cut
-
-###############################################################################
-
-=head1 COPYRIGHT
-
-Copyright (C) 2005-2008, Parrot Foundation.
-
-=head1 LICENSE
-
-This program is free software. It is subject to the same license
-as the Parrot interpreter itself.
-
-=cut
-
-
-/*
- * Local variables:
- * c-file-style: "parrot"
- * End:
- * vim: expandtab shiftwidth=4:
- */
Modified: branches/kill_jit/src/packfile.c
==============================================================================
--- branches/kill_jit/src/packfile.c Wed Sep 16 20:55:27 2009 (r41308)
+++ branches/kill_jit/src/packfile.c Wed Sep 16 21:22:58 2009 (r41309)
@@ -583,8 +583,6 @@
}
break;
case PF_UNKNOWN_SEG:
- if (memcmp(seg->name, "PIC_idx", 7) == 0)
- pf->cur_cs->pic_index = seg;
break;
case PF_DEBUG_SEG:
pf->cur_cs->debugs = (PackFile_Debug *)seg;
@@ -1771,9 +1769,6 @@
cur_cs->const_table->code = cur_cs;
- cur_cs->pic_index = create_seg(interp, &pf->directory,
- PF_UNKNOWN_SEG, "PIC_idx", file_name, add);
-
return cur_cs;
}
@@ -2569,7 +2564,6 @@
ASSERT_ARGS(byte_code_destroy)
PackFile_ByteCode * const byte_code = (PackFile_ByteCode *)self;
- parrot_PIC_destroy(byte_code);
if (byte_code->prederef.code) {
Parrot_free_memalign(byte_code->prederef.code);
byte_code->prederef.code = NULL;
@@ -2582,7 +2576,6 @@
byte_code->fixups = NULL;
byte_code->const_table = NULL;
- byte_code->pic_index = NULL;
byte_code->debugs = NULL;
}
Modified: branches/kill_jit/src/parrot_debugger.c
==============================================================================
--- branches/kill_jit/src/parrot_debugger.c Wed Sep 16 20:55:27 2009 (r41308)
+++ branches/kill_jit/src/parrot_debugger.c Wed Sep 16 21:22:58 2009 (r41309)
@@ -145,6 +145,7 @@
#include "../compilers/imcc/parser.h"
#include "parrot/embed.h"
#include "parrot/debugger.h"
+#include "parrot/runcore_api.h"
static void PDB_printwelcome(void);
static void PDB_run_code(PARROT_INTERP, int argc, char *argv[]);
Modified: branches/kill_jit/src/pbc_merge.c
==============================================================================
--- branches/kill_jit/src/pbc_merge.c Wed Sep 16 20:55:27 2009 (r41308)
+++ branches/kill_jit/src/pbc_merge.c Wed Sep 16 21:22:58 2009 (r41309)
@@ -140,19 +140,6 @@
__attribute__nonnull__(1)
__attribute__nonnull__(2);
-static void pbc_merge_pic_index(PARROT_INTERP,
- ARGMOD(pbc_merge_input **inputs),
- int num_inputs,
- ARGMOD(PackFile *pf),
- ARGMOD(PackFile_ByteCode *bc))
- __attribute__nonnull__(1)
- __attribute__nonnull__(2)
- __attribute__nonnull__(4)
- __attribute__nonnull__(5)
- FUNC_MODIFIES(*inputs)
- FUNC_MODIFIES(*pf)
- FUNC_MODIFIES(*bc);
-
static void pbc_merge_write(PARROT_INTERP,
ARGMOD(PackFile *pf),
ARGIN(const char *filename))
@@ -192,11 +179,6 @@
#define ASSERT_ARGS_pbc_merge_loadpbc __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp) \
|| PARROT_ASSERT_ARG(fullname)
-#define ASSERT_ARGS_pbc_merge_pic_index __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(inputs) \
- || PARROT_ASSERT_ARG(pf) \
- || PARROT_ASSERT_ARG(bc)
#define ASSERT_ARGS_pbc_merge_write __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp) \
|| PARROT_ASSERT_ARG(pf) \
@@ -653,59 +635,6 @@
/*
-=item C<static void pbc_merge_pic_index(PARROT_INTERP, pbc_merge_input **inputs,
-int num_inputs, PackFile *pf, PackFile_ByteCode *bc)>
-
-This function merges the pic_index segments from the input PBC files.
-
-=cut
-
-*/
-
-static void
-pbc_merge_pic_index(PARROT_INTERP, ARGMOD(pbc_merge_input **inputs),
- int num_inputs, ARGMOD(PackFile *pf), ARGMOD(PackFile_ByteCode *bc))
-{
- ASSERT_ARGS(pbc_merge_pic_index)
- int i;
- PackFile_Segment *pic_index;
- size_t size;
- opcode_t cursor = 0;
- opcode_t start = 0;
- opcode_t last = 0;
-
- /* calc needed size */
- for (i = 0, size = 0; i < num_inputs; i++) {
- PackFile_Segment * const in_seg = inputs[i]->pf->cur_cs->pic_index;
- size += in_seg->size;
- }
- pic_index = PackFile_Segment_new_seg(interp,
- &pf->directory, PF_UNKNOWN_SEG, "PIC_idx_MERGED", 1);
- pic_index->data
- = (opcode_t *)mem_sys_allocate_zeroed(size * sizeof (opcode_t));
- pic_index->size = size;
-
- for (i = 0, size = 0; i < num_inputs; i++) {
- PackFile_Segment * const in_seg = inputs[i]->pf->cur_cs->pic_index;
- size_t j;
- /*
- * pic_index is 0 or an ever increasing (by 1) number
- */
- for (j = 0; j < in_seg->size; j++) {
- const opcode_t k = in_seg->data[j];
- if (k) {
- pic_index->data[cursor] = k + start;
- last = k;
- }
- cursor++;
- }
- start = last;
- }
- bc->pic_index = pic_index;
-}
-
-/*
-
=item C<static void pbc_merge_ctpointers(PARROT_INTERP, pbc_merge_input
**inputs, int num_inputs, PackFile_ByteCode *bc)>
@@ -822,7 +751,6 @@
pbc_merge_fixups(interp, inputs, num_inputs, merged, bc);
pbc_merge_debugs(interp, inputs, num_inputs, merged, bc);
- pbc_merge_pic_index(interp, inputs, num_inputs, merged, bc);
/* Walk bytecode and fix ops that reference the constants table. */
pbc_merge_ctpointers(interp, inputs, num_inputs, bc);
Deleted: branches/kill_jit/src/pic_jit.c
==============================================================================
--- branches/kill_jit/src/pic_jit.c Wed Sep 16 21:22:58 2009 (r41308)
+++ /dev/null 00:00:00 1970 (deleted)
@@ -1,605 +0,0 @@
-/*
-Copyright (C) 2006-2009, Parrot Foundation.
-$Id$
-
-=head1 NAME
-
-src/pic_jit.c - Polymorphic Inline Cache to JIT compilation
-
-=head1 DESCRIPTION
-
-Some statically known and simple subroutines are replaced by
-their JITted variants, if
-
- - JIT is supported and can JIT subroutines
- - arguments passing is simple
- - the code is fully JITtable
- - and more such checks
-
-TODO:
-
- - save jit_info in sub
- - check for multiple calls to the same sub
- either reuse code or create new
- - handle void calls/returns
-
-=head2 Functions
-
-=over 4
-
-=cut
-
-*/
-
-#include "parrot/parrot.h"
-#include "parrot/oplib/ops.h"
-#include "pmc/pmc_sub.h"
-#include "parrot/runcore_api.h"
-
-/* HEADERIZER HFILE: include/parrot/pic.h */
-
-/* HEADERIZER BEGIN: static */
-/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
-
-PARROT_WARN_UNUSED_RESULT
-static int args_match_params(PARROT_INTERP,
- ARGIN(PMC *sig_args),
- ARGIN(const PackFile_ByteCode *seg),
- ARGIN(const opcode_t *start))
- __attribute__nonnull__(1)
- __attribute__nonnull__(2)
- __attribute__nonnull__(3)
- __attribute__nonnull__(4);
-
-PARROT_WARN_UNUSED_RESULT
-static int call_is_safe(PARROT_INTERP,
- ARGIN(PMC *sub_pmc),
- ARGMOD(opcode_t **set_args))
- __attribute__nonnull__(1)
- __attribute__nonnull__(2)
- __attribute__nonnull__(3)
- FUNC_MODIFIES(*set_args);
-
-PARROT_WARN_UNUSED_RESULT
-static int jit_can_compile_sub(PARROT_INTERP, ARGIN(PMC *sub_pmc))
- __attribute__nonnull__(1)
- __attribute__nonnull__(2);
-
-PARROT_WARN_UNUSED_RESULT
-static int ops_jittable(PARROT_INTERP,
- ARGIN(PMC *sub),
- ARGIN(PMC *sig_results),
- ARGIN(const PackFile_ByteCode *seg),
- ARGIN(opcode_t *pc),
- ARGIN(const opcode_t *end),
- ARGOUT(int *flags))
- __attribute__nonnull__(1)
- __attribute__nonnull__(2)
- __attribute__nonnull__(3)
- __attribute__nonnull__(4)
- __attribute__nonnull__(5)
- __attribute__nonnull__(6)
- __attribute__nonnull__(7)
- FUNC_MODIFIES(*flags);
-
-PARROT_WARN_UNUSED_RESULT
-PARROT_CAN_RETURN_NULL
-static opcode_t * pic_test_func(PARROT_INTERP,
- SHIM(INTVAL *sig_bits),
- ARGOUT(void **args))
- __attribute__nonnull__(1)
- __attribute__nonnull__(3)
- FUNC_MODIFIES(*args);
-
-PARROT_WARN_UNUSED_RESULT
-static int returns_match_results(PARROT_INTERP,
- ARGIN(PMC *sig_ret),
- ARGIN(PMC *sig_result))
- __attribute__nonnull__(1)
- __attribute__nonnull__(2)
- __attribute__nonnull__(3);
-
-#define ASSERT_ARGS_args_match_params __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(sig_args) \
- || PARROT_ASSERT_ARG(seg) \
- || PARROT_ASSERT_ARG(start)
-#define ASSERT_ARGS_call_is_safe __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(sub_pmc) \
- || PARROT_ASSERT_ARG(set_args)
-#define ASSERT_ARGS_jit_can_compile_sub __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(sub_pmc)
-#define ASSERT_ARGS_ops_jittable __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(sub) \
- || PARROT_ASSERT_ARG(sig_results) \
- || PARROT_ASSERT_ARG(seg) \
- || PARROT_ASSERT_ARG(pc) \
- || PARROT_ASSERT_ARG(end) \
- || PARROT_ASSERT_ARG(flags)
-#define ASSERT_ARGS_pic_test_func __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(args)
-#define ASSERT_ARGS_returns_match_results __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(sig_ret) \
- || PARROT_ASSERT_ARG(sig_result)
-/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
-/* HEADERIZER END: static */
-
-
-#ifdef HAVE_COMPUTED_GOTO
-# include "parrot/oplib/core_ops_cgp.h"
-#endif
-
-#ifdef HAS_JIT
-# include "parrot/exec.h"
-# include "jit.h"
-
-extern const jit_arch_info *
-Parrot_jit_init(PARROT_INTERP);
-
-
-# ifdef PIC_TEST
-/*
- * just for testing the whole scheme ...
-
-
-.sub main :main
- .local int i
- i = 32
- i = __pic_test(i, 10)
- print i
- print "\n"
-.end
-.sub __pic_test
- .param int i
- .param int j
- $I0 = i + j
- .return ($I0)
-.end
-... prints 42, if PIC_TEST is 1, because the C function is called
- with cgp and switch runcores.
-*/
-
-/*
-
-=item C<static opcode_t * pic_test_func(PARROT_INTERP, INTVAL *sig_bits, void
-**args)>
-
-Determines whether the given subroutine C<sub> can be JIT'd. Counts the
-number of registers used by the sub, and returns C<0> if more registers
-are used then JIT supports. Returns 1 if it does not use too many registers.
-
-=cut
-
-*/
-
-PARROT_WARN_UNUSED_RESULT
-PARROT_CAN_RETURN_NULL
-static opcode_t *
-pic_test_func(PARROT_INTERP, SHIM(INTVAL *sig_bits), ARGOUT(void **args))
-{
- ASSERT_ARGS(pic_test_func)
- INTVAL * const result = (INTVAL*) args[0];
- INTVAL const i = (INTVAL) args[1];
- INTVAL const j = (INTVAL) args[2];
-
- *result = i + j;
-
- return args[3];
-}
-# endif
-
-/*
-
-=item C<static int jit_can_compile_sub(PARROT_INTERP, PMC *sub_pmc)>
-
-Determines whether the given subroutine C<sub> can be JIT'd. Counts the
-number of registers used by the sub, and returns C<0> if more registers
-are used then JIT supports. Returns 1 if it does not use too many registers.
-
-=cut
-
-*/
-
-PARROT_WARN_UNUSED_RESULT
-static int
-jit_can_compile_sub(PARROT_INTERP, ARGIN(PMC *sub_pmc))
-{
- ASSERT_ARGS(jit_can_compile_sub)
- const jit_arch_info * const info = Parrot_jit_init(interp);
- const jit_arch_regs * const regs = info->regs + JIT_CODE_SUB_REGS_ONLY;
- INTVAL *n_regs_used;
- Parrot_Sub_attributes *sub;
-
- PMC_get_sub(interp, sub_pmc, sub);
- n_regs_used = sub->n_regs_used;
-
- /* if the sub is using more regs than the arch has
- * we don't JIT it at all
- */
- if (n_regs_used[REGNO_INT] > regs->n_mapped_I)
- return 0;
-
- if (n_regs_used[REGNO_NUM] > regs->n_mapped_F)
- return 0;
-
- /* if the Sub is using S regs, we can't JIT it yet */
- if (n_regs_used[REGNO_STR])
- return 0;
-
- /* if the Sub is using more than 1 P reg, we can't JIT it yet
- * the P reg could be a (recursive) call to a sub
- */
- if (n_regs_used[REGNO_PMC] > 1)
- return 0;
-
- return 1;
-}
-
-
-/*
-
-=item C<static int args_match_params(PARROT_INTERP, PMC *sig_args, const
-PackFile_ByteCode *seg, const opcode_t *start)>
-
-Returns C<1> if the passed arguments match the subroutine's parameter list.
-Returns C<0> otherwise.
-
-=cut
-
-*/
-
-PARROT_WARN_UNUSED_RESULT
-static int
-args_match_params(PARROT_INTERP, ARGIN(PMC *sig_args), ARGIN(const PackFile_ByteCode *seg),
- ARGIN(const opcode_t *start))
-{
- ASSERT_ARGS(args_match_params)
- PMC *sig_params;
- int n, type;
-
- if (*start != PARROT_OP_get_params_pc)
- return 0;
-
- sig_params = seg->const_table->constants[start[1]]->u.key;
-
- /* verify that we actually can pass arguments */
- ASSERT_SIG_PMC(sig_params);
-
- n = parrot_pic_check_sig(interp, sig_args, sig_params, &type);
-
- /* arg count mismatch */
- if (n == -1)
- return 0;
-
- /* no args - this would be safe, if the JIT code could already
- * deal with no args
- * TODO
- */
- if (!n)
- return 0;
-
- switch (type & ~PARROT_ARG_CONSTANT) {
- case PARROT_ARG_INTVAL:
- case PARROT_ARG_FLOATVAL:
- return 1;
- default:
- return 0;
- }
-}
-
-/*
-
-=item C<static int returns_match_results(PARROT_INTERP, PMC *sig_ret, PMC
-*sig_result)>
-
-Returns 1 if the return values match the returned results. Returns C<0>
-otherwise.
-
-=cut
-
-*/
-
-PARROT_WARN_UNUSED_RESULT
-static int
-returns_match_results(PARROT_INTERP, ARGIN(PMC *sig_ret), ARGIN(PMC *sig_result))
-{
- ASSERT_ARGS(returns_match_results)
- int type;
- const int n = parrot_pic_check_sig(interp, sig_ret, sig_result, &type);
-
- /* arg count mismatch */
- if (n == -1)
- return 0;
-
- /* no args - this would be safe, if the JIT code could already
- * deal with no args
- * TODO
- */
- if (!n)
- return 0;
-
- switch (type & ~PARROT_ARG_CONSTANT) {
- case PARROT_ARG_INTVAL:
- case PARROT_ARG_FLOATVAL:
- return 1;
- default:
- return 0;
- }
-}
-
-/*
-
-=item C<static int call_is_safe(PARROT_INTERP, PMC *sub_pmc, opcode_t
-**set_args)>
-
-Returns C<1> if the passed arguments match the subroutine's parameter list.
-Returns C<0> otherwise.
-
-=cut
-
-*/
-
-PARROT_WARN_UNUSED_RESULT
-static int
-call_is_safe(PARROT_INTERP, ARGIN(PMC *sub_pmc), ARGMOD(opcode_t **set_args))
-{
- ASSERT_ARGS(call_is_safe)
- PMC *called, *sig_results;
- Parrot_Sub_attributes *sub;
- PMC *sig_args;
- opcode_t *pc = *set_args;
-
- PMC_get_sub(interp, sub_pmc, sub);
- sig_args = sub->seg->const_table->constants[pc[1]]->u.key;
-
- /* ignore the signature for now */
- pc += 2 + VTABLE_elements(interp, sig_args);
-
- if (*pc != PARROT_OP_set_p_pc)
- return 0;
-
- called = sub->seg->const_table->constants[pc[2]]->u.key;
-
- /* we can JIT just recursive subs for now */
- if (called != sub_pmc)
- return 0;
-
- pc += 3;
-
- if (*pc != PARROT_OP_get_results_pc)
- return 0;
-
- sig_results = sub->seg->const_table->constants[pc[1]]->u.key;
- pc += 2 + VTABLE_elements(interp, sig_results);
-
- if (*pc != PARROT_OP_invokecc_p)
- return 0;
-
- pc += 2;
- *set_args = pc;
-
- return 1;
-}
-
-/*
-
-=item C<static int ops_jittable(PARROT_INTERP, PMC *sub, PMC *sig_results, const
-PackFile_ByteCode *seg, opcode_t *pc, const opcode_t *end, int *flags)>
-
-Returns 1 if the return values match the returned results. Returns C<0>
-otherwise.
-
-=cut
-
-*/
-
-PARROT_WARN_UNUSED_RESULT
-static int
-ops_jittable(PARROT_INTERP, ARGIN(PMC *sub), ARGIN(PMC *sig_results),
- ARGIN(const PackFile_ByteCode *seg), ARGIN(opcode_t *pc),
- ARGIN(const opcode_t *end), ARGOUT(int *flags))
-{
- ASSERT_ARGS(ops_jittable)
- while (pc < end) {
- /* special opcodes which are handled, but not marked as JITtable */
- int i;
-
- const int op = *pc;
- const op_info_t * const op_info = interp->op_info_table + op;
- int n = op_info->op_count;
-
- switch (op) {
- case PARROT_OP_returncc:
- case PARROT_OP_get_params_pc:
- goto op_is_ok;
- break;
- case PARROT_OP_set_returns_pc:
- {
- PMC * const sig_ret = seg->const_table->constants[pc[1]]->u.key;
- if (!returns_match_results(interp, sig_ret, sig_results))
- return 0;
- }
- goto op_is_ok;
- break;
- case PARROT_OP_set_args_pc:
- /* verify call, return address after the call */
- if (!call_is_safe(interp, sub, &pc))
- return 0;
- *flags |= JIT_CODE_RECURSIVE;
- continue;
- default:
- /* non-jitted or JITted vtable */
- if (op_jit[op].extcall != 0)
- return 0;
- break;
- }
- /*
- * there are some JITted opcodes like set_s_s, which we can't
- * handle (yet)
- */
- for (i = 1; i < n; i++) {
- const int type = op_info->types[i - 1];
- switch (type) {
- case PARROT_ARG_I:
- case PARROT_ARG_N:
- case PARROT_ARG_IC:
- case PARROT_ARG_NC:
- break;
- default:
- return 0;
- }
- }
-op_is_ok:
- ADD_OP_VAR_PART(interp, seg, pc, n);
- pc += n;
- }
- return 1;
-}
-
-#endif /* HAS_JIT */
-
-
-/*
-
-=item C<int parrot_pic_is_safe_to_jit(PARROT_INTERP, PMC *sub_pmc, PMC
-*sig_args, PMC *sig_results, int *flags)>
-
-=cut
-
-*/
-
-PARROT_WARN_UNUSED_RESULT
-int
-parrot_pic_is_safe_to_jit(PARROT_INTERP, ARGIN(PMC *sub_pmc), ARGIN(PMC *sig_args),
- ARGIN(PMC *sig_results), ARGOUT(int *flags))
-{
- ASSERT_ARGS(parrot_pic_is_safe_to_jit)
-#ifdef HAS_JIT
- opcode_t *base, *start, *end;
- Parrot_Sub_attributes *sub;
-
- *flags = 0;
-
- /*
- * 0) if runcore setting doesn't contain JIT
- * forget it
- */
- if (!(PARROT_RUNCORE_JIT_OPS_TEST(interp->run_core)))
- return 0;
-
- /* 1) if the JIT system can't JIT_CODE_SUB_REGS_ONLY
- * or the sub is using too many registers
- */
- if (!jit_can_compile_sub(interp, sub_pmc))
- return 0;
-
- /*
- * 2) check if get_params is matching set_args
- */
-
- PMC_get_sub(interp, sub_pmc, sub);
- base = sub->seg->base.data;
- start = base + sub->start_offs;
- end = base + sub->end_offs;
-
- if (!args_match_params(interp, sig_args, sub->seg, start))
- return 0;
-
- /*
- * 3) verify if all opcodes are JITtable, also check set_returns
- * if it's reached
- */
- if (!ops_jittable(interp, sub_pmc, sig_results, sub->seg, start, end, flags))
- return 0;
-
- return 1;
-#else
- UNUSED(interp);
- UNUSED(sub_pmc);
- UNUSED(sig_args);
- UNUSED(sig_results);
- UNUSED(flags);
-
- return 0;
-#endif
-}
-
-/*
-
-=item C<funcptr_t parrot_pic_JIT_sub(PARROT_INTERP, PMC *sub_pmc, int flags)>
-
-=cut
-
-*/
-
-funcptr_t
-parrot_pic_JIT_sub(PARROT_INTERP, ARGIN(PMC *sub_pmc), int flags)
-{
- ASSERT_ARGS(parrot_pic_JIT_sub)
-#ifdef HAS_JIT
-# ifdef PIC_TEST
- UNUSED(interp);
- UNUSED(sub_pmc);
- return (funcptr_t) pic_test_func;
-# else
- /*
- * create JIT code - just a test
- */
- Parrot_Sub_attributes *sub;
- opcode_t *base;
- opcode_t *start;
- opcode_t *end;
- Parrot_jit_info_t *jit_info;
-
- PMC_get_sub(interp, sub_pmc, sub);
- base = sub->seg->base.data;
- start = base + sub->start_offs;
- end = base + sub->end_offs;
- /* TODO pass Sub */
-
- jit_info = parrot_build_asm(interp,
- start, end, NULL, JIT_CODE_SUB_REGS_ONLY | flags);
-
- if (!jit_info)
- return NULLfunc;
-
- return (funcptr_t) jit_info->arena.start;
-# endif
-#else
- UNUSED(interp);
- UNUSED(sub_pmc);
- UNUSED(flags);
-
- return NULLfunc;
-#endif
-}
-
-
-/*
-
-=back
-
-=head1 AUTHOR
-
-Leopold Toetsch
-
-=head1 SEE ALSO
-
-F<src/pic.c>, F<src/jit.c>, F<ops/core_ops_cgp.c>,
-F<include/parrot/pic.h>, F<ops/pic.ops>
-
-=cut
-
-*/
-
-/*
- * Local variables:
- * c-file-style: "parrot"
- * End:
- * vim: expandtab shiftwidth=4:
- */
Modified: branches/kill_jit/src/pmc/default.pmc
==============================================================================
--- branches/kill_jit/src/pmc/default.pmc Wed Sep 16 20:55:27 2009 (r41308)
+++ branches/kill_jit/src/pmc/default.pmc Wed Sep 16 21:22:58 2009 (r41309)
@@ -231,7 +231,6 @@
PMC *prop;
PMC_metadata(self) = prop = pmc_new(interp, enum_class_Hash);
- GC_WRITE_BARRIER(interp, self, NULL, prop);
propagate_std_props(interp, self, prop);
return prop;
}
Modified: branches/kill_jit/src/pmc/eval.pmc
==============================================================================
--- branches/kill_jit/src/pmc/eval.pmc Wed Sep 16 20:55:27 2009 (r41308)
+++ branches/kill_jit/src/pmc/eval.pmc Wed Sep 16 21:22:58 2009 (r41309)
@@ -211,12 +211,6 @@
cur_cs->fixups = NULL;
}
- seg = cur_cs->pic_index;
- if (seg) {
- PackFile_Segment_destroy(INTERP, seg);
- cur_cs->pic_index = NULL;
- }
-
/* XXX Commenting out this to fix TT #995 and related problems.
* May leak some memory, need further revision.
@@ -271,10 +265,6 @@
PackFile_add_segment(INTERP, &pf->directory,
(PackFile_Segment *)seg->fixups);
- if (seg->pic_index)
- PackFile_add_segment(INTERP, &pf->directory,
- (PackFile_Segment *)seg->pic_index);
-
size = PackFile_pack_size(INTERP, pf) * sizeof (opcode_t);
/*
Modified: branches/kill_jit/src/pmc/fixedpmcarray.pmc
==============================================================================
--- branches/kill_jit/src/pmc/fixedpmcarray.pmc Wed Sep 16 20:55:27 2009 (r41308)
+++ branches/kill_jit/src/pmc/fixedpmcarray.pmc Wed Sep 16 21:22:58 2009 (r41309)
@@ -549,7 +549,6 @@
_("FixedPMCArray: index out of bounds!"));
data = PMC_array(SELF);
- GC_WRITE_BARRIER(INTERP, SELF, data[key], src);
data[key] = src;
}
Modified: branches/kill_jit/src/pmc/fixedstringarray.pmc
==============================================================================
--- branches/kill_jit/src/pmc/fixedstringarray.pmc Wed Sep 16 20:55:27 2009 (r41308)
+++ branches/kill_jit/src/pmc/fixedstringarray.pmc Wed Sep 16 21:22:58 2009 (r41309)
@@ -436,7 +436,7 @@
"FixedStringArray: index out of bounds!");
GET_ATTR_str_array(INTERP, SELF, str_array);
- GC_WRITE_BARRIER(INTERP, SELF, str_array[key], value);
+
str_array[key] = value;
}
Modified: branches/kill_jit/src/pmc/resizablepmcarray.pmc
==============================================================================
--- branches/kill_jit/src/pmc/resizablepmcarray.pmc Wed Sep 16 20:55:27 2009 (r41308)
+++ branches/kill_jit/src/pmc/resizablepmcarray.pmc Wed Sep 16 21:22:58 2009 (r41309)
@@ -266,7 +266,7 @@
SELF.set_integer_native(key+1);
data = PMC_array(SELF);
- GC_WRITE_BARRIER(INTERP, SELF, data[key], src);
+
data[key] = src;
}
Modified: branches/kill_jit/src/pmc/resizablestringarray.pmc
==============================================================================
--- branches/kill_jit/src/pmc/resizablestringarray.pmc Wed Sep 16 20:55:27 2009 (r41308)
+++ branches/kill_jit/src/pmc/resizablestringarray.pmc Wed Sep 16 21:22:58 2009 (r41309)
@@ -88,7 +88,6 @@
SELF.set_integer_native(key+1);
GET_ATTR_str_array(INTERP, SELF, str_array);
- GC_WRITE_BARRIER(INTERP, SELF, str_array[key], value);
str_array[key] = value;
}
Modified: branches/kill_jit/src/pmc_freeze.c
==============================================================================
--- branches/kill_jit/src/pmc_freeze.c Wed Sep 16 20:55:27 2009 (r41308)
+++ branches/kill_jit/src/pmc_freeze.c Wed Sep 16 21:22:58 2009 (r41309)
@@ -908,11 +908,6 @@
PARROT_ASSERT(must_have_seen);
- /*
- * that's a duplicate
- if (info->container)
- GC_WRITE_BARRIER(interp, info->container, NULL, pmc);
- */
*info->thaw_ptr = pmc;
return;
}
@@ -930,19 +925,16 @@
if (!info->thaw_result)
info->thaw_result = pmc;
- else {
- if (info->container) {
- GC_WRITE_BARRIER(interp, info->container, NULL, pmc);
- }
+ else
*info->thaw_ptr = pmc;
- }
+
list_assign(interp, (List *)PMC_data(info->id_list), id, pmc, enum_type_PMC);
+
/* remember nested aggregates depth first */
list_unshift(interp, (List *)PMC_data(info->todo), pmc, enum_type_PMC);
}
-
/*
=item C<static void add_pmc_todo_list(PARROT_INTERP, PMC *pmc, visit_info
Modified: branches/kill_jit/src/runcore/cores.c
==============================================================================
--- branches/kill_jit/src/runcore/cores.c Wed Sep 16 20:55:27 2009 (r41308)
+++ branches/kill_jit/src/runcore/cores.c Wed Sep 16 21:22:58 2009 (r41309)
@@ -1030,19 +1030,11 @@
ADD_OP_VAR_PART(interp, interp->code, pc, n);
- /* count ops that need a PIC */
- if (parrot_PIC_op_is_cached(*pc))
- n_pics++;
-
pc += n;
i += n;
}
interp->code->prederef.code = temp;
-
- /* allocate pic store, which starts from 1 */
- if (n_pics)
- parrot_PIC_alloc_store(interp->code, n_pics + 1);
}
return NULL;
Modified: branches/kill_jit/src/runcore/main.c
==============================================================================
--- branches/kill_jit/src/runcore/main.c Wed Sep 16 20:55:27 2009 (r41308)
+++ branches/kill_jit/src/runcore/main.c Wed Sep 16 21:22:58 2009 (r41309)
@@ -365,8 +365,11 @@
prederef_args(pc_prederef, interp, pc, opinfo);
- if (PARROT_RUNCORE_PREDEREF_OPS_TEST(runcore))
- parrot_PIC_prederef(interp, *pc, pc_prederef, interp->run_core);
+ if (PARROT_RUNCORE_PREDEREF_OPS_TEST(runcore)) {
+ *pc_prederef = PARROT_RUNCORE_CGOTO_OPS_TEST(runcore)
+ ? ((void **)interp->op_lib->op_func_table)[*pc]
+ : (void**)*pc;
+ }
else
Parrot_ex_throw_from_c_args(interp, NULL, 1,
"Tried to prederef wrong core");
Modified: branches/kill_jit/t/tools/ops2pm/samples/core_ops.original
==============================================================================
--- branches/kill_jit/t/tools/ops2pm/samples/core_ops.original Wed Sep 16 20:55:27 2009 (r41308)
+++ branches/kill_jit/t/tools/ops2pm/samples/core_ops.original Wed Sep 16 21:22:58 2009 (r41309)
@@ -1122,7 +1122,7 @@
if ($1)
Parrot_do_dod_run(interp, 0);
else
- if (interp->arena_base->num_early_DOD_PMCs)
+ if (interp->mem_pools->num_early_DOD_PMCs)
Parrot_do_dod_run(interp, GC_lazy_FLAG);
}
@@ -1185,7 +1185,7 @@
op needs_destroy(invar PMC) {
PObj_needs_early_DOD_SET($1);
- ++interp->arena_base->num_early_DOD_PMCs;
+ ++interp->mem_pools->num_early_DOD_PMCs;
}
=back
Modified: branches/kill_jit/t/tools/pbc_dump.t
==============================================================================
--- branches/kill_jit/t/tools/pbc_dump.t Wed Sep 16 20:55:27 2009 (r41308)
+++ branches/kill_jit/t/tools/pbc_dump.t Wed Sep 16 21:22:58 2009 (r41309)
@@ -46,10 +46,10 @@
plan skip_all => "pbc_dump hasn't been built. Run make parrot_utils";
exit(0);
}
- plan tests => 7;
+ plan tests => 6;
}
-dump_output_like( <<PIR, "pir", [qr/FIXUP_t/, qr/PIC_idx/, qr/CONSTANT_t/, qr/BYTECODE_t/], 'pbc_dump basic sanity');
+dump_output_like( <<PIR, "pir", [qr/FIXUP_t/, qr/CONSTANT_t/, qr/BYTECODE_t/], 'pbc_dump basic sanity');
.sub main :main
\$I0 = 42
.end
More information about the parrot-commits
mailing list