[svn:parrot] r44375 - in trunk: include/parrot lib/Parrot/Ops2c src/interp src/runcore
bacek at svn.parrot.org
bacek at svn.parrot.org
Tue Feb 23 09:25:56 UTC 2010
Author: bacek
Date: Tue Feb 23 09:25:55 2010
New Revision: 44375
URL: https://trac.parrot.org/parrot/changeset/44375
Log:
Pass interp through ops initialization process. Switch ops deinit to GC allocations
Modified:
trunk/include/parrot/oplib.h
trunk/lib/Parrot/Ops2c/Utils.pm
trunk/src/interp/inter_create.c
trunk/src/runcore/cores.c
trunk/src/runcore/main.c
Modified: trunk/include/parrot/oplib.h
==============================================================================
--- trunk/include/parrot/oplib.h Tue Feb 23 09:03:16 2010 (r44374)
+++ trunk/include/parrot/oplib.h Tue Feb 23 09:25:55 2010 (r44375)
@@ -41,7 +41,7 @@
} op_lib_flags_enum;
/* when init = true initialize, else de_initialize */
-typedef op_lib_t *(*oplib_init_f)(long init);
+typedef op_lib_t *(*oplib_init_f)(PARROT_INTERP, long init);
/* core.ops special opcode numbers */
typedef enum {
Modified: trunk/lib/Parrot/Ops2c/Utils.pm
==============================================================================
--- trunk/lib/Parrot/Ops2c/Utils.pm Tue Feb 23 09:03:16 2010 (r44374)
+++ trunk/lib/Parrot/Ops2c/Utils.pm Tue Feb 23 09:25:55 2010 (r44375)
@@ -477,7 +477,7 @@
#include "parrot/parrot.h"
#include "parrot/oplib.h"
-$self->{sym_export} op_lib_t *$self->{init_func}(long init);
+$self->{sym_export} op_lib_t *$self->{init_func}(PARROT_INTERP, long init);
END_C
return 1;
@@ -899,7 +899,7 @@
/* XXX on changing interpreters, this should be called,
through a hook */
-static void hop_deinit(void);
+static void hop_deinit(PARROT_INTERP);
/*
* find a short or full opcode
@@ -956,7 +956,7 @@
if (get_op(interp, info[i].name, 0) == -1)
store_op(interp, info + i, 0);
}
-static void hop_deinit(void)
+static void hop_deinit(PARROT_INTERP)
{
if (hop) {
size_t i;
@@ -964,7 +964,7 @@
HOP *p = hop[i];
while (p) {
HOP * const next = p->next;
- mem_sys_free(p);
+ mem_gc_free(interp, p);
p = next;
}
}
@@ -977,7 +977,7 @@
}
else {
print $fh <<END_C;
-static void hop_deinit(void) {}
+static void hop_deinit(SHIM_INTERP) {}
END_C
}
return 1;
@@ -1026,11 +1026,11 @@
print $fh <<END_C;
op_lib_t *
-$self->{init_func}(long init) {
+$self->{init_func}(PARROT_INTERP, long init) {
/* initialize and return op_lib ptr */
if (init == 1) {
$init1_code
- return &$self->{bs}op_lib;
+ return &$self->{bs}op_lib;
}
/* set op_lib to the passed ptr (in init) */
else if (init) {
@@ -1038,7 +1038,7 @@
}
/* deinit - free resources */
else {
- hop_deinit();
+ hop_deinit(interp);
}
return NULL;
}
Modified: trunk/src/interp/inter_create.c
==============================================================================
--- trunk/src/interp/inter_create.c Tue Feb 23 09:03:16 2010 (r44374)
+++ trunk/src/interp/inter_create.c Tue Feb 23 09:25:55 2010 (r44375)
@@ -254,7 +254,7 @@
Parrot_runcore_init(interp);
/* Load the core op func and info tables */
- interp->op_lib = PARROT_CORE_OPLIB_INIT(1);
+ interp->op_lib = PARROT_CORE_OPLIB_INIT(interp, 1);
interp->op_count = interp->op_lib->op_count;
interp->op_func_table = interp->op_lib->op_func_table;
interp->op_info_table = interp->op_lib->op_info_table;
@@ -445,7 +445,7 @@
/* strings, charsets, encodings - only once */
Parrot_str_finish(interp);
- PARROT_CORE_OPLIB_INIT(0);
+ PARROT_CORE_OPLIB_INIT(interp, 0);
if (!interp->parent_interpreter) {
if (interp->thread_data)
Modified: trunk/src/runcore/cores.c
==============================================================================
--- trunk/src/runcore/cores.c Tue Feb 23 09:03:16 2010 (r44374)
+++ trunk/src/runcore/cores.c Tue Feb 23 09:25:55 2010 (r44375)
@@ -1052,7 +1052,7 @@
int (*get_op)(PARROT_INTERP, const char * name, int full);
get_op = interp->op_lib->op_code;
- interp->op_lib = init_func(1);
+ interp->op_lib = init_func(interp, 1);
/* preserve the get_op function */
interp->op_lib->op_code = get_op;
Modified: trunk/src/runcore/main.c
==============================================================================
--- trunk/src/runcore/main.c Tue Feb 23 09:03:16 2010 (r44374)
+++ trunk/src/runcore/main.c Tue Feb 23 09:25:55 2010 (r44375)
@@ -55,7 +55,9 @@
/* HEADERIZER BEGIN: static */
/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
-static void dynop_register_switch(size_t n_old, size_t n_new);
+static void dynop_register_switch(PARROT_INTERP, size_t n_old, size_t n_new)
+ __attribute__nonnull__(1);
+
static void dynop_register_xx(PARROT_INTERP,
size_t n_old,
size_t n_new,
@@ -91,7 +93,8 @@
static void turn_ev_check(PARROT_INTERP, int on)
__attribute__nonnull__(1);
-#define ASSERT_ARGS_dynop_register_switch __attribute__unused__ int _ASSERT_ARGS_CHECK = (0)
+#define ASSERT_ARGS_dynop_register_switch __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
+ PARROT_ASSERT_ARG(interp))
#define ASSERT_ARGS_dynop_register_xx __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp))
#define ASSERT_ARGS_get_dynamic_op_lib_init __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
@@ -481,7 +484,7 @@
stop_prederef(PARROT_INTERP)
{
ASSERT_ARGS(stop_prederef)
- interp->op_func_table = PARROT_CORE_OPLIB_INIT(1)->op_func_table;
+ interp->op_func_table = PARROT_CORE_OPLIB_INIT(interp, 1)->op_func_table;
if (interp->evc_func_table) {
mem_gc_free(interp, interp->evc_func_table);
@@ -580,7 +583,7 @@
ASSERT_ARGS(Parrot_setup_event_func_ptrs)
const size_t n = interp->op_count;
const oplib_init_f init_func = get_core_op_lib_init(interp, interp->run_core);
- op_lib_t * const lib = init_func(1);
+ op_lib_t * const lib = init_func(interp, 1);
/* remember op_func_table */
interp->save_func_table = lib->op_func_table;
@@ -640,13 +643,13 @@
return;
#ifdef HAVE_COMPUTED_GOTO
- cg_lib = PARROT_CORE_CGP_OPLIB_INIT(1);
+ cg_lib = PARROT_CORE_CGP_OPLIB_INIT(interp, 1);
if (cg_lib->op_func_table)
mem_gc_free(interp, cg_lib->op_func_table);
cg_lib->op_func_table = NULL;
- cg_lib = PARROT_CORE_CG_OPLIB_INIT(1);
+ cg_lib = PARROT_CORE_CG_OPLIB_INIT(interp, 1);
if (cg_lib->op_func_table)
mem_gc_free(interp, cg_lib->op_func_table);
cg_lib->op_func_table = NULL;
@@ -707,7 +710,7 @@
interp->n_libs + 1, interp->n_libs, op_lib_t *);
init_func = get_dynamic_op_lib_init(interp, lib_pmc);
- lib = init_func(1);
+ lib = init_func(interp, 1);
interp->all_op_libs[interp->n_libs++] = lib;
@@ -725,7 +728,7 @@
n_old = interp->op_count;
n_new = lib->op_count;
n_tot = n_old + n_new;
- core = PARROT_CORE_OPLIB_INIT(1);
+ core = PARROT_CORE_OPLIB_INIT(interp, 1);
PARROT_ASSERT(interp->op_count == core->op_count);
@@ -766,7 +769,7 @@
interp->save_func_table = new_func_table;
/* deinit core, so that it gets rehashed */
- (void) PARROT_CORE_OPLIB_INIT(0);
+ (void) PARROT_CORE_OPLIB_INIT(interp, 0);
/* set table */
core->op_func_table = interp->op_func_table = new_func_table;
@@ -780,7 +783,7 @@
dynop_register_xx(interp, n_old, n_new, PARROT_CORE_CG_OPLIB_INIT);
#endif
- dynop_register_switch(n_old, n_new);
+ dynop_register_switch(interp, n_old, n_new);
}
@@ -802,7 +805,7 @@
ASSERT_ARGS(dynop_register_xx)
const size_t n_tot = n_old + n_new;
op_func_t *ops_addr = NULL;
- op_lib_t *cg_lib = init_func(1);
+ op_lib_t *cg_lib = init_func(interp, 1);
op_lib_t *new_lib;
#if 0
@@ -893,13 +896,14 @@
/* tell the cg_core about the new jump table */
cg_lib->op_func_table = ops_addr;
cg_lib->op_count = n_tot;
- init_func((long) ops_addr);
+ init_func(interp, (long) ops_addr);
}
/*
-=item C<static void dynop_register_switch(size_t n_old, size_t n_new)>
+=item C<static void dynop_register_switch(PARROT_INTERP, size_t n_old, size_t
+n_new)>
Used only at the end of dynop_register. Sums the old and new op_counts
storing the result into the operations count field of the interpreter
@@ -910,10 +914,10 @@
*/
static void
-dynop_register_switch(size_t n_old, size_t n_new)
+dynop_register_switch(PARROT_INTERP, size_t n_old, size_t n_new)
{
ASSERT_ARGS(dynop_register_switch)
- op_lib_t * const lib = PARROT_CORE_SWITCH_OPLIB_INIT(1);
+ op_lib_t * const lib = PARROT_CORE_SWITCH_OPLIB_INIT(interp, 1);
lib->op_count = n_old + n_new;
}
@@ -934,7 +938,7 @@
ASSERT_ARGS(notify_func_table)
const oplib_init_f init_func = get_core_op_lib_init(interp, interp->run_core);
- init_func((long) table);
+ init_func(interp, (long) table);
if (PARROT_RUNCORE_FUNC_TABLE_TEST(interp->run_core)) {
PARROT_ASSERT(table);
More information about the parrot-commits
mailing list