[svn:parrot] r39370 - in branches/pcc_rewiring: include/parrot src src/call src/ops src/pmc

allison at svn.parrot.org allison at svn.parrot.org
Wed Jun 3 21:04:08 UTC 2009


Author: allison
Date: Wed Jun  3 21:04:03 2009
New Revision: 39370
URL: https://trac.parrot.org/parrot/changeset/39370

Log:
[pcc_branch] Committing uncommitted changes so others can take a look
(some may be reverted later).

Modified:
   branches/pcc_rewiring/include/parrot/call.h
   branches/pcc_rewiring/src/call/pcc.c
   branches/pcc_rewiring/src/events.c
   branches/pcc_rewiring/src/exceptions.c
   branches/pcc_rewiring/src/inter_cb.c
   branches/pcc_rewiring/src/ops/pic.ops
   branches/pcc_rewiring/src/packfile.c
   branches/pcc_rewiring/src/pmc/class.pmc
   branches/pcc_rewiring/src/scheduler.c
   branches/pcc_rewiring/src/stacks.c
   branches/pcc_rewiring/src/thread.c
   branches/pcc_rewiring/src/utils.c

Modified: branches/pcc_rewiring/include/parrot/call.h
==============================================================================
--- branches/pcc_rewiring/include/parrot/call.h	Wed Jun  3 17:05:18 2009	(r39369)
+++ branches/pcc_rewiring/include/parrot/call.h	Wed Jun  3 21:04:03 2009	(r39370)
@@ -269,6 +269,17 @@
         FUNC_MODIFIES(*method_name);
 
 PARROT_EXPORT
+void Parrot_pcc_invoke_method_object_from_c_args(PARROT_INTERP,
+    ARGIN(PMC* pmc),
+    ARGIN(PMC *method_obj),
+    ARGIN(const char *signature),
+    ...)
+        __attribute__nonnull__(1)
+        __attribute__nonnull__(2)
+        __attribute__nonnull__(3)
+        __attribute__nonnull__(4);
+
+PARROT_EXPORT
 void Parrot_pcc_invoke_sub_from_c_args(PARROT_INTERP,
     ARGIN(PMC *sub_obj),
     ARGIN(const char *sig),
@@ -424,6 +435,12 @@
     || PARROT_ASSERT_ARG(pmc) \
     || PARROT_ASSERT_ARG(method_name) \
     || PARROT_ASSERT_ARG(signature)
+#define ASSERT_ARGS_Parrot_pcc_invoke_method_object_from_c_args \
+     __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+       PARROT_ASSERT_ARG(interp) \
+    || PARROT_ASSERT_ARG(pmc) \
+    || PARROT_ASSERT_ARG(method_obj) \
+    || PARROT_ASSERT_ARG(signature)
 #define ASSERT_ARGS_Parrot_pcc_invoke_sub_from_c_args \
      __attribute__unused__ int _ASSERT_ARGS_CHECK = \
        PARROT_ASSERT_ARG(interp) \

Modified: branches/pcc_rewiring/src/call/pcc.c
==============================================================================
--- branches/pcc_rewiring/src/call/pcc.c	Wed Jun  3 17:05:18 2009	(r39369)
+++ branches/pcc_rewiring/src/call/pcc.c	Wed Jun  3 21:04:03 2009	(r39370)
@@ -3842,6 +3842,43 @@
 
 /*
 
+=item C<void Parrot_pcc_invoke_method_object_from_c_args(PARROT_INTERP, PMC* pmc,
+PMC *method_obj, const char *signature, ...)>
+
+Makes a method call given the name of the method and the arguments as a
+C variadic argument list. C<pmc> is the invocant, C<method_obj> is the
+invocable method object, C<signature> is a C string describing the
+signature of the invocation, according to the Parrot calling
+conventions.  The variadic argument list contains the input arguments
+followed by the output results in the same order that they appear in the
+function signature.
+
+=cut
+
+*/
+
+PARROT_EXPORT
+void
+Parrot_pcc_invoke_method_object_from_c_args(PARROT_INTERP, ARGIN(PMC* pmc),
+        ARGIN(PMC *method_obj),
+        ARGIN(const char *signature), ...)
+{
+    ASSERT_ARGS(Parrot_pcc_invoke_method_object_from_c_args)
+    PMC *sig_obj;
+    va_list args;
+    va_start(args, signature);
+    sig_obj = Parrot_pcc_build_sig_object_from_varargs(interp, pmc, signature, args);
+    va_end(args);
+
+    /* Invoke the subroutine object with the given CallSignature object */
+    interp->current_object = pmc;
+    Parrot_pcc_invoke_from_sig_object(interp, method_obj, sig_obj);
+    gc_unregister_pmc(interp, sig_obj);
+
+}
+
+/*
+
 =item C<void Parrot_pcc_invoke_method_from_c_args(PARROT_INTERP, PMC* pmc,
 STRING *method_name, const char *signature, ...)>
 
@@ -3916,6 +3953,9 @@
 
     /* Invoke the function */
     dest = VTABLE_invoke(interp, sub_obj, NULL);
+    if (!dest)
+        Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_PARROT_USAGE_ERROR,
+            "Subroutine returned a NULL address");
 
     /* PIR Subs need runops to run their opcodes. Methods and NCI subs
      * don't. */
