WINE for Mac OS X in Development
TylerL82 writes "The Darwine Project aims to get WINE up and running through X11 on Mac OS X/Darwin.
According to the site, WINE itself compiles rather well, and they'll be using Bochs for the actual x86 emulation.
Quite an interesting idea. It's crazy, but it just might work!"
Virtual PC may run reasonably quickly (still not what I'd call 'fast'), but that's because it used a horrible hack. All PPC processors up to and NOT including the G5 were bi-endian. VPC switched their endianness while it was running so it could do everything without swapping bytes. This is both the delay to further VPC releases and the reason x86 emulators will remain quite slow.
I don't know where all this Bochs talk is coming from. I checked the FAQ and looked around some links and never saw it mentioned. QEMU on the other hand seems to be what they're putting in the official release. Maybe Bochs is in there for now for compatibility reasons. QEMU is waaaay faster than bochs, I can't wait til this is packaged up in a DMG that I can recommend to my OS X buddies.
Cwm, fjord-bank glyphs vext quiz
Not necessarily. The technology being chosen is a combination of native code - which can do any necessary 'transitions' to a 'normal' endian mechanism at the API boundary between WINE and the application - and the emulator in question.
The emulator in question is based on something similar to the FX! Alpha code recompiler; it provides an execution environment, yes, but also dynamically recompiles code into native.
Between the core Windows libraries being "native" (in that they're wine lib, and therefore PPC-compiled native on OSX, not native x86) and the remainder in this 'recompiled' code execution environment, it's possible to strip out much of the endian issues.
Not saying they will - only that there's a lot of room to manoeuvre here.
Free.fr, where the project is hosted, is (of course) being slashdotted.
One of the performance metrics lists the QEMU version of gzip (x86 on PPC) being 5 times slower than native (for example) - and comparison to bochs put bochs well behind (however, qemu had no MMU emulation).
-- A mind is a terrible thing.
> the bit-order is going to have to be switched (different endians). This is not fast on a good day
That's byte order, not bit order.
Even on a bad day dealing with byte-reversed integers on a PPC requires just two instructions: Load Byte Reversed and Store Byte Reversed. These replace the Load and Store which PPC uses for native data.
Floating point load/store would suffer, though. You would have to use the integer unit to reverse the bytes, as there is no Load/Store Float Byte Reversed.
Note that data in a PPC register has no endianness, because PPC registers, unlike PPC memory, do not provide byte or bit addressability. (The original POWER processor have an "extract bit" instruction which extracted a bit at (big-endian) position n in a register. This instruction was not carried forward to the PPC.)
The reason QEMU is faster is because of dynamic translation.
Bochs decodes each and every instruction just before it is executed. So if you have a loop that executes 100 times, you have to decode the same instructions 100 times. That's incredibly slow. I have seen estimates that Bochs needs 160,000 native CPU instructions to emulate a single x86 instruction.
QEMU takes a block of code (typically a whole page) and translates the block into the native instruction set. Then it executes the translated block of code. QEMU tries to keep translated blocks around as long as possible, using dirty bits to determine when retranslation is needed. This is the same technique used by VirtualPC on the Macintosh. It is much faster than Bochs!
There is experimental code in Plex86 to do dynamic translation and Bochs can use Plex86 as the backend (it offloads entire pages of code to Plex86). So it's possible that Bochs will one day achieve the performance of QEMU.
Take note that QEMU is usable today, just so long as you're running purely Linux binaries. It is possible to use QEMU to run Linux/x86 binaries on Linux/PPC for example. QEMU's dynamic translation engine is pretty decent. QEMU doesn't emulate the PC hardware. Bochs does emulate the PC hardware. If you could cherry pick the dynamic translation from QEMU and the PC hardware emulation from Bochs then you'd have something to compete with VirtualPC right now.
Unfortunately, the slow part of Bochs is not the front end, it's the emulator. Admittedly, calls to the WINE api will run at native speed, but I imagine that very few windows programs spend most of their time there. Otherwise, expect slowdown of 99% - 99.9%... my G3/600MHz runs console apps in Bochs at around 900kHz equivalent.
I've had this sig for three days.
You are not alone. This is not normal. None of this is normal.
As it's been said here, Wine is not an emulator. The reason it works as well as it does is BECAUSE it's running on x86 hardware. Having it emulate x86 is going to really bog it down. I seriously doubt it will work better than VirtualPC. However, if they can get hardware vidoe acceleration working, then it might just be worth it.
Video acceleration comes free, through a few layers of abstraction. Basically, the windows program will call some Win32 API function
FooDrawTextlpsz(string);
The CPU emulator runs along fine and dandy until it hits this point, and needs to jump to the Win32 native API code. It calls WINE for this.
WINE is a natively compiled PPC application / library, so FooDrawText is just native compiled PPC code.
WINE takes the Win32 function, and uses an Xlib equivalent. XFooMakeStringGetDrawn(string, MONACO) or whatever.
The X server takes this Xlib call, and passes it to the Aqua drawing system, because on Mac OS X, the X Server is just an Application running alongside other native Apps.
So, Aqua draws the text into the window at the correct position, just as windows would on a native system.
This window is treated as a texture object.
The texture is used by the Quartz Compositing engine to draw the window to the screen by using OpenGL.
OpenGL takes the instructions to draw the windows, and hands them off to the video driver.
The video driver then instructs the card to finally draw the window onto the screen, using native commands for the specific card.
Lo and behold, the X86 Win32 request to draw text has resulted in a picture of some letters in our frame buffer.
Egad, I should probably take up baking.
So, anyhow, my point is that the Wine/ppc guys don't need to write an emulator for the video hardware. Though it's heavily abstracted, they get video acceleration for free thanks to the existing Xlib code. The Win32 application never touches the actual video device - it just makes API calls which make things happen to the hardware. Now, if this were a DOS emulator, it'd be completely different. You would need to actually emulate a VGA card that the program can have to itself.