[svn:parrot] r48396 - in trunk: compilers/opsc/src/Ops/Trans src/ops
chromatic at svn.parrot.org
chromatic at svn.parrot.org
Wed Aug 11 01:58:15 UTC 2010
Author: chromatic
Date: Wed Aug 11 01:58:10 2010
New Revision: 48396
URL: https://trac.parrot.org/parrot/changeset/48396
Log:
[opsc] Fixed some of the damage of r48393.
Deallocation must respect the difference between hashes and arrays.
Modified:
trunk/compilers/opsc/src/Ops/Trans/C.pm
trunk/src/ops/core_ops.c
Modified: trunk/compilers/opsc/src/Ops/Trans/C.pm
==============================================================================
--- trunk/compilers/opsc/src/Ops/Trans/C.pm Wed Aug 11 01:37:39 2010 (r48395)
+++ trunk/compilers/opsc/src/Ops/Trans/C.pm Wed Aug 11 01:58:10 2010 (r48396)
@@ -278,6 +278,8 @@
op_info_t * info;
struct hop *next;
} HOP;
+
+static HOP *hop_buckets;
static HOP **hop;
static void hop_init(PARROT_INTERP);
@@ -345,7 +347,7 @@
/* allocate the storage all in one chunk
* yes, this is profligate, but we can tighten it later */
- HOP *hops =
+ HOP *hops = hop_buckets =
mem_gc_allocate_n_zeroed_typed(interp, [[BS]]op_lib.op_count * 2, HOP );
size_t i;
@@ -362,12 +364,13 @@
static void hop_deinit(PARROT_INTERP)
{
- if (hop) {
- HOP *p = hop[0];
- mem_gc_free(interp, p);
+ if (hop)
mem_sys_free(hop);
- hop = NULL;
- }
+ if (hop_buckets)
+ mem_gc_free(interp, hop_buckets);
+
+ hop = NULL;
+ hop_buckets = NULL;
}|;
$fh.print(subst($res, /'[[' BS ']]'/, $emitter.bs, :global));
Modified: trunk/src/ops/core_ops.c
==============================================================================
--- trunk/src/ops/core_ops.c Wed Aug 11 01:37:39 2010 (r48395)
+++ trunk/src/ops/core_ops.c Wed Aug 11 01:58:10 2010 (r48396)
@@ -25045,11 +25045,13 @@
op_info_t * info;
struct hop *next;
} HOP;
+
+static HOP *hop_buckets;
static HOP **hop;
static void hop_init(PARROT_INTERP);
static size_t hash_str(const char *str);
-static void store_op(PARROT_INTERP, op_info_t *info, int full, HOP *p);
+static void store_op(PARROT_INTERP, op_info_t *info, HOP *p, int full);
/* XXX on changing interpreters, this should be called,
through a hook */
@@ -25081,7 +25083,7 @@
return key;
}
-static void store_op(PARROT_INTERP, op_info_t *info, int full, HOP *p)
+static void store_op(PARROT_INTERP, op_info_t *info, HOP *p, int full)
{
const size_t hidx =
hash_str(full ? info->full_name : info->name) % OP_HASH_SIZE;
@@ -25096,7 +25098,7 @@
const HOP * p;
const size_t hidx = hash_str(name) % OP_HASH_SIZE;
if (!hop) {
- hop = mem_gc_allocate_n_zeroed_typed(interp, OP_HASH_SIZE, HOP *);
+ hop = mem_gc_allocate_n_zeroed_typed(interp, OP_HASH_SIZE,HOP *);
hop_init(interp);
}
for (p = hop[hidx]; p; p = p->next) {
@@ -25108,29 +25110,34 @@
static void hop_init(PARROT_INTERP)
{
- size_t i;
op_info_t * const info = core_op_lib.op_info_table;
- HOP *hops =
- mem_gc_allocate_n_zeroed_typed(interp, core_op_lib.op_count * 2, HOP );
+
+ /* allocate the storage all in one chunk
+ * yes, this is profligate, but we can tighten it later */
+ HOP *hops = hop_buckets =
+ mem_gc_allocate_n_zeroed_typed(interp, core_op_lib.op_count * 2, HOP );
+
+ size_t i;
/* store full names */
for (i = 0; i < core_op_lib.op_count; i++)
- store_op(interp, info + i, 1, hops++);
+ store_op(interp, info + i, hops++, 1);
/* plus one short name */
for (i = 0; i < core_op_lib.op_count; i++)
if (get_op(interp, info[i].name, 0) == -1)
- store_op(interp, info + i, 0, hops++);
+ store_op(interp, info + i, hops++, 0);
}
static void hop_deinit(PARROT_INTERP)
{
- if (hop) {
- HOP *p = hop[0];
- mem_gc_free(interp, p);
+ if (hop)
mem_sys_free(hop);
- hop = NULL;
- }
+ if (hop_buckets)
+ mem_gc_free(interp, hop_buckets);
+
+ hop = NULL;
+ hop_buckets = NULL;
}
op_lib_t *
Parrot_DynOp_core_2_6_0(PARROT_INTERP, long init) {
More information about the parrot-commits
mailing list