[Mono-dev] Patch for IPAddress.cs
Miguel de Icaza
miguel at novell.com
Sun Mar 25 12:46:31 EDT 2007
> x86 actually has an instruction whose sole purpose is to invert the byte
> order of a 32-bit value. Look up BSWAP. It requires at least a 486, though.
> Does mono otherwise run on 386 CPUs presently? If it is okay to exclude 386
> systems (or they can be detected on-the-fly and given the alternative 3
> instructions), then perhaps it would be possible to do something like
> marking it as an icall and having the JIT recognize that method and inline
> it as just a BSWAP.
I was thinking more about this issue. The JIT has an infrastructure to
inline some well known methods/properties directly with inline assembly,
so the use of something like BSWAP on 486+ should work and could be used
in a few spots like IPAddress, BitConverter and the new DataConverter.
But in general, one of the challenges that we face is that we want to
avoid a exposing new API entry points in any of the core libraries (as
to keep our binaries compatible with .NET).
I can think right now a few options:
* Create a Mono.Core assembly that contains some of these
implementations. The JIT would be aware of the existence
of Mono.Core and inline things accordingly.
The major drawback for this is that it would be another
obnoxious dependency for folks moving code to other runtimes
and also that our own corlib would have to depend on this
assembly (for DataConverter)
* Create a special namespace that the JIT reserves the right to
inline and provide its own implementation, something like
Some special methods here would be recognized as special and
would be hijacked by the JIT, regardless of what the source
code for that method implement.
The deployment model would be: application developers would
have to bundle a monojitintrinsics.cs file with their
software (they would download that from our site if they
need the extra performance boost) and use it in there.
By default the implementation would provide the same
functionality in C# terms.
* Improve the JIT to recognize a particular operation pattern,
and replace that with bswap.
First we would need to identify an implementation that is
the simplest to analyze, and if we can come up with such
a construct, add special support for the JIT to always map
that to an instruction like bswap.
More information about the Mono-devel-list