[svn:parrot] r47826 - in branches/dynop_mapping: compilers/imcc include/parrot src src/pmc src/runcore

plobsing at svn.parrot.org plobsing at svn.parrot.org
Fri Jun 25 05:35:01 UTC 2010


Author: plobsing
Date: Fri Jun 25 05:35:00 2010
New Revision: 47826
URL: https://trac.parrot.org/parrot/changeset/47826

Log:
handle op_info

Modified:
   branches/dynop_mapping/compilers/imcc/pbc.c
   branches/dynop_mapping/include/parrot/packfile.h
   branches/dynop_mapping/src/debug.c
   branches/dynop_mapping/src/packfile.c
   branches/dynop_mapping/src/pbc_dump.c
   branches/dynop_mapping/src/pbc_merge.c
   branches/dynop_mapping/src/pmc/opcode.pmc
   branches/dynop_mapping/src/pmc/oplib.pmc
   branches/dynop_mapping/src/runcore/profiling.c
   branches/dynop_mapping/src/runcore/trace.c
   branches/dynop_mapping/src/sub.c

Modified: branches/dynop_mapping/compilers/imcc/pbc.c
==============================================================================
--- branches/dynop_mapping/compilers/imcc/pbc.c	Fri Jun 25 04:41:49 2010	(r47825)
+++ branches/dynop_mapping/compilers/imcc/pbc.c	Fri Jun 25 05:35:00 2010	(r47826)
@@ -746,6 +746,10 @@
         mem_gc_realloc_n_typed_zeroed(interp, bc->op_func_table, bc->op_count, bc->op_count,
                                         op_func_t);
     bc->op_func_table[bc->op_count - 1] = op_func;
+    bc->op_info_table =
+        mem_gc_realloc_n_typed_zeroed(interp, bc->op_info_table, bc->op_count, bc->op_count,
+                                        op_info_t *);
+    bc->op_info_table[bc->op_count - 1] = info;
 
     /* initialize new op mapping */
     om->n_ops++;

Modified: branches/dynop_mapping/include/parrot/packfile.h
==============================================================================
--- branches/dynop_mapping/include/parrot/packfile.h	Fri Jun 25 04:41:49 2010	(r47825)
+++ branches/dynop_mapping/include/parrot/packfile.h	Fri Jun 25 05:35:00 2010	(r47826)
@@ -266,14 +266,15 @@
 } PackFile_ByteCode_OpMapping;
 
 struct PackFile_ByteCode {
-    PackFile_Segment             base;
-    struct PackFile_Debug       *debugs;
-    PackFile_ConstTable         *const_table;
-    PackFile_FixupTable         *fixups;
-    struct PackFile_Annotations *annotations;
-    PackFile_ByteCode_OpMapping  op_mapping;    /* opcode mapping information */
-    size_t                       op_count;      /* number of ops in the func table */
-    op_func_t                   *op_func_table; /* opcode dispatch table */
+    PackFile_Segment              base;
+    struct PackFile_Debug        *debugs;
+    PackFile_ConstTable          *const_table;
+    PackFile_FixupTable          *fixups;
+    struct PackFile_Annotations  *annotations;
+    PackFile_ByteCode_OpMapping   op_mapping;    /* opcode mapping information */
+    size_t                        op_count;      /* number of ops in the func table */
+    op_func_t                    *op_func_table; /* opcode dispatch table */
+    op_info_t                   **op_info_table;
 };
 
 typedef struct PackFile_DebugFilenameMapping {

Modified: branches/dynop_mapping/src/debug.c
==============================================================================
--- branches/dynop_mapping/src/debug.c	Fri Jun 25 04:41:49 2010	(r47825)
+++ branches/dynop_mapping/src/debug.c	Fri Jun 25 05:35:00 2010	(r47826)
@@ -2593,14 +2593,14 @@
         }
 
         size = PDB_disassemble_op(interp, pfile->source + pfile->size,
-                space, &interp->op_info_table[*pc], pc, pfile, NULL, 1);
+                space, interp->code->op_info_table[*pc], pc, pfile, NULL, 1);
         space       -= size;
         pfile->size += size;
         pfile->source[pfile->size - 1] = '\n';
 
         /* Store the opcode of this line */
         pline->opcode = pc;
-        n             = interp->op_info_table[*pc].op_count;
+        n             = interp->code->op_info_table[*pc]->op_count;
 
         ADD_OP_VAR_PART(interp, interp->code, pc, n);
         pc += n;
@@ -2797,7 +2797,8 @@
     pfile->line   = pline;
     pline->number = 1;
 
