Author: leo
Date: Fri Mar 10 03:16:57 2006
New Revision: 11851

Modified:
   trunk/compilers/imcc/optimizer.c
   trunk/compilers/imcc/parser_util.c
   trunk/src/register.c

Log:
PBC, context handling - 2

* Parrot_{push,pop}_context around compilation of file or string
* remove context preservation in IMCC_subst_constants
  (this could also give a nice speedup, when compiling a lot of opcodes
   with constants only)


Modified: trunk/compilers/imcc/optimizer.c
==============================================================================
--- trunk/compilers/imcc/optimizer.c    (original)
+++ trunk/compilers/imcc/optimizer.c    Fri Mar 10 03:16:57 2006
@@ -702,9 +702,6 @@
     char b[128], fmt[64], op[20];
     const char *debug_fmt = NULL;   /* gcc -O uninit warn */
     int found, branched;
-    parrot_context_t *ctx;
-    INTVAL regs_used[4] = {3,3,3,3};
-
 
     /* construct a FLOATVAL_FMT with needed precision */
     switch (NUMVAL_SIZE) {
@@ -785,9 +782,6 @@
         *ok = 0;
         return NULL;
     }
-    /* preserve registers */
-    ctx = CONTEXT(interpreter->ctx);
-    Parrot_alloc_context(interpreter, regs_used);
 
     IMCC_debug(interpreter, DEBUG_OPT1, debug_fmt, name);
     /* we construct a parrot instruction
@@ -834,13 +828,6 @@
         IMCC_debug(interpreter, DEBUG_OPT1, "%I\n", tmp);
     }
     *ok = 1;
-    /*
-     * restore and recycle register frame
-     */
-    Parrot_free_context(interpreter, CONTEXT(interpreter->ctx), 1);
-    CONTEXT(interpreter->ctx) = ctx;
-    interpreter->ctx.bp = ctx->bp;
-    interpreter->ctx.bp_ps = ctx->bp_ps;
     return tmp;
 }
 

Modified: trunk/compilers/imcc/parser_util.c
==============================================================================
--- trunk/compilers/imcc/parser_util.c  (original)
+++ trunk/compilers/imcc/parser_util.c  Fri Mar 10 03:16:57 2006
@@ -610,6 +610,7 @@
         const void * __c_ptr;
         void * __ptr;
     } __ptr_u;
+    INTVAL regs_used[4] = {3,3,3,3};
 
     /*
      * we create not yet anchored PMCs - e.g. Subs: turn off DOD
@@ -643,9 +644,11 @@
     IMCC_INFO(interp)->state->pasm_file = pasm_file;
     IMCC_INFO(interp)->state->file = name;
     expect_pasm = 0;
+    Parrot_push_context(interp, regs_used);
 
     compile_string(interp, const_cast(s));
 
+    Parrot_pop_context(interp);
     /*
      * compile_string NULLifies frames->next, so that yywrap
      * doesn't try to continue compiling the previous buffer
@@ -710,6 +713,10 @@
     char *ext;
     FILE *fp;
     struct _imc_info_t *imc_info = NULL;
+    /* need at least 3 regs for compilation of constant math e.g.
+     * add_i_ic_ic - see also IMCC_subst_constants()
+     */
+    INTVAL regs_used[4] = {3,3,3,3};
 
     if (IMCC_INFO(interp)->last_unit) {
         /* got a reentrant compile */
@@ -742,6 +749,7 @@
      * which can destroy packfiles under construction
      */
     Parrot_block_DOD(interp);
+    Parrot_push_context(interp, regs_used);
 
     if (ext && strcmp (ext, ".pasm") == 0) {
         IMCC_INFO(interp)->state->pasm_file = 1;
@@ -756,6 +764,7 @@
         compile_file(interp, fp);
     }
     Parrot_unblock_DOD(interp);
+    Parrot_pop_context(interp);
 
     imc_cleanup(interp);
     fclose(fp);

Modified: trunk/src/register.c
==============================================================================
--- trunk/src/register.c        (original)
+++ trunk/src/register.c        Fri Mar 10 03:16:57 2006
@@ -295,6 +295,8 @@
     old = CONTEXT(interpreter->ctx);
     ctx = Parrot_alloc_context(interpreter, n_regs_used);
     ctx->caller_ctx = old;
+    ctx->current_sub = old->current_sub;  /* doesn't change */
+    /* copy more ? */
     return ctx;
 }
 

Reply via email to