[svn:parrot] r40284 - in branches/kill_stacks: include/parrot src/gc src/interp src/ops src/pmc

whiteknight at svn.parrot.org whiteknight at svn.parrot.org
Sun Jul 26 20:02:08 UTC 2009


Author: whiteknight
Date: Sun Jul 26 20:02:06 2009
New Revision: 40284
URL: https://trac.parrot.org/parrot/changeset/40284

Log:
[kill_stacks] reimplement pushaction, pushmark, and popmark opcodes in terms of a regular RPA PMC instead of stacks

Modified:
   branches/kill_stacks/include/parrot/interpreter.h
   branches/kill_stacks/src/gc/mark_sweep.c
   branches/kill_stacks/src/interp/inter_create.c
   branches/kill_stacks/src/ops/core.ops
   branches/kill_stacks/src/pmc/coroutine.pmc

Modified: branches/kill_stacks/include/parrot/interpreter.h
==============================================================================
--- branches/kill_stacks/include/parrot/interpreter.h	Sun Jul 26 19:27:32 2009	(r40283)
+++ branches/kill_stacks/include/parrot/interpreter.h	Sun Jul 26 20:02:06 2009	(r40284)
@@ -356,7 +356,7 @@
 
     PDB_t  *pdb;                              /* debug /trace system */
 
-    struct Stack_Chunk *dynamic_env;          /* current dynamic environment */
+    PMC * dynamic_env;                        /* Dynamic environment stack */
 
     void *lo_var_ptr;                         /* Pointer to memory on runops
                                                * system stack */

Modified: branches/kill_stacks/src/gc/mark_sweep.c
==============================================================================
--- branches/kill_stacks/src/gc/mark_sweep.c	Sun Jul 26 19:27:32 2009	(r40283)
+++ branches/kill_stacks/src/gc/mark_sweep.c	Sun Jul 26 20:02:06 2009	(r40284)
@@ -195,7 +195,7 @@
     mark_context(interp, ctx);
 
     /* mark the dynamic environment. */
-    mark_stack(interp, interp->dynamic_env);
+    Parrot_gc_mark_PObj_alive(interp, (PObj*)interp->dynamic_env);
 
     /* mark the vtables: the data, Class PMCs, etc. */
     mark_vtables(interp);

Modified: branches/kill_stacks/src/interp/inter_create.c
==============================================================================
--- branches/kill_stacks/src/interp/inter_create.c	Sun Jul 26 19:27:32 2009	(r40283)
+++ branches/kill_stacks/src/interp/inter_create.c	Sun Jul 26 20:02:06 2009	(r40284)
@@ -210,12 +210,6 @@
     PARROT_ERRORS_on(interp, PARROT_ERRORS_RESULT_COUNT_FLAG);
 #endif
 
-    /* allocate stack chunk cache */
-    stack_system_init(interp);
-
-    /* And a dynamic environment stack */
-    interp->dynamic_env = new_stack(interp, "DynamicEnv");
-
     /* clear context introspection vars */
     CONTEXT(interp)->current_sub    = NULL;
     CONTEXT(interp)->current_cont   = NULL;
@@ -235,6 +229,10 @@
     /* create the root set registry */
     interp->gc_registry     = pmc_new(interp, enum_class_AddrRegistry);
 
+    /* And a dynamic environment stack */
+    /* TODO: We should really consider removing this (TT #876) */
+    interp->dynamic_env = pmc_new(interp, enum_class_ResizablePMCArray);
+
     /* create exceptions list */
     interp->current_runloop_id    = 0;
     interp->current_runloop_level = 0;

