develooper Front page | perl.cvs.parrot | Postings from January 2009

[svn:parrot] r35000 - branches/jit_h_files/src/jit/i386

From:
Whiteknight
Date:
January 5, 2009 10:07
Subject:
[svn:parrot] r35000 - branches/jit_h_files/src/jit/i386
Message ID:
20090105180700.B7DACCB9F9@x12.develooper.com
Author: Whiteknight
Date: Mon Jan  5 10:06:59 2009
New Revision: 35000

Modified:
   branches/jit_h_files/src/jit/i386/jit_defs.c
   branches/jit_h_files/src/jit/i386/jit_emit.h

Log:
[jit_h_files] move a few more functions over.

Modified: branches/jit_h_files/src/jit/i386/jit_defs.c
==============================================================================
--- branches/jit_h_files/src/jit/i386/jit_defs.c	(original)
+++ branches/jit_h_files/src/jit/i386/jit_defs.c	Mon Jan  5 10:06:59 2009
@@ -4,6 +4,12 @@
 #include "parrot/oplib/ops.h"
 #include "jit.h"
 
+#if defined(__cplusplus)
+#  define EXTERN extern "C"
+#else
+#  define EXTERN
+#endif
+
 INTVAL
 get_nci_I(PARROT_INTERP, ARGMOD(call_state *st), int n)
 {
@@ -1076,3 +1082,160 @@
     emitm_jumpm(jit_info->native_ptr, emit_EDX, emit_EAX,
             sizeof (*jit_info->arena.op_map) / 4, 0);
 }
