Commits

Anonymous committed c17f36f

#123: Mainlining directly

  • Participants
  • Parent commits 9dfaf4d

Comments (0)

Files changed (5)

File src/tools/pmImgCreator.py

         # for each entry create fxn
         for (funcname, funcstr) in self.nativetable:
             fileBuff.append("PmReturn_t\n"
-                            "%s(pPmFrame_t *ppframe, signed char numargs)\n"
+                            "%s(pPmFrame_t *ppframe)\n"
                             "{\n"
                             "%s\n"
                             "}\n\n" % (funcname, funcstr))
 
         # create fxn table
         fileBuff.append("/* native function lookup table */\n"
-                        "PmReturn_t (* %s[])(pPmFrame_t *, signed char) =\n"
+                        "PmReturn_t (* %s[])(pPmFrame_t *) =\n"
                         "{\n" % (NATIVE_TABLE_NAME[self.imgtarget]))
 
         # put all native funcs in the table

File src/vm/frame.h

  * The maximum number of local variables a native function can have.
  * This defines the length of the locals array in the native frame struct.
  */
-#define NATIVE_NUM_LOCALS   8
+#define NATIVE_MAX_NUM_LOCALS   8
 
 
 /***************************************************************
 
     /** Counter for number of times the GC runs in one native code session */
     uint8_t nf_gcCount;
-    
+
+    /** Number of args passed to the native function */
+    uint8_t nf_numlocals;
+
     /** Local vars */
-    pPmObj_t nf_locals[NATIVE_NUM_LOCALS];
+    pPmObj_t nf_locals[NATIVE_MAX_NUM_LOCALS];
 } PmNativeFrame_t,
  *pPmNativeFrame_t;
 

File src/vm/heap.c

 
             /* Mark the consts tuple */
             retval = heap_gcMarkObj((pPmObj_t)((pPmCo_t)pobj)->co_consts);
+            PM_RETURN_IF_ERROR(retval);
             break;
 
         case OBJ_TYPE_MOD:
                 PM_RETURN_IF_ERROR(retval);
 
                 /* Mark the stack object */
-                retval = heap_gcMarkObj((pPmObj_t)
-                                        gVmGlobal.nativeframe.nf_stack);
+                retval = heap_gcMarkObj(gVmGlobal.nativeframe.nf_stack);
                 PM_RETURN_IF_ERROR(retval);
 
                 /* Mark the args to the native func */
-                /* TODO: a stale pointer here may cause trouble */
-                for (i = 0; i < NATIVE_NUM_LOCALS; i++)
+                for (i = 0; i < NATIVE_GET_NUM_ARGS(); i++)
                 {
-                    retval = heap_gcMarkObj((pPmObj_t)
-                                            gVmGlobal.nativeframe.nf_locals);
+                    retval = heap_gcMarkObj(gVmGlobal.nativeframe
+                                            .nf_locals[i]);
                     PM_RETURN_IF_ERROR(retval);
                 }
             }

File src/vm/interp.c

  * Prototypes
  **************************************************************/
 
-extern PmReturn_t (*std_nat_fxn_table[]) (pPmFrame_t *, signed char);
-extern PmReturn_t (*usr_nat_fxn_table[]) (pPmFrame_t *, signed char);
+extern PmReturn_t (*std_nat_fxn_table[]) (pPmFrame_t *);
+extern PmReturn_t (*usr_nat_fxn_table[]) (pPmFrame_t *);
 
 
 /***************************************************************
                          OBJ_TYPE_NOB)
                 {
                     /* Ensure num args fits in native frame */
-                    if (t16 > NATIVE_NUM_LOCALS)
+                    if (t16 > NATIVE_MAX_NUM_LOCALS)
                     {
                         PM_RAISE(retval, PM_RET_EX_SYS);
                         break;
                     }
 
-                    /* Keep numargs */
-                    t8 = (int8_t)t16;
+                    /* Set number of locals (arguments) */
+                    gVmGlobal.nativeframe.nf_numlocals = (uint8_t)t16;
 
                     /* Pop args from stack */
                     while (--t16 >= 0)
                     /* Positive index is a stdlib func */
                     if (t16 >= 0)
                     {
-                        retval = std_nat_fxn_table[t16] (&FP, t8);
+                        retval = std_nat_fxn_table[t16] (&FP);
                     }
 
                     /* Negative index is a usrlib func */
                     else
                     {
-                        retval = usr_nat_fxn_table[-t16] (&FP, t8);
+                        retval = usr_nat_fxn_table[-t16] (&FP);
                     }
 
                     /*

File src/vm/interp.h

 /** gets a pointer to the frame that called this native fxn */
 #define NATIVE_GET_PFRAME()   (*ppframe)
 /** gets the number of args passed to the native fxn */
-#define NATIVE_GET_NUM_ARGS() (numargs)
+#define NATIVE_GET_NUM_ARGS() (gVmGlobal.nativeframe.nf_numlocals)
 
 
 /***************************************************************