Bug 15761 - Speed up JSImmediate::getTruncated* by using custom float -> int code
Summary: Speed up JSImmediate::getTruncated* by using custom float -> int code
Status: RESOLVED INVALID
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 523.x (Safari 3)
Hardware: Mac OS X 10.4
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-10-30 03:17 PDT by Eric Seidel (no email)
Modified: 2007-11-08 22:59 PST (History)
2 users (show)

See Also:


Attachments
broken fix (3.00 KB, patch)
2007-10-30 03:19 PDT, Eric Seidel (no email)
no flags Details | Formatted Diff | Diff
nearly correct functions (fail two tests) inside test harness (6.36 KB, text/plain)
2007-10-30 19:22 PDT, Eric Seidel (no email)
no flags Details
an actual patch for JSC (same code as in test above) (2.80 KB, patch)
2007-10-30 20:18 PDT, Eric Seidel (no email)
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Eric Seidel (no email) 2007-10-30 03:17:42 PDT
Speed up JSImmediate::getTruncated* by using custom float -> int code

I've written some code for this (attached).  It seems to break sun-spider, even though my printf-debugging seems to suggest my code is correct.  Not sure yet what's wrong.  Anyone should feel free to fix/land this as needed, I probably won't get to look at it for several days.
Comment 1 Eric Seidel (no email) 2007-10-30 03:19:00 PDT
Created attachment 16944 [details]
broken fix
Comment 2 Eric Seidel (no email) 2007-10-30 19:22:06 PDT
Created attachment 16956 [details]
nearly correct functions (fail two tests) inside test harness
Comment 3 Eric Seidel (no email) 2007-10-30 19:23:49 PDT
The test output:

Running JSImmediate::getTruncated* tests, this will take a while.
                       testing : -2147483648 : 1000 0000 0000 0000 0000 0000 0000 0000 
getTruncatedUInt32 -0.000000 expected: 0 (1) got: 0 (0)
                       testing : -822083584 : 1100 1111 0000 0000 0000 0000 0000 0000 
getTruncatedInt32  -2147483648.000000 expected: -2147483648 (1) got: -2147483648 (0)

The first failure is obvious.  Not sure if we need to support it (depending on how 0 is stored in JSImmediate floats), probably though.  The second failure seems to be related to exponent size.
Comment 4 Eric Seidel (no email) 2007-10-30 19:56:55 PDT
FYI, in addition to being slightly wrong... this code is also slightly (but only slightly!) slower than the current float -> int code.  I'm confident that both correctness and speed can be fixed, but I'm a bit tired to do so myself.  Perhaps someone will do so while I'm in Mexico.
Comment 5 Eric Seidel (no email) 2007-10-30 20:18:28 PDT
Created attachment 16957 [details]
an actual patch for JSC (same code as in test above)
Comment 6 Darin Adler 2007-11-08 22:59:14 PST
Oliver got good results by switching our immediate optimization from floating point to int instead.