Author: tkreuzer
Date: Wed Jun 22 20:15:58 2011
New Revision: 52430
URL:
http://svn.reactos.org/svn/reactos?rev=52430&view=rev
Log:
[NTOSKRNL]
Optimize KiSystemCallTrampoline inline assembly for MSVC. save one register, use eax for
the handler address and don't assign to an intermediate variable before returning
(hint by Alex)
Modified:
trunk/reactos/ntoskrnl/include/internal/i386/ke.h
Modified: trunk/reactos/ntoskrnl/include/internal/i386/ke.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
==============================================================================
--- trunk/reactos/ntoskrnl/include/internal/i386/ke.h [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/include/internal/i386/ke.h [iso-8859-1] Wed Jun 22 20:15:58
2011
@@ -600,13 +600,6 @@
//
// Performs a system call
//
-NTSTATUS
-FORCEINLINE
-KiSystemCallTrampoline(IN PVOID Handler,
- IN PVOID Arguments,
- IN ULONG StackBytes)
-{
- NTSTATUS Result;
/*
* This sequence does a RtlCopyMemory(Stack - StackBytes, Arguments, StackBytes)
@@ -624,6 +617,14 @@
*
*/
#ifdef __GNUC__
+NTSTATUS
+FORCEINLINE
+KiSystemCallTrampoline(IN PVOID Handler,
+ IN PVOID Arguments,
+ IN ULONG StackBytes)
+{
+ NTSTATUS Result;
+
__asm__ __volatile__
(
"subl %1, %%esp\n"
@@ -639,26 +640,32 @@
"r"(Handler)
: "%esp", "%esi", "%edi"
);
+ return Result;
+}
#elif defined(_MSC_VER)
+NTSTATUS
+FORCEINLINE
+KiSystemCallTrampoline(IN PVOID Handler,
+ IN PVOID Arguments,
+ IN ULONG StackBytes)
+{
__asm
{
mov ecx, StackBytes
- mov edx, Arguments
- mov ebx, Handler
+ mov esi, Arguments
+ mov eax, Handler
sub esp, ecx
mov edi, esp
- mov esi, edx
shr ecx, 2
rep movsd
- call ebx
- mov Result, eax
+ call eax
}
+ /* Return with result in EAX */
+}
#else
#error Unknown Compiler
#endif
- return Result;
-}
//
// Checks for pending APCs