Duh. Here's a unified diff.

-- 
Jason
Index: docs/jit.pod
===================================================================
RCS file: /cvs/public/parrot/docs/jit.pod,v
retrieving revision 1.4
diff -u -r1.4 jit.pod
--- docs/jit.pod        29 Jul 2002 21:13:38 -0000      1.4
+++ docs/jit.pod        1 Aug 2002 19:46:23 -0000
@@ -73,7 +73,9 @@
 =item jit/${jitcpuarch}/core.jit
 
 The functions to generate native code for core parrot opcodes are specified
-here.
+here. To simplify the maintenance of these functions, they are specified in a
+format that is pre-processed by B<jit2h.pl> to produce a valid C source file,
+B<jit_cpu.c>. See L<Format of .jit Files> below.
 
 =item jit/${jitcpuarch}/string.jit
 
@@ -116,7 +118,7 @@
  
 =item jit2h.pl
 
-Reads the .jit files and prints the struct opcode_assembly_t.
+Preprocesses the .jit files to produce and prints the struct opcode_assembly_t.
 
 =back
 
@@ -129,12 +131,18 @@
 
 =item I<op-name> { I<body> }
 
-Where I<op-name> is the name of the Parrot opcode, and I<body> consists
-of a sequence of the following forms:
-
-=item Assembly instruction.
-
-Which may have one of this B<Identifiers> as an argument: 
+Where I<op-name> is the name of the Parrot opcode, and I<body> consists of C
+syntax code which may contain any of the identifiers listed in the following
+section.
+
+=item Identifiers
+
+In general, prefixing an identifier with I<&> yields the address of the
+referenced Parrot register or constant.  If an identifier is given without a
+prefix, the value is returned by default.   To emphasis the use of the value,
+the I<*> prefix may be used.  Since Parrot register values vary during code
+execution, their values can not be obtained through identifier substitution
+alone.
 
 B<INT_REG[n]>
 
@@ -207,8 +215,6 @@
 B<TEMP_CHAR[n]>
 
 Gets replaced by the I<n>th temporary char array.
-
-You must preside all the identifiers with I<&> requesting the address of that 
identifier, or I<*> requesting the value, I<*> can be used only with constants since 
the replacement is done before start running.
 
 B<&INTERPRETER[n]>
 
Index: jit/i386/core.jit
===================================================================
RCS file: /cvs/public/parrot/jit/i386/core.jit,v
retrieving revision 1.20
diff -u -r1.20 core.jit
--- jit/i386/core.jit   5 Jul 2002 11:15:42 -0000       1.20
+++ jit/i386/core.jit   1 Aug 2002 19:46:23 -0000
@@ -5,7 +5,9 @@
 ;
 
 Parrot_end {
+    emitm_addl_i_r(jit_info->native_ptr, 4, emit_ESP);
     NATIVECODE = emit_popl_r(NATIVECODE, emit_ESI);
+    NATIVECODE = emit_popl_r(NATIVECODE, emit_EBP);
     emitm_ret(NATIVECODE);
 }
 
Index: jit/i386/jit_emit.h
===================================================================
RCS file: /cvs/public/parrot/jit/i386/jit_emit.h,v
retrieving revision 1.4
diff -u -r1.4 jit_emit.h
--- jit/i386/jit_emit.h 5 Jul 2002 11:11:09 -0000       1.4
+++ jit/i386/jit_emit.h 1 Aug 2002 19:46:24 -0000
@@ -98,7 +98,7 @@
             break;
         default :
             internal_exception(JIT_ERROR, "Invalid scale factor %d\n", scale);
-            break;
+            return;
     }
 
     *pc = scale_byte | (i == emit_None ? emit_Index_None : emit_reg_Index(i)) |