-    PARROT_ASSERT(interp->op_info_table);
+    PARROT_ASSERT(interp->code);
+    PARROT_ASSERT(interp->code->op_info_table);
     PARROT_ASSERT(pc);
 
     while ((c = fgetc(file)) != EOF) {
@@ -2817,7 +2818,7 @@
             PDB_line_t *newline = mem_gc_allocate_zeroed_typed(interp, PDB_line_t);
 
             if (PDB_hasinstruction(pfile->source + pline->source_offset)) {
-                size_t n      = interp->op_info_table[*pc].op_count;
+                size_t n      = interp->code->op_info_table[*pc]->op_count;
                 pline->opcode = pc;
                 ADD_OP_VAR_PART(interp, interp->code, pc, n);
                 pc           += n;

Modified: branches/dynop_mapping/src/packfile.c
==============================================================================
--- branches/dynop_mapping/src/packfile.c	Fri Jun 25 04:41:49 2010	(r47825)
+++ branches/dynop_mapping/src/packfile.c	Fri Jun 25 05:35:00 2010	(r47826)
@@ -2623,6 +2623,8 @@
 
     if (byte_code->op_func_table)
         mem_gc_free(interp, byte_code->op_func_table);
+    if (byte_code->op_info_table)
+        mem_gc_free(interp, byte_code->op_info_table);
     if (byte_code->op_mapping.libs)
         mem_gc_free(interp, byte_code->op_mapping.libs);
 
@@ -2631,6 +2633,7 @@
     byte_code->debugs          = NULL;
     byte_code->op_mapping.libs = NULL;
     byte_code->op_func_table   = NULL;
+    byte_code->op_info_table   = NULL;
 }
 
 
@@ -2726,6 +2729,8 @@
     byte_code->op_count          = PF_fetch_opcode(self->pf, &cursor);
     byte_code->op_func_table     = mem_gc_allocate_n_zeroed_typed(interp,
                                         byte_code->op_count, op_func_t);
+    byte_code->op_info_table     = mem_gc_allocate_n_zeroed_typed(interp,
+                                        byte_code->op_count, op_info_t *);
 
 
     byte_code->op_mapping.n_libs = PF_fetch_opcode(self->pf, &cursor);
@@ -2804,6 +2809,7 @@
                 entry->table_ops[j]           = idx;
                 entry->lib_ops[j]             = op;
                 byte_code->op_func_table[idx] = entry->lib->op_func_table[op];
+                byte_code->op_info_table[idx] = &entry->lib->op_info_table[op];
             }
         }
     }

Modified: branches/dynop_mapping/src/pbc_dump.c
==============================================================================
--- branches/dynop_mapping/src/pbc_dump.c	Fri Jun 25 04:41:49 2010	(r47825)
+++ branches/dynop_mapping/src/pbc_dump.c	Fri Jun 25 05:35:00 2010	(r47826)
@@ -118,7 +118,7 @@
 
     while (pc < self->data + self->size) {
         /* n can't be const; the ADD_OP_VAR_PART macro increments it */
-        size_t n = (size_t)interp->op_info_table[*pc].op_count;
+        size_t n = (size_t)interp->cur_cs->op_info_table[*pc]->op_count;
         size_t i;
 
         /* trace_op_dump(interp, self->pf->src, pc); */
@@ -131,7 +131,7 @@
                 Parrot_io_printf(interp, "         ");
 
         Parrot_io_printf(interp, "%s\n",
-                interp->op_info_table[*pc].full_name);
+                interp->cur_cs->op_info_table[*pc]->full_name);
 
         ADD_OP_VAR_PART(interp, interp->code, pc, n);
         pc += n;
@@ -159,16 +159,16 @@
     const PackFile_Segment *debug      = PackFile_find_segment(interp,
                                             self->dir, debug_name, 1);
 
-    const opcode_t  * pc            = self->data;
-    const opcode_t  * debug_ops     = debug->data;
-    const op_info_t * const op_info = interp->op_info_table;
+    const opcode_t   * pc            = self->data;
+    const opcode_t   * debug_ops     = debug->data;
+    const op_info_t ** const op_info = interp->cur_cs->op_info_table;
 
     while (pc < self->data + self->size) {
         /* n can't be const; the ADD_OP_VAR_PART macro increments it */
         size_t n = (size_t)op_info[*pc].op_count;
 
         Parrot_io_printf(interp, " %04x:  %s\n",
-            *(debug_ops++), op_info[*pc].full_name);
+            *(debug_ops++), op_info[*pc]->full_name);
 
         ADD_OP_VAR_PART(interp, interp->code, pc, n);
         pc += n;

Modified: branches/dynop_mapping/src/pbc_merge.c
==============================================================================
--- branches/dynop_mapping/src/pbc_merge.c	Fri Jun 25 04:41:49 2010	(r47825)
+++ branches/dynop_mapping/src/pbc_merge.c	Fri Jun 25 05:35:00 2010	(r47826)
@@ -648,7 +648,7 @@
 
         /* Get info about this op and jump over it. */
         op_num = ops[cur_op];
-        op     = &interp->op_info_table[op_num];
+        op     = interp->cur_cs->op_info_table[op_num];
         op_ptr = ops + cur_op;
         ++cur_op;
 