@@ -3925,12 +3965,12 @@
         const opcode_t offset = dest - interp->code->base.data;
 
         /* can't re-enter the runloop from here with PIC cores: RT #60048 */
-        if (interp->run_core == PARROT_CGP_CORE
+/*        if (interp->run_core == PARROT_CGP_CORE
         ||  interp->run_core == PARROT_SWITCH_CORE)
-            interp->run_core = PARROT_SLOW_CORE;
+            interp->run_core = PARROT_SLOW_CORE;*/
 
         runops(interp, offset);
-        interp->run_core = old_core;
+/*        interp->run_core = old_core; */
     }
 
 }

Modified: branches/pcc_rewiring/src/events.c
==============================================================================
--- branches/pcc_rewiring/src/events.c	Wed Jun  3 17:05:18 2009	(r39369)
+++ branches/pcc_rewiring/src/events.c	Wed Jun  3 21:04:03 2009	(r39370)
@@ -1471,8 +1471,8 @@
             break;
         case EVENT_TYPE_TIMER:
             /* run ops, save registers */
-            Parrot_runops_fromc_args_event(interp,
-                    event->u.timer_event.sub, "v");
+            Parrot_pcc_invoke_sub_from_c_args(interp,
+                    event->u.timer_event.sub, "->");
             break;
         case EVENT_TYPE_CALL_BACK:
             edebug((stderr, "starting user cb\n"));
@@ -1481,9 +1481,9 @@
             break;
         case EVENT_TYPE_IO:
             edebug((stderr, "starting io handler\n"));
-            Parrot_runops_fromc_args_event(interp,
+            Parrot_pcc_invoke_sub_from_c_args(interp,
                     event->u.io_event.handler,
-                    "vPP",
+                    "PP->",
                     event->u.io_event.pio,
                     event->u.io_event.user_data);
             break;

Modified: branches/pcc_rewiring/src/exceptions.c
==============================================================================
--- branches/pcc_rewiring/src/exceptions.c	Wed Jun  3 17:05:18 2009	(r39369)
+++ branches/pcc_rewiring/src/exceptions.c	Wed Jun  3 21:04:03 2009	(r39370)
@@ -351,7 +351,7 @@
     }
 
     /* Run the handler. */
-    Parrot_runops_fromc_args(interp, handler, "vP", exception);
+    Parrot_pcc_invoke_sub_from_c_args(interp, handler, "P->", exception);
 
     /* After handling a C exception, you don't want to resume at the point
      * where the C exception was thrown, you want to resume the next outer

Modified: branches/pcc_rewiring/src/inter_cb.c
==============================================================================
--- branches/pcc_rewiring/src/inter_cb.c	Wed Jun  3 17:05:18 2009	(r39369)
+++ branches/pcc_rewiring/src/inter_cb.c	Wed Jun  3 21:04:03 2009	(r39370)
@@ -294,7 +294,7 @@
     PMC     *sub;
     STRING  *sig_str;
     char    *p;
-    char     pasm_sig[4];
+    char     pasm_sig[5];
     INTVAL   i_param;
     PMC     *p_param;
     void    *param = NULL;      /* avoid -Ox warning */
