Author: sir_richard
Date: Sun Jan 24 00:59:59 2010
New Revision: 45223
URL:
http://svn.reactos.org/svn/reactos?rev=45223&view=rev
Log:
[PERF]: Make all trap handlers, trap exit code, fatal exit code, and exception dispatch
code "no return" since it always leads to an iret or other kind of
non-directly-returning mechanism. This allows the compiler to optimize better and also
remove useless code at the bottom of the functions. Since __builtin_unreachable is only
for GCC 4.5, we use exit(0) for now (it will never be reached) to trick GCC.
Modified:
trunk/reactos/ntoskrnl/include/internal/trap_x.h
trunk/reactos/ntoskrnl/ke/i386/traphdlr.c
Modified: trunk/reactos/ntoskrnl/include/internal/trap_x.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
==============================================================================
--- trunk/reactos/ntoskrnl/include/internal/trap_x.h [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/include/internal/trap_x.h [iso-8859-1] Sun Jan 24 00:59:59
2010
@@ -214,6 +214,7 @@
VOID
FORCEINLINE
+DECLSPEC_NORETURN
KiDispatchException0Args(IN NTSTATUS Code,
IN ULONG_PTR Address,
IN PKTRAP_FRAME TrapFrame)
@@ -224,6 +225,7 @@
VOID
FORCEINLINE
+DECLSPEC_NORETURN
KiDispatchException1Args(IN NTSTATUS Code,
IN ULONG_PTR Address,
IN ULONG P1,
@@ -235,6 +237,7 @@
VOID
FORCEINLINE
+DECLSPEC_NORETURN
KiDispatchException2Args(IN NTSTATUS Code,
IN ULONG_PTR Address,
IN ULONG P1,
@@ -247,6 +250,7 @@
FORCEINLINE
VOID
+DECLSPEC_NORETURN
KiSystemCallReturn(IN PKTRAP_FRAME TrapFrame)
{
/* Restore nonvolatiles, EAX, and do a "jump" back to the kernel caller */
@@ -272,10 +276,12 @@
[v] "i"(KTRAP_FRAME_ESP)
: "%esp"
);
-}
-
-FORCEINLINE
-VOID
+ exit(0);
+}
+
+FORCEINLINE
+VOID
+DECLSPEC_NORETURN
KiSystemCallTrapReturn(IN PKTRAP_FRAME TrapFrame)
{
/* Regular interrupt exit, but we only restore EAX as a volatile */
@@ -299,10 +305,12 @@
[e] "i"(KTRAP_FRAME_EIP)
: "%esp"
);
-}
-
-FORCEINLINE
-VOID
+ exit(0);
+}
+
+FORCEINLINE
+VOID
+DECLSPEC_NORETURN
KiSystemCallSysExitReturn(IN PKTRAP_FRAME TrapFrame)
{
/* Restore nonvolatiles, EAX, and do a SYSEXIT back to the user caller */
@@ -330,10 +338,12 @@
[v] "i"(KTRAP_FRAME_V86_ES)
: "%esp"
);
-}
-
-FORCEINLINE
-VOID
+ exit(0);
+}
+
+FORCEINLINE
+VOID
+DECLSPEC_NORETURN
KiTrapReturn(IN PKTRAP_FRAME TrapFrame)
{
/* Regular interrupt exit */
@@ -361,10 +371,12 @@
[e] "i"(KTRAP_FRAME_EIP)
: "%esp"
);
-}
-
-FORCEINLINE
-VOID
+ exit(0);
+}
+
+FORCEINLINE
+VOID
+DECLSPEC_NORETURN
KiEditedTrapReturn(IN PKTRAP_FRAME TrapFrame)
{
/* Regular interrupt exit */
@@ -393,6 +405,7 @@
[e] "i"(KTRAP_FRAME_ERROR_CODE) /* We *WANT* the error code since ESP
is there! */
: "%esp"
);
+ exit(0);
}
NTSTATUS
Modified: trunk/reactos/ntoskrnl/ke/i386/traphdlr.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/i386/traphdlr.…
==============================================================================
--- trunk/reactos/ntoskrnl/ke/i386/traphdlr.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/ke/i386/traphdlr.c [iso-8859-1] Sun Jan 24 00:59:59 2010
@@ -50,6 +50,7 @@
VOID
FASTCALL
+DECLSPEC_NORETURN
KiExitTrap(IN PKTRAP_FRAME TrapFrame,
IN UCHAR Skip)
{
@@ -235,6 +236,7 @@
VOID
FASTCALL
+DECLSPEC_NORETURN
KiEoiHelper(IN PKTRAP_FRAME TrapFrame)
{
/* Disable interrupts until we return */
@@ -249,6 +251,7 @@
VOID
FASTCALL
+DECLSPEC_NORETURN
KiServiceExit(IN PKTRAP_FRAME TrapFrame,
IN NTSTATUS Status)
{
@@ -267,6 +270,7 @@
VOID
FASTCALL
+DECLSPEC_NORETURN
KiServiceExit2(IN PKTRAP_FRAME TrapFrame)
{
/* Disable interrupts until we return */
@@ -423,6 +427,7 @@
VOID
FASTCALL
+DECLSPEC_NORETURN
KiSystemFatalException(IN ULONG ExceptionCode,
IN PKTRAP_FRAME TrapFrame)
{
@@ -437,6 +442,7 @@
VOID
NTAPI
+DECLSPEC_NORETURN
KiDispatchExceptionFromTrapFrame(IN NTSTATUS Code,
IN ULONG_PTR Address,
IN ULONG ParameterCount,
@@ -477,6 +483,7 @@
VOID
FASTCALL
+DECLSPEC_NORETURN
KiDebugHandler(IN PKTRAP_FRAME TrapFrame,
IN ULONG Parameter1,
IN ULONG Parameter2,
@@ -500,6 +507,7 @@
VOID
FASTCALL
+DECLSPEC_NORETURN
KiNpxHandler(IN PKTRAP_FRAME TrapFrame,
IN PKTHREAD Thread,
IN PFX_SAVE_AREA SaveArea)
@@ -656,6 +664,7 @@
VOID
FASTCALL
+DECLSPEC_NORETURN
KiTrap00Handler(IN PKTRAP_FRAME TrapFrame)
{
/* Save trap frame */
@@ -675,6 +684,7 @@
VOID
FASTCALL
+DECLSPEC_NORETURN
KiTrap01Handler(IN PKTRAP_FRAME TrapFrame)
{
/* Save trap frame */
@@ -694,6 +704,7 @@
}
VOID
+DECLSPEC_NORETURN
KiTrap02(VOID)
{
PKTSS Tss, NmiTss;
@@ -840,6 +851,7 @@
VOID
FASTCALL
+DECLSPEC_NORETURN
KiTrap03Handler(IN PKTRAP_FRAME TrapFrame)
{
/* Save trap frame */
@@ -851,6 +863,7 @@
VOID
FASTCALL
+DECLSPEC_NORETURN
KiTrap04Handler(IN PKTRAP_FRAME TrapFrame)
{
/* Save trap frame */
@@ -870,6 +883,7 @@
VOID
FASTCALL
+DECLSPEC_NORETURN
KiTrap05Handler(IN PKTRAP_FRAME TrapFrame)
{
/* Save trap frame */
@@ -892,6 +906,7 @@
VOID
FASTCALL
+DECLSPEC_NORETURN
KiTrap06Handler(IN PKTRAP_FRAME TrapFrame)
{
PUCHAR Instruction;
@@ -937,6 +952,7 @@
VOID
FASTCALL
+DECLSPEC_NORETURN
KiTrap07Handler(IN PKTRAP_FRAME TrapFrame)
{
PKTHREAD Thread, NpxThread;
@@ -1046,6 +1062,7 @@
VOID
FASTCALL
+DECLSPEC_NORETURN
KiTrap08Handler(IN PKTRAP_FRAME TrapFrame)
{
/* FIXME: Not handled */
@@ -1054,6 +1071,7 @@
VOID
FASTCALL
+DECLSPEC_NORETURN
KiTrap09Handler(IN PKTRAP_FRAME TrapFrame)
{
/* Save trap frame */
@@ -1066,6 +1084,7 @@
VOID
FASTCALL
+DECLSPEC_NORETURN
KiTrap0AHandler(IN PKTRAP_FRAME TrapFrame)
{
/* Save trap frame */
@@ -1080,6 +1099,7 @@
VOID
FASTCALL
+DECLSPEC_NORETURN
KiTrap0BHandler(IN PKTRAP_FRAME TrapFrame)
{
/* Save trap frame */
@@ -1092,6 +1112,7 @@
VOID
FASTCALL
+DECLSPEC_NORETURN
KiTrap0CHandler(IN PKTRAP_FRAME TrapFrame)
{
/* Save trap frame */
@@ -1104,6 +1125,7 @@
VOID
FASTCALL
+DECLSPEC_NORETURN
KiTrap0DHandler(IN PKTRAP_FRAME TrapFrame,
IN ULONG EFlags)
{
@@ -1388,6 +1410,7 @@
VOID
FASTCALL
+DECLSPEC_NORETURN
KiTrap0EHandler(IN PKTRAP_FRAME TrapFrame)
{
PKTHREAD Thread;
@@ -1510,6 +1533,7 @@
VOID
FASTCALL
+DECLSPEC_NORETURN
KiTrap0FHandler(IN PKTRAP_FRAME TrapFrame)
{
/* Save trap frame */
@@ -1520,9 +1544,9 @@
KiSystemFatalException(EXCEPTION_RESERVED_TRAP, TrapFrame);
}
-
-VOID
-FASTCALL
+VOID
+FASTCALL
+DECLSPEC_NORETURN
KiTrap10Handler(IN PKTRAP_FRAME TrapFrame)
{
PKTHREAD Thread;
@@ -1550,6 +1574,7 @@
VOID
FASTCALL
+DECLSPEC_NORETURN
KiTrap11Handler(IN PKTRAP_FRAME TrapFrame)
{
/* Save trap frame */
@@ -1562,6 +1587,7 @@
VOID
FASTCALL
+DECLSPEC_NORETURN
KiTrap13Handler(IN PKTRAP_FRAME TrapFrame)
{
PKTHREAD Thread;
@@ -1664,6 +1690,7 @@
VOID
FASTCALL
+DECLSPEC_NORETURN
KiRaiseAssertionHandler(IN PKTRAP_FRAME TrapFrame)
{
/* Save trap frame */
@@ -1680,6 +1707,7 @@
VOID
FASTCALL
+DECLSPEC_NORETURN
KiDebugServiceHandler(IN PKTRAP_FRAME TrapFrame)
{
/* Save trap frame */
@@ -1694,6 +1722,7 @@
VOID
FASTCALL
+DECLSPEC_NORETURN
KiSystemCall(IN ULONG SystemCallNumber,
IN PVOID Arguments)
{
@@ -1784,6 +1813,7 @@
VOID
FORCEINLINE
+DECLSPEC_NORETURN
KiSystemCallHandler(IN PKTRAP_FRAME TrapFrame,
IN ULONG ServiceNumber,
IN PVOID Arguments,
@@ -1825,6 +1855,7 @@
VOID
__attribute__((regparm(3)))
+DECLSPEC_NORETURN
KiFastCallEntryHandler(IN ULONG ServiceNumber,
IN PVOID Arguments,
IN PKTRAP_FRAME TrapFrame)
@@ -1858,6 +1889,7 @@
VOID
__attribute__((regparm(3)))
+DECLSPEC_NORETURN
KiSystemServiceHandler(IN ULONG ServiceNumber,
IN PVOID Arguments,
IN PKTRAP_FRAME TrapFrame)