[svn:parrot] r44224 - in branches/sys_mem_reduce: compilers/imcc include/parrot lib/Parrot/Ops2c

bacek at svn.parrot.org bacek at svn.parrot.org
Sat Feb 20 11:41:26 UTC 2010


Author: bacek
Date: Sat Feb 20 11:41:25 2010
New Revision: 44224
URL: https://trac.parrot.org/parrot/changeset/44224

Log:
Switch HOP to GC allocations

Modified:
   branches/sys_mem_reduce/compilers/imcc/instructions.c
   branches/sys_mem_reduce/compilers/imcc/optimizer.c
   branches/sys_mem_reduce/compilers/imcc/parser_util.c
   branches/sys_mem_reduce/compilers/imcc/pbc.c
   branches/sys_mem_reduce/include/parrot/oplib.h
   branches/sys_mem_reduce/lib/Parrot/Ops2c/Utils.pm

Modified: branches/sys_mem_reduce/compilers/imcc/instructions.c
==============================================================================
--- branches/sys_mem_reduce/compilers/imcc/instructions.c	Sat Feb 20 11:40:55 2010	(r44223)
+++ branches/sys_mem_reduce/compilers/imcc/instructions.c	Sat Feb 20 11:41:25 2010	(r44224)
@@ -149,7 +149,7 @@
     if (!w_special[0]) {
         size_t i;
         for (i = 0; i < N_ELEMENTS(writes); i++) {
-            const int n = interp->op_lib->op_code(writes[i], 1);
+            const int n = interp->op_lib->op_code(interp, writes[i], 1);
             PARROT_ASSERT(n);
             w_special[i] = n;
         }

Modified: branches/sys_mem_reduce/compilers/imcc/optimizer.c
==============================================================================
--- branches/sys_mem_reduce/compilers/imcc/optimizer.c	Sat Feb 20 11:40:55 2010	(r44223)
+++ branches/sys_mem_reduce/compilers/imcc/optimizer.c	Sat Feb 20 11:41:25 2010	(r44224)
@@ -802,7 +802,7 @@
     int i;
     op_info_t *op_info;
 
-    opnum = interp->op_lib->op_code(op, 1);
+    opnum = interp->op_lib->op_code(interp, op, 1);
     if (opnum < 0)
         IMCC_fatal(interp, 1, "eval_ins: op '%s' not found\n", op);
     op_info = interp->op_info_table + opnum;

Modified: branches/sys_mem_reduce/compilers/imcc/parser_util.c
==============================================================================
--- branches/sys_mem_reduce/compilers/imcc/parser_util.c	Sat Feb 20 11:40:55 2010	(r44223)
+++ branches/sys_mem_reduce/compilers/imcc/parser_util.c	Sat Feb 20 11:41:25 2010	(r44224)
@@ -285,7 +285,7 @@
     ASSERT_ARGS(check_op)
     op_fullname(fullname, name, r, narg, keyvec);
 
-    return interp->op_lib->op_code(fullname, 1);
+    return interp->op_lib->op_code(interp, fullname, 1);
 }
 
 /*
@@ -303,8 +303,8 @@
 is_op(PARROT_INTERP, ARGIN(const char *name))
 {
     ASSERT_ARGS(is_op)
-    return interp->op_lib->op_code(name, 0) >= 0
-        || interp->op_lib->op_code(name, 1) >= 0;
+    return interp->op_lib->op_code(interp, name, 0) >= 0
+        || interp->op_lib->op_code(interp, name, 1) >= 0;
 }
 
 /*
@@ -341,7 +341,7 @@
     r[0]->pmc_type = enum_class_FixedIntegerArray;
 
     op_fullname(fullname, name, r, 1, 0);
-    op = interp->op_lib->op_code(fullname, 1);
+    op = interp->op_lib->op_code(interp, fullname, 1);
 
     PARROT_ASSERT(op >= 0);
 
@@ -404,11 +404,11 @@
         return var_arg_ins(interp, unit, name, r, n, emit);
 
     op_fullname(fullname, name, r, n, keyvec);
-    op = interp->op_lib->op_code(fullname, 1);
+    op = interp->op_lib->op_code(interp, fullname, 1);
 
     /* maybe we have a fullname */
     if (op < 0)
-        op = interp->op_lib->op_code(name, 1);
+        op = interp->op_lib->op_code(interp, name, 1);
 
     /* still wrong, try reverse compare */
     if (op < 0) {
@@ -416,7 +416,7 @@
         if (n_name) {
             name = n_name;
             op_fullname(fullname, name, r, n, keyvec);
-            op   = interp->op_lib->op_code(fullname, 1);
+            op   = interp->op_lib->op_code(interp, fullname, 1);
         }
     }
 
