develooper Front page | perl.cvs.parrot | Postings from December 2008

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

From:
Whiteknight
Date:
December 21, 2008 14:35
Subject:
[svn:parrot] r34220 - branches/jit_h_files/src/jit/i386
Message ID:
20081221223537.2703CCBA12@x12.develooper.com
Author: Whiteknight
Date: Sun Dec 21 14:35:31 2008
New Revision: 34220

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] moving a function definition back into the .h file because it's conditionally defined in two different ways. Will find a better solution later

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	Sun Dec 21 14:35:31 2008
@@ -2006,142 +2006,6 @@
     jit_emit_finit(jit_info->native_ptr);
 }
 
-#  ifdef JIT_CGP
-
-void
-Parrot_jit_normal_op(Parrot_jit_info_t *jit_info,
-                     PARROT_INTERP)
-{
-    Parrot_jit_optimizer_section_ptr cur_section =
-        jit_info->optimizer->cur_section;
-    int last_is_branch = 0;
-    void ** offset;
-
-    PARROT_ASSERT(op_jit[*jit_info->cur_op].extcall == 1);
-    if (cur_section->done == 1)
-        return;
-    else if (cur_section->done == -1 && --cur_section->ins_count > 0)
-        return;
-    /* check, where section ends
-     */
-    if (interp->op_info_table[*cur_section->end].jump)
-        last_is_branch = 1;
-    else if (cur_section->next && !cur_section->next->isjit)
-        last_is_branch = 1;
-    /* if more then 1 op, then jump to CGP, branches are never
-     * executed in CGP, they are handled below */
-    if (cur_section->done >= 0 &&
-            (INTVAL)cur_section->op_count >= 2 + last_is_branch) {
-        int saved = 0;
-        offset = (jit_info->cur_op - interp->code->base.data) +
-            interp->code->prederef.code;
-
-        jit_emit_mov_ri_i(interp, jit_info->native_ptr, emit_ESI, offset);
-        emitm_callm(jit_info->native_ptr, emit_ESI, 0, 0, 0);
-        /* now patch a B<cpu_ret> opcode after the end of the
-         * prederefed (non JIT) section
-         */
-        if (last_is_branch) {
-            offset = (cur_section->end - interp->code->base.data) +
-                interp->code->prederef.code;
-            cur_section->done = -1;
-            /* ins to skip */
-            cur_section->ins_count = cur_section->op_count - 1;
-        }
-        else {
-            /* There must be a next section: either we have a B<end>
-             * or a JITed branch,
-             * when the branch is non JIT, we are in the above case
-             */
-            offset = (cur_section->next->begin - interp->code->base.data)
-                + interp->code->prederef.code;
-            cur_section->done = 1;
-        }
-        *offset = ((op_func_t*)interp->op_lib->op_func_table)[2];
-    }
-    else {
-        /* else call normal funtion */
-        emitm_pushl_i(jit_info->native_ptr, interp);
-        emitm_pushl_i(jit_info->native_ptr, jit_info->cur_op);
-        call_func(jit_info,
-            (void (*)(void))interp->op_func_table[*(jit_info->cur_op)]);
-        emitm_addb_i_r(jit_info->native_ptr, 8, emit_ESP);
-        /* when this was a branch, then EAX is now the offset
-         * in the byte_code
-         */
-    }
-}
-
-#  else
-
-void
-Parrot_jit_normal_op(Parrot_jit_info_t *jit_info,
-                     PARROT_INTERP)
-{
-    int cur_op = *jit_info->cur_op;
-    static int check;
-
-    if (cur_op >= jit_op_count()) {
-        cur_op = CORE_OPS_wrapper__;
-    }
-
-    if ((++check & 0x7) == 0) {
-        /*
-         * every 8 ??? normal ops, we emit a check for event processing
-         */
-
-/*
- * There is an optimization to reuse arguments on the stack.  Compilers may
- * decide to reuse the argument space though.  If you are *absolutely sure*
- * this does not happen define PARROT_JIT_STACK_REUSE_INTERP.
- */
-#    ifdef PARROT_JIT_STACK_REUSE_INTERP
-        /*
-        * op functions have the signature (cur_op, interp)
-        * we use the interpreter already on stack and only push the
-        * cur_op
-        */
-#    else
-        /* push interpreter */
-        Parrot_jit_emit_get_INTERP(interp, jit_info->native_ptr, emit_ECX);
-        emitm_pushl_r(jit_info->native_ptr, emit_ECX);
-#    endif
-
-        emitm_pushl_i(jit_info->native_ptr, CORE_OPS_check_events);
-
-        call_func(jit_info,
-            (void (*) (void)) (interp->op_func_table[CORE_OPS_check_events]));
-#    ifdef PARROT_JIT_STACK_REUSE_INTERP
-        emitm_addb_i_r(jit_info->native_ptr, 4, emit_ESP);
-#    else
-        emitm_addb_i_r(jit_info->native_ptr, 8, emit_ESP);
-#    endif
-    }
-
-#    ifdef PARROT_JIT_STACK_REUSE_INTERP
-    /*
-    * op functions have the signature (cur_op, interp)
-    * we use the interpreter already on stack and only push the
-    * cur_op
-    */
-#    else
-    Parrot_jit_emit_get_INTERP(interp, jit_info->native_ptr, emit_ECX);
-    emitm_pushl_r(jit_info->native_ptr, emit_ECX);
-#    endif
-
-    emitm_pushl_i(jit_info->native_ptr, jit_info->cur_op);
-
-    call_func(jit_info,
-            (void (*) (void))(interp->op_func_table[cur_op]));
-#    ifdef PARROT_JIT_STACK_REUSE_INTERP
-    emitm_addb_i_r(jit_info->native_ptr, 4, emit_ESP);
-#    else
-    emitm_addb_i_r(jit_info->native_ptr, 8, emit_ESP);
-#    endif
-}
-
-#  endif /* JIT_CGP */
-
 void
 Parrot_jit_cpcf_op(Parrot_jit_info_t *jit_info,
                    PARROT_INTERP)

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	Sun Dec 21 14:35:31 2008
@@ -88,7 +88,6 @@
 
 #define INT_REGISTERS_TO_MAP 4
 
