[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)

svn path=/trunk/; revision=52430
This commit is contained in:
Timo Kreuzer 2011-06-22 20:15:58 +00:00
parent 590a071060
commit b4e4d6e5c4

View file

@ -600,13 +600,6 @@ KiDispatchException2Args(IN NTSTATUS Code,
// //
// Performs a system call // 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) * This sequence does a RtlCopyMemory(Stack - StackBytes, Arguments, StackBytes)
@ -624,6 +617,14 @@ KiSystemCallTrampoline(IN PVOID Handler,
* *
*/ */
#ifdef __GNUC__ #ifdef __GNUC__
NTSTATUS
FORCEINLINE
KiSystemCallTrampoline(IN PVOID Handler,
IN PVOID Arguments,
IN ULONG StackBytes)
{
NTSTATUS Result;
__asm__ __volatile__ __asm__ __volatile__
( (
"subl %1, %%esp\n" "subl %1, %%esp\n"
@ -639,26 +640,32 @@ KiSystemCallTrampoline(IN PVOID Handler,
"r"(Handler) "r"(Handler)
: "%esp", "%esi", "%edi" : "%esp", "%esi", "%edi"
); );
return Result;
}
#elif defined(_MSC_VER) #elif defined(_MSC_VER)
NTSTATUS
FORCEINLINE
KiSystemCallTrampoline(IN PVOID Handler,
IN PVOID Arguments,
IN ULONG StackBytes)
{
__asm __asm
{ {
mov ecx, StackBytes mov ecx, StackBytes
mov edx, Arguments mov esi, Arguments
mov ebx, Handler mov eax, Handler
sub esp, ecx sub esp, ecx
mov edi, esp mov edi, esp
mov esi, edx
shr ecx, 2 shr ecx, 2
rep movsd rep movsd
call ebx call eax
mov Result, eax
} }
/* Return with result in EAX */
}
#else #else
#error Unknown Compiler #error Unknown Compiler
#endif #endif
return Result;
}
// //
// Checks for pending APCs // Checks for pending APCs