[svn:parrot] r43819 - in branches/rm_cflags/src: . call runcore

coke at svn.parrot.org coke at svn.parrot.org
Tue Feb 9 15:24:43 UTC 2010


Author: coke
Date: Tue Feb  9 15:24:42 2010
New Revision: 43819
URL: https://trac.parrot.org/parrot/changeset/43819

Log:
Eliminate some unused variables and static functions.

Most interesting one is the string creation inside the loops in src/call/args.c
- might be worth a benchmark on trunk.

Modified:
   branches/rm_cflags/src/call/args.c
   branches/rm_cflags/src/debug.c
   branches/rm_cflags/src/embed.c
   branches/rm_cflags/src/extend.c
   branches/rm_cflags/src/packfile.c
   branches/rm_cflags/src/parrot_debugger.c
   branches/rm_cflags/src/pbc_merge.c
   branches/rm_cflags/src/pmc.c
   branches/rm_cflags/src/runcore/main.c

Modified: branches/rm_cflags/src/call/args.c
==============================================================================
--- branches/rm_cflags/src/call/args.c	Tue Feb  9 15:08:18 2010	(r43818)
+++ branches/rm_cflags/src/call/args.c	Tue Feb  9 15:24:42 2010	(r43819)
@@ -797,7 +797,6 @@
     PMC            *call_object;
     INTVAL         *int_array;
     PMC            *ctx         = CURRENT_CONTEXT(interp);
-    INTVAL          returns_pos = 0;
     INTVAL          arg_index;
     INTVAL          arg_count;
 
