Changeset 5239 in webkit for trunk/JavaScriptCore/kjs


Ignore:
Timestamp:
Oct 22, 2003, 2:31:46 PM (22 years ago)
Author:
mjs
Message:

Merged 64-bit compilation fixes, and fixes for handling negative 0
from upstream kjs.

  • kjs/internal.cpp:
  • kjs/simple_number.h: (KJS::SimpleNumber): fixed constants; added negZero constant. (KJS::SimpleNumber::is): adjusted to use long and not int. (KJS::SimpleNumber::value): ditto. (KJS::SimpleNumber::fits): ditto; also don't allow -0 to fit, so we don't lose the distinction between -0 and +0. (KJS::SimpleNumber::make): adjusted to use long.
Location:
trunk/JavaScriptCore/kjs
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/internal.cpp

    r4909 r5239  
    283283  return (double)uint32 == val;
    284284}
     285
     286double SimpleNumber::negZero = -0.0;
    285287
    286288// ------------------------------ LabelStack -----------------------------------
  • trunk/JavaScriptCore/kjs/simple_number.h

    r3373 r5239  
    2626#include <limits.h>
    2727#include <math.h>
     28#include <string.h>
     29
     30#define IS_NEGATIVE_ZERO(num) (num == 0.0 && !memcmp(&num,&SimpleNumber::negZero,sizeof(double)))
    2831
    2932namespace KJS {
     
    3235    class SimpleNumber {
    3336    public:
    34         enum { tag = 1, shift = 2, mask = (1 << shift) - 1, sign = 1 << 31, max = (1 << (31 - shift)) - 1, min = -max - 1 };
     37        enum { tag = 1, shift = 2, mask = (1 << shift) - 1, sign = 1L << (sizeof(long) * 8 - 1 ), max = (1L << ((sizeof(long) * 8 - 1) - shift)) - 1, min = -max - 1, imax = (1L << ((sizeof(int) * 8 - 1) - shift)) - 1, imin = -imax - 1 };
    3538
    36         static inline bool is(const ValueImp *imp) { return ((int)imp & mask) == tag; }
    37         static inline int value(const ValueImp *imp) { return ((int)imp >> shift) | (((int)imp & sign) ? ~max : 0); }
     39        static inline bool is(const ValueImp *imp) { return ((long)imp & mask) == tag; }
     40        static inline long value(const ValueImp *imp) { return ((long)imp >> shift) | (((long)imp & sign) ? ~max : 0); }
    3841
    39         static inline bool fits(int i) { return i <= max && i >= min; }
     42        static inline bool fits(int i) { return i <= imax && i >= imin; }
    4043        static inline bool fits(unsigned i) { return i <= (unsigned)max; }
    4144        static inline bool fits(long i) { return i <= max && i >= min; }
    4245        static inline bool fits(unsigned long i) { return i <= (unsigned)max; }
    43         static inline bool fits(double d) { return d <= max && d >= min && d == (double)(int)d; }
    44         static inline ValueImp *make(int i) { return (ValueImp *)((i << shift) | tag); }
     46        static inline bool fits(double d) { return d <= max && d >= min && d == (double)(long)d &&
     47                                            !IS_NEGATIVE_ZERO(d); }
     48        static inline ValueImp *make(long i) { return (ValueImp *)((i << shift) | tag); }
    4549    };
    4650}
Note: See TracChangeset for help on using the changeset viewer.