Modified: branches/kill_stacks/src/ops/core.ops
==============================================================================
--- branches/kill_stacks/src/ops/core.ops	Sun Jul 26 19:27:32 2009	(r40283)
+++ branches/kill_stacks/src/ops/core.ops	Sun Jul 26 20:02:06 2009	(r40284)
@@ -923,15 +923,33 @@
 }
 
 inline op pushmark(in INT) {
-    Parrot_push_mark(interp, $1);
+    PMC * const newint = pmc_new(interp, enum_class_Integer);
+    VTABLE_set_integer_native(interp, newint, $1);
+    VTABLE_push_pmc(interp, interp->dynamic_env, newint);
 }
 
 inline op popmark(in INT) {
-    Parrot_pop_mark(interp, $1);
+    opcode_t * dest;
+    opcode_t * const ret = expr NEXT();
+    int found = 0;
+    while (VTABLE_elements(interp, interp->dynamic_env)) {
+        PMC * const item = VTABLE_pop_pmc(interp, interp->dynamic_env);
+        if (item->vtable->base_type == enum_class_Integer
+           && VTABLE_get_integer(interp, item) == $1) {
+           found = 1;
+           break;
+        }
+
+        else if (item->vtable->base_type == enum_class_Sub
+                 || item->vtable->base_type == enum_class_NCI)
+            Parrot_pcc_invoke_sub_from_c_args(interp, item, "I->", 0);
+    }
+    if (!found)
+        dest = Parrot_ex_throw_from_op_args(interp, ret, 1, "Mark %d not found", $1);
 }
 
 inline op pushaction(invar PMC) {
-    Parrot_push_action(interp, $1);
+    VTABLE_push_pmc(interp, interp->dynamic_env, $1);
 }
 
 =back

Modified: branches/kill_stacks/src/pmc/coroutine.pmc
==============================================================================
--- branches/kill_stacks/src/pmc/coroutine.pmc	Sun Jul 26 19:27:32 2009	(r40283)
+++ branches/kill_stacks/src/pmc/coroutine.pmc	Sun Jul 26 20:02:06 2009	(r40284)
@@ -150,7 +150,6 @@
             ctx        = Parrot_set_new_context(INTERP, co->n_regs_used);
 
             co->ctx                   = Parrot_context_ref(interp, ctx);
-            co->dynamic_state         = interp->dynamic_env;
 
             ctx->caller_ctx           = caller_ctx;
             PMC_cont(ccont)->from_ctx = ctx;
@@ -179,7 +178,6 @@
         /* if calling the Coro we need the segment of the Coro */
         else if (!(PObj_get_FLAGS(SELF) & SUB_FLAG_CORO_FF)) {
             PMC *ccont;
-            Stack_Chunk_t    *state;
             Parrot_Context   *ctx;
 
             PObj_get_FLAGS(SELF) |= SUB_FLAG_CORO_FF;
@@ -195,16 +193,12 @@
                                   = CONTEXT(interp);
 
             /* set context to coro context */
-            state                 = interp->dynamic_env;
-            interp->dynamic_env   = co->dynamic_state;
-            co->dynamic_state     = state;
             CONTEXT(interp)       = ctx;
             INTERP->ctx.bp        = ctx->bp;
             INTERP->ctx.bp_ps     = ctx->bp_ps;
         }
         else {
             PMC *ccont;
-            Stack_Chunk_t    *state;
             Parrot_Context   *ctx;
 
             PObj_get_FLAGS(SELF) &= ~SUB_FLAG_CORO_FF;
@@ -224,9 +218,6 @@
                                "Cannot resume dead coroutine.");
             }
 
-            state                = interp->dynamic_env;
-            interp->dynamic_env  = co->dynamic_state;
-            co->dynamic_state    = state;
             CONTEXT(interp)      = ctx;
             INTERP->ctx.bp       = ctx->bp;
             INTERP->ctx.bp_ps    = ctx->bp_ps;
@@ -258,9 +249,6 @@
 
         /* co->ctx marked in SUPER(), so do not mark here */
         if (co) {
-            if (co->dynamic_state)
-                mark_stack(INTERP, co->dynamic_state);
-
             SUPER();
         }
     }


More information about the parrot-commits mailing list