@@ -823,7 +822,6 @@
     GETATTR_FixedIntegerArray_int_array(interp, raw_sig, int_array);
 
     for (arg_index = 0; arg_index < arg_count; arg_index++) {
-        STRING * const signature = CONST_STRING(interp, "signature");
         const INTVAL arg_flags = int_array[arg_index];
         const INTVAL raw_index = raw_args[arg_index + 2];
 
@@ -884,7 +882,6 @@
         ARGIN(const char *sig), va_list args)
 {
     ASSERT_ARGS(Parrot_pcc_build_sig_object_from_varargs)
-    PMC         *type_tuple         = PMCNULL;
     PMC         *arg_flags     = PMCNULL;
     PMC         *return_flags  = PMCNULL;
     PMC         * const call_object = pmc_new(interp, enum_class_CallContext);
@@ -905,7 +902,6 @@
         const INTVAL type = sig[i];
 
         if (in_return_sig) {
-            STRING * const signature = CONST_STRING(interp, "signature");
             /* Returns store the original passed-in pointer so they can pass
              * the result back to the caller. */
             switch (type) {
@@ -1596,13 +1592,11 @@
     INTVAL *return_array;
     INTVAL *result_array;
     PMC    *result_sig         = NULL;
-    PMC    *ctx                = CURRENT_CONTEXT(interp);
     PMC    *named_used_list    = PMCNULL;
     PMC    *named_return_list  = PMCNULL;
     INTVAL  return_index       = 0;
     INTVAL  return_subindex    = 0;
     INTVAL  result_index       = 0;
-    INTVAL  positional_index   = 0;
     INTVAL  named_count        = 0;
     INTVAL  err_check          = 0;
     INTVAL  positional_returns = 0; /* initialized by a loop later */
@@ -2758,6 +2752,7 @@
 intval_constant_from_varargs(PARROT_INTERP, ARGIN(void *data), INTVAL index)
 {
     ASSERT_ARGS(intval_constant_from_varargs)
+    UNUSED(index);
     PARROT_ASSERT(!"Wrong call");
     return 0;
 }
@@ -2766,6 +2761,7 @@
 numval_constant_from_varargs(PARROT_INTERP, ARGIN(void *data), INTVAL index)
 {
     ASSERT_ARGS(numval_constant_from_varargs)
+    UNUSED(index);
     PARROT_ASSERT(!"Wrong call");
     return 0.0;
 }
@@ -2775,6 +2771,7 @@
 string_constant_from_varargs(PARROT_INTERP, ARGIN(void *data), INTVAL index)
 {
     ASSERT_ARGS(string_constant_from_varargs)
+    UNUSED(index);
     PARROT_ASSERT(!"Wrong call");
     return NULL;
 }
@@ -2784,6 +2781,7 @@
 pmc_constant_from_varargs(PARROT_INTERP, ARGIN(void *data), INTVAL index)
 {
     ASSERT_ARGS(pmc_constant_from_varargs)
+    UNUSED(index);
     PARROT_ASSERT(!"Wrong call");
     return PMCNULL;
 }
@@ -3150,7 +3148,6 @@
     INTVAL  int_type;
 
     Parrot_String return_flags_name = Parrot_str_new_constant(interp, "return_flags");
-    Parrot_String sig_name          = Parrot_str_new_constant(interp, "signature");
 
     full_sig = VTABLE_get_string(interp, sig_object);
     /* Append ->[T] */

Modified: branches/rm_cflags/src/debug.c
==============================================================================
--- branches/rm_cflags/src/debug.c	Tue Feb  9 15:08:18 2010	(r43818)
+++ branches/rm_cflags/src/debug.c	Tue Feb  9 15:24:42 2010	(r43819)
@@ -111,45 +111,11 @@
 static void list_breakpoints(ARGIN(PDB_t *pdb))
         __attribute__nonnull__(1);
 
-PARROT_CAN_RETURN_NULL
-PARROT_WARN_UNUSED_RESULT
-static const char * nextarg(ARGIN_NULLOK(const char *command));
-
 static void no_such_register(PARROT_INTERP,
     char register_type,
     UINTVAL register_num)
         __attribute__nonnull__(1);
 
-PARROT_CANNOT_RETURN_NULL
-PARROT_WARN_UNUSED_RESULT
-static const char * parse_int(ARGIN(const char *str), ARGOUT(int *intP))
-        __attribute__nonnull__(1)
-        __attribute__nonnull__(2)
-        FUNC_MODIFIES(*intP);
-
-PARROT_CAN_RETURN_NULL
-PARROT_WARN_UNUSED_RESULT
-static const char* parse_key(PARROT_INTERP,
-    ARGIN(const char *str),
-    ARGOUT(PMC **keyP))
-        __attribute__nonnull__(1)
-        __attribute__nonnull__(2)
-        __attribute__nonnull__(3)
-        FUNC_MODIFIES(*keyP);
-
-PARROT_CAN_RETURN_NULL
-PARROT_WARN_UNUSED_RESULT
-static const char * parse_string(PARROT_INTERP,
-    ARGIN(const char *str),
-    ARGOUT(STRING **strP))
-        __attribute__nonnull__(1)
-        __attribute__nonnull__(2)
-        __attribute__nonnull__(3)
-        FUNC_MODIFIES(*strP);
-
-PARROT_CANNOT_RETURN_NULL
-static const char * skip_command(ARGIN(const char *str))
-        __attribute__nonnull__(1);
 
 PARROT_WARN_UNUSED_RESULT
 PARROT_CANNOT_RETURN_NULL
@@ -178,22 +144,8 @@
        PARROT_ASSERT_ARG(cmd))
 #define ASSERT_ARGS_list_breakpoints __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
        PARROT_ASSERT_ARG(pdb))
-#define ASSERT_ARGS_nextarg __attribute__unused__ int _ASSERT_ARGS_CHECK = (0)
 #define ASSERT_ARGS_no_such_register __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
        PARROT_ASSERT_ARG(interp))
-#define ASSERT_ARGS_parse_int __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
-       PARROT_ASSERT_ARG(str) \
-    , PARROT_ASSERT_ARG(intP))
-#define ASSERT_ARGS_parse_key __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
-       PARROT_ASSERT_ARG(interp) \
-    , PARROT_ASSERT_ARG(str) \
-    , PARROT_ASSERT_ARG(keyP))
-#define ASSERT_ARGS_parse_string __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
-       PARROT_ASSERT_ARG(interp) \
-    , PARROT_ASSERT_ARG(str) \
-    , PARROT_ASSERT_ARG(strP))
-#define ASSERT_ARGS_skip_command __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
-       PARROT_ASSERT_ARG(str))
 #define ASSERT_ARGS_skip_whitespace __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
        PARROT_ASSERT_ARG(cmd))
 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END.  Your changes will be lost. */
