-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PowerMac G4 hitting illegal instruction #97
Comments
The instructions the G4 processor does not implement are described in the manual http://www.freescale.com/files/32bit/doc/ref_manual/MPC7410UM.pdf Of these, our 32-bit build uses: fsqrt, fcfid |
Hi all, Noob here. I'm continuing from this thread: https://groups.google.com/forum/#!topic/nodejs/ivGMr-C_m1Y As mentioned there, I have a Titanium Powerbook G4 with Linux MintPPC 11 set up with the code and have also identified some fcfid calls. I would like to help with this, and at this point I'm wondering what the accepted method is to add exceptions for the G4. Since I snagged the fcfid instruction first, and after some googling, I was wondering if fctiw would be a place to start. Anyway any pointers on doing this the correct way would be great, Thanks! |
@mike - as you've got some in progress changes to support the G4 just go ahead and make a branch in this repo. We can merge once you've for the bugs worked out. |
I have added the branch g4compat |
I spent a bit of time today looking at the v8 build on a G4 running Ubuntu.
Writing a simple C program:
proves that the basic math library is sane, so I'm guessing the issue is around conversion of then number / rounding - but I haven't put my finger on the exact problem yet. Given that Mike was 'hacking' in the branch https://github.com/andrewlow/v8ppc/tree/g4compat there might be a bit of work to merge this without breaking things. |
@andrewlow Be careful that printf() isn't rounding the answer in your C program. Try this to check:
Here we can compare the precise hexadecimal representation of 0.1 and sqrt(0.01) and see by eye any difference. This is actually not so easy to do (particularly with confidence) when using a decimal representation. |
@tunniclm good point One of our Power7 Linux machines
The G4
|
I've done more digging - I think the C program is mis-leading us. In JS the Math.sqrt() calls maps down to a call v8::internal::fast_sqrt, which in turn is a call to the C library sqrt(). On Power7 the object that comes back has this hex value for the double:
on the G4
I'm starting to wonder if we've left the FPSCR state in the wrong mode?
G4
It appears the difference between the two registers is the FR bit ( "Floating-point fraction rounded. The last arithmetic or rounding and conversion instruction that rounded the intermediate result incremented the fraction." ) This makes sense as the Power7 result has been rounded and the FR bit is set appropriately. I think this is proof the C math library is giving us an unexpected answer, looking at the state of FPSCR prior to making the call to the C math library, we're using the same RN (rounding mode) of 00. (round to nearest) |
I modified the simple C program above to demonstrate the issue we're seeing. (don't forget to link the math library with -lm)
Power7
G4
When we pass in the 0.01 value in a double (as a variable) the G4 doesn't round it correctly (where correctly is defined as how the V8 tests expect it to work). |
The following hits an illegal instruction
Seems to be a problem with fsqrt
The text was updated successfully, but these errors were encountered: