mirror of
https://github.com/reactos/reactos.git
synced 2024-10-01 06:57:08 +00:00
[KERNEL32]: Optimize SwitchToFiber to simply use "ret" to jump between fibers, instead of saving EIP and doing a JMP.
Bug #50: SwitchToFiber needs to check if FXSR is *NOT* present in order to skip using ldmxcsr/stmxcsr. Previously, it would check if it's unsupported, and jump past the instruction if it was (resulting in invalid opcode instructions on older systems) 50 bugs. Penance has been paid. svn path=/trunk/; revision=52807
This commit is contained in:
parent
8a06cf76c6
commit
7eda2f21b7
|
@ -26,20 +26,16 @@ _SwitchToFiber@4:
|
|||
mov [eax+FIBER_CONTEXT_EDI], edi
|
||||
mov [eax+FIBER_CONTEXT_EBP], ebp
|
||||
|
||||
/* Save the return address */
|
||||
mov ebx, [esp]
|
||||
mov [eax+FIBER_CONTEXT_EIP], ebx
|
||||
|
||||
/* Check if we're to save FPU State */
|
||||
cmp dword ptr [eax+FIBER_CONTEXT_FLAGS], CONTEXT_FULL OR CONTEXT_FLOATING_POINT
|
||||
jnz NoFpuStateSave
|
||||
|
||||
/* Save the FPU State (Status and Control)*/
|
||||
fstsw [eax+FIBER_CONTEXT_FLOAT_SAVE_STATUS_WORD]
|
||||
fstcw [eax+FIBER_CONTEXT_FLOAT_SAVE_CONTROL_WORD]
|
||||
fnstcw [eax+FIBER_CONTEXT_FLOAT_SAVE_CONTROL_WORD]
|
||||
|
||||
/* Check if the CPU supports SIMD MXCSR State Save */
|
||||
cmp byte ptr ds:[PROCESSOR_FEATURE_FXSR], 0
|
||||
cmp byte ptr ds:[PROCESSOR_FEATURE_FXSR], 1
|
||||
jnz NoFpuStateSave
|
||||
stmxcsr [eax+FIBER_CONTEXT_DR6]
|
||||
|
||||
|
@ -103,7 +99,7 @@ StatusWordChanged:
|
|||
ControlWordEqual:
|
||||
|
||||
/* Load the new one */
|
||||
cmp byte ptr ds:[PROCESSOR_FEATURE_FXSR], 0
|
||||
cmp byte ptr ds:[PROCESSOR_FEATURE_FXSR], 1
|
||||
jnz NoFpuStateRestore
|
||||
ldmxcsr [ecx+FIBER_CONTEXT_DR6]
|
||||
|
||||
|
@ -121,7 +117,8 @@ NoFpuStateRestore:
|
|||
mov [edx+TEB_FLS_DATA], eax
|
||||
|
||||
/* Jump to new fiber */
|
||||
jmp dword ptr [ecx+FIBER_CONTEXT_EIP]
|
||||
|
||||
mov esp, [ecx+FIBER_CONTEXT_ESP]
|
||||
ret 4
|
||||
END
|
||||
|
||||
/* EOF */
|
||||
|
|
Loading…
Reference in a new issue