@@ -741,193 +693,6 @@
 
 /*
 
-=item C<static const char * nextarg(const char *command)>
-
-Returns the position just past the current argument in the PASM instruction
-C<command>. This is not the same as C<skip_command()>, which is intended for
-debugger commands. This function is used for C<eval>.
-
-=cut
-
-*/
-
-PARROT_CAN_RETURN_NULL
-PARROT_WARN_UNUSED_RESULT
-static const char *
-nextarg(ARGIN_NULLOK(const char *command))
-{
-    ASSERT_ARGS(nextarg)
-    /* as long as the character pointed to by command is not NULL,
-     * and it is either alphanumeric, a comma or a closing bracket,
-     * continue looking for the next argument.
-     */
-    if (command) {
-        while (isalnum((unsigned char) *command) || *command == ',' || *command == ']')
-            command++;
-
-        /* eat as much space as possible */
-        command = skip_whitespace(command);
-    }
-
-    return command;
-}
-
-/*
-
-=item C<static const char * skip_command(const char *str)>
-
-Returns the pointer past the current debugger command. (This is an
-alternative to the C<skip_command()> macro above.)
-
-=cut
-
-*/
-
-PARROT_CANNOT_RETURN_NULL
-static const char *
-skip_command(ARGIN(const char *str))
-{
-    ASSERT_ARGS(skip_command)
-    /* while str is not null and it contains a command (no spaces),
-     * skip the character
-     */
-    while (*str && !isspace((unsigned char) *str))
-        str++;
-
-    /* eat all space after that */
-    return skip_whitespace(str);
-}
-
-/*
-
-=item C<static const char * parse_int(const char *str, int *intP)>
-
-Parse an C<int> out of a string and return a pointer to just after the C<int>.
-The output parameter C<intP> contains the parsed value.
-
-=cut
-
-*/
-
-PARROT_CANNOT_RETURN_NULL
-PARROT_WARN_UNUSED_RESULT
-static const char *
-parse_int(ARGIN(const char *str), ARGOUT(int *intP))
-{
-    ASSERT_ARGS(parse_int)
-    char *end;
-
-    *intP = strtol(str, &end, 0);
-
-    return end;
-}
-
-/*
-
-=item C<static const char * parse_string(PARROT_INTERP, const char *str, STRING
-**strP)>
-
-Parse a double-quoted string out of a C string and return a pointer to
-just after the string. The parsed string is converted to a Parrot
-C<STRING> and placed in the output parameter C<strP>.
-
-=cut
-
-*/
-
-PARROT_CAN_RETURN_NULL
-PARROT_WARN_UNUSED_RESULT
-static const char *
-parse_string(PARROT_INTERP, ARGIN(const char *str), ARGOUT(STRING **strP))
-{
-    ASSERT_ARGS(parse_string)
-    const char *string_start;
-
-    /* if this is not a quoted string, there's nothing to parse */
-    if (*str != '"')
-        return NULL;
-
-    /* skip the quote */
-    str++;
-
-    string_start = str;
-
-    /* parse while there's no closing quote */
-    while (*str && *str != '"') {
-        /* skip any potentially escaped quotes */
-        if (*str == '\\' && str[1])
-            str += 2;
-        else
-            str++;
-    }
-
-    /* create the output STRING */
-    *strP = string_make(interp, string_start, (UINTVAL)(str - string_start),
-        NULL, 0);
-
-    /* skip the closing quote */
-    if (*str)
-        str++;
-
-    return str;
-}
-
-/*
-
-=item C<static const char* parse_key(PARROT_INTERP, const char *str, PMC
-**keyP)>
-
-Parse an aggregate key out of a string and return a pointer to just
-after the key. Currently only string and integer keys are allowed.
-
-=cut
-
-*/
-
-PARROT_CAN_RETURN_NULL
-PARROT_WARN_UNUSED_RESULT
-static const char*
-parse_key(PARROT_INTERP, ARGIN(const char *str), ARGOUT(PMC **keyP))
-{
-    ASSERT_ARGS(parse_key)
-    /* clear output parameter */
-    *keyP = NULL;
-
-    /* make sure it's a key */
-    if (*str != '[')
-        return NULL;
-
-    /* Skip [ */
-    str++;
-
-    /* if this is a string key, create a Parrot STRING */
-    if (*str == '"') {
-        STRING *parrot_string;
-        str   = parse_string(interp, str, &parrot_string);
-        *keyP = key_new_string(interp, parrot_string);
-    }
-    /* if this is a numeric key */
-    else if (isdigit((unsigned char) *str)) {
-        int value;
-        str   = parse_int(str, &value);
-        *keyP = key_new_integer(interp, (INTVAL) value);
-    }
-    /* unsupported case; neither a string nor a numeric key */
-    else {
-        return NULL;
-    }
-
-    /* hm, but if this doesn't match, it's probably an error */
-    /* XXX str can be NULL from parse_string() */
-    if (*str != ']')
-        return NULL;
-
-    /* skip the closing brace on the key */
-    return ++str;
-}
-
-/*
-
 =item C<static void debugger_cmdline(PARROT_INTERP)>
 
 Debugger command line.
@@ -1815,10 +1580,7 @@
     /* Allocate the new break point */
     newbreak = mem_allocate_zeroed_typed(PDB_breakpoint_t);
 
