From 10d27a8815dd6152e6ae83d75f37057e38317b08 Mon Sep 17 00:00:00 2001
From: Per Hedbor <ph@opera.com>
Date: Fri, 8 Aug 2014 14:06:59 +0200
Subject: [PATCH] Revert "Changed fast_call_threads_etc handling with valgrind"

This reverts commit 1c4cf54199bd51903bc071a5aceff11e40c00222.

Needs more work, currently it is causing crashes.
---
 src/code/amd64.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/code/amd64.c b/src/code/amd64.c
index 9c6dd62c12..640e1ca739 100644
--- a/src/code/amd64.c
+++ b/src/code/amd64.c
@@ -585,6 +585,7 @@ static void add_mem_imm( enum amd64_reg reg, int offset, int imm32 )
   low_add_mem_imm( 1, reg, offset, imm32 );
 }
 
+#ifndef USE_VALGRIND
 static void add_mem8_imm( enum amd64_reg reg, int offset, int imm32 )
 {
   int r2 = imm32 == -1 ? 1 : 0;
@@ -604,6 +605,7 @@ static void add_mem8_imm( enum amd64_reg reg, int offset, int imm32 )
     ib( imm32 );
   }
 }
+#endif
 
 static void sub_reg_imm( enum amd64_reg reg, int imm32 )
 {
@@ -983,9 +985,6 @@ void amd64_ins_entry(void)
   push(P_REG_R12);
   push(P_REG_RBX);
   sub_reg_imm(P_REG_RSP, 8);	/* Align on 16 bytes. */
-#ifdef USE_VALGRIND
-  mov_imm_mem32(0, P_REG_RSP, 0 ); /* clear counter used by check_threads_etc */
-#endif
   mov_reg_reg(ARG1_REG, Pike_interpreter_reg);
   amd64_flush_code_generator_state();
 }
@@ -1486,10 +1485,14 @@ static void amd64_ins_branch_check_threads_etc(int code_only)
   {
     LABEL_A;
     /* Use C-stack for counter. We have padding added in entry */
+#ifndef USE_VALGRIND
     add_mem8_imm( P_REG_RSP, 0, 1 );
     jno( &label_B );
+#endif
     call_rel_imm32( branch_check_threads_update_etc );
+#ifndef USE_VALGRIND
    LABEL_B;
+#endif
   }
 }
 
-- 
GitLab