The stack pointer was not restored after call because %ecx is always 0
after arguments are copied because it's decremented by 'rep movsb'.

This also optimizes argument copying by using movsd instead of movsb.

Signed-off-by: Tomek Grabiec <tgrab...@gmail.com>
---
 arch/x86/include/arch/call.h |   24 ++++++++++++------------
 1 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/arch/x86/include/arch/call.h b/arch/x86/include/arch/call.h
index a9037ec..18dbebb 100644
--- a/arch/x86/include/arch/call.h
+++ b/arch/x86/include/arch/call.h
@@ -3,25 +3,25 @@
 
 #ifdef CONFIG_X86_32
 /**
- * This calls a function (@target) with call arguments copied from
- * @args array. The array contains @args_count elements of machine
- * word size. The call result will be stored in @result.
+ * This calls a function with call arguments copied from @args
+ * array. The array contains @args_count elements of machine word
+ * size. The @target must be a variable holding a function
+ * pointer. Call result will be stored in @result.
  */
 #define native_call(target, args, args_count, result) {                        
\
                __asm__ volatile (                                      \
-                 "movl %2, %%esi \n"                                   \
-                 "movl %1, %%ecx \n"                                   \
-                 "subl %%ecx, %%esp \n"                                \
+                 "movl %%ebx, %%ecx \n"                                \
+                 "shl $2, %%ebx \n"                                    \
+                 "subl %%ebx, %%esp \n"                                \
                  "movl %%esp, %%edi \n"                                \
                  "cld \n"                                              \
-                 "rep movsb \n"                                        \
-                 "movl %%ecx, %%esi \n"                                \
+                 "rep movsd \n"                                        \
+                 "movl %%ebx, %%esi \n"                                \
                  "call *%3 \n"                                         \
                  "addl %%esi, %%esp \n"                                \
-                 "movl %%eax, %0 \n"                                   \
-                 : "=r" (result)                                       \
-                 : "r" (sizeof(long) * args_count), "r"(args), "m"(target) \
-                 : "%ecx", "%esi", "%eax", "cc", "memory" \
+                 : "=a" (result)                                       \
+                 : "b" (args_count), "S"(args), "m"(target)            \
+                 : "%ecx", "%edi", "cc"                                \
                                                                ); \
        }
 #else
-- 
1.6.0.6


------------------------------------------------------------------------------
_______________________________________________
Jatovm-devel mailing list
Jatovm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jatovm-devel

Reply via email to