Stack size warnings in GCC 4.7

Andrew Whitworth wknight8111 at gmail.com
Tue Jun 28 15:53:17 UTC 2011


I believe the one in spfrender.c is allocating a 4096 byte buffer on
the stack for building temporary strings. I've not been in love with
that algorithm, and there are obvious limitations if we have need more
than 4096 bytes for whatever purpose uses that buffer. We should clean
that function out eventually, it hasn't been on the radar quite yet
because nobody is bumping into the limits of it (and performance for
it hasn't been too bad).

The one in compilers/imcc/instructions.c I think does a similar thing,
allocating a large buffer on the stack for holding temporary data. I
need to double-check this. Again it's not a "problem" per se, but it
is definitely a signal that the code here is probably not up to the
level of quality that we would like.

The other instances you mentioned don't look like problems either, but
are places where an interested hacker looking for something to do
could try out refactoring the code to decrease stack usage.

--Andrew Whitworth



On Tue, Jun 28, 2011 at 1:41 AM, Andy Lester <andy at petdance.com> wrote:
>
> GCC 4.7 has a new warning to check for stack usage over a certain amount.  I added a check -Wstack-usage=500 to the compiler flags.
>
> https://github.com/parrot/parrot/commit/d990f60e7b51edc124a93d62dbb802c4dae4b6b7
>
> Here are the warnings it kicked out.  I don't see anything obviously horrible, but it's nice to have the flag there in the future.
>
>    src/debug.c: In function ‘size_t PDB_disassemble_op(Parrot_Interp, char*, size_t, const op_info_t*, const opcode_t*, PDB_file_t*, const opcode_t*, int)’:
>    src/debug.c:2884:1: warning: stack usage is 1248 bytes [-Wstack-usage=]
>
>    src/spf_render.c: In function ‘STRING* Parrot_sprintf_format(Parrot_Interp, const STRING*, SPRINTF_OBJ*)’:
>    src/spf_render.c:943:1: warning: stack usage is 4304 bytes [-Wstack-usage=]
>
>    src/pmc/default.c: In function ‘VTABLE* Parrot_default_get_vtable(Parrot_Interp)’:
>    src/pmc/default.c:3448:1: warning: stack usage is 1552 bytes [-Wstack-usage=]
>
>    compilers/imcc/imcparser.c: In function ‘int yyparse(void*, imc_info_t*)’:
>    compilers/imcc/imcparser.c:5924:1: warning: stack usage is 2528 bytes [-Wstack-usage=]
>
>    compilers/imcc/instructions.c: In function ‘int ins_print(imc_info_t*, PIOHANDLE, const Instruction*)’:
>    compilers/imcc/instructions.c:650:1: warning: stack usage is 4336 bytes [-Wstack-usage=]
>
>    compilers/imcc/optimizer.c: In function ‘Instruction* IMCC_subst_constants(imc_info_t*, IMC_Unit*, const char*, SymReg**, int, int*)’:
>    compilers/imcc/optimizer.c:1090:1: warning: stack usage is 800 bytes [-Wstack-usage=]
>
>    src/dynpmc/file.c: In function ‘void Parrot_File_nci_copy(Parrot_Interp, PMC*)’:
>    src/dynpmc/file.c:332:1: warning: stack usage is 1104 bytes [-Wstack-usage=]
>
> xoxo,
> Andy
>
> --
> Andy Lester => andy at petdance.com => www.petdance.com => AIM:petdance
>
> _______________________________________________
> http://lists.parrot.org/mailman/listinfo/parrot-dev
>


More information about the parrot-dev mailing list