develooper Front page | perl.cvs.parrot | Postings from November 2008

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

From:
chromatic
Date:
November 13, 2008 22:33
Subject:
[svn:parrot] r32633 - trunk/compilers/imcc
Message ID:
20081114063327.C82C0CB9AF@x12.develooper.com
Author: chromatic
Date: Thu Nov 13 22:33:26 2008
New Revision: 32633

Modified:
   trunk/compilers/imcc/pbc.c

Log:
[IMCC] Added code to clear global symbols when running a PIR sub with a pragma
at the end of its compilation in IMCC.  This fixes the problem described in RT
#60000 (reported by Klass-Jan Stol, where an :immediate sub which uses
load_bytecode to load another PIR file often crashes).

This is not a beautiful fix; the right approach is to reset the color of all
constant SymRegs stored in IMCC_INFO(interp)->ghash to -1 before running the
immediate subs, but this fixes the problem for now.  Working trumps pretty at
the moment; pretty can come soon.

Modified: trunk/compilers/imcc/pbc.c
==============================================================================
--- trunk/compilers/imcc/pbc.c	(original)
+++ trunk/compilers/imcc/pbc.c	Thu Nov 13 22:33:26 2008
@@ -268,8 +268,8 @@
             (PackFile_Constant **)mem_sys_allocate(newcount * sizeof (PackFile_Constant *));
     }
 
-    interp->code->const_table->constants[newcount - 1] = new_constant;
-    interp->code->const_table->const_count             = newcount;
+    interp->code->const_table->constants[oldcount] = new_constant;
+    interp->code->const_table->const_count         = newcount;
 
     return oldcount;
 }
@@ -1688,13 +1688,24 @@
     pragma = ins->symregs[0]->pcc_sub->pragma;
 
     if (pragma & P_IMMEDIATE) {
-        imcc_globals *g            = IMCC_INFO(interp)->globals;
-        IMCC_INFO(interp)->globals = NULL;
+        const imcc_globals  *g           = IMCC_INFO(interp)->globals;
+        const SymReg       **data        = IMCC_INFO(interp)->ghash.data;
+        const unsigned int   size        = IMCC_INFO(interp)->ghash.size;
+        const unsigned int   entries     = IMCC_INFO(interp)->ghash.entries;
+
+        IMCC_INFO(interp)->globals       = NULL;
+        IMCC_INFO(interp)->ghash.data    = NULL;
+        IMCC_INFO(interp)->ghash.size    = 0;
+        IMCC_INFO(interp)->ghash.entries = 0;
 
         IMCC_debug(interp, DEBUG_PBC, "immediate sub '%s'",
                 ins->symregs[0]->name);
         PackFile_fixup_subs(interp, PBC_IMMEDIATE, NULL);
-        IMCC_INFO(interp)->globals = g;
+
+        IMCC_INFO(interp)->globals       = g;
+        IMCC_INFO(interp)->ghash.data    = data;
+        IMCC_INFO(interp)->ghash.size    = size;
+        IMCC_INFO(interp)->ghash.entries = entries;
     }
 
     return 0;
@@ -1789,9 +1800,9 @@
 e_pbc_emit(PARROT_INTERP, SHIM(void *param), ARGIN(const IMC_Unit *unit),
         ARGIN(const Instruction *ins))
 {
-    int        op, i;
-    int        ok = 0;
     op_info_t *op_info;
+    int        ok = 0;
+    int        op, i;
 
 #if IMC_TRACE_HIGH
     PIO_eprintf(NULL, "e_pbc_emit\n");
@@ -1985,7 +1996,7 @@
 
             /* TODO get rid of verify_signature - PIR call sigs are already
              * fixed, but PASM still needs it */
-         verify_signature(interp, ins, IMCC_INFO(interp)->pc);
+            verify_signature(interp, ins, IMCC_INFO(interp)->pc);
 
             /* emit var_args part */
             for (; i < ins->opsize - 1; ++i) {



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About