On Sun, 08 Apr 2007 12:04:37 -0700 [EMAIL PROTECTED] (Paul Cochrane) wrote:
> # New Ticket Created by Paul Cochrane > # Please include the string: [perl #42355] > # in the subject line of all future correspondence about this issue. > # <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=42355 > > > > In the file src/ops/pic.ops in the pic_callr__() op there is a todo > item which merely states: > > "ARG_MAX" > > I believe this means use the ARG_MAX macro instead of a hard-coded > number in the args[] array mentioned on this line. In short: fix. There is no ARG_MAX macro. There's a PCC_ARG_MAX macro, defined to 1024, which is probably not quite what we were looking for (the magic number in question is 6). There is already a PARROT_MAX_ARGS define in ops.h, set to 8. This function (pic_callr__) declares an array of 6 args, and does some work to copy arguments 2+ from the current opcode into this array. I don't know what the first 2 arguments do or why they were skipped, but here's a patch to clean up the magic number 6 (the cause of this ticket) as well as the magic offset number 2, which occurs in several places farther down in the function. I was warnocked on the IRC channel asking what all of this stuff was about, so it's quite probable that the macros this patch adds could have better names. (Or that I'm calculating 6 from the wrong source.) Please feel free to correct me. Anyway, here's a patch. Mark
=== include/parrot/op.h ================================================================== --- include/parrot/op.h (revision 20478) +++ include/parrot/op.h (local) @@ -15,7 +15,9 @@ #include "parrot/config.h" -#define PARROT_MAX_ARGS 8 +#define PARROT_MAX_ARGS 8 +#define PARROT_OP_ARGS_OFFSET 2 +#define PARROT_OP_ARGS (PARROT_MAX_ARGS-PARROT_OP_ARGS_OFFSET) typedef enum { PARROT_INLINE_OP, === src/ops/pic.ops ================================================================== --- src/ops/pic.ops (revision 20478) +++ src/ops/pic.ops (local) @@ -246,7 +246,7 @@ inline op pic_callr__(inconst PMC) :pic { Parrot_MIC *mic; Parrot_PIC_lru *lru; - void *args[6]; /* RT#42355 ARG_MAX */ + void *args[PARROT_OP_ARGS]; parrot_context_t *ctx; opcode_t *pc; void **pred_pc; @@ -277,15 +277,15 @@ switch (sig_bits[i]) { case PARROT_ARG_INTVAL: args[1 + i] = (void*)*(INTVAL*)(_reg_base + - ((opcode_t*)cur_opcode)[2 + i]); + ((opcode_t*)cur_opcode)[PARROT_OP_ARGS_OFFSET + i]); break; case PARROT_ARG_INTVAL|PARROT_ARG_CONSTANT: case PARROT_ARG_FLOATVAL|PARROT_ARG_CONSTANT: - args[1 + i] = (void**)cur_opcode[2 + i]; + args[1 + i] = (void**)cur_opcode[PARROT_OP_ARGS_OFFSET + i]; break; case PARROT_ARG_FLOATVAL: args[1 + i] = (_reg_base + - ((opcode_t*)cur_opcode)[2 + i]); + ((opcode_t*)cur_opcode)[PARROT_OP_ARGS_OFFSET + i]); break; default: internal_exception(1, "unhandled sig_bits");