+
+#  define MAP(i) jit_info->optimizer->map_branch[jit_info->op_i + (i)]
+#  include "parrot/oplib/ops.h"
+EXTERN INTVAL Parrot_FixedIntegerArray_get_integer_keyed_int(Interp*, PMC*, INTVAL);
+EXTERN void Parrot_FixedIntegerArray_set_integer_keyed_int(Interp*, PMC*, INTVAL, INTVAL);
+#  define NATIVECODE jit_info->native_ptr
+#  define ROFFS_PMC(x) REG_OFFS_PMC(jit_info->cur_op[(x)])
+#  define ROFFS_INT(x) REG_OFFS_INT(jit_info->cur_op[(x)])
+#  define jit_emit_mov_RM_i(interp, pc, reg, offs) \
+    emitm_movl_m_r((interp), (pc), (reg), emit_EBX, emit_None, 1, (offs))
+#  define jit_emit_cmp_ri_i(interp, pc, reg, imm) \
+    emitm_alul_i_r((pc), 0x81, emit_b111, (imm), (reg))
+#  define emitm_js   8
+/* Integer comparisons */
+#  define jit_emit_cmp_rr(pc, reg1, reg2) \
+    emitm_alul_r_r((pc), 0x39, (reg2), (reg1))
+#  define jit_emit_cmp_rr_i(pc, r1, r2) jit_emit_cmp_rr((pc), (r1), (r2))
+#  define emitm_jnl 13
+#  define emitm_js   8
+
+#  define emitm_movl_r_m(interp, pc, reg1, b, i, s, d) \
+    emitm_movX_Y_Z((interp), 0x89, (pc), (reg1), (b), (i), (s), (d))
+	
+char*
+jit_set_i_p_ki(Parrot_jit_info_t *jit_info, PARROT_INTERP, size_t offset)
+{
+    char *L1, *L2, *L3, *L4;
+    /*
+     * mov $2, %edi
+     * mov (vtable)%edi, %eax
+     * mov (offset)%eax, %esi
+     * cmp Parrot_FixedIntegerArray_get_integer_keyed_int, %esi
+     * jne L1
+     */
+    jit_emit_mov_RM_i(interp, NATIVECODE, emit_EDI, ROFFS_PMC(2));
+    emitm_movl_m_r(interp, NATIVECODE, emit_EAX, emit_EDI, emit_None, 1,
+            offsetof(struct PMC, vtable));
+    emitm_movl_m_r(interp, NATIVECODE, emit_ESI, emit_EAX, emit_None, 1, offset);
+    jit_emit_cmp_ri_i(interp, NATIVECODE, emit_ESI,
+            Parrot_FixedIntegerArray_get_integer_keyed_int);
+    L1 = NATIVECODE;
+    emitm_jxs(NATIVECODE, emitm_jnz, 0);
+    /*
+     * mov $3, %ecx
+     * cmp %ecx, 0
+     * js L2
+     * mov (int_val)%edi, %eax
+     * cmp %ecx, $eax
+     * jge L3
+     *
+     */
+    if (MAP(3)) {
+        jit_emit_mov_rr_i(NATIVECODE, emit_ECX, MAP(3));
+    }
+    else {
+        jit_emit_mov_RM_i(interp, NATIVECODE, emit_ECX, ROFFS_INT(3));
+    }
+    /*  range check */
+    jit_emit_cmp_ri_i(interp, NATIVECODE, emit_ECX, 0);
+    L2 = NATIVECODE;
+    emitm_jxs(NATIVECODE, emitm_js, 0);
+    emitm_movl_m_r(interp, NATIVECODE, emit_EAX, emit_EDI, 0, 1,
+            offsetof(struct PMC, cache._i._int_val));
+    jit_emit_cmp_rr_i(NATIVECODE, emit_ECX, emit_EAX);
+    L3 = NATIVECODE;
+    emitm_jxs(NATIVECODE, emitm_jnl, 0);
+
+    /*
+     * mov (data)%edi, %eax
+     * mov (%eax, %ecx, 4), %eax
+     * jmp L4
+     */
+    emitm_movl_m_r(interp, NATIVECODE, emit_EAX, emit_EDI, 0, 1,
+            offsetof(struct PMC, data));
+    emitm_movl_m_r(interp, NATIVECODE, emit_EAX, emit_EAX, emit_ECX, 4, 0);
+
+    L4 = NATIVECODE;
+    emitm_jumps(NATIVECODE, 0);
+    /* L1: L2: L3: */
+    L1[1] = (char)(NATIVECODE - L1 - 2);
+    L2[1] = (char)(NATIVECODE - L2 - 2);
+    L3[1] = (char)(NATIVECODE - L3 - 2);
+    return L4;
+}
+
+char*
+jit_set_p_ki_i(Parrot_jit_info_t *jit_info, PARROT_INTERP, size_t offset)
+{
+    char *L1, *L2, *L3, *L4;
+    /*
+     * mov $1, %edi
+     * mov (vtable)%edi, %eax
+     * mov (offset)%eax, %esi
+     * cmp Parrot_FixedIntegerArray_set_integer_keyed_int, %esi
+     * jne L1
+     */
+    jit_emit_mov_RM_i(interp, NATIVECODE, emit_EDI, ROFFS_PMC(1));
+    emitm_movl_m_r(interp, NATIVECODE, emit_EAX, emit_EDI, emit_None, 1,
+            offsetof(struct PMC, vtable));
+    emitm_movl_m_r(interp, NATIVECODE, emit_ESI, emit_EAX, emit_None, 1, offset);
+    jit_emit_cmp_ri_i(interp, NATIVECODE, emit_ESI,
+            Parrot_FixedIntegerArray_set_integer_keyed_int);
+    L1 = NATIVECODE;
+    emitm_jxs(NATIVECODE, emitm_jnz, 0);
+    /*
+     * mov $2, %ecx
+     * cmp %ecx, 0
+     * js L2
+     * mov (int_val)%edi, %eax
+     * cmp %ecx, $eax
+     * jge L3
+     *
+     */
+    if (MAP(2)) {
+        jit_emit_mov_rr_i(NATIVECODE, emit_ECX, MAP(2));
+    }
+    else {
+        jit_emit_mov_RM_i(interp, NATIVECODE, emit_ECX, ROFFS_INT(2));
+    }
+    /*  range check */
+    jit_emit_cmp_ri_i(interp, NATIVECODE, emit_ECX, 0);
+    L2 = NATIVECODE;
+    emitm_jxs(NATIVECODE, emitm_js, 0);
+    emitm_movl_m_r(interp, NATIVECODE, emit_EAX, emit_EDI, 0, 1,
+            offsetof(struct PMC, cache._i._int_val));
+    jit_emit_cmp_rr_i(NATIVECODE, emit_ECX, emit_EAX);
+    L3 = NATIVECODE;
+    emitm_jxs(NATIVECODE, emitm_jnl, 0);
+
+    /*
+     * mov (data)%eax, %eax
+     * mov $3, %edx
+     * mov $edx, (%eax, %ecx, 4)
+     * jmp L4
+     */
+    emitm_movl_m_r(interp, NATIVECODE, emit_EAX, emit_EDI, 0, 1,
+            offsetof(struct PMC, data));
+    if (MAP(3)) {
+        jit_emit_mov_rr_i(NATIVECODE, emit_EDX, MAP(3));
+    }
+    else {
+        jit_emit_mov_RM_i(interp, NATIVECODE, emit_EDX, ROFFS_INT(3));
+    }
+    emitm_movl_r_m(interp, NATIVECODE, emit_EDX, emit_EAX, emit_ECX, 4, 0);
+
+    L4 = NATIVECODE;
+    emitm_jumps(NATIVECODE, 0);
+    /* L1: L2: L3: */
+    L1[1] = (char)(NATIVECODE - L1 - 2);
+    L2[1] = (char)(NATIVECODE - L2 - 2);
+    L3[1] = (char)(NATIVECODE - L3 - 2);
+    return L4;
+}
+
+#undef NATIVECODE
+#undef ROFFS_PMC
+#undef ROFFS_INT

