Permalink
Browse files

remove the two-stage initialization dance. We can now initialize an i…

…nterpreter by passing in a struct of options
  • Loading branch information...
1 parent 7a89af6 commit f2252b40d0d2d4cce22d6be8100847b5102da4a7 @Whiteknight Whiteknight committed Nov 10, 2010
Showing with 34 additions and 27 deletions.
  1. +7 −0 include/parrot/api.h
  2. +7 −0 include/parrot/gc_api.h
  3. +20 −19 src/embed/api.c
  4. +0 −8 src/gc/gc_private.h
@@ -12,6 +12,13 @@
#include "parrot/config.h"
#include "parrot/core_types.h"
+typedef struct _Parrot_Init_Args {
+ void *stacktop;
+ INTVAL gc_system;
+ INTVAL gc_threshold;
+ INTVAL hash_seed;
+} Parrot_Init_Args;
+
/* HEADERIZER BEGIN src/embed_api.c */
/* HEADERIZER END src/embed_api.c */
@@ -33,6 +33,13 @@
#define GC_DYNAMIC_THRESHOLD_DEFAULT 25
+typedef enum _gc_sys_type_enum {
+ MS, /* mark and sweep */
+ INF, /* infinite memory core */
+ TMS, /* tricolor mark and sweep */
+ MS2
+} gc_sys_type_enum;
+
/* pool iteration */
typedef enum {
POOL_PMC = 0x01,
View
@@ -19,29 +19,30 @@
PARROT_API
PARROT_CANNOT_RETURN_NULL
PARROT_MALLOC
-Parrot_Interp *
-Parrot_api_make_interpreter(ARGIN_NULLOK(PMC *parent), INTVAL flags)
-{
- ASSERT_ARGS(Parrot_api_make_interpreter)
- Parrot_set_config_hash();
- Parrot_Interp * const parent_raw = PMC_IS_NULL(parent) ? NULL : GET_RAW_INTERP(parent);
- Parrot_Interp * const interp = allocate_interpreter(parent, flags);
- return interp;
-}
-
-PARROT_API
INTVAL
-Parrot_api_initialize_interpreter(ARGIN(Parrot_Interp *interp), ARGIN_NULLOK(void * stacktop), ARGOUT(PMC ** interp_pmc))
+Parrot_api_make_interpreter(ARGIN_NULLOK(PMC *parent), INTVAL flags, ARGIN_NULLOK(Parrot_Init_Args *args), ARGOUT(PMC **interp))
{
- ASSERT_ARGS(Parrot_api_initialize_interpreter)
+ ASSERT_ARGS(Parrot_api_make_interpreter)
int alt_stacktop;
- if (PMC_IS_NULL(interp_pmc)
- return;
- if (stacktop == NULL)
- stacktop = &alt_stacktop;
- initialize_interpreter(interp, stacktop);
+ void *stacktop_ptr = &alt_stacktop;
+ Parrot_set_config_hash();
+ {
+ Parrot_Interp * const parent_raw = PMC_IS_NULL(parent) ? NULL : GET_RAW_INTERP(parent);
+ Parrot_Interp * const interp_raw = allocate_interpreter(parent_raw, flags);
+ if (args) {
+ if (args->stack_top)
+ stacktop_ptr = args->stacktop;
+ if (args->gc_system)
+ interp->gc_sys->sys_type = args->gc_system;
+ if (args->gc_threshold)
+ interp->gc_threshold = args->gc_threshold;
+ if (args->hash_seed)
+ interp->hash_seed = args->hash_seed;
+ }
+ }
+ initialize_interpreter(interp_raw, stacktop);
*interp_pmc = VTABLE_get_pmc_keyed_int(interp, iglobals, (INTVAL)IGLOBALS_INTERPRETER);
- return (!PMC_IS_NULL(interp_pmc);
+ return !PMC_IS_NULL(*interp);
}
PARROT_API
View
@@ -77,14 +77,6 @@ typedef struct GC_MS_PObj_Wrapper {
struct GC_MS_PObj_Wrapper * next_ptr;
} GC_MS_PObj_Wrapper;
-
-typedef enum _gc_sys_type_enum {
- MS, /* mark and sweep */
- INF, /* infinite memory core */
- TMS, /* tricolor mark and sweep */
- MS2
-} gc_sys_type_enum;
-
/* how often to skip a full GC when this pool has nothing free */
typedef enum _gc_skip_type_enum {
GC_NO_SKIP = 0,

0 comments on commit f2252b4

Please sign in to comment.