changeset 244:1e7c0fb4048a

Bug 3422: [REFACTORING] Stack and base pointer operation Reviewed-by: ykubota https://github.com/HeapStats/heapstats/pull/111
author Yasumasa Suenaga <yasuenag@gmail.com>
date Wed, 19 Jul 2017 17:53:11 +0900
parents be9892e921b3
children 354b87b559ef
files ChangeLog agent/src/heapstats-engines/arch/x86/overrideFunc.amd64.S
diffstat 2 files changed, 13 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Mon Jul 17 23:44:04 2017 +0900
+++ b/ChangeLog	Wed Jul 19 17:53:11 2017 +0900
@@ -1,3 +1,7 @@
+2017-07-19 Yasumasa Suenaga <yasuenag@gmail.com>
+
+	* Bug 3422: [REFACTORING] Stack and base pointer operation
+
 2017-07-17 KUBOTA Yuji <kubota.yuji@lab.ntt.co.jp>
 
 	* Bug 3420: Migrate Plugin API module from fx module
--- a/agent/src/heapstats-engines/arch/x86/overrideFunc.amd64.S	Mon Jul 17 23:44:04 2017 +0900
+++ b/agent/src/heapstats-engines/arch/x86/overrideFunc.amd64.S	Wed Jul 19 17:53:11 2017 +0900
@@ -58,24 +58,20 @@
   mov collectedHeap@GOTPCREL(%rip), %rdi;   \
   mov (%rdi), %rdi;                         \
   mov oop_ofs(%rsp), %rsi;                  \
-  push %rbp;                                \
-  mov %rsp, %rbp;                           \
   call *(%r11);                             \
-  pop %rbp;                                 \
   test %al, %al;                            
 
 #define DO_JMP_TO_CALLBACK(header, ary_idx, oop_ofs) \
   mov oop_ofs(%rsp), %rdi;                                  \
   mov header##_enter_hook_##ary_idx##@GOTPCREL(%rip), %r11; \
-  push %rbp;                                                \
-  mov %rsp, %rbp;                                           \
-  call *(%r11);                                             \
-  pop %rbp;
+  call *(%r11);
 
 #define OVERRIDE_FUNC_DEFINE(header, ary_idx) \
 .global header##_override_func_##ary_idx ;                     \
 .type header##_override_func_##ary_idx, @function;             \
 header##_override_func_##ary_idx: ;                            \
+  push %rbp;                                                   \
+  mov %rsp, %rbp;                                              \
   /* Save argument registers. */ ;                             \
   DO_SAVE_REG                                                  \
                                                                \
@@ -138,5 +134,11 @@
 .LORIGINAL_FUNC:
   pop %r11;
   DO_LOAD_REG
+
+  /* Restore stack pointer */
+  mov %rbp, %rsp;
+  /* Restore base pointer */
+  pop %rbp;
+
   jmp *%r11;