[svn:parrot] r46456 - trunk/compilers/imcc

plobsing at svn.parrot.org plobsing at svn.parrot.org
Mon May 10 02:51:47 UTC 2010


Author: plobsing
Date: Mon May 10 02:51:46 2010
New Revision: 46456
URL: https://trac.parrot.org/parrot/changeset/46456

Log:
all static variables in IMCC are now either marked "XXX non-reentrant" or are const

also eliminate more dead code

Modified:
   trunk/compilers/imcc/imcc.l
   trunk/compilers/imcc/imclexer.c
   trunk/compilers/imcc/instructions.c
   trunk/compilers/imcc/instructions.h
   trunk/compilers/imcc/parser_util.c
   trunk/compilers/imcc/pcc.c
   trunk/compilers/imcc/reg_alloc.c
   trunk/compilers/imcc/symreg.c

Modified: trunk/compilers/imcc/imcc.l
==============================================================================
--- trunk/compilers/imcc/imcc.l	Mon May 10 02:37:29 2010	(r46455)
+++ trunk/compilers/imcc/imcc.l	Mon May 10 02:51:46 2010	(r46456)
@@ -769,6 +769,7 @@
 
 static macro_frame_t *
 new_frame(PARROT_INTERP) {
+    /* XXX non-reentrant */
     static int label   = 0;
     macro_frame_t * const tmp = mem_gc_allocate_zeroed_typed(interp, macro_frame_t);
 

Modified: trunk/compilers/imcc/imclexer.c
==============================================================================
--- trunk/compilers/imcc/imclexer.c	Mon May 10 02:37:29 2010	(r46455)
+++ trunk/compilers/imcc/imclexer.c	Mon May 10 02:51:46 2010	(r46456)
@@ -75,6 +75,7 @@
 typedef unsigned char flex_uint8_t; 
 typedef unsigned short int flex_uint16_t;
 typedef unsigned int flex_uint32_t;
+#endif /* ! C99 */
 
 /* Limits of integral types. */
 #ifndef INT8_MIN
@@ -105,8 +106,6 @@
 #define UINT32_MAX             (4294967295U)
 #endif
 
-#endif /* ! C99 */
-
 #endif /* ! FLEXINT_H */
 
 #ifdef __cplusplus
@@ -180,15 +179,7 @@
 
 /* Size of default input buffer. */
 #ifndef YY_BUF_SIZE
-#ifdef __ia64__
-/* On IA-64, the buffer size is 16k, not 8k.
- * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case.
- * Ditto for the __ia64__ case accordingly.
- */
-#define YY_BUF_SIZE 32768
-#else
 #define YY_BUF_SIZE 16384
-#endif /* __ia64__ */
 #endif
 
 /* The state buf must be large enough to hold one state per character in the main buffer.
@@ -2554,7 +2545,7 @@
 
 
 
-#line 2558 "compilers/imcc/imclexer.c"
+#line 2549 "compilers/imcc/imclexer.c"
 
 #define INITIAL 0
 #define emit 1
@@ -2689,12 +2680,7 @@
     
 /* Amount of stuff to slurp up with each read. */
 #ifndef YY_READ_BUF_SIZE
-#ifdef __ia64__
-/* On IA-64, the buffer size is 16k, not 8k */
-#define YY_READ_BUF_SIZE 16384
-#else
 #define YY_READ_BUF_SIZE 8192
-#endif /* __ia64__ */
 #endif
 
 /* Copy whatever the last rule matched to the standard output. */
@@ -2702,7 +2688,7 @@
 /* This used to be an fputs(), but since the string might contain NUL's,
  * we now use fwrite().
  */
-#define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0)
+#define ECHO fwrite( yytext, yyleng, 1, yyout )
 #endif
 
 /* Gets input and stuffs it into "buf".  number of characters read, or YY_NULL,
@@ -2713,7 +2699,7 @@
 	if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
 		{ \
 		int c = '*'; \
-		size_t n; \
+		int n; \
 		for ( n = 0; n < max_size && \
 			     (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
 			buf[n] = (char) c; \
@@ -2818,7 +2804,7 @@
             return 0;
         }
 
-#line 2822 "compilers/imcc/imclexer.c"
+#line 2808 "compilers/imcc/imclexer.c"
 
 	if ( !yyg->yy_init )
 		{
@@ -4027,7 +4013,7 @@
 #line 740 "compilers/imcc/imcc.l"
 ECHO;
 	YY_BREAK
-#line 4031 "compilers/imcc/imclexer.c"
+#line 4017 "compilers/imcc/imclexer.c"
 case YY_STATE_EOF(pod):
 case YY_STATE_EOF(cmt1):
 case YY_STATE_EOF(cmt2):
@@ -4816,8 +4802,8 @@
 
 /** Setup the input buffer state to scan the given bytes. The next call to yylex() will
  * scan from a @e copy of @a bytes.
- * @param yybytes the byte buffer to scan
- * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes.
+ * @param bytes the byte buffer to scan
+ * @param len the number of bytes in the buffer pointed to by @a bytes.
  * @param yyscanner The scanner object.
  * @return the newly allocated buffer state object.
  */
@@ -5273,6 +5259,7 @@
 
 static macro_frame_t *
 new_frame(PARROT_INTERP) {
+    /* XXX non-reentrant */
     static int label   = 0;
     macro_frame_t * const tmp = mem_gc_allocate_zeroed_typed(interp, macro_frame_t);
 

Modified: trunk/compilers/imcc/instructions.c
==============================================================================
--- trunk/compilers/imcc/instructions.c	Mon May 10 02:37:29 2010	(r46455)
+++ trunk/compilers/imcc/instructions.c	Mon May 10 02:51:46 2010	(r46456)
@@ -117,78 +117,6 @@
     return ins;
 }
 
-
-/*
- * Some instructions don't have a hint in op_info that they work
- * on all registers or all registers of a given type (e.g., cleari)
- * These instructions need special handling at various points in the code.
- */
-
-static int w_special[1+4*3];
-
-/*
-
-=item C<void imcc_init_tables(PARROT_INTERP)>
-
-Initializes IMCC's table of opcodes, based on the list maintained
-by the Parrot interpreter. Stores the results in global variable
-C<w_special>.
-
-=cut
-
-*/
-
-void
-imcc_init_tables(PARROT_INTERP)
-{
-    ASSERT_ARGS(imcc_init_tables)
-    const char *writes[] = {
-        "cleari", "clearn", "clearp", "clears",
-    };
-    /* init opnums */
-    if (!w_special[0]) {
-        size_t i;
-        for (i = 0; i < N_ELEMENTS(writes); i++) {
-            const int n = interp->op_lib->op_code(interp, writes[i], 1);
-            PARROT_ASSERT(n);
-            w_special[i] = n;
-        }
-    }
-}
-
-/*
-
-=item C<int ins_writes2(const Instruction *ins, int t)>
-
-Returns TRUE if instruction ins writes to a register of type t
-
-=cut
-
-*/
-
-int
-ins_writes2(ARGIN(const Instruction *ins), int t)
-{
-    ASSERT_ARGS(ins_writes2)
-    const char *p;
-
-    if (ins->opnum == w_special[0])
-        return 1;
-
-    p = strchr(types, t);
-
-    if (p) {
-        const size_t idx = p - types;
-        size_t i;
-
-        for (i = 1; i < N_ELEMENTS(w_special); i += 4)
-            if (ins->opnum == w_special[i + idx])
-                return 1;
-    }
-
-    return 0;
-}
-
 /*
 
 =item C<int instruction_reads(const Instruction *ins, const SymReg *r)>

Modified: trunk/compilers/imcc/instructions.h
==============================================================================
--- trunk/compilers/imcc/instructions.h	Mon May 10 02:37:29 2010	(r46455)
+++ trunk/compilers/imcc/instructions.h	Mon May 10 02:51:46 2010	(r46456)
@@ -152,9 +152,6 @@
 int get_branch_regno(ARGIN(const Instruction *ins))
         __attribute__nonnull__(1);
 
-void imcc_init_tables(PARROT_INTERP)
-        __attribute__nonnull__(1);
-
 PARROT_IGNORABLE_RESULT
 int /*@alt void@*/
 ins_print(PARROT_INTERP,
@@ -164,9 +161,6 @@
         __attribute__nonnull__(2)
         __attribute__nonnull__(3);
 
-int ins_writes2(ARGIN(const Instruction *ins), int t)
-        __attribute__nonnull__(1);
-
 void insert_ins(
     ARGMOD(IMC_Unit *unit),
     ARGMOD_NULLOK(Instruction *ins),
@@ -246,14 +240,10 @@
        PARROT_ASSERT_ARG(ins))
 #define ASSERT_ARGS_get_branch_regno __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
        PARROT_ASSERT_ARG(ins))
-#define ASSERT_ARGS_imcc_init_tables __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
-       PARROT_ASSERT_ARG(interp))
 #define ASSERT_ARGS_ins_print __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
        PARROT_ASSERT_ARG(interp) \
     , PARROT_ASSERT_ARG(io) \
     , PARROT_ASSERT_ARG(ins))