Modified: branches/dynop_mapping/src/pmc/opcode.pmc
==============================================================================
--- branches/dynop_mapping/src/pmc/opcode.pmc	Fri Jun 25 04:41:49 2010	(r47825)
+++ branches/dynop_mapping/src/pmc/opcode.pmc	Fri Jun 25 05:35:00 2010	(r47826)
@@ -70,7 +70,7 @@
         if (value >= opcount || value < 0)
             Parrot_ex_throw_from_c_args(INTERP, NULL, EXCEPTION_OUT_OF_BOUNDS,
                 "Opcode: Opcode index %d out of bounds", value);
-        attrs->info = &(INTERP->op_info_table[value]);
+        attrs->info      = INTERP->code->op_info_table[value];
         attrs->op_number = value;
     }
 

Modified: branches/dynop_mapping/src/pmc/oplib.pmc
==============================================================================
--- branches/dynop_mapping/src/pmc/oplib.pmc	Fri Jun 25 04:41:49 2010	(r47825)
+++ branches/dynop_mapping/src/pmc/oplib.pmc	Fri Jun 25 05:35:00 2010	(r47826)
@@ -93,7 +93,7 @@
             Parrot_ex_throw_from_c_args(INTERP, NULL, EXCEPTION_OUT_OF_BOUNDS,
                 "OpLib: Opcode index %d out of bounds", value);
         else {
-            const char * const name   = INTERP->op_info_table[value].full_name;
+            const char * const name   = INTERP->code->op_info_table[value]->full_name;
             STRING     * const newstr = Parrot_str_new(INTERP, name, 0);
             return VTABLE_get_pmc_keyed_str(INTERP, SELF, newstr);
         }
@@ -106,12 +106,12 @@
     METHOD op_family(STRING *shortname)
     {
         char * const sname = Parrot_str_to_cstring(INTERP, shortname);
-        const op_lib_t * const op_lib = INTERP->op_lib;
-        const op_info_t * const table = op_lib->op_info_table;
+        const op_lib_t  * const op_lib = INTERP->op_lib;
+        const op_info_t ** const table = op_lib->op_info_table;
         PMC *result = PMCNULL;
         UINTVAL i;
         for (i = 0; i < op_lib->op_count; ++i) {
-            if (strcmp(table[i].name, sname) == 0) {
+            if (strcmp(table[i]->name, sname) == 0) {
                 if (PMC_IS_NULL(result))
                     result = Parrot_pmc_new(INTERP, enum_class_ResizablePMCArray);
                 VTABLE_push_pmc(INTERP, result, SELF.get_pmc_keyed_int(i));

Modified: branches/dynop_mapping/src/runcore/profiling.c
==============================================================================
--- branches/dynop_mapping/src/runcore/profiling.c	Fri Jun 25 04:41:49 2010	(r47825)
+++ branches/dynop_mapping/src/runcore/profiling.c	Fri Jun 25 05:35:00 2010	(r47826)
@@ -459,7 +459,7 @@
             pprof_data[PPROF_DATA_TIME] = op_time;
         }
         pprof_data[PPROF_DATA_LINE]   = preop_line;
-        pprof_data[PPROF_DATA_OPNAME] = (PPROF_DATA)(interp->op_info_table)[*preop_pc].name;
+        pprof_data[PPROF_DATA_OPNAME] = (PPROF_DATA)(interp->code->op_info_table)[*preop_pc]->name;
         runcore->output_fn(runcore, pprof_data, PPROF_LINE_OP);
     }
 

Modified: branches/dynop_mapping/src/runcore/trace.c
==============================================================================
--- branches/dynop_mapping/src/runcore/trace.c	Fri Jun 25 04:41:49 2010	(r47825)
+++ branches/dynop_mapping/src/runcore/trace.c	Fri Jun 25 05:35:00 2010	(r47826)
@@ -297,7 +297,7 @@
 {
     ASSERT_ARGS(trace_op_dump)
     Interp    * const debugger = debugger_or_interp(interp);
-    op_info_t * const info     = &interp->op_info_table[*pc];
+    op_info_t * const info     = interp->code->op_info_table[*pc];
     PMC *sig                   = PMCNULL;
     INTVAL n                   = info->op_count;
     INTVAL s                   = 1;

Modified: branches/dynop_mapping/src/sub.c
==============================================================================
--- branches/dynop_mapping/src/sub.c	Fri Jun 25 04:41:49 2010	(r47825)
+++ branches/dynop_mapping/src/sub.c	Fri Jun 25 05:35:00 2010	(r47826)
@@ -182,7 +182,7 @@
         if (!debug)
             return 0;
         for (i = n = 0; n < sub->seg->base.size; ++i) {
-            op_info_t * const op_info = &interp->op_info_table[*pc];
+            op_info_t * const op_info = interp->code->op_info_table[*pc];
             opcode_t var_args = 0;
 
             if (i >= debug->base.size)
@@ -234,7 +234,7 @@
     current_annotation = pc - base_pc;
 
     for (i = op = 0; op < debug_size; ++i) {
-        op_info_t * const op_info  = &interp->op_info_table[*base_pc];
+        op_info_t * const op_info  = interp->code->op_info_table[*base_pc];
         opcode_t          var_args = 0;
 
         if (i >= debug_size)


More information about the parrot-commits mailing list