@@ -1193,7 +1193,7 @@
 
     if (changed) {
         op_fullname(fullname, name, r, n, keyvec);
-        return interp->op_lib->op_code(fullname, 1);
+        return interp->op_lib->op_code(interp, fullname, 1);
     }
 
     return -1;

Modified: branches/sys_mem_reduce/compilers/imcc/pbc.c
==============================================================================
--- branches/sys_mem_reduce/compilers/imcc/pbc.c	Sat Feb 20 11:40:55 2010	(r44223)
+++ branches/sys_mem_reduce/compilers/imcc/pbc.c	Sat Feb 20 11:41:25 2010	(r44224)
@@ -826,7 +826,7 @@
                     SymReg * const nam = mk_const(interp, fixup->name,
                             fixup->type & VT_ENCODED ? 'U' : 'S');
 
-                    const int op = interp->op_lib->op_code("find_sub_not_null_p_sc", 1);
+                    const int op = interp->op_lib->op_code(interp, "find_sub_not_null_p_sc", 1);
                     PARROT_ASSERT(op);
 
                     interp->code->base.data[addr] = op;

Modified: branches/sys_mem_reduce/include/parrot/oplib.h
==============================================================================
--- branches/sys_mem_reduce/include/parrot/oplib.h	Sat Feb 20 11:40:55 2010	(r44223)
+++ branches/sys_mem_reduce/include/parrot/oplib.h	Sat Feb 20 11:41:25 2010	(r44224)
@@ -32,7 +32,7 @@
     size_t      op_count;
     op_info_t * op_info_table;
     op_func_t * op_func_table;
-    int (*op_code)(const char * name, int full);
+    int (*op_code)(PARROT_INTERP, const char * name, int full);
 } op_lib_t;
 
 typedef enum {

Modified: branches/sys_mem_reduce/lib/Parrot/Ops2c/Utils.pm
==============================================================================
--- branches/sys_mem_reduce/lib/Parrot/Ops2c/Utils.pm	Sat Feb 20 11:40:55 2010	(r44223)
+++ branches/sys_mem_reduce/lib/Parrot/Ops2c/Utils.pm	Sat Feb 20 11:41:25 2010	(r44224)
@@ -559,7 +559,7 @@
 
     if ( $self->{suffix} eq '' && !$self->{flag}->{dynamic} ) {
         print $fh <<END_C_2;
-static int get_op(const char * name, int full);
+static int get_op(PARROT_INTERP, const char * name, int full);
 
 END_C_2
     }
@@ -892,9 +892,9 @@
 } HOP;
 static HOP **hop;
 
-static void hop_init(void);
+static void hop_init(PARROT_INTERP);
 static size_t hash_str(const char *str);
-static void store_op(op_info_t *info, int full);
+static void store_op(PARROT_INTERP, op_info_t *info, int full);
 
 /* XXX on changing interpreters, this should be called,
    through a hook */
@@ -923,8 +923,8 @@
     return key;
 }
 
-static void store_op(op_info_t *info, int full) {
-    HOP * const p     = mem_allocate_typed(HOP);
+static void store_op(PARROT_INTERP, op_info_t *info, int full) {
+    HOP * const p     = mem_gc_allocate_zeroed_typed(interp, HOP);
     const size_t hidx =
         hash_str(full ? info->full_name : info->name) % OP_HASH_SIZE;
 
@@ -932,12 +932,12 @@
     p->next   = hop[hidx];
     hop[hidx] = p;
 }
-static int get_op(const char * name, int full) {
+static int get_op(PARROT_INTERP, const char * name, int full) {
     const HOP * p;
     const size_t hidx = hash_str(name) % OP_HASH_SIZE;
     if (!hop) {
-        hop = mem_allocate_n_zeroed_typed(OP_HASH_SIZE,HOP *);
-        hop_init();
+        hop = mem_gc_allocate_n_zeroed_typed(interp, OP_HASH_SIZE,HOP *);
+        hop_init(interp);
     }
     for (p = hop[hidx]; p; p = p->next) {
         if(STREQ(name, full ? p->info->full_name : p->info->name))
@@ -945,16 +945,16 @@
     }
     return -1;
 }
-static void hop_init(void) {
+static void hop_init(PARROT_INTERP) {
     size_t i;
     op_info_t * const info = $self->{bs}op_lib.op_info_table;
     /* store full names */
     for (i = 0; i < $self->{bs}op_lib.op_count; i++)
-        store_op(info + i, 1);
+        store_op(interp, info + i, 1);
     /* plus one short name */
     for (i = 0; i < $self->{bs}op_lib.op_count; i++)
-        if (get_op(info[i].name, 0) == -1)
-            store_op(info + i, 0);
+        if (get_op(interp, info[i].name, 0) == -1)
+            store_op(interp, info + i, 0);
 }
 static void hop_deinit(void)
 {


More information about the parrot-commits mailing list