@@ -309,13 +309,12 @@
     p         = sig_str->strstart;
     ++p;     /* Skip return type */
 
-    pasm_sig[0] = 'v';  /* no return value supported yet */
-    pasm_sig[1] = 'P';
+    pasm_sig[0] = 'P';
     if (*p == 'U') /* user_data Z in pdd16 */
         ++p;       /* p is now type of external data */
     switch (*p) {
         case 'v':
-            pasm_sig[2] = 'v';
+            pasm_sig[1] = 'v';
             break;
 #if 0
         case '2':
@@ -334,7 +333,7 @@
         case 'c':
             i_param = (INTVAL)(char)(long)external_data;
 case_I:
-            pasm_sig[2] = 'I';
+            pasm_sig[1] = 'I';
             param = (void*) i_param;
             break;
 #if 0
@@ -349,24 +348,26 @@
             /* created a UnManagedStruct */
             p_param = pmc_new(interp, enum_class_UnManagedStruct);
             VTABLE_set_pointer(interp, p_param, external_data);
-            pasm_sig[2] = 'P';
+            pasm_sig[1] = 'P';
             param = (void*) p_param;
             break;
 #if 0
         case 'P':
-            pasm_sig[2] = 'P';
+            pasm_sig[1] = 'P';
             break;
 #endif
         case 't':
-            pasm_sig[2] = 'S';
+            pasm_sig[1] = 'S';
             param = Parrot_str_new(interp, external_data, 0);
             break;
         default:
             Parrot_ex_throw_from_c_args(interp, NULL, 1,
                 "unhandled signature char '%c' in run_cb", *p);
     }
-    pasm_sig[3] = '\0';
-    Parrot_runops_fromc_args_event(interp, sub, pasm_sig,
+    pasm_sig[2] = '-';
+    pasm_sig[3] = '>';  /* no return value supported yet */
+    pasm_sig[4] = '\0';
+    Parrot_pcc_invoke_sub_from_c_args(interp, sub, pasm_sig,
             user_data, param);
 }
 /*

Modified: branches/pcc_rewiring/src/ops/pic.ops
==============================================================================
--- branches/pcc_rewiring/src/ops/pic.ops	Wed Jun  3 17:05:18 2009	(r39369)
+++ branches/pcc_rewiring/src/ops/pic.ops	Wed Jun  3 21:04:03 2009	(r39370)
@@ -244,6 +244,10 @@
     void **pred_pc;
     INTVAL i, n_args, *sig_bits;
     PMC *sig;
+    opcode_t *handler = Parrot_ex_throw_from_op_args(interp, NULL,
+                        EXCEPTION_INVALID_OPERATION,
+                        "Impossible call, poking into low-level args");
+    goto ADDRESS(handler);
 
     ctx = CONTEXT(interp);
     mic = (Parrot_MIC *) cur_opcode[1];

Modified: branches/pcc_rewiring/src/packfile.c
==============================================================================
--- branches/pcc_rewiring/src/packfile.c	Wed Jun  3 17:05:18 2009	(r39369)
+++ branches/pcc_rewiring/src/packfile.c	Wed Jun  3 21:04:03 2009	(r39370)
@@ -678,7 +678,7 @@
 
     CONTEXT(interp)->constants = interp->code->const_table->constants;
 
-    retval           = (PMC *)Parrot_runops_fromc_args(interp, sub_pmc, "P");
+    Parrot_pcc_invoke_sub_from_c_args(interp, sub_pmc, "->P", &retval);
     interp->run_core = old;
 
     return retval;

Modified: branches/pcc_rewiring/src/pmc/class.pmc
==============================================================================
--- branches/pcc_rewiring/src/pmc/class.pmc	Wed Jun  3 17:05:18 2009	(r39369)
+++ branches/pcc_rewiring/src/pmc/class.pmc	Wed Jun  3 21:04:03 2009	(r39370)
@@ -364,7 +364,8 @@
         meth = Parrot_oo_find_vtable_override_for_class(interp, parent, name);
 
         if (!PMC_IS_NULL(meth))
-            Parrot_run_meth_fromc_args(interp, meth, object, name, "vP", init);
+            Parrot_pcc_invoke_sub_from_c_args(interp, meth,
+                    "PiP->", object, init);
     }
 }
 

Modified: branches/pcc_rewiring/src/scheduler.c
==============================================================================
--- branches/pcc_rewiring/src/scheduler.c	Wed Jun  3 17:05:18 2009	(r39369)
+++ branches/pcc_rewiring/src/scheduler.c	Wed Jun  3 21:04:03 2009	(r39370)
@@ -140,8 +140,8 @@
             PMC * const handler = Parrot_cx_find_handler_for_task(interp, task);
             if (!PMC_IS_NULL(handler)) {
                 PMC * handler_sub = VTABLE_get_attr_str(interp, handler, CONST_STRING(interp, "code"));
-                Parrot_runops_fromc_args_event(interp, handler_sub,
-                    "vPP", handler, task);
+                Parrot_pcc_invoke_sub_from_c_args(interp, handler_sub,
+                    "PP->", handler, task);
             }
         }
         else {
@@ -950,8 +950,8 @@
                     Parrot_floatval_time());
 #endif
     if (!PMC_IS_NULL(timer_struct->codeblock)) {
-        Parrot_runops_fromc_args_event(interp,
-                timer_struct->codeblock, "v");
+        Parrot_pcc_invoke_sub_from_c_args(interp,
+                timer_struct->codeblock, "->");
     }
 }
 

Modified: branches/pcc_rewiring/src/stacks.c
==============================================================================
--- branches/pcc_rewiring/src/stacks.c	Wed Jun  3 17:05:18 2009	(r39369)
+++ branches/pcc_rewiring/src/stacks.c	Wed Jun  3 21:04:03 2009	(r39370)
@@ -544,7 +544,7 @@
      * stack - run the action subroutine with an INTVAL arg of 0
      */
     PMC * const sub = UVal_pmc(e->entry);