-    if (command) {
-        /*command = skip_command(command);*/
-    }
-    else {
+    if (! command) {
         Parrot_ex_throw_from_c_args(interp, NULL, 1,
             "NULL command passed to PDB_set_break");
     }
@@ -3340,7 +3102,6 @@
 {
     ASSERT_ARGS(PDB_eval)
 
-    PDB_t         *pdb = interp->pdb;
     Interp *warninterp = (interp->pdb && interp->pdb->debugger) ?
         interp->pdb->debugger : interp;
     TRACEDEB_MSG("PDB_eval");

Modified: branches/rm_cflags/src/embed.c
==============================================================================
--- branches/rm_cflags/src/embed.c	Tue Feb  9 15:08:18 2010	(r43818)
+++ branches/rm_cflags/src/embed.c	Tue Feb  9 15:24:42 2010	(r43819)
@@ -32,11 +32,6 @@
 /* HEADERIZER BEGIN: static */
 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END.  Your changes will be lost. */
 
-PARROT_CANNOT_RETURN_NULL
-PARROT_OBSERVER
-static const char * op_name(PARROT_INTERP, int k)
-        __attribute__nonnull__(1);
-
 static void print_constant_table(PARROT_INTERP)
         __attribute__nonnull__(1);
 
@@ -52,8 +47,6 @@
         __attribute__nonnull__(1)
         __attribute__nonnull__(3);
 
-#define ASSERT_ARGS_op_name __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
-       PARROT_ASSERT_ARG(interp))
 #define ASSERT_ARGS_print_constant_table __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
        PARROT_ASSERT_ARG(interp))
 #define ASSERT_ARGS_print_debug __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
