Ge van Geldorp wrote:
From: Alex
Ionescu
Ge van Geldorp wrote:
Is this routine so time-critical that we want to
resort to
self-modifying code?
Yup, and there are many more cases where NT does this:
- Syscall vs INT2e
- Cmpxch8 vs cmpxchg x2 + spinlock
- XMMI Page Zeroing vs regular Page Zeroing
- Prefetching
And I'm probably missing more. There are critical APIs that
would be very slow should the check be done each time they are called.
I'm not arguing that we should ban self-modifying code in every case (and I
certainly don't intend to start a vote on it ;-)), the SYSCALL v. INT2E case
is a prime example of where it is useful. However, I was talking about "THIS
routine". Frankly, I don't buy that a routine that is not even called right
now (it was UNIMPLEMENTED()) is so time-critical that we need this. It kills
ROMability of the code, effectively shutting us out of the embedded market
that some people had rather high hopes for.
This is a very good point, but I think there are much bigger problems
then this to get NT loading on a ROM. And a machine with a ROM wouldn't
support this function in either case, so it's a moot point in the end.
This routine is pretty new and that's why it's not called, but from what
I've read on SSE, prefetching is supposed to be an ultra-time critical
operation and the API can be called recursively a large number of times.
It was my opinion that maximing the speed was a good choice. When I
studied the routine under Windows and I saw that a team of over 2 500
hardware and software experts with access to gigantic user bases,
profiling equipment and connections with developers and Intel made the
same decision, it was gratifying. (To be honest, my original idea was to
use "nop" and overwrite it with "ret", but both Patrick (who wrote the
patch) and MS were right in making it a "ret" by default and using
"nop"
to overwrite, since that's even faster).
The fact that NT does this is of
little concern, we only need to be compatible, not identical.
It was of concern to me not because of compatibility, but because it
shows that a team with so many resources agreed with my implementation
(although, like I said before, in an even more optimized way).
To see an example where I disagree with MS (as proof that I'm not
obessesed with copying NT) on a similar self-modifying code issue, take
cmpxch8. I think that the code which MS uses to overwrite entire chunks
of the functions with new assembly code is horribly wrong. I would
implement both functions and then use a function pointer to chose one.
Best regards,
Alex Ionescu
GvG
_______________________________________________
Ros-dev mailing list
Ros-dev(a)reactos.org
http://www.reactos.org/mailman/listinfo/ros-dev