[svn:parrot] r41603 - in branches/pcc_reapply: include/parrot src/call src/ops

allison at svn.parrot.org allison at svn.parrot.org
Thu Oct 1 23:02:34 UTC 2009


Author: allison
Date: Thu Oct  1 23:02:32 2009
New Revision: 41603
URL: https://trac.parrot.org/parrot/changeset/41603

Log:
[pcc] More intelligent handling of a null CallSignature in fill_returns, though
it's still not perfect, due to the asymmetrical nature of return argument
passing (i.e. return arguments aren't currently handled the same way as call
arguments, though they should be and will be).

Modified:
   branches/pcc_reapply/include/parrot/call.h
   branches/pcc_reapply/src/call/pcc.c
   branches/pcc_reapply/src/ops/core.ops

Modified: branches/pcc_reapply/include/parrot/call.h
==============================================================================
--- branches/pcc_reapply/include/parrot/call.h	Thu Oct  1 22:53:09 2009	(r41602)
+++ branches/pcc_reapply/include/parrot/call.h	Thu Oct  1 23:02:32 2009	(r41603)
@@ -291,11 +291,10 @@
 
 PARROT_EXPORT
 void Parrot_pcc_fill_returns_from_op(PARROT_INTERP,
-    ARGMOD(PMC *call_object),
+    ARGMOD_NULLOK(PMC *call_object),
     ARGIN(PMC *raw_sig),
     ARGIN(opcode_t *raw_returns))
         __attribute__nonnull__(1)
-        __attribute__nonnull__(2)
         __attribute__nonnull__(3)
         __attribute__nonnull__(4)
         FUNC_MODIFIES(*call_object);
@@ -460,7 +459,6 @@
 #define ASSERT_ARGS_Parrot_pcc_fill_returns_from_op \
      __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
        PARROT_ASSERT_ARG(interp) \
-    , PARROT_ASSERT_ARG(call_object) \
     , PARROT_ASSERT_ARG(raw_sig) \
     , PARROT_ASSERT_ARG(raw_returns))
 #define ASSERT_ARGS_Parrot_pcc_invoke_from_sig_object \

Modified: branches/pcc_reapply/src/call/pcc.c
==============================================================================
--- branches/pcc_reapply/src/call/pcc.c	Thu Oct  1 22:53:09 2009	(r41602)
+++ branches/pcc_reapply/src/call/pcc.c	Thu Oct  1 23:02:32 2009	(r41603)
@@ -1351,14 +1351,14 @@
 
 PARROT_EXPORT
 void
-Parrot_pcc_fill_returns_from_op(PARROT_INTERP, ARGMOD(PMC *call_object),
+Parrot_pcc_fill_returns_from_op(PARROT_INTERP, ARGMOD_NULLOK(PMC *call_object),
         ARGIN(PMC *raw_sig), ARGIN(opcode_t *raw_returns))
 {
     ASSERT_ARGS(Parrot_pcc_fill_returns_from_op)
     INTVAL return_list_elements;
     PMC *ctx = CURRENT_CONTEXT(interp);
-    PMC * const return_list = VTABLE_get_attr_str(interp, call_object, CONST_STRING(interp, "returns"));
-    PMC * const caller_return_flags = VTABLE_get_attr_str(interp, call_object, CONST_STRING(interp, "return_flags"));
+    PMC *return_list;
+    PMC *caller_return_flags;
     INTVAL raw_return_count     = VTABLE_elements(interp, raw_sig);
     INTVAL return_index = 0;
     INTVAL return_list_index = 0;
@@ -1369,6 +1369,18 @@
     if (PARROT_ERRORS_test(interp, PARROT_ERRORS_RESULT_COUNT_FLAG))
             err_check = 1;
 
+    /* A null call object is fine if there are no arguments and no returns. */
+    if (PMC_IS_NULL(call_object)) {
+        if (return_list_elements > 0) {
+            if (err_check)
+                Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
+                        "too many return values: %d passed, 0 expected",
+                        return_list_elements);
+            return;
+        }
+    }
+
+    return_list = VTABLE_get_attr_str(interp, call_object, CONST_STRING(interp, "returns"));
     if (PMC_IS_NULL(return_list)) {
         if (err_check)
             Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
@@ -1379,6 +1391,8 @@
     else
         return_list_elements = VTABLE_elements(interp, return_list);
 
+    caller_return_flags = VTABLE_get_attr_str(interp, call_object, CONST_STRING(interp, "return_flags"));
+
 
     if (raw_return_count > return_list_elements) {
         if (err_check)

Modified: branches/pcc_reapply/src/ops/core.ops
==============================================================================
--- branches/pcc_reapply/src/ops/core.ops	Thu Oct  1 22:53:09 2009	(r41602)
+++ branches/pcc_reapply/src/ops/core.ops	Thu Oct  1 23:02:32 2009	(r41603)
@@ -583,7 +583,8 @@
 
     Parrot_pcc_fill_returns_from_op(interp, call_object, signature, raw_returns);
 
-    gc_unregister_pmc(interp, call_object);
+    if (!PMC_IS_NULL(call_object))
+        gc_unregister_pmc(interp, call_object);
     Parrot_pcc_set_signature(interp, ctx, NULL);
 
     argc = VTABLE_elements(interp, signature);


More information about the parrot-commits mailing list