@@ -108,8 +108,8 @@
 static char *emit_r_X(char *pc, int reg_opcode, int base, int i, int scale,
             long disp)
 {
-    if((i && !scale) || (scale && !i)){
-    internal_exception(JIT_ERROR,
+    if(i && !scale){
+        internal_exception(JIT_ERROR,
                             "emit_r_X passed invalid scale+index combo\n");
     }
 
@@ -341,6 +341,8 @@
 
 #define emitm_alul_i_r(pc, op1, op2, imm, reg) { *(pc++) = op1; *(pc++) = 
emit_alu_X_r(op2, reg); *(long *)((pc)) = (long)(imm); (pc) += 4; }
 
+#define emitm_alub_i_r(pc, op1, op2, imm, reg) { *(pc++) = op1; *(pc++) = 
+emit_alu_X_r(op2, reg); *(pc++) = (char)(imm); }
+
 #define emitm_alul_i_m(pc, op1, op2, imm, b, i, s, d) { \
  *(pc++) = op1; \
  (pc) = emit_r_X(pc, emit_reg(op2), b, i, s, d); \
@@ -366,6 +368,8 @@
 /* ADDs */
 
 #define emitm_addb_r_r(pc, reg1, reg2) emitm_alul_r_r(pc, 0x00, reg1, reg2)
+#define emitm_addb_i_r(pc, imm, reg)   emitm_alub_i_r(pc, 0x83, emit_b000, imm, reg)
+
 #define emitm_addl_r_r(pc, reg1, reg2) emitm_alul_r_r(pc, 0x01, reg1, reg2)
 #define emitm_addl_i_r(pc, imm, reg)   emitm_alul_i_r(pc, 0x81, emit_b000, imm, reg)
 #define emitm_addl_r_m(pc, reg, b, i, s, d) emitm_alul_r_m(pc, 0x01, reg, b, i, s, d)
@@ -667,14 +671,25 @@
 void Parrot_jit_begin(Parrot_jit_info *jit_info,
                       struct Parrot_Interp * interpreter)
 {
+    /* Maintain the stack frame pointer for the sake of gdb */
+    jit_info->native_ptr = emit_pushl_r(jit_info->native_ptr, emit_EBP);
+    emitm_movl_r_r(jit_info->native_ptr, emit_ESP, emit_EBP);
+
+    /* Save ESI, as it's value is clobbered by jit_cpcf_op */
     jit_info->native_ptr = emit_pushl_r(jit_info->native_ptr, emit_ESI);
+
+    /* Cheat on op function calls by writing the interpreter arg on the stack
+     * just once. If an op function ever modifies the interpreter argument on
+     * the stack this will stop working !!! */
+    emitm_pushl_i(jit_info->native_ptr, interpreter);
+
+    /* Point ESI to the opcode-native code map array */ 
     emitm_movl_i_r(jit_info->native_ptr, jit_info->op_map, emit_ESI);
 }
 
 void Parrot_jit_normal_op(Parrot_jit_info *jit_info,
                           struct Parrot_Interp * interpreter)
 {
-    emitm_pushl_i(jit_info->native_ptr, interpreter);
     emitm_pushl_i(jit_info->native_ptr, jit_info->cur_op);
 
     Parrot_jit_newfixup(jit_info);
@@ -683,7 +698,7 @@
         (void (*)(void))interpreter->op_func_table[*(jit_info->cur_op)];
 
     emitm_calll(jit_info->native_ptr, 0xdeafc0de);
-    emitm_addl_i_r(jit_info->native_ptr, 8, emit_ESP);
+    emitm_addb_i_r(jit_info->native_ptr, 4, emit_ESP);
 }
 
 void Parrot_jit_cpcf_op(Parrot_jit_info *jit_info,
Index: jit/sun4/jit_emit.h
===================================================================
RCS file: /cvs/public/parrot/jit/sun4/jit_emit.h,v
retrieving revision 1.3
diff -u -r1.3 jit_emit.h
--- jit/sun4/jit_emit.h 4 Jul 2002 22:40:59 -0000       1.3
+++ jit/sun4/jit_emit.h 1 Aug 2002 19:46:25 -0000
@@ -6,6 +6,17 @@
 ** $Id: jit_emit.h,v 1.3 2002/07/04 22:40:59 mrjoltcola Exp $
 **/
 
+/* 
+ * SPARC JIT overview:
+ * 
+ * The interpreter pointer is kept in i0.
+ * The address of register I0 is stored in i1, with all parrot register access
+ * performed relative to this register.
+ * The address of the opcode - native code mapping array is kept in i3.
+ *
+ * See IMPORTANT SHORTCUTS below.
+ * /
+
 /* Sparc register numbers */
 #define emitm_g(n) (n)
 #define emitm_o(n) ((n) + 8)
@@ -264,13 +275,27 @@
 /* Fixup types */
 enum  {JIT_BRANCH, JIT_CALL30 };
 
-/* Shortcuts for registers */
+/* 
+ *
+ * IMPORTANT SHORTCUTS
+ *
+ * */ 
+    
+/* The register holding the interpreter pointer */
 #define Parrot_jit_intrp emitm_i(0)
+
+/* The register holding the address of I0 */
 #define Parrot_jit_regbase emitm_i(1)
+
+/* The register containing the address of the opmap */
 #define Parrot_jit_opmap emitm_i(3)
+
+/* The scratch register used for certain address calculations */
 #define Parrot_jit_tmp emitm_l(7)
 
 #define Parrot_jit_regbase_ptr(i) &((i)->ctx.int_reg.registers[0])
+
+/* The offset of a Parrot register from the base register */
 #define Parrot_jit_regoff(a, i) (unsigned)(a) - (unsigned)(Parrot_jit_regbase_ptr(i))
 
 /* Generate conditional branch to offset from current parrot op */
@@ -299,6 +324,7 @@
     emitm_bicc(jit_info->native_ptr, annul, cond, 0);
 }
 
+/* This function loads a value */
 static void Parrot_jit_int_load(Parrot_jit_info *jit_info,
                              struct Parrot_Interp *interpreter,
                              int param,

Reply via email to