[svn:parrot] r43855 - in trunk: compilers/imcc include/parrot src/interp
bacek at svn.parrot.org
bacek at svn.parrot.org
Wed Feb 10 13:01:35 UTC 2010
Author: bacek
Date: Wed Feb 10 13:01:35 2010
New Revision: 43855
URL: https://trac.parrot.org/parrot/changeset/43855
Log:
Split make_interpreter into allocate and initialize parts. It will give
us ability to override defaults for some subsystems such as GC.
Modified:
trunk/compilers/imcc/parser_util.c
trunk/include/parrot/interpreter.h
trunk/src/interp/inter_create.c
Modified: trunk/compilers/imcc/parser_util.c
==============================================================================
--- trunk/compilers/imcc/parser_util.c Wed Feb 10 12:29:38 2010 (r43854)
+++ trunk/compilers/imcc/parser_util.c Wed Feb 10 13:01:35 2010 (r43855)
@@ -1290,9 +1290,8 @@
imcc_init(PARROT_INTERP)
{
ASSERT_ARGS(imcc_init)
- PARROT_ASSERT(IMCC_INFO(interp) == NULL);
+ PARROT_ASSERT(IMCC_INFO(interp) != NULL);
- IMCC_INFO(interp) = mem_allocate_zeroed_typed(imc_info_t);
/* register PASM and PIR compilers to parrot core */
register_compilers(interp);
}
Modified: trunk/include/parrot/interpreter.h
==============================================================================
--- trunk/include/parrot/interpreter.h Wed Feb 10 12:29:38 2010 (r43854)
+++ trunk/include/parrot/interpreter.h Wed Feb 10 13:01:35 2010 (r43855)
@@ -387,6 +387,18 @@
PARROT_EXPORT
PARROT_CANNOT_RETURN_NULL
+Parrot_Interp allocate_interpreter(
+ ARGIN_NULLOK(Interp *parent),
+ INTVAL flags);
+
+PARROT_EXPORT
+PARROT_CANNOT_RETURN_NULL
+Parrot_Interp initialize_interpeter(PARROT_INTERP, ARGIN(void *stacktop))
+ __attribute__nonnull__(1)
+ __attribute__nonnull__(2);
+
+PARROT_EXPORT
+PARROT_CANNOT_RETURN_NULL
Parrot_Interp make_interpreter(ARGIN_NULLOK(Interp *parent), INTVAL flags);
PARROT_EXPORT
@@ -398,6 +410,10 @@
SHIM(void *arg))
__attribute__nonnull__(1);
+#define ASSERT_ARGS_allocate_interpreter __attribute__unused__ int _ASSERT_ARGS_CHECK = (0)
+#define ASSERT_ARGS_initialize_interpeter __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
+ PARROT_ASSERT_ARG(interp) \
+ , PARROT_ASSERT_ARG(stacktop))
#define ASSERT_ARGS_make_interpreter __attribute__unused__ int _ASSERT_ARGS_CHECK = (0)
#define ASSERT_ARGS_Parrot_destroy __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp))
Modified: trunk/src/interp/inter_create.c
==============================================================================
--- trunk/src/interp/inter_create.c Wed Feb 10 12:29:38 2010 (r43854)
+++ trunk/src/interp/inter_create.c Wed Feb 10 13:01:35 2010 (r43855)
@@ -114,6 +114,37 @@
int stacktop;
Interp *interp;
+ interp = allocate_interpreter(parent, flags);
+ initialize_interpeter(interp,(void*)&stacktop);
+ return interp;
+}
+
+/*
+
+=item C<Parrot_Interp allocate_interpreter(Interp *parent, INTVAL flags)>
+
+Allocate new interpeter from system memory. Everything is preallocated but not
+initialized. Used in next cycle:
+
+ allocate_interpreter
+ parseflags
+ initialize_interpeter
+
+for overriding subsystems (e.g. GC) which require early initialization.
+
+=cut
+
+*/
+
+PARROT_EXPORT
+PARROT_CANNOT_RETURN_NULL
+Parrot_Interp
+allocate_interpreter(ARGIN_NULLOK(Interp *parent), INTVAL flags)
+{
+ ASSERT_ARGS(allocate_interpreter)
+ int stacktop;
+ Interp *interp;
+
/* Get an empty interpreter from system memory */
interp = mem_allocate_zeroed_typed(Interp);
@@ -135,8 +166,45 @@
/* Must initialize flags before Parrot_gc_initialize() is called
* so the GC_DEBUG stuff is available. */
interp->flags = flags;
+
+ interp->ctx = PMCNULL;
+ interp->resume_flag = RESUME_INITIAL;
+
+ interp->recursion_limit = RECURSION_LIMIT;
+
+ /* PANIC will fail until this is done */
+ interp->piodata = NULL;
+
+ /* create exceptions list */
+ interp->current_runloop_id = 0;
+ interp->current_runloop_level = 0;
+
+ /* Allocate IMCC info */
+ IMCC_INFO(interp) = mem_allocate_zeroed_typed(imc_info_t);
+
+ /* Done. Return and be done with it */
+ return interp;
+}
+
+/*
+
+=item C<Parrot_Interp initialize_interpeter(PARROT_INTERP)>
+
+Initialize previously allocated interpeter.
+
+=cut
+
+*/
+
+PARROT_EXPORT
+PARROT_CANNOT_RETURN_NULL
+Parrot_Interp
+initialize_interpeter(PARROT_INTERP, ARGIN(void *stacktop))
+{
+ ASSERT_ARGS(initialize_interpeter)
+
/* Set up the memory allocation system */
- Parrot_gc_initialize(interp, (void*)&stacktop);
+ Parrot_gc_initialize(interp, stacktop);
Parrot_block_GC_mark(interp);
Parrot_block_GC_sweep(interp);
@@ -155,15 +223,6 @@
*/
Parrot_str_init(interp);
- if (is_env_var_set(interp, CONST_STRING(interp, "PARROT_GC_DEBUG"))) {
-#if ! DISABLE_GC_DEBUG
- Interp_flags_SET(interp, PARROT_GC_DEBUG_FLAG);
-#else
- fprintf(stderr, "PARROT_GC_DEBUG is set but the binary was compiled "
- "with DISABLE_GC_DEBUG.\n");
-#endif
- }
-
Parrot_initialize_core_vtables(interp);
/* Set up MMD; MMD cache for builtins. */
@@ -177,6 +236,15 @@
init_world_once(interp);
/* context data */
+ if (is_env_var_set(interp, CONST_STRING(interp, "PARROT_GC_DEBUG"))) {
+#if ! DISABLE_GC_DEBUG
+ Interp_flags_SET(interp, PARROT_GC_DEBUG_FLAG);
+#else
+ fprintf(stderr, "PARROT_GC_DEBUG is set but the binary was compiled "
+ "with DISABLE_GC_DEBUG.\n");
+#endif
+ }
+
/* Initialize interpreter's flags */
PARROT_WARNINGS_off(interp, PARROT_WARNINGS_ALL_FLAG);
@@ -264,6 +332,7 @@
return interp;
}
+
/*
=item C<void Parrot_destroy(PARROT_INTERP)>
More information about the parrot-commits
mailing list