[svn:parrot] r37997 - in trunk/src: jit/i386 pmc

cotto at svn.parrot.org cotto at svn.parrot.org
Thu Apr 9 17:53:31 UTC 2009


Author: cotto
Date: Thu Apr  9 17:53:30 2009
New Revision: 37997
URL: https://trac.parrot.org/parrot/changeset/37997

Log:
[JIT] remove undocumented dependency of jit code on PMC internals, fixing TT #365
Infinoid++ for the original patch
Whiteknight++ for the review

Modified:
   trunk/src/jit/i386/jit_defs.c
   trunk/src/pmc/nci.pmc

Modified: trunk/src/jit/i386/jit_defs.c
==============================================================================
--- trunk/src/jit/i386/jit_defs.c	Thu Apr  9 16:46:31 2009	(r37996)
+++ trunk/src/jit/i386/jit_defs.c	Thu Apr  9 17:53:30 2009	(r37997)
@@ -2317,10 +2317,25 @@
         sig++;
     }
 
-    emitm_addl_i_r(pc, 16, emit_ESP);
-    /* get the pmc from stack - movl 12(%ebp), %eax */
+    /* prepare to call VTABLE_get_pointer, set up args */
+    /* interpreter - movl 8(%ebp), %eax */
+    emitm_movl_m_r(interp, pc, emit_EAX, emit_EBP, 0, 1, 8);
+    emitm_movl_r_m(interp, pc, emit_EAX, emit_EBP, 0, 1, temp_calls_offset + 0);
+
+    /* pmc - movl 12(%ebp), %eax */
     emitm_movl_m_r(interp, pc, emit_EAX, emit_EBP, 0, 1, 12);
-    emitm_callm(pc, emit_EAX, emit_None, emit_None, 0);
+    emitm_movl_r_m(interp, pc, emit_EAX, emit_EBP, 0, 1, temp_calls_offset + 4);
+
+    /* get the get_pointer() pointer from the pmc's 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));
+
+    /* call get_pointer(), result goes into eax */
+    emitm_callr(pc, emit_EAX);
+    emitm_addl_i_r(pc, 16, emit_ESP);
+
+    /* call the resulting function pointer */
+    emitm_callr(pc, emit_EAX);
     emitm_subl_i_r(pc, 16, emit_ESP);
 
     /* SAVE OFF EAX */

Modified: trunk/src/pmc/nci.pmc
==============================================================================
--- trunk/src/pmc/nci.pmc	Thu Apr  9 16:46:31 2009	(r37996)
+++ trunk/src/pmc/nci.pmc	Thu Apr  9 17:53:30 2009	(r37997)
@@ -171,6 +171,10 @@
         PObj_flag_SET(private2, SELF);
     }
 
+    VTABLE void *get_pointer() {
+        return PARROT_NCI(SELF)->orig_func;
+    }
+
     VTABLE void set_pointer_keyed_str(STRING *key, void *func) {
         Parrot_NCI_attributes * const nci_info = PARROT_NCI(SELF);
         int                             jitted = 0;
@@ -260,7 +264,7 @@
         nci_info_ret->pcc_params_signature  = nci_info_self->pcc_params_signature;
         nci_info_ret->arity                 = nci_info_self->arity;
         nci_info_ret->jitted                = nci_info_self->jitted;
-        PObj_get_FLAGS(ret)    |= (PObj_get_FLAGS(SELF) & 0x7);
+        PObj_get_FLAGS(ret)                |= (PObj_get_FLAGS(SELF) & 0x7);
 
         return ret;
     }
@@ -312,13 +316,8 @@
 
             nci_jit_sub_t jit_func = (nci_jit_sub_t) D2FPTR(nci_info->func);
 
-            /* TT #365 - Some i386 jit code depends on this.  If t/pmc/nci.t
-             * passes without it, the next line is safe to remove. */
-            PMC_struct_val(SELF) = nci_info->orig_func;
-
             /* Parrot_eprintf(interp, "JITTED %S\n", nci_info->signature); */
-            jit_func(INTERP, SELF,
-                (char *) nci_info->pcc_params_signature->strstart);
+            jit_func(INTERP, SELF, (char *) nci_info->pcc_params_signature->strstart);
         }
         else {
             if (PObj_flag_TEST(private2, SELF)) {


More information about the parrot-commits mailing list