-    Parrot_runops_fromc_args(interp, sub, "vI", 0);
+    Parrot_pcc_invoke_sub_from_c_args(interp, sub, "I->", 0);
 }
 
 /*

Modified: branches/pcc_rewiring/src/thread.c
==============================================================================
--- branches/pcc_rewiring/src/thread.c	Wed Jun  3 17:05:18 2009	(r39369)
+++ branches/pcc_rewiring/src/thread.c	Wed Jun  3 21:04:03 2009	(r39370)
@@ -532,7 +532,7 @@
         Parrot_ex_add_c_handler(interp, &jump_point);
         Parrot_unblock_GC_mark(interp);
         Parrot_unblock_GC_sweep(interp);
-        ret_val = Parrot_runops_fromc_args(interp, sub_pmc, "PF", sub_arg);
+        Parrot_pcc_invoke_sub_from_c_args(interp, sub_pmc, "P->P", sub_arg, &ret_val);
     }
 
     /* thread is finito */

Modified: branches/pcc_rewiring/src/utils.c
==============================================================================
--- branches/pcc_rewiring/src/utils.c	Wed Jun  3 17:05:18 2009	(r39369)
+++ branches/pcc_rewiring/src/utils.c	Wed Jun  3 21:04:03 2009	(r39370)
@@ -902,6 +902,7 @@
 COMPARE(PARROT_INTERP, ARGIN(void *a), ARGIN(void *b), ARGIN(PMC *cmp))
 {
     ASSERT_ARGS(COMPARE)
+    INTVAL result;
     if (PMC_IS_NULL(cmp))
         return VTABLE_cmp(interp, (PMC *)a, (PMC *)b);
 
@@ -910,7 +911,8 @@
         return f(interp, a, b);
     }
 
-    return Parrot_runops_fromc_args_reti(interp, cmp, "IPP", a, b);
+    Parrot_pcc_invoke_sub_from_c_args(interp, cmp, "PP->I", a, b, &result);
+    return result;
 }
 
 /*


More information about the parrot-commits mailing list