@@ -666,26 +659,6 @@
 
 /*
 
-=item C<static const char * op_name(PARROT_INTERP, int k)>
-
-Returns the name of the opcode.
-
-=cut
-
-*/
-
-PARROT_CANNOT_RETURN_NULL
-PARROT_OBSERVER
-static const char *
-op_name(PARROT_INTERP, int k)
-{
-    ASSERT_ARGS(op_name)
-    return interp->op_info_table[k].full_name;
-}
-
-
-/*
-
 =item C<static void print_debug(PARROT_INTERP, int status, void *p)>
 
 Prints GC info.

Modified: branches/rm_cflags/src/extend.c
==============================================================================
--- branches/rm_cflags/src/extend.c	Tue Feb  9 15:08:18 2010	(r43818)
+++ branches/rm_cflags/src/extend.c	Tue Feb  9 15:24:42 2010	(r43819)
@@ -1152,9 +1152,7 @@
     va_list     args;
     PMC        *sig_object;
     Parrot_Int  result;
-    char        return_sig  = signature[0];
     const char *arg_sig     = signature;
-    Parrot_sub *sub;
 
     arg_sig++;
     va_start(args, signature);

Modified: branches/rm_cflags/src/packfile.c
==============================================================================
--- branches/rm_cflags/src/packfile.c	Tue Feb  9 15:08:18 2010	(r43818)
+++ branches/rm_cflags/src/packfile.c	Tue Feb  9 15:24:42 2010	(r43819)
@@ -2807,7 +2807,6 @@
     const PackFile_Debug * const debug = (const PackFile_Debug *)self;
 
     opcode_t i;
-    size_t   j;
 
     default_dump_header(interp, self);
 

Modified: branches/rm_cflags/src/parrot_debugger.c
==============================================================================
--- branches/rm_cflags/src/parrot_debugger.c	Tue Feb  9 15:08:18 2010	(r43818)
+++ branches/rm_cflags/src/parrot_debugger.c	Tue Feb  9 15:24:42 2010	(r43819)
@@ -249,7 +249,7 @@
         STRING *compiler = Parrot_str_new_constant(interp, "PIR");
         STRING *errstr = NULL;
         const char source []= ".sub aux :main\nexit 0\n.end\n";
-        PMC *code = Parrot_compile_string(interp, compiler, source, &errstr);
+        Parrot_compile_string(interp, compiler, source, &errstr);
 
         if (!STRING_is_null(interp, errstr))
             Parrot_io_eprintf(interp, "%Ss\n", errstr);

Modified: branches/rm_cflags/src/pbc_merge.c
==============================================================================
--- branches/rm_cflags/src/pbc_merge.c	Tue Feb  9 15:08:18 2010	(r43818)
+++ branches/rm_cflags/src/pbc_merge.c	Tue Feb  9 15:24:42 2010	(r43819)
@@ -720,7 +720,6 @@
     ASSERT_ARGS(pbc_merge_begin)
     PackFile_ByteCode   *bc;
     PackFile_ConstTable *ct;
-    opcode_t             const_count = 0;
     int                  i;
 
     /* Create a new empty packfile. */

Modified: branches/rm_cflags/src/pmc.c
==============================================================================
--- branches/rm_cflags/src/pmc.c	Tue Feb  9 15:08:18 2010	(r43818)
+++ branches/rm_cflags/src/pmc.c	Tue Feb  9 15:24:42 2010	(r43819)
@@ -252,7 +252,7 @@
 
     ASSERT_ARGS(pmc_reuse_no_init)
     VTABLE *new_vtable;
-    INTVAL  has_ext, new_flags = 0;
+    INTVAL  new_flags = 0;
 
     if (pmc->vtable->base_type == new_type)
         return pmc;

Modified: branches/rm_cflags/src/runcore/main.c
==============================================================================
--- branches/rm_cflags/src/runcore/main.c	Tue Feb  9 15:08:18 2010	(r43818)
+++ branches/rm_cflags/src/runcore/main.c	Tue Feb  9 15:24:42 2010	(r43819)
@@ -800,15 +800,14 @@
     const size_t n_tot    = n_old + n_new;
     op_func_t   *ops_addr = NULL;
     op_lib_t    *cg_lib   = init_func(1);
-    op_lib_t    *new_lib;
 
 #if 0
     /* related to CG and CGP ops issue below */
+    op_lib_t    *new_lib;
     STRING *op_variant;
-#endif
-
     oplib_init_f new_init_func;
     PMC *lib_variant;
+#endif
 
     if (cg_lib->flags & OP_FUNC_IS_ALLOCATED) {
         ops_addr = (op_func_t *)mem_sys_realloc(cg_lib->op_func_table,


More information about the parrot-commits mailing list