Closed Bug 194187 Opened 23 years ago Closed 23 years ago

64bit unclean code in jsemit.h

Categories

(Core :: JavaScript Engine, defect, P1)

All
Linux
defect

Tracking

()

VERIFIED FIXED
mozilla1.3final

People

(Reporter: pthomas, Assigned: brendan)

Details

(Keywords: 64bit, js1.5)

Attachments

(1 file)

User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; de-AT; rv:1.2.1) Gecko/20021204 Build Identifier: Mozilla/5.0 (X11; U; Linux x86_64; de-AT; rv:1.2.1) Gecko/20021204 jsemit.h has this: #define BITS_PER_PTRDIFF (sizeof(ptrdiff_t) * JS_BITS_PER_BYTE) #define BITS_PER_BPDELTA (BITS_PER_PTRDIFF - 1 - JT_UNTAG_SHIFT) #define BPDELTA_MAX ((ptrdiff_t)(JS_BIT(BITS_PER_BPDELTA) - 1)) And jstypes.h has: /*********************************************************************** ** MACROS: JS_BIT ** JS_BITMASK ** DESCRIPTION: ** Bit masking macros. XXX n must be <= 31 to be portable ***********************************************************************/ #define JS_BIT(n) ((JSUint32)1 << (n)) #define JS_BITMASK(n) (JS_BIT(n) - 1) Which of course leads to gcc warning: warning: left shift count >= width of type when actually using BPDELTA_MAX, as shifting a JSUint32 by 64 bits definitely exceeds its size. I'd propose to change the definition of BPDELTA_MAX to #define BPDELTA_MAX ((ptrdiff_t)(((prtdiff_t)1 << BITS_PER_BPDELTA) - 1)) Reproducible: Always Steps to Reproduce: Just look at the code :)
I forgot to state that this comes from compiling Mozilla on x86-64, aka AMD Hammer, which uses the LP64 model, i.e. long and pointer are 64 bit long, so sizeof(ptrdiff_t) is 8.
Status: UNCONFIRMED → NEW
Ever confirmed: true
same fun on Alpha/Linux
Keywords: 64bit
Hardware: PC → All
Reassigning; cc'ing Brendan -
Assignee: rogerl → khanson
Attached patch proposed fixSplinter Review
Oops. Sorry about that. I don't think two casts are needed -- the inner (ptrdiff_t) cast applied to 1 should suffice to yield the right type for the entire expression that is the macro's definition. Please let me know if this patch is good soon, and I will try to get it into 1.3 final. Thanks, /be
I'll take this. /be
Assignee: khanson → brendan
Severity: normal → critical
Priority: -- → P1
Target Milestone: --- → mozilla1.3final
Attachment #115025 - Flags: review?(shaver)
This is an easy portability fix to get into 1.3final. /be
Flags: blocking1.3?
Keywords: js1.5
Attachment #115025 - Flags: review?(shaver) → review+
Attachment #115025 - Flags: approval1.3?
Comment on attachment 115025 [details] [diff] [review] proposed fix a=asa (on behalf of drivers) for checkin to 1.3
Fixed. /be
Status: NEW → RESOLVED
Closed: 23 years ago
Resolution: --- → FIXED
Marking Verified -
Status: RESOLVED → VERIFIED
Flags: blocking1.3?
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: