Newsgroups: perl.perl6.internals Date: Thu, 22 Jan 2004 14:35:54 -0500 Subject: Re: Another GC bug From: [EMAIL PROTECTED] (Dan Sugalski)
Attached is the slightly modified version of c2str.pl. This generates a string "resource" file from _S("string") macros.
I've modified src/objects.c to use these macros for get_init_meth (when CALL__BUILD is enabled):
$ perl c2str.pl src/objects.c > src/objects.str $ make -s $ time CALL__BUILD=1 parrot -j oo2b.pasm
real 0m3.229s # w #include "objects.str" real 0m3.950s # w string_make
So:
1) Can we make that compile silently?
2) Do all compilers understand this struct initializer?
3) How can we best integrate such a solution into the build process (not all files - or better only a few files will need pre-processing)?
Comments welcome, leo
PS current __init call (oo2) is 2.7 seconds. The two additional hash lookups are rather expensive.
--- parrot/src/objects.c Thu Apr 15 16:02:02 2004 +++ parrot-leo/src/objects.c Fri Apr 16 11:49:55 2004 @@ -20,7 +20,8 @@ #include "parrot/parrot.h" #include <assert.h> - +//#include "objects.str" +#define _S(s) const_string(interpreter, s) static PMC * clone_array(Parrot_Interp interpreter, PMC *source_array) @@ -461,12 +462,11 @@ static PMC* get_init_meth(Parrot_Interp interpreter, PMC *class, - const char * init_name, STRING **meth_str) + const STRING *prop_str , STRING **meth_str) { PMC *prop; - STRING *prop_str, *meth; + STRING *meth; #if 0 - prop_str = const_string(interpreter, init_name); prop = VTABLE_getprop(interpreter, class, prop_str); if (!VTABLE_defined(interpreter, prop)) return NULL; @@ -476,7 +476,6 @@ PMC *props; if ( !(props = PMC_metadata(class))) return NULL; - prop_str = const_string(interpreter, init_name); b = hash_get_bucket(interpreter, (Hash*) PMC_struct_val(props), prop_str); if (!b) @@ -515,7 +514,8 @@ * no redispatch */ STRING *meth_str; - PMC *meth = get_init_meth(interpreter, class, "CONSTRUCT", &meth_str); + PMC *meth = get_init_meth(interpreter, class, _S("CONSTRUCT"), + &meth_str); if (meth) { if (init) Parrot_run_meth_fromc_args_save(interpreter, meth, @@ -532,7 +532,7 @@ for (i = nparents - 1; i >= 0; --i) { parent_class = VTABLE_get_pmc_keyed_int(interpreter, classsearch_array, i); - meth = get_init_meth(interpreter, parent_class, "BUILD", &meth_str); + meth = get_init_meth(interpreter, parent_class, _S("BUILD"), &meth_str); if (meth) { if (init) Parrot_run_meth_fromc_args_save(interpreter, meth, @@ -542,7 +542,7 @@ object, meth_str); } } - meth = get_init_meth(interpreter, class, "BUILD", &meth_str); + meth = get_init_meth(interpreter, class, _S("BUILD"), &meth_str); if (meth) { if (init) Parrot_run_meth_fromc_args_save(interpreter, meth,
c2str.pl
Description: Perl program
newclass P1, "Foo" new P2, .PerlString set P2, "init" setprop P1, "BUILD", P2 addattribute P1, ".i" addattribute P1, ".j"
set I10, 0 set I11, 500000 find_type I12, "Foo" loop: new P3, I12 inc I10 lt I10, I11, loop new P3, I12 classoffset I0, P3, "Foo" getattribute P2, P3, I0 print P2 print "\n" end .namespace ["Foo"] .pcc_sub init: classoffset I0, P2, "Foo" new P10, .PerlInt set P10, 10 setattribute P2, I0, P10 inc I0 new P10, .PerlInt set P10, 20 setattribute P2, I0, P10 invoke P1