Modified: branches/jit_h_files/src/jit/i386/jit_emit.h
==============================================================================
--- branches/jit_h_files/src/jit/i386/jit_emit.h	(original)
+++ branches/jit_h_files/src/jit/i386/jit_emit.h	Mon Jan  5 10:06:59 2009
@@ -1644,136 +1644,13 @@
 #  define ROFFS_INT(x) REG_OFFS_INT(jit_info->cur_op[(x)])
 #  define NATIVECODE jit_info->native_ptr
 
-static char*
+char*
 jit_set_i_p_ki(Parrot_jit_info_t *jit_info, PARROT_INTERP, size_t offset)
-{
-    char *L1, *L2, *L3, *L4;
-    /*
-     * mov $2, %edi
-     * mov (vtable)%edi, %eax
-     * mov (offset)%eax, %esi
-     * cmp Parrot_FixedIntegerArray_get_integer_keyed_int, %esi
-     * jne L1
-     */
-    jit_emit_mov_RM_i(interp, NATIVECODE, emit_EDI, ROFFS_PMC(2));
-    emitm_movl_m_r(interp, NATIVECODE, emit_EAX, emit_EDI, emit_None, 1,
-            offsetof(struct PMC, vtable));
-    emitm_movl_m_r(interp, NATIVECODE, emit_ESI, emit_EAX, emit_None, 1, offset);
-    jit_emit_cmp_ri_i(interp, NATIVECODE, emit_ESI,
-            Parrot_FixedIntegerArray_get_integer_keyed_int);
-    L1 = NATIVECODE;
-    emitm_jxs(NATIVECODE, emitm_jnz, 0);
-    /*
-     * mov $3, %ecx
-     * cmp %ecx, 0
-     * js L2
-     * mov (int_val)%edi, %eax
-     * cmp %ecx, $eax
-     * jge L3
-     *
-     */
-    if (MAP(3)) {
-        jit_emit_mov_rr_i(NATIVECODE, emit_ECX, MAP(3));
-    }
-    else {
-        jit_emit_mov_RM_i(interp, NATIVECODE, emit_ECX, ROFFS_INT(3));
-    }
-    /*  range check */
-    jit_emit_cmp_ri_i(interp, NATIVECODE, emit_ECX, 0);
-    L2 = NATIVECODE;
-    emitm_jxs(NATIVECODE, emitm_js, 0);
-    emitm_movl_m_r(interp, NATIVECODE, emit_EAX, emit_EDI, 0, 1,
-            offsetof(struct PMC, cache._i._int_val));
-    jit_emit_cmp_rr_i(NATIVECODE, emit_ECX, emit_EAX);
-    L3 = NATIVECODE;
-    emitm_jxs(NATIVECODE, emitm_jnl, 0);
+;
 
-    /*
-     * mov (data)%edi, %eax
-     * mov (%eax, %ecx, 4), %eax
-     * jmp L4
-     */
-    emitm_movl_m_r(interp, NATIVECODE, emit_EAX, emit_EDI, 0, 1,
-            offsetof(struct PMC, data));
-    emitm_movl_m_r(interp, NATIVECODE, emit_EAX, emit_EAX, emit_ECX, 4, 0);
-
-    L4 = NATIVECODE;
-    emitm_jumps(NATIVECODE, 0);
-    /* L1: L2: L3: */
-    L1[1] = (char)(NATIVECODE - L1 - 2);
-    L2[1] = (char)(NATIVECODE - L2 - 2);
-    L3[1] = (char)(NATIVECODE - L3 - 2);
-    return L4;
-}
-
-static char*
+char*
 jit_set_p_ki_i(Parrot_jit_info_t *jit_info, PARROT_INTERP, size_t offset)
