* src/vm/jit/emit-common.c (codegen.h): Added.
authortwisti <none@none>
Tue, 28 Nov 2006 22:25:11 +0000 (22:25 +0000)
committertwisti <none@none>
Tue, 28 Nov 2006 22:25:11 +0000 (22:25 +0000)
(vm/options.h): Likewise.
[ENABLE_STATISTICS] (vm/statistics.h): Likewise.
(emit_bc): New function.
(emit_br): Likewise.

* src/vm/jit/emit-common.h (emit_branch): Added.

src/vm/jit/emit-common.c
src/vm/jit/emit-common.h

index 202118b5b5a087235b27f55d73fd85aaf7ad5b32..2d89ea1e35338d9d8eac3d715af23d92d24d39a9 100644 (file)
 
 #include "vm/types.h"
 
+#include "codegen.h"
+
+#include "vm/options.h"
+
+#if defined(ENABLE_STATISTICS)
+# include "vm/statistics.h"
+#endif
+
 #include "vm/jit/emit-common.h"
 #include "vm/jit/jit.h"
 
@@ -252,6 +260,44 @@ void emit_store_dst(jitdata *jd, instruction *iptr, s4 d)
 
 *******************************************************************************/
 
+void emit_bc(codegendata *cd, basicblock *target, s4 condition)
+{
+       s4 branchmpc;
+       s4 disp;
+
+       /* Target basic block already has an PC, so we can generate the
+          branch immediately. */
+
+       if ((target->mpc >= 0)) {
+               STATISTICS(count_branches_resolved++);
+
+               /* calculate the mpc of the branch instruction */
+
+               branchmpc = cd->mcodeptr - cd->mcodebase;
+               disp      = target->mpc - branchmpc;
+
+               emit_branch(cd, disp, condition);
+       }
+       else {
+               /* current mcodeptr is the correct position,
+                  afterwards emit the NOPs */
+
+               codegen_add_branch_ref(cd, target, condition);
+
+               /* generate NOPs as placeholder for branch code */
+               /* XXX if recompile-with-long-branches */
+
+               BRANCH_NOPS;
+       }
+}
+
+
+void emit_br(codegendata *cd, basicblock *target)
+{
+       emit_bc(cd, target, BRANCH_UNCONDITIONAL);
+}
+
+
 void emit_beq(codegendata *cd, basicblock *target)
 {
        emit_bc(cd, target, BRANCH_EQ);
index b4c71580f64e1448f23f260def02e67370805cd0..5344323bbb01104bb36e42c9bcbdf6a8442c667f 100644 (file)
@@ -101,6 +101,8 @@ void emit_ble(codegendata *cd, basicblock *target);
 
 void emit_bnan(codegendata *cd, basicblock *target);
 
+void emit_branch(codegendata *cd, s4 disp, s4 condition);
+
 void emit_arithmetic_check(codegendata *cd, s4 reg);
 void emit_arrayindexoutofbounds_check(codegendata *cd, s4 s1, s4 s2);
 void emit_arraystore_check(codegendata *cd, s4 reg);