-
 /* Scratch register. */
 
 #define ISR1 emit_EAX
@@ -1495,7 +1494,6 @@
 EXTERN void Parrot_FixedIntegerArray_set_integer_keyed_int(Interp*, PMC*, INTVAL, INTVAL);
 #  define JIT_ROFFS_PMC(x) REG_OFFS_PMC(jit_info->cur_op[(x)])
 #  define JIT_ROFFS_INT(x) REG_OFFS_INT(jit_info->cur_op[(x)])
-#  define NATIVECODE jit_info->native_ptr
 
 #endif /* JIT_VTABLE_OPS */
 
@@ -1810,7 +1808,152 @@
 
 void Parrot_jit_emit_finit(Parrot_jit_info_t *jit_info);
 
+/*
 void Parrot_jit_normal_op(Parrot_jit_info_t *jit_info, PARROT_INTERP);
+*/
+
+#if JIT_EMIT == 2
+#  ifdef JIT_CGP
+/*
+ * XXX needs some fixing
+ * s. t/sub/pmc_{8,9}.t: the 2 print in tail call without that 'end'
+ *    are recogniced as one non JIIted block
+ */
+void
+Parrot_jit_normal_op(Parrot_jit_info_t *jit_info,
+                     PARROT_INTERP)
+{
+    Parrot_jit_optimizer_section_ptr cur_section =
+        jit_info->optimizer->cur_section;
+    int last_is_branch = 0;
+    void ** offset;
+
+    PARROT_ASSERT(op_jit[*jit_info->cur_op].extcall == 1);
+    if (cur_section->done == 1)
+        return;
+    else if (cur_section->done == -1 && --cur_section->ins_count > 0)
+        return;
+    /* check, where section ends
+     */
+    if (interp->op_info_table[*cur_section->end].jump)
+        last_is_branch = 1;
+    else if (cur_section->next && !cur_section->next->isjit)
+        last_is_branch = 1;
+    /* if more then 1 op, then jump to CGP, branches are never
+     * executed in CGP, they are handled below */
+    if (cur_section->done >= 0 &&
+            (INTVAL)cur_section->op_count >= 2 + last_is_branch) {
+        int saved = 0;
+        offset = (jit_info->cur_op - interp->code->base.data) +
+            interp->code->prederef.code;
+
+        jit_emit_mov_ri_i(interp, jit_info->native_ptr, emit_ESI, offset);
+        emitm_callm(jit_info->native_ptr, emit_ESI, 0, 0, 0);
+        /* now patch a B<cpu_ret> opcode after the end of the
+         * prederefed (non JIT) section
+         */
+        if (last_is_branch) {
+            offset = (cur_section->end - interp->code->base.data) +
+                interp->code->prederef.code;
+            cur_section->done = -1;
+            /* ins to skip */
+            cur_section->ins_count = cur_section->op_count - 1;
+        }
+        else {
+            /* There must be a next section: either we have a B<end>
+             * or a JITed branch,
+             * when the branch is non JIT, we are in the above case
+             */
+            offset = (cur_section->next->begin - interp->code->base.data)
+                + interp->code->prederef.code;
+            cur_section->done = 1;
+        }
+        *offset = ((op_func_t*)interp->op_lib->op_func_table)[2];
+    }
+    else {
+        /* else call normal funtion */
+        emitm_pushl_i(jit_info->native_ptr, interp);
+        emitm_pushl_i(jit_info->native_ptr, jit_info->cur_op);
+        call_func(jit_info,
+            (void (*)(void))interp->op_func_table[*(jit_info->cur_op)]);
+        emitm_addb_i_r(jit_info->native_ptr, 8, emit_ESP);
+        /* when this was a branch, then EAX is now the offset
+         * in the byte_code
+         */
+    }
+}
+
+#  else /* JIT_CGP */
+extern int jit_op_count(void);
+
+void
+Parrot_jit_normal_op(Parrot_jit_info_t *jit_info,
+                     PARROT_INTERP)
+{
+    int cur_op = *jit_info->cur_op;
+    static int check;
+
+    if (cur_op >= jit_op_count()) {
+        cur_op = CORE_OPS_wrapper__;
+    }
+
+    if ((++check & 0x7) == 0) {
+        /*
+         * every 8 ??? normal ops, we emit a check for event processing
+         */
+
+/*
+ * There is an optimization to reuse arguments on the stack.  Compilers may
+ * decide to reuse the argument space though.  If you are *absolutely sure*
+ * this does not happen define PARROT_JIT_STACK_REUSE_INTERP.
+ */
+#    ifdef PARROT_JIT_STACK_REUSE_INTERP
+        /*
+        * op functions have the signature (cur_op, interp)
+        * we use the interpreter already on stack and only push the
+        * cur_op
+        */
+#    else
+        /* push interpreter */
+        Parrot_jit_emit_get_INTERP(interp, jit_info->native_ptr, emit_ECX);
+        emitm_pushl_r(jit_info->native_ptr, emit_ECX);
+#    endif
+
+        emitm_pushl_i(jit_info->native_ptr, CORE_OPS_check_events);
+
+        call_func(jit_info,
+            (void (*) (void)) (interp->op_func_table[CORE_OPS_check_events]));
+#    ifdef PARROT_JIT_STACK_REUSE_INTERP
+        emitm_addb_i_r(jit_info->native_ptr, 4, emit_ESP);
+#    else
+        emitm_addb_i_r(jit_info->native_ptr, 8, emit_ESP);
+#    endif
+    }
+
+#    ifdef PARROT_JIT_STACK_REUSE_INTERP
+    /*
+    * op functions have the signature (cur_op, interp)
+    * we use the interpreter already on stack and only push the
+    * cur_op
+    */
+#    else
+    Parrot_jit_emit_get_INTERP(interp, jit_info->native_ptr, emit_ECX);
+    emitm_pushl_r(jit_info->native_ptr, emit_ECX);
+#    endif
+
+    emitm_pushl_i(jit_info->native_ptr, jit_info->cur_op);
+
+    call_func(jit_info,
+            (void (*) (void))(interp->op_func_table[cur_op]));
+#    ifdef PARROT_JIT_STACK_REUSE_INTERP
+    emitm_addb_i_r(jit_info->native_ptr, 4, emit_ESP);
+#    else
+    emitm_addb_i_r(jit_info->native_ptr, 8, emit_ESP);
+#    endif
+}
+
+#  endif /* JIT_CGP */
+#endif
 
 extern int jit_op_count(void);
 



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