-{
-    char *L1, *L2, *L3, *L4;
-    /*
-     * mov $1, %edi
-     * mov (vtable)%edi, %eax
-     * mov (offset)%eax, %esi
-     * cmp Parrot_FixedIntegerArray_set_integer_keyed_int, %esi
-     * jne L1
-     */
-    jit_emit_mov_RM_i(interp, NATIVECODE, emit_EDI, ROFFS_PMC(1));
-    emitm_movl_m_r(interp, NATIVECODE, emit_EAX, emit_EDI, emit_None, 1,
-            offsetof(struct PMC, vtable));
-    emitm_movl_m_r(interp, NATIVECODE, emit_ESI, emit_EAX, emit_None, 1, offset);
-    jit_emit_cmp_ri_i(interp, NATIVECODE, emit_ESI,
-            Parrot_FixedIntegerArray_set_integer_keyed_int);
-    L1 = NATIVECODE;
-    emitm_jxs(NATIVECODE, emitm_jnz, 0);
-    /*
-     * mov $2, %ecx
-     * cmp %ecx, 0
-     * js L2
-     * mov (int_val)%edi, %eax
-     * cmp %ecx, $eax
-     * jge L3
-     *
-     */
-    if (MAP(2)) {
-        jit_emit_mov_rr_i(NATIVECODE, emit_ECX, MAP(2));
-    }
-    else {
-        jit_emit_mov_RM_i(interp, NATIVECODE, emit_ECX, ROFFS_INT(2));
-    }
-    /*  range check */
-    jit_emit_cmp_ri_i(interp, NATIVECODE, emit_ECX, 0);
-    L2 = NATIVECODE;
-    emitm_jxs(NATIVECODE, emitm_js, 0);
-    emitm_movl_m_r(interp, NATIVECODE, emit_EAX, emit_EDI, 0, 1,
-            offsetof(struct PMC, cache._i._int_val));
-    jit_emit_cmp_rr_i(NATIVECODE, emit_ECX, emit_EAX);
-    L3 = NATIVECODE;
-    emitm_jxs(NATIVECODE, emitm_jnl, 0);
-
-    /*
-     * mov (data)%eax, %eax
-     * mov $3, %edx
-     * mov $edx, (%eax, %ecx, 4)
-     * jmp L4
-     */
-    emitm_movl_m_r(interp, NATIVECODE, emit_EAX, emit_EDI, 0, 1,
-            offsetof(struct PMC, data));
-    if (MAP(3)) {
-        jit_emit_mov_rr_i(NATIVECODE, emit_EDX, MAP(3));
-    }
-    else {
-        jit_emit_mov_RM_i(interp, NATIVECODE, emit_EDX, ROFFS_INT(3));
-    }
-    emitm_movl_r_m(interp, NATIVECODE, emit_EDX, emit_EAX, emit_ECX, 4, 0);
-
-    L4 = NATIVECODE;
-    emitm_jumps(NATIVECODE, 0);
-    /* L1: L2: L3: */
-    L1[1] = (char)(NATIVECODE - L1 - 2);
-    L2[1] = (char)(NATIVECODE - L2 - 2);
-    L3[1] = (char)(NATIVECODE - L3 - 2);
-    return L4;
-}
+;
 
 #  undef ROFFS_PMC
 #  undef ROFFS_INT



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About