[svn:parrot] r41433 - trunk/src

NotFound at svn.parrot.org NotFound at svn.parrot.org
Wed Sep 23 15:16:47 UTC 2009


Author: NotFound
Date: Wed Sep 23 15:16:47 2009
New Revision: 41433
URL: https://trac.parrot.org/parrot/changeset/41433

Log:
[nci] fix and simplify handling of 'p' arguments in frame_builder

Modified:
   trunk/src/frame_builder.c
   trunk/src/frame_builder.h

Modified: trunk/src/frame_builder.c
==============================================================================
--- trunk/src/frame_builder.c	Wed Sep 23 15:05:11 2009	(r41432)
+++ trunk/src/frame_builder.c	Wed Sep 23 15:16:47 2009	(r41433)
@@ -156,6 +156,28 @@
     return UVal_pmc(st->val);
 }
 
+PARROT_WARN_UNUSED_RESULT
+PARROT_CAN_RETURN_NULL
+void*
+get_nci_p(PARROT_INTERP, ARGMOD(call_state *st), int n)
+{
+    /*
+     * excessive args are passed as NULL
+     * used by e.g. MMD infix like __add
+     */
+    if (n < st->src.n) {
+        PMC *value;
+        Parrot_fetch_arg_nci(interp, st);
+        value = UVal_pmc(st->val);
+        if (PMC_IS_NULL(value))
+            return NULL;
+        else
+            return VTABLE_get_pointer(interp, value);
+    }
+    else
+        return NULL;
+}
+
 /*
  * set return value
  */
@@ -497,18 +519,8 @@
                 arg_count--;
                 break;
             case 'p':   /* push pmc->data */
-                emitm_call_cfunc(pc, get_nci_P);
-                /* save off PMC* */
-                emitm_movl_r_m(interp, pc, emit_EAX, emit_EBP, 0, 1, temp_calls_offset + 4);
-                /* lookup get_pointer in VTABLE */
-                emitm_movl_m_r(interp, pc, emit_EAX, emit_EAX, 0, 1, offsetof(PMC, vtable));
-                emitm_movl_m_r(interp, pc, emit_EAX, emit_EAX, 0, 1, offsetof(VTABLE, get_pointer));
-                emitm_callr(pc, emit_EAX);
+                emitm_call_cfunc(pc, get_nci_p);
                 emitm_movl_r_m(interp, pc, emit_EAX, emit_EBP, 0, 1, args_offset);
-                /* reset ESP(4) */
-                emitm_lea_m_r(interp, pc, emit_EAX, emit_EBP, 0, 1, st_offset);
-                emitm_movl_r_m(interp, pc, emit_EAX, emit_EBP, 0, 1, temp_calls_offset + 4);
-
                 break;
             case 'O':   /* push PMC * object in P2 */
             case 'P':   /* push PMC * */

Modified: trunk/src/frame_builder.h
==============================================================================
--- trunk/src/frame_builder.h	Wed Sep 23 15:05:11 2009	(r41432)
+++ trunk/src/frame_builder.h	Wed Sep 23 15:16:47 2009	(r41433)
@@ -70,6 +70,11 @@
 PMC*
 get_nci_P(PARROT_INTERP, ARGMOD(call_state *st), int n);
 
+PARROT_WARN_UNUSED_RESULT
+PARROT_CAN_RETURN_NULL
+void*
+get_nci_p(PARROT_INTERP, ARGMOD(call_state *st), int n);
+
 #define GET_NCI_I(n) get_nci_I(interp, &st, (n))
 #define GET_NCI_S(n) get_nci_S(interp, &st, (n))
 #define GET_NCI_N(n) get_nci_N(interp, &st, (n))


More information about the parrot-commits mailing list