guile-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Guile-commits] 03/17: Move add, sub slow paths out of line


From: Andy Wingo
Subject: [Guile-commits] 03/17: Move add, sub slow paths out of line
Date: Wed, 11 Dec 2019 03:47:49 -0500 (EST)

wingo pushed a commit to branch master
in repository guile.

commit 9c329776df1d032e34e224035a357fbbf18149d2
Author: Andy Wingo <address@hidden>
Date:   Tue Dec 10 17:08:05 2019 +0100

    Move add, sub slow paths out of line
    
    * libguile/jit.c (compile_call_scm_from_scm_sc)
      (compile_call_scm_from_scm_scm_slow): Move non-fixnum path out of
      line.
---
 libguile/jit.c | 71 ++++++++++++++++++++++++++++------------------------------
 1 file changed, 34 insertions(+), 37 deletions(-)

diff --git a/libguile/jit.c b/libguile/jit.c
index 26abafa..1ed8f92 100644
--- a/libguile/jit.c
+++ b/libguile/jit.c
@@ -2537,67 +2537,64 @@ compile_long_fmov_slow (scm_jit_state *j, uint32_t dst, 
uint32_t src)
 static void
 compile_call_scm_from_scm_scm (scm_jit_state *j, uint8_t dst, uint8_t a, 
uint8_t b, uint32_t idx)
 {
-  void *intrinsic = ((void **) &scm_vm_intrinsics)[idx];
-  int has_fast = 0;
-  jit_reloc_t fast;
-
-  jit_operand_t op_a = sp_scm_operand (j, a);
-  jit_operand_t op_b = sp_scm_operand (j, b);
-
   switch ((enum scm_vm_intrinsic) idx)
     {
     case SCM_VM_INTRINSIC_ADD:
       {
         emit_sp_ref_scm (j, T0, a);
         emit_sp_ref_scm (j, T1, b);
-        op_a = jit_operand_gpr (JIT_OPERAND_ABI_POINTER, T0);
-        op_b = jit_operand_gpr (JIT_OPERAND_ABI_POINTER, T1);
-        jit_reloc_t a_not_inum = jit_bmci (j->jit, T0, scm_tc2_int);
-        jit_reloc_t b_not_inum = jit_bmci (j->jit, T1, scm_tc2_int);
+        add_slow_path_patch (j, jit_bmci (j->jit, T0, scm_tc2_int));
+        add_slow_path_patch (j, jit_bmci (j->jit, T1, scm_tc2_int));
         jit_subi (j->jit, T0, T0, scm_tc2_int);
-        fast = jit_bxaddr (j->jit, T0, T1);
-        has_fast = 1;
-        /* Restore previous value before slow path.  */
-        jit_subr (j->jit, T0, T0, T1);
-        jit_addi (j->jit, T0, T0, scm_tc2_int);
-        jit_patch_here (j->jit, a_not_inum);
-        jit_patch_here (j->jit, b_not_inum);
+        add_slow_path_patch (j, jit_boaddr (j->jit, T0, T1));
         break;
       }
     case SCM_VM_INTRINSIC_SUB:
       {
         emit_sp_ref_scm (j, T0, a);
         emit_sp_ref_scm (j, T1, b);
-        op_a = jit_operand_gpr (JIT_OPERAND_ABI_POINTER, T0);
-        op_b = jit_operand_gpr (JIT_OPERAND_ABI_POINTER, T1);
-        jit_reloc_t a_not_inum = jit_bmci (j->jit, T0, scm_tc2_int);
-        jit_reloc_t b_not_inum = jit_bmci (j->jit, T1, scm_tc2_int);
+        add_slow_path_patch (j, jit_bmci (j->jit, T0, scm_tc2_int));
+        add_slow_path_patch (j, jit_bmci (j->jit, T1, scm_tc2_int));
         jit_subi (j->jit, T1, T1, scm_tc2_int);
-        fast = jit_bxsubr (j->jit, T0, T1);
-        has_fast = 1;
-        /* Restore previous values before slow path.  */
-        jit_addr (j->jit, T0, T0, T1);
-        jit_addi (j->jit, T1, T1, scm_tc2_int);
-        jit_patch_here (j->jit, a_not_inum);
-        jit_patch_here (j->jit, b_not_inum);
+        add_slow_path_patch (j, jit_bosubr (j->jit, T0, T1));
         break;
       }
     default:
-      break;
+      {
+        void *intrinsic = ((void **) &scm_vm_intrinsics)[idx];
+        jit_operand_t op_a = sp_scm_operand (j, a);
+        jit_operand_t op_b = sp_scm_operand (j, b);
+        emit_store_current_ip (j, T2);
+        emit_call_2 (j, intrinsic, op_a, op_b);
+        emit_retval (j, T0);
+        emit_reload_sp (j);
+      }
     }
 
-  emit_store_current_ip (j, T2);
-  emit_call_2 (j, intrinsic, op_a, op_b);
-  emit_retval (j, T0);
-  emit_reload_sp (j);
-
-  if (has_fast)
-    jit_patch_here (j->jit, fast);
   emit_sp_set_scm (j, dst, T0);
 }
 static void
 compile_call_scm_from_scm_scm_slow (scm_jit_state *j, uint8_t dst, uint8_t a, 
uint8_t b, uint32_t idx)
 {
+  switch ((enum scm_vm_intrinsic) idx)
+    {
+    case SCM_VM_INTRINSIC_ADD:
+    case SCM_VM_INTRINSIC_SUB:
+      {
+        void *intrinsic = ((void **) &scm_vm_intrinsics)[idx];
+        jit_operand_t op_a = sp_scm_operand (j, a);
+        jit_operand_t op_b = sp_scm_operand (j, b);
+        emit_store_current_ip (j, T1);
+        emit_call_2 (j, intrinsic, op_a, op_b);
+        emit_retval (j, T0);
+        emit_reload_sp (j);
+        emit_sp_set_scm (j, dst, T0);
+        continue_after_slow_path (j, j->next_ip);
+        break;
+      }
+    default:
+      break;
+    }
 }
 
 static void



reply via email to

[Prev in Thread] Current Thread [Next in Thread]