* src/vm/jit/emit-common.c (emit_label_bccz): Code restructured.
authorChristian Thalinger <twisti@complang.tuwien.ac.at>
Thu, 17 Apr 2008 11:15:20 +0000 (13:15 +0200)
committerChristian Thalinger <twisti@complang.tuwien.ac.at>
Thu, 17 Apr 2008 11:15:20 +0000 (13:15 +0200)
(emit_label): Likewise.

src/vm/jit/emit-common.c

index 0ad3cceb801c6abdab689a305c26e30d4e2b31bd..3a167808265e151f477303cf419a2c7c6c4be292 100644 (file)
@@ -527,40 +527,40 @@ void emit_label_bccz(codegendata *cd, s4 label, s4 condition, s4 reg, u4 options
                        break;
        }
 
-       /* a branch reference was found */
+       if (br == NULL) {
+               /* current mcodeptr is the correct position,
+                  afterwards emit the NOPs */
 
-       if (br != NULL) {
-               /* calculate the mpc of the branch instruction */
+               codegen_branch_label_add(cd, label, condition, reg, options);
+
+               /* generate NOPs as placeholder for branch code */
+
+               BRANCH_NOPS;
+               return;
+       }
+
+       /* Branch reference was found. */
+
+       /* calculate the mpc of the branch instruction */
 
-               mpc  = cd->mcodeptr - cd->mcodebase;
-               disp = br->mpc - mpc;
+       mpc  = cd->mcodeptr - cd->mcodebase;
+       disp = br->mpc - mpc;
 
 #if defined(ENABLE_STATISTICS)
-               count_emit_branch++;
-               if ((int8_t)disp == disp)  count_emit_branch_8bit++; 
-               else if ((int16_t)disp == disp) count_emit_branch_16bit++;
-               else if ((int32_t)disp == disp) count_emit_branch_32bit++;
+       count_emit_branch++;
+       if ((int8_t)disp == disp)  count_emit_branch_8bit++; 
+       else if ((int16_t)disp == disp) count_emit_branch_16bit++;
+       else if ((int32_t)disp == disp) count_emit_branch_32bit++;
 # if SIZEOF_VOID_P == 8
-               else if ((int64_t)disp == disp) count_emit_branch_64bit++;
+       else if ((int64_t)disp == disp) count_emit_branch_64bit++;
 # endif
 #endif
 
-               emit_branch(cd, disp, condition, reg, options);
+       emit_branch(cd, disp, condition, reg, options);
 
-               /* now remove the branch reference */
-
-               list_remove(list, br);
-       }
-       else {
-               /* current mcodeptr is the correct position,
-                  afterwards emit the NOPs */
+       /* now remove the branch reference */
 
-               codegen_branch_label_add(cd, label, condition, reg, options);
-
-               /* generate NOPs as placeholder for branch code */
-
-               BRANCH_NOPS;
-       }
+       list_remove(list, br);
 }
 
 
@@ -592,45 +592,45 @@ void emit_label(codegendata *cd, s4 label)
                        break;
        }
 
-       /* a branch reference was found */
+       if (br == NULL) {
+               /* No branch reference found, add the label to the list (use
+                  invalid values for condition and register). */
 
-       if (br != NULL) {
-               /* calculate the mpc of the branch instruction */
+               codegen_branch_label_add(cd, label, -1, -1, BRANCH_OPT_NONE );
+               return;
+       }
+
+       /* Branch reference was found. */
+
+       /* calculate the mpc of the branch instruction */
 
-               mpc  = cd->mcodeptr - cd->mcodebase;
-               disp = mpc - br->mpc;
+       mpc  = cd->mcodeptr - cd->mcodebase;
+       disp = mpc - br->mpc;
 
-               /* temporary set the mcodeptr */
+       /* temporary set the mcodeptr */
 
-               mcodeptr     = cd->mcodeptr;
-               cd->mcodeptr = cd->mcodebase + br->mpc;
+       mcodeptr     = cd->mcodeptr;
+       cd->mcodeptr = cd->mcodebase + br->mpc;
 
 #if defined(ENABLE_STATISTICS)
-               count_emit_branch++;
-               if ((int8_t)disp == disp)  count_emit_branch_8bit++; 
-               else if ((int16_t)disp == disp) count_emit_branch_16bit++;
-               else if ((int32_t)disp == disp) count_emit_branch_32bit++;
+       count_emit_branch++;
+       if ((int8_t)disp == disp)  count_emit_branch_8bit++; 
+       else if ((int16_t)disp == disp) count_emit_branch_16bit++;
+       else if ((int32_t)disp == disp) count_emit_branch_32bit++;
 # if SIZEOF_VOID_P == 8
-               else if ((int64_t)disp == disp) count_emit_branch_64bit++;
+       else if ((int64_t)disp == disp) count_emit_branch_64bit++;
 # endif
 #endif
 
-               emit_branch(cd, disp, br->condition, br->reg, br->options);
+       emit_branch(cd, disp, br->condition, br->reg, br->options);
 
-               /* restore mcodeptr */
+       /* restore mcodeptr */
 
-               cd->mcodeptr = mcodeptr;
+       cd->mcodeptr = mcodeptr;
 
-               /* now remove the branch reference */
+       /* now remove the branch reference */
 
-               list_remove(list, br);
-       }
-       else {
-               /* add the label to the list (use invalid values for condition
-                  and register) */
-
-               codegen_branch_label_add(cd, label, -1, -1, BRANCH_OPT_NONE );
-       }
+       list_remove(list, br);
 }