-#define ASSERT_ARGS_ins_writes2 __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
-       PARROT_ASSERT_ARG(ins))
 #define ASSERT_ARGS_insert_ins __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
        PARROT_ASSERT_ARG(unit) \
     , PARROT_ASSERT_ARG(tmp))

Modified: trunk/compilers/imcc/parser_util.c
==============================================================================
--- trunk/compilers/imcc/parser_util.c	Mon May 10 02:37:29 2010	(r46455)
+++ trunk/compilers/imcc/parser_util.c	Mon May 10 02:51:46 2010	(r46456)
@@ -121,6 +121,7 @@
  * absolutely global to prevent the files from being overwritten.
  *
  */
+/* XXX non-reentrant */
 static Parrot_mutex eval_nr_lock;
 static INTVAL       eval_nr  = 0;
 
@@ -1158,7 +1159,7 @@
 try_rev_cmp(ARGIN(const char *name), ARGMOD(SymReg **r))
 {
     ASSERT_ARGS(try_rev_cmp)
-    static struct br_pairs {
+    static const struct br_pairs {
         PARROT_OBSERVER const char * const op;
         PARROT_OBSERVER const char * const nop;
         const int to_swap;

Modified: trunk/compilers/imcc/pcc.c
==============================================================================
--- trunk/compilers/imcc/pcc.c	Mon May 10 02:37:29 2010	(r46455)
+++ trunk/compilers/imcc/pcc.c	Mon May 10 02:51:46 2010	(r46456)
@@ -258,9 +258,9 @@
     static const char item[] = {'0', 'x', 'f', 'f', 'f', 'f', ','};
     /* The list suffix includes the '\0' terminator */
     static const char subf[] = {')', '"', '\0'};
-    static unsigned int lenpref = sizeof pref;
-    static unsigned int lenitem = sizeof item;
-    static unsigned int lensubf = sizeof subf;
+    static const unsigned int lenpref = sizeof pref;
+    static const unsigned int lenitem = sizeof item;
+    static const unsigned int lensubf = sizeof subf;
     int i, flags;
     char s[16];
 
@@ -535,6 +535,7 @@
 {
     ASSERT_ARGS(pcc_reg_mov)
     static const char types[] = "INSP";
+    /* XXX non-reentrant */
     static SymReg    *temps[4];
     move_info_t      *info    = (move_info_t *)vinfo;
     SymReg           *src     = NULL;

Modified: trunk/compilers/imcc/reg_alloc.c
==============================================================================
--- trunk/compilers/imcc/reg_alloc.c	Mon May 10 02:37:29 2010	(r46455)
+++ trunk/compilers/imcc/reg_alloc.c	Mon May 10 02:51:46 2010	(r46456)
@@ -167,7 +167,6 @@
                 (OPT_PRE|OPT_CFG|OPT_PASM)) && unit->pasm_file)
         goto done;
 
-    imcc_init_tables(interp);
     IMCC_INFO(interp)->allocated = 0;
 
 #if IMC_TRACE

Modified: trunk/compilers/imcc/symreg.c
==============================================================================
--- trunk/compilers/imcc/symreg.c	Mon May 10 02:37:29 2010	(r46455)
+++ trunk/compilers/imcc/symreg.c	Mon May 10 02:51:46 2010	(r46456)
@@ -368,6 +368,7 @@
 {
     ASSERT_ARGS(mk_temp_reg)
     char       buf[30];
+    /* XXX non-reentrant */
     static int temp;
 
     snprintf(buf, sizeof (buf), "__imcc_temp_%d", ++temp);


More information about the parrot-commits mailing list